簡體   English   中英

如何使用python SVN API SWIG綁定調用svn.client.svn_client_list2?

[英]How can I call the svn.client.svn_client_list2 with python SVN API SWIG bindings?

問題

如何通過SVN API SWIG綁定從python調用svn_client_list2 C API函數?

問題描述

我可以從svn.client模塊中找到該函數,但是調用它是個問題 ,因為它使用的回調函數是typedef svn_client_list_func_t ,我不知道如何在python中使用該typedef。

盡管我可以從svn.client.svn_client_list_func_t以及svn.client.svn_client_list_func_tPtr找到它的類,但是我找不到如何使用它的示例。

svn.client.svn_client_list2的用法不正確

如果使用普通的python函數作為回調參數調用svn.client.svn_client_list2函數,則會出現錯誤。

 import svn.core, svn.client path = svn.core.svn_path_canonicalize("/path/to/a/working_copy/") pool = svn.core.Pool() ctx = svn.client.svn_client_create_context(pool) revision = svn.core.svn_opt_revision_t() SVN_DIRENT_ALL = 0xffffffffl def _handle_list(path, dirent, abs_path, pool): print(path, dirent, abs_path, pool) svn.client.svn_client_list2(path, revision, revision, svn.core.svn_depth_infinity, SVN_DIRENT_ALL, True, _handle_list, ctx, pool) 

TypeError: argument number 7: a 'svn_client_list_func_t *' is expected, 'function(<function _handle_list at 0x01365270>)' is received

svn.client.svn_client_list_func_t的用法不正確

嘗試初始化svn.client.svn_client_list_func_t將導致異常。

 callback_function = svn.client.svn_client_list_func_t() 

RuntimeError: No constructor defined

我如何進行想法?

看來您目前無法真正做到這一點。 當我深入研究SWIG綁定代碼和文檔時,它說,當您將目標語言函數用作回調函數時,就需要像SWIG文檔中所述的那樣為其輸入類型圖:

盡管SWIG通常不允許使用目標語言編寫回調函數,但是可以使用類型映射和其他高級SWIG功能來實現。

似乎Python缺少它...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM