[pygccxml-commit] source/pyplusplus/code_creators algorithm.py,1.13,1.14
Brought to you by:
mbaas,
roman_yakovenko
From: Roman <rom...@us...> - 2006-03-06 04:56:17
|
Update of /cvsroot/pygccxml/source/pyplusplus/code_creators In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5588/pyplusplus/code_creators Modified Files: algorithm.py Log Message: Cleaning decl_wrapper\algorithm.py and code_creators\algorithm.py files There is still work that should be done Index: algorithm.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/code_creators/algorithm.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** algorithm.py 14 Dec 2005 09:09:52 -0000 1.13 --- algorithm.py 6 Mar 2006 04:56:13 -0000 1.14 *************** *** 9,12 **** --- 9,15 ---- """ + from pyplusplus.decl_wrappers.algorithm import * + + import re import types *************** *** 14,96 **** import namespace - def creators_affect_on_me( me ): - """ - This algorithm finds all code creators that can influence on code generated - by me. Description of alogrithm: - [a b c d e f g] - | - + [k l m] - | - + [y x] <-- we are here ( x ) - The answer of this algorithm is [y,l,k,d,c,b,a] - """ - class impl: - def __init__( self, creator): - self._creator = creator - - def _get_left_siblings( self, child ): - if not child or not child.parent: - return [] - ids = map( id, child.parent.creators ) - child_index = ids.index( id( child ) ) - return child.parent.creators[:child_index] - - def _get_definition_set( self, child ): - answer = [] - while child: - answer.extend( self._get_left_siblings( child ) ) - child = child.parent - return answer - - def affect_creators(self): - return self._get_definition_set( self._creator ) - return impl( me ).affect_creators() - - __RE_VALID_IDENTIFIER = re.compile( r"[_a-z]\w*", re.I | re.L | re.U ) - def create_valid_name(name): - """ - This function takes valid C++ class\\function name and will return valid - Python name. I need this function in order to expose template instantiations - """ - global __RE_VALID_IDENTIFIER - match_found = __RE_VALID_IDENTIFIER.match(name) - if match_found and ( match_found.end() - match_found.start() == len(name) ): - return name - replace_table = { - '<' : '_less_' - , '>' : '_grate_' - , '::' : '_scope_' - , ',' : '_comma_' - , ' ' : '_' - , '\t' : '_' - , '*' : '_ptr_' - , '&' : '_ref_' - , '(' : '_obrace_' - , ')' : '_cbrace_' - , '[' : '_o_sq_brace_' - , ']' : '_c_sq_brace_' - , '=' : '_equal_' - } - for orig, dest in replace_table.items(): - name = name.replace( orig, dest ) - return name - - - def create_identifier(creator, full_name ): - """ - This function will find all relevant namespace aliases and will return new - full name that takes into account namespace aliases. - """ - dset = creators_affect_on_me( creator ) - dset = filter( lambda x: isinstance( x, namespace.namespace_alias_t ), dset ) - full_name = full_name.lstrip( '::' ) - for nsalias in dset: - fnsname = nsalias.full_namespace_name + '::' - if full_name.startswith( fnsname ): - new_name = nsalias.alias + '::' + full_name[ len(fnsname) : ] - return new_name - else: - return full_name - def _make_flatten_list( creator_or_creators ): import compound --- 17,20 ---- *************** *** 176,191 **** search_area = make_flatten( where ) return filter( lambda inst: isinstance( inst, what ), search_area ) ! find_by_class_instance = staticmethod( find_by_class_instance ) ! ! ! class dummy_type_t( pygccxml.declarations.type_t ): ! #This class is very usefull for code generation ! def __init__( self, decl_string ): ! pygccxml.declarations.type_t.__init__( self ) ! self._decl_string = decl_string ! ! def _create_decl_string(self): ! return self._decl_string ! ! def _clone_impl( self ): ! return concrete_array_1_type_t( self._decl_string ) --- 100,102 ---- search_area = make_flatten( where ) return filter( lambda inst: isinstance( inst, what ), search_area ) ! find_by_class_instance = staticmethod( find_by_class_instance ) \ No newline at end of file |