pygccxml-commit Mailing List for C++ Python language bindings (Page 26)
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: <rom...@us...> - 2008-02-06 10:07:05
|
Revision: 1234 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1234&view=rev Author: roman_yakovenko Date: 2008-02-06 02:07:10 -0800 (Wed, 06 Feb 2008) Log Message: ----------- casting constructor will be generated in the same file as the exposed class Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/calldef.py pyplusplus_dev/pyplusplus/module_creator/creator.py pyplusplus_dev/unittests/data/split_module_to_be_exported.hpp Modified: pyplusplus_dev/pyplusplus/code_creators/calldef.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/calldef.py 2008-02-06 07:55:18 UTC (rev 1233) +++ pyplusplus_dev/pyplusplus/code_creators/calldef.py 2008-02-06 10:07:10 UTC (rev 1234) @@ -55,7 +55,7 @@ if self.declaration.call_policies.is_default(): return '' return self.declaration.call_policies.create( self ) - + def create_def_code( self ): if not self.works_on_instance: return '%s.def' % self.parent.class_var_name @@ -180,7 +180,7 @@ ft = self.declaration.transformations[0] files.extend( ft.required_headers() ) if self.declaration.call_policies: - files.append( self.declaration.call_policies.header_file ) + files.append( self.declaration.call_policies.header_file ) return files class free_function_t( calldef_t ): @@ -213,7 +213,7 @@ return 'typedef %s;' % ftype.create_typedef( self.function_type_alias, exported_class_alias, with_defaults=False ) def create_function_ref_code(self, use_function_alias=False): - fname = declarations.full_name( self.declaration, with_defaults=False ) + fname = declarations.full_name( self.declaration, with_defaults=False ) if use_function_alias: return '%s( &%s )' % ( self.function_type_alias, fname ) elif self.declaration.create_with_signature: @@ -230,7 +230,7 @@ return 'typedef %s;' % ftype.create_typedef( self.function_type_alias, exported_class_alias ) def create_function_ref_code(self, use_function_alias=False): - fname = declarations.full_name( self.declaration, with_defaults=False ) + fname = declarations.full_name( self.declaration, with_defaults=False ) if use_function_alias: return '%s( %s(&%s) )' \ % ( self.pure_virtual_identifier() @@ -300,14 +300,14 @@ result = [] ftype = self.declaration.function_type() - result.append( 'typedef %s;' + result.append( 'typedef %s;' % ftype.create_typedef( self.function_type_alias , exported_class_alias , with_defaults=False) ) if self.wrapper: result.append( os.linesep ) ftype = self.wrapper.function_type() - result.append( 'typedef %s;' + result.append( 'typedef %s;' % ftype.create_typedef( self.default_function_type_alias , with_defaults=False) ) return ''.join( result ) @@ -613,7 +613,7 @@ def create_virtual_body(self): template = [] - + precall_code = self.declaration.override_precall_code if precall_code: template.append( os.linesep.join( precall_code ) ) @@ -758,7 +758,7 @@ return self.unoverriden_function_body() template = [] - + precall_code = self.declaration.override_precall_code if precall_code: template.append( os.linesep.join( precall_code ) ) @@ -863,7 +863,7 @@ return 'staticmethod( "%s" )' % self.function_code_creator.alias def _get_system_headers_impl( self ): - return [] + return [] class constructor_wrapper_t( calldef_wrapper_t ): """ @@ -966,7 +966,7 @@ def __init__( self, class_ ): code_creator.code_creator_t.__init__( self ) declaration_based.declaration_based_t.__init__( self, declaration=class_ ) - + def _create_constructor_call( self ): return algorithm.create_identifier( self, self.declaration.decl_string ) + '()' @@ -1037,7 +1037,7 @@ if self.declaration.symbol == '<<': str_identifier = algorithm.create_identifier( self, '::boost::python::self_ns::str' ) return '%s( %s )' % ( str_identifier, self_identifier ) - + answer = [ None, self.declaration.symbol, None ] self_position = self._findout_self_position() if self_position == self.SELF_POSITION.FIRST: @@ -1130,7 +1130,7 @@ def _get_system_headers_impl( self ): return [] - + class casting_constructor_t( registration_based.registration_based_t , declaration_based.declaration_based_t ): """ @@ -1141,6 +1141,7 @@ def __init__( self, constructor ): registration_based.registration_based_t.__init__( self ) declaration_based.declaration_based_t.__init__( self, declaration=constructor ) + self.works_on_instance = False def _create_impl(self): implicitly_convertible = algorithm.create_identifier( self, '::boost::python::implicitly_convertible' ) @@ -1207,7 +1208,7 @@ @property def name( self ): return '%s_%s_overloads' % ( self.parent_decl.alias, self.alias ) - + class mem_fun_overloads_class_t( calldef_overloads_class_t ): def __init__( self, mem_funs ): #precondition: all member functions belong to same class and Modified: pyplusplus_dev/pyplusplus/module_creator/creator.py =================================================================== --- pyplusplus_dev/pyplusplus/module_creator/creator.py 2008-02-06 07:55:18 UTC (rev 1233) +++ pyplusplus_dev/pyplusplus/module_creator/creator.py 2008-02-06 10:07:10 UTC (rev 1234) @@ -99,10 +99,10 @@ self.__module_body = code_creators.module_body_t( name=module_name ) self.__extmodule.adopt_creator( self.__module_body ) - + self.__opaque_types_manager = opaque_types_manager.manager_t( self.__extmodule ) self.__dependencies_manager = dependencies_manager.manager_t(self.decl_logger) - + prepared_decls = self._prepare_decls( decls, doc_extractor ) self.__decls = sort_algorithms.sort( prepared_decls ) @@ -116,8 +116,8 @@ def __print_readme( self, decl ): readme = decl.readme() if not readme: - return - + return + if not decl.exportable: reason = readme[0] readme = readme[1:] @@ -134,20 +134,20 @@ if isinstance( decl, declarations.namespace_t ): continue - + if not decl.exportable: #leave only decls that user wants to export and that could be exported self.__print_readme( decl ) continue - + if decl.already_exposed: #check wether this is already exposed in other module continue - + if isinstance( decl.parent, declarations.namespace_t ): #leave only declarations defined under namespace, but remove namespaces to_be_exposed.append( decl ) - + #Right now this functionality introduce a bug: declarations that should #not be exported for some reason are not marked as such. I will need to #find out. @@ -158,12 +158,12 @@ #if isinstance( decl, declarations.variable_t ): #self.__types_db.update( decl ) - + if doc_extractor: decl.documentation = doc_extractor( decl ) self.__print_readme( decl ) - + return to_be_exposed def _adopt_free_operator( self, operator ): @@ -281,7 +281,7 @@ used_containers = filter( lambda cls: cls.indexing_suite.include_files , used_containers ) used_containers.sort( cmp_by_name ) - for cls in used_containers: + for cls in used_containers: self.__print_readme( cls ) if cls.already_exposed: @@ -310,7 +310,7 @@ element_type_cc = code_creators.value_traits_t( value_cls ) self.__extmodule.adopt_declaration_creator( element_type_cc ) cls_creator.adopt_creator( code_creators.indexing_suite2_t(cls) ) - + creators.reverse() self.__module_body.adopt_creators( creators, 0 ) @@ -335,7 +335,7 @@ creator.target_configuration = self.__target_configuration #last action. self._append_user_code() - + add_include = self.__extmodule.add_include #add system headers system_headers = self.__extmodule.get_system_headers( recursive=True, unique=True ) @@ -343,12 +343,12 @@ , system_headers ) #add user defined header files if decl_headers is None: - decl_headers = declarations.declaration_files( self.__decls ) + decl_headers = declarations.declaration_files( self.__decls ) map( lambda header: add_include( header, user_defined=False, system=False ) , decl_headers ) - + self.__dependencies_manager.inform_user() - + return self.__extmodule def visit_member_function( self ): @@ -357,7 +357,7 @@ self.__dependencies_manager.add_exported( self.curr_decl ) if None is self.curr_decl.call_policies: self.curr_decl.call_policies = self.__call_policies_resolver( self.curr_decl ) - + maker_cls, fwrapper_cls = creators_wizard.find_out_mem_fun_creator_classes( self.curr_decl ) maker = None @@ -382,7 +382,7 @@ maker = maker_cls( function=self.curr_decl ) self.curr_code_creator.adopt_creator( maker ) self.__opaque_types_manager.register_opaque( maker, self.curr_decl ) - + if self.curr_decl.has_static: #static_method should be created only once. found = filter( lambda creator: isinstance( creator, code_creators.static_method_t ) @@ -396,16 +396,13 @@ def visit_constructor( self ): self.__types_db.update( self.curr_decl ) self.__dependencies_manager.add_exported( self.curr_decl ) - if self.curr_decl.allow_implicit_conversion: - maker = code_creators.casting_constructor_t( constructor=self.curr_decl ) - self.__module_body.adopt_creator( maker ) cwrapper = None if self.curr_decl.parent.is_wrapper_needed(): class_wrapper = self.curr_code_creator.wrapper cwrapper = code_creators.constructor_wrapper_t( constructor=self.curr_decl ) class_wrapper.adopt_creator( cwrapper ) -#TODO: FT for constructor + #TODO: FT for constructor #~ if self.curr_decl.transformations: #~ cwrapper = code_creators.constructor_transformed_wrapper_t( constructor=self.curr_decl ) #~ class_wrapper.adopt_creator( cwrapper ) @@ -415,7 +412,6 @@ #~ class_wrapper.adopt_creator( cwrapper ) #~ self.__module_body.adopt_creator( cwrapper ) #~ self.curr_code_creator.associated_decl_creators.append( cwrapper ) - #~ maker = None #~ if self.curr_decl.transformations: #~ maker = code_creators.constructor_transformed_t( constructor=self.curr_decl ) @@ -425,6 +421,12 @@ self.curr_decl.call_policies = self.__call_policies_resolver( self.curr_decl ) self.curr_code_creator.adopt_creator( maker ) + if self.curr_decl.allow_implicit_conversion: + maker = code_creators.casting_constructor_t( constructor=self.curr_decl ) + #casting constructor will be generated in the same file as class + self.curr_code_creator.adopt_creator( maker ) + + def visit_destructor( self ): pass @@ -441,13 +443,13 @@ self.__dependencies_manager.add_exported( self.curr_decl ) if None is self.curr_decl.call_policies: self.curr_decl.call_policies = self.__call_policies_resolver( self.curr_decl ) - + self.__types_db.update( self.curr_decl ) if not self.curr_decl.parent.is_abstract and not declarations.is_reference( self.curr_decl.return_type ): maker = code_creators.casting_operator_t( operator=self.curr_decl ) self.__module_body.adopt_creator( maker ) self.__opaque_types_manager.register_opaque( maker, self.curr_decl ) - + #what to do if class is abstract maker = code_creators.casting_member_operator_t( operator=self.curr_decl ) self.curr_code_creator.adopt_creator( maker ) @@ -480,7 +482,7 @@ self.curr_code_creator.adopt_creator( overloads_reg ) overloads_reg.associated_decl_creators.append( overloads_cls_creator ) self.__opaque_types_manager.register_opaque( overloads_reg, overloads ) - + ctext_t = code_creators.custom_text_t for f in overloads: uc_creators = map( lambda uc: ctext_t( uc.text ), f.declaration_code ) @@ -492,7 +494,7 @@ self.__dependencies_manager.add_exported( self.curr_decl ) if None is self.curr_decl.call_policies: self.curr_decl.call_policies = self.__call_policies_resolver( self.curr_decl ) - + maker = None if self.curr_decl.transformations: wrapper = code_creators.free_fun_transformed_wrapper_t( self.curr_decl ) @@ -509,7 +511,7 @@ insert_pos = self.__extmodule.creators.index( self.__module_body ) self.__extmodule.adopt_creators( uc_creators, insert_pos ) maker.associated_decl_creators.extend( uc_creators ) - + def visit_free_operator( self ): self.__types_db.update( self.curr_decl ) self.__free_operators.append( self.curr_decl ) @@ -576,7 +578,7 @@ #find out whether user or compiler defined it if self.curr_decl.noncopyable: add_to_wrapper = False - elif not copy_constr: + elif not copy_constr: add_to_wrapper = True #compiler defined will not be exposed manually later elif copy_constr.is_artificial: add_to_wrapper = True #compiler defined will not be exposed manually later @@ -592,7 +594,7 @@ add_to_wrapper = True if add_to_wrapper: tcons = code_creators.null_constructor_wrapper_t( class_=self.curr_decl ) - wrapper.adopt_creator( tcons ) + wrapper.adopt_creator( tcons ) else: if declarations.has_copy_constructor( self.curr_decl ): copy_constr = self.curr_decl.find_copy_constructor() @@ -604,7 +606,7 @@ #this constructor is not going to be exposed tcons = code_creators.null_constructor_wrapper_t( class_=self.curr_decl ) wrapper.adopt_creator( tcons ) - + exposed = self.expose_overloaded_mem_fun_using_macro( cls_decl, cls_cc ) cls_parent_cc.adopt_creator( cls_cc ) @@ -670,7 +672,7 @@ def visit_variable(self): self.__types_db.update( self.curr_decl ) self.__dependencies_manager.add_exported( self.curr_decl ) - + if declarations.is_array( self.curr_decl.type ): if self._register_array_1( self.curr_decl.type ): array_1_registrator = code_creators.array_1_registrator_t( array_type=self.curr_decl.type ) Modified: pyplusplus_dev/unittests/data/split_module_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/split_module_to_be_exported.hpp 2008-02-06 07:55:18 UTC (rev 1233) +++ pyplusplus_dev/unittests/data/split_module_to_be_exported.hpp 2008-02-06 10:07:10 UTC (rev 1234) @@ -57,6 +57,14 @@ return str2item_t(); } +class CodeInject +{ +public: +CodeInject(int value_) : value(value_) {} + +int value; +}; + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-02-06 07:55:16
|
Revision: 1233 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1233&view=rev Author: roman_yakovenko Date: 2008-02-05 23:55:18 -0800 (Tue, 05 Feb 2008) Log Message: ----------- adding new test Modified Paths: -------------- pyplusplus_dev/unittests/test_all.py Added Paths: ----------- pyplusplus_dev/unittests/data/deepcopy_to_be_exported.hpp pyplusplus_dev/unittests/deepcopy_tester.py Added: pyplusplus_dev/unittests/data/deepcopy_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/deepcopy_to_be_exported.hpp (rev 0) +++ pyplusplus_dev/unittests/data/deepcopy_to_be_exported.hpp 2008-02-06 07:55:18 UTC (rev 1233) @@ -0,0 +1,33 @@ +// Copyright 2004 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) + +#ifndef __deepcopy_to_be_exported_hpp__ +#define __deepcopy_to_be_exported_hpp__ + +#include <vector> + +namespace deepcopy{ + +struct item_t{ + item_t(){ + id = reinterpret_cast< int >( this ); + } + int id; +}; + +typedef std::vector< item_t > items_t; + +inline items_t create_items(){ + items_t items; + items.push_back( item_t() ); + items.push_back( item_t() ); + items.push_back( item_t() ); + return items; +} + +}//statics + + +#endif//__deepcopy_to_be_exported_hpp__ Added: pyplusplus_dev/unittests/deepcopy_tester.py =================================================================== --- pyplusplus_dev/unittests/deepcopy_tester.py (rev 0) +++ pyplusplus_dev/unittests/deepcopy_tester.py 2008-02-06 07:55:18 UTC (rev 1233) @@ -0,0 +1,41 @@ +# Copyright 2004 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) + +import os +import sys +import copy +import unittest +import fundamental_tester_base +from pyplusplus import code_creators + +class tester_t(fundamental_tester_base.fundamental_tester_base_t): + EXTENSION_NAME = 'deepcopy' + + def __init__( self, *args ): + fundamental_tester_base.fundamental_tester_base_t.__init__( + self + , tester_t.EXTENSION_NAME + , indexing_suite_version=2 + , *args ) + + def customize( self, mb ): + pass + + def run_tests( self, module): + items = module.create_items() + for i in items: + print i.id + self.failIfNotRaisesAny( copy.deepcopy, items ) + +def create_suite(): + suite = unittest.TestSuite() + suite.addTest( unittest.makeSuite(tester_t)) + return suite + +def run_suite(): + unittest.TextTestRunner(verbosity=2).run( create_suite() ) + +if __name__ == "__main__": + run_suite() Modified: pyplusplus_dev/unittests/test_all.py =================================================================== --- pyplusplus_dev/unittests/test_all.py 2008-02-04 16:08:50 UTC (rev 1232) +++ pyplusplus_dev/unittests/test_all.py 2008-02-06 07:55:18 UTC (rev 1233) @@ -83,6 +83,7 @@ import custom_string_tester import final_classes_tester import templates_tester +import deepcopy_tester #gui_tester #gui_wizard_tester # @@ -185,6 +186,7 @@ , precompiled_header_tester , balanced_files_tester , ft_inout_tester + , deepcopy_tester ] class module_runner_t( object ): @@ -192,11 +194,11 @@ test_name_re = re.compile( '(?P<name>.+ \(.+\))\s\.\.\.' ) failed_test_re = re.compile( 'FAIL\:\s(?P<name>.+ \(.+\))' ) error_test_re = re.compile( 'ERROR\:\s(?P<name>.+ \(.+\))' ) - + def __init__( self, module ): self.module = module self.output = None - + self.test_results = {} #test name : result self.num_of_tests = 0 self.total_run_time = 0 @@ -204,7 +206,7 @@ def __call__( self ): print os.linesep, '<*> start %s tester' % os.path.basename( self.module.__file__) - + test_file_name = self.module.__file__ if test_file_name.endswith( 'pyc' ): test_file_name = test_file_name[:-1] @@ -219,11 +221,11 @@ break else: print data, - self.output = ''.join( report ) + self.output = ''.join( report ) self.exit_status = output.close() self.__update() print '<***> finish %s tester' % os.path.basename( self.module.__file__) - + def __create_unique_name( self, name ): if '__main__.' in name: name = name.replace( '__main__', os.path.basename( self.module.__file__)[:-4] ) @@ -231,14 +233,14 @@ def __update( self ): match_found = self.bottom_line_re.search( self.output ) - if match_found: + if match_found: self.num_of_tests += int( match_found.group( 'num_of_tests' ) ) self.total_run_time += float( match_found.group( 'seconds' ) ) - + uname = self.__create_unique_name for match_found in self.test_name_re.finditer( self.output ): self.test_results[ uname( match_found.group( 'name' ) ) ] = 'ok' - + for match_found in self.failed_test_re.finditer( self.output ): self.test_results[ uname( match_found.group( 'name' ) ) ] = 'FAIL' @@ -249,11 +251,11 @@ class process_tester_runner_t( object ): - + def __init__( self, modules ): self.__m_runners = [ module_runner_t(m) for m in modules ] self.__total_time = 0 - + def __dump_statistics( self ): num_of_tests = 0 test_results = {} @@ -265,20 +267,20 @@ test_results.update( stat.test_results ) exit_status = max( exit_status, stat.exit_status ) test_failed = len( filter( lambda result: result != 'ok', test_results.values() ) ) - + for name, result in test_results.iteritems(): if result != 'ok': print '! ', print name, ' - ', result - print '----------------------------------------------------------------------' + print '----------------------------------------------------------------------' print 'Final exit status: ', exit_status print 'Ran %d test in %fs. Multi-processing overhead: %fs.' \ % ( num_of_tests, self.__total_time, self.__total_time - total_tests_only_run_time ) print ' ' if test_failed: - print os.linesep.join(['FAILED (failures=%d)' % test_failed, 'False']) + print os.linesep.join(['FAILED (failures=%d)' % test_failed, 'False']) else: - print 'ok' + print 'ok' def __call__( self ): start_time = time.time() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-02-04 16:08:45
|
Revision: 1232 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1232&view=rev Author: roman_yakovenko Date: 2008-02-04 08:08:50 -0800 (Mon, 04 Feb 2008) Log Message: ----------- Added Paths: ----------- pygccxml_dev/pygccxml/parser/pdb_reader.py Added: pygccxml_dev/pygccxml/parser/pdb_reader.py =================================================================== --- pygccxml_dev/pygccxml/parser/pdb_reader.py (rev 0) +++ pygccxml_dev/pygccxml/parser/pdb_reader.py 2008-02-04 16:08:50 UTC (rev 1232) @@ -0,0 +1,26 @@ +import os +import sys +import comtypes.client +from sets import Set as set + +#~ MODULE_IDENTIFIER = ('{106173A0-0173-4e5c-84E7-E915422BE997}', 0, 2, 0) +#~ MODULE_PATH = r'Lib\site-packages\win32com\gen_py\106173A0-0173-4e5c-84E7-E915422BE997x0x2x0.py' + +#~ try: + #~ full_module_path = os.path.split( sys.executable )[0] + #~ full_module_path = os.path.join( full_module_path, MODULE_PATH ) + #~ if os.path.exists( full_module_path ): + #~ os.remove( full_module_path ) + #~ print(full_module_path, " removed successfully") +#~ except Exception, error: + #~ print 'Exception:', str(error) + +#~ msdia = win32com.client.gencache.EnsureModule( *MODULE_IDENTIFIER ) + +ds = comtypes.client.CreateObject( "{e60afbee-502d-46ae-858f-8272a09bd707}" ) +ds.loadDataFromPdb( 'xxx.pdb' ) + +#~ ds = msdia.DiaSource() +#~ ds.loadDataFromPdb( 'xxx.pdb' ) +#~ session = ds.openSession() +#~ print 'done' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-02-04 06:36:49
|
Revision: 1231 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1231&view=rev Author: roman_yakovenko Date: 2008-02-03 22:36:54 -0800 (Sun, 03 Feb 2008) Log Message: ----------- adding new unit test Modified Paths: -------------- pyplusplus_dev/unittests/test_all.py Added Paths: ----------- pyplusplus_dev/unittests/data/ft_inout_bugs_to_be_exported.hpp pyplusplus_dev/unittests/ft_inout_tester.py Added: pyplusplus_dev/unittests/data/ft_inout_bugs_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/ft_inout_bugs_to_be_exported.hpp (rev 0) +++ pyplusplus_dev/unittests/data/ft_inout_bugs_to_be_exported.hpp 2008-02-04 06:36:54 UTC (rev 1231) @@ -0,0 +1,20 @@ + +namespace tests{ + +inline void set_flag( bool value, bool& flag ){ + flag = value; +} + +struct base{ + virtual void set_flag( bool value, bool& flag ){ + flag = value; + } +}; + +struct inventor : base{ + virtual void set_flag( bool value, bool& flag ){ + flag = !value; + } +}; + +} Added: pyplusplus_dev/unittests/ft_inout_tester.py =================================================================== --- pyplusplus_dev/unittests/ft_inout_tester.py (rev 0) +++ pyplusplus_dev/unittests/ft_inout_tester.py 2008-02-04 06:36:54 UTC (rev 1231) @@ -0,0 +1,52 @@ +# Copyright 2004 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) + +import os +import sys +import math +import unittest +import fundamental_tester_base +from pygccxml import declarations +from pyplusplus import function_transformers as ft +from pyplusplus.module_builder import call_policies + + +class tester_t(fundamental_tester_base.fundamental_tester_base_t): + EXTENSION_NAME = 'ft_inout_bugs' + + def __init__( self, *args ): + fundamental_tester_base.fundamental_tester_base_t.__init__( + self + , tester_t.EXTENSION_NAME + , *args ) + + def customize( self, mb ): + #~ mb.global_ns.exclude() + #~ mb.namespace( 'tests' ).include() + set_flag = mb.calldefs( 'set_flag' ) + set_flag.add_transformation( ft.inout(1) ) + + def run_tests(self, module): + x = False + self.failUnless( True == module.set_flag( True, x ) ) + self.failUnless( False == module.set_flag( False, x ) ) + b = module.base() + self.failUnless( True == b.set_flag( True, x ) ) + self.failUnless( False == b.set_flag( False, x ) ) + inventor = module.inventor() + self.failUnless( False == inventor.set_flag( True, x ) ) + self.failUnless( True == inventor.set_flag( False, x ) ) + + +def create_suite(): + suite = unittest.TestSuite() + suite.addTest( unittest.makeSuite(tester_t)) + return suite + +def run_suite(): + unittest.TextTestRunner(verbosity=2).run( create_suite() ) + +if __name__ == "__main__": + run_suite() Modified: pyplusplus_dev/unittests/test_all.py =================================================================== --- pyplusplus_dev/unittests/test_all.py 2008-02-03 20:22:34 UTC (rev 1230) +++ pyplusplus_dev/unittests/test_all.py 2008-02-04 06:36:54 UTC (rev 1231) @@ -98,8 +98,8 @@ import constructors_bug_tester import precompiled_header_tester import balanced_files_tester +import ft_inout_tester - testers = [ algorithms_tester , module_body_tester @@ -184,6 +184,7 @@ , constructors_bug_tester , precompiled_header_tester , balanced_files_tester + , ft_inout_tester ] class module_runner_t( object ): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-02-03 20:22:29
|
Revision: 1230 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1230&view=rev Author: roman_yakovenko Date: 2008-02-03 12:22:34 -0800 (Sun, 03 Feb 2008) Log Message: ----------- creating tag for release 0.9.5 Added Paths: ----------- tags/pyplusplus_dev_0.9.5/ Copied: tags/pyplusplus_dev_0.9.5 (from rev 1229, pyplusplus_dev) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-02-03 20:20:51
|
Revision: 1229 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1229&view=rev Author: roman_yakovenko Date: 2008-02-03 12:20:57 -0800 (Sun, 03 Feb 2008) Log Message: ----------- Added Paths: ----------- tags/pygccxml_dev_0.9.5/ Removed Paths: ------------- tags/pygccxml_0.9.5/ Copied: tags/pygccxml_dev_0.9.5 (from rev 1228, tags/pygccxml_0.9.5) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-02-03 20:19:06
|
Revision: 1228 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1228&view=rev Author: roman_yakovenko Date: 2008-02-03 12:19:09 -0800 (Sun, 03 Feb 2008) Log Message: ----------- creating tag for release 0.9.5 Added Paths: ----------- tags/pygccxml_0.9.5/ Copied: tags/pygccxml_0.9.5 (from rev 1227, pygccxml_dev) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-02-03 20:17:34
|
Revision: 1227 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1227&view=rev Author: roman_yakovenko Date: 2008-02-03 12:17:38 -0800 (Sun, 03 Feb 2008) Log Message: ----------- Added Paths: ----------- tags/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-02-03 16:39:43
|
Revision: 1226 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1226&view=rev Author: roman_yakovenko Date: 2008-02-03 08:39:47 -0800 (Sun, 03 Feb 2008) Log Message: ----------- small improvements Modified Paths: -------------- pyplusplus_dev/pyplusplus/module_builder/builder.py pyplusplus_dev/unittests/fundamental_tester_base.py Modified: pyplusplus_dev/pyplusplus/module_builder/builder.py =================================================================== --- pyplusplus_dev/pyplusplus/module_builder/builder.py 2008-01-30 21:08:00 UTC (rev 1225) +++ pyplusplus_dev/pyplusplus/module_builder/builder.py 2008-02-03 16:39:47 UTC (rev 1226) @@ -348,7 +348,7 @@ , dir_name , huge_classes=None , on_unused_file_found=os.remove - , use_files_sum_repository=True): + , use_files_sum_repository=False): """ Writes module to multiple files @@ -393,7 +393,7 @@ , dir_name , number_of_files , on_unused_file_found=os.remove - , use_files_sum_repository=True): + , use_files_sum_repository=False): """ Writes module to fixed number of multiple cpp files Modified: pyplusplus_dev/unittests/fundamental_tester_base.py =================================================================== --- pyplusplus_dev/unittests/fundamental_tester_base.py 2008-01-30 21:08:00 UTC (rev 1225) +++ pyplusplus_dev/unittests/fundamental_tester_base.py 2008-02-03 16:39:47 UTC (rev 1226) @@ -130,6 +130,7 @@ def _create_extension(self): cmd = autoconfig.scons.cmd_build % self.__generated_scons_file_name + print cmd output = os.popen( cmd ) scons_reports = [] while True: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-01-30 21:08:00
|
Revision: 1225 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1225&view=rev Author: roman_yakovenko Date: 2008-01-30 13:08:00 -0800 (Wed, 30 Jan 2008) Log Message: ----------- updating docs Modified Paths: -------------- pyplusplus_dev/docs/history/history.rest Modified: pyplusplus_dev/docs/history/history.rest =================================================================== --- pyplusplus_dev/docs/history/history.rest 2008-01-30 08:24:15 UTC (rev 1224) +++ pyplusplus_dev/docs/history/history.rest 2008-01-30 21:08:00 UTC (rev 1225) @@ -43,9 +43,45 @@ * Py++ will not expose free operators, if at least one of the classes, it works on, is not exposed. Many thanks to Meghana Haridev for reporting the bug. - + 2. Added ability to completely disable warnings reporting. - + +3. All logging is now done to ``stderr`` instead of ``stdout``. + +4. Generated code improvements: + + * ``default_call_policies`` is not generated + + * ``return_internal_reference`` call policies - default arguments are not + generated + + * STD containers are generated without default arguments. For example instead + of ``std::vector< int, std::allocator< int > >``, in many cases `Py++`_ will + generate ``std::vector< int >``. + +5. `create_with_signature`_ algorithm was improved. `Py++`_ will generate correct + code in one more use case. + +.. _`create_with_signature` : ../documentation/functions/overloading.html + +6. Added ability to exclude declarations from being exposed, if they will cause + compilation to fail. + +7. Starting from this version, `Py++`_ provides a complete solution for + `multi-module development`_. + +.. _`multi-module development` : ../documentation/multi_module_development.html + +8. Classes, which expose C arrays will be registered only once. + +9. Starting from this version, `Py++`_ supports a code generation with different + encodings. + +10. There is a new strategy to split code into files. It is IDE friendly. Be sure + to read `the updated documentation`_. + +.. _`the updated documentation` : ../documentation/split_module.html + ------------- Version 0.9.0 ------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-01-30 08:24:13
|
Revision: 1224 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1224&view=rev Author: roman_yakovenko Date: 2008-01-30 00:24:15 -0800 (Wed, 30 Jan 2008) Log Message: ----------- making link checker happy Modified Paths: -------------- developer_scripts/check_links.bat pygccxml_dev/docs/example/example.rest pygccxml_dev/docs/history/history.rest pygccxml_dev/docs/pygccxml.rest pygccxml_dev/docs/users.rest pygccxml_dev/pygccxml/__init__.py pygccxml_dev/setup.py pyplusplus_dev/docs/documentation/how_to/best_practices.rest pyplusplus_dev/docs/documentation/how_to/how_to.rest pyplusplus_dev/docs/documentation/how_to/templates.rest pyplusplus_dev/docs/documentation/index.rest pyplusplus_dev/docs/documentation/warnings.rest pyplusplus_dev/docs/download.rest pyplusplus_dev/docs/history/history.rest pyplusplus_dev/docs/links.rest pyplusplus_dev/docs/quotes.rest pyplusplus_dev/pyplusplus/__init__.py pyplusplus_dev/setup.py Modified: developer_scripts/check_links.bat =================================================================== --- developer_scripts/check_links.bat 2008-01-26 20:26:03 UTC (rev 1223) +++ developer_scripts/check_links.bat 2008-01-30 08:24:15 UTC (rev 1224) @@ -1,3 +1,3 @@ cd D:\dev\language-binding\production\www\ -E:\Python25\Scripts\linkchecker.bat index.html +E:\Python25\Scripts\linkchecker.bat --config=D:\dev\language-binding\sources\developer_scripts\linkcheckerrc index.html Modified: pygccxml_dev/docs/example/example.rest =================================================================== --- pygccxml_dev/docs/example/example.rest 2008-01-26 20:26:03 UTC (rev 1223) +++ pygccxml_dev/docs/example/example.rest 2008-01-30 08:24:15 UTC (rev 1224) @@ -2,6 +2,11 @@ Example ======= +**Example** + +This example prints all declarations found in `example.hpp`_ file. For every class, +it prints it's base and derived classes. + The example consists from few files: * `example.hpp`_ - C++ source code, this file was passed to GCC-XML Modified: pygccxml_dev/docs/history/history.rest =================================================================== --- pygccxml_dev/docs/history/history.rest 2008-01-26 20:26:03 UTC (rev 1223) +++ pygccxml_dev/docs/history/history.rest 2008-01-30 08:24:15 UTC (rev 1224) @@ -23,9 +23,9 @@ * Jeremy Sanders * Ben Schleimer ------------ -SVN Version ------------ +------------- +Version 0.9.5 +------------- 1. Class ``free_operator_t`` is now able to provide references to the class declarations instances it works on. Modified: pygccxml_dev/docs/pygccxml.rest =================================================================== --- pygccxml_dev/docs/pygccxml.rest 2008-01-26 20:26:03 UTC (rev 1223) +++ pygccxml_dev/docs/pygccxml.rest 2008-01-30 08:24:15 UTC (rev 1224) @@ -31,21 +31,7 @@ * generate UML diagrams * build code analyzer * ... - -------------- -Usage example -------------- -First of all let's see a small and simple `example`_. This example prints all -declarations, reported by `GCC-XML`_ after parsing `example.hpp`_ file. Also it -prints all classes, and for every class it will print it's base and derived -classes. It was simple task, right? If you are still curious how it looks -"in the real life", I mean how xml file is look like, you may look at the -`original XML file`_ generated by `GCC-XML`_. -.. _`original XML file` : ./example.hpp.xml.html -.. _`example.hpp` : ./example.hpp.html -.. _`example` : ./example.py.html - -------- Features -------- Modified: pygccxml_dev/docs/users.rest =================================================================== --- pygccxml_dev/docs/users.rest 2008-01-26 20:26:03 UTC (rev 1223) +++ pygccxml_dev/docs/users.rest 2008-01-30 08:24:15 UTC (rev 1224) @@ -19,7 +19,7 @@ - http://blog.susheelspace.com/?p=88 - " ... I’ve used pygccxml for parsing c++ code, it was a lot of fun to use " + " ... I have used pygccxml for parsing c++ code, it was a lot of fun to use " - http://cysquatch.net/blog/2007/09/01/c-code-metrics-with-pygccxml @@ -35,4 +35,4 @@ Short listing of C++ parsers and their description. - .. _`pygccxml` : ./../pygccxml.html \ No newline at end of file + .. _`pygccxml` : ./pygccxml.html Modified: pygccxml_dev/pygccxml/__init__.py =================================================================== --- pygccxml_dev/pygccxml/__init__.py 2008-01-26 20:26:03 UTC (rev 1223) +++ pygccxml_dev/pygccxml/__init__.py 2008-01-30 08:24:15 UTC (rev 1224) @@ -37,6 +37,6 @@ # 1. Write documentation for filtering functionality. # 2. Add "explicit" property for constructors -__version__ = '0.9.0' +__version__ = '0.9.5' __revision__ = 1080 Modified: pygccxml_dev/setup.py =================================================================== --- pygccxml_dev/setup.py 2008-01-26 20:26:03 UTC (rev 1223) +++ pygccxml_dev/setup.py 2008-01-30 08:24:15 UTC (rev 1224) @@ -52,7 +52,7 @@ setup( name = "pygccxml", - version = "0.9.0", + version = "0.9.5", description = "GCC-XML generated file reader", author = "Roman Yakovenko", author_email = "rom...@gm...", Modified: pyplusplus_dev/docs/documentation/how_to/best_practices.rest =================================================================== --- pyplusplus_dev/docs/documentation/how_to/best_practices.rest 2008-01-26 20:26:03 UTC (rev 1223) +++ pyplusplus_dev/docs/documentation/how_to/best_practices.rest 2008-01-30 08:24:15 UTC (rev 1224) @@ -23,7 +23,7 @@ few hundred of header files. `Py++`_ was born to create `Python`_ bindings for such projects. If you take a look `here`__ you will find few such projects. -.. __ : ./../../pyplusplus/quotes.html +.. __ : ./../../quotes.html Tips ---- @@ -109,7 +109,7 @@ mb = module_builder( [ os.path.abspath('date_time/date_time.hpp') ], ... ) .. _`this error` : http://boost.org/libs/python/doc/v2/faq.html#c1204 -.. __ : ./../../pygccxml/design.html +.. __ : ./../../../pygccxml/design.html * Keep the declaration tree small. @@ -170,7 +170,7 @@ .. _`Py++` : ./../pyplusplus.html -.. _`pygccxml` : ./../../pygccxml/pygccxml.html +.. _`pygccxml` : ./../../../pygccxml/pygccxml.html .. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html .. _`Python`: http://www.python.org .. _`GCC-XML`: http://www.gccxml.org Modified: pyplusplus_dev/docs/documentation/how_to/how_to.rest =================================================================== --- pyplusplus_dev/docs/documentation/how_to/how_to.rest 2008-01-26 20:26:03 UTC (rev 1223) +++ pyplusplus_dev/docs/documentation/how_to/how_to.rest 2008-01-30 08:24:15 UTC (rev 1224) @@ -82,7 +82,7 @@ -.. _`Py++` : ./../pyplusplus.html +.. _`Py++` : ./../../pyplusplus.html .. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html .. _`Python`: http://www.python.org .. _`GCC-XML`: http://www.gccxml.org Modified: pyplusplus_dev/docs/documentation/how_to/templates.rest =================================================================== --- pyplusplus_dev/docs/documentation/how_to/templates.rest 2008-01-26 20:26:03 UTC (rev 1223) +++ pyplusplus_dev/docs/documentation/how_to/templates.rest 2008-01-30 08:24:15 UTC (rev 1224) @@ -79,8 +79,6 @@ Function ``create_text_fc`` allows you to extract declarations from the string, which contains valid C++ code. It creates temporal header file and compiles it. -.. __ : ./../../../pygccxml/design.html#parser-configuration-classes - ---------------------------------- Functions templated on return type ---------------------------------- Modified: pyplusplus_dev/docs/documentation/index.rest =================================================================== --- pyplusplus_dev/docs/documentation/index.rest 2008-01-26 20:26:03 UTC (rev 1223) +++ pyplusplus_dev/docs/documentation/index.rest 2008-01-30 08:24:15 UTC (rev 1224) @@ -43,37 +43,21 @@ .. _`architecture` : ./architecture.html -* `best practices`_ - `Py++`_ is huge, this document will explain you how to - effectively use it - -.. _`best practices`: ./best_practices.html - * `documentation string`_ - explains how to automatically extract a documentation from the source files and put it as Python documentation string .. _`documentation string` : ./doc_string.html -* `warnings`_ - `Py++`_ could be used as some kind of validator. It checks the - exposed declarations and reports the potential errors. Thus you are able to - create high quality Python bindings from the beginning. This document also - describes how to suppress the errors\\warnings. - -.. _`warnings` : ./warnings.html - * `functions & operators`_ - contains a complete guide to exposing functions and operators, including "call policies" and description of different caveats .. _`functions & operators` : ./functions/functions.html -* `hints`_ - describes few techniques, which will help you with exposing template - instantiations +* `how to ... ?`_ - contains answers for different FAQs and my suggestions about + better `Py++`_ usage. -.. _`hints`: ./hints.html +.. _`how to ... ?` : ./how_to/how_to.html -* `how to ... ?`_ - contains answers for different frequently asked questions - -.. _`how to ... ?` : ./how_to.html - * `inserting code`_ - a complete guide for insert your code into the generated one .. _`inserting code` : ./inserting_code.html @@ -88,12 +72,26 @@ .. _`properties`: ./properties.html +* `splitting generated code to files`_ - `Py++`_ provides 4 different strategies + for splitting the generated code into files. Take a look on this document, + it will save you the time. + +.. _`splitting generated code to files` : ./split_module.html + * `tutorials`_ - don't know where to start? Start here. Small and simple example will help you to start with `Py++`_. If you want to evaluate `Py++`_ you will find here small and handy GUI program. .. _`tutorials` : ./tutorials/tutorials.html +* `warnings`_ - `Py++`_ could be used as some kind of validator. It checks the + exposed declarations and reports the potential errors. Thus you are able to + create high quality Python bindings from the beginning. This document also + describes how to suppress the errors\\warnings. + +.. _`warnings` : ./warnings.html + + .. _`epydoc` : http://epydoc.sourceforge.net/ .. _`Py++` : ./../pyplusplus.html .. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html Modified: pyplusplus_dev/docs/documentation/warnings.rest =================================================================== --- pyplusplus_dev/docs/documentation/warnings.rest 2008-01-26 20:26:03 UTC (rev 1223) +++ pyplusplus_dev/docs/documentation/warnings.rest 2008-01-30 08:24:15 UTC (rev 1224) @@ -207,7 +207,7 @@ is not exportable. -.. _`Formatter` : http://docs.python.org/lib/node357.html +.. _`Formatter` : http://docs.python.org/lib/node422.html .. _`logging` : http://docs.python.org/lib/module-logging.html .. _`Py++` : ./../pyplusplus.html .. _`pygccxml` : ./../../pygccxml/pygccxml.html Modified: pyplusplus_dev/docs/download.rest =================================================================== --- pyplusplus_dev/docs/download.rest 2008-01-26 20:26:03 UTC (rev 1223) +++ pyplusplus_dev/docs/download.rest 2008-01-30 08:24:15 UTC (rev 1224) @@ -50,8 +50,8 @@ Boost libraries. .. _`getting started guide` : http://boost.cvs.sourceforge.net/*checkout*/boost/boost/more/getting_started.html -.. _`here` : http://www.boost-consulting.com/download.html -.. _`installer for Boost Libraries` : http://www.boost-consulting.com/download.html +.. _`here` : http://www.boost-consulting.com/products/free +.. _`installer for Boost Libraries` : http://www.boost-consulting.com/products/free ------------ Dependencies Modified: pyplusplus_dev/docs/history/history.rest =================================================================== --- pyplusplus_dev/docs/history/history.rest 2008-01-26 20:26:03 UTC (rev 1223) +++ pyplusplus_dev/docs/history/history.rest 2008-01-30 08:24:15 UTC (rev 1224) @@ -34,9 +34,9 @@ 3. Users always changed the name of the projects. I saw at least 6 different names. ------------ -SVN Version ------------ +------------- +Version 0.9.5 +------------- 1. Bug fixes: @@ -89,7 +89,7 @@ 5. `input_c_buffer`_ - new functions transformation, which allows to pass a Python sequence to function, instead of pair of arguments: pointer to buffer and size. -.. _`input_c_buffer` : ../documentation/functions/transformation/built_in/input_c_buffer.html +.. _`input_c_buffer` : ../documentation/functions/transformation/input_c_buffer.html 6. Added ability to control generated "include" directives. Now you can ask `Py++`_ to include a header file, when it generates code for some declaration. For more @@ -131,7 +131,7 @@ 2. "Py++" introduces new functionality, which allows you to control messages and warnings: `how to disable warnings?`_ . -.. _`how to disable warnings?` : ../documentation/feedback.html#how-to-disable-warning-s +.. _`how to disable warnings?` : ../documentation/warnings.html 3. Added new algorithm, which controls the registration order of the functions. See `registration order document`_ Modified: pyplusplus_dev/docs/links.rest =================================================================== --- pyplusplus_dev/docs/links.rest 2008-01-26 20:26:03 UTC (rev 1223) +++ pyplusplus_dev/docs/links.rest 2008-01-30 08:24:15 UTC (rev 1224) @@ -58,7 +58,7 @@ * http://boost.cvs.sourceforge.net/boost/boost/libs/python/test/ - `Boost.Python`_ unit tests. They could be very, very helpful. -* http://svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/unittests/ - `Py++`_ +* http://pygccxml.svn.sourceforge.net/viewvc/pygccxml/pyplusplus_dev/unittests/ - `Py++`_ unit tests. They could be even more helpful! ------------- Modified: pyplusplus_dev/docs/quotes.rest =================================================================== --- pyplusplus_dev/docs/quotes.rest 2008-01-26 20:26:03 UTC (rev 1223) +++ pyplusplus_dev/docs/quotes.rest 2008-01-30 08:24:15 UTC (rev 1224) @@ -100,11 +100,6 @@ .. _`CEGUI` : http://www.cegui.org.uk/wiki/index.php/Main_Page - * `Newton`_ - Newton Game Dynamics, a closed source (but free) physics and - collisions library. - - .. _`Newton` : http://www.newtondynamics.com/apache2-default/ - * `ODE`_ - an open source, high performance library for simulating rigid body dynamics. @@ -112,7 +107,10 @@ * `OIS`_ - an object oriented input system. - .. _`OIS` : http://www.wreckedgames.com/wiki/index.php/WreckedLibs:OIS + .. _`OIS` : http://www.wreckedgames.com/forum/ + + * All in all, `Python-OGRE`_ project contains bindings for more than 30 libraries. + You can find code generation scripts here: https://python-ogre.svn.sourceforge.net/svnroot/python-ogre/trunk/python-ogre/code_generators/ * I am :-). I created Python bindings for next libraries: Modified: pyplusplus_dev/pyplusplus/__init__.py =================================================================== --- pyplusplus_dev/pyplusplus/__init__.py 2008-01-26 20:26:03 UTC (rev 1223) +++ pyplusplus_dev/pyplusplus/__init__.py 2008-01-30 08:24:15 UTC (rev 1224) @@ -34,7 +34,7 @@ from _logging_ import multi_line_formatter_t -__version__ = '0.9.0' +__version__ = '0.9.5' import pygccxml if not hasattr( pygccxml, '__revision__' ) or pygccxml.__revision__ < 1080: Modified: pyplusplus_dev/setup.py =================================================================== --- pyplusplus_dev/setup.py 2008-01-26 20:26:03 UTC (rev 1223) +++ pyplusplus_dev/setup.py 2008-01-30 08:24:15 UTC (rev 1224) @@ -90,7 +90,7 @@ setup( name = "Py++", - version = "0.9.0", + version = "0.9.5", description="Py++ is a framework of components for creating C++ code generator for Boost.Python library", author="Roman Yakovenko", author_email="rom...@gm...", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-01-26 20:26:00
|
Revision: 1223 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1223&view=rev Author: roman_yakovenko Date: 2008-01-26 12:26:03 -0800 (Sat, 26 Jan 2008) Log Message: ----------- updating docs Modified Paths: -------------- pyplusplus_dev/docs/documentation/how_to/how_to.rest pyplusplus_dev/docs/documentation/how_to/www_configuration.py Added Paths: ----------- pyplusplus_dev/docs/documentation/how_to/absolute_relative_paths.rest pyplusplus_dev/docs/documentation/how_to/file_name_too_long.rest Added: pyplusplus_dev/docs/documentation/how_to/absolute_relative_paths.rest =================================================================== --- pyplusplus_dev/docs/documentation/how_to/absolute_relative_paths.rest (rev 0) +++ pyplusplus_dev/docs/documentation/how_to/absolute_relative_paths.rest 2008-01-26 20:26:03 UTC (rev 1223) @@ -0,0 +1,41 @@ +========================= +Absolute\\relative paths +========================= + +**Absolute\\relative paths** + +Consider next fileers, the average number of characters per line is +less than 2. Please cs layout: +:: + + boost/ + date_time/ + ptime.hpp + time_duration.hpp + date_time.hpp + +``date_time.hpp`` is the main header file, which should be parsed. + +`Py++`_ does not handle relative paths, as input, well. It tries, but there are uses +cases it fails. In these cases it generates empty module - nothing is exposed: + +.. code-block:: Python + + mb = module_builder( [ 'date_time/date_time.hpp' ], ... ) + mb.split_module( ... ) + +I recommend you to use absolute paths instead of relative ones: + +.. code-block:: Python + + import os + mb = module_builder( [ os.path.abspath('date_time/date_time.hpp') ], ... ) + mb.split_module( ... ) + +and `Py++`_ will expose all declarations found in the ``date_time.hpp`` file and +other files from the same directory. + +.. _`Py++` : ./../../pyplusplus.html +.. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html +.. _`Python`: http://www.python.org +.. _`GCC-XML`: http://www.gccxml.org Added: pyplusplus_dev/docs/documentation/how_to/file_name_too_long.rest =================================================================== --- pyplusplus_dev/docs/documentation/how_to/file_name_too_long.rest (rev 0) +++ pyplusplus_dev/docs/documentation/how_to/file_name_too_long.rest 2008-01-26 20:26:03 UTC (rev 1223) @@ -0,0 +1,48 @@ +=============================== +Generated file name is too long +=============================== + +**Generated file name is too long** + +There are use cases, when `Py++`_ generated file name is too long. In some cases +the code generation process even fails because of this. + +This is just a symptom of the problem. This happens when you expose template +instantiated classes and you did not specify the class alias. `Py++`_ uses a class +alias as a basis for the file name. + +Let me explain. + +.. code-block:: C++ + + template < class T> + struct holder{ ... }; + +As you know, a class name in `Python`_ has few `constraints`_ and `Py++`_ is aware +of them. "holder< int >" is illegal class name, so `Py++`_ will generate another +one - "holder_less_int_grate\_". Pretty ugly and even long, but at least it is +legal one. + +.. _`constraints` : http://www.python.org/doc/current/ref/identifiers.html + +It is pretty simple to change the alias of the class, or any other declaration: + +.. code-block:: Python + + from pyplusplus import module_builder + + mb = module_builder_t( ... ) + holder = mb.class_( 'holder< int >' ) + holder.alias = 'IntHolder' + #next line has same effect as the previous one: + holder.rename( 'IntHolder' ) + +Another solution to the problem, is to use different strategy to split the generated +code to files. You can read more about splitting files `here`_. + +.. _`here` : ./../split_module.html + +.. _`Py++` : ./../pyplusplus.html +.. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html +.. _`Python`: http://www.python.org +.. _`GCC-XML`: http://www.gccxml.org Modified: pyplusplus_dev/docs/documentation/how_to/how_to.rest =================================================================== --- pyplusplus_dev/docs/documentation/how_to/how_to.rest 2008-01-26 20:25:11 UTC (rev 1222) +++ pyplusplus_dev/docs/documentation/how_to/how_to.rest 2008-01-26 20:26:03 UTC (rev 1223) @@ -16,6 +16,14 @@ .. _`Fatal error C1204:Compiler limit: internal structure overflow` : ./fatal_error_c1204.html +`Absolute\\relative paths`_ + +.. _`Absolute\\relative paths` : ./absolute_relative_paths.html + +`Generated file name is too long`_ + +.. _`Generated file name is too long` : ./file_name_too_long.html + ------------------------------------------------------- How to expose function, which has hand-written wrapper? ------------------------------------------------------- @@ -72,89 +80,8 @@ That's all. -------------------------------------- -Py++ generated file name is too long! -------------------------------------- -There are use cases, when `Py++`_ generated file name is too long. In some cases -the code generation process even fails because of this. What can you do in order -to eliminate the problem? -First of all the problem arises when you expose template instantiated classes -and you did not set the class alias. -Let me explain: - -.. code-block:: C++ - - template < class T> - struct holder{ ... }; - - -Lets say that you want to export ``holder< int >`` class. Class name in `Python`_ -has few `constraints`_. `Py++`_ is aware of the `constraints`_ and if you didn't -set an alias to the class, `Py++`_ will do it for you. In this case, -"holder_less_int_grate\_" is the generated alias. Obviously it is much longer -and not readable. - -.. _`constraints` : http://www.python.org/doc/current/ref/identifiers.html - -There are few pretty good reasons for this behavior: - -* when you just start to work on `Python`_ bindings concentrate your attention - on really important things - -* if you forgot to set the class alias your users still can use the class - functionality, however the class name will be a little bit ugly. - - -In this case the generate alias for ``holder`` instantiation is relatively short. -Imagine how long it could be for ``std::map`` instantiation. - -`Py++`_ uses class alias for the file name. So if you want to force `Py++`_ to -generate files with short name, you have to set class alias: - -.. code-block:: Python - - from pyplusplus import module_builder - - mb = module_builder_t( ... ) - holder = mb.class_( 'holder< int >' ) - holder.alias = 'IntHolder' - #next line has same effect as the previous one: - holder.rename( 'IntHolder' ) - -The nice thing about this approach is that now `Python`_ users have "normal" -class name and you have short file name. - -------------------- -Full\relative paths -------------------- - -Consider next file layout: -:: - - boost/ - date_time/ - ptime.hpp - time_duration.hpp - date_time.hpp //main header, which include all other header files - -Py++ currently does not handle relative paths as input very well, so it is -recommended that you use ``os.path.abspath()`` to transform the header file to -be processed into an absolute path: - -.. code-block:: Python - - #Next code will expose nothing - mb = module_builder( [ 'date_time/date_time.hpp' ], ... ) - mb.split_module( ... ) - - #while this one will work as expected - import os - mb = module_builder( [ os.path.abspath('date_time/date_time.hpp') ], ... ) - mb.split_module( ... ) - - .. _`Py++` : ./../pyplusplus.html .. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html .. _`Python`: http://www.python.org Modified: pyplusplus_dev/docs/documentation/how_to/www_configuration.py =================================================================== --- pyplusplus_dev/docs/documentation/how_to/www_configuration.py 2008-01-26 20:25:11 UTC (rev 1222) +++ pyplusplus_dev/docs/documentation/how_to/www_configuration.py 2008-01-26 20:26:03 UTC (rev 1223) @@ -6,6 +6,8 @@ , 'templates' : 'deal with templates' , 'best_practices' : 'best practices' , 'exception_translation' : 'exception translation' - , 'fatal_error_c1204' : 'fatal error C1204: compiler limit: internal structure overflow' + , 'fatal_error_c1204' : 'fatal error: C1204' + , 'absolute_relative_paths' : 'absolute\\relative paths' + , 'file_name_too_long' : 'file name is too long' } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-01-26 20:25:21
|
Revision: 1222 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1222&view=rev Author: roman_yakovenko Date: 2008-01-26 12:25:11 -0800 (Sat, 26 Jan 2008) Log Message: ----------- updating docs Modified Paths: -------------- pyplusplus_dev/docs/quotes.rest Modified: pyplusplus_dev/docs/quotes.rest =================================================================== --- pyplusplus_dev/docs/quotes.rest 2008-01-26 20:24:00 UTC (rev 1221) +++ pyplusplus_dev/docs/quotes.rest 2008-01-26 20:25:11 UTC (rev 1222) @@ -42,10 +42,10 @@ Andy Miller, a developer of `Python-OGRE`_ project -"... I tried Py++ and it indeed automatically handles the case I outlined above -concerning C-array members, and with much less tedious writing of registration -code. I also found it convenient to use to insert some other C++ code for each -of my structures that normally I wrote by hand. The API docs and examples on your +"... I tried Py++ and it indeed automatically handles the case I outlined above +concerning C-array members, and with much less tedious writing of registration +code. I also found it convenient to use to insert some other C++ code for each +of my structures that normally I wrote by hand. The API docs and examples on your webpage were very helpful. " David Carpman @@ -71,15 +71,15 @@ SystemC and TLM libraries that are high level hardware description languages based on C++. - .. _`ReSP` : http://www.esa.int/TEC/Microelectronics/ + .. _`ReSP` : http://www.resp-sim.org/?page_id=2 * Allen Bierbaum, the author of `PyOpenSG`_ project, is using `Py++`_ to create Python bindings for `OpenSG`_ - - `OpenSG`_ - is a portable scenegraph system to create realtime graphics - programs, e.g. for virtual reality applications. - + `OpenSG`_ - is a portable scenegraph system to create realtime graphics + programs, e.g. for virtual reality applications. + + * Matthias Baas, the author of `Python Computer Graphics Kit`_ project, is using `Py++`_ to create Python bindings for `Maya C++ SDK`__. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-01-26 20:23:57
|
Revision: 1221 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1221&view=rev Author: roman_yakovenko Date: 2008-01-26 12:24:00 -0800 (Sat, 26 Jan 2008) Log Message: ----------- updating docs Modified Paths: -------------- pygccxml_dev/docs/users.rest Modified: pygccxml_dev/docs/users.rest =================================================================== --- pygccxml_dev/docs/users.rest 2008-01-05 21:19:44 UTC (rev 1220) +++ pygccxml_dev/docs/users.rest 2008-01-26 20:24:00 UTC (rev 1221) @@ -4,7 +4,35 @@ .. contents:: Table of contents +Users +----- + * `PyBindGen`_ - is a Python module that is geared to generating C/C++ code that binds a C/C++ library for Python. .. _`PyBindGen` : https://launchpad.net/pybindgen + +* your project name ... :-) + +pygccxml in blogs +----------------- + +- http://blog.susheelspace.com/?p=88 + + " ... I’ve used pygccxml for parsing c++ code, it was a lot of fun to use " + +- http://cysquatch.net/blog/2007/09/01/c-code-metrics-with-pygccxml + + `pygccxml`_ is used to calculate the Weighted Methods per Class (WMC) metric. + +- http://www.garagegames.com/blogs/4280/13907 + + `pygccxml`_ is used to generate input files for `SIP`_ code generator. + +.. _`SIP` : http://www.riverbankcomputing.co.uk/sip/index.php + +- http://blogs.sun.com/thorsten/entry/more_on_source_code_grokking + + Short listing of C++ parsers and their description. + + .. _`pygccxml` : ./../pygccxml.html \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-01-05 21:19:41
|
Revision: 1220 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1220&view=rev Author: roman_yakovenko Date: 2008-01-05 13:19:44 -0800 (Sat, 05 Jan 2008) Log Message: ----------- moving docs Removed Paths: ------------- pyplusplus_dev/docs/documentation/best_practices.rest pyplusplus_dev/docs/documentation/hints.rest pyplusplus_dev/docs/documentation/how_to.rest Deleted: pyplusplus_dev/docs/documentation/best_practices.rest =================================================================== --- pyplusplus_dev/docs/documentation/best_practices.rest 2008-01-05 21:18:15 UTC (rev 1219) +++ pyplusplus_dev/docs/documentation/best_practices.rest 2008-01-05 21:19:44 UTC (rev 1220) @@ -1,176 +0,0 @@ -============== -Best practices -============== - -.. contents:: Table of contents - ------------- -Introduction ------------- - -`Py++`_ has reach interface and a lot of functionality. Sometimes reach -interface helps, but sometimes it can confuse. This document will describe how -effectively to use `Py++`_. - ------------- -Big projects ------------- - -Definition ----------- - -First of all, let me to define "big project". "Big project" is a project with -few hundred of header files. `Py++`_ was born to create `Python`_ bindings -for such projects. If you take a look `here`__ you will find few such projects. - -.. __ : ./../../pyplusplus/quotes.html - -Tips ----- - -* Create one header file, which will include all project header files. - - Doing it this way makes it so `GCC-XML`_ is only called once and it reduces the - overhead that would occur if you pass `GCC-XML`_ all the files individually. - Namely `GCC-XML`_ would have to run hundreds of times and each call would - actually end up including quite a bit of common code anyway. This way takes a - `GCC-XML`_ processing time from multiple hours with gigabytes of caches to a - couple minutes with a reasonable cache size. - - You can read more about different caches supported by `pygccxml`_ `here`__. - ``module_builder_t.__init__`` method takes reference to an instance of cache - class or ``None``: - - .. code-block:: Python - - from module_builder import * - mb = module_builder_t( ..., cache=file_cache_t( path to project cache file ), ... ) - -* Single header file, will also improve performance compiling the generated bindings. - - When `Py++`_ generated the bindings, you have a lot of .cpp files to - compile. The project you are working on is big. I am sure it takes a lot of - time to compile projects that depend on it. Generated code also depend on it, - more over this code contains a lot of template instantiations. So it could - take a great deal of time to compile it. Allen Bierbaum investigated this - problem. He found out that most of the time is really spent processing all the - headers, templates, macros from the project and from the boost library. So he - come to conclusion, that in order to improve compilation speed, user should - be able to control( to be able to generate ) precompiled header file. He - implemented an initial version of the functionality. After small discussion, - we agreed on next interface: - - .. code-block:: Python - - class module_builder_t( ... ): - ... - def split_module( self, directory_path, huge_classes=None, precompiled_header=None ): - ... - - ``precompiled_header`` argument could be ``None`` or string, that contains - name of precompiled header file, which will be created in the directory. - `Py++`_ will add to it header files from `Boost.Python`_ library and - your header files. - - What is ``huge_classes`` argument for? ``huge_classes`` could be ``None`` or - list of references to class declarations. It is there to provide a solution to - `this error`_. `Py++`_ will automatically split generated code for the - huge classes to few files: - - .. code-block:: Python - - mb = module_builder_t( ... ) - ... - my_big_class = mb.class_( my_big_class ) - mb.split_module( ..., huge_classes=[my_big_class], ... ) - - * **Caveats** - - Consider next file layout: - :: - - boost/ - date_time/ - ptime.hpp - time_duration.hpp - date_time.hpp //main header, which include all other header files - - Py++ currently does not handle relative paths as input very well, so it is - recommended that you use "os.path.abspath()" to transform the header file to - be processed into an absolute path: - - .. code-block:: Python - - #Next code will expose nothing - mb = module_builder( [ 'date_time/date_time.hpp' ], ... ) - - #while this one will work as expected - import os - mb = module_builder( [ os.path.abspath('date_time/date_time.hpp') ], ... ) - -.. _`this error` : http://boost.org/libs/python/doc/v2/faq.html#c1204 -.. __ : ./../../pygccxml/design.html - -* Keep the declaration tree small. - - When parsing the header files to build the declaration tree, there will also - be the occasional "junk" declaration inside the tree that is not relevant to - the bindings you want to generate. These extra declarations come from header - files that were included somewhere in the header files that you were actually - parsing (e.g. if that library uses the STL or OpenGL or other system headers - then the final declaration tree will contain those declarations, too). - It can happen that the majority of declarations in your declaration tree are - such "junk" declarations that are not required for generating your bindings - and that just slow down the generation process (reading the declaration cache - and doing queries will take longer). - - To speed up your generation process you might want to consider making the - declaration tree as small as possible and only store those declarations that - somehow have an influence on the bindings. Ideally, this is done as early - as possible and luckily gccxml provides an option that allows you to reduce - the number of declarations that it will store in the output XML file. You can - specify one or more declarations using the ``-fxml-start`` option and only - those sub-tree starting at the specified declarations will be written. For - example, if you specify the name of a particular class, only this class - and all its members will get written. Or if your project already uses - a dedicated namespace you can simply use this namespace as a starting point - and all declarations stemming from system headers will be ignored (except - for those declarations that are actually used within your library). - - In the ``pygccxml`` package you can set the value for the ``-fxml-start`` - option using the ``start_with_declarations`` attribute of the - ``pygccxml.parser.config_t`` object that you are passing to the parser. - -* Use `Py++`_ repository of generated files md5 sum. - - `Py++`_ is able to store md5 sum of generated files in a file. Next time you - will generate code, `Py++`_ will compare generated file content against the sum, - instead of loading the content of the previously generated file from the disk - and comparing against it. - - .. code-block:: Python - - mb = module_builder_t( ... ) - ... - my_big_class = mb.class_( my_big_class ) - mb.split_module( ..., use_files_sum_repository=True ) - - `Py++`_ will generate file named "<your module name>.md5.sum" in the directory - it will generate all the files. - - Enabling this functionality should give you 10-15% of performance boost. - - * **Caveats** - - If you changed manually some of the files - don't forget to delete the relevant - line from "md5.sum" file. You can also delete the whole file. If the file is - missing, `Py++`_ will use old plain method of comparing content of the files. - It will not re-write "unchanged" files and you will not be forced to recompile - the whole project. - - -.. _`Py++` : ./../pyplusplus.html -.. _`pygccxml` : ./../../pygccxml/pygccxml.html -.. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html -.. _`Python`: http://www.python.org -.. _`GCC-XML`: http://www.gccxml.org Deleted: pyplusplus_dev/docs/documentation/hints.rest =================================================================== --- pyplusplus_dev/docs/documentation/hints.rest 2008-01-05 21:18:15 UTC (rev 1219) +++ pyplusplus_dev/docs/documentation/hints.rest 2008-01-05 21:19:44 UTC (rev 1220) @@ -1,64 +0,0 @@ -===== -Hints -===== - -.. contents:: Table of contents - ----------------------------------- -Class template instantiation alias ----------------------------------- - -`Py++`_ has nice feature. If you define ``typedef`` for instantiated class -template, than `Py++`_ will use it as a `Python`_ class name. - -For example: - -.. code-block:: C++ - - #include <vector> - typedef std::vector< int > numbers; - numbers generate_n(){ - ... - } - -`Py++`_ will use "numbers" as Python class name: - -.. code-block:: C++ - - using boost::python; - class_< std::vector< int > >( "numbers" ) - ... - ; - -`Py++`_ will pick up the alias, only in case the class has single "typedef". - -``pyplusplus::aliases`` namespace ---------------------------------- - -The previous approach is "implicit" - `Py++`_ does something behind the scene. -Recently (version 0.8.6 ), another approach was introduced: - -.. code-block:: C++ - - #include <vector> - - namespace pyplusplus{ namespace aliases{ - //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - typedef std::vector< int > numbers; - - } } //pyplusplus::aliases - -The idea is that you create namespace with a special name - ``pyplusplus::aliases`` -and `Py++`_ automatically picks the class aliases from it. In case you accidentally -introduced two or more different aliases to the same class, it will pick the -longest one and print a warning. Other advantages of the approach: - -* you are not forced to learn new API - -* you continue to use your favorite editor and familiar language - -.. _`Py++` : ./../pyplusplus.html -.. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html -.. _`Python`: http://www.python.org -.. _`GCC-XML`: http://www.gccxml.org - Deleted: pyplusplus_dev/docs/documentation/how_to.rest =================================================================== --- pyplusplus_dev/docs/documentation/how_to.rest 2008-01-05 21:18:15 UTC (rev 1219) +++ pyplusplus_dev/docs/documentation/how_to.rest 2008-01-05 21:19:44 UTC (rev 1220) @@ -1,411 +0,0 @@ -============ -How to ... ? -============ - -.. contents:: Table of contents - ----------------------------------------- -How to add custom exception translation? ----------------------------------------- - -.. code-block:: C++ - - struct my_exception{ - ... - const std::string& error() const; - } - -First of all lets define ``translate`` function: - -.. code-block:: Python - - translate_code = \ - """ - void translate(const my_exception &exception){ - PyErr_SetString( PyExc_RuntimeError, exception.error().c_str() ); - } - """ - -.. code-block:: Python - - mb = module_builder_t( ... ) - mb.add_declaration_code( translate_code ) - - -Now we should register it: - -.. code-block:: Python - - registration_code = "boost::python::register_exception_translator<my_exception>(&translate);" - mb.add_registration_code( registration_code ) - -Small usage advice. -------------------- - -`Py++`_ allows you to define a query that will return you all exception classes: - -.. code-block:: Python - - mb = module_builder_t( ... ) - exception_classes = mb.decls( lambda decl: decl.name.endswith( 'exception' ) ) - -Now you can iterate on ``exception_classes``, generate and register translate -code for every class. - -That's all. - -------------------------------------------------------- -How to expose function, which has hand-written wrapper? -------------------------------------------------------- -.. code-block:: C++ - - struct window_t{ - ... - void get_size( int& height, int& widht ) const; - }; - -You can not expose ``get_size`` function as is - ``int`` is immutable type in -Python. So, we need to create a wrapper to the function: - -.. code-block:: C++ - - boost::python::tuple get_size_wrapper( const window_t& win ){ - int height(0), width( 0 ); - win.get_size( height, widht ); - return boost::python::make_tuple( height, width ); - } - -.. code-block:: C++ - - class_<window_t>( ... ) - .def( "get_size", &get_size_wrapper ) - ... - ; - -Now, after you know how this problem is solved. I will show how this solution -could be integrated with `Py++`_. - -.. code-block:: Python - - wrapper_code = \ - """ - static boost::python::tuple get_size( const window_t& win ){ - int height(0), width( 0 ); - win.get_size( height, width ); - return boost::python::make_tuple( height, width ); - } - """ - -.. code-block:: Python - - registration_code = 'def( "get_size", &%s::get_size )' % window.wrapper_alias - -.. code-block:: Python - - mb = module_builder_t( ... ) - window = mb.class_( "window_t" ) - window.member_function( "get_size" ).exclude() - window.add_wrapper_code( wrapper_code ) - window.registration_code( registration_code ) - -That's all. - -------------------------------------------------------------- -Fatal error C1204:Compiler limit: internal structure overflow -------------------------------------------------------------- - -If you get this error, than the generated file is too big. You will have to split -it to few files. Well, not you but `Py++`_, you will only have to tell it to do -that. - -If you are using ``module_builder_t.write_module`` method, consider to switch -to ``module_builder_t.split_module``. - -If you are using ``split_module``, but still the generated code for some class -could not be compiled, because of the error, you can ask `Py++`_ to split the -code generated for class to be split to few cpp files. - -For more information, please read the documentation. - ------------------------------------------------------- -How to automatically export template functions\\class? ------------------------------------------------------- - -Lets say you have next C++ function: - -.. code-block:: C++ - - // file point.h - namespace geometry{ - template< class T> - struct point_t{ - T x, y; - }; - template <class T> - double distance( const point_t<T>& point ){ - return sqrt( point.x * point.x + point.y*point.y ); - } - } //namespace geometry - -You should understand, that you can not export template itself, but only its -instantiations. The solution is built using next facts: - -* ``sizeof( class name )`` causes a compiler to instantiate the class - -* free function invocation causes a compiler to instantiate the function - -Lets say that we need to export the class and the function template -instantiations for ``int`` and ``custom_type`` types. There are few ways to do it. - -Simple and straightforward --------------------------- - -Open your favourite editor and create a header file with the content: - -.. code-block:: C++ - - #include "point.h" - -.. code-block:: C++ - - namespace py_details{ - inline void instantiate(){ - using namespace geometry; - sizeof( point_t<int> ); - sizeof( point_t<custom_type> ); - distance( point_t<int>(0,0) ); - distance( point_t<custom_type>(0,0) ); - } - } - -Now, you add this file to the list of files you pass as input to -``module_builder_t.__init__`` method and excludes the ``py_details`` namespace -declarations from being exported: - -.. code-block:: Python - - mb = module_builder_t( [..., just created file ], ... ) - mb.namespace( 'py_details' ).exclude() - -"Dynamic" instantiation ------------------------ - -Lets say you are less lucky than I, and you have to create ``X`` instantiations -of the class\\function. Obviously, the previous approach will not work for you. -The solution is to build your own code generator, which will generate code similar -to the one, in the previous paragraph. - -.. code-block:: Python - - from module_builder import module_builder_t, create_text_fc - -.. code-block:: Python - - def generate_instantiations_string( ... ): - ... - -.. code-block:: Python - - code = generate_instantiations_string( ... ) - -.. code-block:: Python - - mb = module_builder_t( [ ..., create_text_fc( code ) ], ... ) - mb.namespace( 'py_details' ).exclude() - - -`Py++`_ allows you to extract declarations from string, which contains -valid C++ code. It creates temporal header file and compiles it. At the end of -the compilation process it will remove it. You can read mode about ``create_text_fc`` -function `here`__. - -.. __ : ./../../pygccxml/design.html#parser-configuration-classes - - - -I understand that the provided solution is not perfect. I understand that something -better and simpler should be done, but a priority of this is low. There are few -tasks, that have much higher priority. Allen Bierbaum wants to fix the situation. -He created a `wiki page`_, that discuss possible solutions. Your contribution is -welcome too! - -.. _`wiki page` : https://realityforge.vrsource.org/view/PyppApi/TemplateSupport - ---------------------------------------------------- -How to deal with template on return type functions? ---------------------------------------------------- -.. code-block:: C++ - - struct environment_t{ - ... - template< class T> - T get_value(const std::string& name); - ... - }; - - //Somewhere in your code - environment_t env; - std::string path = env.get_value< std::string >( "PATH" ); - int version = env.get_value< int >( "VERSION" ); - -`GCC-XML`_ will see both instantiations, ``get_value<int>`` and ``get_value< std::string >``, -and will provide information about them. The name of both member functions, -reported by `GCC-XML`_ is "**get_value**". - -In this case, `Py++`_ generates a code, which contains few errors and if your are -lucky, depends on the compiler you use, the generated code will not compile. -Otherwise, you will discover the errors while testing the bindings. - -Generated code: - -.. code-block:: C++ - - bp::class_< environment_t >( "environment_t" ) - ... - .def( "get_value" - , (int ( ::environment_t::* )( ::std::string const & ) )( &::environment_t::get_value ) ) - .def( "get_value" - , (::std::string ( ::environment_t::* )( ::std::string const & ) )( &::environment_t::get_value ) ); - -The correct code: - -.. code-block:: C++ - - bp::class_< environment_t >( "environment_t" ) - .def( "get_value" - , (int ( ::environment_t::* )( ::std::string const & ) )( &::environment_t::get_value< int > ) ) - //--------------------------------------------------------------------------^^^^^^^^^^^^^^^^ - .def( "get_value" - , (::std::string ( ::environment_t::* )( ::std::string const & ) )( &::environment_t::get_value< std::string > ) ); - //------------------------------------------------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^ - -The perfect one: - -.. code-block:: C++ - - bp::class_< environment_t >( "environment_t" ) - ... - .def( "get_value", &::environment_t::get_value< int > ) - .def( "get_value", &::environment_t::get_value< std::string > ); - -Solution --------- -.. code-block:: Python - - mb = module_builder_t( ..., optimize_queries=False, ... ) - environment = mb.class_( "environment_t" ) - for f in environment.member_functions( "get_value" ): - f.alias = f.name + "_" + f.return_type.decl_string #create new function alias - f.name = f.demangled_name - mb.run_query_optimizer() - -Before you read the rest of the answer, you should understand what is "name mangling" -means. If you don't, consider reading about it on `Wikipedia`__. - -.. __ : http://en.wikipedia.org/wiki/Name_mangling - - -The solution is pretty simple. `GCC-XML`_ reports mangled and demangled function -names. The demangled function name contains "real" function name: -``get_value< used type >``. You only have to instruct `Py++`_ to use it. - -`Py++`_ does not use by default demangled function name for mainly one reason. -Demangled function name is a string that contains a lot of information. `Py++`_ -implements a parser, which extracts the only relevant one. The parser -implementation is a little bit complex and was not heavily tested. By "heavily" I -mean that I tested it on a lot of crazy use cases and on a real project, but -there is always some new use case out there. I am almost sure it will work for -you. The problem, we deal with, is rare, so by default "demangled_name" -feature is turned off. - -By the way, almost the same problem exists for template classes. But, in the -classes use case `Py++`_ uses demangled name by default. - - -------------------------------------- -Py++ generated file name is too long! -------------------------------------- -There are use cases, when `Py++`_ generated file name is too long. In some cases -the code generation process even fails because of this. What can you do in order -to eliminate the problem? - -First of all the problem arises when you expose template instantiated classes -and you did not set the class alias. - -Let me explain: - -.. code-block:: C++ - - template < class T> - struct holder{ ... }; - - -Lets say that you want to export ``holder< int >`` class. Class name in `Python`_ -has few `constraints`_. `Py++`_ is aware of the `constraints`_ and if you didn't -set an alias to the class, `Py++`_ will do it for you. In this case, -"holder_less_int_grate\_" is the generated alias. Obviously it is much longer -and not readable. - -.. _`constraints` : http://www.python.org/doc/current/ref/identifiers.html - -There are few pretty good reasons for this behavior: - -* when you just start to work on `Python`_ bindings concentrate your attention - on really important things - -* if you forgot to set the class alias your users still can use the class - functionality, however the class name will be a little bit ugly. - - -In this case the generate alias for ``holder`` instantiation is relatively short. -Imagine how long it could be for ``std::map`` instantiation. - -`Py++`_ uses class alias for the file name. So if you want to force `Py++`_ to -generate files with short name, you have to set class alias: - -.. code-block:: Python - - from pyplusplus import module_builder - - mb = module_builder_t( ... ) - holder = mb.class_( 'holder< int >' ) - holder.alias = 'IntHolder' - #next line has same effect as the previous one: - holder.rename( 'IntHolder' ) - -The nice thing about this approach is that now `Python`_ users have "normal" -class name and you have short file name. - -------------------- -Full\relative paths -------------------- - -Consider next file layout: -:: - - boost/ - date_time/ - ptime.hpp - time_duration.hpp - date_time.hpp //main header, which include all other header files - -Py++ currently does not handle relative paths as input very well, so it is -recommended that you use ``os.path.abspath()`` to transform the header file to -be processed into an absolute path: - -.. code-block:: Python - - #Next code will expose nothing - mb = module_builder( [ 'date_time/date_time.hpp' ], ... ) - mb.split_module( ... ) - - #while this one will work as expected - import os - mb = module_builder( [ os.path.abspath('date_time/date_time.hpp') ], ... ) - mb.split_module( ... ) - - -.. _`Py++` : ./../pyplusplus.html -.. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html -.. _`Python`: http://www.python.org -.. _`GCC-XML`: http://www.gccxml.org This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-01-05 21:18:15
|
Revision: 1219 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1219&view=rev Author: roman_yakovenko Date: 2008-01-05 13:18:15 -0800 (Sat, 05 Jan 2008) Log Message: ----------- updating docs Modified Paths: -------------- pyplusplus_dev/docs/documentation/how_to/how_to.rest pyplusplus_dev/docs/documentation/how_to/www_configuration.py Added Paths: ----------- pyplusplus_dev/docs/documentation/how_to/fatal_error_c1204.rest Added: pyplusplus_dev/docs/documentation/how_to/fatal_error_c1204.rest =================================================================== --- pyplusplus_dev/docs/documentation/how_to/fatal_error_c1204.rest (rev 0) +++ pyplusplus_dev/docs/documentation/how_to/fatal_error_c1204.rest 2008-01-05 21:18:15 UTC (rev 1219) @@ -0,0 +1,26 @@ +============================================================== +Fatal error C1204: compiler limit: internal structure overflow +============================================================== + +**Fatal error C1204: compiler limit: internal structure overflow** + +If you get this error, than the generated file is too big. You will have to split +it to few files. Well, not you but `Py++`_, you will only have to tell it to do +that. + +If you are using ``module_builder_t.write_module`` method, consider to switch +to ``module_builder_t.split_module``. + +If you are using ``split_module``, but still the generated code for some class +could not be compiled, because of the error, you can ask `Py++`_ to split the +code generated for class to be split to few source files. + +For more information, considre to read the `splitting generated code to files`_ +document. + +.. _`splitting generated code to files` : ./../split_module.html + +.. _`Py++` : ./../pyplusplus.html +.. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html +.. _`Python`: http://www.python.org +.. _`GCC-XML`: http://www.gccxml.org Modified: pyplusplus_dev/docs/documentation/how_to/how_to.rest =================================================================== --- pyplusplus_dev/docs/documentation/how_to/how_to.rest 2008-01-05 20:47:42 UTC (rev 1218) +++ pyplusplus_dev/docs/documentation/how_to/how_to.rest 2008-01-05 21:18:15 UTC (rev 1219) @@ -8,10 +8,14 @@ .. _`How to deal with templates?` : ./templates.html -`How to add custom exception translation?`_ +`How to register an exception translation?`_ -.. _ `How to add custom exception translation?` : custom_exception_translation.html +.. _`How to register an exception translation?` : exception_translation.html +`Fatal error C1204:Compiler limit: internal structure overflow`_ + +.. _`Fatal error C1204:Compiler limit: internal structure overflow` : ./fatal_error_c1204.html + ------------------------------------------------------- How to expose function, which has hand-written wrapper? ------------------------------------------------------- @@ -68,24 +72,6 @@ That's all. -------------------------------------------------------------- -Fatal error C1204:Compiler limit: internal structure overflow -------------------------------------------------------------- - -If you get this error, than the generated file is too big. You will have to split -it to few files. Well, not you but `Py++`_, you will only have to tell it to do -that. - -If you are using ``module_builder_t.write_module`` method, consider to switch -to ``module_builder_t.split_module``. - -If you are using ``split_module``, but still the generated code for some class -could not be compiled, because of the error, you can ask `Py++`_ to split the -code generated for class to be split to few cpp files. - -For more information, please read the documentation. - - ------------------------------------- Py++ generated file name is too long! ------------------------------------- Modified: pyplusplus_dev/docs/documentation/how_to/www_configuration.py =================================================================== --- pyplusplus_dev/docs/documentation/how_to/www_configuration.py 2008-01-05 20:47:42 UTC (rev 1218) +++ pyplusplus_dev/docs/documentation/how_to/www_configuration.py 2008-01-05 21:18:15 UTC (rev 1219) @@ -6,5 +6,6 @@ , 'templates' : 'deal with templates' , 'best_practices' : 'best practices' , 'exception_translation' : 'exception translation' + , 'fatal_error_c1204' : 'fatal error C1204: compiler limit: internal structure overflow' } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-01-05 20:47:40
|
Revision: 1218 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1218&view=rev Author: roman_yakovenko Date: 2008-01-05 12:47:42 -0800 (Sat, 05 Jan 2008) Log Message: ----------- improving docs Added Paths: ----------- pyplusplus_dev/docs/documentation/how_to/ pyplusplus_dev/docs/documentation/how_to/best_practices.rest pyplusplus_dev/docs/documentation/how_to/exception_translation.rest pyplusplus_dev/docs/documentation/how_to/hints.rest pyplusplus_dev/docs/documentation/how_to/how_to.rest pyplusplus_dev/docs/documentation/how_to/templates.rest pyplusplus_dev/docs/documentation/how_to/www_configuration.py Added: pyplusplus_dev/docs/documentation/how_to/best_practices.rest =================================================================== --- pyplusplus_dev/docs/documentation/how_to/best_practices.rest (rev 0) +++ pyplusplus_dev/docs/documentation/how_to/best_practices.rest 2008-01-05 20:47:42 UTC (rev 1218) @@ -0,0 +1,176 @@ +============== +Best practices +============== + +.. contents:: Table of contents + +------------ +Introduction +------------ + +`Py++`_ has reach interface and a lot of functionality. Sometimes reach +interface helps, but sometimes it can confuse. This document will describe how +effectively to use `Py++`_. + +------------ +Big projects +------------ + +Definition +---------- + +First of all, let me to define "big project". "Big project" is a project with +few hundred of header files. `Py++`_ was born to create `Python`_ bindings +for such projects. If you take a look `here`__ you will find few such projects. + +.. __ : ./../../pyplusplus/quotes.html + +Tips +---- + +* Create one header file, which will include all project header files. + + Doing it this way makes it so `GCC-XML`_ is only called once and it reduces the + overhead that would occur if you pass `GCC-XML`_ all the files individually. + Namely `GCC-XML`_ would have to run hundreds of times and each call would + actually end up including quite a bit of common code anyway. This way takes a + `GCC-XML`_ processing time from multiple hours with gigabytes of caches to a + couple minutes with a reasonable cache size. + + You can read more about different caches supported by `pygccxml`_ `here`__. + ``module_builder_t.__init__`` method takes reference to an instance of cache + class or ``None``: + + .. code-block:: Python + + from module_builder import * + mb = module_builder_t( ..., cache=file_cache_t( path to project cache file ), ... ) + +* Single header file, will also improve performance compiling the generated bindings. + + When `Py++`_ generated the bindings, you have a lot of .cpp files to + compile. The project you are working on is big. I am sure it takes a lot of + time to compile projects that depend on it. Generated code also depend on it, + more over this code contains a lot of template instantiations. So it could + take a great deal of time to compile it. Allen Bierbaum investigated this + problem. He found out that most of the time is really spent processing all the + headers, templates, macros from the project and from the boost library. So he + come to conclusion, that in order to improve compilation speed, user should + be able to control( to be able to generate ) precompiled header file. He + implemented an initial version of the functionality. After small discussion, + we agreed on next interface: + + .. code-block:: Python + + class module_builder_t( ... ): + ... + def split_module( self, directory_path, huge_classes=None, precompiled_header=None ): + ... + + ``precompiled_header`` argument could be ``None`` or string, that contains + name of precompiled header file, which will be created in the directory. + `Py++`_ will add to it header files from `Boost.Python`_ library and + your header files. + + What is ``huge_classes`` argument for? ``huge_classes`` could be ``None`` or + list of references to class declarations. It is there to provide a solution to + `this error`_. `Py++`_ will automatically split generated code for the + huge classes to few files: + + .. code-block:: Python + + mb = module_builder_t( ... ) + ... + my_big_class = mb.class_( my_big_class ) + mb.split_module( ..., huge_classes=[my_big_class], ... ) + + * **Caveats** + + Consider next file layout: + :: + + boost/ + date_time/ + ptime.hpp + time_duration.hpp + date_time.hpp //main header, which include all other header files + + Py++ currently does not handle relative paths as input very well, so it is + recommended that you use "os.path.abspath()" to transform the header file to + be processed into an absolute path: + + .. code-block:: Python + + #Next code will expose nothing + mb = module_builder( [ 'date_time/date_time.hpp' ], ... ) + + #while this one will work as expected + import os + mb = module_builder( [ os.path.abspath('date_time/date_time.hpp') ], ... ) + +.. _`this error` : http://boost.org/libs/python/doc/v2/faq.html#c1204 +.. __ : ./../../pygccxml/design.html + +* Keep the declaration tree small. + + When parsing the header files to build the declaration tree, there will also + be the occasional "junk" declaration inside the tree that is not relevant to + the bindings you want to generate. These extra declarations come from header + files that were included somewhere in the header files that you were actually + parsing (e.g. if that library uses the STL or OpenGL or other system headers + then the final declaration tree will contain those declarations, too). + It can happen that the majority of declarations in your declaration tree are + such "junk" declarations that are not required for generating your bindings + and that just slow down the generation process (reading the declaration cache + and doing queries will take longer). + + To speed up your generation process you might want to consider making the + declaration tree as small as possible and only store those declarations that + somehow have an influence on the bindings. Ideally, this is done as early + as possible and luckily gccxml provides an option that allows you to reduce + the number of declarations that it will store in the output XML file. You can + specify one or more declarations using the ``-fxml-start`` option and only + those sub-tree starting at the specified declarations will be written. For + example, if you specify the name of a particular class, only this class + and all its members will get written. Or if your project already uses + a dedicated namespace you can simply use this namespace as a starting point + and all declarations stemming from system headers will be ignored (except + for those declarations that are actually used within your library). + + In the ``pygccxml`` package you can set the value for the ``-fxml-start`` + option using the ``start_with_declarations`` attribute of the + ``pygccxml.parser.config_t`` object that you are passing to the parser. + +* Use `Py++`_ repository of generated files md5 sum. + + `Py++`_ is able to store md5 sum of generated files in a file. Next time you + will generate code, `Py++`_ will compare generated file content against the sum, + instead of loading the content of the previously generated file from the disk + and comparing against it. + + .. code-block:: Python + + mb = module_builder_t( ... ) + ... + my_big_class = mb.class_( my_big_class ) + mb.split_module( ..., use_files_sum_repository=True ) + + `Py++`_ will generate file named "<your module name>.md5.sum" in the directory + it will generate all the files. + + Enabling this functionality should give you 10-15% of performance boost. + + * **Caveats** + + If you changed manually some of the files - don't forget to delete the relevant + line from "md5.sum" file. You can also delete the whole file. If the file is + missing, `Py++`_ will use old plain method of comparing content of the files. + It will not re-write "unchanged" files and you will not be forced to recompile + the whole project. + + +.. _`Py++` : ./../pyplusplus.html +.. _`pygccxml` : ./../../pygccxml/pygccxml.html +.. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html +.. _`Python`: http://www.python.org +.. _`GCC-XML`: http://www.gccxml.org Added: pyplusplus_dev/docs/documentation/how_to/exception_translation.rest =================================================================== --- pyplusplus_dev/docs/documentation/how_to/exception_translation.rest (rev 0) +++ pyplusplus_dev/docs/documentation/how_to/exception_translation.rest 2008-01-05 20:47:42 UTC (rev 1218) @@ -0,0 +1,65 @@ +========================================= +How to register an exception translation? +========================================= + +.. contents:: Table of contents + +------------ +Introduction +------------ + +Boost.Python provides functionality to translate any C++ exception to a Python one. +`Py++`_ provides a convenient API to do this. + +By the way, be sure to take a look on "`troubleshooting guide - exceptions`_". +The guide will introduces a complete solution for handling exceptions within +Python scripts. + +.. _`troubleshooting guide - exceptions` : ./../../troubleshooting_guide/exceptions/exceptions.html + +-------- +Solution +-------- + +`Boost.Python exception translator documentation`_ contains a complete explanation +what should be done. I will use that example, to show how it could be done with +`Py++`_: + +.. code-block:: Python + + from pyplusplus import module_builder_t + + mb = module_builder_t( ... ) + my_exception = mb.class_( 'my_exception' ) + + translate_code = 'PyErr_SetString(PyExc_RuntimeError, exc.what();' + my_exception.exception_translation_code = translate_code + +That's all, really. `Py++`_ will generate for you the ``translate`` function +definition and than will register it. + +I think this is a most popular use case - translate a C++ exception to a string +and than to create an instance of Python built-in exception. That is exactly why +`Py++`_ provides additional API: + +.. code-block:: Python + + mb = module_builder_t( ... ) + my_exception = mb.class_( 'my_exception' ) + + my_exception.translate_exception_to_string( 'PyExc_RuntimeError', 'exc.what()') + +The first argument of ``translate_exception_to_string`` method is exception type, +The second one is a string - code that converts your exception to ``const char*``. + +As you see, it is really simple to add exception translation to your project. + +One more point, in both pieces of code I used "``exc``" as the name of ``my_exception`` +class instance. This is a predefined name. I am not going to change it without +any good reason, any time soon :-). + +.. _`Boost.Python exception translator documentation` : http://boost.org/libs/python/doc/v2/exception_translator.html +.. _`Py++` : ./../../pyplusplus.html +.. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html +.. _`Python`: http://www.python.org +.. _`GCC-XML`: http://www.gccxml.org Added: pyplusplus_dev/docs/documentation/how_to/hints.rest =================================================================== --- pyplusplus_dev/docs/documentation/how_to/hints.rest (rev 0) +++ pyplusplus_dev/docs/documentation/how_to/hints.rest 2008-01-05 20:47:42 UTC (rev 1218) @@ -0,0 +1,64 @@ +===== +Hints +===== + +.. contents:: Table of contents + +---------------------------------- +Class template instantiation alias +---------------------------------- + +`Py++`_ has nice feature. If you define ``typedef`` for instantiated class +template, than `Py++`_ will use it as a `Python`_ class name. + +For example: + +.. code-block:: C++ + + #include <vector> + typedef std::vector< int > numbers; + numbers generate_n(){ + ... + } + +`Py++`_ will use "numbers" as Python class name: + +.. code-block:: C++ + + using boost::python; + class_< std::vector< int > >( "numbers" ) + ... + ; + +`Py++`_ will pick up the alias, only in case the class has single "typedef". + +``pyplusplus::aliases`` namespace +--------------------------------- + +The previous approach is "implicit" - `Py++`_ does something behind the scene. +Recently (version 0.8.6 ), another approach was introduced: + +.. code-block:: C++ + + #include <vector> + + namespace pyplusplus{ namespace aliases{ + //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + typedef std::vector< int > numbers; + + } } //pyplusplus::aliases + +The idea is that you create namespace with a special name - ``pyplusplus::aliases`` +and `Py++`_ automatically picks the class aliases from it. In case you accidentally +introduced two or more different aliases to the same class, it will pick the +longest one and print a warning. Other advantages of the approach: + +* you are not forced to learn new API + +* you continue to use your favorite editor and familiar language + +.. _`Py++` : ./../pyplusplus.html +.. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html +.. _`Python`: http://www.python.org +.. _`GCC-XML`: http://www.gccxml.org + Added: pyplusplus_dev/docs/documentation/how_to/how_to.rest =================================================================== --- pyplusplus_dev/docs/documentation/how_to/how_to.rest (rev 0) +++ pyplusplus_dev/docs/documentation/how_to/how_to.rest 2008-01-05 20:47:42 UTC (rev 1218) @@ -0,0 +1,175 @@ +============ +How to ... ? +============ + +.. contents:: Table of contents + +`How to deal with templates?`_ + +.. _`How to deal with templates?` : ./templates.html + +`How to add custom exception translation?`_ + +.. _ `How to add custom exception translation?` : custom_exception_translation.html + +------------------------------------------------------- +How to expose function, which has hand-written wrapper? +------------------------------------------------------- +.. code-block:: C++ + + struct window_t{ + ... + void get_size( int& height, int& widht ) const; + }; + +You can not expose ``get_size`` function as is - ``int`` is immutable type in +Python. So, we need to create a wrapper to the function: + +.. code-block:: C++ + + boost::python::tuple get_size_wrapper( const window_t& win ){ + int height(0), width( 0 ); + win.get_size( height, widht ); + return boost::python::make_tuple( height, width ); + } + +.. code-block:: C++ + + class_<window_t>( ... ) + .def( "get_size", &get_size_wrapper ) + ... + ; + +Now, after you know how this problem is solved. I will show how this solution +could be integrated with `Py++`_. + +.. code-block:: Python + + wrapper_code = \ + """ + static boost::python::tuple get_size( const window_t& win ){ + int height(0), width( 0 ); + win.get_size( height, width ); + return boost::python::make_tuple( height, width ); + } + """ + +.. code-block:: Python + + registration_code = 'def( "get_size", &%s::get_size )' % window.wrapper_alias + +.. code-block:: Python + + mb = module_builder_t( ... ) + window = mb.class_( "window_t" ) + window.member_function( "get_size" ).exclude() + window.add_wrapper_code( wrapper_code ) + window.registration_code( registration_code ) + +That's all. + +------------------------------------------------------------- +Fatal error C1204:Compiler limit: internal structure overflow +------------------------------------------------------------- + +If you get this error, than the generated file is too big. You will have to split +it to few files. Well, not you but `Py++`_, you will only have to tell it to do +that. + +If you are using ``module_builder_t.write_module`` method, consider to switch +to ``module_builder_t.split_module``. + +If you are using ``split_module``, but still the generated code for some class +could not be compiled, because of the error, you can ask `Py++`_ to split the +code generated for class to be split to few cpp files. + +For more information, please read the documentation. + + +------------------------------------- +Py++ generated file name is too long! +------------------------------------- +There are use cases, when `Py++`_ generated file name is too long. In some cases +the code generation process even fails because of this. What can you do in order +to eliminate the problem? + +First of all the problem arises when you expose template instantiated classes +and you did not set the class alias. + +Let me explain: + +.. code-block:: C++ + + template < class T> + struct holder{ ... }; + + +Lets say that you want to export ``holder< int >`` class. Class name in `Python`_ +has few `constraints`_. `Py++`_ is aware of the `constraints`_ and if you didn't +set an alias to the class, `Py++`_ will do it for you. In this case, +"holder_less_int_grate\_" is the generated alias. Obviously it is much longer +and not readable. + +.. _`constraints` : http://www.python.org/doc/current/ref/identifiers.html + +There are few pretty good reasons for this behavior: + +* when you just start to work on `Python`_ bindings concentrate your attention + on really important things + +* if you forgot to set the class alias your users still can use the class + functionality, however the class name will be a little bit ugly. + + +In this case the generate alias for ``holder`` instantiation is relatively short. +Imagine how long it could be for ``std::map`` instantiation. + +`Py++`_ uses class alias for the file name. So if you want to force `Py++`_ to +generate files with short name, you have to set class alias: + +.. code-block:: Python + + from pyplusplus import module_builder + + mb = module_builder_t( ... ) + holder = mb.class_( 'holder< int >' ) + holder.alias = 'IntHolder' + #next line has same effect as the previous one: + holder.rename( 'IntHolder' ) + +The nice thing about this approach is that now `Python`_ users have "normal" +class name and you have short file name. + +------------------- +Full\relative paths +------------------- + +Consider next file layout: +:: + + boost/ + date_time/ + ptime.hpp + time_duration.hpp + date_time.hpp //main header, which include all other header files + +Py++ currently does not handle relative paths as input very well, so it is +recommended that you use ``os.path.abspath()`` to transform the header file to +be processed into an absolute path: + +.. code-block:: Python + + #Next code will expose nothing + mb = module_builder( [ 'date_time/date_time.hpp' ], ... ) + mb.split_module( ... ) + + #while this one will work as expected + import os + mb = module_builder( [ os.path.abspath('date_time/date_time.hpp') ], ... ) + mb.split_module( ... ) + + +.. _`Py++` : ./../pyplusplus.html +.. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html +.. _`Python`: http://www.python.org +.. _`GCC-XML`: http://www.gccxml.org Added: pyplusplus_dev/docs/documentation/how_to/templates.rest =================================================================== --- pyplusplus_dev/docs/documentation/how_to/templates.rest (rev 0) +++ pyplusplus_dev/docs/documentation/how_to/templates.rest 2008-01-05 20:47:42 UTC (rev 1218) @@ -0,0 +1,196 @@ +=========================== +How to deal with templates? +=========================== + +.. contents:: Table of contents + +------------ +Introduction +------------ + +I would like to introduce next piece of code I will use for most exlanations. + +.. code-block:: C++ + + // file point.h + template< class T> + struct point_t{ + T x, y; + }; + + template <class T> + double distance( const point_t<T>& point ){ + return sqrt( point.x * point.x + point.y*point.y ); + } + + struct environment_t{ + ... + template< class T> + T get_value(const std::string& name); + ... + }; + +---------------------- +Template instantiation +---------------------- + +First of all you should understand, that you can not export template itself, but +only its instantiations. + +You can instantiate template class using operator ``sizeof``: + +.. code-block:: C++ + + sizeof( point_t<int> ); + + +In order to instantiate a function you have to call it: + +.. code-block:: C++ + + void instantiate(){ + double x = distance( point_t<t>() ); + + environment_t env; + std::string path = env.get_value< std::string >( "PATH" ); + int version = env.get_value< int >( "VERSION" ); + } + +You should put that code in some header file, parsed by GCC-XML. + +"Dynamic" instantiation +----------------------- +If you have a template class, which should be instantiated with many types, you +can create a small code generator, which will "instantiate the class". It is +pretty easy to blend together the generated code and the existing one: + +.. code-block:: Python + + from module_builder import module_builder_t, create_text_fc + + def generate_instantiations_string( ... ): + ... + + code = generate_instantiations_string( ... ) + + mb = module_builder_t( [ create_text_fc( code ), other header files ], ... ) + ... + +Function ``create_text_fc`` allows you to extract declarations from the string, +which contains valid C++ code. It creates temporal header file and compiles it. + +.. __ : ./../../../pygccxml/design.html#parser-configuration-classes + +---------------------------------- +Functions templated on return type +---------------------------------- + +.. code-block:: C++ + + environment_t env; + std::string path = env.get_value< std::string >( "PATH" ); + int version = env.get_value< int >( "VERSION" ); + + +`GCC-XML`_ provides information for both instantiations: + + * ``get_value<int>`` + + * ``get_value< std::string >`` + +But, in this case there is a catch: the name of both functions is "**get_value**". +The only difference is "return type". + +In this situation, `Py++`_ will generate code that contains errors. If your are +lucky, it depends on the compiler you use, the generated code will not compile. +Otherwise, you will discover the errors while testing the bindings. + +Generated code: + +.. code-block:: C++ + + bp::class_< environment_t >( "environment_t" ) + ... + .def( "get_value" + , (int ( ::environment_t::* )( ::std::string const & ) )( &::environment_t::get_value ) ) + .def( "get_value" + , (::std::string ( ::environment_t::* )( ::std::string const & ) )( &::environment_t::get_value ) ); + +The correct code: + +.. code-block:: C++ + + bp::class_< environment_t >( "environment_t" ) + .def( "get_value" + , (int ( ::environment_t::* )( ::std::string const & ) )( &::environment_t::get_value< int > ) ) + //--------------------------------------------------------------------------^^^^^^^^^^^^^^^^ + .def( "get_value" + , (::std::string ( ::environment_t::* )( ::std::string const & ) )( &::environment_t::get_value< std::string > ) ); + //------------------------------------------------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^ + +The perfect one: + +.. code-block:: C++ + + bp::class_< environment_t >( "environment_t" ) + ... + .def( "get_value", &::environment_t::get_value< int > ) + .def( "get_value", &::environment_t::get_value< std::string > ); + + +Work-around +----------- + +`Py++`_ contains a work-around to the problem: + +.. code-block:: Python + + mb = module_builder_t( ..., optimize_queries=False, ... ) + environment = mb.class_( "environment_t" ) + for f in environment.member_functions( "get_value" ): + #set the function alias + f.alias = f.name + "_" + f.return_type.decl_string + #correct function name + f.name = f.demangled_name + #you still want the queries to run fast + mb.run_query_optimizer() + +Before you read the rest of the solution, you should understand what is +"name mangling" means. If you don't, consider reading about it on `Wikipedia`__ . + +.. __ : http://en.wikipedia.org/wiki/Name_mangling + +The solution is pretty simple. `GCC-XML`_ reports mangled and demangled function +names. The demangled function name contains "real" function name: +``get_value< used type >``. You only have to instruct `Py++`_ to use it. + +`Py++`_ does not use by default demangled function name for mainly one reason. +Demangled function name is a string that contains a lot of information. `Py++`_ +implements a parser, which extracts the only relevant one. The parser +implementation is a little bit complex and was not heavily tested. By "heavily" I +mean that I tested it on a lot of crazy use cases and on a real project, but +there is always some new use case out there. I am almost sure it will work for +you. The problem, we deal with, is rare, so by default "demangled_name" +feature is turned off. + +By the way, almost the same problem exists for template classes. But, in the +classes use case `Py++`_ uses demangled name by default. + +----------- +Help wanted +----------- +I understand that the provided solutions are not perfect and that something +better and simpler should be done. Unfortunatelly the priority of this task is +low. + +Allen Bierbaum has few suggestion that could improve `Py++`_. He created a +`wiki page`_, that discuss possible solutions. Your contribution is welcome too! + +.. _`wiki page` : https://realityforge.vrsource.org/view/PyppApi/TemplateSupport + + + +.. _`Py++` : ./../pyplusplus.html +.. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html +.. _`Python`: http://www.python.org +.. _`GCC-XML`: http://www.gccxml.org Added: pyplusplus_dev/docs/documentation/how_to/www_configuration.py =================================================================== --- pyplusplus_dev/docs/documentation/how_to/www_configuration.py (rev 0) +++ pyplusplus_dev/docs/documentation/how_to/www_configuration.py 2008-01-05 20:47:42 UTC (rev 1218) @@ -0,0 +1,10 @@ +name = 'how to ... ?' +#main_html_file = 'index.html' + +names = { 'hints' : 'hints' + , 'how_to' : 'how to' + , 'templates' : 'deal with templates' + , 'best_practices' : 'best practices' + , 'exception_translation' : 'exception translation' +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-01-03 12:25:12
|
Revision: 1217 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1217&view=rev Author: roman_yakovenko Date: 2008-01-03 04:25:07 -0800 (Thu, 03 Jan 2008) Log Message: ----------- updating docs Modified Paths: -------------- pyplusplus_dev/docs/documentation/how_to.rest pyplusplus_dev/docs/documentation/split_module.rest Modified: pyplusplus_dev/docs/documentation/how_to.rest =================================================================== --- pyplusplus_dev/docs/documentation/how_to.rest 2008-01-03 10:23:45 UTC (rev 1216) +++ pyplusplus_dev/docs/documentation/how_to.rest 2008-01-03 12:25:07 UTC (rev 1217) @@ -376,6 +376,35 @@ The nice thing about this approach is that now `Python`_ users have "normal" class name and you have short file name. +------------------- +Full\relative paths +------------------- + +Consider next file layout: +:: + + boost/ + date_time/ + ptime.hpp + time_duration.hpp + date_time.hpp //main header, which include all other header files + +Py++ currently does not handle relative paths as input very well, so it is +recommended that you use ``os.path.abspath()`` to transform the header file to +be processed into an absolute path: + +.. code-block:: Python + + #Next code will expose nothing + mb = module_builder( [ 'date_time/date_time.hpp' ], ... ) + mb.split_module( ... ) + + #while this one will work as expected + import os + mb = module_builder( [ os.path.abspath('date_time/date_time.hpp') ], ... ) + mb.split_module( ... ) + + .. _`Py++` : ./../pyplusplus.html .. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html .. _`Python`: http://www.python.org Modified: pyplusplus_dev/docs/documentation/split_module.rest =================================================================== --- pyplusplus_dev/docs/documentation/split_module.rest 2008-01-03 10:23:45 UTC (rev 1216) +++ pyplusplus_dev/docs/documentation/split_module.rest 2008-01-03 12:25:07 UTC (rev 1217) @@ -209,11 +209,23 @@ * ``huge_classes`` - list of names of huge classes * ``on_unused_file_found`` - callable object, which is called every time `Py++`_ found that previously generated file is not in use anymore. - * ``use_files_sum_repository`` - Py++ can generate file, which will contain md5 - sum of every generated file. Next time you generate code, md5sum will be loaded - from the file and compared. This could speed-up code generation process by 10-15% - on big projects. + * ``use_files_sum_repository`` + `Py++`_ is able to store md5 sum of the generated files in a file. Next + time you will generate code, Py++ will compare generated file content + against the sum, instead of loading the content of the previously generated + file from the disk and comparing against it. + "<your module name>.md5.sum" is the file, that will be generated in the + ``dir_name`` directory. + + Enabling this functionality should give you 10-15% of performance boost. + + Warning: If you changed manually some of the files - don't forget to delete + the relevant line from "md5.sum" file. You can also delete the whole file. + If the file is missing, Py++ will use old plain method of comparing content + of the files. It will not re-write "unchanged" files and you will not be + forced to recompile the whole project. + * .. code-block:: Python @@ -227,9 +239,6 @@ * ``number_of_files`` - the desired number of generated source files - - - .. _`Py++` : ./../pyplusplus.html .. _`pygccxml` : ./../../pygccxml/pygccxml.html .. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2008-01-03 10:23:40
|
Revision: 1216 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1216&view=rev Author: roman_yakovenko Date: 2008-01-03 02:23:45 -0800 (Thu, 03 Jan 2008) Log Message: ----------- adding docs Modified Paths: -------------- pyplusplus_dev/docs/documentation/split_module.rest Modified: pyplusplus_dev/docs/documentation/split_module.rest =================================================================== --- pyplusplus_dev/docs/documentation/split_module.rest 2007-12-31 09:27:13 UTC (rev 1215) +++ pyplusplus_dev/docs/documentation/split_module.rest 2008-01-03 10:23:45 UTC (rev 1216) @@ -23,12 +23,14 @@ ----------- If you just start with `Py++`_ or you are developing small module, than you should -start with this strategy. It is simple - all source code generated to single file. +start with this strategy. It is simple - all source code generated to a single file. Of course this solution has it's price - every time you change the code you will -have to recompile it. If you expose 2 or more declarations this is annoying and -time-consuming operation. +have to recompile it. If you expose 2 or more declarations, this is annoying and +time-consuming operation. In some cases you even will not be able to compile the +generated code, because of its size. + Usage example ------------- @@ -48,22 +50,186 @@ as follows: * every class has it's own source & header file -* all free enumerations are written to a single source file -* all free functions are written to a single source file -* all global variables are written to a single source file -* source file, which contains complete code for module registration +* next declarations are split to separate source files: + * named & unnamed enumerations + + * free functions + + * global variables +* "main" file - the file, which contains complete module registration + The main advantage of this mode is that you don't have to recompile the whole project if only single declaration was changed. Thus this mode suites well huge projects. There are few problems with this mode: -1. There are use cases, when the generated file names are too long. +1. There are use cases, when the generated file name is too long. `Py++`_ + uses class name as a basis for the file name. So in case of template + instantiations the file name could be really long, very long. +2. This mode doesn't play nicely with IDEs. Every time you add/remove classes in + your project the list of generated files will be changed. So, you will have + to maintain your IDE environment file. + This problem was addressed in "fixed set of multiple files" mode. Keep + reading :-). +3. If your project has pretty big class, than it is possible that the generated + code will be too big and it take huge amount of time to compile it (GCC) or + even to fail to compile it (MSVC 7.1). + This problem was addressed in "multiple files, where single class code is + split to few files" mode. + +Usage example +------------- + +.. code-block:: Python + + from pyplusplus import module_builder + + mb = module_builder.module_builder_t(...) + mb.build_code_creator( ... ) + mb.split_module( directory name ) + + +------------------------------------------------------------- +Multiple files, where single class code is split to few files +------------------------------------------------------------- + +This mode solves the problem, I mentioned earlier - you have to expose huge class +and you have problems to compile generated code. + +`Py++`_ will split huge class to files using next strategy: + +* every generated source file can contain maximum 20 exposed declarations +* next declarations are split to separate source files: + + * enumerations + + * unnamed enumerations + + * classes + + * member functions + + * virtual member functions + + * pure virtual member functions + + * protected member functions + +* "main" class file - the file, which contains complete definition/registration + of the generated file + +Usage example +------------- + +.. code-block:: Python + + from pyplusplus import module_builder + + mb = module_builder.module_builder_t(...) + mb.build_code_creator( ... ) + mb.split_module( directory name, [ list of huge classes names ] ) + +--------------------------- +Fixed set of multiple files +--------------------------- + +This mode was born to play nicely with IDEs. It also can solve the problem with +long file names. The scheme used to name files doesn't use class name. + +In this mode you define the number of generated source files for classes. + + +Usage example +------------- + +.. code-block:: Python + + from pyplusplus import module_builder + + mb = module_builder.module_builder_t(...) + mb.build_code_creator( ... ) + mb.balanced_split_module( directory name, number of generated source files ) + + +------------------ +Precompiled header +------------------ + +Usage of precompiled header file reduces overall compilation time. Not all +compilers support the feature, moreover some of them can't handle presence of +"boost/python.hpp" header in precompiled header file. + +`Py++`_ doesn't provide user-friendly API to add/define precompiled header file +to the generated code. The main reason is that I don't have a good idea how to +integrate/add this functionality to `Py++`_. Nevertheless, you can enjoy from +this time-saving feature: + +.. code-block:: Python + + from pyplusplus import module_builder + from pyplusplus import code_creators + + mb = module_builder_t( ... ) + mb.build_code_creator( ... ) + + precompiled_header = code_creators.include_t( 'your file name' ) + mb.code_creator.adopt_creator( precompiled_header, 0 ) + + mb.split_module( ... ) + + +----------- +API summary +----------- + +Class ``module_builder_t`` contains 3 functions, related to file generation: + +* + .. code-block:: Python + + def write_module( file_name ) + +* + .. code-block:: Python + + def split_module( self + , dir_name + , huge_classes=None + , on_unused_file_found=os.remove + , use_files_sum_repository=True) + + + * ``dir_name`` - directory name the generated files will be put in + * ``huge_classes`` - list of names of huge classes + * ``on_unused_file_found`` - callable object, which is called every time + `Py++`_ found that previously generated file is not in use anymore. + * ``use_files_sum_repository`` - Py++ can generate file, which will contain md5 + sum of every generated file. Next time you generate code, md5sum will be loaded + from the file and compared. This could speed-up code generation process by 10-15% + on big projects. + +* + .. code-block:: Python + + def balanced_split_module( self + , dir_name + , number_of_files + , on_unused_file_found=os.remove + , use_files_sum_repository=True) + + + * ``number_of_files`` - the desired number of generated source files + + + + + .. _`Py++` : ./../pyplusplus.html .. _`pygccxml` : ./../../pygccxml/pygccxml.html .. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2007-12-31 09:27:09
|
Revision: 1215 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1215&view=rev Author: roman_yakovenko Date: 2007-12-31 01:27:13 -0800 (Mon, 31 Dec 2007) Log Message: ----------- adding docs for file writers Modified Paths: -------------- pyplusplus_dev/docs/documentation/www_configuration.py Added Paths: ----------- pyplusplus_dev/docs/documentation/split_module.rest Added: pyplusplus_dev/docs/documentation/split_module.rest =================================================================== --- pyplusplus_dev/docs/documentation/split_module.rest (rev 0) +++ pyplusplus_dev/docs/documentation/split_module.rest 2007-12-31 09:27:13 UTC (rev 1215) @@ -0,0 +1,71 @@ +================================= +Splitting generated code to files +================================= + +.. contents:: Table of contents + +------------ +Introduction +------------ + +`Py++`_ provides 4 different strategies for splitting the generated code into files: + +* single file + +* multiple files + +* fixed set of multiple files + +* multiple files, where single class code is split to few files + +----------- +Single file +----------- + +If you just start with `Py++`_ or you are developing small module, than you should +start with this strategy. It is simple - all source code generated to single file. + +Of course this solution has it's price - every time you change the code you will +have to recompile it. If you expose 2 or more declarations this is annoying and +time-consuming operation. + +Usage example +------------- + +.. code-block:: Python + + from pyplusplus import module_builder + + mb = module_builder.module_builder_t(...) + mb.build_code_creator( ... ) + mb.write_module( file name ) + +-------------- +Multiple files +-------------- + +I believe this is the most widely used strategy. `Py++`_ splits generated code +as follows: + +* every class has it's own source & header file +* all free enumerations are written to a single source file +* all free functions are written to a single source file +* all global variables are written to a single source file +* source file, which contains complete code for module registration + +The main advantage of this mode is that you don't have to recompile the whole +project if only single declaration was changed. Thus this mode suites well huge +projects. + +There are few problems with this mode: + +1. There are use cases, when the generated file names are too long. + + + + +.. _`Py++` : ./../pyplusplus.html +.. _`pygccxml` : ./../../pygccxml/pygccxml.html +.. _`Boost.Python`: http://www.boost.org/libs/python/doc/index.html +.. _`Python`: http://www.python.org +.. _`GCC-XML`: http://www.gccxml.org Modified: pyplusplus_dev/docs/documentation/www_configuration.py =================================================================== --- pyplusplus_dev/docs/documentation/www_configuration.py 2007-12-30 10:39:06 UTC (rev 1214) +++ pyplusplus_dev/docs/documentation/www_configuration.py 2007-12-31 09:27:13 UTC (rev 1215) @@ -7,4 +7,5 @@ , 'inserting_code' : 'inserting code' , 'best_practices' : 'best practices' , 'multi_module_development' : 'multi-module development' + , 'split_module' : 'splitting generated code to files' } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2007-12-30 10:39:06
|
Revision: 1214 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1214&view=rev Author: roman_yakovenko Date: 2007-12-30 02:39:06 -0800 (Sun, 30 Dec 2007) Log Message: ----------- docs update Modified Paths: -------------- pyplusplus_dev/docs/documentation/multi_module_development.rest pyplusplus_dev/pyplusplus/module_builder/builder.py Modified: pyplusplus_dev/docs/documentation/multi_module_development.rest =================================================================== --- pyplusplus_dev/docs/documentation/multi_module_development.rest 2007-12-30 08:25:29 UTC (rev 1213) +++ pyplusplus_dev/docs/documentation/multi_module_development.rest 2007-12-30 10:39:06 UTC (rev 1214) @@ -126,6 +126,29 @@ As you can see "png.cpp" file doesn't contains code, which exposes ``core::image_i`` class. + +----------------------- +Semi-automatic solution +----------------------- + +``already_exposed`` solution is pretty good when you mix hand-written modules with +the Py++ generated ones. It doesn't work/scale for "true" multi-module development. +This is exactly the reason why `Py++`_ offers "semi automatic" solution. + +For every exposed module, `Py++`_ generates "exposed_decl.pypp.txt" file. This +file contains the list of all parsed declarations and whether they were included +or excluded. Later, when you work on another module, you can tell `Py++`_ that +the current module depends on the previously generated one. `Py++`_ will load +"exposed_decl.pypp.txt" file and update the declarations. + +Usage example: + +.. code-block:: Python + + mb = module_builder_t( ... ) + mb.register_module_dependency( other module generated code directory ) + + ------ Caveat ------ Modified: pyplusplus_dev/pyplusplus/module_builder/builder.py =================================================================== --- pyplusplus_dev/pyplusplus/module_builder/builder.py 2007-12-30 08:25:29 UTC (rev 1213) +++ pyplusplus_dev/pyplusplus/module_builder/builder.py 2007-12-30 10:39:06 UTC (rev 1214) @@ -107,9 +107,22 @@ def encoding( self ): return self.__encoding - def register_module_dependency( self, other_module_generate_code_dir ): + def register_module_dependency( self, other_module_generated_code_dir ): + """``already_exposed`` solution is pretty good when you mix hand-written + modules with Py++ generated. It doesn't work/scale for "true" + multi-module development. This is exactly the reason why ``Py++``_ + offers "semi automatic" solution. + + For every exposed module, ``Py++``_ generates "exposed_decl.pypp.txt" file. + This file contains the list of all parsed declarations and whether they + were included or excluded. Later, when you work on another module, you + can tell ``Py++``_ that the current module depends on the previously + generated one. ``Py++``_ will load "exposed_decl.pypp.txt" file and + update the declarations. + """ + db = utils.exposed_decls_db_t() - db.load( other_module_generate_code_dir ) + db.load( other_module_generated_code_dir ) db.update_decls( self.global_ns ) def run_query_optimizer(self): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2007-12-30 08:25:26
|
Revision: 1213 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1213&view=rev Author: roman_yakovenko Date: 2007-12-30 00:25:29 -0800 (Sun, 30 Dec 2007) Log Message: ----------- docs update Modified Paths: -------------- pyplusplus_dev/docs/documentation/warnings.rest pyplusplus_dev/docs/history/history.rest Removed Paths: ------------- pyplusplus_dev/docs/documentation/feedback.html pyplusplus_dev/docs/to_pyste_comparison.html pyplusplus_dev/docs/todo.txt Deleted: pyplusplus_dev/docs/documentation/feedback.html =================================================================== --- pyplusplus_dev/docs/documentation/feedback.html 2007-12-30 08:17:57 UTC (rev 1212) +++ pyplusplus_dev/docs/documentation/feedback.html 2007-12-30 08:25:29 UTC (rev 1213) @@ -1,9 +0,0 @@ -<html> -<head> -<meta http-equiv="refresh" content="0; URL=./warnings.html"> -</head> -<body> -Automatic redirection failed, please go to -<a href="./warnings.html">./warnings.html</a> -</body> -</html> Modified: pyplusplus_dev/docs/documentation/warnings.rest =================================================================== --- pyplusplus_dev/docs/documentation/warnings.rest 2007-12-30 08:17:57 UTC (rev 1212) +++ pyplusplus_dev/docs/documentation/warnings.rest 2007-12-30 08:25:29 UTC (rev 1213) @@ -128,8 +128,10 @@ .. code-block:: Python messages.disable( messages.W1020 ) + + #you also can disable warnings reporting at all: + messages.disable( *messages.all_warning_msgs ) - Logging API ----------- Modified: pyplusplus_dev/docs/history/history.rest =================================================================== --- pyplusplus_dev/docs/history/history.rest 2007-12-30 08:17:57 UTC (rev 1212) +++ pyplusplus_dev/docs/history/history.rest 2007-12-30 08:25:29 UTC (rev 1213) @@ -43,6 +43,8 @@ * Py++ will not expose free operators, if at least one of the classes, it works on, is not exposed. Many thanks to Meghana Haridev for reporting the bug. + +2. Added ability to completely disable warnings reporting. ------------- Version 0.9.0 Deleted: pyplusplus_dev/docs/to_pyste_comparison.html =================================================================== --- pyplusplus_dev/docs/to_pyste_comparison.html 2007-12-30 08:17:57 UTC (rev 1212) +++ pyplusplus_dev/docs/to_pyste_comparison.html 2007-12-30 08:25:29 UTC (rev 1213) @@ -1,9 +0,0 @@ -<html> -<head> -<meta http-equiv="refresh" content="0; URL=./comparisons/pyste.html"> -</head> -<body> -Automatic redirection failed, please go to -<a href="./comparisons/pyste.html">./comparisons/pyste.html</a> -</body> -</html> Deleted: pyplusplus_dev/docs/todo.txt =================================================================== --- pyplusplus_dev/docs/todo.txt 2007-12-30 08:17:57 UTC (rev 1212) +++ pyplusplus_dev/docs/todo.txt 2007-12-30 08:25:29 UTC (rev 1213) @@ -1,4 +0,0 @@ -Todo ----- - -- Provide a way to customize log messages (i.e. set verbosity level) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2007-12-30 08:17:52
|
Revision: 1212 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1212&view=rev Author: roman_yakovenko Date: 2007-12-30 00:17:57 -0800 (Sun, 30 Dec 2007) Log Message: ----------- adding new quote Modified Paths: -------------- pyplusplus_dev/docs/quotes.rest Modified: pyplusplus_dev/docs/quotes.rest =================================================================== --- pyplusplus_dev/docs/quotes.rest 2007-12-27 07:35:39 UTC (rev 1211) +++ pyplusplus_dev/docs/quotes.rest 2007-12-30 08:17:57 UTC (rev 1212) @@ -42,6 +42,15 @@ Andy Miller, a developer of `Python-OGRE`_ project +"... I tried Py++ and it indeed automatically handles the case I outlined above +concerning C-array members, and with much less tedious writing of registration +code. I also found it convenient to use to insert some other C++ code for each +of my structures that normally I wrote by hand. The API docs and examples on your +webpage were very helpful. " + + David Carpman + + ------------------ Who is using Py++? ------------------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2007-12-27 07:35:38
|
Revision: 1211 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1211&view=rev Author: roman_yakovenko Date: 2007-12-26 23:35:39 -0800 (Wed, 26 Dec 2007) Log Message: ----------- updating "history" Modified Paths: -------------- pygccxml_dev/docs/history/history.rest Modified: pygccxml_dev/docs/history/history.rest =================================================================== --- pygccxml_dev/docs/history/history.rest 2007-12-24 22:02:36 UTC (rev 1210) +++ pygccxml_dev/docs/history/history.rest 2007-12-27 07:35:39 UTC (rev 1211) @@ -40,7 +40,27 @@ 4. Support for a type/class "align", "offset" and "size" was added. Many thanks to Ben Schleimer for the implementation. + +5. Support for GCC-XML 0.9 was added. +6. Support for ``__restrict__`` was added. + +7. ``declarations.has_trivial_copy`` was renamed to ``declarations.has_copy_constructor``. + The old name is still available, but will be removed soon. + +8. ``declarations.priority_queue`` was renamed to ``declarations.priority_queue_traits``. + +9. ``declarations.find_container_traits`` function was added. + +10. Support for "partial name" was added. "Partial name" is the class name, without + template default arguments. The functionality was added to std containers + classes. + +11. ``declarations.class_t`` and ``declarations.class_declaration_t`` has new property - + ``container_traits``. This property describes std container element class. + +12. All logging is now done to ``stderr`` instead of ``stdout``. + ------------- Version 0.9.0 ------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2007-12-24 22:02:32
|
Revision: 1210 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1210&view=rev Author: roman_yakovenko Date: 2007-12-24 14:02:36 -0800 (Mon, 24 Dec 2007) Log Message: ----------- updating documentation Modified Paths: -------------- pygccxml_dev/docs/upgrade_issues.rest pygccxml_dev/docs/www_configuration.py Modified: pygccxml_dev/docs/upgrade_issues.rest =================================================================== --- pygccxml_dev/docs/upgrade_issues.rest 2007-12-24 19:17:09 UTC (rev 1209) +++ pygccxml_dev/docs/upgrade_issues.rest 2007-12-24 22:02:36 UTC (rev 1210) @@ -8,9 +8,9 @@ Introduction ------------ -Recently, GCC-XML internal parser was updated to GCC 4.2. The internal representation -of source code, provided by GCC's parser, has changed a lot and few backward -compatibility issues were introduced. In this document, I will try to cover all +Recently, GCC-XML internal parser was updated to GCC 4.2. The internal representation +of source code, provided by GCC's parser, has changed a lot and few backward +compatibility issues were introduced. In this document, I will try to cover all problems you may encounter. @@ -18,10 +18,10 @@ Default constructor ------------------- -GCC-XML 0.9 doesn't report compiler generated default and copy constructors as +GCC-XML 0.9 doesn't report compiler generated default and copy constructors as an implicit ones. -If you rely havily on their existence in the generated XML, I suggest you to swith +If you rely heavily on their existence in the generated XML, I suggest you to switch to `type_traits.has_trivial_constructor`_/`type_traits.has_trivial_copy`_ functions. .. _`type_traits.has_trivial_constructor` : ./apidocs/pygccxml.declarations.type_traits-pysrc.html#has_trivial_constructor @@ -47,7 +47,7 @@ typedef int (xyz_t::*mfun_ptr_t)( double ); typedef int (xyz_t::*mvar_ptr_t); - + GCC-XML 0.7: .. code-block:: XML @@ -57,7 +57,7 @@ <MethodType id="_128" basetype="_7" returns="_136"> <Argument type="_140"/> </MethodType> - + <Typedef id="_4" name="mvar_ptr_t" type="_3" /> <PointerType id="_3" type="_127" size="32" align="32"/> <OffsetType id="_127" basetype="_7" type="_136" size="32" align="32"/> @@ -71,11 +71,11 @@ <MethodType id="_147" basetype="_92" returns="_131"> <Argument type="_127"/> </MethodType> - + <Typedef id="_52" name="mvar_ptr_t" type="_139" /> <OffsetType id="_139" basetype="_92" type="_131" size="32" align="32"/> -`pygccxml`_ handles this problem automatically, you don't have to change your code. +`pygccxml`_ handles this issue automatically, you don't have to change your code. ----------------------- Constant variable value @@ -87,8 +87,8 @@ .. code-block:: C++ - const long unsigned int initialized = 10122004; - + const long unsigned int initialized = 10122004; + GCC-XML 0.9 will report the ``initialized`` value as ``10122004ul``, while GCC-XML 0.7 as ``10122004``. @@ -101,11 +101,11 @@ Both versions of GCC-XML have a few issues, related to default arguments. GCC-XML 0.9 fixes some issues, but introduces another ones. Take a look on next examples: -* +* .. code-block:: C++ void fix_numeric( ull arg=(ull)-1 ); - + GCC-XML 0.7 .. code-block:: XML @@ -119,11 +119,11 @@ <Argument name="arg" type="_103" default="0xffffffffffffffffu"/> -* +* .. code-block:: C++ void fix_function_call( int i=calc( 1,2,3) ); - + GCC-XML 0.7 .. code-block:: XML @@ -137,11 +137,11 @@ <Argument name="i" type="_34" default="function_call::calc(1, 2, 3)"/> -* +* .. code-block:: C++ void typedef__func( const typedef_::alias& position = typedef_::alias() ); - + GCC-XML 0.7 .. code-block:: XML @@ -155,11 +155,11 @@ <Argument name="position" type="_1703" default="typedef_::original_name()"/> -* +* .. code-block:: C++ void typedef__func2( const typedef_::alias& position = alias() ); - + GCC-XML 0.7 .. code-block:: XML @@ -173,12 +173,12 @@ <Argument name="position" type="_1703" default="typedef_::original_name()"/> - -* + +* .. code-block:: C++ node* clone_tree( const std::vector<std::string> &types=std::vector<std::string>() ); - + GCC-XML 0.7 .. code-block:: XML @@ -192,33 +192,59 @@ <Argument name="types" type="_3096" default="std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >(((const std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >&)((const std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)(& std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >()))))"/> +Basically `pygccxml`_ can't help you here. The good news is that you always can +change the default value expression from the script: +.. code-block:: Python + + #f is "calldef_t" instance + for arg in f.arguments: + arg.default_value = <new default value or None> + + ------------- Name mangling ------------- -GCC-XML 0.9 manlges names different than the previous one. +GCC-XML 0.9 mangles names different than the previous one. This change is the most +dramatic one, because it may require from you to change the code. +Consider next C++ code: +.. code-block:: C++ + template< unsigned long i1> + struct item_t{ + static const unsigned long v1 = i1; + }; + struct buggy{ + typedef unsigned long ulong; + typedef item_t< ulong( 0xDEECE66DUL ) | (ulong(0x5) << 32) > my_item_t; + my_item_t my_item_var; + }; +==================== ====================== ======================= + generated data GCC-XML 0.7 GCC-XML 0.9 +==================== ====================== ======================= +class name item_t<0x0deece66d> item_t<-554899859ul> +class mangled name 6item_tILm3740067437EE 6item_tILm3740067437EE +class demangled name item_t<3740067437l> item_t<3740067437ul> +==================== ====================== ======================= +`pygccxml`_ uses class demangled name as a "name" of the class. This was done to +overcome few bugs GCC-XML has, when it works on libraries with extreme usage of +templates. +As you can see the name of the class is different. `pygccxml`_ is unable to help +you in such situations. I suggest you to use query API strict mode. This is the +default one. If the class/declaration with the given name could not be found, it +will raise an error with clear description of the problem. +You can also to print the declarations tree to ``stdout`` and find out the name +of the class/declaration from it. - - - - - - - - - - - .. _`pygccxml`: ./pygccxml.html .. _`Python`: http://www.python.org .. _`GCC-XML`: http://www.gccxml.org Modified: pygccxml_dev/docs/www_configuration.py =================================================================== --- pygccxml_dev/docs/www_configuration.py 2007-12-24 19:17:09 UTC (rev 1209) +++ pygccxml_dev/docs/www_configuration.py 2007-12-24 22:02:36 UTC (rev 1210) @@ -1,3 +1,4 @@ name = 'pygccxml' files_to_skip = ['definition.rest'] -names = { 'query_interface' : 'query interface' } +names = { 'query_interface' : 'query interface' + , 'upgrade_issues' : 'gccxml 0.7 => 0.9 upgrade issues' } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |