FAQ
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

Search Discussions

  • Thomas Jollans at Jun 10, 2010 at 3:50 pm

    On 06/10/2010 05:15 PM, Murrgon wrote:
    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)
    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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJun 10, '10 at 3:15p
activeJun 10, '10 at 3:50p
posts2
users2
websitepython.org

2 users in discussion

Murrgon: 1 post Thomas Jollans: 1 post

People

Translate

site design / logo © 2021 Grokbase