我有一个共享的C库,期望unsigned char *
作为参数之一
将Javascript字符串作为unsigned char *的最佳方法是什么?
在我的js文件中,我将参数声明为ctypes.unsigned_char.ptr,但它不会只是将javascript字符串作为参数传递
这一切都是在firefox扩展的上下文中完成的。这是我对函数的声明
var myfunction = mylib.declare("function",
ctypes.default_abi,
ctypes.int,
ctypes.unsigned_char.ptr,
ctypes.long);
其中mylib是var i,它使用ctypes模块加载了共享库。
答案 0 :(得分:1)
以下should work:
ctypes.uint8_t
。ctypes.uint8_t.ptr(new Uint8Array(...))
。