|
From: Alexis H. Rivera-R. <ahr...@ya...> - 2005-08-03 19:48:44
|
Hi,
I'm trying to expose my own class that uses gmtl
objects.
This is an example:
struct Test
{
gmtl::Vec3d x;
gmtl::Point3d y;
Test()
: x(0,0,0),y(0,0,0) {}
Test(const Test &other)
: x(other.x),
y(other.y){}
Test& operator=(const Test& other)
{
if (this==&other)
return *this;
x = other.x;
y = other.y;
}
};
Im exposing the class like this:
class_< Test >("Test", init< >())
.def(init< const Test& >())
.def_readwrite("x", &Test::x)
.def_readwrite("y", &Test::y)
;
But this fails:
>>> import gmtl
>>> from PyStatATA import *
>>> test = Test()
>>> test.x = gmtl.Vec3d(0,0,1)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
Boost.Python.ArgumentError: Python argument types in
None.None(Test, Vec3d)
did not match C++ signature:
None(struct Test {lvalue}, class
gmtl::Vec<double,3>)
>>> test.y = gmtl.Point3d(0,0,1)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
Boost.Python.ArgumentError: Python argument types in
None.None(Test, Point3d)
did not match C++ signature:
None(struct Test {lvalue}, class
gmtl::Point<double,3>)
>>> my = test.y
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: No Python class registered for C++ class
class gmtl::Point<double,3>
>>> mx = test.x
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: No Python class registered for C++ class
class gmtl::Vec<double,3>
I'm assuming somehow, I need to define converters from
the gmtl types to python and viceversa. But, it seems
that this has probably been done in your bindings.
Can you suggest me a way of letting python know that
the gtml types have already being defined?
Has anybody done something like this before?
Thanks,
Alexis
Programming Tutorial:
In Python: To do this, do this
In Perl: To do this, do this or this or this or this...
In C: To do this, do this, but be careful
In C++: To do this, do this, but don't do this, be careful of this, watch out for this, and whatever you do, don't do this
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs
|