-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
关于创建void * 参数传递和结构体图片数据问题 #47
Comments
关于指针的内容请查看DataType.External以及createPointer等相关api |
结果是通过参数传递,不是通过返回值,我看文档 |
1、DataType.Void不等于void*指针,一个代表空值一个代表通用类型指针,虽然也可以创建一个空值指针再写入值 |
` unsigned long __declspec(dllimport) __stdcall elist(ListRef* ListRef) DataType.Void 是一个类型,在使用createPointer时候,我理解为创建一个该类型的指针,但是该方法一定需要传入值 |
ListRef是结构体指针,你需要创建一个结构体指针传入 |
__edObject 这个结构体是对外隐藏的,我只需要获取到这个句柄即可,构建一个结构体指针,我需要如何做,因为我并不知道这个结构里面有什么 |
const vp = createPointer({ paramsType: [DataType.Void], paramsValue: [''] }) }); paramsValue: vp,试试 |
这样的话进程直接崩溃了 |
C++ 定义,_ _EdsObject * 是私有结构体,实际使用过程中只需要获取该指针句柄即可 typedef struct __EdsObject* EdsBaseRef;
typedef EdsBaseRef EdsCameraListRef;
typedef long EdsInt32;
typedef EdsUInt32 EdsError;
EdsError EDSAPI EdsGetCameraList( EdsCameraListRef* outCameraListRef );
EdsError EDSAPI EdsGetChildCount( EdsBaseRef inRef,EdsUInt32* outCount ); 第一种函数不使用void* 利用,如下 let po = createPointer({
paramsType: [DataType.WString],
paramsValue: [""]
})
load({
library: 'EDSDK',
funcName: 'EdsGetCameraList',
retType: DataType.U64,
paramsType: [DataType.External],
paramsValue: po,
errno: true,
}) 解决,但是这个指针怎么传递呢后续如下 load({
library: 'EDSDK',
funcName: 'EdsGetChildCount',
retType: DataType.U64,
paramsType: [DataType.External, DataType.External],
paramsValue: [po,countNum],
errno: true,
}) 这样传递就会出现go object,括号去除就会出现params_type length is not equal with params_value length, |
const vp = createPointer({ paramsType: [DataType.Void], paramsValue: [''] })在语义上等价于ffi-napi中的ref.void,本质都是创建一个指针指向未初始化的数据。 createPointer({ 创建的是指向字符串的指针,字符串数据在c语言中本身就是char*类型的指针。也就是说你上面的createPointer代码实际是创建了一个wchar**类型的指针。 |
ImageData { int width; int height; int channels; unsigned char *data; };
在ffi-napi 中 是通过base64 转换成 buffer 后,放入上面结构体中 通过 ImageData.ref() 传入到函数中
The text was updated successfully, but these errors were encountered: