Python 3.x Python/SIP规范文件-kwargs和NULL

Python 3.x Python/SIP规范文件-kwargs和NULL,python-3.x,python-sip,Python 3.x,Python Sip,刚刚开始深入研究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 #in

刚刚开始深入研究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
float*hostMem=NULL
参数。我已经阅读了SIP文档,没有任何注释遗漏

最终目标是将numpy数组(.data属性)传递给
hostMem
参数

如何在SIP中公开指针?带默认参数NULL的指针呢


(Python3.5、PyQt4、SIP4.18.x)

我已经用ctypes.POINTER解决了这个问题


您可以为空指针传入None。

我已经用ctypes.pointer解决了这个问题

您可以为空指针传入None。

您可以尝试“/in/”注释:

void Allocate(int width, int height, int pitch, bool withHost, float* devMem /In/ = NULL, SIP_PYOBJECT *hostMem /In/ = NULL) /KeywordArgs="All"/;
请告诉我它是否有效。

您可以尝试“/In/”注释:

void Allocate(int width, int height, int pitch, bool withHost, float* devMem /In/ = NULL, SIP_PYOBJECT *hostMem /In/ = NULL) /KeywordArgs="All"/;
请让我知道它是否有效