[C++-sig] [Py++] registration order problem in constructor

Werner Joergensen wjoergensen at yahoo.com
Tue Jun 9 22:43:53 CEST 2009


Thanks! I can't express my gratitude for your help on this list.
I think my questions are answered. I'll see if I can implement your solutions.

Werner


> > But would you mind mentioning the other alternatives? My aim is to construct 
> the class like the "t=testmodule.Test("Hello")" above.
> 
> In my opinion, you are working with "tricky" overloading - "char",
> "char*" and "std::string". I could be wrong, but Python doesn't have
> type "char", but string and unicode. So may be you should not expose
> "Test(char)" and "Test(char*)" constructors at all. Anyway,
> "pure/poor" Python user will/should not understand the difference
> between those constructors.
> 
> Another option, could be to create a Python class which derives from
> the Test class ( you can rename it ) and implement dispatch logic by
> yourself. You also can create fake constructor in C++, which takes
> boost::python::object and makes the desired dispatching.
> 
> > I was not able to use the suggested "create_*" functions as fake constructors 
> "test.add_fake_constructors( mb.calldefs( 'create_test_from_char' ) )". Do they 
> have to return an auto_ptrfor this purpose?
> 
> Yes. It was my mistake, sorry.
> 
> HTH
> 
> -- 
> Roman Yakovenko
> C++ Python language binding
> http://www.language-binding.net/
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig at python.org
> http://mail.python.org/mailman/listinfo/cplusplus-sig



      


More information about the Cplusplus-sig mailing list