我正在尝试包装一个需要传递给它的结构数组的C函数。
我的.i文件中的函数定义是:
extern HRESULT WINAPI ScriptItemize(
const WCHAR *pwcInChars, // In Unicode string to be itemized
int cInChars, // In Codepoint count to itemize
int cMaxItems, // In Max length of itemization array
const SCRIPT_CONTROL *psControl, // In Analysis control (optional)
const SCRIPT_STATE *psState, // In Initial bidi algorithm state (optional)
SCRIPT_ITEM *pItems, // Out Array to receive itemization
int *pcItems); // Out Count of items processed (optional)之前已经在.i文件中定义了结构SCRIPT_CONTROL、SCRIPT_STATE和SCRIPT_ITEM。
我可以通过包含以下行来指示pcItems是一个返回值:
%include <typemaps.i>
%apply int *OUTPUT {int *pcItems};但是,尝试对pItems执行相同的操作:
%apply SCRIPT_ITEM *OUTPUT {SCRIPT_ITEM *pItems};我得到这样的警告:
Can't apply (SCRIPT_ITEM *OUTPUT). No typemaps are defined.如何指示pItems是返回值?
另外,如何在Python中创建SCRIPT_ITEM结构的数组?
发布于 2012-12-24 20:11:05
我已经设法找到了这样做的方法,将我的.i文件修改如下:
%include <carrays.i>
%array_class(SCRIPT_ITEM, SCRIPT_ITEM_ARRAY);
extern HRESULT WINAPI ScriptItemize(
const WCHAR *pwcInChars, // In Unicode string to be itemized
int cInChars, // In Codepoint count to itemize
int cMaxItems, // In Max length of itemization array
const SCRIPT_CONTROL *psControl, // In Analysis control (optional)
const SCRIPT_STATE *psState, // In Initial bidi algorithm state (optional)
SCRIPT_ITEM_ARRAY *pItems, // Out Array to receive itemization
int *pcItems); // Out Count of items processed (optional)https://stackoverflow.com/questions/14020922
复制相似问题