Re: [pygccxml-development] Using pyplusplus with indexing suite
Brought to you by:
mbaas,
roman_yakovenko
From: Allen B. <al...@vr...> - 2006-05-17 14:58:39
|
Roman Yakovenko wrote: > On 5/17/06, Allen Bierbaum <al...@vr...> wrote: > >> I have a function class method that I am trying to wrap with pyplusplus. >> >> The method is similar to: >> >> std::vector< boost::shared_ptr< ClassA > > MyClass::getData(); >> >> I would like to use the indexing suite or something similar to make it >> possible to iterate over and use this list from python. Is there any >> support for this directly in pyplusplus or can anyone tell me what I >> need to do custom to allow this? > > > There are 2 ways to solve the problem. I will not like both of them. > > 1. Add custom code to class A: > > class_<std::vector< boost::shared_ptr<A> > >("AVec") > .def(vector_indexing_suite<std::vector< std::vector< > boost::shared_ptr<A> > > >()) > ; > > And then from Python create a reference from global scope to it: > > AVec = A.AVec > > http://boost.org/libs/python/doc/v2/indexing.html I will have to try this one. I have to admit the code sample above doesn't make sense yet, but I will re-read the indexing documentation and see if I can figure it out. > > 2. I will accept the patch. Now when I think about it, it should be > fairly simple. > 1. There is a need for vector_indexing_suite_ code creator. > 2. After this small modification should be done to types_database_t. > It should recognize, that data type is vector or map. > pygccxml.declarations.templates parser will do the job easier > 3. Modify module_creator.creator_t class > > I am running out of time, otherwise I would implement the patch by > myself. > I think it should take like 3-5 hours. > Unfortunately I am not skilled enough to implement this. It is one thing to make patches that change interfaces slightly or fix small parts of code, it is an entirely different thing to understand the full code base and add a large new capability. :) I wish I had time to learn the code that well, but I do not right now. Sorry. :( Thanks for your help. -Allen |