pygccxml-commit Mailing List for C++ Python language bindings (Page 84)
Brought to you by:
mbaas,
roman_yakovenko
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
(190) |
Apr
(166) |
May
(170) |
Jun
(75) |
Jul
(105) |
Aug
(131) |
Sep
(99) |
Oct
(84) |
Nov
(67) |
Dec
(54) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(66) |
Feb
(49) |
Mar
(25) |
Apr
(62) |
May
(21) |
Jun
(34) |
Jul
(9) |
Aug
(21) |
Sep
(5) |
Oct
|
Nov
(63) |
Dec
(34) |
2008 |
Jan
(10) |
Feb
(42) |
Mar
(26) |
Apr
(25) |
May
(6) |
Jun
(40) |
Jul
(18) |
Aug
(29) |
Sep
(6) |
Oct
(32) |
Nov
(14) |
Dec
(56) |
2009 |
Jan
(127) |
Feb
(52) |
Mar
(2) |
Apr
(10) |
May
(29) |
Jun
(3) |
Jul
|
Aug
(16) |
Sep
(4) |
Oct
(11) |
Nov
(8) |
Dec
(14) |
2010 |
Jan
(31) |
Feb
(1) |
Mar
(7) |
Apr
(9) |
May
(1) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
(8) |
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Matthias B. <mb...@us...> - 2006-03-15 17:16:42
|
Update of /cvsroot/pygccxml/source/pyplusplus/experimental In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1184 Modified Files: declwrapper.py selection.py Log Message: Queries are now local by default and accept an argument recursive. The default value for that argument is customizable. Index: selection.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/experimental/selection.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** selection.py 14 Mar 2006 22:48:53 -0000 1.3 --- selection.py 15 Mar 2006 17:16:39 -0000 1.4 *************** *** 9,12 **** --- 9,13 ---- """ + import sys from treerange import TreeRange *************** *** 40,43 **** --- 41,46 ---- # Match the declarations... + # print "Selection range:",rng + # print "Select among %d decls"%len(list(rng)) res = [] for decl in rng: Index: declwrapper.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/experimental/declwrapper.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** declwrapper.py 14 Mar 2006 22:48:53 -0000 1.3 --- declwrapper.py 15 Mar 2006 17:16:39 -0000 1.4 *************** *** 20,24 **** allow_empty_queries = False ! # IDecl --- 20,24 ---- allow_empty_queries = False ! default_recursive = False # IDecl *************** *** 270,274 **** accesstype=None, filter=None, ! include_children=True, assert_count=None ): --- 270,275 ---- accesstype=None, filter=None, ! recursive=None, ! allow_empty=None, assert_count=None ): *************** *** 322,325 **** --- 323,330 ---- @param filter: User defined filter function @type callable + @param recursive: Extend the search to grandchildren? If not specified, a global (customizable) default value is used. + @type recursive: bool + @param allow_empty: Allow empty results. If not specified, a global (customizable) default value is used. + @type allow_empty: bool @param assert_count: Check the number of matched declarations in the resulting Decl object @type assert_count: int *************** *** 328,335 **** --- 333,346 ---- @see: Namespace(), Class(), Method(), Function(), Enum() """ + global allow_empty_queries, default_recursive itype = 0 filters = [] + if recursive==None: + recursive = default_recursive + if allow_empty==None: + allow_empty = allow_empty_queries + def addFilter(arg, filtercls): if arg!=None: *************** *** 377,383 **** type = 0 type |= itype - addFilter(type, TypeFilter) if len(filters)==0: filter = TrueFilter() --- 388,405 ---- type = 0 type |= itype addFilter(type, TypeFilter) + # Add parent filters... + pfs = [] + for decl in self.decl_handles: + pfs.append(ParentFilter(decl, recursive)) + if len(pfs)>0: + if len(pfs)==1: + filters.append(pfs[0]) + else: + filters.append(OrFilter(pfs)) + + # Create the final filter by combining the individual filters + # with AND... if len(filters)==0: filter = TrueFilter() *************** *** 392,399 **** else: decls = selection.select(self.decl_handles, filter) ! res = IDecl(decls) count = res.count ! if allow_empty_queries and count==0: return res if count==0: --- 414,421 ---- else: decls = selection.select(self.decl_handles, filter) ! res = IDecl(decls) count = res.count ! if allow_empty and count==0: return res if count==0: |
From: Matthias B. <mb...@us...> - 2006-03-15 17:14:52
|
Update of /cvsroot/pygccxml/source/pyplusplus/experimental In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32535 Modified Files: filters.py Log Message: The ParentFilter was only working with recursive=False. The RetvalFilter now also accepts regular expressions. Index: filters.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/experimental/filters.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** filters.py 14 Mar 2006 22:48:53 -0000 1.3 --- filters.py 15 Mar 2006 17:14:49 -0000 1.4 *************** *** 248,251 **** --- 248,258 ---- """ def __init__(self, parent, grandparents=False): + """Constructor. + + @param parent: Parent node + @type parent: declaration_t + @param grandparents: Determine whether the parent may also be a grandparent + @type grandparent: bool + """ FilterBase.__init__(self) self.parent = parent *************** *** 253,260 **** def __str__(self): ! return "parent=='%s'"%self.parent.name def __call__(self, decl): ! return decl.parent==self.parent def filterRange(self): --- 260,275 ---- def __str__(self): ! if self.recursive: ! return "anyparent=='%s'"%self.parent.name ! else: ! return "parent=='%s'"%self.parent.name def __call__(self, decl): ! # We can always return True as the filter range was already adjusted ! # so that all visited declarations meet the requirements for this ! # filter ! return True ! # The following line only works with recursive=False ! # return id(decl.parent)==id(self.parent) def filterRange(self): *************** *** 266,275 **** """ ! def __init__(self, retval): FilterBase.__init__(self) ! self.retval = retval def __str__(self): ! return "retval==%s"%self.retval def __call__(self, decl): --- 281,290 ---- """ ! def __init__(self, retvalpattern): FilterBase.__init__(self) ! self.matcher = _StringMatcher(retvalpattern) def __str__(self): ! return "retval==%s"%self.matcher.pattern def __call__(self, decl): *************** *** 277,281 **** if rettype==None: return False ! return rettype.decl_string==self.retval # ArgsFilter --- 292,296 ---- if rettype==None: return False ! return self.matcher.match(rettype.decl_string) # ArgsFilter |
From: Matthias B. <mb...@us...> - 2006-03-15 17:12:22
|
Update of /cvsroot/pygccxml/source/pyplusplus/experimental In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31182 Modified Files: treerange.py Log Message: The main intersect() function was plain wrong. Index: treerange.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/experimental/treerange.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** treerange.py 14 Mar 2006 22:48:53 -0000 1.1 --- treerange.py 15 Mar 2006 17:12:17 -0000 1.2 *************** *** 9,12 **** --- 9,14 ---- """ + from pygccxml.declarations import scopedef_t + # TreeRange class TreeRange: *************** *** 93,97 **** for ch in children: yield ch ! if recursive: for node in self._iterdecls(ch, True): yield node --- 95,99 ---- for ch in children: yield ch ! if recursive and isinstance(ch, scopedef_t): for node in self._iterdecls(ch, True): yield node *************** *** 102,105 **** --- 104,108 ---- The ranges are iterated from bottom to top. + All ranges are disjoint! """ *************** *** 124,130 **** """ ! res = self for rng in other.iterRanges(): ! res = res._simpleIntersect(rng) return res --- 127,141 ---- """ ! res = TreeRange(None, False) ! ! # Intersect self with each disjoint component of other and ! # "add" the result to res... for rng in other.iterRanges(): ! intersection = self._simpleIntersect(rng) ! res = res.union(intersection) ! ! # Check if the result only contains one sub range... ! if res.parent==None and len(res.subranges)==1: ! res = res.subranges[0] return res *************** *** 330,333 **** --- 341,352 ---- return res + def _dump(self, level=0): + """Dump the range tree for debugging purposes. + """ + s = "Rng: (%s:%s, %s)"%(getattr(self.parent, "name", "None"), self.parent.__class__.__name__, self.recursive) + print "%s%s"%((2*level)*" ", s) + for sr in self.subranges: + sr._dump(level+1) + ###################################################################### |
From: Roman <rom...@us...> - 2006-03-15 10:27:48
|
Update of /cvsroot/pygccxml/source/pygccxml/declarations In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20719/pygccxml/declarations Modified Files: scopedef.py Log Message: fixing serious bug reported by Matthias Index: scopedef.py =================================================================== RCS file: /cvsroot/pygccxml/source/pygccxml/declarations/scopedef.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** scopedef.py 8 Mar 2006 08:46:10 -0000 1.9 --- scopedef.py 15 Mar 2006 10:27:40 -0000 1.10 *************** *** 31,36 **** if not declaration.declaration_t.__eq__( self, other ): return False ! return self._sorted_list( self.declarations ) \ ! == other._sorted_list( other.declarations ) def _get_declarations_impl(self): --- 31,36 ---- if not declaration.declaration_t.__eq__( self, other ): return False ! return self._sorted_list( self.declarations[:] ) \ ! == other._sorted_list( other.declarations[:] ) def _get_declarations_impl(self): |
Update of /cvsroot/pygccxml/source/pyplusplus/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24990/pyplusplus/unittests Modified Files: call_policies_tester.py class_order_tester.py classes_tester.py enums_tester.py free_functions_tester.py fundamental_tester_base.py global_variables_tester.py member_functions_tester.py member_variables_tester.py operators_bug_tester.py operators_tester.py optional_tester.py recursive_tester.py regression1_tester.py regression2_tester.py temprorary_variable_tester.py Log Message: adding select interface to decl_wrapper class hierarchy Documentation strings will come later Index: free_functions_tester.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/unittests/free_functions_tester.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** free_functions_tester.py 28 Feb 2006 07:31:33 -0000 1.6 --- free_functions_tester.py 15 Mar 2006 09:27:07 -0000 1.7 *************** *** 21,30 **** def customize(self, mb ): ! matcher = declarations.match_declaration_t( name='one' ) ! function_one = code_creators.creator_finder.find_by_declaration( matcher ! , mb.module_creator.creators ) ! self.failUnless( len(function_one) == 1) ! function_one = function_one[0] ! function_one.alias = "ONE" def run_tests(self, module): --- 21,25 ---- def customize(self, mb ): ! mb.calldef( 'one' ).alias = 'ONE' def run_tests(self, module): Index: member_variables_tester.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/unittests/member_variables_tester.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** member_variables_tester.py 28 Feb 2006 07:31:33 -0000 1.13 --- member_variables_tester.py 15 Mar 2006 09:27:07 -0000 1.14 *************** *** 21,30 **** def customize(self, mb ): ! matcher = declarations.match_declaration_t( name='prefered_color' ) ! color = code_creators.creator_finder.find_by_declaration( matcher ! , mb.module_creator.creators ) ! self.failUnless( len(color) == 1) ! color = color[0] ! color.alias = 'PreferedColor' def change_default_color( self, module ): --- 21,25 ---- def customize(self, mb ): ! mb.variable( 'prefered_color' ).alias = 'PreferedColor' def change_default_color( self, module ): Index: recursive_tester.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/unittests/recursive_tester.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** recursive_tester.py 28 Feb 2006 07:31:33 -0000 1.2 --- recursive_tester.py 15 Mar 2006 09:27:07 -0000 1.3 *************** *** 21,28 **** def customize( self, mb ): ! for decl in declarations.make_flatten( mb.declarations ): ! if isinstance( decl, declarations.namespace_t ): ! continue ! decl.ignore = 'skip' not in decl.name matcher = declarations.match_declaration_t( name='skip_a' ) --- 21,27 ---- def customize( self, mb ): ! decls = mb.decls( lambda decl: not isinstance(decl, declarations.namespace_t) ! and 'skip' in decl.name ) ! decls.ignore = True matcher = declarations.match_declaration_t( name='skip_a' ) *************** *** 30,33 **** --- 29,33 ---- , mb.module_creator.creators ) self.failUnless( not found, "'skip_a' declaration should not be exported" ) + matcher = declarations.match_declaration_t( name='skip_b' ) found = code_creators.creator_finder.find_by_declaration( matcher Index: class_order_tester.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/unittests/class_order_tester.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** class_order_tester.py 28 Feb 2006 07:31:33 -0000 1.4 --- class_order_tester.py 15 Mar 2006 09:27:07 -0000 1.5 *************** *** 27,35 **** #This will add item creator to be last exported class extmodule.body.adopt_creator(item_creator) ! relevant_classes = (code_creators.function_t, code_creators.constructor_t ) ! calldefs = filter( lambda creator: isinstance( creator, relevant_classes ) ! , code_creators.make_flatten( extmodule.creators ) ) ! for calldef in calldefs: ! calldef.use_keywords = False def run_tests(self, module): --- 27,32 ---- #This will add item creator to be last exported class extmodule.body.adopt_creator(item_creator) ! ! mb.calldefs().use_keywords = False def run_tests(self, module): Index: classes_tester.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/unittests/classes_tester.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** classes_tester.py 28 Feb 2006 07:31:33 -0000 1.13 --- classes_tester.py 15 Mar 2006 09:27:07 -0000 1.14 *************** *** 21,32 **** def customize(self, mb ): ! extmodule = mb.module_creator ! matcher = declarations.match_declaration_t( name='fundamental2' ! , type=declarations.class_t) ! found = code_creators.creator_finder.find_by_declaration( matcher ! , extmodule.creators ) ! self.failUnless( len(found) == 1) ! found = found[0] ! found.alias = 'FUNDAMENTAL2' def run_tests(self, module): --- 21,25 ---- def customize(self, mb ): ! mb.class_( 'fundamental2' ).alias = 'FUNDAMENTAL2' def run_tests(self, module): Index: temprorary_variable_tester.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/unittests/temprorary_variable_tester.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** temprorary_variable_tester.py 28 Feb 2006 07:31:33 -0000 1.3 --- temprorary_variable_tester.py 15 Mar 2006 09:27:07 -0000 1.4 *************** *** 22,32 **** def customize(self, mb): ! for creator in code_creators.make_flatten( mb.module_creator.body.creators ): ! if not isinstance( creator, code_creators.function_t ): ! continue ! if not creator.call_policies and 'name' in creator.alias: ! creator.call_policies \ ! = decl_wrappers.return_value_policy( decl_wrappers.copy_non_const_reference ) ! def _create_derived_from_named_item(self, extmodule): --- 22,29 ---- def customize(self, mb): ! functions = mb.calldefs( lambda decl: not decl.call_policies ! and 'name' in decl.alias ) ! functions.call_policies \ ! = decl_wrappers.return_value_policy( decl_wrappers.copy_non_const_reference ) def _create_derived_from_named_item(self, extmodule): Index: regression2_tester.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/unittests/regression2_tester.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** regression2_tester.py 28 Feb 2006 07:31:33 -0000 1.2 --- regression2_tester.py 15 Mar 2006 09:27:07 -0000 1.3 *************** *** 21,28 **** def customize( self, mb ): ! for decl in declarations.make_flatten( mb.declarations ): ! if isinstance( decl, declarations.namespace_t ): ! continue ! decl.ignore = decl.name == 'get_a' def run_tests(self, module): --- 21,27 ---- def customize( self, mb ): ! decls = mb.decls( lambda decl: not isinstance( decl, declarations.namespace_t ) ! and decl.name == 'get_a' ) ! decls.ignore = True def run_tests(self, module): Index: enums_tester.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/unittests/enums_tester.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** enums_tester.py 28 Feb 2006 07:31:33 -0000 1.8 --- enums_tester.py 15 Mar 2006 09:27:07 -0000 1.9 *************** *** 21,34 **** def customize(self, mb ): ! color_matcher = declarations.match_declaration_t( name='color' ) ! color = code_creators.creator_finder.find_by_declaration( color_matcher ! , mb.module_creator.creators ) ! self.failUnless( len(color) == 1) ! color = color[0] ! assert isinstance( color, code_creators.enum_t ) color.alias = 'Color' color.value_aliases['red'] = 'RED' color.value_aliases['blue']= 'BLUE' ! color.export_values.extend( ['red', 'blue'] ) def run_tests(self, module): --- 21,33 ---- def customize(self, mb ): ! color = mb.enumeration( 'color' ) ! self.failUnless(color) color.alias = 'Color' color.value_aliases['red'] = 'RED' color.value_aliases['blue']= 'BLUE' ! color.export_values = ['red', 'blue'] ! ! def get_green( self, module): ! module.green def run_tests(self, module): *************** *** 38,41 **** --- 37,41 ---- self.failUnless( module.RED ) self.failUnless( module.BLUE ) + self.failIfNotRaisesAny( lambda: self.get_green( module ) ) def create_suite(): Index: global_variables_tester.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/unittests/global_variables_tester.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** global_variables_tester.py 28 Feb 2006 07:31:33 -0000 1.9 --- global_variables_tester.py 15 Mar 2006 09:27:07 -0000 1.10 *************** *** 21,30 **** def customize(self, mb ): ! var_matcher = declarations.match_declaration_t( name='non_const_var' ) ! var = code_creators.creator_finder.find_by_declaration( var_matcher ! , mb.module_creator.creators ) ! self.failUnless( len(var) == 1) ! var = var[0] ! var.alias = 'NonConstVar' def run_tests(self, module): --- 21,25 ---- def customize(self, mb ): ! mb.variable('non_const_var').alias = 'NonConstVar' def run_tests(self, module): Index: operators_bug_tester.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/unittests/operators_bug_tester.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** operators_bug_tester.py 28 Feb 2006 07:31:33 -0000 1.6 --- operators_bug_tester.py 15 Mar 2006 09:27:07 -0000 1.7 *************** *** 21,28 **** def customize(self, mb ): ! class_creators = filter( lambda creator: isinstance( creator, code_creators.class_t ) ! , code_creators.make_flatten( mb.module_creator.creators ) ) ! for class_creator in class_creators: ! class_creator.redefine_operators = True def run_tests(self, module): --- 21,25 ---- def customize(self, mb ): ! mb.classes().redefine_operators = True def run_tests(self, module): Index: member_functions_tester.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/unittests/member_functions_tester.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** member_functions_tester.py 28 Feb 2006 07:31:33 -0000 1.12 --- member_functions_tester.py 15 Mar 2006 09:27:07 -0000 1.13 *************** *** 21,25 **** def customize(self, mb ): - find = code_creators.creator_finder.find_by_declaration_single names = [ 'protected_protected_derived_t' --- 21,24 ---- *************** *** 31,41 **** , 'private_base_t' ] - classes = [] - for name in names: - matcher = declarations.match_declaration_t( name=name, type=declarations.class_t) - classes.append( find( matcher, mb.module_creator.body.creators ) ) - for class_ in classes: - class_.always_expose_using_scope = True def create_test_class_inst(self, class_ ): class tester_impl_t( class_ ): --- 30,36 ---- , 'private_base_t' ] + mb.classes( lambda decl: decl.name in names ).always_expose_using_scope = True + def create_test_class_inst(self, class_ ): class tester_impl_t( class_ ): Index: regression1_tester.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/unittests/regression1_tester.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** regression1_tester.py 28 Feb 2006 07:31:33 -0000 1.5 --- regression1_tester.py 15 Mar 2006 09:27:07 -0000 1.6 *************** *** 22,30 **** def customize( self, mb ): ! set_updater = filter( lambda creator: isinstance( creator, code_creators.function_t ) ! and creator.declaration.name == 'set_updater' ! , code_creators.make_flatten( mb.module_creator ) ) ! assert len(set_updater) == 1 ! set_updater = set_updater[0] set_updater.call_policies = decl_wrappers.with_custodian_and_ward( 1, 2 ) --- 22,26 ---- def customize( self, mb ): ! set_updater = mb.calldef( 'set_updater' ) set_updater.call_policies = decl_wrappers.with_custodian_and_ward( 1, 2 ) Index: operators_tester.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/unittests/operators_tester.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** operators_tester.py 28 Feb 2006 07:31:33 -0000 1.8 --- operators_tester.py 15 Mar 2006 09:27:07 -0000 1.9 *************** *** 22,47 **** def customize( self, mb ): ! gns = mb.namespace( name='::' ) ! gns.exclude() #I don't want to export base classes of 'rational<long int>' ! rational = declarations.find_declaration( gns ! , type=declarations.class_t ! , name='rational<long int>' ) rational.include() rational.alias = "pyrational" ! for decl in declarations.make_flatten( gns ): ! if isinstance( decl, declarations.free_operator_t ) \ ! and 'rational<long int>' in decl.decl_string: ! decl.include() ! r_assign = declarations.find_declaration( rational.declarations ! , type=declarations.calldef_t ! , name='assign' ! , recursive=False) r_assign.call_policies = decl_wrappers.return_self() ! bad_rational = declarations.find_declaration( gns, type=declarations.class_t, name='bad_rational' ) bad_rational.include() --- 22,40 ---- def customize( self, mb ): ! mb.global_ns.exclude() #I don't want to export base classes of 'rational<long int>' ! ! rational = mb.class_('rational<long int>') rational.include() rational.alias = "pyrational" ! foperators = mb.free_operators( lambda decl: 'rational<long int>' in decl.decl_string ) ! foperators.include() ! r_assign = rational.calldef( 'assign', recursive=False ) r_assign.call_policies = decl_wrappers.return_self() ! bad_rational = mb.class_('bad_rational' ) bad_rational.include() Index: call_policies_tester.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/unittests/call_policies_tester.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** call_policies_tester.py 28 Feb 2006 07:31:33 -0000 1.8 --- call_policies_tester.py 15 Mar 2006 09:27:07 -0000 1.9 *************** *** 22,34 **** def customize(self, mb ): ! extmodule = mb.module_creator ! matcher = declarations.match_declaration_t( name='return_second_arg' ) ! rsa = code_creators.creator_finder.find_by_declaration_single( matcher, extmodule.creators ) self.failUnless( rsa ) rsa.call_policies = decl_wrappers.return_arg( 2 ) ! ! matcher = declarations.match_declaration_t( name='return_self' ) ! rs = code_creators.creator_finder.find_by_declaration_single( matcher, extmodule.creators ) ! self.failUnless( rs ) rs.call_policies = decl_wrappers.return_self() --- 22,29 ---- def customize(self, mb ): ! rsa = mb.calldef( 'return_second_arg' ) self.failUnless( rsa ) rsa.call_policies = decl_wrappers.return_arg( 2 ) ! rs = mb.calldef( 'return_self' ) rs.call_policies = decl_wrappers.return_self() Index: fundamental_tester_base.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/unittests/fundamental_tester_base.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** fundamental_tester_base.py 28 Feb 2006 07:31:33 -0000 1.29 --- fundamental_tester_base.py 15 Mar 2006 09:27:07 -0000 1.30 *************** *** 44,53 **** def failIfNotRaisesAny(self, callableObj, *args, **kwargs): try: callableObj(*args, **kwargs) - self.fail( 'exception has not been raised during execution.') except: ! pass ! def customize(self, generator): pass --- 44,53 ---- def failIfNotRaisesAny(self, callableObj, *args, **kwargs): + was_exception = False try: callableObj(*args, **kwargs) except: ! was_exception = True ! self.failUnless(was_exception, 'exception has not been raised during execution.') def customize(self, generator): pass Index: optional_tester.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/unittests/optional_tester.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** optional_tester.py 2 Mar 2006 13:30:37 -0000 1.1 --- optional_tester.py 15 Mar 2006 09:27:07 -0000 1.2 *************** *** 21,27 **** def customize( self, mb ): ! for decl in declarations.make_flatten( mb.declarations ): ! if isinstance( decl, declarations.calldef_t ): ! decl.use_default_arguments = False def run_tests(self, module): --- 21,25 ---- def customize( self, mb ): ! mb.calldefs().use_default_arguments = False def run_tests(self, module): |
From: Roman <rom...@us...> - 2006-03-15 09:27:16
|
Update of /cvsroot/pygccxml/source/pygccxml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24990/pygccxml Modified Files: __init__.py Log Message: adding select interface to decl_wrapper class hierarchy Documentation strings will come later Index: __init__.py =================================================================== RCS file: /cvsroot/pygccxml/source/pygccxml/__init__.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** __init__.py 8 Mar 2006 08:41:18 -0000 1.20 --- __init__.py 15 Mar 2006 09:27:06 -0000 1.21 *************** *** 4,8 **** # http://www.boost.org/LICENSE_1_0.txt) ! """Python gccxml frontend. This package provides functionality to extract and inspect --- 4,8 ---- # http://www.boost.org/LICENSE_1_0.txt) ! """Python GCC-XML front end. This package provides functionality to extract and inspect |
From: Roman <rom...@us...> - 2006-03-15 09:27:14
|
Update of /cvsroot/pygccxml/source/pyplusplus/decl_wrappers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24990/pyplusplus/decl_wrappers Modified Files: namespace_wrapper.py scopedef_wrapper.py Log Message: adding select interface to decl_wrapper class hierarchy Documentation strings will come later Index: namespace_wrapper.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/decl_wrappers/namespace_wrapper.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** namespace_wrapper.py 28 Feb 2006 07:31:33 -0000 1.1 --- namespace_wrapper.py 15 Mar 2006 09:27:06 -0000 1.2 *************** *** 15,17 **** def is_finalizable(self): return True ! \ No newline at end of file --- 15,38 ---- def is_finalizable(self): return True ! ! def namespace( self, *args, **keywds ): ! return self._find_single( declarations.namespace_matcher_t, *args, **keywds ) ! ! def namespaces( self, *args, **keywds ): ! return self._find_multiple( declarations.namespace_matcher_t, *args, **keywds ) ! ! def free_function( self, *args, **keywds ): ! keywds['decl_type'] = declarations.free_function_t ! return self._find_single( declarations.calldef_matcher_t, *args, **keywds ) ! ! def free_functions( self, *args, **keywds ): ! keywds['decl_type'] = declarations.free_function_t ! return self._find_multiple( declarations.calldef_matcher_t, *args, **keywds ) ! ! def free_operator( self, *args, **keywds ): ! keywds['decl_type'] = declarations.free_operator_t ! return self._find_single( declarations.operator_matcher_t, *args, **keywds ) ! ! def free_operators( self, *args, **keywds ): ! keywds['decl_type'] = declarations.free_operator_t ! return self._find_multiple( declarations.operator_matcher_t, *args, **keywds ) Index: scopedef_wrapper.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/decl_wrappers/scopedef_wrapper.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** scopedef_wrapper.py 28 Feb 2006 07:31:33 -0000 1.1 --- scopedef_wrapper.py 15 Mar 2006 09:27:06 -0000 1.2 *************** *** 7,12 **** --- 7,16 ---- import finalizable from pygccxml import declarations + import mdecl_wrapper class scopedef_t(decl_wrapper.decl_wrapper_t, finalizable.finalizable_t): + + RECURSIVE_DEFAULT = True + def __init__(self): decl_wrapper.decl_wrapper_t.__init__( self ) *************** *** 27,28 **** --- 31,125 ---- , declarations.make_flatten( self.declarations ) ) map( lambda decl: decl.finalize(), finalizables ) + + def __create_matcher( self, match_class, *args, **keywds ): + if len( args ) == 1 and not keywds and callable( args[0] ): + matcher = match_class() + return lambda decl: matcher( decl ) and args[0](decl) + else: + if 1 == len( args ) and isinstance( args[0], str ): + keywds['name'] = args[0] + args = [] + return match_class(*args, **keywds) + + def _find_single( self, match_class, *args, **keywds ): + matcher = self.__create_matcher( match_class, *args, **keywds ) + recursive = keywds.get( 'recursive', scopedef_t.RECURSIVE_DEFAULT ) + return declarations.matcher.get_single( matcher, self.declarations, recursive ) + + def _find_multiple( self, match_class, *args, **keywds ): + matcher = self.__create_matcher( match_class, *args, **keywds ) + recursive = keywds.get( 'recursive', scopedef_t.RECURSIVE_DEFAULT ) + found = declarations.matcher.find( matcher, self.declarations, recursive ) + return mdecl_wrapper.mdecl_wrapper_t( found ) + + def decl( self, *args, **keywds ): + return self._find_single( declarations.declaration_matcher_t, *args, **keywds ) + + def decls( self, *args, **keywds ): + return self._find_multiple( declarations.declaration_matcher_t, *args, **keywds ) + + def class_( self, *args, **keywds ): + keywds['decl_type'] = declarations.class_t + return self._find_single( declarations.declaration_matcher_t, *args, **keywds ) + + def classes( self, *args, **keywds ): + keywds['decl_type'] = declarations.class_t + return self._find_multiple( declarations.declaration_matcher_t, *args, **keywds ) + + def variable( self, *args, **keywds ): + return self._find_single( declarations.variable_matcher_t, *args, **keywds ) + + def variables( self, *args, **keywds ): + return self._find_multiple( declarations.variable_matcher_t, *args, **keywds ) + + def calldef( self, *args, **keywds ): + return self._find_single( declarations.calldef_matcher_t, *args, **keywds ) + + def calldefs( self, *args, **keywds ): + return self._find_multiple( declarations.calldef_matcher_t, *args, **keywds ) + + def operator( self, *args, **keywds ): + return self._find_single( declarations.operator_matcher_t, *args, **keywds ) + + def operators( self, *args, **keywds ): + return self._find_multiple( declarations.operator_matcher_t, *args, **keywds ) + + def member_function( self, *args, **keywds ): + keywds['decl_type'] = declarations.member_function_t + return self._find_single( declarations.calldef_matcher_t, *args, **keywds ) + + def member_functions( self, *args, **keywds ): + keywds['decl_type'] = declarations.member_function_t + return self._find_multiple( declarations.calldef_matcher_t, *args, **keywds ) + + def constructor( self, *args, **keywds ): + keywds['decl_type'] = declarations.member_function_t + return self._find_single( declarations.calldef_matcher_t, *args, **keywds ) + + def constructors( self, *args, **keywds ): + keywds['decl_type'] = declarations.constructor_t + return self._find_multiple( declarations.calldef_matcher_t, *args, **keywds ) + + def member_operator( self, *args, **keywds ): + keywds['decl_type'] = declarations.member_operator_t + return self._find_single( declarations.operator_matcher_t, *args, **keywds ) + + def member_operators( self, *args, **keywds ): + keywds['decl_type'] = declarations.member_operator_t + return self._find_multiple( declarations.operator_matcher_t, *args, **keywds ) + + def casting_operator( self, *args, **keywds ): + keywds['decl_type'] = declarations.casting_operator_t + return self._find_single( declarations.calldef_matcher_t, *args, **keywds ) + + def casting_operators( self, *args, **keywds ): + keywds['decl_type'] = declarations.casting_operator_t + return self._find_multiple( declarations.calldef_matcher_t, *args, **keywds ) + + def enumeration( self, *args, **keywds ): + keywds['decl_type'] = declarations.enumeration_t + return self._find_single( declarations.declaration_matcher_t, *args, **keywds ) + + def enumerations( self, *args, **keywds ): + keywds['decl_type'] = declarations.enumeration_t + return self._find_multiple( declarations.declaration_matcher_t, *args, **keywds ) |
From: Roman <rom...@us...> - 2006-03-15 09:27:14
|
Update of /cvsroot/pygccxml/source/pygccxml/declarations In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24990/pygccxml/declarations Modified Files: __init__.py filters.py Log Message: adding select interface to decl_wrapper class hierarchy Documentation strings will come later Index: __init__.py =================================================================== RCS file: /cvsroot/pygccxml/source/pygccxml/declarations/__init__.py,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** __init__.py 6 Mar 2006 05:00:32 -0000 1.35 --- __init__.py 15 Mar 2006 09:27:06 -0000 1.36 *************** *** 141,144 **** --- 141,145 ---- from filters import regex_matcher_t from filters import access_type_matcher_t + from filters import operator_matcher_t from matcher import matcher Index: filters.py =================================================================== RCS file: /cvsroot/pygccxml/source/pygccxml/declarations/filters.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** filters.py 8 Mar 2006 08:46:10 -0000 1.2 --- filters.py 15 Mar 2006 09:27:06 -0000 1.3 *************** *** 17,24 **** class declaration_matcher_t( object ): ! def __init__( self, decl_type=None, name=None, header_file=None, header_dir=None ): """ header and header dir should be absolute! """ #An other option is that #pygccxml will create absolute path using os.path.abspath function. --- 17,29 ---- class declaration_matcher_t( object ): ! def __init__( self, *args, **keywds ): """ header and header dir should be absolute! + decl_type + name + header_file + header_dir """ + #An other option is that #pygccxml will create absolute path using os.path.abspath function. *************** *** 26,42 **** #cwd and this behaviour is fragile and not so easy to find the bug. object.__init__( self ) ! self.decl_type = decl_type ! self.name = name ! self.header_dir = header_dir if self.header_dir: ! self.header_dir = utils.normalize_path( header_dir ) ! self.header_file = header_file if self.header_file: ! self.header_file = utils.normalize_path( header_file ) ! ! if self.header_dir and not os.path.isabs( self.header_dir ): ! raise RuntimeError( "Path to header directory should be absolute!" ) ! if self.header_file and not os.path.isabs( self.header_file ): ! raise RuntimeError( "Path to header file should be absolute!" ) def __call__( self, decl ): --- 31,48 ---- #cwd and this behaviour is fragile and not so easy to find the bug. object.__init__( self ) ! self.decl_type = keywds.get('decl_type', None) ! self.name = keywds.get('name', None) ! self.header_dir = keywds.get('header_dir', None) ! self.header_file = keywds.get('header_file', None) ! if self.header_dir: ! self.header_dir = utils.normalize_path( self.header_dir ) ! if not os.path.isabs( self.header_dir ): ! raise RuntimeError( "Path to header directory should be absolute!" ) ! if self.header_file: ! self.header_file = utils.normalize_path( self.header_file ) ! if not os.path.isabs( self.header_file ): ! raise RuntimeError( "Path to header file should be absolute!" ) def __call__( self, decl ): *************** *** 64,75 **** class variable_matcher_t( declaration_matcher_t ): ! def __init__( self, type=None, value=None, *arguments, **keywords): """ type could be string or instance of class derived from cpptypes.type_t """ ! declaration_matcher_t.__init__( self, variable.variable_t, *arguments, **keywords ) ! ! self.type = type ! self.value = value def __call__( self, decl ): --- 70,81 ---- class variable_matcher_t( declaration_matcher_t ): ! def __init__( self, *args, **keywds ): """ type could be string or instance of class derived from cpptypes.type_t """ ! keywds.update(decl_type=variable.variable_t) ! declaration_matcher_t.__init__( self, *args, **keywds ) ! self.type = keywds.get('type', None) ! self.value = keywds.get('value', None) def __call__( self, decl ): *************** *** 86,91 **** class namespace_matcher_t( declaration_matcher_t ): ! def __init__( self, *arguments, **keywords ): ! declaration_matcher_t.__init__( self, namespace.namespace_t, *arguments, **keywords) def __call__( self, decl ): --- 92,98 ---- class namespace_matcher_t( declaration_matcher_t ): ! def __init__( self, *args, **keywds ): ! keywds.update(decl_type=namespace.namespace_t) ! declaration_matcher_t.__init__( self, namespace.namespace_t, *args, **keywds) def __call__( self, decl ): *************** *** 94,98 **** class calldef_matcher_t( declaration_matcher_t ): ! def __init__( self, return_type=None, arg_types=None, *arguments, **keywords): """Constructor. --- 101,105 ---- class calldef_matcher_t( declaration_matcher_t ): ! def __init__( self, *args, **keywds): """Constructor. *************** *** 106,115 **** default argument value and/or exception .... """ ! if not keywords.has_key( 'decl_type' ): ! keywords[ 'decl_type' ] = calldef.calldef_t ! declaration_matcher_t.__init__( self, *arguments, **keywords ) ! self.return_type = return_type ! self.arg_types = arg_types def __call__( self, decl ): --- 113,122 ---- default argument value and/or exception .... """ ! if not keywds.has_key( 'decl_type' ): ! keywds.update( decl_type=calldef.calldef_t ) ! declaration_matcher_t.__init__( self, *args, **keywds ) ! self.return_type = keywds.get( 'return_type', None ) ! self.arg_types = keywds.get( 'arg_types', None ) def __call__( self, decl ): *************** *** 141,145 **** return True ! class regex_matcher_t: def __init__( self, regex, function ): --- 148,163 ---- return True ! class operator_matcher_t( calldef_matcher_t ): ! def __init__( self, symbol=None, *args, **keywds): ! if not keywds.has_key( 'decl_type' ): ! keywds.update( decl_type=calldef.operator_t ) ! calldef_matcher_t.__init__( self, *args, **keywds ) ! self.symbol = keywds.get( 'symbol', None ) ! ! def __call__( self, decl ): ! if not super( operator_matcher_t, self ).__call__( decl ): ! return False ! return None != self.symbol and self.symbol == decl.symbol ! class regex_matcher_t: def __init__( self, regex, function ): |
From: Roman <rom...@us...> - 2006-03-15 09:27:14
|
Update of /cvsroot/pygccxml/source/pygccxml/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24990/pygccxml/unittests Modified Files: autoconfig.py Log Message: adding select interface to decl_wrapper class hierarchy Documentation strings will come later Index: autoconfig.py =================================================================== RCS file: /cvsroot/pygccxml/source/pygccxml/unittests/autoconfig.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** autoconfig.py 6 Mar 2006 04:53:31 -0000 1.11 --- autoconfig.py 15 Mar 2006 09:27:06 -0000 1.12 *************** *** 56,59 **** --- 56,60 ---- , 'decls' , 'namespace' + , 'namespaces' , 'enum' , 'const' *************** *** 64,68 **** , 'os' , 'normcase' ! , 'normpath' ] ) except ImportError: pass \ No newline at end of file --- 65,77 ---- , 'os' , 'normcase' ! , 'normpath' ! , 'scopedef' ! , 'ira'#part of Matthias mail address ! , 'uka'#part of Matthias mail address ! , 'de'#part of Matthias mail address ! , 'dat'#file extension of directory cache ! , 'config'#parameter description ! , 'gccxml'#parameter description ! ] ) except ImportError: pass \ No newline at end of file |
From: Roman <rom...@us...> - 2006-03-15 09:27:14
|
Update of /cvsroot/pygccxml/source/pyplusplus/module_builder In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24990/pyplusplus/module_builder Modified Files: builder.py Log Message: adding select interface to decl_wrapper class hierarchy Documentation strings will come later Index: builder.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/module_builder/builder.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** builder.py 28 Feb 2006 07:31:33 -0000 1.1 --- builder.py 15 Mar 2006 09:27:07 -0000 1.2 *************** *** 18,21 **** --- 18,22 ---- self.__module_name = module_name self.__decls = None + self.__global_ns = None self.__module_creator = None self.__files = files *************** *** 82,90 **** file_writers.write_multiple_files( self.mcreator_package, dir_name ) ! def namespace( self, *arguments, **keywords ): ! if len( arguments ) == 1 and not keywords: ! return decls_package.matcher.get_single( arguments[0], self.declarations ) ! else: ! return decls_package.matcher.get_single( ! decls_package.namespace_matcher_t( *arguments, **keywords ) ! , self.declarations ) \ No newline at end of file --- 83,169 ---- file_writers.write_multiple_files( self.mcreator_package, dir_name ) ! def _get_global_ns( self ): ! if not self.__global_ns: ! self.__global_ns = decls_package.matcher.get_single( ! decls_package.namespace_matcher_t( name='::' ) ! , self.declarations ) ! return self.__global_ns ! global_ns = property( _get_global_ns ) ! ! def decl( self, *args, **keywds ): ! return self.global_ns.decl( *args, **keywds ) ! ! def decls( self, *args, **keywds ): ! return self.global_ns.decls( *args, **keywds ) ! ! def class_( self, *args, **keywds ): ! return self.global_ns.class_( *args, **keywds ) ! ! def classes( self, *args, **keywds ): ! return self.global_ns.classes( *args, **keywds ) ! ! def variable( self, *args, **keywds ): ! return self.global_ns.variable( *args, **keywds ) ! ! def variables( self, *args, **keywds ): ! return self.global_ns.variables( *args, **keywds ) ! ! def calldef( self, *args, **keywds ): ! return self.global_ns.calldef( *args, **keywds ) ! ! def calldefs( self, *args, **keywds ): ! return self.global_ns.calldefs( *args, **keywds ) ! ! def operator( self, *args, **keywds ): ! return self.global_ns.operator( *args, **keywds ) ! ! def operators( self, *args, **keywds ): ! return self.global_ns.operators( *args, **keywds ) ! ! def member_function( self, *args, **keywds ): ! return self.global_ns.member_function( *args, **keywds ) ! ! def member_functions( self, *args, **keywds ): ! return self.global_ns.member_functions( *args, **keywds ) ! ! def constructor( self, *args, **keywds ): ! return self.global_ns.constructor( *args, **keywds ) ! ! def constructors( self, *args, **keywds ): ! return self.global_ns.constructors( *args, **keywds ) ! ! def member_operator( self, *args, **keywds ): ! return self.global_ns.member_operator( *args, **keywds ) ! ! def member_operators( self, *args, **keywds ): ! return self.global_ns.member_operators( *args, **keywds ) ! ! def casting_operator( self, *args, **keywds ): ! return self.global_ns.casting_operator( *args, **keywds ) ! ! def casting_operators( self, *args, **keywds ): ! return self.global_ns.casting_operators( *args, **keywds ) ! ! def enumeration( self, *args, **keywds ): ! return self.global_ns.enumeration( *args, **keywds ) ! ! def enumerations( self, *args, **keywds ): ! return self.global_ns.enumerations( *args, **keywds ) ! ! def namespace( self, *args, **keywds ): ! return self.global_ns.namespace( *args, **keywds ) ! ! def namespaces( self, *args, **keywds ): ! return self.global_ns.namespaces( *args, **keywds ) ! ! def free_function( self, *args, **keywds ): ! return self.global_ns.free_function( *args, **keywds ) ! ! def free_functions( self, *args, **keywds ): ! return self.global_ns.free_functions( *args, **keywds ) ! ! def free_operator( self, *args, **keywds ): ! return self.global_ns.free_operator( *args, **keywds ) ! ! def free_operators( self, *args, **keywds ): ! return self.global_ns.free_operators( *args, **keywds ) |
From: Roman <rom...@us...> - 2006-03-15 09:27:11
|
Update of /cvsroot/pygccxml/source/pygccxml/unittests/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24990/pygccxml/unittests/data Modified Files: core_cache.hpp Log Message: adding select interface to decl_wrapper class hierarchy Documentation strings will come later Index: core_cache.hpp =================================================================== RCS file: /cvsroot/pygccxml/source/pygccxml/unittests/data/core_cache.hpp,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** core_cache.hpp 28 Feb 2006 07:11:09 -0000 1.45 --- core_cache.hpp 15 Mar 2006 09:27:06 -0000 1.46 *************** *** 24,26 **** ! //touch//touch//touch//touch \ No newline at end of file --- 24,26 ---- ! //touch//touch//touch//touch//touch//touch//touch//touch//touch \ No newline at end of file |
From: Matthias B. <mb...@us...> - 2006-03-14 22:49:03
|
Update of /cvsroot/pygccxml/source/pyplusplus/experimental In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12314 Modified Files: filters.py selection.py declwrapper.py Added Files: treerange.py Log Message: Added the TreeRange class that serves as an iterator over selected parts of the declaration tree. The filters can now specify a range they operate on (instead of what I was calling 'parent constraints'). With this change it is now possible to concatenate queries no matter if it was a query that returned a single result or multiple results. The TreeRange will also ease the distinction of local vs global search (even on node by node basis). Currently, the default is still global search, I'll change that asap. --- NEW FILE: treerange.py --- # Copyright 2006 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) # # Initial author: Matthias Baas """This module contains the TreeRange class. """ # TreeRange class TreeRange: """This class represents a part of a tree. A B{simple tree range} is defined by a I{parent} node and a boolean flag I{recursive}. The immediate children of the parent node are always contained in the range (the parent itself is excluded). If the boolean flag is True then all grand-children of the parent node are also contained in the range. A B{compound range} is one that contains more than one simple ranges. The purpose of this class is to provide an iterator that yields parts of a declaration tree. This iteration is used when particular declarations are queried. By calling the L{union()} and L{intersection()} methods, a range can be created that restricts the search to particular areas of the tree. This can be used to exploit a priori knowledge about the filter function when it is known that a filter will never match a node outside a particular range. A tree range can itself be a tree of ranges. For example, consider the case when only the direct children of a node are contained in a range and you make a union() operation with a range that lies beneath that node. In this case, the sub range will be a children of the first range. A range object can only have sub ranges when its recursive flag is set to False, otherwise all possible sub ranges are already contained in that range anyway. """ def __init__(self, parent, recursive, subranges=None): """Constructor. """ if subranges==None: subranges = [] # Parent node # (None is only allowed in the root) self.parent = parent # Recursive flag self.recursive = recursive # A list of sub ranges. The list items are TreeRange objects. # The sub ranges must be disjoint! # The list must be empty when recursive is True! self.subranges = subranges def __str__(self): return "<TreeRange: parent:%s recursive:%s #subranges:%d>"%(self.parent, self.recursive, len(self.subranges)) def __iter__(self): """The same as iterNodes().""" return self.iterNodes() # iterNodes def iterNodes(self): """Iterate over all nodes within this range. yields the individual nodes (declaration_t objects). """ if self.parent!=None: for node in self._iterdecls(self.parent, self.recursive): yield node for sr in self.subranges: for node in sr.iterNodes(): yield node # _iterdecls def _iterdecls(self, parent, recursive): """Depth first iteration over a declaration (sub) tree. Iterates over the children of parent. If recursive is set to True the iteration also includes the grand-children. The parent itself is not returned. @param parent: Starting node @param recursive: Determines whether the method also yields children nodes @type recursive: bool """ children = getattr(parent, "declarations", []) for ch in children: yield ch if recursive: for node in self._iterdecls(ch, True): yield node # iterRanges def iterRanges(self): """Iterate over the simple ranges within this range. The ranges are iterated from bottom to top. """ for sr in self.subranges: for r in sr.iterRanges(): yield r if self.parent!=None: yield self.parent, self.recursive # intersect def intersect(self, other): """Return the intersection of self and other. Update the current tree and return the new root. @param other: A simple range (parent, recursive). @type other: 2-tuple @returns: The new root node. @rtype: TreeRange """ res = self for rng in other.iterRanges(): res = res._simpleIntersect(rng) return res def _simpleIntersect(self, simplerange): """Return the intersection of self and other. Update the current tree and return the new root. @param simplerange: A simple range (parent, recursive). @type simplerange: 2-tuple @returns: The new root node. @rtype: TreeRange """ otherparent, otherrecursive = simplerange if self.parent!=None: rs = self._rangeRelationship(self.parent, otherparent) # disjoint? if rs==0: self.parent = None self.recursive = False self.subranges = [] return self # otherparent==parent? elif rs==3: if not otherrecursive: self.recursive = False self.subranges = [] return self # parent below otherparent? elif rs==2: if not otherrecursive: self.parent = None self.recursive = False self.subranges = [] return self # otherparent below parent else: if self.recursive: self.parent = otherparent self.recursive = otherrecursive self.subranges = [] return self self.parent = None # go on as if parent was None in the first place # newsub receives all sub ranges that are below otherparent # (these will survive) newsub = [] for sr in self.subranges: rs = self._rangeRelationship(sr.parent, otherparent) # sr parent == otherparent? if rs==3: if not otherrecursive: sr.subranges = [] sr.recursive = False return sr # otherparent below sr.parent? elif rs==1: return sr._simpleIntersect(simplerange) # sr.parent below otherparent? elif rs==2: if otherrecursive: newsub.append(sr) self.subranges = newsub return self # union def union(self, other): """Return the union of self and other. Update the current tree and return the new root. @param other: Another TreeRange object @type other: TreeRange @returns: The new root node. @rtype: TreeRange """ res = self for rng in other.iterRanges(): res = res._simpleUnion(rng) return res def _simpleUnion(self, simplerange): """Return the union of self and a simple range. Update the current tree and return the new root. @param simplerange: A simple range (parent, recursive). @type simplerange: 2-tuple @returns: The new root node. @rtype: TreeRange """ otherparent, otherrecursive = simplerange if self.parent!=None: rs = self._rangeRelationship(self.parent, otherparent) # disjoint? if rs==0: otherrange = TreeRange(otherparent, otherrecursive, []) root = TreeRange(None, False, [self, otherrange]) return root # otherparent==parent? elif rs==3: if otherrecursive: self.recursive = True self.subranges = [] return self # parent below otherparent? elif rs==2: if otherrecursive: self.parent = otherparent self.recursive = True self.subranges = [] return self else: rng = TreeRange(otherparent, False, [self]) return rng # otherparent below parent else: # Are we already recursive? Then self already contains other... if self.recursive: return self # if we get here, otherparent is below parent and self is not # recursive. This is treated as if parent was None # newsub receives all sub ranges that are below otherparent # (these will become the new sub range of other) newsub = [] for i,sr in enumerate(self.subranges): rs = self._rangeRelationship(sr.parent, otherparent) # sr parent == otherparent? if rs==3: if otherrecursive: sr.recursive = True sr.subranges = [] return self # otherparent below sr.parent? elif rs==1: del self.subranges[i] newsr = sr._simpleUnion(simplerange) # if a new TreeRange with empty parent was created, then # pull the subranges to this level if newsr.parent==None: self.subranges.extend(newsr.subranges) else: self.subranges.append(newsr) return self # sr.parent below otherparent? elif rs==2: newsub.append(sr) # other will become a new sub range rng = TreeRange(otherparent, otherrecursive, []) # Was other above some previous sub ranges? Then move those sub ranges # below other... if len(newsub)>0: for sr in newsub: self.subranges.remove(sr) rng.subranges = newsub self.subranges.append(rng) return self def _rangeRelationship(self, parent1, parent2): """Determines the relationship between two nodes. @returns: Returns the relationship as an integer value: - 0: The sub trees rooted at parent1 and parent2 are disjoint - 1: parent2 is below parent1 - 2: parent1 is below parent2 - 3: parent1 and parent2 are the same @rtype: int """ path1 = self._rootPath(parent1) path2 = self._rootPath(parent2) res = 0 if parent1 in path2: res |= 0x01 if parent2 in path1: res |= 0x02 return res def _rootPath(self, node): """Returns a list with all nodes from node to the root (including node). @precondition: node must have a parent attribute @returns: Returns a list of nodes @rtype: list """ res = [] while node!=None: res.append(node) node = node.parent return res ###################################################################### if __name__=="__main__": class DummyNode: def __init__(self, id, parent=None): self.id = id self.parent = parent self.declarations = [] if parent!=None: self.parent.declarations.append(self) def __str__(self): return "<Node %d>"%self.id root = DummyNode(0) n1 = DummyNode(1, root) n2 = DummyNode(2, n1) n3 = DummyNode(3, n1) n4 = DummyNode(4, root) n5 = DummyNode(5, n4) n6 = DummyNode(6, n2) tr = TreeRange(root, False) tr = tr.union((n4,True)) print tr for r in tr.iterRanges(): print r for n in tr: print n Index: filters.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/experimental/filters.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** filters.py 14 Mar 2006 18:08:57 -0000 1.2 --- filters.py 14 Mar 2006 22:48:53 -0000 1.3 *************** *** 12,15 **** --- 12,16 ---- from pygccxml.declarations import * from decltypes import * + from treerange import TreeRange # _StringMatcher *************** *** 78,84 **** --- 79,97 ---- return OrFilter([self, other]) + def filterRange(self): + """Return the range of the filter. + + A return value of none means the filter's range is unlimited. + + @returns: Filter range or None + @rtype: TreeRange + """ + return None + def parentConstraints(self): """Return the parent constraints. + *** obsolete *** + A filter can use this method to indicate that it will always return False if the parent is not a particular node. *************** *** 138,169 **** return True ! def parentConstraints(self): ! parent = None ! recursive = None for f in self.filters: ! res = f.parentConstraints() ! # No constraints? Then go on with the next filter... ! if res==None: ! continue ! # One individual filter always fails? ! # Then this filter fails as well... ! if res==[]: ! return [] ! # Check if the individual constraints are conflicting... ! for p,r in res: ! if parent==None: ! parent = p ! recursive = r else: ! if p==parent: ! # recursive only remains True if r is also True ! recursive = recursive & r ! else: ! # Two different parents => This filter will always fail ! return [] ! if parent==None: ! return None ! else: ! return [parent, recursive] # OrFilter --- 151,165 ---- return True ! def filterRange(self): ! res = None for f in self.filters: ! rng = f.filterRange() ! if rng!=None: ! if res==None: ! res = rng else: ! res = res.intersect(rng) ! return res ! # OrFilter *************** *** 184,207 **** return False ! def parentConstraints(self): ! remove = [] ! constraints = [] for f in self.filters: ! res = f.parentConstraints() ! if res==[]: ! remove.append(f) ! continue ! if res!=None: ! constraints.extend(res) ! ! # Remove all filters that always return False ! for f in remove: ! self.filters.remove(f) ! ! if constraints==[]: ! return None ! else: ! return constraints ! # NotFilter --- 180,195 ---- return False ! def filterRange(self): ! res = None for f in self.filters: ! rng = f.filterRange() ! if rng==None: ! return None ! if res==None: ! res = rng ! else: ! res = res.union(rng) ! return res ! # NotFilter *************** *** 219,222 **** --- 207,215 ---- return not self.filter(decl) + def filterRange(self): + # TreeRange does not support a NOT operation, so extend the + # range to full range + return None + # NameFilter *************** *** 250,253 **** --- 243,264 ---- return self.matcher.match(full_name(decl)) + # ParentFilter + class ParentFilter(FilterBase): + """Filter by parent node. + """ + def __init__(self, parent, grandparents=False): + FilterBase.__init__(self) + self.parent = parent + self.recursive = grandparents + + def __str__(self): + return "parent=='%s'"%self.parent.name + + def __call__(self, decl): + return decl.parent==self.parent + + def filterRange(self): + return TreeRange(self.parent, self.recursive) + # RetValFilter class RetValFilter(FilterBase): Index: selection.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/experimental/selection.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** selection.py 14 Mar 2006 18:06:43 -0000 1.2 --- selection.py 14 Mar 2006 22:48:53 -0000 1.3 *************** *** 9,65 **** """ ! # iterdecls ! def iterdecls(rootdecl, recursive=True): ! """Depth first iteration over one or more declaration trees. ! rootdecl can be either a single declaration, a list of declarations ! or None. A declaration must be an object derived from the declaration_t ! class. ! """ ! if rootdecl==None: ! return ! ! if type(rootdecl) is not list: ! rootdecl = [rootdecl] ! ! for root in rootdecl: ! yield root ! if recursive: ! children = getattr(root, "declarations", None) ! for node in iterdecls(children): ! yield node # select def select(root, filter): ! """Select declarations based on a filter function. ! filter must accept a declaration as argument and return a boolean ! indicating whether the declaration matches the filter or not. ! @param root: Root of the declaration tree ! @type root: declaration_t ! @param filter: A filter that either accepts or rejects a declaration ! @type filter: callable ! """ ! parents = None ! # First check for the parentConstraints() method so that also ! # regular functions can be passed ! if hasattr(filter, "parentConstraints"): ! parents = filter.parentConstraints() ! # Does the filter always return False? ! if parents==[]: ! return [] ! # No constraints on the parent? Then use the root and walk the entire tree ! if parents==None: ! parents = [(root, True)] ! res = [] ! for parent,recursive in parents: ! for decl in iterdecls(parent): ! if filter(decl): ! res.append(decl) ! return res --- 9,49 ---- """ ! from treerange import TreeRange # select def select(root, filter): ! """Select declarations based on a filter function. ! filter must accept a declaration as argument and return a boolean ! indicating whether the declaration matches the filter or not. ! @param root: The node(s) under which to search ! @type root: declaration_t or list of declaration_t ! @param filter: A filter that either accepts or rejects a declaration ! @type filter: callable ! """ ! if type(root)!=list: ! root = [root] ! rng = TreeRange(root[0],True) ! for node in root[1:]: ! rng = rng.union(TreeRange(node,True)) ! parents = None ! # First check for the filterRange() method so that also ! # regular functions can be passed ! if hasattr(filter, "filterRange"): ! frng = filter.filterRange() ! if frng!=None: ! rng = rng.intersect(frng) ! # Match the declarations... ! res = [] ! for decl in rng: ! if filter(decl): ! res.append(decl) ! ! return res Index: declwrapper.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/experimental/declwrapper.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** declwrapper.py 14 Mar 2006 18:10:48 -0000 1.2 --- declwrapper.py 14 Mar 2006 22:48:53 -0000 1.3 *************** *** 391,398 **** decls = [] else: ! if len(self.decl_handles)!=1: ! print "***WARNING***: len(decl_handles) != 1" ! root = self.decl_handles[0] ! decls = selection.select(root, filter) res = IDecl(decls) --- 391,395 ---- decls = [] else: ! decls = selection.select(self.decl_handles, filter) res = IDecl(decls) |
From: Matthias B. <mb...@us...> - 2006-03-14 18:11:15
|
Update of /cvsroot/pygccxml/source/pyplusplus/experimental In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14031 Modified Files: declwrapper.py Log Message: Allow empty queries Index: declwrapper.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/experimental/declwrapper.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** declwrapper.py 14 Mar 2006 10:25:12 -0000 1.1 --- declwrapper.py 14 Mar 2006 18:10:48 -0000 1.2 *************** *** 325,328 **** --- 325,329 ---- @type assert_count: int @returns: Returns a Decl object that may reference an arbitrary number of declarations. + @rtype: IDecl @see: Namespace(), Class(), Method(), Function(), Enum() """ *************** *** 348,352 **** # args filter if args!=None: ! filters.append([ArgsFilter(args)]) type |= CALLABLE # anyarg filter --- 349,353 ---- # args filter if args!=None: ! filters.append(ArgsFilter(args)) type |= CALLABLE # anyarg filter *************** *** 387,394 **** # print "Filter:",filter ! if len(self.decl_handles)!=1: ! print "***WARNING***: len(decl_handles) != 1" ! root = self.decl_handles[0] ! decls = selection.select(root, filter) res = IDecl(decls) --- 388,398 ---- # print "Filter:",filter ! if len(self.decl_handles)==0: ! decls = [] ! else: ! if len(self.decl_handles)!=1: ! print "***WARNING***: len(decl_handles) != 1" ! root = self.decl_handles[0] ! decls = selection.select(root, filter) res = IDecl(decls) |
From: Matthias B. <mb...@us...> - 2006-03-14 18:09:00
|
Update of /cvsroot/pygccxml/source/pyplusplus/experimental In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12673 Modified Files: filters.py Log Message: Doc string updates Index: filters.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/experimental/filters.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** filters.py 14 Mar 2006 10:25:12 -0000 1.1 --- filters.py 14 Mar 2006 18:08:57 -0000 1.2 *************** *** 54,59 **** # It was only a successful match when the entire string was matched return m.end()==len(txt) ! ! # FilterBase --- 54,58 ---- # It was only a successful match when the entire string was matched return m.end()==len(txt) ! # FilterBase *************** *** 81,86 **** def parentConstraints(self): """Return the parent constraints. ! @returns: Tuple (parent, recursive) """ return None --- 80,101 ---- def parentConstraints(self): """Return the parent constraints. + + A filter can use this method to indicate that it will always + return False if the parent is not a particular node. ! The following return values are possible: ! ! - C{None}: There are no constraints. The filter may return True on any node. ! - C{[]}: The filter will always return False. ! - C{[(parent, recursive),...]}: The parent constraints. ! ! A single parent constraint (I{parent}, I{recursive}) means that the ! filter may only return True on children of I{parent}. If I{recursive} ! is set to True these can also be grand-children, otherwise they ! are only the direct children. On all other nodes, the filter will ! always return False so the search algorithm may decide not to visit ! them at all to speed up the search. ! ! @returns: None, an empty list or a list of tuples (parent, recursive). """ return None |
From: Matthias B. <mb...@us...> - 2006-03-14 18:07:00
|
Update of /cvsroot/pygccxml/source/pyplusplus/experimental In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11093 Modified Files: selection.py Log Message: Fixed some typos Index: selection.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/experimental/selection.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** selection.py 14 Mar 2006 10:25:12 -0000 1.1 --- selection.py 14 Mar 2006 18:06:43 -0000 1.2 *************** *** 33,38 **** """Select declarations based on a filter function. ! filter must to accept a declaration as argument and return a boolean ! indicating whether the declarations matches the filter or not. @param root: Root of the declaration tree --- 33,38 ---- """Select declarations based on a filter function. ! filter must accept a declaration as argument and return a boolean ! indicating whether the declaration matches the filter or not. @param root: Root of the declaration tree |
From: Matthias B. <mb...@us...> - 2006-03-14 10:25:19
|
Update of /cvsroot/pygccxml/source/pyplusplus/experimental In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30088 Added Files: decltypes.py declwrapper.py filters.py selection.py Log Message: Added an experimental replacement for the DeclWrapper/MultiDeclWrapper classes. Note: To try this out, you have to activate the new class explicitly! --- NEW FILE: declwrapper.py --- # Copyright 2006 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) # # Initial author: Matthias Baas """This module contains the 'Declaration wrapper' object. """ import types from filters import * import decltypes import pygccxml import pyplusplus import selection # Create an alias for the builtin type() function _type = type allow_empty_queries = False # IDecl class IDecl: """Declaration interface. This class represents the interface to the declaration tree. Its main purpose is to "decorate" the nodes in the tree with information about how the binding is to be created. Instances of this class are never created by the user, instead they are returned by the API. You can think of this class as a container for declaration nodes that are selected by matching a set of filters. @group Selection interface: Decl, Namespace, Class, Constructor, Method, Function, Enum, Var, Decls, Namespaces, Classes, Constructors, Methods, Functions, Enums, Vars @group Decoration interface: expose, ignore, exclude, finalize, rename, setPolicy, disableKeywordArgs, setHeldType, addMethod, cdef, staticmethod """ def __init__(self, decls): """Constructor. @param decls: One or more declarations that should be stored in this instance @type decls: declaration_t or list of declaration_t """ if type(decls)!=list: decls = [decls] # A sequence containing the underlying pygccxml declaration nodes. # (actually these are decl_wrapper nodes) self.decl_handles = decls def __str__(self): """Return a descriptive string.""" if len(self.decl_handles)==0: return "Decl: <empty>" elif len(self.decl_handles)==1: ds = getattr(self.decl_handles[0], "name", "?") return 'Decl: "%s"'%(ds) else: return 'Decl: (%d declarations)'%(len(self.decl_handles)) def __iter__(self): return self.iterContained() # iterContained def iterContained(self): """Iterate over all contained nodes. The iterator yields Decl objects. """ for decl in self._iterContained(): yield IDecl([decl]) # expose def expose(self, flag=True): """Expose the declarations in the generated module. If flag is True all contained declarations are marked for being exposed, otherwise they are marked for being ignored. @param flag: Determines whether the declaration is actually exposed or ignored. @type flag: bool @returns: Returns self @see: L{ignore()} """ for d in self._iterContained(): d.include() return self # ignore def ignore(self, flag=True): """Ignore the declarations in the generated module. If flag is True all contained declarations are marked for being ignored, otherwise they are marked for being exposed. @param flag: Determines whether the declaration is actually ignored or exposed. @type flag: bool @return: Returns self @see: L{expose()} """ for d in self._iterContained(): d.exclude() return self # exclude def exclude(self, flag=True): """This is an alias for L{ignore()}.""" return self.ignore(flag) # rename def rename(self, name): """Rename a declaration. The declaration will receive a new name under which it is exposed in the Python module. If there are currently several declarations referenced the new name is assigned to all of them. However, only the declarations that were directly matched will receive a new name, children are always ignored. @param name: New name for the declaration @type name: str """ for decl in self._iterContained(recursive=False): decl.rename(name) return self # finalize def finalize(self): """Finalize virtual member functions or an entire class. Prevents the generation of wrappers for virtual member functions. """ for decl in self._iterContained(): decl.finalize() return self # setPolicy def setPolicy(self, policy): """Set policies for functions or methods. @param policy: Policy to apply to the contained functions/methods. @type policy: ...policy... """ for decl in self._iterContained(): decl.call_policies = policy # setHeldType def setHeldType(self, heldtype): """Explicitly set the held type. Ex: C{setHeldType("boost::shared_ptr<Class>")} """ for decl in self._iterContained(): decl.held_type = heldType return self # disableKeywordArgs def disableKeywordArgs(self): """Disable generation of keyword arguments. """ for decl in self._iterContained(): decl.use_keywords = False # if ( isinstance(decl, calldef_t) and # not isinstance(decl, destructor_t) and # getattr(decl, "access_type", None)!=PRIVATE): # decl._use_keywords = False return self # addMethod def addMethod(self, name, impl): """Add a new method to a class. Adds a new method to a class. The implementation is given as a C/C++ function that is defined elsewhere. The return value is a Decl object that can be used to further customize the method. @Note: This method isn't implemented yet! @param name: The method name as it will appear in the Python module @type name: str: @param impl: The name of the C/C++ function that implements the method. @type impl: str @returns: Returns a Decl object containing the newly created method. """ raise NotImplementedError, "addMethod() isn't implemented yet" pass # def def cdef(self, name, fn, *args): """Apply a raw def() statement. This method is equivalent to the Boost.Python def() method. Example:: Class("Foo").cdef("spam", "cspam", return_internal_reference(), (arg("a"), arg("b", 0)), "The spam method") It is up to the user to ensure that the C/C++ function cspam is declared and implemented somewhere. @param name: Name of the Python method @type name: str @param fn: Name of the C++ function that implements the method @type fn: str @param args: There can be up to three additional arguments in any order: A doc string, the call policies and the keywords. @see: L{staticmethod()} """ raise NotImplementedError, "cdef() isn't implemented yet" ## doc,policies,keywords = self._parseDefArgs(args) ## args = ['"%s"'%name, fn] ## if policies!=None: ## pass # todo ## if keywords!=None: ## args.append("(%s)"%", ".join(map(lambda x: "bp::"+str(x), keywords))) ## if doc!=None: ## a = map(lambda x: "%s\\n"%x, doc.split("\n")) ## while len(a)>0 and a[-1]=="\\n": ## a = a[:-1] ## if len(a)>0: ## # Remove the newline in the last line ## a[-1] = a[-1][:-2] ## args.append('%s'%"\n".join(map(lambda x: '"%s"'%x, a))) ## src = 'def( %s )'%(", ".join(args)) ## for decl in self._iterContained(no_children=True): ## # Add the 'def' source code line to the list of defs... ## if not hasattr(decl, "_user_defs"): ## decl._user_defs = [] ## decl._user_defs.append(src) return self # staticmethod def staticmethod(self, name): """Apply a raw staticmethod() statement. @param name: Name of the method. @type name: str @see: L{cdef()} """ raise NotImplementedError, "staticmethod() isn't implemented yet" # for decl in self._iterContained(no_children=True): # if not hasattr(decl, "_user_defs"): # decl._user_defs = [] # decl._user_defs.append('staticmethod( "%s" )'%name) return self # Decl def Decls(self, name=None, fullname=None, type=None, retval=None, args=None, anyarg=None, signature=None, header=None, headerdir=None, accesstype=None, filter=None, include_children=True, assert_count=None ): """Obtain a Decl object referencing one or more declarations. Filters all contained declarations and returns a new Decl object that only contains declarations matching the filtering rules as specified by the arguments. If an argument is None, that particular filtering operation is disabled. If several arguments are provided, all of them must be matched. For any filter that is based on strings (such as name) the following rules apply: - A string must match exactly the corresponding attribute of the declaration (C{name="wxFrame"} will only return the class "wxFrame"). - A string that is bracketed by a leading and trailing slash '/' is interpreted as a regular expression (C{name="/wx.*/"} will return all classes that begin with "wx"). Any argument can also be passed a list of values which duplicates the filter. These filter are concatenated with OR, so a declaration has to match only one of the filters. For example, you can select all classes starting with either "wx" or "WX" by setting C{name=["/wx.*/", "/WX.*/"}]. The user defined filter function filter must accept a Decl object as argument and has to return True when the declaration is matched. @param name: Select declarations by name @type name: str @param fullname: Select declarations by name (which includes namespaces) @type fullname: str @param type: Select declarations by type. The type is given by a combination of flags (CLASS, MEMBER_FUNCTION/METHOD, FREE_FUNCTION/FUNCTION, ENUM, ...) @type type: int @param retval: Select functions/methods based on their return value (this implies the type flags MEMBER_FUNCTION | FREE_FUNCTION) @type retval: str @param args: Select functions/methods bases on their arguments (this implies the type flags MEMBER_FUNCTION | FREE_FUNCTION) @type args: list of str @param anyarg: Select all functions/methods that have the specified argument somewhere in their argument list (this implies the type flags MEMBER_FUNCTION | FREE_FUNCTION) @type anyarg: str @param signature: Select declarations by their signature (this implies the type flags MEMBER_FUNCTION | FREE_FUNCTION) @type signature: str @param header: Select declarations by the header file in which they are defined @type header: str @param headerdir: Select declarations by the directory in which their header file is located @type headerdir: str @param accesstype: Access type (PUBLIC or PROTECTED). This implies the type flag MEMBER_FUNCTION. @param filter: User defined filter function @type callable @param assert_count: Check the number of matched declarations in the resulting Decl object @type assert_count: int @returns: Returns a Decl object that may reference an arbitrary number of declarations. @see: Namespace(), Class(), Method(), Function(), Enum() """ itype = 0 filters = [] def addFilter(arg, filtercls): if arg!=None: if _type(arg)==list: filters.append(OrFilter(map(lambda x: filtercls(x), arg))) else: filters.append(filtercls(arg)) # name filter addFilter(name, NameFilter) # fullname filter addFilter(fullname, FullNameFilter) # retval filter if retval!=None: addFilter(retval, RetValFilter) itype |= CALLABLE # args filter if args!=None: filters.append([ArgsFilter(args)]) type |= CALLABLE # anyarg filter if anyarg!=None: raise NotImplementedError, "anyarg filter is not yet implemented" # signature filter if signature!=None: raise NotImplementedError, "signature filter is not yet implemented" # header filter addFilter(header, HeaderFilter) # headerdir filter addFilter(headerdir, HeaderDirFilter) # accesstype filter if accesstype!=None: addFilter(accesstype, AccessTypeFilter) type |= METHOD # custom filters if filter!=None: if _type(filter)==list: filters.extend(filter) else: filters.append(filter) # XXX if itype!=0: if type==None: type = 0 type |= itype addFilter(type, TypeFilter) if len(filters)==0: filter = TrueFilter() elif len(filters)==1: filter = filters[0] else: filter = AndFilter(filters) # print "Filter:",filter if len(self.decl_handles)!=1: print "***WARNING***: len(decl_handles) != 1" root = self.decl_handles[0] decls = selection.select(root, filter) res = IDecl(decls) count = res.count if allow_empty_queries and count==0: return res if count==0: raise RuntimeError, "Query produced no results (filter: %s)"%filter if assert_count!=None: if res.count!=assert_count: raise RuntimeError, "Query produced the wrong number of results (%d instead of %d)"%(res.count, assert_count) return res # Namespace def Namespaces(self, name=None, type=0, **args): """Obtain a Decl object referencing one or more namespaces. This method is equivalent to calling Decl() with the flag NAMESPACE set in its type filter. See Decl() for a full description of this method. @returns: Returns a Decl object that may reference an arbitrary number of declarations. @see: L{Decl()} """ return self.Decls(name=name, type=type|NAMESPACE, **args) # Class def Classes(self, name=None, type=0, **args): return self.Decls(name=name, type=type|CLASS, **args) # Method def Methods(self, name=None, type=0, **args): return self.Decls(name=name, type=type|METHOD, **args) # Constructor def Constructors(self, name=None, type=0, **args): return self.Decls(name=name, type=type|CONSTRUCTOR, **args) # Function def Functions(self, name=None, type=0, **args): return self.Decls(name=name, type=type|FUNCTION, **args) # Enum def Enums(self, name=None, type=0, **args): return self.Decls(name=name, type=type|ENUM, **args) # Vars def Vars(self, name=None, type=0, **args): return self.Vars(name=name, type=type|VARIABLE, **args) # Decl def Decl(self, name=None, **args): return self.Decls(name, assert_count=1, **args) # Namespace def Namespace(self, name=None, **args): return self.Namespaces(name, assert_count=1, **args) # Class def Class(self, name=None, **args): return self.Classes(name, assert_count=1, **args) # Method def Method(self, name=None, **args): return self.Methods(name, assert_count=1, **args) # Constructor def Constructor(self, name=None, **args): return self.Constructors(name, assert_count=1, **args) # Function def Function(self, name=None, **args): return self.Functions(name, assert_count=1, **args) # Enum def Enum(self, name=None, **args): return self.Enums(name, assert_count=1, **args) # Var def Var(self, name=None, **args): return self.Vars(name, assert_count=1, **args) # Private methods: def _getCount(self): """Return the number of matched declarations. """ return len(self.decl_handles) count = property(_getCount, None, None, "The number of matched declarations.") def _getTotalCount(self): """Return the total number of contained declarations (including the children). """ return len(list(self)) totalcount = property(_getTotalCount, None, None, "The total number of contained declarations.") def _parseDefArgs(self, args): """Determine which of the args is the doc string, call policies and keywords argument. @returns: Returns a tuple (doc, policies, keywords). """ if len(args)>3: raise ValueError, "Too many arguments (%d)"%len(args) doc = None policies = None keywords = None # call_policy_t = pyplusplus.code_creators.call_policies.call_policy_t call_policy_t = pyplusplus.decl_wrappers.call_policies.call_policy_t for a in args: if isinstance(a, types.StringTypes): doc = a elif isinstance(a, call_policy_t): policies = a elif type(a)==tuple: keywords = a elif isinstance(a, decltypes.arg): keywords = (a,) else: raise ValueError, "Invalid argument: %s"%a return doc,policies,keywords def _iterContained(self, recursive=True): """Iterate over all contained declarations. The generator yields pygccxml declaration objects. @param recursive: Determines whether the method also yields children nodes @type recursive: bool """ global _timestamp _timestamp += 1 for rootdecl in self.decl_handles: for decl in self._iterdecls(rootdecl, recursive=recursive): # Get the time stamp and check if this declaration hasn't # been visited yet ts = getattr(decl, "_timestamp", -1) if ts!=_timestamp: decl._timestamp = _timestamp yield decl # _iterdecls def _iterdecls(self, rootdecl, recursive=True): """Depth first iteration over one or more declaration trees. rootdecl can be either a single declaration, a list of declarations or None. A declaration must be an object derived from the declaration_t class. If recursive is False, only the root is returned. @param recursive: Determines whether the method also yields children nodes @type recursive: bool """ if rootdecl==None: return if type(rootdecl) is not list: rootdecl = [rootdecl] for root in rootdecl: yield root if recursive: children = getattr(root, "declarations", None) for node in self._iterdecls(children): yield node # This value is used to determine if a declaration was already visited or not _timestamp = 0 --- NEW FILE: decltypes.py --- # Copyright 2006 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) # # Initial author: Matthias Baas """This module contains some basic definitions. """ NAMESPACE = 0x01 CLASS = 0x02 MEMBER_FUNCTION = 0x04 METHOD = MEMBER_FUNCTION # this also includes constructors FREE_FUNCTION = 0x08 FUNCTION = FREE_FUNCTION CONSTRUCTOR = 0x10 # limit to constructors ENUM = 0x20 VARIABLE = 0x40 CALLABLE = METHOD | FUNCTION | CONSTRUCTOR # arg class arg: """Provide keyword arguments for methods/functions. This class is equivalent to the Boost.Python arg class and is used together with the Decl.cdef method. """ def __init__(self, name, default=None): """Constructor. @param name: Argument name @type name: str @param default: Optional default value """ self.name = name self.default = default def __str__(self): res = 'arg("%s")'%self.name if self.default!=None: res += "=%s"%self.py2cpp(self.default) return res def py2cpp(self, val): """Convert a Python value to a C++ value. """ if type(val)==bool: return str(val).lower() elif type(val)==str: return '"%s"'%val else: return str(val) --- NEW FILE: selection.py --- # Copyright 2006 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) # # Initial author: Matthias Baas """This module contains the generic selection function. """ # iterdecls def iterdecls(rootdecl, recursive=True): """Depth first iteration over one or more declaration trees. rootdecl can be either a single declaration, a list of declarations or None. A declaration must be an object derived from the declaration_t class. """ if rootdecl==None: return if type(rootdecl) is not list: rootdecl = [rootdecl] for root in rootdecl: yield root if recursive: children = getattr(root, "declarations", None) for node in iterdecls(children): yield node # select def select(root, filter): """Select declarations based on a filter function. filter must to accept a declaration as argument and return a boolean indicating whether the declarations matches the filter or not. @param root: Root of the declaration tree @type root: declaration_t @param filter: A filter that either accepts or rejects a declaration @type filter: callable """ parents = None # First check for the parentConstraints() method so that also # regular functions can be passed if hasattr(filter, "parentConstraints"): parents = filter.parentConstraints() # Does the filter always return False? if parents==[]: return [] # No constraints on the parent? Then use the root and walk the entire tree if parents==None: parents = [(root, True)] res = [] for parent,recursive in parents: for decl in iterdecls(parent): if filter(decl): res.append(decl) return res --- NEW FILE: filters.py --- # Copyright 2006 Roman Yakovenko. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) # # Initial author: Matthias Baas """This module contains the filters that are used to select declarations. """ import re, os.path from pygccxml.declarations import * from decltypes import * # _StringMatcher class _StringMatcher: """Helper class to match strings. This class can be used to match a string with a pattern that may either be an ordinary string as well or contain a regular expression enclosed in '/'. """ def __init__(self, pattern): """Constructor. pattern may contain a regular expression enclosed between two '/'. @param pattern: The pattern used for matching @type pattern: str """ self.regexp = None self.pattern = pattern # Is pattern a regular expression? if len(pattern)>=2 and pattern[0]=="/" and pattern[-1]=="/": self.regexp = re.compile(pattern[1:-1]) # match def match(self, txt): """Check if a string matches the pattern. @param txt: The string to match @type txt: str @returns: True if txt matches the pattern """ if self.regexp==None: return txt==self.pattern else: m = self.regexp.match(txt) if m==None: return False # It was only a successful match when the entire string was matched return m.end()==len(txt) # FilterBase class FilterBase: """Base class for all filters. """ def __init__(self): pass def __call__(self, decl): raise NotImplementedError, "filters must always implement the __call__() method." def __invert__(self): """NOT-operator (~)""" return NotFilter(self) def __and__(self, other): """AND-operator (&)""" return AndFilter([self, other]) def __or__(self, other): """OR-Operator (|)""" return OrFilter([self, other]) def parentConstraints(self): """Return the parent constraints. @returns: Tuple (parent, recursive) """ return None # TrueFilter class TrueFilter(FilterBase): """Returns always True. """ def __call__(self, decl): return True def __str__(self): return "True" # FalseFilter class FalseFilter(FilterBase): """Returns always False. """ def __call__(self, decl): return False def __str__(self): return "False" # AndFilter class AndFilter(FilterBase): """Combine several other filters with AND. """ def __init__(self, filters): FilterBase.__init__(self) self.filters = filters def __str__(self): return " & ".join(map(lambda x: "(%s)"%str(x), self.filters)) def __call__(self, decl): for f in self.filters: if not f(decl): return False return True def parentConstraints(self): parent = None recursive = None for f in self.filters: res = f.parentConstraints() # No constraints? Then go on with the next filter... if res==None: continue # One individual filter always fails? # Then this filter fails as well... if res==[]: return [] # Check if the individual constraints are conflicting... for p,r in res: if parent==None: parent = p recursive = r else: if p==parent: # recursive only remains True if r is also True recursive = recursive & r else: # Two different parents => This filter will always fail return [] if parent==None: return None else: return [parent, recursive] # OrFilter class OrFilter(FilterBase): """Combine several other filters with OR. """ def __init__(self, filters): FilterBase.__init__(self) self.filters = filters def __str__(self): return " | ".join(map(lambda x: "(%s)"%str(x), self.filters)) def __call__(self, decl): for f in self.filters: if f(decl): return True return False def parentConstraints(self): remove = [] constraints = [] for f in self.filters: res = f.parentConstraints() if res==[]: remove.append(f) continue if res!=None: constraints.extend(res) # Remove all filters that always return False for f in remove: self.filters.remove(f) if constraints==[]: return None else: return constraints # NotFilter class NotFilter(FilterBase): """Return the inverse result of a filter. """ def __init__(self, filter): FilterBase.__init__(self) self.filter = filter def __str__(self): return "~(%s)"%str(self.filter) def __call__(self, decl): return not self.filter(decl) # NameFilter class NameFilter(FilterBase): """Filter by declaration name. """ def __init__(self, namepattern): FilterBase.__init__(self) self.matcher = _StringMatcher(namepattern) def __str__(self): return "name=='%s'"%self.matcher.pattern def __call__(self, decl): return self.matcher.match(decl.name) # FullNameFilter class FullNameFilter(FilterBase): """Filter by full declaration name. """ def __init__(self, namepattern): FilterBase.__init__(self) self.matcher = _StringMatcher(namepattern) def __str__(self): return "fullname=='%s'"%self.matcher.pattern def __call__(self, decl): return self.matcher.match(full_name(decl)) # RetValFilter class RetValFilter(FilterBase): """Filter by return type. """ def __init__(self, retval): FilterBase.__init__(self) self.retval = retval def __str__(self): return "retval==%s"%self.retval def __call__(self, decl): rettype = getattr(decl, "return_type", None) if rettype==None: return False return rettype.decl_string==self.retval # ArgsFilter class ArgsFilter(FilterBase): """Filter by argument types. """ def __init__(self, args): FilterBase.__init__(self) self.args = args def __str__(self): return "args==%s"%self.args def __call__(self, decl): args = self.args declargs = getattr(decl, "arguments", None) if declargs==None: return False if len(args)!=len(declargs): return False for arg,argument in zip(args, declargs): if arg!=argument.type.decl_string: return False return True # TypeFilter class TypeFilter(FilterBase): """Filter by declaration type. """ def __init__(self, typeflags): FilterBase.__init__(self) self.flags = typeflags def __str__(self): f = self.flags t = [] if f & NAMESPACE: t.append("NAMESPACE") if f & CLASS: t.append("CLASS") if f & METHOD: t.append("METHOD") if f & FUNCTION: t.append("FUNCTION") if f & CONSTRUCTOR: t.append("CONSTRUCTOR") if f & ENUM: t.append("ENUM") return "type==%s"%("|".join(t)) def __call__(self, decl): return (self.declFlags(decl) & self.flags)!=0 # declFlags def declFlags(self, decl): """Return the type flags for decl. @param decl: Declaration @type decl: declaration_t """ res = 0 if isinstance(decl, class_t): res |= CLASS elif isinstance(decl, member_calldef_t): res |= METHOD elif isinstance(decl, free_calldef_t): res |= FUNCTION elif isinstance(decl, enumeration.enumeration_t): res |= ENUM elif isinstance(decl, namespace_t): res |= NAMESPACE if isinstance(decl, constructor_t): res |= CONSTRUCTOR return res # HeaderFilter class HeaderFilter(FilterBase): """Filter by header file. """ def __init__(self, header): FilterBase.__init__(self) self.header = os.path.abspath(header) def __str__(self): return "header==%s"%self.header def __call__(self, decl): loc = getattr(decl, "location", None) if loc==None: return False header = os.path.abspath(loc.file_name) return header==self.header # HeaderDirFilter class HeaderDirFilter(FilterBase): """Filter by header location. """ def __init__(self, headerdir): FilterBase.__init__(self) self.headerdir = os.path.abspath(headerdir) def __str__(self): return "headerdir==%s"%self.headerdir def __call__(self, decl): loc = getattr(decl, "location", None) if loc==None: return False dir = os.path.abspath(os.path.dirname(loc.file_name)) return dir[:len(self.headerdir)]==self.headerdir # AccessTypeFilter class AccessTypeFilter(FilterBase): """Filter by access type. """ def __init__(self, accesstype): """Constructor. accesstype can bei either PUBLIC or PROTECTED. """ FilterBase.__init__(self) self.accesstype = accesstype def __str__(self): return "accesstype==%s"%self.accesstype def __call__(self, decl): at = getattr(decl, "access_type", None) if at==None: return False return at==self.accesstype |
From: Matthias B. <mb...@us...> - 2006-03-14 10:22:18
|
Update of /cvsroot/pygccxml/source/pyplusplus/experimental In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28440 Modified Files: pypp_api.py Log Message: 1) parse() now returns the top-level namespace. 2) writeModule() checks for missing policies and aborts if there are still some missing. 3) Provided a shortcut to the pygccxml access types (by making them part of the high level API. Index: pypp_api.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/experimental/pypp_api.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** pypp_api.py 10 Mar 2006 12:35:14 -0000 1.7 --- pypp_api.py 14 Mar 2006 10:22:10 -0000 1.8 *************** *** 33,36 **** --- 33,37 ---- from pygccxml import parser from pygccxml import declarations + from pygccxml.declarations import ACCESS_TYPES import pygccxml.utils *************** *** 52,55 **** --- 53,60 ---- from pyplusplus.decl_wrappers import return_value_policy + PUBLIC = ACCESS_TYPES.PUBLIC + PROTECTED = ACCESS_TYPES.PROTECTED + PRIVATE = ACCESS_TYPES.PRIVATE + def cleanTemplateName(templateName): """ Build a clean template name. """ *************** *** 110,113 **** --- 115,119 ---- have been made. + @returns: Returns the root of the declaration tree @postcondition: This class can act as a wrapper for namespace("::") and all declarations are set to be ignored. """ *************** *** 178,181 **** --- 184,189 ---- print "completed parsing." + return self.mDeclRootWrapper + def buildCreators(self, moduleName, filename, useScope=False): *************** *** 253,257 **** extmodule = self.mExtModule assert extmodule ! if self.mVerbose: print "Writing out files..." --- 261,278 ---- extmodule = self.mExtModule assert extmodule ! ! # Check for missing policies... ! print "Checking policies..." ! creators = code_creators.make_flatten(self.mExtModule) ! fmfunctions = filter(lambda creator: isinstance(creator, code_creators.function_t), creators) ! missing_flag = False ! for creator in fmfunctions: ! if not creator.call_policies: ! print "Missing policy:", declarations.full_name(creator.declaration) ! missing_flag = True ! if missing_flag: ! print "*** Aborting because of missing policies!" ! return ! if self.mVerbose: print "Writing out files..." |
From: Roman <rom...@us...> - 2006-03-13 09:22:15
|
Update of /cvsroot/pygccxml/source/pygccxml/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1948/pygccxml/docs Modified Files: pygccxml.rest Log Message: Fixing few warnings from docutils Index: pygccxml.rest =================================================================== RCS file: /cvsroot/pygccxml/source/pygccxml/docs/pygccxml.rest,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pygccxml.rest 5 Mar 2006 05:39:08 -0000 1.4 --- pygccxml.rest 13 Mar 2006 09:22:00 -0000 1.5 *************** *** 328,332 **** .. _`GCC-XML`: http://www.gccxml.org .. _`Boost Software License`: http://boost.org/more/license_info.html ! .. _`Eric 3.4`: http://www.die-offenbachs.de/detlev/eric3.html .. _`Debian Linux`: http://www.debian.org .. _`UML diagram` : ./declarations.png --- 328,332 ---- .. _`GCC-XML`: http://www.gccxml.org .. _`Boost Software License`: http://boost.org/more/license_info.html ! .. _`Eric 3.6`: http://www.die-offenbachs.de/detlev/eric3.html .. _`Debian Linux`: http://www.debian.org .. _`UML diagram` : ./declarations.png |
From: Roman <rom...@us...> - 2006-03-13 09:22:12
|
Update of /cvsroot/pygccxml/source/pyplusplus/docs/examples/qtxml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1948/pyplusplus/docs/examples/qtxml Modified Files: qtxml.rest Log Message: Fixing few warnings from docutils Index: qtxml.rest =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/docs/examples/qtxml/qtxml.rest,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** qtxml.rest 16 Jan 2006 13:58:19 -0000 1.2 --- qtxml.rest 13 Mar 2006 09:22:03 -0000 1.3 *************** *** 54,60 **** 5. generated - directory that contains all generated code and only it ! 5. mixed - directory that contains generated and hand written code ! 6. unittests - directory that contains small example of using `Qt.Xml` module in `Python`_ --- 54,60 ---- 5. generated - directory that contains all generated code and only it ! 6. mixed - directory that contains generated and hand written code ! 7. unittests - directory that contains small example of using `Qt.Xml` module in `Python`_ |
From: Matthias B. <mb...@us...> - 2006-03-10 12:35:17
|
Update of /cvsroot/pygccxml/source/pyplusplus/experimental In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25413 Modified Files: pypp_api.py Log Message: Switched rename() to the new scheme Index: pypp_api.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/experimental/pypp_api.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pypp_api.py 10 Mar 2006 10:56:05 -0000 1.6 --- pypp_api.py 10 Mar 2006 12:35:14 -0000 1.7 *************** *** 63,68 **** By default all declarations are ignored. - @todo: Fix the parsing to work with recent changes - """ def __init__(self, headerFiles, workingDir=None, --- 63,66 ---- *************** *** 441,445 **** def rename(self, newName): """ Rename declaration to newName. """ ! self.mDecl.declDecorator.rename = newName return self --- 439,443 ---- def rename(self, newName): """ Rename declaration to newName. """ ! self.mDecl.rename(newName) return self |
From: Matthias B. <mb...@us...> - 2006-03-10 10:57:36
|
Update of /cvsroot/pygccxml/source/pyplusplus/module_creator In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21571/module_creator Modified Files: creator.py Log Message: Added doc strings Index: creator.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/module_creator/creator.py,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** creator.py 8 Mar 2006 09:30:34 -0000 1.60 --- creator.py 10 Mar 2006 10:57:31 -0000 1.61 *************** *** 17,20 **** --- 17,33 ---- class creator_t( declarations.decl_visitor_t ): + """Creating code creators. + + This class takes a set of declarations as input and creates a code + creator tree that contains the Boost.Python C++ source code for the + final extension module. Each node in the code creators tree represents + a block of text (C++ source code). + + Usage of this class: Create an instance and pass all relevant input + data to the constructor. Then call L{create()} to obtain the code + creator tree whose root node is a L{module_t<code_creators.module_t>} + object representing the source code for the entire extension module. + """ + def __init__( self , decls *************** *** 25,28 **** --- 38,58 ---- , types_db=None , target_configuration=None ): + """Constructor. + + @param decls: Declarations that should be exposed in the final module. + @param module_name: The name of the final module. + @param boost_python_ns_name: The alias for the boost::python namespace. + @param create_castinig_constructor: ...todo... + @param call_policies_resolver_: Callable that takes one declaration (calldef_t) as input and returns a call policy object which should be used for this declaration. + @param types_db: ...todo... + @param target_configuration: A target configuration object can be used to customize the generated source code to a particular compiler or a particular version of Boost.Python. + @type decls: list of declaration_t + @type module_name: str + @type boost_python_ns_name: str + @type create_castinig_constructor: bool + @type call_policies_resolver_: callable + @type types_db: L{types_database_t<types_database.types_database_t>} + @type target_configuration: L{target_configuration_t<code_creators.target_configuration_t>} + """ declarations.decl_visitor_t.__init__(self) *************** *** 281,286 **** """Create and return the module for the extension. ! declHeaders: If None the headers for the wrapped decls are automatically found. But you can pass a list of headers here to override that search. """ if not decl_headers: --- 311,318 ---- """Create and return the module for the extension. ! @param decl_headers: If None the headers for the wrapped decls are automatically found. But you can pass a list of headers here to override that search. + @returns: Returns the root of the code creators tree + @rtype: L{module_t<code_creators.module_t>} """ if not decl_headers: *************** *** 289,292 **** --- 321,325 ---- for h in decl_headers: self.__extmodule.adopt_include(code_creators.include_t(header=h)) + # Invoke the appropriate visit_*() method on all decls for decl in self.__decls: self.__curr_decl = decl |
From: Matthias B. <mb...@us...> - 2006-03-10 10:57:36
|
Update of /cvsroot/pygccxml/source/pyplusplus/decl_wrappers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21571/decl_wrappers Modified Files: __init__.py Log Message: Added doc strings Index: __init__.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/decl_wrappers/__init__.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** __init__.py 9 Mar 2006 01:47:19 -0000 1.3 --- __init__.py 10 Mar 2006 10:57:31 -0000 1.4 *************** *** 4,7 **** --- 4,37 ---- # http://www.boost.org/LICENSE_1_0.txt) + """Declaration decorators. + + This sub-package contains the pyplusplus specific declaration objects + that are the nodes of the declaration tree. In addition to the + interface of the declarations in the pygccxml package the objects in + this package also provide a I{decoration} interface. This interface + allows customizing the bindings and influences the code creators that + have to be generated in subsequent steps. + + Each node is derived from its corresponding node in the pygccxml + package and from a decorator base class. + + You may encounter the following objects in a declaration tree: + + - L{namespace_t} + - L{typedef_t} + - L{variable_t} + - L{enumeration_t} + - L{casting_operator_t} + - L{free_function_t} + - L{free_operator_t} + - L{class_declaration_t} + - L{class_t} + - L{constructor_t} + - L{destructor_t} + - L{member_function_t} + - L{member_operator_t} + + """ + from decl_wrapper import decl_wrapper_t |
From: Matthias B. <mb...@us...> - 2006-03-10 10:56:08
|
Update of /cvsroot/pygccxml/source/pyplusplus/experimental In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20609 Modified Files: pypp_api.py Log Message: 1) Removed the filtering in buildCreators() as this is now managed by pyplusplus. Now expose()/ignore() actually works again. 2) Fixed some typos Index: pypp_api.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/experimental/pypp_api.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pypp_api.py 9 Mar 2006 10:55:50 -0000 1.5 --- pypp_api.py 10 Mar 2006 10:56:05 -0000 1.6 *************** *** 60,64 **** """ Wrapper for a module (or part of a module). Captures handling of parsing and writing out bindings. ! Note: The pubic namespace '::' is the root decl for the Module. By default all declarations are ignored. --- 60,64 ---- """ Wrapper for a module (or part of a module). Captures handling of parsing and writing out bindings. ! Note: The public namespace '::' is the root decl for the Module. By default all declarations are ignored. *************** *** 92,96 **** self.mCacheFile = cacheFile # File to use for caching gccxml output self.mVerbose = verbose # Should there be verbose output during processing ! self.mDeclRoot = None # Root of the parsed decls self.mFinalDecls = None # Final list of decls to export self.mTemplates = [] # List of (templateType, typedefName) to instantiate --- 92,97 ---- self.mCacheFile = cacheFile # File to use for caching gccxml output self.mVerbose = verbose # Should there be verbose output during processing ! self.mDeclRoot = None # Root of the parsed decls (as declaration_t object) ! self.mDeclRootWrapper = None # The wrapper around mDeclRoot self.mFinalDecls = None # Final list of decls to export self.mTemplates = [] # List of (templateType, typedefName) to instantiate *************** *** 115,118 **** --- 116,121 ---- if self.mVerbose: print "Parsing headers: ", self.mHeaderFiles + + # Create and initialize the config object parser_cfg = parser.config_t(self.mGccXmlPath, self.mWorkingDir, *************** *** 134,143 **** temp_file.close() if self.mVerbose: ! print " creating template instatiation file: ", temp_filename full_header_list.append(temp_filename) ! the_parser = parser.project_reader_t(config=parser_cfg, cache=self.mCacheFile, decl_factory=decl_wrappers.dwfactory_t()) parsed_decls = the_parser.read_files(full_header_list, parser.project_reader.COMPILATION_MODE.FILE_BY_FILE) --- 137,148 ---- temp_file.close() if self.mVerbose: ! print " creating template instantiation file: ", temp_filename full_header_list.append(temp_filename) ! ! # Create the parser object... the_parser = parser.project_reader_t(config=parser_cfg, cache=self.mCacheFile, decl_factory=decl_wrappers.dwfactory_t()) + # ...and parse the headers parsed_decls = the_parser.read_files(full_header_list, parser.project_reader.COMPILATION_MODE.FILE_BY_FILE) *************** *** 189,204 **** # Filter the exposed decl list to create a final decl list. ! def filter(decl): ! expose = getattr(decl, "_expose_flag", False) ! return expose ! if self.mVerbose: ! print "Filtering module..." ! self.mFinalDecls = declarations.filtering.user_defined( self.mDeclRoot, filter) # Create creator.module_t for the module # - override the header files in create since we already know what files we used. ! maker = module_creator.creator_t(self.mFinalDecls, module_name=moduleName) extmodule = maker.create(decl_headers=self.mHeaderFiles) --- 194,213 ---- # Filter the exposed decl list to create a final decl list. ! # def filter(decl): ! # expose = getattr(decl, "_expose_flag", False) ! # return expose ! # if self.mVerbose: ! # print "Filtering module..." ! # self.mFinalDecls = declarations.filtering.user_defined( self.mDeclRoot, filter) ! ! # The above filtering is already done in pyplusplus as it stores ! # the "ignore" flag itself. [mbaas] # Create creator.module_t for the module # - override the header files in create since we already know what files we used. ! maker = module_creator.creator_t(self.mDeclRoot, module_name=moduleName) ! # maker = module_creator.creator_t(self.mFinalDecls, module_name=moduleName) extmodule = maker.create(decl_headers=self.mHeaderFiles) |
From: Matthias B. <mb...@us...> - 2006-03-09 11:01:37
|
Update of /cvsroot/pygccxml/source/pyplusplus/module_builder In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18746/module_builder Added Files: .cvsignore Log Message: Added .cvsignore files so that *.pyc files are ignored by cvs --- NEW FILE: .cvsignore --- *.pyc |
From: Matthias B. <mb...@us...> - 2006-03-09 11:01:37
|
Update of /cvsroot/pygccxml/source/pyplusplus/decl_wrappers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18746/decl_wrappers Added Files: .cvsignore Log Message: Added .cvsignore files so that *.pyc files are ignored by cvs --- NEW FILE: .cvsignore --- *.pyc |