[C++-sig] Pyste: wrapper function for overloaded function problems

paul.bridger paul.bridger at paradise.net.nz
Thu Jun 24 00:31:50 CEST 2004


Hi,

I've just done a diff of my Pyste vs. CVS. There are a few small improvements 
I've made.

Two in ClassExporter.py:
The problem described below was easy to fix:
ClassExporter.py: 375
             if method.minArgs != method.maxArgs:
# here pyste adds overload declarations and creates extra argument to def()
becomes
             if method.minArgs != method.maxArgs and not method_info.wrapper:
# so we nolonger do this if the method has a wrapper

This worked fine for me, but I am nolonger using (and hence testing) this 
change every day. I was writing function/method wrappers for functions that 
took a customised string implementation, but I stopped doing this when I 
found I couldn't write constructor wrappers (AFAIK). Now everything is 
consistently unwrapped.

A diff snippet for that:
375c381
<             if method.minArgs != method.maxArgs:
---
 >             if method.minArgs != method.maxArgs and not method_info.wrapper:


I also noticed that for inherited virtual methods, Pyste would not:
a) warn about lack of defined policies, and
b) register the default policy when it could

Here is the fix:

778,779c787,792
<         # Add policy to overloaded methods also
<         policy = self.info[method.name].policy or ''
---
 >         # warn the user if this method needs a policy and doesn't have one
 >         method_info = self.info[method.name]
 >         method_info.policy = exporterutils.HandlePolicy(method, 
method_info.policy)
 >
 >         # Add policy to overloaded methods also
 >         policy = method_info.policy or ''


There was also a change in GCCXMLParser.py. I posted to C++-Sig about this a 
little while ago:
http://aspn.activestate.com/ASPN/Mail/Message/c++-sig/2088336

GCCXMLParser.py
280c280
<             if type(decl) in Class.ValidMemberTypes():
---
 >             if type(decl) in Class.ValidMemberTypes() and decl.name != '':


Thanks.
Paul Bridger


Nicodemus wrote:
> Hi Paul, sorry about the delay,
> 
> paul.bridger wrote:
> 
>> I am trying to expose a C++ member function with a bunch of default 
>> arguments, but I also want to provide a C++ wrapper for it.
>> The problem I've had is that Pyste still generates the overload 
>> machinery even though it's not wanted since my wrapper function takes 
>> different arguments.
>>
>> Any hints? I'm going digging in the Pyste source.
> 
> 
> 
> You want to take a look at the method ExportMethods in ClassExporter.py. ;)
> Patches are welcome, as always!
> 
> Regards,
> Nicodemus.
> 
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
> 
> 











More information about the Cplusplus-sig mailing list