Hi,

I am trying to get a c++ pointer to a python object.

I am using DirectPython, and a function in that library, getDevice(), "returns the address of the object" - a IDirect3DDevice9*, already created using DirectPython code.

Using boost::python, I have an extension module function with this
signature:

// c++
void TestClass::Init( IDirect3DDevice9* device );

I tried to call this function with:

#python, called after device is created:
from testClass import TestClass
test = TestClass()
test.Init( d3d.getDevice() )

Here's the error I get:
##################
Traceback (most recent call last):
  File "client.py", line 31, in __init__
    test.Init(d3d.getDevice())
Boost.Python.ArgumentError: Python argument types in
    TestClass.Init(TestClass, long)
did not match C++ signature:
    Init(class TestClass {lvalue}, struct IDirect3DDevice9 *)
##################

But got a type mismatch. DirectPython gives the address as a long, when c++ wants a pointer to a struct.

I then tried this with the same python calling code:

void TestClass::Init(void* deviceAddress)
{
IDirect3DDevice9* m_device = static_cast<IDirect3DDevice9*>(deviceAddress);
}

Of course I get a similar error:

##################
Traceback (most recent call last):
  File "client.py", line 33, in __init__
    test.Init(d3d.getDevice())
Boost.Python.ArgumentError: Python argument types in
    TestClass.Init(TestClass, long)
did not match C++ signature:
    Init(class TestClass {lvalue}, void *)
##################

How can I get the address from python to c++?

Thanks

Simon
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to