繁体   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