[pygccxml-commit] SF.net SVN: pygccxml: [308] pyplusplus_dev/unittests
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-07-17 18:18:38
|
Revision: 308 Author: roman_yakovenko Date: 2006-07-17 11:18:24 -0700 (Mon, 17 Jul 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=308&view=rev Log Message: ----------- adding documentation to generated code Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/calldef.py pyplusplus_dev/pyplusplus/code_creators/class_declaration.py pyplusplus_dev/pyplusplus/code_creators/declaration_based.py pyplusplus_dev/pyplusplus/code_creators/member_variable.py pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py pyplusplus_dev/unittests/fundamental_tester_base.py Modified: pyplusplus_dev/pyplusplus/code_creators/calldef.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/calldef.py 2006-07-17 14:03:30 UTC (rev 307) +++ pyplusplus_dev/pyplusplus/code_creators/calldef.py 2006-07-17 18:18:24 UTC (rev 308) @@ -71,7 +71,10 @@ return '%s.def' % self.parent.class_var_name else: return 'def' - + + def create_doc(self): + return self.documentation + def create_function_ref_code( self, use_function_alias=False ): raise NotImplementedError() @@ -100,8 +103,8 @@ result.append( self.create_def_code() + '( ' ) result.append( os.linesep + self.indent( '"%s"' % self.alias ) ) + result.append( self.param_sep() ) - result.append( self.create_function_ref_code( not self.works_on_instance ) ) if self.declaration.use_keywords: @@ -114,6 +117,11 @@ else: result.append( os.linesep + self.indent( '/* undefined call policies */', 2 ) ) + doc = self.create_doc() + if doc: + result.append( self.param_sep() ) + result.append( doc ) + result.append( ' )' ) if not self.works_on_instance: result.append( ';' ) @@ -316,6 +324,9 @@ ftype = self.wrapper.function_type() result.append( 'typedef %s;' % ftype.create_typedef( self.default_function_type_alias ) ) return ''.join( result ) + + def create_doc(self): + return None def create_function_ref_code(self, use_function_alias=False): result = [] @@ -817,10 +828,16 @@ init_identifier = algorithm.create_identifier( self, '::boost::python::init' ) args = [ self._generate_definition_args() ] answer = [ '%s' % declarations.templates.join( init_identifier, args ) ] + answer.append( '(' ) + keywords_args = None if self.declaration.use_keywords: - answer.append( '(%s)' % self.keywords_args() ) - else: - answer.append( '()' ) + keywords_args = self.keywords_args() + answer.append( '%s' % keywords_args ) + if self.documentation: + if keywords_args: + answer.append( ', ' ) + answer.append( self.documentation ) + answer.append( ')' ) if self.declaration.call_policies: answer.append('[%s]' % self.declaration.call_policies.create( self ) ) #I think it better not to print next line @@ -1063,7 +1080,7 @@ self._call_policies = None def _create_impl(self): - template = 'def( "%(function_name)s", &%(class_name)s::operator %(destination_type)s %(call_policies)s )' + template = 'def( "%(function_name)s", &%(class_name)s::operator %(destination_type)s %(call_policies)s%(doc)s )' class_name = algorithm.create_identifier( self , declarations.full_name( self.declaration.parent ) ) @@ -1071,11 +1088,16 @@ policies = '/*, undefined call policies */' if self.declaration.call_policies: policies = ',' + self.declaration.call_policies.create( self ) - + + doc = '' + if self.documentation: + doc = ', %s' % self.documentation + return template % { 'function_name' : self.declaration.alias , 'class_name' : class_name , 'destination_type' : self.declaration.return_type.decl_string , 'call_policies' : policies + , 'doc' : doc } class casting_constructor_t( declaration_based.declaration_based_t ): Modified: pyplusplus_dev/pyplusplus/code_creators/class_declaration.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/class_declaration.py 2006-07-17 14:03:30 UTC (rev 307) +++ pyplusplus_dev/pyplusplus/code_creators/class_declaration.py 2006-07-17 18:18:24 UTC (rev 308) @@ -190,6 +190,8 @@ result = [] result.append( '(' ) result.append( ' "%s"' % self.alias ) + if self.documentation: + result.append( ', %s' % self.documentation ) used_init = None inits = filter( lambda x: isinstance( x, calldef.constructor_t ), self.creators ) if ( self.declaration.is_abstract \ Modified: pyplusplus_dev/pyplusplus/code_creators/declaration_based.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/declaration_based.py 2006-07-17 14:03:30 UTC (rev 307) +++ pyplusplus_dev/pyplusplus/code_creators/declaration_based.py 2006-07-17 18:18:24 UTC (rev 308) @@ -37,7 +37,6 @@ def _get_alias(self): return self.declaration.alias - def _set_alias(self, alias): self.declaration.alias = alias alias = property( _get_alias, _set_alias ) @@ -45,4 +44,9 @@ def _get_decl_identifier( self ): return algorithm.create_identifier( self, self.declaration.decl_string ) decl_identifier = property( _get_decl_identifier ) - \ No newline at end of file + + @property + def documentation( self ): + if None is self.declaration.documentation: + return '' + return self.declaration.documentation Modified: pyplusplus_dev/pyplusplus/code_creators/member_variable.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2006-07-17 14:03:30 UTC (rev 307) +++ pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2006-07-17 18:18:24 UTC (rev 308) @@ -36,9 +36,12 @@ #> On Wednesday, 19. April 2006 23:05, Ralf W. Grosse-Kunstleve wrote: #> .add_property("p", make_function(&A::get_p, return_value_policy<reference_existing_object>())) def _generate_for_pointer( self ): + doc = '' #static property does not support documentation if self.declaration.type_qualifiers.has_static: add_property = 'add_static_property' else: + if self.documentation: + doc = self.documentation add_property = 'add_property' answer = [ add_property ] answer.append( '( ' ) @@ -66,6 +69,9 @@ , 'setter_type' : self.wrapper.setter_type , 'wfname' : self.wrapper.setter_full_name , 'call_pol' : call_pol } ) + if doc: + answer.append( self.PARAM_SEPARATOR ) + answer.append( doc ) answer.append( ' ) ' ) code = ''.join( answer ) @@ -80,18 +86,21 @@ def _generate_for_none_pointer( self ): tmpl = None if self.declaration.type_qualifiers.has_static: - tmpl = '%(access)s( "%(alias)s", %(name)s )' + tmpl = '%(access)s( "%(alias)s", %(name)s%(doc)s )' else: - tmpl = '%(access)s( "%(alias)s", &%(name)s )' + tmpl = '%(access)s( "%(alias)s", &%(name)s%(doc)s )' access = 'def_readwrite' if self.is_read_only(): access = 'def_readonly' - + doc = '' + if self.documentation: + doc = ', %s' % self.documentation result = tmpl % { 'access' : access , 'alias' : self.alias - , 'name' : algorithm.create_identifier( self, self.declaration.decl_string ) } + , 'name' : algorithm.create_identifier( self, self.declaration.decl_string ) + , 'doc' : doc } return result @@ -232,9 +241,12 @@ member_variable_base_t.__init__( self, variable=variable, wrapper=wrapper ) def _create_impl( self ): + doc = '' if self.declaration.type_qualifiers.has_static: add_property = 'add_static_property' else: + if self.documentation: + doc = self.documentation add_property = 'add_property' answer = [ add_property ] answer.append( '( ' ) @@ -247,6 +259,9 @@ answer.append( self.PARAM_SEPARATOR ) answer.append( '(%s)(&%s)' % ( self.wrapper.setter_type, self.wrapper.setter_full_name ) ) + if doc: + answer.append( self.PARAM_SEPARATOR ) + answer.append( doc ) answer.append( ' ) ' ) code = ''.join( answer ) @@ -327,9 +342,12 @@ def _create_impl( self ): assert isinstance( self.wrapper, array_mv_wrapper_t ) + doc = '' if self.declaration.type_qualifiers.has_static: answer = [ 'add_static_property' ] else: + if self.documentation: + doc = self.documentation answer = [ 'add_property' ] answer.append( '( ' ) answer.append('"%s"' % self.declaration.name ) @@ -344,6 +362,9 @@ temp.append( call_policies.with_custodian_and_ward_postcall( 0, 1 ).create(self) ) temp.append( ' )' ) answer.append( ''.join( temp ) ) + if doc: + answer.append( self.PARAM_SEPARATOR ) + answer.append( doc ) answer.append( ' );' ) return ''.join( answer ) @@ -423,6 +444,9 @@ answer.append( self.declaration.getter_call_policies.create( self ) ) else: answer.append( os.linesep + self.indent( '/* undefined call policies */', 2 ) ) + if self.documentation: + answer.append( self.param_sep ) + answer.append( self.documentation ) answer.append( ' )' ) return ''.join( answer ) Modified: pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2006-07-17 14:03:30 UTC (rev 307) +++ pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2006-07-17 18:18:24 UTC (rev 308) @@ -34,11 +34,20 @@ self._ignore = False self._exportable = None self._exportable_reason = None + self._documentation = None @property def logger( self ): return _logging_.loggers.declarations - + + def _get_documentation( self ): + return self._documentation + + def _set_documentation( self, value ): + self._documentation = value + documentation = property( _get_documentation, _set_documentation + , doc="Using this property you can set documentatio of exported declaration." ) + def _generate_valid_name(self, name=None): if name == None: name = self.name Modified: pyplusplus_dev/unittests/fundamental_tester_base.py =================================================================== --- pyplusplus_dev/unittests/fundamental_tester_base.py 2006-07-17 14:03:30 UTC (rev 307) +++ pyplusplus_dev/unittests/fundamental_tester_base.py 2006-07-17 18:18:24 UTC (rev 308) @@ -57,6 +57,8 @@ , include_paths=[autoconfig.boost.include] , undefine_symbols=['__MINGW32__'] , indexing_suite_version=self.__indexing_suite_version) + for decl in mb.decls(): + decl.documentation = '"documentation"' self.customize( mb ) if not mb.has_code_creator(): mb.build_code_creator( self.__module_name ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |