[英]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
找到它的類,但是我找不到如何使用它的示例。
如果使用普通的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
將導致異常。
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.