Thread: [pygccxml-development] 2 Questions
Brought to you by:
mbaas,
roman_yakovenko
From: Allen B. <al...@vr...> - 2006-09-12 16:04:16
|
I have two questions that I am surprised I haven't run into before. I hope that both have easy answers. 1. Base class virtual ignored, but coming in inside derived class wrappers. I have a base class and derived class like: struct Base { virtual const int* getData() const = 0; }; struct Child : public Base { } struct GrandChild : public Child { virtual const int* getData() const; } In my py++ generation script I ignore the getData decl in the Base class (and the GrandChild). But py++ still ends up generating wrapper code for getData for the Child class. To make matters worse, since it is not a decl for getData in the Child class I can not ignore it there. It is almost like Py++ is seeing the virtual method and deciding that it needs to provide a wrapper for it in Child even though it is ignored in Base. Is this a bug in Py++ or is there some way that I can take care of this. 2. The alternative option would be to just wrap the method correctly, but how can I wrap returning a memory buffer (array) of arbitrary length? Is there a way to wrap this method so it will return a const wrapper around this data buffer to make it look like a python list? If so what is the easiest way to do it and do I really need to wait for MB's method transformer code to do it right? Thanks for you help. I am sorry if either of these seems like a really basic question, I just haven't run into this before. -Allen |
From: Roman Y. <rom...@gm...> - 2006-09-12 18:08:28
|
On 9/12/06, Allen Bierbaum <al...@vr...> wrote: > I have two questions that I am surprised I haven't run into before. I > hope that both have easy answers. > > 1. Base class virtual ignored, but coming in inside derived class wrappers. > > I have a base class and derived class like: > > struct Base > { > virtual const int* getData() const = 0; > }; > > struct Child : public Base > { } > > struct GrandChild : public Child > { > virtual const int* getData() const; > } > > In my py++ generation script I ignore the getData decl in the Base class > (and the GrandChild). But py++ still ends up generating wrapper code > for getData for the Child class. To make matters worse, since it is not > a decl for getData in the Child class I can not ignore it there. It is > almost like Py++ is seeing the virtual method and deciding that it needs > to provide a wrapper for it in Child even though it is ignored in Base. > Is this a bug in Py++ or is there some way that I can take care of this. Do you know how hard I work to implement this? Basically this is because wrapper classes could not be abstract. Also untill now I didn't have use case where user ignore some method. May be I will have to take a look on it. > > 2. The alternative option would be to just wrap the method correctly, > but how can I wrap returning a memory buffer (array) of arbitrary length? > > Is there a way to wrap this method so it will return a const wrapper > around this data buffer to make it look like a python list? If so what > is the easiest way to do it and do I really need to wait for MB's method > transformer code to do it right? You don't have to wait, you can join and help :-). Take a look on TnFOX Python bindings, they deal with the same problem ( image classes ). It uses indexing suite v2 to solve the problem. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Allen B. <al...@vr...> - 2006-09-12 18:19:58
|
Roman Yakovenko wrote: > On 9/12/06, Allen Bierbaum <al...@vr...> wrote: > >> I have two questions that I am surprised I haven't run into before. I >> hope that both have easy answers. >> >> 1. Base class virtual ignored, but coming in inside derived class >> wrappers. >> >> I have a base class and derived class like: >> >> struct Base >> { >> virtual const int* getData() const = 0; >> }; >> >> struct Child : public Base >> { } >> >> struct GrandChild : public Child >> { >> virtual const int* getData() const; >> } >> >> In my py++ generation script I ignore the getData decl in the Base class >> (and the GrandChild). But py++ still ends up generating wrapper code >> for getData for the Child class. To make matters worse, since it is not >> a decl for getData in the Child class I can not ignore it there. It is >> almost like Py++ is seeing the virtual method and deciding that it needs >> to provide a wrapper for it in Child even though it is ignored in Base. >> Is this a bug in Py++ or is there some way that I can take care of this. > > > Do you know how hard I work to implement this? Basically this is because > wrapper classes could not be abstract. Also untill now I didn't have > use case > where user ignore some method. May be I will have to take a look on it. Can you give me a pointer to where the logic for this is so I can take a look at fixing it? > >> >> 2. The alternative option would be to just wrap the method correctly, >> but how can I wrap returning a memory buffer (array) of arbitrary >> length? >> >> Is there a way to wrap this method so it will return a const wrapper >> around this data buffer to make it look like a python list? If so what >> is the easiest way to do it and do I really need to wait for MB's method >> transformer code to do it right? > > > You don't have to wait, you can join and help :-). Take a look on > TnFOX Python > bindings, they deal with the same problem ( image classes ). It uses > indexing > suite v2 to solve the problem. > This will probably be the long term solution for me. Right now I just need to get my bindings compiling again so I can get some short term work done. Thanks, Allen |
From: Roman Y. <rom...@gm...> - 2006-09-12 18:24:25
|
On 9/12/06, Allen Bierbaum <al...@vr...> wrote: > Can you give me a pointer to where the logic for this is so I can take a > look at fixing it? creator_t.redefine_funcs Please post the fix to the list. The code in this specific function is too fragile. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Allen B. <al...@vr...> - 2006-09-12 19:01:02
|
Allen Bierbaum wrote: >Roman Yakovenko wrote: > > > >>On 9/12/06, Allen Bierbaum <al...@vr...> wrote: >> >> >> >>>I have two questions that I am surprised I haven't run into before. I >>>hope that both have easy answers. >>> >>>1. Base class virtual ignored, but coming in inside derived class >>>wrappers. >>> >>>I have a base class and derived class like: >>> >>>struct Base >>>{ >>> virtual const int* getData() const = 0; >>>}; >>> >>>struct Child : public Base >>>{ } >>> >>>struct GrandChild : public Child >>>{ >>> virtual const int* getData() const; >>>} >>> >>>In my py++ generation script I ignore the getData decl in the Base class >>>(and the GrandChild). But py++ still ends up generating wrapper code >>>for getData for the Child class. To make matters worse, since it is not >>>a decl for getData in the Child class I can not ignore it there. It is >>>almost like Py++ is seeing the virtual method and deciding that it needs >>>to provide a wrapper for it in Child even though it is ignored in Base. >>>Is this a bug in Py++ or is there some way that I can take care of this. >>> >>> >>Do you know how hard I work to implement this? Basically this is because >>wrapper classes could not be abstract. Also untill now I didn't have >>use case >>where user ignore some method. May be I will have to take a look on it. >> >> > >Can you give me a pointer to where the logic for this is so I can take a >look at fixing it? > > Ok, this didn't work out so well. I found a way to ignore these methods but this made it so the wrapper didn't generate a function at all. Which in turn makes the wrapper a pure class that can be instantiated and thus the compile fails. It seems like what I would want here is for the wrapper class to generate a method but then for the exposer for the real class to not generate bindings for that method. Unfortunately I don't see a way to do this right now. :( -Allen > > >>>2. The alternative option would be to just wrap the method correctly, >>>but how can I wrap returning a memory buffer (array) of arbitrary >>>length? >>> >>>Is there a way to wrap this method so it will return a const wrapper >>>around this data buffer to make it look like a python list? If so what >>>is the easiest way to do it and do I really need to wait for MB's method >>>transformer code to do it right? >>> >>> >>You don't have to wait, you can join and help :-). Take a look on >>TnFOX Python >>bindings, they deal with the same problem ( image classes ). It uses >>indexing >>suite v2 to solve the problem. >> >> >> >This will probably be the long term solution for me. Right now I just >need to get my bindings compiling again so I can get some short term >work done. > >Thanks, >Allen > > >------------------------------------------------------------------------- >Using Tomcat but need to do more? Need to support web services, security? >Get stuff done quickly with pre-integrated technology to make your job easier >Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >_______________________________________________ >pygccxml-development mailing list >pyg...@li... >https://lists.sourceforge.net/lists/listinfo/pygccxml-development > > > |
From: Roman Y. <rom...@gm...> - 2006-09-12 19:06:54
|
On 9/12/06, Allen Bierbaum <al...@vr...> wrote: > Ok, this didn't work out so well. I found a way to ignore these methods > but this made it so the wrapper didn't generate a function at all. > Which in turn makes the wrapper a pure class that can be instantiated > and thus the compile fails. It seems like what I would want here is for > the wrapper class to generate a method but then for the exposer for the > real class to not generate bindings for that method. Unfortunately I > don't see a way to do this right now. :( You mean in class wrapper to create the function, but after this in class_<...> not to register it right? Well the function is registered only in base class -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |