[pygccxml-development] FT argument\return type\value indexing - decision
Brought to you by:
mbaas,
roman_yakovenko
From: Roman Y. <rom...@gm...> - 2006-10-08 19:30:20
|
Hi. I think we discuss enough this point and there is no sense to continue. I am not happy with the way I do it, but it seems that I have no other choice. Problem: how user should address\refer to function argument and return type\value. Current implementation: index is 1 based, in order to allow user to specify 0 as return. The solution: 1. Index should be 0 based. 2. Special const will be introduced to represent "reference" to return type\value: return_ = None ( or -1 ). 3. function_transformation_t will have new variable - USE_1_BASED_INDEXING By default its value will be False. Every one who consider "more natural" to use 0 based indexing will set this to True. 4. function_transformation_t will introduce 2 new methods: def get_argument( reference, func ): if isinstance( reference, str ): found = filter( lambda arg: arg.name == reference, func.arguments ) if len( found ) == 1: return found[0] raise RuntimeError( "Argument with %s was not found" % reference ) else: assert isinstance( reference, int ) if function_transformation_t.USE_1_BASED_INDEXING: reference += 1 return func.arguments[ reference ] def get_type( reference, func ): if isinstance( reference, int ) and reference == return_: return func.return_type else: return get_argument( reference, func ).type As you can see new implementation allows to use argument names as parameter to transformers. 5. Every built-in transformer will have to use these functions. One more time, I prefer to make a decision, when there is a consensus. This time we don't have it. I hope the solution provides a compromise. We still may discuss any detail of the solution, but I would like to make it clear: by default indexing will be 0 ( zero ) base. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |