Re: [pygccxml-development] Question about calldef_wrapper_t.argument_name()
Brought to you by:
mbaas,
roman_yakovenko
From: Roman Y. <rom...@gm...> - 2006-09-14 18:27:30
|
On 9/14/06, Matthias Baas <ba...@ir...> wrote: > Hi, > > while going through the Py++ sources I wondered about the method > argument_name() in class calldef_wrapper_t. Here is its definition: > > def argument_name( self, index ): > arg = self.declaration.arguments[ index ] > if arg.name: > return arg.name > else: > return 'p%d' % index > > What I wondered is if the 'else' block is ever reached? I searched in > scanner.py where the argument_t class is actually used and found this: > > argument = argument_t() > argument.name = attrs.get( XML_AN_NAME, 'arg%d' % > len(self.__inst.arguments) ) > > So the name can only be empty if gccxml reports it as such. I don't know > if this can ever happen or not, but even if it can happen, why is the > test from calldef_wrapper_t not moved to the scanner? For example: > > if not argument.name: > argument.name = 'arg%d' % len(self.__inst.arguments) > > Then an argument_t object read from a C++ file would always have a valid > name and the method argument_name() wouldn't be required anymore (and > other parts of the code would actually also be able to know the name of > an argument). You can not do it. If you set argument names from the scanner, than Py++ will generate wrong code - keyword arguments. Take a look on code_creators.calldef_t.keywords_args method. Now the answer to your question should be clear. In order to call function I have to pass arguments to it, so I just created names for them. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |