[pygccxml-development] Question about calldef_wrapper_t.argument_name()
Brought to you by:
mbaas,
roman_yakovenko
From: Matthias B. <ba...@ir...> - 2006-09-14 15:45:53
|
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). To be on the safe side, the _get_name() method of argument_t could also create a name if the argument doesn't already have a valid name. - Matthias - |