刚刚开始深入研究 SIP。我有一个 .h 文件,其中包含以下公共方法:
void Allocate(int width, int height, int pitch, bool withHost, float *devMem = NULL, float* hostMem = NULL);
我创建了一个相应的 .sip 文件:
1 //SIP wrapper for CUDA Image
2
3 class CudaImage
4 {
5 %TypeHeaderCode
6 #include "cudaImage.h"
7 %End
8
9 public:
10 CudaImage();
11
12 void Allocate(int width, int height, int pitch, bool withHost, float *devMem=NULL, float *hostMem=NULL) /KeywordArgs="All"/;
13 double Download();
14
15
16 int width;
17 int height;
18 int pitch;
19 };
使用 CMake,我可以构建工作,可以将模块导入 Python 并可以调用构造函数(成功有限)。我也可以调用 Allocate 方法。不幸的是,在 Python 方面,我无法暴露float *devMem=NULL
orfloat *hostMem=Null
参数。我已经浏览过 SIP 文档,并且没有任何注释因为缺失而跳出来。
最终目标是将一个numpy数组(我相信.data属性)传递给hostMem
参数。
如何在 SIP 中公开指针?带有默认 NULL 参数的指针呢?
(Python 3.5、PyQt4、SIP 4.18.x)