[pygccxml-commit] SF.net SVN: pygccxml: [635] pyplusplus_dev/contrib/goodies
Brought to you by:
mbaas,
roman_yakovenko
From: <al...@us...> - 2006-10-09 21:44:54
|
Revision: 635 http://svn.sourceforge.net/pygccxml/?rev=635&view=rev Author: allenb Date: 2006-10-09 14:44:47 -0700 (Mon, 09 Oct 2006) Log Message: ----------- Add some changes I have had sitting around for a long time and need to get in. Modified Paths: -------------- pyplusplus_dev/contrib/goodies/__init__.py pyplusplus_dev/contrib/goodies/goodie_utils.py Modified: pyplusplus_dev/contrib/goodies/__init__.py =================================================================== --- pyplusplus_dev/contrib/goodies/__init__.py 2006-10-09 20:37:05 UTC (rev 634) +++ pyplusplus_dev/contrib/goodies/__init__.py 2006-10-09 21:44:47 UTC (rev 635) @@ -11,7 +11,8 @@ import goodie_overrides from goodie_utils import (set_recursive_default, set_allow_empty_mdecl_default, - finalize, add_member_function, wrap_method, add_method, + finalize, decl_from_typedef, + add_member_function, wrap_method, add_method, is_const_ref, exclude_protected, wrap_const_ref_params, TemplateBuilder) Modified: pyplusplus_dev/contrib/goodies/goodie_utils.py =================================================================== --- pyplusplus_dev/contrib/goodies/goodie_utils.py 2006-10-09 20:37:05 UTC (rev 634) +++ pyplusplus_dev/contrib/goodies/goodie_utils.py 2006-10-09 21:44:47 UTC (rev 635) @@ -16,6 +16,8 @@ import copy import re +# TODO: +# - extend add_member_function to include method to add def set_recursive_default(val): pd.scopedef_t.RECURSIVE_DEFAULT = val @@ -23,6 +25,16 @@ def set_allow_empty_mdecl_default(val): pd.scopedef_t.ALLOW_EMPTY_MDECL_WRAPPER = val + +def decl_from_typedef(decl): + """ decl: decl or mdecl with typedef. Return the "real" decl. """ + typedef_decl = decl + if isinstance(typedef_decl, pd.mdecl_wrapper_t): + typedef_decl = decl[0] + assert isinstance(typedef_decl, pd.typedef_t) + return typedef_decl.type.declaration + + def finalize(cls): """ Attempt to finalize a class by not exposing virtual methods. Still exposes in the case of pure virtuals otherwise the class @@ -54,7 +66,6 @@ code_text = 'boost::python::def("%s",%s);'%(methodName, method) moduleBuilder.add_registration_code(code_text) - def is_const_ref(type): """ Extra trait tester method to check if something is a const reference. """ is_const = tt.is_const(type) or (hasattr(type,'base') and tt.is_const(type.base)) @@ -139,13 +150,13 @@ to allow access to the template at a later time. TODO: If used a form that allowed multiple templates to be specified - ex: TemplateWrapper("osg::vector", arguments=[["float","3"],["int","4"]] + ex: TemplateWrapper("OSG::vector", arguments=[["float","3"],["int","4"]] then how would we handle naming? Automatic or must be specified? """ def __init__(self, templateType, finalName = None): #, arguments=None): """ - templateType: Either a base type ("osg::vector") or a full template - type ("osg::vector<float>") + templateType: Either a base type ("OSG::vector") or a full template + type ("OSG::vector<float>") finalName: Name to rename the decl to after finding it. """ self.mTemplateType = templateType @@ -187,7 +198,7 @@ Usage: tb = TemplateBuilder() - vec3f_t = tb.Template("osg::vector<float,3>") + vec3f_t = tb.Template("OSG::vector<float,3>") # Add autogen code to a header that is included mb = moduble_builder_t([myheaders]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |