Update of /cvsroot/pygccxml/source/pyplusplus/decl_wrappers
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5588/pyplusplus/decl_wrappers
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/decl_wrappers/algorithm.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** algorithm.py 28 Feb 2006 07:31:33 -0000 1.1
--- algorithm.py 6 Mar 2006 04:56:14 -0000 1.2
***************
*** 93,182 ****
return full_name
- def _make_flatten_list( creator_or_creators ):
- import compound
- def proceed_single( creator ):
- answer = [ creator ]
- if not isinstance( creator, compound.compound_t):
- return answer
- for internal in creator.creators:
- if isinstance( creator, compound.compound_t):
- answer.extend( proceed_single( internal ) )
- else:
- answer.append( internal )
- return answer
-
- creators = []
- if isinstance( creator_or_creators, types.ListType ):
- creators.extend( creator_or_creators )
- else:
- creators.append( creator_or_creators )
- answer = []
- for creator in creators:
- answer.extend( proceed_single( creator ) )
- return answer
-
- def _make_flatten_generator( creator_or_creators ):
- import compound
- def proceed_single( creator ):
- yield creator
- if not isinstance( creator, compound.compound_t):
- return
- for internal in creator.creators:
- if isinstance( internal, compound.compound_t):
- for internal_internal in proceed_single( internal ):
- yield internal_internal
- else:
- yield internal
-
- if isinstance( creator_or_creators, types.ListType ):
- for creator in creator_or_creators:
- for internal in proceed_single( creator ):
- yield internal
- else:
- for internal in proceed_single( creator_or_creators ):
- yield internal
-
- """
- make_flatten - function that will create flat representation of code creators tree.
- """
- make_flatten = _make_flatten_list
-
- class creator_finder:
- """
- This class is used as container for different find algorithms.
- """
- "creator_finder - this class used as namespace"
- def find_by_declaration( declaration_matcher, where, recursive=True ):
- """
- Finds code creator by declaration.
- declaration_matcher should be callable, that takes single argument
- declaration, and returns True or False
- where - code creator or list of code creators
- This function returns a list of all relevant code creators
- """
- import declaration_based #prevent cyclic import
- search_area = where
- if recursive:
- search_area = make_flatten( where )
- return filter( lambda inst: isinstance( inst, declaration_based.declaration_based_t ) \
- and declaration_matcher( inst.declaration )
- , search_area )
- find_by_declaration = staticmethod( find_by_declaration )
-
- def find_by_declaration_single( declaration_matcher, where, recursive=True ):
- answer = creator_finder.find_by_declaration( declaration_matcher, where, recursive )
- if len( answer ) == 1:
- return answer[0]
- return None
- find_by_declaration_single = staticmethod( find_by_declaration_single )
-
- def find_by_class_instance( what, where, recursive=True ):
- search_area = where
- if recursive:
- 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
--- 93,96 ----
|