Re: [pygccxml-development] How to manage wrapper classes?
Brought to you by:
mbaas,
roman_yakovenko
From: Matthias B. <ba...@ir...> - 2006-03-27 08:14:55
|
Roman Yakovenko wrote: > First of all I think you should be able to create custom call policies. > Take a look on this link: > http://boost.org/libs/python/doc/v2/CallPolicies.html#CallPolicies-concept > > May be, this will be enough, I am not sure. Interesting idea. From reading the above page I couldn't say if it is possible or not. precall() and postcall() are supposed to manage Python tuples which might indicate that they cannot access the original arguments....? Well, anyway, I posted a message to the c++-sig list, let's see what the "experts" have to say about this. >> So how should that be accomplished? > > There are 2 other ways to solve this problem. > 1. Create small wrappers in Python. I do not know exactly how it should be done. > But, I feel that this is the right way to go. I hope some days > pyplusplus will have > 3'rd tree - Python code creators ( they will generate Python code ). I have also thought about that and I might even get away with this for the Maya SDK, but in general, I think the problem would be that those Python wrappers would only be active when the object was created on the Python side and not on the C++ side. > 2. Create small wrapper in C++, in the way you did it. Just put that declaration > in some namespace and add it to using add_code functions. But as I don't want to create the wrappers manually, how could I add wrappers that I generate automatically to the generated source files (not the main file)? > Using this > approach you should be carefull. There are so many cases, while exporting > some function to Python. By the way, do we talk about pure virtual > functions or overloaded ones? What do you mean? The functions are not pure virtual, they are already implemented in the Maya SDK and I only need to access them. They are neither overloaded.... maybe I didn't understand the actual question...? >> (and how can it be guaranteed that >> the user's wrapper code doesn't interfere with the wrapper code that >> might already get generated by pyplusplus?) > > 1. Do you still want to expose functions that returns, take by > reference MStatus object? Uhm, yes? (that's what my mail was about...?) > If the answer is not then we can add replace_code function to decl_wrapper_t > class. Then pyplusplus will generate that code. What code would replace_code() replace? > If the answer is yes, then you have a problem. It seems to me that pyplusplus > contains all tools in order to solve this problem, may be it does not > expose good interface ( we will find out, right :-) ). I hope so. :) Well, I hope I'll get an answer to my mail on the c++-sig list so that we'll see if explicit wrappers are definitely required or not. - Matthias - |