Py++, boost and python type mismatch error

M

Murrgon

I have a simple C++ library (from a dll) I am attempting to make accessible
through bindings to python. I used Py++ to generate some boost code for the
library that I compiled into a pyd. I can import the pyd no problem into
python, but I can't seem to call the functions.

struct MM_Api
{
void* pData;
};

int declspec(dllimport) MM_Initialize( MM_Api* pApi );

I made a PyMM.pyd that has this in it.

import PyMM
api = PyMM.MM_Api
ret = PyMM.MM_Initialize(api)

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Boost.Python.ArgumentError: Python argument types in
PyMM.MM_Initialize(Boost.Python.class)
did not match C++ signature:
MM_Initialize(struct MM_Api * pApi)

The docs for Py++ leave a lot guess work up to the user, so I don't know if I
forgot a step, or messed something up. Is there some glue I need to
write/generate that will translate an instance of PyMM.MM_Api to the C++
version of MM_Api, and if so, is this python glue, or C/C++ glue?

Thank you
Murrgon
 
T

Thomas Jollans

I have a simple C++ library (from a dll) I am attempting to make
accessible through bindings to python. I used Py++ to generate some
boost code for the library that I compiled into a pyd. I can import the
pyd no problem into python, but I can't seem to call the functions.

struct MM_Api
{
void* pData;
};

int declspec(dllimport) MM_Initialize( MM_Api* pApi );

I made a PyMM.pyd that has this in it.

import PyMM
api = PyMM.MM_Api
ret = PyMM.MM_Initialize(api)

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Boost.Python.ArgumentError: Python argument types in
PyMM.MM_Initialize(Boost.Python.class)
did not match C++ signature:
MM_Initialize(struct MM_Api * pApi)

Just guessing here: maybe you meant to type

import PyMM
api = PyMM.MM_Api()
ret = PyMM.MM_Initialize(api)

(initializing the MM_Api and passing the object instead of the class)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top