Thread: [pygccxml-commit] SF.net SVN: pygccxml:[1783] pyplusplus_dev (Page 4)
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2009-12-24 21:26:17
|
Revision: 1783 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1783&view=rev Author: roman_yakovenko Date: 2009-12-24 21:25:59 +0000 (Thu, 24 Dec 2009) Log Message: ----------- according to MSDN(http://msdn.microsoft.com/en-us/library/s2ff0fz8%28VS.100%29.aspx) conversion constructor is a constructor that could be called with one argument - this change implements this behaviour - small bug fix Modified Paths: -------------- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py pyplusplus_dev/unittests/data/casting_to_be_exported.hpp Modified: pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2009-12-23 21:25:58 UTC (rev 1782) +++ pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2009-12-24 21:25:59 UTC (rev 1783) @@ -348,7 +348,7 @@ return False if self.is_copy_constructor: return False - if 1 != len( self.required_args ): + if not( len( self.arguments) and len( self.required_args ) < 2 ): return False if self.parent.find_out_member_access_type( self ) != declarations.ACCESS_TYPES.PUBLIC: return False Modified: pyplusplus_dev/unittests/data/casting_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/casting_to_be_exported.hpp 2009-12-23 21:25:58 UTC (rev 1782) +++ pyplusplus_dev/unittests/data/casting_to_be_exported.hpp 2009-12-24 21:25:59 UTC (rev 1783) @@ -9,7 +9,7 @@ namespace casting{ struct conversion_constructor_t{ - conversion_constructor_t( int a, int b=0 ) + conversion_constructor_t( int a=2, int b=0 ) : value_a( a* (-1) ), value_b( b * (-1) ) {} int value_a; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-12-26 19:21:59
|
Revision: 1784 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1784&view=rev Author: roman_yakovenko Date: 2009-12-26 19:21:49 +0000 (Sat, 26 Dec 2009) Log Message: ----------- fix ctypes - bit fields code generation Modified Paths: -------------- pyplusplus_dev/docs/history/history.rest pyplusplus_dev/pyplusplus/code_creators/member_variable.py pyplusplus_dev/unittests/ctypes_tester.py pyplusplus_dev/unittests/data/ctypes/variables/variables.cpp pyplusplus_dev/unittests/data/ctypes/variables/variables.h Modified: pyplusplus_dev/docs/history/history.rest =================================================================== --- pyplusplus_dev/docs/history/history.rest 2009-12-24 21:25:59 UTC (rev 1783) +++ pyplusplus_dev/docs/history/history.rest 2009-12-26 19:21:49 UTC (rev 1784) @@ -26,6 +26,7 @@ * Carsten( spom.spom ) * Pertti Kellomäki * Benoît Leveau +* Nikolaus Rath ----------- SVN Version @@ -66,6 +67,8 @@ Many thanks to Benoît Leveau. +10. Numerous bugs in "ctypes code generator" were fixed. Many thanks to Nikolaus Rath. + ----------- Version 1.0 ----------- Modified: pyplusplus_dev/pyplusplus/code_creators/member_variable.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2009-12-24 21:25:59 UTC (rev 1783) +++ pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2009-12-26 19:21:49 UTC (rev 1784) @@ -735,9 +735,14 @@ vars = vars.to_list() vars.sort( key=lambda d: d.location.line ) for v in vars: - result.append( self.indent( '("%(name)s", %(type)s),' - % dict( name=v.alias - ,type=ctypes_formatter.as_ctype( v.type ) ) ) ) + tmp = None + type_as_str = ctypes_formatter.as_ctype( v.type ) + if v.bits != None: + tmp = '("%(name)s", %(type)s, %(bits)d),' \ + % dict( name=v.alias, type=type_as_str, bits=v.bits ) + else: + tmp = '("%(name)s", %(type)s),' % dict( name=v.alias, type=type_as_str ) + result.append( self.indent( tmp ) ) result.append( ']' ) return os.linesep.join( result ) Modified: pyplusplus_dev/unittests/ctypes_tester.py =================================================================== --- pyplusplus_dev/unittests/ctypes_tester.py 2009-12-24 21:25:59 UTC (rev 1783) +++ pyplusplus_dev/unittests/ctypes_tester.py 2009-12-26 19:21:49 UTC (rev 1784) @@ -151,6 +151,8 @@ self.module_ref.init() self.failUnless( self.module_ref.j.value == 87 ) self.failUnless( self.module_ref.data.i == 1900 ) + + self.failUnless( self.module_ref.data.j == 7 ) self.failUnless( self.module_ref.data_ptr.contents.i == 11 ) self.module_ref.j.value = 78 @@ -158,7 +160,13 @@ self.module_ref.data.i = 987 self.failUnless( self.module_ref.get_value_data() == 987 ) + + self.module_ref.data.j = 8 + self.failUnless( self.module_ref.get_value_data_j() == 0 ) + self.module_ref.data.j = 5 + self.failUnless( self.module_ref.get_value_data_j() == 5 ) + self.module_ref.data_ptr.contents.i = 34 self.failUnless( self.module_ref.get_value_data_p() == 34 ) Modified: pyplusplus_dev/unittests/data/ctypes/variables/variables.cpp =================================================================== --- pyplusplus_dev/unittests/data/ctypes/variables/variables.cpp 2009-12-24 21:25:59 UTC (rev 1783) +++ pyplusplus_dev/unittests/data/ctypes/variables/variables.cpp 2009-12-26 19:21:49 UTC (rev 1784) @@ -1,7 +1,8 @@ #include "variables.h" EXPORT_SYMBOL void init(){ - data.i = 1900; + data.i = 1900; + data.j = 7; data_ptr = new data_t(); data_ptr->i = 11; j = 87; @@ -18,5 +19,9 @@ EXPORT_SYMBOL int get_value_data_p(){ return data_ptr->i; } + +EXPORT_SYMBOL int get_value_data_j(){ + return data.j; +} Modified: pyplusplus_dev/unittests/data/ctypes/variables/variables.h =================================================================== --- pyplusplus_dev/unittests/data/ctypes/variables/variables.h 2009-12-24 21:25:59 UTC (rev 1783) +++ pyplusplus_dev/unittests/data/ctypes/variables/variables.h 2009-12-26 19:21:49 UTC (rev 1784) @@ -1,7 +1,8 @@ #include "libconfig.h" struct EXPORT_SYMBOL data_t{ - int i; + int i; + unsigned int j : 3; }; EXPORT_SYMBOL int j; @@ -11,6 +12,7 @@ EXPORT_SYMBOL void init(); EXPORT_SYMBOL int get_value_j(); EXPORT_SYMBOL int get_value_data(); -EXPORT_SYMBOL int get_value_data_p(); +EXPORT_SYMBOL int get_value_data_p(); +EXPORT_SYMBOL int get_value_data_j(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-12-26 20:13:20
|
Revision: 1785 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1785&view=rev Author: roman_yakovenko Date: 2009-12-26 20:13:12 +0000 (Sat, 26 Dec 2009) Log Message: ----------- ctypes code generator created wrong code for callback functions - this commit fixes the issue and introduces the tester Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/ctypes_formatter.py pyplusplus_dev/unittests/ctypes_tester.py pyplusplus_dev/unittests/sconstruct Added Paths: ----------- pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/ pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/binaries/ pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/binaries/ctypes_utils.py pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/binaries/exposed_decl.pypp.txt pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/binaries/function_ptr_as_variable.os pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/binaries/function_ptr_as_variable.py pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/function_ptr_as_variable.cpp pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/function_ptr_as_variable.h pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/sconscript Modified: pyplusplus_dev/pyplusplus/code_creators/ctypes_formatter.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/ctypes_formatter.py 2009-12-26 19:21:49 UTC (rev 1784) +++ pyplusplus_dev/pyplusplus/code_creators/ctypes_formatter.py 2009-12-26 20:13:12 UTC (rev 1785) @@ -93,7 +93,10 @@ else: base_visitor = type_converter_t( self.user_type.base, self.decl_formatter ) internal_type_str = declarations.apply_visitor( base_visitor, base_visitor.user_type ) - return "ctypes.POINTER( %s )" % internal_type_str + if declarations.is_calldef_pointer( self.user_type ): + return internal_type_str + else: + return "ctypes.POINTER( %s )" % internal_type_str def visit_reference( self ): no_ref = declarations.remove_const( declarations.remove_reference( self.user_type ) ) Modified: pyplusplus_dev/unittests/ctypes_tester.py =================================================================== --- pyplusplus_dev/unittests/ctypes_tester.py 2009-12-26 19:21:49 UTC (rev 1784) +++ pyplusplus_dev/unittests/ctypes_tester.py 2009-12-26 20:13:12 UTC (rev 1785) @@ -171,6 +171,22 @@ self.failUnless( self.module_ref.get_value_data_p() == 34 ) +class function_ptr_as_variable_tester_t( ctypes_base_tester_t ): + def __init__( self, *args, **keywd ): + ctypes_base_tester_t.__init__( self, 'function_ptr_as_variable', *args, **keywd ) + + def customize( self, mb ): + mb.global_ns.typedef('do_smth_fun_t').include() + + @staticmethod + def identity(v): + return v + + def test(self): + info = self.module_ref.info() + info.do_smth_fun = self.module_ref.do_smth_fun_t(self.identity) + self.failUnless( 21 == self.module_ref.execute_callback( info, 21 ) ) + class varargs_tester_t( ctypes_base_tester_t ): def __init__( self, *args, **keywd ): ctypes_base_tester_t.__init__( self, 'varargs', *args, **keywd ) @@ -206,6 +222,7 @@ suite.addTest( unittest.makeSuite(variables_tester_t)) suite.addTest( unittest.makeSuite(varargs_tester_t)) suite.addTest( unittest.makeSuite(circular_references_tester_t)) + suite.addTest( unittest.makeSuite(function_ptr_as_variable_tester_t)) return suite def run_suite(): Added: pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/binaries/ctypes_utils.py =================================================================== --- pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/binaries/ctypes_utils.py (rev 0) +++ pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/binaries/ctypes_utils.py 2009-12-26 20:13:12 UTC (rev 1785) @@ -0,0 +1,135 @@ +# This file has been generated by Py++. + +# Copyright 2004-2008 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 ctypes + +# what is the best way to treat overloaded constructors +class native_callable( object ): + def __init__(self, dll, name, restype=None, argtypes=None ): + self.name = name + self.func = getattr( dll, dll.undecorated_names[name] ) + self.func.restype = restype + self.func.argtypes = argtypes + + def __call__(self, *args, **keywd ): + return self.func( *args, **keywd ) + +class native_overloaded_callable( object ): + def __init__(self, functions ): + self.__functions = functions + + def __call__( self, *args ): + types = None + if args: + types = tuple(arg.__class__ for arg in args) + f = self.__functions.get(types) + if f is None: + msg = ['Unable to find a function that match the arguments you passed.'] + msg.append( 'First argument type is "this" type.' ) + msg.append( 'This function call argument types: ' + str( types ) ) + msg.append( 'Registered methods argument types: ' ) + for key in self.__functions.iterkeys(): + msg.append(' ' + str(key)) + raise TypeError(os.linesep.join(msg)) + else: + return f(*args) + +class multi_method_registry_t: + def __init__( self, factory, restype ): + self.factory = factory + self.restype = restype + self.__functions = {} + + def register( self, callable_or_name, argtypes=None ): + if isinstance( callable_or_name, native_callable ): + callable = callable_or_name + else: + name = callable_or_name + callable = self.factory( name, restype=self.restype, argtypes=argtypes ) + self.__functions[ tuple(callable.func.argtypes) ] = callable.func + return self + + def finalize(self): + return native_overloaded_callable( self.__functions ) + + +class mem_fun_factory( object ): + def __init__( self, dll, wrapper, class_name, namespace='' ): + self.dll = dll + self.namespace = namespace + self.class_name = class_name + self.this_type = ctypes.POINTER( wrapper ) + + def __call__( self, name, **keywd ): + if 'argtypes' not in keywd or keywd['argtypes'] is None: + keywd['argtypes'] = [ self.this_type ] + else: + keywd['argtypes'].insert( 0, self.this_type ) + return native_callable( self.dll, name, **keywd ) + + def __get_ns_name(self): + if self.namespace: + return self.namespace + '::' + else: + return '' + + def default_constructor( self ): + return self( '%(ns)s%(class_name)s::%(class_name)s(void)' + % dict( ns=self.__get_ns_name() + , class_name=self.class_name ) ) + + def constructor( self, argtypes_str, **keywd ): + return self( '%(ns)s%(class_name)s::%(class_name)s(%(args)s)' + % dict( ns=self.__get_ns_name() + , class_name=self.class_name + , args=argtypes_str ) + , **keywd ) + + def copy_constructor( self ): + return self( '%(ns)s%(class_name)s::%(class_name)s(%(ns)s%(class_name)s const &)' + % dict( ns=self.__get_ns_name() + , class_name=self.class_name ) + , argtypes=[self.this_type] ) + + def destructor( self, is_virtual=False ): + virtuality = '' + if is_virtual: + virtuality = 'virtual ' + return self( '%(virtuality)s%(ns)s%(class_name)s::~%(class_name)s(void)' + % dict( ns=self.__get_ns_name() + , virtuality=virtuality + , class_name=self.class_name ) ) + + def operator_assign( self ): + return self( '%(ns)s%(class_name)s & %(class_name)s::operator=(%(class_name)s const &)' + % dict( ns=self.__get_ns_name() + , class_name=self.class_name ) + , restype=self.this_type + , argtypes=[self.this_type] ) + + def method( self, name, restype_str=None, argtypes_str=None, **keywd ): + if None is restype_str: + restype_str = 'void' + if None is argtypes_str: + argtypes_str = 'void' + + return self( '%(return_)s %(ns)s%(class_name)s::%(method_name)s(%(args)s)' + % dict( return_=restype_str + , ns=self.__get_ns_name() + , class_name=self.class_name + , method_name=name + , args=argtypes_str ) + , **keywd ) + + def multi_method( self, restype=None ): + return multi_method_registry_t( self, restype ) + + +#take a look on http://code.activestate.com/recipes/413486/ +Enumeration = ctypes.c_int + Added: pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/binaries/exposed_decl.pypp.txt =================================================================== --- pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/binaries/exposed_decl.pypp.txt (rev 0) +++ pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/binaries/exposed_decl.pypp.txt 2009-12-26 20:13:12 UTC (rev 1785) @@ -0,0 +1,429 @@ ++@destructor_t@~info@ ( ::info::* )( ) ( ::info::* )( ) +~@destructor_t@~_IO_marker@ ( ::_IO_marker::* )( ) ( ::_IO_marker::* )( ) +~@destructor_t@~_IO_FILE@ ( ::_IO_FILE::* )( ) ( ::_IO_FILE::* )( ) +~@destructor_t@~._5@ ( ::_IO_cookie_io_functions_t::* )( ) ( ::_IO_cookie_io_functions_t::* )( ) +~@destructor_t@~._4@ ( ::_G_fpos64_t::* )( ) ( ::_G_fpos64_t::* )( ) +~@destructor_t@~._1@ ( ::__mbstate_t::* )( ) ( ::__mbstate_t::* )( ) +~@destructor_t@~._0@ ( ::__fsid_t::* )( ) ( ::__fsid_t::* )( ) +~@destructor_t@~._3@ ( ::_G_fpos_t::* )( ) ( ::_G_fpos_t::* )( ) +~@destructor_t@~._2@ ( ::__mbstate_t::* )( ) ( ::__mbstate_t::* )( ) +~@enumeration_t@__codecvt_result@::__codecvt_result +~@typedef_t@__uint16_t@::__uint16_t +~@typedef_t@cookie_close_function_t@::cookie_close_function_t +~@typedef_t@__uint64_t@::__uint64_t +~@typedef_t@__int16_t@::__int16_t +~@typedef_t@__ssize_t@::__ssize_t +~@typedef_t@__io_close_fn@::__io_close_fn +~@typedef_t@__mode_t@::__mode_t +~@typedef_t@__off64_t@::__off64_t +~@typedef_t@__u_char@::__u_char +~@typedef_t@_G_uint32_t@::_G_uint32_t +~@typedef_t@size_t@::size_t +~@typedef_t@__blksize_t@::__blksize_t +~@typedef_t@__u_long@::__u_long +~@typedef_t@__swblk_t@::__swblk_t +~@typedef_t@FILE@::FILE +~@typedef_t@__off_t@::__off_t +~@typedef_t@__fsblkcnt_t@::__fsblkcnt_t +~@typedef_t@__rlim_t@::__rlim_t +~@typedef_t@__fsfilcnt_t@::__fsfilcnt_t +~@typedef_t@__id_t@::__id_t +~@typedef_t@cookie_io_functions_t@::cookie_io_functions_t +~@typedef_t@__gid_t@::__gid_t +~@typedef_t@__clockid_t@::__clockid_t +~@typedef_t@__uint32_t@::__uint32_t +~@typedef_t@__useconds_t@::__useconds_t +~@typedef_t@__uint8_t@::__uint8_t +~@typedef_t@fpos_t@::fpos_t ++@typedef_t@do_smth_fun_t@::do_smth_fun_t +~@typedef_t@__io_read_fn@::__io_read_fn +~@typedef_t@__int32_t@::__int32_t +~@typedef_t@__daddr_t@::__daddr_t +~@typedef_t@__u_quad_t@::__u_quad_t +~@typedef_t@__u_short@::__u_short +~@typedef_t@__ino64_t@::__ino64_t +~@typedef_t@_G_int16_t@::_G_int16_t +~@typedef_t@va_list@::va_list +~@typedef_t@__loff_t@::__loff_t +~@typedef_t@__pid_t@::__pid_t +~@typedef_t@__FILE@::__FILE +~@typedef_t@__int64_t@::__int64_t +~@typedef_t@__io_seek_fn@::__io_seek_fn +~@typedef_t@__io_write_fn@::__io_write_fn +~@typedef_t@_G_uint16_t@::_G_uint16_t +~@typedef_t@__fsblkcnt64_t@::__fsblkcnt64_t +~@typedef_t@cookie_seek_function_t@::cookie_seek_function_t +~@typedef_t@__nlink_t@::__nlink_t +~@typedef_t@fpos64_t@::fpos64_t +~@typedef_t@__ino_t@::__ino_t +~@typedef_t@__dev_t@::__dev_t +~@typedef_t@cookie_write_function_t@::cookie_write_function_t +~@typedef_t@_IO_lock_t@::_IO_lock_t +~@typedef_t@__intptr_t@::__intptr_t +~@typedef_t@__time_t@::__time_t +~@typedef_t@__qaddr_t@::__qaddr_t +~@typedef_t@__caddr_t@::__caddr_t +~@typedef_t@__suseconds_t@::__suseconds_t +~@typedef_t@__clock_t@::__clock_t +~@typedef_t@__socklen_t@::__socklen_t +~@typedef_t@__u_int@::__u_int +~@typedef_t@__blkcnt_t@::__blkcnt_t +~@typedef_t@__fsfilcnt64_t@::__fsfilcnt64_t +~@typedef_t@__quad_t@::__quad_t +~@typedef_t@__blkcnt64_t@::__blkcnt64_t +~@typedef_t@__key_t@::__key_t +~@typedef_t@cookie_read_function_t@::cookie_read_function_t +~@typedef_t@_G_int32_t@::_G_int32_t +~@typedef_t@__gnuc_va_list@::__gnuc_va_list +~@typedef_t@__uid_t@::__uid_t +~@typedef_t@__rlim64_t@::__rlim64_t +~@typedef_t@__int8_t@::__int8_t +~@typedef_t@__timer_t@::__timer_t +~@namespace_t@std@::std +~@namespace_t@__cxxabiv1@::__cxxabiv1 +~@class_declaration_t@_IO_jump_t@::_IO_jump_t +~@class_declaration_t@obstack@::obstack +~@class_declaration_t@_IO_FILE_plus@::_IO_FILE_plus +~@class_declaration_t@_IO_cookie_file@::_IO_cookie_file +~@variable_t@_flags2@::_IO_FILE::_flags2 +~@variable_t@_vtable_offset@::_IO_FILE::_vtable_offset +~@variable_t@stdout@::stdout +~@variable_t@_IO_read_end@::_IO_FILE::_IO_read_end +~@variable_t@_unused2@::_IO_FILE::_unused2 +~@variable_t@_old_offset@::_IO_FILE::_old_offset +~@variable_t@_pos@::_IO_marker::_pos +~@variable_t@_IO_buf_end@::_IO_FILE::_IO_buf_end +~@variable_t@__pos@::_G_fpos_t::__pos +~@variable_t@__pos@::_G_fpos64_t::__pos +~@variable_t@_next@::_IO_marker::_next +~@variable_t@_mode@::_IO_FILE::_mode +~@variable_t@sys_nerr@::sys_nerr +~@variable_t@close@::_IO_cookie_io_functions_t::close +~@variable_t@_IO_save_base@::_IO_FILE::_IO_save_base +~@variable_t@_IO_read_base@::_IO_FILE::_IO_read_base +~@variable_t@seek@::_IO_cookie_io_functions_t::seek +~@variable_t@__state@::_G_fpos_t::__state +~@variable_t@__state@::_G_fpos64_t::__state +~@variable_t@sys_errlist@::sys_errlist +~@variable_t@_lock@::_IO_FILE::_lock +~@variable_t@_shortbuf@::_IO_FILE::_shortbuf +~@variable_t@_IO_2_1_stdin_@::_IO_2_1_stdin_ +~@variable_t@_sys_errlist@::_sys_errlist +~@variable_t@_IO_backup_base@::_IO_FILE::_IO_backup_base +~@variable_t@_chain@::_IO_FILE::_chain +~@variable_t@_IO_write_ptr@::_IO_FILE::_IO_write_ptr +~@variable_t@write@::_IO_cookie_io_functions_t::write +~@variable_t@_sys_nerr@::_sys_nerr ++@variable_t@do_smth_fun@::info::do_smth_fun +~@variable_t@_fileno@::_IO_FILE::_fileno +~@variable_t@__pad5@::_IO_FILE::__pad5 +~@variable_t@_flags@::_IO_FILE::_flags +~@variable_t@__wch@::__mbstate_t::__wch +~@variable_t@__pad4@::_IO_FILE::__pad4 +~@variable_t@_sbuf@::_IO_marker::_sbuf +~@variable_t@read@::_IO_cookie_io_functions_t::read +~@variable_t@__wchb@::__mbstate_t::__wchb +~@variable_t@_IO_write_end@::_IO_FILE::_IO_write_end +~@variable_t@_IO_2_1_stderr_@::_IO_2_1_stderr_ +~@variable_t@_IO_2_1_stdout_@::_IO_2_1_stdout_ +~@variable_t@__val@::__fsid_t::__val +~@variable_t@_cur_column@::_IO_FILE::_cur_column +~@variable_t@__count@::__mbstate_t::__count +~@variable_t@_IO_write_base@::_IO_FILE::_IO_write_base +~@variable_t@_IO_save_end@::_IO_FILE::_IO_save_end +~@variable_t@__pad1@::_IO_FILE::__pad1 +~@variable_t@_offset@::_IO_FILE::_offset +~@variable_t@__pad3@::_IO_FILE::__pad3 +~@variable_t@__pad2@::_IO_FILE::__pad2 +~@variable_t@_markers@::_IO_FILE::_markers +~@variable_t@_IO_read_ptr@::_IO_FILE::_IO_read_ptr +~@variable_t@stderr@::stderr +~@variable_t@__value@::__mbstate_t::__value +~@variable_t@stdin@::stdin +~@variable_t@_IO_buf_base@::_IO_FILE::_IO_buf_base ++@class_t@info@::info +~@class_t@__mbstate_t@::__mbstate_t +~@class_t@_G_fpos64_t@::_G_fpos64_t +~@class_t@_IO_cookie_io_functions_t@::_IO_cookie_io_functions_t +~@class_t@_IO_marker@::_IO_marker +~@class_t@_IO_FILE@::_IO_FILE +~@class_t@__fsid_t@::__fsid_t +~@class_t@('/usr/include/wchar.h', 87)@::__mbstate_t +~@class_t@_G_fpos_t@::_G_fpos_t ++@constructor_t@info@ ( ::info::* )( ::info const & ) ( ::info::* )( ::info const & ) ++@constructor_t@info@ ( ::info::* )( ) ( ::info::* )( ) +~@constructor_t@__mbstate_t@ ( ::__mbstate_t::* )( ::__mbstate_t const & ) ( ::__mbstate_t::* )( ::__mbstate_t const & ) +~@constructor_t@__mbstate_t@ ( ::__mbstate_t::* )( ) ( ::__mbstate_t::* )( ) +~@constructor_t@_G_fpos64_t@ ( ::_G_fpos64_t::* )( ::_G_fpos64_t const & ) ( ::_G_fpos64_t::* )( ::_G_fpos64_t const & ) +~@constructor_t@_G_fpos64_t@ ( ::_G_fpos64_t::* )( ) ( ::_G_fpos64_t::* )( ) +~@constructor_t@_IO_cookie_io_functions_t@ ( ::_IO_cookie_io_functions_t::* )( ::_IO_cookie_io_functions_t const & ) ( ::_IO_cookie_io_functions_t::* )( ::_IO_cookie_io_functions_t const & ) +~@constructor_t@_IO_cookie_io_functions_t@ ( ::_IO_cookie_io_functions_t::* )( ) ( ::_IO_cookie_io_functions_t::* )( ) +~@constructor_t@_IO_marker@ ( ::_IO_marker::* )( ::_IO_marker const & ) ( ::_IO_marker::* )( ::_IO_marker const & ) +~@constructor_t@_IO_marker@ ( ::_IO_marker::* )( ) ( ::_IO_marker::* )( ) +~@constructor_t@_IO_FILE@ ( ::_IO_FILE::* )( ::_IO_FILE const & ) ( ::_IO_FILE::* )( ::_IO_FILE const & ) +~@constructor_t@_IO_FILE@ ( ::_IO_FILE::* )( ) ( ::_IO_FILE::* )( ) +~@constructor_t@__fsid_t@ ( ::__fsid_t::* )( ::__fsid_t const & ) ( ::__fsid_t::* )( ::__fsid_t const & ) +~@constructor_t@__fsid_t@ ( ::__fsid_t::* )( ) ( ::__fsid_t::* )( ) +~@constructor_t@('/usr/include/wchar.h', 87)@ ( ::__mbstate_t::* )( ::__mbstate_t const & ) ( ::__mbstate_t::* )( ::__mbstate_t const & ) +~@constructor_t@('/usr/include/wchar.h', 87)@ ( ::__mbstate_t::* )( ) ( ::__mbstate_t::* )( ) +~@constructor_t@_G_fpos_t@ ( ::_G_fpos_t::* )( ::_G_fpos_t const & ) ( ::_G_fpos_t::* )( ::_G_fpos_t const & ) +~@constructor_t@_G_fpos_t@ ( ::_G_fpos_t::* )( ) ( ::_G_fpos_t::* )( ) +~@member_operator_t@operator=@::_IO_cookie_io_functions_t & ( ::_IO_cookie_io_functions_t::* )( ::_IO_cookie_io_functions_t const & ) ::_IO_cookie_io_functions_t & ( ::_IO_cookie_io_functions_t::* )( ::_IO_cookie_io_functions_t const & ) +~@member_operator_t@operator=@::_IO_FILE & ( ::_IO_FILE::* )( ::_IO_FILE const & ) ::_IO_FILE & ( ::_IO_FILE::* )( ::_IO_FILE const & ) +~@member_operator_t@operator=@::_G_fpos_t & ( ::_G_fpos_t::* )( ::_G_fpos_t const & ) ::_G_fpos_t & ( ::_G_fpos_t::* )( ::_G_fpos_t const & ) ++@member_operator_t@operator=@::info & ( ::info::* )( ::info const & ) ::info & ( ::info::* )( ::info const & ) +~@member_operator_t@operator=@::_G_fpos64_t & ( ::_G_fpos64_t::* )( ::_G_fpos64_t const & ) ::_G_fpos64_t & ( ::_G_fpos64_t::* )( ::_G_fpos64_t const & ) +~@member_operator_t@operator=@::__mbstate_t & ( ::__mbstate_t::* )( ::__mbstate_t const & ) ::__mbstate_t & ( ::__mbstate_t::* )( ::__mbstate_t const & ) +~@member_operator_t@operator=@::__mbstate_t & ( ::__mbstate_t::* )( ::__mbstate_t const & ) ::__mbstate_t & ( ::__mbstate_t::* )( ::__mbstate_t const & ) +~@member_operator_t@operator=@::__fsid_t & ( ::__fsid_t::* )( ::__fsid_t const & ) ::__fsid_t & ( ::__fsid_t::* )( ::__fsid_t const & ) +~@member_operator_t@operator=@::_IO_marker & ( ::_IO_marker::* )( ::_IO_marker const & ) ::_IO_marker & ( ::_IO_marker::* )( ::_IO_marker const & ) +~@free_function_t@__builtin_ldexpf@float (*)( float,int )float (*)( float,int ) +~@free_function_t@obstack_vprintf@int (*)( __restrict__ ::obstack *,__restrict__ char const *,::__gnuc_va_list )int (*)( __restrict__ ::obstack *,__restrict__ char const *,::__gnuc_va_list ) +~@free_function_t@__builtin_tanhf@float (*)( float )float (*)( float ) +~@free_function_t@__builtin_ldexpl@long double (*)( long double,int )long double (*)( long double,int ) +~@free_function_t@_IO_putc@int (*)( int,::_IO_FILE * )int (*)( int,::_IO_FILE * ) +~@free_function_t@__builtin_inf@double (*)( )double (*)( ) +~@free_function_t@__builtin_prefetch@void (*)( void const *,... )void (*)( void const *,... ) +~@free_function_t@__builtin_popcount@int (*)( int )int (*)( int ) +~@free_function_t@__builtin_expf@float (*)( float )float (*)( float ) +~@free_function_t@__builtin_islessgreater@bool (*)( ... )bool (*)( ... ) +~@free_function_t@fseeko64@int (*)( ::FILE *,::__off64_t,int )int (*)( ::FILE *,::__off64_t,int ) +~@free_function_t@__builtin_cargf@float (*)( complex float )float (*)( complex float ) +~@free_function_t@__builtin_cpowl@complex long double (*)( complex long double,complex long double )complex long double (*)( complex long double,complex long double ) +~@free_function_t@fflush@int (*)( ::FILE * )int (*)( ::FILE * ) +~@free_function_t@__builtin_expl@long double (*)( long double )long double (*)( long double ) +~@free_function_t@fputc@int (*)( int,::FILE * )int (*)( int,::FILE * ) +~@free_function_t@__underflow@int (*)( ::_IO_FILE * )int (*)( ::_IO_FILE * ) +~@free_function_t@fwrite@::size_t (*)( __restrict__ void const *,::size_t,::size_t,__restrict__ ::FILE * )::size_t (*)( __restrict__ void const *,::size_t,::size_t,__restrict__ ::FILE * ) +~@free_function_t@fflush_unlocked@int (*)( ::FILE * )int (*)( ::FILE * ) +~@free_function_t@__builtin_log10@double (*)( double )double (*)( double ) +~@free_function_t@_IO_cookie_init@void (*)( ::_IO_cookie_file *,int,void *,::_IO_cookie_io_functions_t )void (*)( ::_IO_cookie_file *,int,void *,::_IO_cookie_io_functions_t ) +~@free_function_t@fputs@int (*)( __restrict__ char const *,__restrict__ ::FILE * )int (*)( __restrict__ char const *,__restrict__ ::FILE * ) +~@free_function_t@__builtin_exp@double (*)( double )double (*)( double ) +~@free_function_t@tmpnam@char * (*)( char * )char * (*)( char * ) +~@free_function_t@feof_unlocked@int (*)( ::FILE * )int (*)( ::FILE * ) +~@free_function_t@__builtin_popcountll@int (*)( long long int )int (*)( long long int ) +~@free_function_t@getline@::__ssize_t (*)( __restrict__ char * *,__restrict__ ::size_t *,__restrict__ ::FILE * )::__ssize_t (*)( __restrict__ char * *,__restrict__ ::size_t *,__restrict__ ::FILE * ) +~@free_function_t@_IO_padn@::__ssize_t (*)( ::_IO_FILE *,int,::__ssize_t )::__ssize_t (*)( ::_IO_FILE *,int,::__ssize_t ) +~@free_function_t@__builtin_csinh@complex double (*)( complex double )complex double (*)( complex double ) +~@free_function_t@__builtin_acosf@float (*)( float )float (*)( float ) +~@free_function_t@__builtin_csin@complex double (*)( complex double )complex double (*)( complex double ) +~@free_function_t@__builtin_csinl@complex long double (*)( complex long double )complex long double (*)( complex long double ) +~@free_function_t@__builtin_acos@double (*)( double )double (*)( double ) +~@free_function_t@__builtin_ccosl@complex long double (*)( complex long double )complex long double (*)( complex long double ) +~@free_function_t@getc_unlocked@int (*)( ::FILE * )int (*)( ::FILE * ) +~@free_function_t@_IO_sgetn@::size_t (*)( ::_IO_FILE *,void *,::size_t )::size_t (*)( ::_IO_FILE *,void *,::size_t ) +~@free_function_t@__builtin_acosl@long double (*)( long double )long double (*)( long double ) +~@free_function_t@__builtin_csinf@complex float (*)( complex float )complex float (*)( complex float ) +~@free_function_t@_IO_ftrylockfile@int (*)( ::_IO_FILE * )int (*)( ::_IO_FILE * ) +~@free_function_t@__builtin_frame_address@void * (*)( unsigned int )void * (*)( unsigned int ) +~@free_function_t@__builtin_cpowf@complex float (*)( complex float,complex float )complex float (*)( complex float,complex float ) +~@free_function_t@__builtin_ctzll@int (*)( long long int )int (*)( long long int ) +~@free_function_t@renameat@int (*)( int,char const *,int,char const * )int (*)( int,char const *,int,char const * ) +~@free_function_t@fileno@int (*)( ::FILE * )int (*)( ::FILE * ) +~@free_function_t@gets@char * (*)( char * )char * (*)( char * ) +~@free_function_t@perror@void (*)( char const * )void (*)( char const * ) +~@free_function_t@__builtin_tanf@float (*)( float )float (*)( float ) +~@free_function_t@__builtin_tanh@double (*)( double )double (*)( double ) +~@free_function_t@freopen64@::FILE * (*)( __restrict__ char const *,__restrict__ char const *,__restrict__ ::FILE * )::FILE * (*)( __restrict__ char const *,__restrict__ char const *,__restrict__ ::FILE * ) +~@free_function_t@remove@int (*)( char const * )int (*)( char const * ) +~@free_function_t@__builtin_tanl@long double (*)( long double )long double (*)( long double ) +~@free_function_t@__builtin_modff@float (*)( float,float * )float (*)( float,float * ) +~@free_function_t@__builtin_clogf@complex float (*)( complex float )complex float (*)( complex float ) +~@free_function_t@_IO_vfprintf@int (*)( __restrict__ ::_IO_FILE *,__restrict__ char const *,::__gnuc_va_list )int (*)( __restrict__ ::_IO_FILE *,__restrict__ char const *,::__gnuc_va_list ) +~@free_function_t@freopen@::FILE * (*)( __restrict__ char const *,__restrict__ char const *,__restrict__ ::FILE * )::FILE * (*)( __restrict__ char const *,__restrict__ char const *,__restrict__ ::FILE * ) +~@free_function_t@__builtin_clogl@complex long double (*)( complex long double )complex long double (*)( complex long double ) ++@free_function_t@execute_callback@int (*)( ::info *,int )int (*)( ::info *,int ) +~@free_function_t@__builtin_modfl@long double (*)( long double,long double * )long double (*)( long double,long double * ) +~@free_function_t@fread_unlocked@::size_t (*)( __restrict__ void *,::size_t,::size_t,__restrict__ ::FILE * )::size_t (*)( __restrict__ void *,::size_t,::size_t,__restrict__ ::FILE * ) +~@free_function_t@__builtin_atan@double (*)( double )double (*)( double ) +~@free_function_t@__builtin_sqrt@double (*)( double )double (*)( double ) +~@free_function_t@__builtin_isunordered@bool (*)( ... )bool (*)( ... ) +~@free_function_t@tempnam@char * (*)( char const *,char const * )char * (*)( char const *,char const * ) +~@free_function_t@tmpfile@::FILE * (*)( )::FILE * (*)( ) +~@free_function_t@vsscanf@int (*)( __restrict__ char const *,__restrict__ char const *,::__gnuc_va_list )int (*)( __restrict__ char const *,__restrict__ char const *,::__gnuc_va_list ) +~@free_function_t@__builtin_ctanhf@complex float (*)( complex float )complex float (*)( complex float ) +~@free_function_t@__builtin_fabsf@float (*)( float )float (*)( float ) +~@free_function_t@snprintf@int (*)( __restrict__ char *,::size_t,__restrict__ char const *,... )int (*)( __restrict__ char *,::size_t,__restrict__ char const *,... ) +~@free_function_t@__builtin_csqrtl@complex long double (*)( complex long double )complex long double (*)( complex long double ) +~@free_function_t@fgetc@int (*)( ::FILE * )int (*)( ::FILE * ) +~@free_function_t@pclose@int (*)( ::FILE * )int (*)( ::FILE * ) +~@free_function_t@__builtin_ctzl@int (*)( long int )int (*)( long int ) +~@free_function_t@__builtin_ceill@long double (*)( long double )long double (*)( long double ) +~@free_function_t@__builtin_ctanhl@complex long double (*)( complex long double )complex long double (*)( complex long double ) +~@free_function_t@__builtin_fabsl@long double (*)( long double )long double (*)( long double ) +~@free_function_t@__builtin_cargl@long double (*)( complex long double )long double (*)( complex long double ) +~@free_function_t@fileno_unlocked@int (*)( ::FILE * )int (*)( ::FILE * ) +~@free_function_t@fgets_unlocked@char * (*)( __restrict__ char *,int,__restrict__ ::FILE * )char * (*)( __restrict__ char *,int,__restrict__ ::FILE * ) +~@free_function_t@fgets@char * (*)( __restrict__ char *,int,__restrict__ ::FILE * )char * (*)( __restrict__ char *,int,__restrict__ ::FILE * ) +~@free_function_t@ctermid@char * (*)( char * )char * (*)( char * ) +~@free_function_t@__builtin_sinf@float (*)( float )float (*)( float ) +~@free_function_t@__builtin_inff@float (*)( )float (*)( ) +~@free_function_t@_IO_feof@int (*)( ::_IO_FILE * )int (*)( ::_IO_FILE * ) +~@free_function_t@getchar_unlocked@int (*)( )int (*)( ) +~@free_function_t@__builtin_atan2l@long double (*)( long double,long double )long double (*)( long double,long double ) +~@free_function_t@fgetc_unlocked@int (*)( ::FILE * )int (*)( ::FILE * ) +~@free_function_t@__builtin_fabs@double (*)( double )double (*)( double ) +~@free_function_t@fgetpos@int (*)( __restrict__ ::FILE *,__restrict__ ::fpos_t * )int (*)( __restrict__ ::FILE *,__restrict__ ::fpos_t * ) +~@free_function_t@__builtin_atan2f@float (*)( float,float )float (*)( float,float ) +~@free_function_t@__builtin_isfinite@bool (*)( ... )bool (*)( ... ) +~@free_function_t@__builtin_sinh@double (*)( double )double (*)( double ) +~@free_function_t@fsetpos@int (*)( ::FILE *,::fpos_t const * )int (*)( ::FILE *,::fpos_t const * ) +~@free_function_t@ftell@long int (*)( ::FILE * )long int (*)( ::FILE * ) +~@free_function_t@__builtin_floor@double (*)( double )double (*)( double ) +~@free_function_t@sprintf@int (*)( __restrict__ char *,__restrict__ char const *,... )int (*)( __restrict__ char *,__restrict__ char const *,... ) +~@free_function_t@__builtin_cabsl@long double (*)( complex long double )long double (*)( complex long double ) +~@free_function_t@vscanf@int (*)( __restrict__ char const *,::__gnuc_va_list )int (*)( __restrict__ char const *,::__gnuc_va_list ) +~@free_function_t@__builtin_popcountl@int (*)( long int )int (*)( long int ) +~@free_function_t@__builtin_cabsf@float (*)( complex float )float (*)( complex float ) +~@free_function_t@ferror_unlocked@int (*)( ::FILE * )int (*)( ::FILE * ) +~@free_function_t@fgetpos64@int (*)( __restrict__ ::FILE *,__restrict__ ::fpos64_t * )int (*)( __restrict__ ::FILE *,__restrict__ ::fpos64_t * ) +~@free_function_t@__getdelim@::__ssize_t (*)( __restrict__ char * *,__restrict__ ::size_t *,int,__restrict__ ::FILE * )::__ssize_t (*)( __restrict__ char * *,__restrict__ ::size_t *,int,__restrict__ ::FILE * ) +~@free_function_t@__overflow@int (*)( ::_IO_FILE *,int )int (*)( ::_IO_FILE *,int ) +~@free_function_t@asprintf@int (*)( __restrict__ char * *,__restrict__ char const *,... )int (*)( __restrict__ char * *,__restrict__ char const *,... ) +~@free_function_t@ferror@int (*)( ::FILE * )int (*)( ::FILE * ) +~@free_function_t@__builtin_csqrtf@complex float (*)( complex float )complex float (*)( complex float ) +~@free_function_t@__builtin_csinhl@complex long double (*)( complex long double )complex long double (*)( complex long double ) +~@free_function_t@open_memstream@::FILE * (*)( char * *,::size_t * )::FILE * (*)( char * *,::size_t * ) +~@free_function_t@__builtin_coshf@float (*)( float )float (*)( float ) +~@free_function_t@fsetpos64@int (*)( ::FILE *,::fpos64_t const * )int (*)( ::FILE *,::fpos64_t const * ) +~@free_function_t@__builtin_ccos@complex double (*)( complex double )complex double (*)( complex double ) +~@free_function_t@__builtin_ccosh@complex double (*)( complex double )complex double (*)( complex double ) +~@free_function_t@__builtin_csinhf@complex float (*)( complex float )complex float (*)( complex float ) +~@free_function_t@__builtin_coshl@long double (*)( long double )long double (*)( long double ) +~@free_function_t@tmpnam_r@char * (*)( char * )char * (*)( char * ) +~@free_function_t@_IO_seekpos@::__off64_t (*)( ::_IO_FILE *,::__off64_t,int )::__off64_t (*)( ::_IO_FILE *,::__off64_t,int ) +~@free_function_t@fseeko@int (*)( ::FILE *,::__off_t,int )int (*)( ::FILE *,::__off_t,int ) +~@free_function_t@putchar@int (*)( int )int (*)( int ) +~@free_function_t@__builtin_isinf@bool (*)( ... )bool (*)( ... ) +~@free_function_t@__builtin_ctz@int (*)( int )int (*)( int ) +~@free_function_t@__builtin_powi@double (*)( double,int )double (*)( double,int ) +~@free_function_t@fseek@int (*)( ::FILE *,long int,int )int (*)( ::FILE *,long int,int ) +~@free_function_t@__builtin_powl@long double (*)( long double,long double )long double (*)( long double,long double ) +~@free_function_t@__builtin_csqrt@complex double (*)( complex double )complex double (*)( complex double ) +~@free_function_t@__builtin_cexpl@complex long double (*)( complex long double )complex long double (*)( complex long double ) +~@free_function_t@_IO_ferror@int (*)( ::_IO_FILE * )int (*)( ::_IO_FILE * ) +~@free_function_t@fputc_unlocked@int (*)( int,::FILE * )int (*)( int,::FILE * ) +~@free_function_t@clearerr_unlocked@void (*)( ::FILE * )void (*)( ::FILE * ) +~@free_function_t@__builtin_cexpf@complex float (*)( complex float )complex float (*)( complex float ) +~@free_function_t@_IO_peekc_locked@int (*)( ::_IO_FILE * )int (*)( ::_IO_FILE * ) +~@free_function_t@scanf@int (*)( __restrict__ char const *,... )int (*)( __restrict__ char const *,... ) +~@free_function_t@__builtin_asinf@float (*)( float )float (*)( float ) +~@free_function_t@_IO_flockfile@void (*)( ::_IO_FILE * )void (*)( ::_IO_FILE * ) +~@free_function_t@__builtin_cpow@complex double (*)( complex double,complex double )complex double (*)( complex double,complex double ) +~@free_function_t@fcloseall@int (*)( )int (*)( ) +~@free_function_t@obstack_printf@int (*)( __restrict__ ::obstack *,__restrict__ char const *,... )int (*)( __restrict__ ::obstack *,__restrict__ char const *,... ) +~@free_function_t@__builtin_cexp@complex double (*)( complex double )complex double (*)( complex double ) +~@free_function_t@__builtin_cabs@double (*)( complex double )double (*)( complex double ) +~@free_function_t@__builtin_asinl@long double (*)( long double )long double (*)( long double ) +~@free_function_t@getdelim@::__ssize_t (*)( __restrict__ char * *,__restrict__ ::size_t *,int,__restrict__ ::FILE * )::__ssize_t (*)( __restrict__ char * *,__restrict__ ::size_t *,int,__restrict__ ::FILE * ) +~@free_function_t@__builtin_ctanl@complex long double (*)( complex long double )complex long double (*)( complex long double ) +~@free_function_t@__builtin_atan2@double (*)( double,double )double (*)( double,double ) +~@free_function_t@__builtin_frexpf@float (*)( float,int * )float (*)( float,int * ) +~@free_function_t@__uflow@int (*)( ::_IO_FILE * )int (*)( ::_IO_FILE * ) +~@free_function_t@tmpfile64@::FILE * (*)( )::FILE * (*)( ) +~@free_function_t@printf@int (*)( __restrict__ char const *,... )int (*)( __restrict__ char const *,... ) +~@free_function_t@fmemopen@::FILE * (*)( void *,::size_t,char const * )::FILE * (*)( void *,::size_t,char const * ) +~@free_function_t@fopen@::FILE * (*)( __restrict__ char const *,__restrict__ char const * )::FILE * (*)( __restrict__ char const *,__restrict__ char const * ) +~@free_function_t@getchar@int (*)( )int (*)( ) +~@free_function_t@putw@int (*)( int,::FILE * )int (*)( int,::FILE * ) +~@free_function_t@__builtin_expect@long int (*)( long int,long int )long int (*)( long int,long int ) +~@free_function_t@puts@int (*)( char const * )int (*)( char const * ) +~@free_function_t@__builtin_ctanf@complex float (*)( complex float )complex float (*)( complex float ) +~@free_function_t@fdopen@::FILE * (*)( int,char const * )::FILE * (*)( int,char const * ) +~@free_function_t@__builtin_ctanh@complex double (*)( complex double )complex double (*)( complex double ) +~@free_function_t@__builtin_islessequal@bool (*)( ... )bool (*)( ... ) +~@free_function_t@__builtin_carg@double (*)( complex double )double (*)( complex double ) +~@free_function_t@__builtin_memchr@void * (*)( void const *,int,unsigned int )void * (*)( void const *,int,unsigned int ) +~@free_function_t@__builtin_sqrtl@long double (*)( long double )long double (*)( long double ) +~@free_function_t@fclose@int (*)( ::FILE * )int (*)( ::FILE * ) +~@free_function_t@__builtin_nans@double (*)( char const * )double (*)( char const * ) +~@free_function_t@__builtin_frexpl@long double (*)( long double,int * )long double (*)( long double,int * ) +~@free_function_t@__asprintf@int (*)( __restrict__ char * *,__restrict__ char const *,... )int (*)( __restrict__ char * *,__restrict__ char const *,... ) +~@free_function_t@dprintf@int (*)( int,__restrict__ char const *,... )int (*)( int,__restrict__ char const *,... ) +~@free_function_t@__builtin_isnormal@bool (*)( ... )bool (*)( ... ) +~@free_function_t@__builtin_floorf@float (*)( float )float (*)( float ) +~@free_function_t@ftello64@::__off64_t (*)( ::FILE * )::__off64_t (*)( ::FILE * ) +~@free_function_t@__builtin_atanf@float (*)( float )float (*)( float ) +~@free_function_t@__builtin_clog@complex double (*)( complex double )complex double (*)( complex double ) +~@free_function_t@__builtin_floorl@long double (*)( long double )long double (*)( long double ) +~@free_function_t@__builtin_return@void (*)( void * )void (*)( void * ) +~@free_function_t@__builtin_powil@long double (*)( long double,int )long double (*)( long double,int ) +~@free_function_t@setlinebuf@void (*)( ::FILE * )void (*)( ::FILE * ) +~@free_function_t@__builtin_log@double (*)( double )double (*)( double ) +~@free_function_t@__builtin_atanl@long double (*)( long double )long double (*)( long double ) +~@free_function_t@__builtin_log10l@long double (*)( long double )long double (*)( long double ) +~@free_function_t@__builtin_sqrtf@float (*)( float )float (*)( float ) +~@free_function_t@__builtin_powf@float (*)( float,float )float (*)( float,float ) +~@free_function_t@__builtin_tanhl@long double (*)( long double )long double (*)( long double ) +~@free_function_t@__builtin_log10f@float (*)( float )float (*)( float ) +~@free_function_t@__builtin_tan@double (*)( double )double (*)( double ) +~@free_function_t@fopencookie@::FILE * (*)( __restrict__ void *,__restrict__ char const *,::_IO_cookie_io_functions_t )::FILE * (*)( __restrict__ void *,__restrict__ char const *,::_IO_cookie_io_functions_t ) +~@free_function_t@__builtin_infl@long double (*)( )long double (*)( ) +~@free_function_t@fscanf@int (*)( __restrict__ ::FILE *,__restrict__ char const *,... )int (*)( __restrict__ ::FILE *,__restrict__ char const *,... ) +~@free_function_t@__builtin_frexp@double (*)( double,int * )double (*)( double,int * ) +~@free_function_t@ftrylockfile@int (*)( ::FILE * )int (*)( ::FILE * ) +~@free_function_t@cuserid@char * (*)( char * )char * (*)( char * ) +~@free_function_t@__builtin_ldexp@double (*)( double,int )double (*)( double,int ) +~@free_function_t@setbuffer@void (*)( __restrict__ ::FILE *,__restrict__ char *,::size_t )void (*)( __restrict__ ::FILE *,__restrict__ char *,::size_t ) +~@free_function_t@_IO_vfscanf@int (*)( __restrict__ ::_IO_FILE *,__restrict__ char const *,::__gnuc_va_list,__restrict__ int * )int (*)( __restrict__ ::_IO_FILE *,__restrict__ char const *,::__gnuc_va_list,__restrict__ int * ) +~@free_function_t@ungetc@int (*)( int,::FILE * )int (*)( int,::FILE * ) +~@free_function_t@fprintf@int (*)( __restrict__ ::FILE *,__restrict__ char const *,... )int (*)( __restrict__ ::FILE *,__restrict__ char const *,... ) +~@free_function_t@vsprintf@int (*)( __restrict__ char *,__restrict__ char const *,::__gnuc_va_list )int (*)( __restrict__ char *,__restrict__ char const *,::__gnuc_va_list ) +~@free_function_t@rename@int (*)( char const *,char const * )int (*)( char const *,char const * ) +~@free_function_t@vsnprintf@int (*)( __restrict__ char *,::size_t,__restrict__ char const *,::__gnuc_va_list )int (*)( __restrict__ char *,::size_t,__restrict__ char const *,::__gnuc_va_list ) +~@free_function_t@__builtin_sinhl@long double (*)( long double )long double (*)( long double ) +~@free_function_t@sscanf@int (*)( __restrict__ char const *,__restrict__ char const *,... )int (*)( __restrict__ char const *,__restrict__ char const *,... ) +~@free_function_t@__builtin_powif@float (*)( float,int )float (*)( float,int ) +~@free_function_t@__builtin_sinhf@float (*)( float )float (*)( float ) +~@free_function_t@fread@::size_t (*)( __restrict__ void *,::size_t,::size_t,__restrict__ ::FILE * )::size_t (*)( __restrict__ void *,::size_t,::size_t,__restrict__ ::FILE * ) +~@free_function_t@ftello@::__off_t (*)( ::FILE * )::__off_t (*)( ::FILE * ) +~@free_function_t@fwrite_unlocked@::size_t (*)( __restrict__ void const *,::size_t,::size_t,__restrict__ ::FILE * )::size_t (*)( __restrict__ void const *,::size_t,::size_t,__restrict__ ::FILE * ) +~@free_function_t@popen@::FILE * (*)( char const *,char const * )::FILE * (*)( char const *,char const * ) +~@free_function_t@__builtin_ctan@complex double (*)( complex double )complex double (*)( complex double ) +~@free_function_t@__builtin_sin@double (*)( double )double (*)( double ) +~@free_function_t@vprintf@int (*)( __restrict__ char const *,::__gnuc_va_list )int (*)( __restrict__ char const *,::__gnuc_va_list ) +~@free_function_t@_IO_seekoff@::__off64_t (*)( ::_IO_FILE *,::__off64_t,int,int )::__off64_t (*)( ::_IO_FILE *,::__off64_t,int,int ) +~@free_function_t@feof@int (*)( ::FILE * )int (*)( ::FILE * ) +~@free_function_t@putc@int (*)( int,::FILE * )int (*)( int,::FILE * ) +~@free_function_t@__builtin_logl@long double (*)( long double )long double (*)( long double ) +~@free_function_t@__builtin_asin@double (*)( double )double (*)( double ) +~@free_function_t@clearerr@void (*)( ::FILE * )void (*)( ::FILE * ) +~@free_function_t@__builtin_logf@float (*)( float )float (*)( float ) +~@free_function_t@getc@int (*)( ::FILE * )int (*)( ::FILE * ) +~@free_function_t@__builtin_isgreater@bool (*)( ... )bool (*)( ... ) +~@free_function_t@putchar_unlocked@int (*)( int )int (*)( int ) +~@free_function_t@vfprintf@int (*)( __restrict__ ::FILE *,__restrict__ char const *,::__gnuc_va_list )int (*)( __restrict__ ::FILE *,__restrict__ char const *,::__gnuc_va_list ) +~@free_function_t@rewind@void (*)( ::FILE * )void (*)( ::FILE * ) +~@free_function_t@putc_unlocked@int (*)( int,::FILE * )int (*)( int,::FILE * ) +~@free_function_t@vfscanf@int (*)( __restrict__ ::FILE *,__restrict__ char const *,::__gnuc_va_list )int (*)( __restrict__ ::FILE *,__restrict__ char const *,::__gnuc_va_list ) +~@free_function_t@__builtin_isless@bool (*)( ... )bool (*)( ... ) +~@free_function_t@getw@int (*)( ::FILE * )int (*)( ::FILE * ) +~@free_function_t@flockfile@void (*)( ::FILE * )void (*)( ::FILE * ) +~@free_function_t@__builtin_nansf@float (*)( char const * )float (*)( char const * ) +~@free_function_t@__builtin_ccoshl@complex long double (*)( complex long double )complex long double (*)( complex long double ) +~@free_function_t@vasprintf@int (*)( __restrict__ char * *,__restrict__ char const *,::__gnuc_va_list )int (*)( __restrict__ char * *,__restrict__ char const *,::__gnuc_va_list ) +~@free_function_t@_IO_free_backup_area@void (*)( ::_IO_FILE * )void (*)( ::_IO_FILE * ) +~@free_function_t@__builtin_ccoshf@complex float (*)( complex float )complex float (*)( complex float ) +~@free_function_t@__builtin_nansl@long double (*)( char const * )long double (*)( char const * ) +~@free_function_t@__builtin_return_address@void * (*)( unsigned int )void * (*)( unsigned int ) +~@free_function_t@__builtin_ceilf@float (*)( float )float (*)( float ) +~@free_function_t@__builtin_isnan@bool (*)( ... )bool (*)( ... ) +~@free_function_t@__builtin_ccosf@complex float (*)( complex float )complex float (*)( complex float ) +~@free_function_t@__builtin_cosf@float (*)( float )float (*)( float ) +~@free_function_t@fputs_unlocked@int (*)( __restrict__ char const *,__restrict__ ::FILE * )int (*)( __restrict__ char const *,__restrict__ ::FILE * ) +~@free_function_t@setbuf@void (*)( __restrict__ ::FILE *,__restrict__ char * )void (*)( __restrict__ ::FILE *,__restrict__ char * ) +~@free_function_t@__builtin_cosh@double (*)( double )double (*)( double ) +~@free_function_t@__builtin_isgreaterequal@bool (*)( ... )bool (*)( ... ) +~@free_function_t@__builtin_cosl@long double (*)( long double )long double (*)( long double ) +~@free_function_t@funlockfile@void (*)( ::FILE * )void (*)( ::FILE * ) +~@free_function_t@vdprintf@int (*)( int,__restrict__ char const *,::__gnuc_va_list )int (*)( int,__restrict__ char const *,::__gnuc_va_list ) +~@free_function_t@__builtin_ceil@double (*)( double )double (*)( double ) +~@free_function_t@_IO_getc@int (*)( ::_IO_FILE * )int (*)( ::_IO_FILE * ) +~@free_function_t@__builtin_fmodf@float (*)( float,float )float (*)( float,float ) +~@free_function_t@__builtin_cos@double (*)( double )double (*)( double ) +~@free_function_t@fopen64@::FILE * (*)( __restrict__ char const *,__restrict__ char const * )::FILE * (*)( __restrict__ char const *,__restrict__ char const * ) +~@free_function_t@__builtin_fmodl@long double (*)( long double,long double )long double (*)( long double,long double ) +~@free_function_t@__builtin_sinl@long double (*)( long double )long double (*)( long double ) +~@free_function_t@setvbuf@int (*)( __restrict__ ::FILE *,__restrict__ char *,int,::size_t )int (*)( __restrict__ ::FILE *,__restrict__ char *,int,::size_t ) +~@free_function_t@_IO_funlockfile@void (*)( ::_IO_FILE * )void (*)( ::_IO_FILE * ) Added: pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/binaries/function_ptr_as_variable.os =================================================================== (Binary files differ) Property changes on: pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/binaries/function_ptr_as_variable.os ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/binaries/function_ptr_as_variable.py =================================================================== --- pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/binaries/function_ptr_as_variable.py (rev 0) +++ pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/binaries/function_ptr_as_variable.py 2009-12-26 20:13:12 UTC (rev 1785) @@ -0,0 +1,24 @@ +# This file has been generated by Py++. + +import ctypes + +import ctypes_utils + +libfunction_ptr_as_variable_lib = ctypes.CDLL( r"/home/roman/language-binding/sources/pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/binaries/libfunction_ptr_as_variable.so" ) + +libfunction_ptr_as_variable_lib.undecorated_names = {#mapping between decorated and undecorated names + "extern int execute_callback(info * info, int arg1) [free function]" : "_Z16execute_callbackP4infoi", + "_Z16execute_callbackP4infoi" : "extern int execute_callback(info * info, int arg1) [free function]", +} + +class info(ctypes.Structure): + """class info""" + +info._fields_ = [ #class info + ("do_smth_fun", ctypes.CFUNCTYPE( ctypes.c_int, ctypes.c_int )), +] + +do_smth_fun_t = ctypes.CFUNCTYPE( ctypes.c_int, ctypes.c_int ) + +execute_callback_type = ctypes.CFUNCTYPE( ctypes.c_int, ctypes.POINTER( info ), ctypes.c_int ) +execute_callback = execute_callback_type( ( libfunction_ptr_as_variable_lib.undecorated_names["extern int execute_callback(info * info, int arg1) [free function]"], libfunction_ptr_as_variable_lib ) ) Added: pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/function_ptr_as_variable.cpp =================================================================== --- pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/function_ptr_as_variable.cpp (rev 0) +++ pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/function_ptr_as_variable.cpp 2009-12-26 20:13:12 UTC (rev 1785) @@ -0,0 +1,5 @@ +#include "function_ptr_as_variable.h" + +EXPORT_SYMBOL int execute_callback(struct info* info, int v) { + return info->do_smth_fun(v); +} Added: pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/function_ptr_as_variable.h =================================================================== --- pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/function_ptr_as_variable.h (rev 0) +++ pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/function_ptr_as_variable.h 2009-12-26 20:13:12 UTC (rev 1785) @@ -0,0 +1,11 @@ +#include "libconfig.h" +#include <stdio.h> + +typedef int do_smth_fun_t(int); + +struct EXPORT_SYMBOL info { + do_smth_fun_t* do_smth_fun; +}; + +EXPORT_SYMBOL int execute_callback(struct info* info, int); + Added: pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/sconscript =================================================================== --- pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/sconscript (rev 0) +++ pyplusplus_dev/unittests/data/ctypes/function_ptr_as_variable/sconscript 2009-12-26 20:13:12 UTC (rev 1785) @@ -0,0 +1,7 @@ +Import('*') + +target_name = 'function_ptr_as_variable' +shlib = env.SharedLibrary( target=target_name + , source=[ target_name + '.cpp' ] + , CPPPATH=['#data'] ) +env.Alias( target_name, shlib ) Modified: pyplusplus_dev/unittests/sconstruct =================================================================== --- pyplusplus_dev/unittests/sconstruct 2009-12-26 19:21:49 UTC (rev 1784) +++ pyplusplus_dev/unittests/sconstruct 2009-12-26 20:13:12 UTC (rev 1785) @@ -32,7 +32,8 @@ , 'variables' , 'varargs' , 'templates' - , 'circular_references' ] + , 'circular_references' + , 'function_ptr_as_variable' ] for s in scripts: SConscript( 'data/ctypes/%s/sconscript' % s This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-12-27 20:43:42
|
Revision: 1786 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1786&view=rev Author: roman_yakovenko Date: 2009-12-27 20:43:34 +0000 (Sun, 27 Dec 2009) Log Message: ----------- add ability to treat char* as a pointer to a binary data Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/calldef_ctypes.py pyplusplus_dev/pyplusplus/code_creators/ctypes_formatter.py pyplusplus_dev/pyplusplus/code_creators/global_variable.py pyplusplus_dev/pyplusplus/code_creators/member_variable.py pyplusplus_dev/pyplusplus/code_creators/module.py pyplusplus_dev/pyplusplus/code_creators/typedef_as_pyvar.py pyplusplus_dev/unittests/ctypes_tester.py pyplusplus_dev/unittests/sconstruct Added Paths: ----------- pyplusplus_dev/unittests/data/ctypes/char_ptr_as_binary_data/ pyplusplus_dev/unittests/data/ctypes/char_ptr_as_binary_data/char_ptr_as_binary_data.cpp pyplusplus_dev/unittests/data/ctypes/char_ptr_as_binary_data/char_ptr_as_binary_data.h pyplusplus_dev/unittests/data/ctypes/char_ptr_as_binary_data/sconscript Removed Paths: ------------- pyplusplus_dev/pyplusplus/code_creators/ctypes_module.py Modified: pyplusplus_dev/pyplusplus/code_creators/calldef_ctypes.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/calldef_ctypes.py 2009-12-26 20:13:12 UTC (rev 1785) +++ pyplusplus_dev/pyplusplus/code_creators/calldef_ctypes.py 2009-12-27 20:43:34 UTC (rev 1786) @@ -66,14 +66,15 @@ def restype_code(self): if not declarations.is_void( self.ftype.return_type ): - return ctypes_formatter.as_ctype( self.ftype.return_type ) + return ctypes_formatter.as_ctype( self.ftype.return_type, self.top_parent.treat_char_ptr_as_binary_data ) else: return '' def argtypes_code(self, group_in_list=True): if not self.ftype.arguments_types: return '' - args = map( ctypes_formatter.as_ctype, self.ftype.arguments_types ) + args = map( lambda type_: ctypes_formatter.as_ctype( type_, self.top_parent.treat_char_ptr_as_binary_data ) + , self.ftype.arguments_types ) return self.join_arguments( args, group_in_list ) def _get_system_files_impl( self ): Modified: pyplusplus_dev/pyplusplus/code_creators/ctypes_formatter.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/ctypes_formatter.py 2009-12-26 20:13:12 UTC (rev 1785) +++ pyplusplus_dev/pyplusplus/code_creators/ctypes_formatter.py 2009-12-27 20:43:34 UTC (rev 1786) @@ -16,11 +16,15 @@ All functions within this class should be redefined in derived classes. """ - def __init__(self, type_, decl_formatter): + def __init__(self, type_, treat_char_ptr_as_binary_data, decl_formatter=algorithm.complete_py_name): declarations.type_visitor_t.__init__(self) self.user_type = type_ self.decl_formatter = decl_formatter + self.treat_char_ptr_as_binary_data = treat_char_ptr_as_binary_data + def create_converter( self, type_): + return type_converter_t( type_, self.treat_char_ptr_as_binary_data, self.decl_formatter ) + def visit_void( self ): return "None" @@ -75,23 +79,23 @@ #skip complex and jxxx types def visit_volatile( self ): - base_visitor = type_converter_t( self.user_type.base, self.decl_formatter ) + base_visitor = self.create_converter( self.user_type.base ) return declarations.apply_visitor( base_visitor, base_visitor.user_type ) def visit_const( self ): - base_visitor = type_converter_t( self.user_type.base, self.decl_formatter ) + base_visitor = self.create_converter( self.user_type.base ) return declarations.apply_visitor( base_visitor, base_visitor.user_type ) def visit_pointer( self ): no_ptr = declarations.remove_const( declarations.remove_pointer( self.user_type ) ) - if declarations.is_same( declarations.char_t(), no_ptr ): + if declarations.is_same( declarations.char_t(), no_ptr ) and self.treat_char_ptr_as_binary_data == False: return "ctypes.c_char_p" - elif declarations.is_same( declarations.wchar_t(), no_ptr ): + elif declarations.is_same( declarations.wchar_t(), no_ptr ) and self.treat_char_ptr_as_binary_data == False: return "ctypes.c_wchar_p" elif declarations.is_same( declarations.void_t(), no_ptr ): return "ctypes.c_void_p" else: - base_visitor = type_converter_t( self.user_type.base, self.decl_formatter ) + base_visitor = self.create_converter( self.user_type.base ) internal_type_str = declarations.apply_visitor( base_visitor, base_visitor.user_type ) if declarations.is_calldef_pointer( self.user_type ): return internal_type_str @@ -107,13 +111,12 @@ elif declarations.is_same( declarations.void_t(), no_ref ): return "ctypes.c_void_p" else: - base_visitor = type_converter_t( self.user_type.base, self.decl_formatter ) + base_visitor = self.create_converter( self.user_type.base ) internal_type_str = declarations.apply_visitor( base_visitor, base_visitor.user_type ) return "ctypes.POINTER( %s )" % internal_type_str def visit_array( self ): - item_visitor = type_converter_t( declarations.array_item_type(self.user_type) - , self.decl_formatter ) + item_visitor = self.create_converter( declarations.array_item_type(self.user_type) ) item_type = declarations.apply_visitor( item_visitor, item_visitor.user_type ) size = declarations.array_size( self.user_type ) if size == declarations.array_t.SIZE_UNKNOWN: @@ -121,11 +124,11 @@ return "( %s * %d )" % ( item_type, size ) def visit_free_function_type( self ): - return_visitor = type_converter_t( self.user_type.return_type, self.decl_formatter ) - return_type = declarations.apply_visitor(return_visitor, self.user_type.return_type) + return_visitor = self.create_converter( self.user_type.return_type ) + return_type = declarations.apply_visitor( return_visitor, self.user_type.return_type ) argtypes = [] for arg in self.user_type.arguments_types: - arg_visitor = type_converter_t( arg, self.decl_formatter ) + arg_visitor = self.create_converter( arg ) argtypes.append( declarations.apply_visitor(arg_visitor, arg) ) return declarations.call_invocation.join( "ctypes.CFUNCTYPE", [return_type] + argtypes ) @@ -138,19 +141,19 @@ def visit_declarated( self ): #TODO: the follwoing code removes typedefs if isinstance( self.user_type.declaration, declarations.typedef_t ): - base_visitor = type_converter_t( self.user_type.declaration.type, self.decl_formatter ) + base_visitor = self.create_converter( self.user_type.declaration.type ) return declarations.apply_visitor( base_visitor, base_visitor.user_type ) else: return self.decl_formatter( self.user_type.declaration ) def visit_restrict( self ): - base_visitor = type_converter_t( self.user_type.base, self.decl_formatter ) + base_visitor = self.create_converter( self.user_type.base ) return declarations.apply_visitor( base_visitor, base_visitor.user_type ) def visit_ellipsis( self ): return '' -def as_ctype( type_, decl_formatter=algorithm.complete_py_name ): - v = type_converter_t( type_, decl_formatter ) +def as_ctype( type_, treat_char_ptr_as_binary_data=False): + v = type_converter_t( type_, treat_char_ptr_as_binary_data ) return declarations.apply_visitor( v, type_ ) Deleted: pyplusplus_dev/pyplusplus/code_creators/ctypes_module.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/ctypes_module.py 2009-12-26 20:13:12 UTC (rev 1785) +++ pyplusplus_dev/pyplusplus/code_creators/ctypes_module.py 2009-12-27 20:43:34 UTC (rev 1786) @@ -1,30 +0,0 @@ -# Copyright 2004-2008 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 module -import library_reference -from pygccxml import utils - -class ctypes_module_t(module.module_t): - """This class represents the source code for the entire extension module. - - The root of the code creator tree is always a module_t object. - """ - def __init__(self, global_ns): - """Constructor. - """ - module.module_t.__init__(self, global_ns, ctypes_module_t.CODE_GENERATOR_TYPES.CTYPES) - - def _create_impl(self): - return self.create_internal_code( self.creators, indent_code=False ) - - @utils.cached - def library_var_name(self): - for creator in self.creators: - if isinstance( creator, library_reference.library_reference_t ): - return creator.library_var_name - else: - raise RuntimeError( "Internal Error: library_reference_t creator was not created" ) Modified: pyplusplus_dev/pyplusplus/code_creators/global_variable.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/global_variable.py 2009-12-26 20:13:12 UTC (rev 1785) +++ pyplusplus_dev/pyplusplus/code_creators/global_variable.py 2009-12-27 20:43:34 UTC (rev 1786) @@ -192,7 +192,7 @@ def _create_impl( self ): return '%(alias)s = %(type)s.in_dll( %(library_var_name)s, %(library_var_name)s.undecorated_names["%(undecorated_decl_name)s"] )' \ % dict( alias=self.alias - , type=ctypes_formatter.as_ctype( self.declaration.type ) + , type=ctypes_formatter.as_ctype( self.declaration.type, self.top_parent.treat_char_ptr_as_binary_data ) , library_var_name=self.top_parent.library_var_name , undecorated_decl_name=self.undecorated_decl_name ) Modified: pyplusplus_dev/pyplusplus/code_creators/member_variable.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2009-12-26 20:13:12 UTC (rev 1785) +++ pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2009-12-27 20:43:34 UTC (rev 1786) @@ -736,7 +736,7 @@ vars.sort( key=lambda d: d.location.line ) for v in vars: tmp = None - type_as_str = ctypes_formatter.as_ctype( v.type ) + type_as_str = ctypes_formatter.as_ctype( v.type, self.top_parent.treat_char_ptr_as_binary_data ) if v.bits != None: tmp = '("%(name)s", %(type)s, %(bits)d),' \ % dict( name=v.alias, type=type_as_str, bits=v.bits ) Modified: pyplusplus_dev/pyplusplus/code_creators/module.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/module.py 2009-12-26 20:13:12 UTC (rev 1785) +++ pyplusplus_dev/pyplusplus/code_creators/module.py 2009-12-27 20:43:34 UTC (rev 1786) @@ -237,7 +237,8 @@ """Constructor. """ module_t.__init__(self, global_ns, ctypes_module_t.CODE_GENERATOR_TYPES.CTYPES) - + self.treat_char_ptr_as_binary_data = False + def _create_impl(self): return self.create_internal_code( self.creators, indent_code=False ) Modified: pyplusplus_dev/pyplusplus/code_creators/typedef_as_pyvar.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/typedef_as_pyvar.py 2009-12-26 20:13:12 UTC (rev 1785) +++ pyplusplus_dev/pyplusplus/code_creators/typedef_as_pyvar.py 2009-12-27 20:43:34 UTC (rev 1786) @@ -16,7 +16,7 @@ def _create_impl(self): return "%(complete_py_name)s = %(type)s" \ % dict( complete_py_name=self.complete_py_name - , type=ctypes_formatter.as_ctype( self.declaration.type ) ) + , type=ctypes_formatter.as_ctype( self.declaration.type, self.top_parent.treat_char_ptr_as_binary_data ) ) def _get_system_files_impl( self ): return [] Modified: pyplusplus_dev/unittests/ctypes_tester.py =================================================================== --- pyplusplus_dev/unittests/ctypes_tester.py 2009-12-26 20:13:12 UTC (rev 1785) +++ pyplusplus_dev/unittests/ctypes_tester.py 2009-12-27 20:43:34 UTC (rev 1786) @@ -49,6 +49,9 @@ def customize(self, mb ): pass + def customize_cc( self, mb ): + pass + def __build_scons_cmd( self ): cmd = autoconfig.scons.cmd_build + ' ' + self.base_name if autoconfig.cxx_parsers_cfg.gccxml.compiler == 'msvc71': @@ -66,8 +69,9 @@ autoconfig.scons_config.compile( self.__build_scons_cmd(), cwd=autoconfig.this_module_dir_path ) mb = ctypes_module_builder_t( [self.header], self.symbols_file, autoconfig.cxx_parsers_cfg.gccxml ) - self.customize( mb ) + self.customize( mb ) mb.build_code_creator( self.library_file ) + self.customize_cc( mb ) mb.write_module( os.path.join( self.project_dir, 'binaries', self.base_name + '.py' ) ) sys.path.insert( 0, os.path.join( self.project_dir, 'binaries' ) ) __import__( self.base_name ) @@ -212,6 +216,23 @@ #TODO: sort structs and classes by dependencies pass #just test that module could be loaded + +class char_ptr_as_binary_data_tester_t( ctypes_base_tester_t ): + def __init__( self, *args, **keywd ): + ctypes_base_tester_t.__init__( self, 'char_ptr_as_binary_data', *args, **keywd ) + + def customize_cc( self, mb ): + mb.code_creator.treat_char_ptr_as_binary_data = True + + def test(self): + data = self.module_ref.get_empty() + self.failUnless( data.contents.size == 0 ) + self.failUnless( not data.contents.bytes ) + + data = self.module_ref.get_hello_world() + self.failUnless( data.contents.size == len( "hello world" ) ) + self.failUnless( data.contents.bytes[0:data.contents.size + 1] == "hello\0world\0" ) + def create_suite(): #part of this functionality is going to be deprecated suite = unittest.TestSuite() @@ -223,6 +244,7 @@ suite.addTest( unittest.makeSuite(varargs_tester_t)) suite.addTest( unittest.makeSuite(circular_references_tester_t)) suite.addTest( unittest.makeSuite(function_ptr_as_variable_tester_t)) + suite.addTest( unittest.makeSuite(char_ptr_as_binary_data_tester_t)) return suite def run_suite(): Added: pyplusplus_dev/unittests/data/ctypes/char_ptr_as_binary_data/char_ptr_as_binary_data.cpp =================================================================== --- pyplusplus_dev/unittests/data/ctypes/char_ptr_as_binary_data/char_ptr_as_binary_data.cpp (rev 0) +++ pyplusplus_dev/unittests/data/ctypes/char_ptr_as_binary_data/char_ptr_as_binary_data.cpp 2009-12-27 20:43:34 UTC (rev 1786) @@ -0,0 +1,15 @@ +#include "char_ptr_as_binary_data.h" + +EXPORT_SYMBOL data_t* get_empty(){ + data_t* x = new data_t(); + x->size = 0; + x->bytes = 0; + return x; +} + +EXPORT_SYMBOL data_t* get_hello_world(){ + data_t* x = new data_t(); + x->size = 11; + x->bytes = "hello\0world"; + return x; +} Added: pyplusplus_dev/unittests/data/ctypes/char_ptr_as_binary_data/char_ptr_as_binary_data.h =================================================================== --- pyplusplus_dev/unittests/data/ctypes/char_ptr_as_binary_data/char_ptr_as_binary_data.h (rev 0) +++ pyplusplus_dev/unittests/data/ctypes/char_ptr_as_binary_data/char_ptr_as_binary_data.h 2009-12-27 20:43:34 UTC (rev 1786) @@ -0,0 +1,11 @@ +#include "libconfig.h" + +struct EXPORT_SYMBOL data_t{ + unsigned int size; + char const * bytes; +}; + +EXPORT_SYMBOL data_t* get_empty(); +EXPORT_SYMBOL data_t* get_hello_world(); + + Added: pyplusplus_dev/unittests/data/ctypes/char_ptr_as_binary_data/sconscript =================================================================== --- pyplusplus_dev/unittests/data/ctypes/char_ptr_as_binary_data/sconscript (rev 0) +++ pyplusplus_dev/unittests/data/ctypes/char_ptr_as_binary_data/sconscript 2009-12-27 20:43:34 UTC (rev 1786) @@ -0,0 +1,7 @@ +Import('*') + +target_name = 'char_ptr_as_binary_data' +shlib = env.SharedLibrary( target=target_name + , source=[ target_name + '.cpp' ] + , CPPPATH=['#data'] ) +env.Alias( target_name, shlib ) Modified: pyplusplus_dev/unittests/sconstruct =================================================================== --- pyplusplus_dev/unittests/sconstruct 2009-12-26 20:13:12 UTC (rev 1785) +++ pyplusplus_dev/unittests/sconstruct 2009-12-27 20:43:34 UTC (rev 1786) @@ -33,7 +33,8 @@ , 'varargs' , 'templates' , 'circular_references' - , 'function_ptr_as_variable' ] + , 'function_ptr_as_variable' + , 'char_ptr_as_binary_data' ] for s in scripts: SConscript( 'data/ctypes/%s/sconscript' % s This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-12-27 21:15:50
|
Revision: 1790 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1790&view=rev Author: roman_yakovenko Date: 2009-12-27 21:15:38 +0000 (Sun, 27 Dec 2009) Log Message: ----------- move "treat_char_ptr_as_binary_data" to public interface Modified Paths: -------------- pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py pyplusplus_dev/unittests/ctypes_tester.py Modified: pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py =================================================================== --- pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py 2009-12-27 21:00:38 UTC (rev 1789) +++ pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py 2009-12-27 21:15:38 UTC (rev 1790) @@ -47,6 +47,8 @@ if optimize_queries: self.run_query_optimizer() + self.__treat_char_ptr_as_binary_data = None + def __parse_declarations( self, files, gccxml_config, compilation_mode=None, cache=None ): if None is gccxml_config: gccxml_config = parser.config_t() @@ -79,12 +81,27 @@ anonymous_vars = self.global_ns.vars( '', recursive=True, allow_empty=True ) anonymous_vars.alias = '_' + def __get_treat_char_ptr_as_binary_data(self): + if self.has_code_creator(): + return self.code_creator.treat_char_ptr_as_binary_data + else: + return self.__treat_char_ptr_as_binary_data + def __set_treat_char_ptr_as_binary_data( self, value ): + self.__treat_char_ptr_as_binary_data = value + if self.has_code_creator(): + self.code_creator.treat_char_ptr_as_binary_data = value + + treat_char_ptr_as_binary_data = property( __get_treat_char_ptr_as_binary_data, __set_treat_char_ptr_as_binary_data, + doc="""If True, Py++ will generate "POINTER( char )", instead of "c_char_p" for "char*" type. By default it is False""" ) + def build_code_creator( self, library_path, doc_extractor=None ): creator = creators_factory.ctypes_creator_t( self.global_ns , library_path , self.__blob2decl ) self.__code_creator = creator.create() self.__code_creator.update_documentation( doc_extractor ) + if self.__treat_char_ptr_as_binary_data != None: + self.__code_creator.treat_char_ptr_as_binary_data = self.__treat_char_ptr_as_binary_data return self.__code_creator @property Modified: pyplusplus_dev/unittests/ctypes_tester.py =================================================================== --- pyplusplus_dev/unittests/ctypes_tester.py 2009-12-27 21:00:38 UTC (rev 1789) +++ pyplusplus_dev/unittests/ctypes_tester.py 2009-12-27 21:15:38 UTC (rev 1790) @@ -49,9 +49,6 @@ def customize(self, mb ): pass - def customize_cc( self, mb ): - pass - def __build_scons_cmd( self ): cmd = autoconfig.scons.cmd_build + ' ' + self.base_name if autoconfig.cxx_parsers_cfg.gccxml.compiler == 'msvc71': @@ -71,7 +68,6 @@ mb = ctypes_module_builder_t( [self.header], self.symbols_file, autoconfig.cxx_parsers_cfg.gccxml ) self.customize( mb ) mb.build_code_creator( self.library_file ) - self.customize_cc( mb ) mb.write_module( os.path.join( self.project_dir, 'binaries', self.base_name + '.py' ) ) sys.path.insert( 0, os.path.join( self.project_dir, 'binaries' ) ) __import__( self.base_name ) @@ -221,8 +217,8 @@ def __init__( self, *args, **keywd ): ctypes_base_tester_t.__init__( self, 'char_ptr_as_binary_data', *args, **keywd ) - def customize_cc( self, mb ): - mb.code_creator.treat_char_ptr_as_binary_data = True + def customize( self, mb ): + mb.treat_char_ptr_as_binary_data = True def test(self): data = self.module_ref.get_empty() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2009-12-28 21:23:16
|
Revision: 1792 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1792&view=rev Author: roman_yakovenko Date: 2009-12-28 21:23:02 +0000 (Mon, 28 Dec 2009) Log Message: ----------- add ability to generate the user code in a module head/tail Modified Paths: -------------- pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py pyplusplus_dev/unittests/ctypes_tester.py pyplusplus_dev/unittests/sconstruct Added Paths: ----------- pyplusplus_dev/unittests/data/ctypes/user_code/ pyplusplus_dev/unittests/data/ctypes/user_code/sconscript pyplusplus_dev/unittests/data/ctypes/user_code/user_code.cpp pyplusplus_dev/unittests/data/ctypes/user_code/user_code.h Modified: pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py =================================================================== --- pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py 2009-12-28 21:17:07 UTC (rev 1791) +++ pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py 2009-12-28 21:23:02 UTC (rev 1792) @@ -190,22 +190,22 @@ @property def declarations_code_head( self ): - "List of user code, that will be added to the head of the declarations section." + "A list of the user code, which will be added to the head of the declarations section." return self.__declarations_code_head @property def declarations_code_tail( self ): - "List of user code, that will be added to the tail of the declarations section." + "A list of the user code, which will be added to the tail of the declarations section." return self.__declarations_code_tail @property def registrations_code_head( self ): - "List of user code, that will be added to the head of the registrations section." + "A list of the user code, which will be added to the head of the registrations section." return self.__registrations_code_head @property def registrations_code_tail( self ): - "List of user code, that will be added to the tail of the registrations section." + "A list of the user code, which will be added to the tail of the registrations section." return self.__registrations_code_tail def build_code_creator( self @@ -259,12 +259,14 @@ return not ( None is self.__code_creator ) def add_declaration_code( self, code, tail=True ): + """adds the user code to the generated one""" if tail: self.__declarations_code_tail.append( code ) else: self.__declarations_code_head.append( code ) def add_registration_code( self, code, tail=True ): + """adds the user code to the generated one""" if tail: self.__registrations_code_tail.append( code ) else: Modified: pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py =================================================================== --- pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py 2009-12-28 21:17:07 UTC (rev 1791) +++ pyplusplus_dev/pyplusplus/module_builder/ctypes_builder.py 2009-12-28 21:23:02 UTC (rev 1792) @@ -49,6 +49,9 @@ self.__treat_char_ptr_as_binary_data = None + self.__module_code_head = [] + self.__module_code_tail = [] + def __parse_declarations( self, files, gccxml_config, compilation_mode=None, cache=None ): if None is gccxml_config: gccxml_config = parser.config_t() @@ -94,6 +97,23 @@ treat_char_ptr_as_binary_data = property( __get_treat_char_ptr_as_binary_data, __set_treat_char_ptr_as_binary_data, doc="""If True, Py++ will generate "POINTER( char )", instead of "c_char_p" for "char*" type. By default it is False""" ) + @property + def module_code_head( self ): + "A list of the user code, which will be added to the top of the module" + return self.__module_code_head + + @property + def module_code_tail( self ): + "A list of the user code, which will be added to the bottom of the module" + return self.__module_code_tail + + def add_module_code( self, code, tail=True ): + """adds the user code to the generated one""" + if tail: + self.__module_code_tail.append( code ) + else: + self.__module_code_head.append( code ) + def build_code_creator( self, library_path, doc_extractor=None ): creator = creators_factory.ctypes_creator_t( self.global_ns , library_path @@ -117,6 +137,13 @@ """ return not ( None is self.__code_creator ) + def __merge_user_code( self ): + for code in self.module_code_tail: + self.code_creator.adopt_creator( code_creators.custom_text_t( code ) ) + + for code in self.module_code_head: + self.code_creator.adopt_creator( code_creators.custom_text_t( code ), 0 ) + def write_module( self, file_name ): """ Writes module to single file @@ -125,6 +152,7 @@ :type file_name: string """ + self.__merge_user_code() file_writers.write_file( self.code_creator, file_name, encoding=self.encoding ) Modified: pyplusplus_dev/unittests/ctypes_tester.py =================================================================== --- pyplusplus_dev/unittests/ctypes_tester.py 2009-12-28 21:17:07 UTC (rev 1791) +++ pyplusplus_dev/unittests/ctypes_tester.py 2009-12-28 21:23:02 UTC (rev 1792) @@ -229,6 +229,28 @@ self.failUnless( data.contents.size == len( "hello world" ) ) self.failUnless( data.contents.bytes[0:data.contents.size + 1] == "hello\0world\0" ) +class user_code_tester_t( ctypes_base_tester_t ): + def __init__( self, *args, **keywd ): + ctypes_base_tester_t.__init__( self, 'user_code', *args, **keywd ) + self.module_top_code = "top = 'top'" + self.module_bottom_code = "bottom = 'bottom'" + + def customize(self, mb ): + mb.add_module_code( self.module_top_code, tail=False ) + mb.add_module_code( self.module_bottom_code, tail=True ) + + def test(self): + self.failUnless( self.module_ref.top == "top" ) + self.failUnless( self.module_ref.bottom == "bottom" ) + content = [] + for line in file( self.module_ref.__file__ ): + if line.lstrip().startswith( '#' ) or not line.strip(): + continue + else: + content.append( line.rstrip() ) + self.failUnless( content[0] == self.module_top_code ) + self.failUnless( content[-1] == self.module_bottom_code ) + def create_suite(): #part of this functionality is going to be deprecated suite = unittest.TestSuite() @@ -241,6 +263,7 @@ suite.addTest( unittest.makeSuite(circular_references_tester_t)) suite.addTest( unittest.makeSuite(function_ptr_as_variable_tester_t)) suite.addTest( unittest.makeSuite(char_ptr_as_binary_data_tester_t)) + suite.addTest( unittest.makeSuite(user_code_tester_t)) return suite def run_suite(): Added: pyplusplus_dev/unittests/data/ctypes/user_code/sconscript =================================================================== --- pyplusplus_dev/unittests/data/ctypes/user_code/sconscript (rev 0) +++ pyplusplus_dev/unittests/data/ctypes/user_code/sconscript 2009-12-28 21:23:02 UTC (rev 1792) @@ -0,0 +1,7 @@ +Import('*') + +target_name = 'user_code' +shlib = env.SharedLibrary( target=target_name + , source=[ target_name + '.cpp' ] + , CPPPATH=['#data'] ) +env.Alias( target_name, shlib ) Added: pyplusplus_dev/unittests/data/ctypes/user_code/user_code.cpp =================================================================== --- pyplusplus_dev/unittests/data/ctypes/user_code/user_code.cpp (rev 0) +++ pyplusplus_dev/unittests/data/ctypes/user_code/user_code.cpp 2009-12-28 21:23:02 UTC (rev 1792) @@ -0,0 +1,5 @@ +#include "user_code.h" + +EXPORT_SYMBOL void init(){ +} + Added: pyplusplus_dev/unittests/data/ctypes/user_code/user_code.h =================================================================== --- pyplusplus_dev/unittests/data/ctypes/user_code/user_code.h (rev 0) +++ pyplusplus_dev/unittests/data/ctypes/user_code/user_code.h 2009-12-28 21:23:02 UTC (rev 1792) @@ -0,0 +1,11 @@ +#include "libconfig.h" + +struct EXPORT_SYMBOL data_t{ + int i; + unsigned int j : 3; +}; + +EXPORT_SYMBOL int j; + +EXPORT_SYMBOL void init(); + Modified: pyplusplus_dev/unittests/sconstruct =================================================================== --- pyplusplus_dev/unittests/sconstruct 2009-12-28 21:17:07 UTC (rev 1791) +++ pyplusplus_dev/unittests/sconstruct 2009-12-28 21:23:02 UTC (rev 1792) @@ -33,7 +33,8 @@ , 'varargs' , 'templates' , 'circular_references' - , 'function_ptr_as_variable' + , 'function_ptr_as_variable' + , 'user_code' , 'char_ptr_as_binary_data' ] for s in scripts: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2010-01-13 09:02:29
|
Revision: 1796 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1796&view=rev Author: roman_yakovenko Date: 2010-01-13 09:02:23 +0000 (Wed, 13 Jan 2010) Log Message: ----------- integrate input_static_matrix Modified Paths: -------------- pyplusplus_dev/docs/documentation/functions/transformation/input_static_array.rest pyplusplus_dev/docs/documentation/functions/transformation/transformation.rest pyplusplus_dev/pyplusplus/function_transformers/transformers.py pyplusplus_dev/unittests/ft_input_static_matrix_tester.py Added Paths: ----------- pyplusplus_dev/docs/documentation/functions/transformation/input_static_matrix.rest Modified: pyplusplus_dev/docs/documentation/functions/transformation/input_static_array.rest =================================================================== --- pyplusplus_dev/docs/documentation/functions/transformation/input_static_array.rest 2010-01-13 08:02:50 UTC (rev 1795) +++ pyplusplus_dev/docs/documentation/functions/transformation/input_static_array.rest 2010-01-13 09:02:23 UTC (rev 1796) @@ -12,7 +12,7 @@ "input_static_array" transformer takes as first argument name or index of the original function argument. The argument should have "array" or "pointer" type. -The second argument should an integer value, which represents array size. +The second argument should be an integer value, which represents array size. ------- Example Added: pyplusplus_dev/docs/documentation/functions/transformation/input_static_matrix.rest =================================================================== --- pyplusplus_dev/docs/documentation/functions/transformation/input_static_matrix.rest (rev 0) +++ pyplusplus_dev/docs/documentation/functions/transformation/input_static_matrix.rest 2010-01-13 09:02:23 UTC (rev 1796) @@ -0,0 +1,90 @@ +================================== +``input_static_matrix`` transformer +================================== + +---------- +Definition +---------- + +"input_static_matrix" transformer works on native static 2D arrays. It +handles the translation between `Python`_ object, passed as argument +that represent a sequence of sequences, and the matrix. The number of rows +and columns should be known in advance. + +"input_static_matrix" transformer takes as first argument name or index of the +original function argument. The argument should have "array" or "pointer" type. +The second and the third arguments specfies rows and columns size. + +----------- +Limitations +----------- + +This transformer could not be applied on virtual functions. + +------- +Example +------- + +.. code-block:: c++ + + template< int rows, int columns > + int sum_impl( const int m[rows][columns] ){ + int result = 0; + for( int r = 0; r < rows; ++r ){ + for( int c = 0; c < columns; ++c ){ + result += m[r][c]; + } + } + return result; + } + + int sum( int m[2][3]){ + return sum_impl<2, 3>( m ); + } + + +In order to expose ``sum`` function we need to create small wrapper: +The following :doc:`Py++ <../../../pyplusplus>` code does it for you: + + .. code-block:: python + + from pyplusplus import module_builder + from pyplusplus import function_transformers as FT + + mb = module_builder.module_builder_t( ... ) + sum = mb.free_fun( 'sum' ) + sum.add_transformation( FT.input_static_matrix('m', rows=2, columns=3) ) + +What you see below is the relevant pieces of generated code: + + .. code-block:: c++ + + #include "__convenience.pypp.hpp" //Py++ header file, which contains few convenience function + + namespace bp = boost::python; + + static boost::python::object sum_d4475c1b6a0ff117f0754ec5ecacdda3( boost::python::object m ){ + int native_m[2][3]; + pyplus_conv::ensure_uniform_sequence< boost::python::list >( m, 2 ); + for( size_t row = 0; row < 2; ++row ){ + pyplus_conv::ensure_uniform_sequence< int >( m[row], 3 ); + pyplus_conv::copy_sequence( m[row], pyplus_conv::array_inserter( native_m[row], 3 ) ); + } + int result = ::ft::sum(native_m); + return bp::object( result ); + } + + BOOST_PYTHON_MODULE(...){ + ... + typedef boost::python::object ( *sum_function_type )( boost::python::object ); + + bp::def( + "sum" + , sum_function_type( &sum_d4475c1b6a0ff117f0754ec5ecacdda3 ) + , ( bp::arg("m") ) ); + } + +.. _`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/functions/transformation/transformation.rest =================================================================== --- pyplusplus_dev/docs/documentation/functions/transformation/transformation.rest 2010-01-13 08:02:50 UTC (rev 1795) +++ pyplusplus_dev/docs/documentation/functions/transformation/transformation.rest 2010-01-13 09:02:23 UTC (rev 1796) @@ -95,6 +95,7 @@ transfer_ownership.rest input_c_buffer.rest from_address.rest + input_static_matrix.rest Modified: pyplusplus_dev/pyplusplus/function_transformers/transformers.py =================================================================== --- pyplusplus_dev/pyplusplus/function_transformers/transformers.py 2010-01-13 08:02:50 UTC (rev 1795) +++ pyplusplus_dev/pyplusplus/function_transformers/transformers.py 2010-01-13 09:02:23 UTC (rev 1796) @@ -612,8 +612,9 @@ self.__configure_sealed( controller ) def configure_virtual_mem_fun( self, controller ): - self.__configure_v_mem_fun_override( controller.override_controller ) - self.__configure_v_mem_fun_default( controller.default_controller ) + raise RuntimeError( '"input_static_matrix" transformation does not support virtual functions yet.' ) + #self.__configure_v_mem_fun_override( controller.override_controller ) + #self.__configure_v_mem_fun_default( controller.default_controller ) # output_static_matrix_t class output_static_matrix_t(transformer.transformer_t): Modified: pyplusplus_dev/unittests/ft_input_static_matrix_tester.py =================================================================== --- pyplusplus_dev/unittests/ft_input_static_matrix_tester.py 2010-01-13 08:02:50 UTC (rev 1795) +++ pyplusplus_dev/unittests/ft_input_static_matrix_tester.py 2010-01-13 09:02:23 UTC (rev 1796) @@ -31,8 +31,8 @@ sum = mb.free_funs( lambda d: d.name in ('sum', 'sum_const' ) ) sum.add_transformation( ft.input_static_matrix('m', rows=2, columns=3) ) - calculate = mb.mem_fun( 'calculate' ) - calculate.add_transformation( ft.input_static_matrix('m', rows=3, columns=5) ) + #calculate = mb.mem_fun( 'calculate' ) + #calculate.add_transformation( ft.input_static_matrix('m', rows=3, columns=5) ) def run_tests(self, module): """Run the actual unit tests""" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2010-01-13 09:48:27
|
Revision: 1797 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1797&view=rev Author: roman_yakovenko Date: 2010-01-13 09:48:10 +0000 (Wed, 13 Jan 2010) Log Message: ----------- integrate output_static_matrix Modified Paths: -------------- pyplusplus_dev/docs/documentation/functions/transformation/input_static_matrix.rest pyplusplus_dev/docs/documentation/functions/transformation/transformation.rest pyplusplus_dev/pyplusplus/function_transformers/transformers.py pyplusplus_dev/unittests/test_all.py Added Paths: ----------- pyplusplus_dev/docs/documentation/functions/transformation/output_static_matrix.rest pyplusplus_dev/unittests/data/ft_output_static_matrix_to_be_exported.hpp pyplusplus_dev/unittests/ft_output_static_matrix_tester.py Modified: pyplusplus_dev/docs/documentation/functions/transformation/input_static_matrix.rest =================================================================== --- pyplusplus_dev/docs/documentation/functions/transformation/input_static_matrix.rest 2010-01-13 09:02:23 UTC (rev 1796) +++ pyplusplus_dev/docs/documentation/functions/transformation/input_static_matrix.rest 2010-01-13 09:48:10 UTC (rev 1797) @@ -13,7 +13,7 @@ "input_static_matrix" transformer takes as first argument name or index of the original function argument. The argument should have "array" or "pointer" type. -The second and the third arguments specfies rows and columns size. +The second and the third arguments specify rows and columns size. ----------- Limitations @@ -43,7 +43,7 @@ } -In order to expose ``sum`` function we need to create small wrapper: +In order to expose ``sum`` function we need to create a small wrapper: The following :doc:`Py++ <../../../pyplusplus>` code does it for you: .. code-block:: python Added: pyplusplus_dev/docs/documentation/functions/transformation/output_static_matrix.rest =================================================================== --- pyplusplus_dev/docs/documentation/functions/transformation/output_static_matrix.rest (rev 0) +++ pyplusplus_dev/docs/documentation/functions/transformation/output_static_matrix.rest 2010-01-13 09:48:10 UTC (rev 1797) @@ -0,0 +1,85 @@ +===================================== +``output_static_matrix`` transformer +===================================== + +---------- +Definition +---------- + +"output_static_matrix" transformer works on native 2D static arrays. +It handles the translation between a matrix and `Python`_ list object. +The matrix row and column sizes should be known in advance. + +"output_static_matrix" transformer takes as first argument name or index of the +original function argument. The argument should have "array" or "pointer" +type. The second and the third arguments specify rows and columns size. + +----------- +Limitations +----------- + +This transformer could not be applied on virtual functions. + + +------- +Example +------- + +.. code-block:: c++ + + void filler( int m[2][3], int value ){ + for( int r = 0; r < 2; ++r ){ + for( int c = 0; c < 3; ++c ){ + m[r][c] = value; + } + } + } + +In order to expose ``filler`` function we need to create a small wrapper. +The following :doc:`Py++ <../../../pyplusplus>` code does it for you: + + .. code-block:: python + + from pyplusplus import module_builder + from pyplusplus import function_transformers as FT + + mb = module_builder.module_builder_t( ... ) + filler = mb.free_fun( 'filler' ) + filler.add_transformation( ft.output_static_matrix('m', rows=2, columns=3) ) + +What you see below is the relevant pieces of generated code: + + .. code-block:: c++ + + #include "__convenience.pypp.hpp" //Py++ header file, which contains few convenience function + + namespace bp = boost::python; + + static boost::python::object filler_7b0a7cb8f4000f0474aa44d21c2e4917( int value ){ + int native_m[2][3]; + boost::python::list py_m; + ::ft::filler(native_m, value); + for (int row = 0; row < 2; ++row ){ + boost::python::list pyrow; + pyplus_conv::copy_container( native_m[row] + , native_m[row] + 3 + , pyplus_conv::list_inserter( pyrow ) ); + py_m.append( pyrow ); + } + return bp::object( py_m ); + } + + BOOST_PYTHON_MODULE(...){ + ... + typedef boost::python::object ( *filler_function_type )( int ); + + bp::def( + "filler" + , filler_function_type( &filler_7b0a7cb8f4000f0474aa44d21c2e4917 ) + , ( bp::arg("value") ) ); + } + +.. _`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/functions/transformation/transformation.rest =================================================================== --- pyplusplus_dev/docs/documentation/functions/transformation/transformation.rest 2010-01-13 09:02:23 UTC (rev 1796) +++ pyplusplus_dev/docs/documentation/functions/transformation/transformation.rest 2010-01-13 09:48:10 UTC (rev 1797) @@ -96,6 +96,7 @@ input_c_buffer.rest from_address.rest input_static_matrix.rest + output_static_matrix.rest Modified: pyplusplus_dev/pyplusplus/function_transformers/transformers.py =================================================================== --- pyplusplus_dev/pyplusplus/function_transformers/transformers.py 2010-01-13 09:02:23 UTC (rev 1796) +++ pyplusplus_dev/pyplusplus/function_transformers/transformers.py 2010-01-13 09:48:10 UTC (rev 1797) @@ -262,11 +262,6 @@ _arr2seq = string.Template( 'pyplus_conv::copy_container( $native_array, $native_array + $array_size, pyplus_conv::list_inserter( $pylist ) );' ) -_mat2seq = string.Template( - 'for (int i=0; i<$rows; ++i) { boost::python::list ${pylist}_i; pyplus_conv::copy_container( $native_matrix[i], $native_matrix[i] + $columns, pyplus_conv::list_inserter( ${pylist}_i ) ); $pylist.append(${pylist}_i); }' ) - - - class input_static_array_t(transformer.transformer_t): """Handles an input array with fixed size. @@ -534,6 +529,17 @@ , ' pyplus_conv::copy_sequence( $pymatrix[$row], pyplus_conv::array_inserter( $native_matrix[$row], $columns ) );' , '}'])) + +_cmatrix2pymatrix = string.Template( os.linesep.join([ + 'for (int $row = 0; $row < $rows; ++$row ){' + , ' boost::python::list $pyrow;' + , ' pyplus_conv::copy_container( $native_matrix[$row]' + , ' , $native_matrix[$row] + $columns' + , ' , pyplus_conv::list_inserter( $pyrow ) );' + , ' $pymatrix.append( $pyrow ); ' + , '}' ])) + + # input_static_matrix_t class input_static_matrix_t(transformer.transformer_t): """Handles an input matrix with fixed size. @@ -654,31 +660,32 @@ return [ code_repository.convenience.file_name ] def __configure_sealed(self, controller): - global _mat2seq + global _cmatrix2pymatrix #removing arg from the function wrapper definition controller.remove_wrapper_arg( self.arg.name ) # Declare a variable that will hold the C matrix... native_matrix = controller.declare_variable( self.matrix_item_type , "native_" + self.arg.name - , '[%d][%d]' % (self.rows, self.columns) - ) + , '[%d][%d]' % (self.rows, self.columns ) ) #adding just declared variable to the original function call expression controller.modify_arg_expression( self.arg_index, native_matrix ) # Declare a Python list which will receive the output... - pylist = controller.declare_variable( declarations.dummy_type_t( "boost::python::list" ) + pymatrix = controller.declare_variable( declarations.dummy_type_t( "boost::python::list" ) , 'py_' + self.arg.name ) - copy_mat2pylist = _mat2seq.substitute( native_matrix = native_matrix, - rows=self.rows, - columns=self.columns, - pylist=pylist) + conversion_code = _cmatrix2pymatrix.substitute( pymatrix=pymatrix + , columns='%d' % self.columns + , row=controller.register_variable_name( "row" ) + , pyrow=controller.register_variable_name( "pyrow" ) + , rows='%d' % self.rows + , native_matrix=native_matrix ) - controller.add_post_call_code( copy_mat2pylist ) + controller.add_post_call_code( conversion_code ) #adding the variable to return variables list - controller.return_variable( pylist ) + controller.return_variable( pymatrix ) def __configure_v_mem_fun_default( self, controller ): self.__configure_sealed( controller ) Added: pyplusplus_dev/unittests/data/ft_output_static_matrix_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/ft_output_static_matrix_to_be_exported.hpp (rev 0) +++ pyplusplus_dev/unittests/data/ft_output_static_matrix_to_be_exported.hpp 2010-01-13 09:48:10 UTC (rev 1797) @@ -0,0 +1,25 @@ +// Copyright 2004-2008 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 __ft_output_static_matrix_to_be_exported_hpp__ +#define __ft_output_static_matrix_to_be_exported_hpp__ + +#include <cmath> +#include <string> +#include <iostream> + +namespace ft{ + +void filler( int m[2][3], int value ){ + for( int r = 0; r < 2; ++r ){ + for( int c = 0; c < 3; ++c ){ + m[r][c] = value; + } + } +} + +} + +#endif//__ft_output_static_matrix_to_be_exported_hpp__ Added: pyplusplus_dev/unittests/ft_output_static_matrix_tester.py =================================================================== --- pyplusplus_dev/unittests/ft_output_static_matrix_tester.py (rev 0) +++ pyplusplus_dev/unittests/ft_output_static_matrix_tester.py 2010-01-13 09:48:10 UTC (rev 1797) @@ -0,0 +1,47 @@ +# Copyright 2004-2008 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_output_static_matrix' + + 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.calldefs().create_with_signature = True + + sum = mb.free_fun( 'filler' ) + sum.add_transformation( ft.output_static_matrix('m', rows=2, columns=3) ) + + + #calculate = mb.mem_fun( 'calculate' ) + #calculate.add_transformation( ft.input_static_matrix('m', rows=3, columns=5) ) + + def run_tests(self, module): + """Run the actual unit tests""" + self.failUnless( [[23,23,23],[23,23,23]] == module.filler( 23 ) ) + +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 2010-01-13 09:02:23 UTC (rev 1796) +++ pyplusplus_dev/unittests/test_all.py 2010-01-13 09:48:10 UTC (rev 1797) @@ -123,6 +123,7 @@ import ft_from_address_tester import indexing_suites2_support_tester import ft_input_static_matrix_tester +import ft_output_static_matrix_tester testers = [ algorithms_tester @@ -234,6 +235,7 @@ , ft_from_address_tester , indexing_suites2_support_tester , ft_input_static_matrix_tester + , ft_output_static_matrix_tester # , ogre_generate_tester too much time ] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2010-01-13 10:38:29
|
Revision: 1798 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1798&view=rev Author: roman_yakovenko Date: 2010-01-13 10:38:19 +0000 (Wed, 13 Jan 2010) Log Message: ----------- integrating inout_static_matrix implementation Modified Paths: -------------- pyplusplus_dev/pyplusplus/function_transformers/transformers.py pyplusplus_dev/unittests/test_all.py Added Paths: ----------- pyplusplus_dev/unittests/data/ft_inout_static_matrix_to_be_exported.hpp pyplusplus_dev/unittests/ft_inout_static_matrix_tester.py Modified: pyplusplus_dev/pyplusplus/function_transformers/transformers.py =================================================================== --- pyplusplus_dev/pyplusplus/function_transformers/transformers.py 2010-01-13 09:48:10 UTC (rev 1797) +++ pyplusplus_dev/pyplusplus/function_transformers/transformers.py 2010-01-13 10:38:19 UTC (rev 1798) @@ -716,8 +716,9 @@ self.__configure_sealed( controller ) def configure_virtual_mem_fun( self, controller ): - self.__configure_v_mem_fun_override( controller.override_controller ) - self.__configure_v_mem_fun_default( controller.default_controller ) + raise RuntimeError( '"output_static_matrix" transformation does not support virtual functions yet.' ) + #self.__configure_v_mem_fun_override( controller.override_controller ) + #self.__configure_v_mem_fun_default( controller.default_controller ) # inout_static_matrix_t class inout_static_matrix_t(transformer.transformer_t): @@ -756,42 +757,46 @@ return [ code_repository.convenience.file_name ] def __configure_sealed(self, controller): - global _seq2arr - global _mat2seq + global _pymatrix2cmatrix + global _cmatrix2pymatrix w_arg = controller.find_wrapper_arg( self.arg.name ) w_arg.type = declarations.dummy_type_t( "boost::python::object" ) # Declare a variable that will hold the C matrix... native_matrix = controller.declare_variable( self.matrix_item_type , "native_" + self.arg.name - , '[%d][%d]' % (self.rows, self.columns) - ) + , '[%d][%d]' % (self.rows, self.columns) ) - pre_call = string.Template('pyplus_conv::ensure_uniform_sequence< $type >( $pylist, $array_size );') - controller.add_pre_call_code(pre_call.substitute(type='boost::python::list', pylist=w_arg.name,array_size=self.rows)) + conversion_code = _pymatrix2cmatrix.substitute( type=self.matrix_item_type + , pymatrix=w_arg.name + , columns='%d' % self.columns + , row=controller.register_variable_name( "row" ) + , rows='%d' % self.rows + , native_matrix=native_matrix ) - #TODO: may be a better idea is move this loop to the generated code. - for i in range(0,self.rows): - copy_pylist2arr = _seq2arr.substitute( type=self.matrix_item_type - , pylist=w_arg.name+"["+str(i)+"]" - , array_size=self.columns - , native_array=native_matrix+'['+str(i)+']' ) + controller.add_pre_call_code( conversion_code ) - controller.add_pre_call_code( copy_pylist2arr ) + controller.modify_arg_expression( self.arg_index, native_matrix ) + + #adding just declared variable to the original function call expression controller.modify_arg_expression( self.arg_index, native_matrix ) - pylist = controller.declare_variable( declarations.dummy_type_t( "boost::python::list" ) + # Declare a Python list which will receive the output... + pymatrix = controller.declare_variable( declarations.dummy_type_t( "boost::python::list" ) , 'py_' + self.arg.name ) - copy_mat2pylist = _mat2seq.substitute( native_matrix = native_matrix - , rows=self.rows - , columns=self.columns - , pylist=pylist) - controller.add_post_call_code( copy_mat2pylist ) + conversion_code = _cmatrix2pymatrix.substitute( pymatrix=pymatrix + , columns='%d' % self.columns + , row=controller.register_variable_name( "row" ) + , pyrow=controller.register_variable_name( "pyrow" ) + , rows='%d' % self.rows + , native_matrix=native_matrix ) + + controller.add_post_call_code( conversion_code ) #adding the variable to return variables list - controller.return_variable( pylist ) + controller.return_variable( pymatrix ) def __configure_v_mem_fun_default( self, controller ): self.__configure_sealed( controller ) @@ -815,8 +820,9 @@ self.__configure_sealed( controller ) def configure_virtual_mem_fun( self, controller ): - self.__configure_v_mem_fun_override( controller.override_controller ) - self.__configure_v_mem_fun_default( controller.default_controller ) + raise RuntimeError( '"output_static_matrix" transformation does not support virtual functions yet.' ) + #self.__configure_v_mem_fun_override( controller.override_controller ) + #self.__configure_v_mem_fun_default( controller.default_controller ) # input_c_buffer_t class input_c_buffer_t(transformer.transformer_t): Added: pyplusplus_dev/unittests/data/ft_inout_static_matrix_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/ft_inout_static_matrix_to_be_exported.hpp (rev 0) +++ pyplusplus_dev/unittests/data/ft_inout_static_matrix_to_be_exported.hpp 2010-01-13 10:38:19 UTC (rev 1798) @@ -0,0 +1,28 @@ +// Copyright 2004-2008 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 __ft_inout_static_matrix_to_be_exported_hpp__ +#define __ft_inout_static_matrix_to_be_exported_hpp__ + +#include <cmath> +#include <string> +#include <iostream> + +namespace ft{ + +int sum_and_fill( int m[2][3], int value ){ + int result = 0; + for( int r = 0; r < 2; ++r ){ + for( int c = 0; c < 3; ++c ){ + result += m[r][c]; + m[r][c] *= value; + } + } + return result; +} + +} + +#endif//__ft_inout_static_matrix_to_be_exported_hpp__ Added: pyplusplus_dev/unittests/ft_inout_static_matrix_tester.py =================================================================== --- pyplusplus_dev/unittests/ft_inout_static_matrix_tester.py (rev 0) +++ pyplusplus_dev/unittests/ft_inout_static_matrix_tester.py 2010-01-13 10:38:19 UTC (rev 1798) @@ -0,0 +1,49 @@ +# Copyright 2004-2008 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_static_matrix' + + 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.calldefs().create_with_signature = True + + sum_and_fill = mb.free_fun( 'sum_and_fill' ) + sum_and_fill.add_transformation( ft.inout_static_matrix('m', rows=2, columns=3) ) + + #calculate = mb.mem_fun( 'calculate' ) + #calculate.add_transformation( ft.input_static_matrix('m', rows=3, columns=5) ) + + def run_tests(self, module): + """Run the actual unit tests""" + m = [ [1, 2, 3], [4,5,6] ] + result = module.sum_and_fill( m, -1 ) + self.failUnless( 21 == result[0] ) + self.failUnless( [ [-1, -2, -3], [-4,-5,-6] ] == result[1]) + +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 2010-01-13 09:48:10 UTC (rev 1797) +++ pyplusplus_dev/unittests/test_all.py 2010-01-13 10:38:19 UTC (rev 1798) @@ -124,6 +124,7 @@ import indexing_suites2_support_tester import ft_input_static_matrix_tester import ft_output_static_matrix_tester +import ft_inout_static_matrix_tester testers = [ algorithms_tester @@ -236,6 +237,7 @@ , indexing_suites2_support_tester , ft_input_static_matrix_tester , ft_output_static_matrix_tester + , ft_inout_static_matrix_tester # , ogre_generate_tester too much time ] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2010-01-13 12:05:28
|
Revision: 1801 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1801&view=rev Author: roman_yakovenko Date: 2010-01-13 12:05:21 +0000 (Wed, 13 Jan 2010) Log Message: ----------- integrating inout_static_matrix implementation Modified Paths: -------------- pyplusplus_dev/docs/documentation/functions/transformation/inout.rest pyplusplus_dev/docs/documentation/functions/transformation/transformation.rest Added Paths: ----------- pyplusplus_dev/docs/documentation/functions/transformation/inout_static_matrix.rest pyplusplus_dev/pyplusplus/code_repository/indexing_suite/registry_utils_header.py Modified: pyplusplus_dev/docs/documentation/functions/transformation/inout.rest =================================================================== --- pyplusplus_dev/docs/documentation/functions/transformation/inout.rest 2010-01-13 11:45:48 UTC (rev 1800) +++ pyplusplus_dev/docs/documentation/functions/transformation/inout.rest 2010-01-13 12:05:21 UTC (rev 1801) @@ -6,7 +6,7 @@ Definition ---------- -``inout`` transformer is a combination of :doc:`input <inout>` and :doc:`output <output>` transformers. +``inout`` transformer is a combination of :doc:`input <input>` and :doc:`output <output>` transformers. It removes a "reference" type from the function argument and then adds the "returned", by the original function, value to the return statement of the function-wrapper. Added: pyplusplus_dev/docs/documentation/functions/transformation/inout_static_matrix.rest =================================================================== --- pyplusplus_dev/docs/documentation/functions/transformation/inout_static_matrix.rest (rev 0) +++ pyplusplus_dev/docs/documentation/functions/transformation/inout_static_matrix.rest 2010-01-13 12:05:21 UTC (rev 1801) @@ -0,0 +1,91 @@ +==================================== +``inout_static_matrix`` transformer +==================================== + +---------- +Definition +---------- + +``inout_static_matrix`` transformer is a combination of :doc:`input <input_static_matrix>` +and :doc:`output <output_static_matrix>` transformers. +It allows to call a C++ function, which takes 2D array using Python ``list`` class + +"input_static_matrix" transformer takes as first argument name or index of the +original function argument. The argument should have "array" or "pointer" type. +The second and the third arguments specify rows and columns sizes. + +----------- +Limitations +----------- + +This transformer could not be applied on virtual functions. + +------- +Example +------- + +.. code-block:: c++ + + int sum_and_fill( int m[2][3], int value ){ + int result = 0; + for( int r = 0; r < 2; ++r ){ + for( int c = 0; c < 3; ++c ){ + result += m[r][c]; + m[r][c] *= value; + } + } + return result; + } + +In order to expose ``sum_and_fill`` function we need to create a small wrapper. +The following :doc:`Py++ <../../../pyplusplus>` code does it for you: + + .. code-block:: python + + from pyplusplus import module_builder + from pyplusplus import function_transformers as FT + + mb = module_builder.module_builder_t( ... ) + sum_and_fill = mb.free_fun( 'sum_and_fill' ) + sum_and_fill.add_transformation( ft.inout_static_matrix('m', rows=2, columns=3) ) + +What you see below is the relevant pieces of generated code: + + .. code-block:: c++ + + static boost::python::tuple sum_and_fill_ec4892ec81f672fe151a0a2caa3215f4( boost::python::object m, int value ){ + int native_m[2][3]; + boost::python::list py_m; + pyplus_conv::ensure_uniform_sequence< boost::python::list >( m, 2 ); + for( size_t row = 0; row < 2; ++row ){ + pyplus_conv::ensure_uniform_sequence< int >( m[row], 3 ); + pyplus_conv::copy_sequence( m[row], pyplus_conv::array_inserter( native_m[row], 3 ) ); + } + int result = ::ft::sum_and_fill(native_m, value); + for (int row2 = 0; row2 < 2; ++row2 ){ + boost::python::list pyrow; + pyplus_conv::copy_container( native_m[row2] + , native_m[row2] + 3 + , pyplus_conv::list_inserter( pyrow ) ); + py_m.append( pyrow ); + } + return bp::make_tuple( result, py_m ); + } + + BOOST_PYTHON_MODULE(ft_inout_static_matrix){ + { //::ft::sum_and_fill + + typedef boost::python::tuple ( *sum_and_fill_function_type )( boost::python::object,int ); + + bp::def( + "sum_and_fill" + , sum_and_fill_function_type( &sum_and_fill_ec4892ec81f672fe151a0a2caa3215f4 ) + , ( bp::arg("m"), bp::arg("value") ) ); + + } + } + +.. _`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/functions/transformation/transformation.rest =================================================================== --- pyplusplus_dev/docs/documentation/functions/transformation/transformation.rest 2010-01-13 11:45:48 UTC (rev 1800) +++ pyplusplus_dev/docs/documentation/functions/transformation/transformation.rest 2010-01-13 12:05:21 UTC (rev 1801) @@ -97,6 +97,7 @@ from_address.rest input_static_matrix.rest output_static_matrix.rest + inout_static_matrix.rest Added: pyplusplus_dev/pyplusplus/code_repository/indexing_suite/registry_utils_header.py =================================================================== --- pyplusplus_dev/pyplusplus/code_repository/indexing_suite/registry_utils_header.py (rev 0) +++ pyplusplus_dev/pyplusplus/code_repository/indexing_suite/registry_utils_header.py 2010-01-13 12:05:21 UTC (rev 1801) @@ -0,0 +1,55 @@ +# Copyright 2004-2008 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) + +""" +This file contains indexing suite v2 code +""" + +file_name = "indexing_suite/registry_utils.hpp" + +code = """// Header file registry_utils.hpp +// +// provides few convenience functions for dealing with boost:python registry +// +// Copyright (c) 2010 Roman Yakovenko +// +// Use, modification and distribution is subject to 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) +// +// History +// ======= +// 2010/01/12 Roman File creation +// + +#ifndef REGISTRY_UTILS_12_01_2010_HPP +#define REGISTRY_UTILS_12_01_2010_HPP + +#include <boost/config.hpp> +#include "boost/python.hpp" +#include "boost/python/converter/registry.hpp" + +namespace boost{ namespace python{ namespace registry{ namespace utils{ + +template<class T> +bool is_registered(){ + namespace bpl = boost::python; + bpl::handle<> class_obj( bpl::objects::registered_class_object( bpl::type_id< T >())); + return class_obj.get() ? true : false; +} + +template< class T > +void register_alias( const char* name ){ + namespace bpl = boost::python; + bpl::handle<> class_obj( bpl::objects::registered_class_object( bpl::type_id< T >())); + boost::python::scope().attr( name ) = bpl::object( class_obj ); +} + +}}}} + +#endif // REGISTRY_UTILS_12_01_2010_HPP + + +""" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2010-01-14 08:50:30
|
Revision: 1802 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1802&view=rev Author: roman_yakovenko Date: 2010-01-14 08:50:23 +0000 (Thu, 14 Jan 2010) Log Message: ----------- integrating input_static_array FT Modified Paths: -------------- pyplusplus_dev/docs/documentation/functions/transformation/transformation.rest pyplusplus_dev/pyplusplus/function_transformers/transformer.py pyplusplus_dev/unittests/test_all.py Added Paths: ----------- pyplusplus_dev/docs/documentation/functions/transformation/inout_static_array.rest pyplusplus_dev/unittests/data/ft_inout_static_array_to_be_exported.hpp pyplusplus_dev/unittests/ft_inout_static_array_tester.py Added: pyplusplus_dev/docs/documentation/functions/transformation/inout_static_array.rest =================================================================== --- pyplusplus_dev/docs/documentation/functions/transformation/inout_static_array.rest (rev 0) +++ pyplusplus_dev/docs/documentation/functions/transformation/inout_static_array.rest 2010-01-14 08:50:23 UTC (rev 1802) @@ -0,0 +1,72 @@ +==================================== +``inout_static_array`` transformer +==================================== + +---------- +Definition +---------- + +``inout_static_array`` transformer is a combination of :doc:`input <input_static_array>` +and :doc:`output <output_static_array>` transformers. +It allows to call a C++ function, which takes an array using Python ``list`` class + +"inout_static_array" transformer takes as first argument name or index of the +original function argument. The argument should have "array" or "pointer" type. +The second argument specifies the array size. + +------- +Example +------- + +.. code-block:: c++ + + int sum_and_fill( int v[3], int value ){ + int result = v[0] + v[1] + v[2]; + v[0] = value; + v[1] = value; + v[2] = value; + return result; + } + +In order to expose ``sum_and_fill`` function we need to create a small wrapper. +The following :doc:`Py++ <../../../pyplusplus>` code does it for you: + + .. code-block:: python + + from pyplusplus import module_builder + from pyplusplus import function_transformers as FT + + mb = module_builder.module_builder_t( ... ) + sum_and_fill = mb.free_fun( 'sum_and_fill' ) + sum_and_fill.add_transformation( ft.inout_static_array('v', 3) ) + +What you see below is the relevant pieces of generated code: + + .. code-block:: c++ + + static boost::python::tuple sum_and_fill_2dd285a3344dbf7d71ffb7c78dd614c5( boost::python::object v, int value ){ + int native_v[3]; + boost::python::list py_v; + pyplus_conv::ensure_uniform_sequence< int >( v, 3 ); + pyplus_conv::copy_sequence( v, pyplus_conv::array_inserter( native_v, 3 ) ); + int result = ::sum_and_fill(native_v, value); + pyplus_conv::copy_container( native_v, native_v + 3, pyplus_conv::list_inserter( py_v ) ); + return bp::make_tuple( result, py_v ); + } + + BOOST_PYTHON_MODULE(ft_inout_static_array){ + { //::ft::sum_and_fill + + typedef boost::python::tuple ( *sum_and_fill_function_type )( boost::python::object,int ); + + bp::def( + "sum_and_fill" + , sum_and_fill_function_type( &sum_and_fill_2dd285a3344dbf7d71ffb7c78dd614c5 ) + , ( bp::arg("v"), bp::arg("value") ) ); + } + } + +.. _`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/functions/transformation/transformation.rest =================================================================== --- pyplusplus_dev/docs/documentation/functions/transformation/transformation.rest 2010-01-13 12:05:21 UTC (rev 1801) +++ pyplusplus_dev/docs/documentation/functions/transformation/transformation.rest 2010-01-14 08:50:23 UTC (rev 1802) @@ -92,6 +92,7 @@ modify_type.rest input_static_array.rest output_static_array.rest + inout_static_array.rest transfer_ownership.rest input_c_buffer.rest from_address.rest Modified: pyplusplus_dev/pyplusplus/function_transformers/transformer.py =================================================================== --- pyplusplus_dev/pyplusplus/function_transformers/transformer.py 2010-01-13 12:05:21 UTC (rev 1801) +++ pyplusplus_dev/pyplusplus/function_transformers/transformer.py 2010-01-14 08:50:23 UTC (rev 1802) @@ -39,7 +39,7 @@ found = filter( lambda arg: arg.name == reference, self.function.arguments ) if len( found ) == 1: return found[0] - raise RuntimeError( "Argument with %s was not found" % reference ) + raise RuntimeError( "Argument with name \"%s\" was not found" % reference ) else: assert isinstance( reference, int ) if transformer_t.USE_1_BASED_INDEXING: Added: pyplusplus_dev/unittests/data/ft_inout_static_array_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/ft_inout_static_array_to_be_exported.hpp (rev 0) +++ pyplusplus_dev/unittests/data/ft_inout_static_array_to_be_exported.hpp 2010-01-14 08:50:23 UTC (rev 1802) @@ -0,0 +1,55 @@ +// Copyright 2004-2008 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 __ft_inout_static_array_to_be_exported_hpp__ +#define __ft_inout_static_array_to_be_exported_hpp__ + +#include <cmath> +#include <string> +#include <iostream> + + +int sum_and_fill( int v[3], int value ){ + int result = v[0] + v[1] + v[2]; + v[0] = value; + v[1] = value; + v[2] = value; + return result; +} + +struct point3d_t{ + + point3d_t() + : x( 0 ), y(0), z(0) + {} + + int initialize( int v[3] ){ + x = v[0]; + y = v[1]; + z = v[2]; + return x*y*z; + } + + virtual void position( int v[3] ){ + v[0] = x; + v[1] = y; + v[2] = z; + } + + void swap( int v[3] ){ + std::swap( x, v[0] ); + std::swap( y, v[1] ); + std::swap( z, v[2] ); + } + + virtual void swap_derived( int v[3] ){ + this->swap( v ); + } + + int x, y, z; +}; + + +#endif//__ft_inout_static_array_to_be_exported_hpp__ Added: pyplusplus_dev/unittests/ft_inout_static_array_tester.py =================================================================== --- pyplusplus_dev/unittests/ft_inout_static_array_tester.py (rev 0) +++ pyplusplus_dev/unittests/ft_inout_static_array_tester.py 2010-01-14 08:50:23 UTC (rev 1802) @@ -0,0 +1,70 @@ +# Copyright 2004-2008 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 + + +def remove_const_ref(type): + """Converts "T const&" into "T &" """ + if declarations.type_traits.is_reference(type): + t = declarations.cpptypes.reference_t(declarations.type_traits.remove_const(type.base)) + return t + return type + + +class tester_t(fundamental_tester_base.fundamental_tester_base_t): + EXTENSION_NAME = 'ft_inout_static_array' + + 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.calldefs().create_with_signature = True + + sum_and_fill = mb.global_ns.calldef( 'sum_and_fill' ) + sum_and_fill.add_transformation( ft.inout_static_array( 'v', 3 ) ) + + point3d = mb.class_( 'point3d_t' ) + point3d.add_wrapper_code( '' ) + + swap = point3d.calldefs( lambda d: 'swap' in d.name ) + swap.add_transformation( ft.inout_static_array( 'v', 3 ) ) + + + point3d.mem_fun( 'initialize' ).add_transformation( ft.input_static_array(0, size=3) ) + point3d.mem_fun( 'position' ).add_transformation( ft.output_static_array(0, size=3) ) + + def run_tests(self, module): + """Run the actual unit tests. + """ + point3d = module.point3d_t() + result = point3d.initialize( [ 1,2,3 ] ) + self.failUnless( result== 1*2*3 and point3d.x == 1 and point3d.y==2 and point3d.z==3 ) + self.failUnless( [1,2,3] == point3d.position() ) + + self.failUnless( ( 12, [10,10,10] ) == module.sum_and_fill( [2,4,6], 10 ) ) + self.failUnless( [1,2,3] == point3d.swap( [4,5,6] ) + and [4,5,6] == point3d.position() ) + +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 2010-01-13 12:05:21 UTC (rev 1801) +++ pyplusplus_dev/unittests/test_all.py 2010-01-14 08:50:23 UTC (rev 1802) @@ -125,6 +125,7 @@ import ft_input_static_matrix_tester import ft_output_static_matrix_tester import ft_inout_static_matrix_tester +import ft_inout_static_array_tester testers = [ algorithms_tester @@ -238,6 +239,7 @@ , ft_input_static_matrix_tester , ft_output_static_matrix_tester , ft_inout_static_matrix_tester + , ft_inout_static_array_tester # , ogre_generate_tester too much time ] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2010-01-14 10:18:06
|
Revision: 1803 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1803&view=rev Author: roman_yakovenko Date: 2010-01-14 10:17:58 +0000 (Thu, 14 Jan 2010) Log Message: ----------- fix code generation for static array properties Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/member_variable.py pyplusplus_dev/unittests/data/member_variables_to_be_exported.cpp pyplusplus_dev/unittests/data/member_variables_to_be_exported.hpp pyplusplus_dev/unittests/member_variables_tester.py Modified: pyplusplus_dev/pyplusplus/code_creators/member_variable.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2010-01-14 08:50:23 UTC (rev 1802) +++ pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2010-01-14 10:17:58 UTC (rev 1803) @@ -434,7 +434,6 @@ class array_mv_wrapper_t( code_creator.code_creator_t , declaration_based.declaration_based_t ): """registers array class""" - def __init__(self, variable ): code_creator.code_creator_t.__init__( self ) declaration_based.declaration_based_t.__init__( self, declaration=variable) @@ -463,9 +462,12 @@ @property def wrapper_creator_type(self): - return declarations.free_function_type_t( - return_type=self.wrapper_type - , arguments_types=[self.wrapped_class_type] ) + if self.declaration.type_qualifiers.has_static: + return declarations.free_function_type_t( return_type=self.wrapper_type ) + else: + return declarations.free_function_type_t( + return_type=self.wrapper_type + , arguments_types=[self.wrapped_class_type] ) @property def wrapper_creator_name(self): @@ -475,15 +477,21 @@ def wrapper_creator_full_name(self): return '::'.join( [self.parent.full_name, self.wrapper_creator_name] ) - def _create_impl( self ): - tmpl = os.linesep.join([ - "static %(wrapper_type)s" - , "%(wrapper_creator_name)s( %(wrapped_class_type)s inst ){" - , self.indent( "return %(wrapper_type)s( inst.%(mem_var_ref)s );" ) - , "}" - ]) + def _create_impl( self ): + tmpl = [ "static %(wrapper_type)s" ] + if self.declaration.type_qualifiers.has_static: + tmpl.append( "%(wrapper_creator_name)s(){" ) + tmpl.append( self.indent( "return %(wrapper_type)s( %(parent_class_type)s::%(mem_var_ref)s );" ) ) + else: + tmpl.append( "%(wrapper_creator_name)s( %(wrapped_class_type)s inst ){" ) + tmpl.append( self.indent( "return %(wrapper_type)s( inst.%(mem_var_ref)s );" ) ) + tmpl.append( "}" ) + + tmpl = os.linesep.join( tmpl ) + return tmpl % { 'wrapper_type' : self.wrapper_type.decl_string + , 'parent_class_type' : self.parent.declaration.partial_decl_string , 'wrapper_creator_name' : self.wrapper_creator_name , 'wrapped_class_type' : self.wrapped_class_type.decl_string , 'mem_var_ref' : self.declaration.name Modified: pyplusplus_dev/unittests/data/member_variables_to_be_exported.cpp =================================================================== --- pyplusplus_dev/unittests/data/member_variables_to_be_exported.cpp 2010-01-14 08:50:23 UTC (rev 1802) +++ pyplusplus_dev/unittests/data/member_variables_to_be_exported.cpp 2010-01-14 10:17:58 UTC (rev 1803) @@ -8,6 +8,7 @@ namespace member_variables{ const array_t::variable_t array_t::vars[] = { array_t::variable_t(), array_t::variable_t(), array_t::variable_t() }; +array_t::variable_t array_t::vars_nonconst[] = { array_t::variable_t(), array_t::variable_t(), array_t::variable_t() }; int point::instance_count = 0; const point::color point::default_color = point::red; Modified: pyplusplus_dev/unittests/data/member_variables_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/member_variables_to_be_exported.hpp 2010-01-14 08:50:23 UTC (rev 1802) +++ pyplusplus_dev/unittests/data/member_variables_to_be_exported.hpp 2010-01-14 10:17:58 UTC (rev 1803) @@ -66,6 +66,7 @@ } static const variable_t vars[3]; + static variable_t vars_nonconst[3]; int ivars[10]; int ivars2[10]; }; Modified: pyplusplus_dev/unittests/member_variables_tester.py =================================================================== --- pyplusplus_dev/unittests/member_variables_tester.py 2010-01-14 08:50:23 UTC (rev 1802) +++ pyplusplus_dev/unittests/member_variables_tester.py 2010-01-14 10:17:58 UTC (rev 1803) @@ -106,10 +106,17 @@ array.ivars[index] = index * index self.failUnless( array.get_ivars_item( index ) == index * index ) - self.failUnless( len( array.vars ) == 3 ) - for i in range( len( array.vars ) ): - self.failUnless( array.vars[i].value == -9 ) + #~ import pdb + #~ pdb.set_trace() + self.failUnless( len( module.array_t.vars ) == 3 ) + for i in range( len( module.array_t.vars ) ): + self.failUnless( module.array_t.vars[i].value == -9 ) + + self.failUnless( len( module.array_t.vars_nonconst ) == 3 ) + for i in range( len( module.array_t.vars_nonconst ) ): + self.failUnless( module.array_t.vars_nonconst[i].value == -9 ) + def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2010-01-14 12:55:02
|
Revision: 1804 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1804&view=rev Author: roman_yakovenko Date: 2010-01-14 12:54:55 +0000 (Thu, 14 Jan 2010) Log Message: ----------- implement PY_SIGNATURE functionality Modified Paths: -------------- pyplusplus_dev/environment.py pyplusplus_dev/pyplusplus/code_repository/call_policies.py pyplusplus_dev/pyplusplus/code_repository/return_range.py Modified: pyplusplus_dev/environment.py =================================================================== --- pyplusplus_dev/environment.py 2010-01-14 10:17:58 UTC (rev 1803) +++ pyplusplus_dev/environment.py 2010-01-14 12:54:55 UTC (rev 1804) @@ -32,7 +32,7 @@ if 'roman' in getpass.getuser(): if sys.platform == 'win32': scons.suffix = '.pyd' - scons.ccflags = ['/MD', '/EHsc', '/GR', '/Zc:wchar_t', '/Zc:forScope', '-DBOOST_PYTHON_NO_PY_SIGNATURES' ] + scons.ccflags = ['/MD', '/EHsc', '/GR', '/Zc:wchar_t', '/Zc:forScope' ] boost.libs = [ r'e:\dev\boost_svn\bin.v2\libs\python\build\msvc-9.0\release\threading-multi' ] boost.include = 'e:/dev/boost_svn' python.libs = 'c:/program files/python26/libs' @@ -41,14 +41,14 @@ os.nice( 20 ) print 'test process niceness: 20' scons.suffix = '.so' - scons.ccflags = ['-DBOOST_PYTHON_NO_PY_SIGNATURES' ] + scons.ccflags = [] boost.libs = ['/home/roman/include/libs' ] boost.include = '/home/roman/boost_svn' python.include = '/usr/include/python2.6' elif 'root' == getpass.getuser(): if sys.platform == 'win32': scons.suffix = '.pyd' - scons.ccflags = ['/MD', '/EHsc', '/GR', '/Zc:wchar_t', '/Zc:forScope', '-DBOOST_PYTHON_NO_PY_SIGNATURES' ] + scons.ccflags = ['/MD', '/EHsc', '/GR', '/Zc:wchar_t', '/Zc:forScope' ] boost.libs = [ 'd:/dev/boost_svn/bin.v2/libs/python/build/msvc-7.1/release/threading-multi' ] boost.include = 'd:/dev/boost_svn' python.libs = 'e:/python25/libs' Modified: pyplusplus_dev/pyplusplus/code_repository/call_policies.py =================================================================== --- pyplusplus_dev/pyplusplus/code_repository/call_policies.py 2010-01-14 10:17:58 UTC (rev 1803) +++ pyplusplus_dev/pyplusplus/code_repository/call_policies.py 2010-01-14 12:54:55 UTC (rev 1804) @@ -161,6 +161,11 @@ MemoryManager::deallocate_array( arr ); return bpl::incref( bpl::tuple( list_ ).ptr() ); } + + static PyTypeObject const *get_pytype(){ + return &PyTuple_Type; + } + }; } Modified: pyplusplus_dev/pyplusplus/code_repository/return_range.py =================================================================== --- pyplusplus_dev/pyplusplus/code_repository/return_range.py 2010-01-14 10:17:58 UTC (rev 1803) +++ pyplusplus_dev/pyplusplus/code_repository/return_range.py 2010-01-14 12:54:55 UTC (rev 1804) @@ -34,8 +34,8 @@ namespace detail{ -struct return_raw_data_ref{ - +struct return_raw_data_ref +{ template <class T> struct apply{ @@ -57,10 +57,12 @@ return PyCObject_FromVoidPtr( data, NULL ); } } + + static PyTypeObject const * get_pytype(){ + return &PyCObject_Type; + } }; - }; - }; } //detail This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2010-01-31 09:02:14
|
Revision: 1824 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1824&view=rev Author: roman_yakovenko Date: 2010-01-31 09:02:08 +0000 (Sun, 31 Jan 2010) Log Message: ----------- porting tests to x86_64 architecture Modified Paths: -------------- pyplusplus_dev/environment.py pyplusplus_dev/unittests/indexing_suites_v2_bug_tester.py Modified: pyplusplus_dev/environment.py =================================================================== --- pyplusplus_dev/environment.py 2010-01-31 08:02:15 UTC (rev 1823) +++ pyplusplus_dev/environment.py 2010-01-31 09:02:08 UTC (rev 1824) @@ -1,6 +1,7 @@ import os import sys import getpass +import platform this_module_dir_path = os.path.abspath ( os.path.dirname( sys.modules[__name__].__file__) ) @@ -16,11 +17,12 @@ include = '' class gccxml: - gccxml_09_path = os.path.join( this_module_dir_path, '..', 'gccxml_bin', 'v09', sys.platform, 'bin' ) - gccxml_path = gccxml_09_path + gccxml_path = os.path.join( this_module_dir_path, '..', 'gccxml_bin', 'v09', platform.system(), platform.machine(), 'bin' ) + if not os.path.exists( gccxml_path ): + gccxml_path = os.path.join( this_module_dir_path, '..', 'gccxml_bin', 'v09', sys.platform, 'bin' ) + gccxml_version = '__GCCXML_09__' - executable = gccxml_path class scons: @@ -42,7 +44,7 @@ print 'test process niceness: 20' scons.suffix = '.so' scons.ccflags = [] - boost.libs = ['/home/roman/include/libs' ] + boost.libs = ['/home/roman/include/libs', '/home/roman/include/lib' ] boost.include = '/home/roman/boost_svn' python.include = '/usr/include/python2.6' elif 'root' == getpass.getuser(): Modified: pyplusplus_dev/unittests/indexing_suites_v2_bug_tester.py =================================================================== --- pyplusplus_dev/unittests/indexing_suites_v2_bug_tester.py 2010-01-31 08:02:15 UTC (rev 1823) +++ pyplusplus_dev/unittests/indexing_suites_v2_bug_tester.py 2010-01-31 09:02:08 UTC (rev 1824) @@ -11,8 +11,12 @@ from pyplusplus import code_creators if 'linux' in sys.platform: - import dl - sys.setdlopenflags(dl.RTLD_NOW | dl.RTLD_GLOBAL) + try: + from ctypes import RTLD_NOW, RTLD_GLOBAL + except ImportError: + RTLD_NOW = 2 + RTLD_GLOBAL = 256 + sys.setdlopenflags(RTLD_NOW | RTLD_GLOBAL) class tester_t(fundamental_tester_base.fundamental_tester_base_t): def __init__( self, *args ): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2010-03-21 07:24:35
|
Revision: 1830 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1830&view=rev Author: roman_yakovenko Date: 2010-03-21 07:24:29 +0000 (Sun, 21 Mar 2010) Log Message: ----------- adding ability to expose some protected variables Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/member_variable.py pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.cpp pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.hpp pyplusplus_dev/unittests/indexing_suites2_support_tester.py pyplusplus_dev/unittests/member_variables_protected_tester.py pyplusplus_dev/unittests/test_all.py Modified: pyplusplus_dev/pyplusplus/code_creators/member_variable.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2010-03-21 07:13:52 UTC (rev 1829) +++ pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2010-03-21 07:24:29 UTC (rev 1830) @@ -437,8 +437,39 @@ def __init__(self, variable ): code_creator.code_creator_t.__init__( self ) declaration_based.declaration_based_t.__init__( self, declaration=variable) + self.__is_protected = bool( variable.access_type == declarations.ACCESS_TYPES.PROTECTED ) @property + def public_accessor_name(self): + return "pyplusplus_%s_accessor" % self.declaration.name + + def generate_public_accessor( self ): + tmpl = os.linesep.join([ + "%(static)s%(const_item_type)s%(item_type)s* %(accessor_name)s()%(const_function)s{" + , " return %(name)s;" + , "}" + ]) + constness = '' + const_function = '' + if declarations.is_const( self.declaration.type ): + constness = 'const ' + const_function = ' const' + + static = '' + if self.declaration.type_qualifiers.has_static: + static = 'static ' + const_function = '' + + return tmpl % { + 'static' : static + , 'const_item_type' : constness + , 'item_type' : declarations.array_item_type( self.declaration.type ).decl_string + , 'accessor_name': self.public_accessor_name + , 'name' : self.declaration.name + , 'const_function' : const_function + } + + @property def wrapper_type( self ): tmpl = "%(namespace)s::%(constness)sarray_1_t< %(item_type)s, %(array_size)d>" @@ -455,7 +486,10 @@ @property def wrapped_class_type( self ): - wrapped_cls_type = declarations.declarated_t( self.declaration.parent ) + if self.__is_protected: + wrapped_cls_type = declarations.dummy_type_t( self.parent.full_name ) + else: + wrapped_cls_type = declarations.declarated_t( self.declaration.parent ) if declarations.is_const( self.declaration.type ): wrapped_cls_type = declarations.const_t( wrapped_cls_type ) return declarations.reference_t( wrapped_cls_type ) @@ -477,26 +511,40 @@ def wrapper_creator_full_name(self): return '::'.join( [self.parent.full_name, self.wrapper_creator_name] ) - def _create_impl( self ): + def _create_impl( self ): + result = [] + if self.__is_protected: + result.append( self.generate_public_accessor() ) + result.append( '' ) + tmpl = [ "static %(wrapper_type)s" ] if self.declaration.type_qualifiers.has_static: tmpl.append( "%(wrapper_creator_name)s(){" ) - tmpl.append( self.indent( "return %(wrapper_type)s( %(parent_class_type)s::%(mem_var_ref)s );" ) ) + if self.__is_protected: + tmpl.append( self.indent( "return %(wrapper_type)s( %(wrapped_class_type_only)s::%(public_accessor_name)s() );" ) ) + else: + tmpl.append( self.indent( "return %(wrapper_type)s( %(parent_class_type)s::%(mem_var_ref)s );" ) ) else: tmpl.append( "%(wrapper_creator_name)s( %(wrapped_class_type)s inst ){" ) - tmpl.append( self.indent( "return %(wrapper_type)s( inst.%(mem_var_ref)s );" ) ) + if self.__is_protected: + tmpl.append( self.indent( "return %(wrapper_type)s( inst.%(public_accessor_name)s() );" ) ) + else: + tmpl.append( self.indent( "return %(wrapper_type)s( inst.%(mem_var_ref)s );" ) ) + tmpl.append( "}" ) - + tmpl = os.linesep.join( tmpl ) - - return tmpl % { - 'wrapper_type' : self.wrapper_type.decl_string - , 'parent_class_type' : self.parent.declaration.partial_decl_string - , 'wrapper_creator_name' : self.wrapper_creator_name - , 'wrapped_class_type' : self.wrapped_class_type.decl_string - , 'mem_var_ref' : self.declaration.name - } + result.append( tmpl % { 'wrapper_type' : self.wrapper_type.decl_string + , 'parent_class_type' : self.parent.declaration.partial_decl_string + , 'wrapper_creator_name' : self.wrapper_creator_name + , 'wrapped_class_type' : self.wrapped_class_type.decl_string + , 'wrapped_class_type_only' : self.parent.full_name + , 'mem_var_ref' : self.declaration.name + , 'public_accessor_name' : self.public_accessor_name + } ) + return os.linesep.join( result ) + def _get_system_files_impl( self ): return [code_repository.array_1.file_name] Modified: pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.cpp =================================================================== --- pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.cpp 2010-03-21 07:13:52 UTC (rev 1829) +++ pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.cpp 2010-03-21 07:24:29 UTC (rev 1830) @@ -9,10 +9,10 @@ const array_t::variable_t array_t::vars[] = { array_t::variable_t(), array_t::variable_t(), array_t::variable_t() }; array_t::variable_t array_t::vars_nonconst[] = { array_t::variable_t(), array_t::variable_t(), array_t::variable_t() }; - +/* int point::instance_count = 0; const point::color point::default_color = point::red; - +*/ unsigned int get_a(const bit_fields_t& inst){ return inst.a; } @@ -24,7 +24,7 @@ unsigned int get_b(const bit_fields_t& inst){ return inst.b; } - +/* namespace pointers{ std::auto_ptr<tree_node_t> create_tree(){ @@ -50,5 +50,5 @@ int xxx = 1997; int* image_t::none_image = &xxx; } - +*/ } Modified: pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.hpp 2010-03-21 07:13:52 UTC (rev 1829) +++ pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.hpp 2010-03-21 07:24:29 UTC (rev 1830) @@ -10,7 +10,7 @@ #include <iostream> namespace member_variables{ - +/* struct point{ enum color{ red, green, blue }; @@ -35,7 +35,7 @@ static int instance_count; static const color default_color; }; - +*/ struct bit_fields_t{ friend unsigned int get_a(const bit_fields_t& inst); friend void set_a( bit_fields_t& inst, unsigned int new_value ); @@ -69,13 +69,13 @@ int get_ivars_item( int index ){ return ivars[index]; } - +protected: static const variable_t vars[3]; static variable_t vars_nonconst[3]; int ivars[10]; int ivars2[10]; }; - +/* namespace pointers{ struct tree_node_t; @@ -193,7 +193,7 @@ void * userData; }; -} +}*/ } #endif//__member_variables_protected_to_be_exported_hpp__ Modified: pyplusplus_dev/unittests/indexing_suites2_support_tester.py =================================================================== --- pyplusplus_dev/unittests/indexing_suites2_support_tester.py 2010-03-21 07:13:52 UTC (rev 1829) +++ pyplusplus_dev/unittests/indexing_suites2_support_tester.py 2010-03-21 07:24:29 UTC (rev 1830) @@ -13,9 +13,9 @@ class tester_t(fundamental_tester_base.fundamental_tester_base_t): EXTENSION_NAME = 'indexing_suites2_support' - + def __init__( self, *args ): - fundamental_tester_base.fundamental_tester_base_t.__init__( + fundamental_tester_base.fundamental_tester_base_t.__init__( self , tester_t.EXTENSION_NAME , indexing_suite_version=2 @@ -26,22 +26,18 @@ fvector = declarations.remove_declarated( fvector.type ) fvector.indexing_suite.call_policies \ = module_builder.call_policies.return_internal_reference() - + def run_tests( self, module): v = module.foo_vector() f = module.foo() f.bar = 0 v.append(f) self.failUnless( v[0].bar == 0 ) - v[0].bar = 10 + v[0].bar = 10 self.failUnless( v[0].bar == 10 ) - x = module.create_set_strings() - self.failUnless( len(x) == 0 ) - x = module.ffff() - self.failUnless( len(x) == 0 ) - + def create_suite(): - suite = unittest.TestSuite() + suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) return suite Modified: pyplusplus_dev/unittests/member_variables_protected_tester.py =================================================================== --- pyplusplus_dev/unittests/member_variables_protected_tester.py 2010-03-21 07:13:52 UTC (rev 1829) +++ pyplusplus_dev/unittests/member_variables_protected_tester.py 2010-03-21 07:24:29 UTC (rev 1830) @@ -9,7 +9,10 @@ import unittest import fundamental_tester_base from pygccxml import declarations +from pyplusplus import decl_wrappers +decl_wrappers.variable_t.EXPOSE_PROTECTED_VARIABLES = True + class tester_t(fundamental_tester_base.fundamental_tester_base_t): EXTENSION_NAME = 'member_variables_protected' @@ -19,22 +22,13 @@ , tester_t.EXTENSION_NAME , *args ) - def is_protected_var( self, var ): - if not isinstance( var.parent, declarations.class_t ): - return False - if var.access_type == declarations.ACCESS_TYPES.PROTECTED: - return True - else: - return False - def customize(self, mb ): - mb.variables( self.is_protected_var ).use_make_functions = True - mb.variable( 'prefered_color' ).alias = 'PreferedColor' + #mb.variable( 'prefered_color' ).alias = 'PreferedColor' mb.classes().always_expose_using_scope = True - image = mb.class_( 'image_t' ) - image.var( 'data' ).expose_address = True - image.var( 'none_image' ).expose_address = True - mb.class_( 'Andy' ).var('userData').expose_address = True + #image = mb.class_( 'image_t' ) + #image.var( 'data' ).expose_address = True + #image.var( 'none_image' ).expose_address = True + #mb.class_( 'Andy' ).var('userData').expose_address = True def change_default_color( self, module ): module.point.default_color = module.point.color.blue @@ -47,17 +41,17 @@ bf.b = value def run_tests(self, module): - self.failIfRaisesAny( module.point ) - xypoint = module.point() - self.failUnless( module.point.instance_count == 1) - self.failUnless( xypoint.instance_count == 1) - self.failUnless( module.point.default_color == module.point.color.red) - self.failUnless( xypoint.default_color == module.point.color.red) - self.failUnless( xypoint.x == -1) - self.failUnless( xypoint.y == 2 ) - self.failUnless( xypoint.PreferedColor == xypoint.color.blue ) - self.failUnlessRaises( Exception, self.change_default_color ) - self.failUnlessRaises( Exception, self.change_prefered_color ) + #self.failIfRaisesAny( module.point ) + #xypoint = module.point() + #self.failUnless( module.point.instance_count == 1) + #self.failUnless( xypoint.instance_count == 1) + #self.failUnless( module.point.default_color == module.point.color.red) + #self.failUnless( xypoint.default_color == module.point.color.red) + #self.failUnless( xypoint.x == -1) + #self.failUnless( xypoint.y == 2 ) + #self.failUnless( xypoint.PreferedColor == xypoint.color.blue ) + #self.failUnlessRaises( Exception, self.change_default_color ) + #self.failUnlessRaises( Exception, self.change_prefered_color ) bf = module.bit_fields_t() module.set_a( bf, 1 ) @@ -65,43 +59,43 @@ self.failUnless( bf.b == module.get_b( bf ) ) self.failIfNotRaisesAny( lambda: self.set_b( bf, 23 ) ) - tree = module.create_tree() - self.failUnless( tree.parent is None ) - self.failUnless( tree.data.value == 0 ) - self.failUnless( tree.right is None ) - self.failUnless( tree.left ) - self.failUnless( tree.left.data.value == 1 ) + #tree = module.create_tree() + #self.failUnless( tree.parent is None ) + #self.failUnless( tree.data.value == 0 ) + #self.failUnless( tree.right is None ) + #self.failUnless( tree.left ) + #self.failUnless( tree.left.data.value == 1 ) - tree.right = module.create_tree() - self.failUnless( tree.right.parent is None ) - self.failUnless( tree.right.data.value == 0 ) - self.failUnless( tree.right.right is None ) - self.failUnless( tree.right.left ) - self.failUnless( tree.right.left.data.value == 1 ) + #tree.right = module.create_tree() + #self.failUnless( tree.right.parent is None ) + #self.failUnless( tree.right.data.value == 0 ) + #self.failUnless( tree.right.right is None ) + #self.failUnless( tree.right.left ) + #self.failUnless( tree.right.left.data.value == 1 ) - mem_var_str = module.mem_var_str_t() - mem_var_str.identity( module.mem_var_str_t.class_name ) + #mem_var_str = module.mem_var_str_t() + #mem_var_str.identity( module.mem_var_str_t.class_name ) - image = module.image_t() + #image = module.image_t() - data_type = ctypes.POINTER( ctypes.c_int ) - data = data_type.from_address( image.data ) - for j in range(5): - self.failUnless( j == data[j] ) - - int_array = ctypes.c_int * 5 - array = int_array() - for i in range( 5 ): - array[i] = 2*i - image.data = ctypes.addressof(array) - data = data_type.from_address( image.data ) - for j in range(5): - self.failUnless( j*2 == data[j] ) - - data_type = ctypes.POINTER( ctypes.c_int ) - data = data_type.from_address( module.image_t.none_image ) - self.failUnless( 1997 == data.contents.value ) + #data_type = ctypes.POINTER( ctypes.c_int ) + #data = data_type.from_address( image.data ) + #for j in range(5): + #self.failUnless( j == data[j] ) + #int_array = ctypes.c_int * 5 + #array = int_array() + #for i in range( 5 ): + #array[i] = 2*i + #image.data = ctypes.addressof(array) + #data = data_type.from_address( image.data ) + #for j in range(5): + #self.failUnless( j*2 == data[j] ) + + #data_type = ctypes.POINTER( ctypes.c_int ) + #data = data_type.from_address( module.image_t.none_image ) + #self.failUnless( 1997 == data.contents.value ) + array = module.array_t() self.failUnless( len( array.ivars ) == 10 ) @@ -116,8 +110,6 @@ array.ivars[index] = index * index self.failUnless( array.get_ivars_item( index ) == index * index ) - #~ import pdb - #~ pdb.set_trace() self.failUnless( len( module.array_t.vars ) == 3 ) for i in range( len( module.array_t.vars ) ): Modified: pyplusplus_dev/unittests/test_all.py =================================================================== --- pyplusplus_dev/unittests/test_all.py 2010-03-21 07:13:52 UTC (rev 1829) +++ pyplusplus_dev/unittests/test_all.py 2010-03-21 07:24:29 UTC (rev 1830) @@ -126,6 +126,7 @@ import ft_output_static_matrix_tester import ft_inout_static_matrix_tester import ft_inout_static_array_tester +import member_variables_protected_tester testers = [ algorithms_tester @@ -240,6 +241,7 @@ , ft_output_static_matrix_tester , ft_inout_static_matrix_tester , ft_inout_static_array_tester + , member_variables_protected_tester # , ogre_generate_tester too much time ] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2010-03-22 12:32:05
|
Revision: 1831 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1831&view=rev Author: roman_yakovenko Date: 2010-03-22 12:31:59 +0000 (Mon, 22 Mar 2010) Log Message: ----------- protected mem. variables: adding one more use case Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/member_variable.py pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.hpp pyplusplus_dev/unittests/fundamental_tester_base.py Modified: pyplusplus_dev/pyplusplus/code_creators/member_variable.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2010-03-21 07:24:29 UTC (rev 1830) +++ pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2010-03-22 12:31:59 UTC (rev 1831) @@ -627,13 +627,17 @@ def __init__(self, variable ): code_creator.code_creator_t.__init__( self ) declaration_based.declaration_based_t.__init__( self, declaration=variable) + self.__is_protected = bool( variable.access_type == declarations.ACCESS_TYPES.PROTECTED ) def _get_getter_full_name(self): return self.parent.full_name + '::' + 'get_' + self.declaration.name getter_full_name = property( _get_getter_full_name ) def _get_class_inst_type( self ): - return declarations.declarated_t( self.declaration.parent ) + if self.__is_protected: + return declarations.dummy_type_t( self.parent.full_name ) + else: + return declarations.declarated_t( self.declaration.parent ) def _get_exported_var_type( self ): type_ = declarations.remove_reference( self.declaration.type ) @@ -685,7 +689,7 @@ def _create_impl(self): answer = [] - cls_type = algorithm.create_identifier( self, self.declaration.parent.decl_string ) + cls_type = algorithm.create_identifier( self, self._get_class_inst_type().decl_string ) substitutions = dict( type=self._get_exported_var_type().decl_string , class_type=cls_type Modified: pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.hpp 2010-03-21 07:24:29 UTC (rev 1830) +++ pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.hpp 2010-03-22 12:31:59 UTC (rev 1831) @@ -112,7 +112,7 @@ std::auto_ptr<tree_node_t> create_tree(); } - +*/ namespace reference{ enum EFruit{ apple, orange }; @@ -142,7 +142,7 @@ }; } - +/* namespace statics{ struct mem_var_str_t{ Modified: pyplusplus_dev/unittests/fundamental_tester_base.py =================================================================== --- pyplusplus_dev/unittests/fundamental_tester_base.py 2010-03-21 07:24:29 UTC (rev 1830) +++ pyplusplus_dev/unittests/fundamental_tester_base.py 2010-03-22 12:31:59 UTC (rev 1831) @@ -97,7 +97,11 @@ def _create_extension_source_file(self): global LICENSE - mb = module_builder.module_builder_t( [self.__to_be_exported_header] + test_header_cfg \ + = pygccxml.parser.create_cached_source_fc( self.__to_be_exported_header + , self.__generated_source_file_name + '.xml' ) + + mb = module_builder.module_builder_t( [ test_header_cfg ] #, undefine_symbols=['__MINGW32__'] , indexing_suite_version=self.__indexing_suite_version , gccxml_config=autoconfig.cxx_parsers_cfg.gccxml) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2010-04-03 09:59:47
|
Revision: 1833 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1833&view=rev Author: roman_yakovenko Date: 2010-04-03 09:59:41 +0000 (Sat, 03 Apr 2010) Log Message: ----------- rolling back protected variables changes Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/member_variable.py pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py pyplusplus_dev/pyplusplus/messages/warnings_.py pyplusplus_dev/unittests/test_all.py Removed Paths: ------------- pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.cpp pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.hpp pyplusplus_dev/unittests/member_variables_protected_tester.py Modified: pyplusplus_dev/pyplusplus/code_creators/member_variable.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2010-03-25 21:12:47 UTC (rev 1832) +++ pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2010-04-03 09:59:41 UTC (rev 1833) @@ -437,39 +437,8 @@ def __init__(self, variable ): code_creator.code_creator_t.__init__( self ) declaration_based.declaration_based_t.__init__( self, declaration=variable) - self.__is_protected = bool( variable.access_type == declarations.ACCESS_TYPES.PROTECTED ) @property - def public_accessor_name(self): - return "pyplusplus_%s_accessor" % self.declaration.name - - def generate_public_accessor( self ): - tmpl = os.linesep.join([ - "%(static)s%(const_item_type)s%(item_type)s* %(accessor_name)s()%(const_function)s{" - , " return %(name)s;" - , "}" - ]) - constness = '' - const_function = '' - if declarations.is_const( self.declaration.type ): - constness = 'const ' - const_function = ' const' - - static = '' - if self.declaration.type_qualifiers.has_static: - static = 'static ' - const_function = '' - - return tmpl % { - 'static' : static - , 'const_item_type' : constness - , 'item_type' : declarations.array_item_type( self.declaration.type ).decl_string - , 'accessor_name': self.public_accessor_name - , 'name' : self.declaration.name - , 'const_function' : const_function - } - - @property def wrapper_type( self ): tmpl = "%(namespace)s::%(constness)sarray_1_t< %(item_type)s, %(array_size)d>" @@ -486,10 +455,7 @@ @property def wrapped_class_type( self ): - if self.__is_protected: - wrapped_cls_type = declarations.dummy_type_t( self.parent.full_name ) - else: - wrapped_cls_type = declarations.declarated_t( self.declaration.parent ) + wrapped_cls_type = declarations.declarated_t( self.declaration.parent ) if declarations.is_const( self.declaration.type ): wrapped_cls_type = declarations.const_t( wrapped_cls_type ) return declarations.reference_t( wrapped_cls_type ) @@ -511,40 +477,26 @@ def wrapper_creator_full_name(self): return '::'.join( [self.parent.full_name, self.wrapper_creator_name] ) - def _create_impl( self ): - result = [] - if self.__is_protected: - result.append( self.generate_public_accessor() ) - result.append( '' ) - + def _create_impl( self ): tmpl = [ "static %(wrapper_type)s" ] if self.declaration.type_qualifiers.has_static: tmpl.append( "%(wrapper_creator_name)s(){" ) - if self.__is_protected: - tmpl.append( self.indent( "return %(wrapper_type)s( %(wrapped_class_type_only)s::%(public_accessor_name)s() );" ) ) - else: - tmpl.append( self.indent( "return %(wrapper_type)s( %(parent_class_type)s::%(mem_var_ref)s );" ) ) + tmpl.append( self.indent( "return %(wrapper_type)s( %(parent_class_type)s::%(mem_var_ref)s );" ) ) else: tmpl.append( "%(wrapper_creator_name)s( %(wrapped_class_type)s inst ){" ) - if self.__is_protected: - tmpl.append( self.indent( "return %(wrapper_type)s( inst.%(public_accessor_name)s() );" ) ) - else: - tmpl.append( self.indent( "return %(wrapper_type)s( inst.%(mem_var_ref)s );" ) ) - + tmpl.append( self.indent( "return %(wrapper_type)s( inst.%(mem_var_ref)s );" ) ) tmpl.append( "}" ) - + tmpl = os.linesep.join( tmpl ) + + return tmpl % { + 'wrapper_type' : self.wrapper_type.decl_string + , 'parent_class_type' : self.parent.declaration.partial_decl_string + , 'wrapper_creator_name' : self.wrapper_creator_name + , 'wrapped_class_type' : self.wrapped_class_type.decl_string + , 'mem_var_ref' : self.declaration.name + } - result.append( tmpl % { 'wrapper_type' : self.wrapper_type.decl_string - , 'parent_class_type' : self.parent.declaration.partial_decl_string - , 'wrapper_creator_name' : self.wrapper_creator_name - , 'wrapped_class_type' : self.wrapped_class_type.decl_string - , 'wrapped_class_type_only' : self.parent.full_name - , 'mem_var_ref' : self.declaration.name - , 'public_accessor_name' : self.public_accessor_name - } ) - return os.linesep.join( result ) - def _get_system_files_impl( self ): return [code_repository.array_1.file_name] @@ -627,17 +579,13 @@ def __init__(self, variable ): code_creator.code_creator_t.__init__( self ) declaration_based.declaration_based_t.__init__( self, declaration=variable) - self.__is_protected = bool( variable.access_type == declarations.ACCESS_TYPES.PROTECTED ) def _get_getter_full_name(self): return self.parent.full_name + '::' + 'get_' + self.declaration.name getter_full_name = property( _get_getter_full_name ) def _get_class_inst_type( self ): - if self.__is_protected: - return declarations.dummy_type_t( self.parent.full_name ) - else: - return declarations.declarated_t( self.declaration.parent ) + return declarations.declarated_t( self.declaration.parent ) def _get_exported_var_type( self ): type_ = declarations.remove_reference( self.declaration.type ) @@ -689,7 +637,7 @@ def _create_impl(self): answer = [] - cls_type = algorithm.create_identifier( self, self._get_class_inst_type().decl_string ) + cls_type = algorithm.create_identifier( self, self.declaration.parent.decl_string ) substitutions = dict( type=self._get_exported_var_type().decl_string , class_type=cls_type Modified: pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2010-03-25 21:12:47 UTC (rev 1832) +++ pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2010-04-03 09:59:41 UTC (rev 1833) @@ -429,8 +429,6 @@ for member in self.protected_members: if isinstance( member, declarations.calldef_t ): members.append( member ) - elif isinstance( member, declarations.variable_t ) and variable_wrapper.variable_t.EXPOSE_PROTECTED_VARIABLES: - members.append( member ) else: pass Modified: pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py 2010-03-25 21:12:47 UTC (rev 1832) +++ pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py 2010-04-03 09:59:41 UTC (rev 1833) @@ -15,8 +15,6 @@ class variable_t(decl_wrapper.decl_wrapper_t, declarations.variable_t): """defines a set of properties, that will instruct `Py++` how to expose the variable""" - EXPOSE_PROTECTED_VARIABLES = False - def __init__(self, *arguments, **keywords): declarations.variable_t.__init__(self, *arguments, **keywords ) decl_wrapper.decl_wrapper_t.__init__( self ) @@ -216,11 +214,7 @@ # return messages.W1061 % ( str( self ), str( cls ) ) if isinstance( self.parent, declarations.class_t ): if self.access_type != declarations.ACCESS_TYPES.PUBLIC: - if self.access_type == declarations.ACCESS_TYPES.PRIVATE: - return messages.W1039 - else: #protected - if not self.EXPOSE_PROTECTED_VARIABLES: - return messages.W1039 + return messages.W1039 if declarations.is_array( type_ ): item_type = declarations.array_item_type( type_ ) if declarations.is_pointer( item_type ): @@ -243,6 +237,4 @@ explanation.append( messages.W1026 % self.name ) if declarations.is_array( self.type ): explanation.append( messages.W1027 % self.name) - if self.access_type == declarations.ACCESS_TYPES.PROTECTED: - explanation.append( messages.W1066 % self.name) return explanation Modified: pyplusplus_dev/pyplusplus/messages/warnings_.py =================================================================== --- pyplusplus_dev/pyplusplus/messages/warnings_.py 2010-03-25 21:12:47 UTC (rev 1832) +++ pyplusplus_dev/pyplusplus/messages/warnings_.py 2010-04-03 09:59:41 UTC (rev 1833) @@ -257,9 +257,6 @@ 'Use `wrapper_alias` property to change class wrapper alias value' 'Other classes : %s' ) - -W1066 = warning( '`Py++` will generate class wrapper - class contains "%s" - protected member variable' ) - warnings = globals() all_warning_msgs = [] Deleted: pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.cpp =================================================================== --- pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.cpp 2010-03-25 21:12:47 UTC (rev 1832) +++ pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.cpp 2010-04-03 09:59:41 UTC (rev 1833) @@ -1,54 +0,0 @@ -// Copyright 2004-2008 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) - -#include "member_variables_protected_to_be_exported.hpp" - -namespace member_variables{ - -const array_t::variable_t array_t::vars[] = { array_t::variable_t(), array_t::variable_t(), array_t::variable_t() }; -array_t::variable_t array_t::vars_nonconst[] = { array_t::variable_t(), array_t::variable_t(), array_t::variable_t() }; -/* -int point::instance_count = 0; -const point::color point::default_color = point::red; -*/ -unsigned int get_a(const bit_fields_t& inst){ - return inst.a; -} - -void set_a( bit_fields_t& inst, unsigned int new_value ){ - inst.a = new_value; -} - -unsigned int get_b(const bit_fields_t& inst){ - return inst.b; -} -/* -namespace pointers{ - -std::auto_ptr<tree_node_t> create_tree(){ - std::auto_ptr<tree_node_t> root( new tree_node_t() ); - root->data = new data_t(); - root->data->value = 0; - - root->left = new tree_node_t( root.get() ); - root->left->data = new data_t(); - root->left->data->value = 1; - - return root; -} - -} - -namespace statics{ - std::string mem_var_str_t::class_name( "mem_var_str_t" ); -} - - -namespace ctypes{ - int xxx = 1997; - int* image_t::none_image = &xxx; -} -*/ -} Deleted: pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.hpp 2010-03-25 21:12:47 UTC (rev 1832) +++ pyplusplus_dev/unittests/data/member_variables_protected_to_be_exported.hpp 2010-04-03 09:59:41 UTC (rev 1833) @@ -1,199 +0,0 @@ -// Copyright 2004-2008 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 __member_variables_protected_to_be_exported_hpp__ -#define __member_variables_protected_to_be_exported_hpp__ -#include <memory> -#include <string> -#include <iostream> - -namespace member_variables{ -/* -struct point{ - enum color{ red, green, blue }; - - point() - : prefered_color( blue ) - , x( -1 ) - , y( 2 ) - {++instance_count;} - - point( const point& other ) - : prefered_color( other.prefered_color ) - , x( other.x ) - , y( other.y ) - {} - - ~point() - { --instance_count; } -protected: - int x; - int y; - const color prefered_color; - static int instance_count; - static const color default_color; -}; -*/ -struct bit_fields_t{ - friend unsigned int get_a(const bit_fields_t& inst); - friend void set_a( bit_fields_t& inst, unsigned int new_value ); - friend unsigned int get_b(const bit_fields_t& inst); - - bit_fields_t() - : b(28){} -protected: - unsigned int a : 1; - unsigned int : 0; - const unsigned int b : 11; -}; - -unsigned int get_a(const bit_fields_t& inst); -void set_a( bit_fields_t& inst, unsigned int new_value ); -unsigned int get_b(const bit_fields_t& inst); - -struct array_t{ - array_t() - { - for( int i = 0; i < 10; ++i ){ - ivars[i] = -i; - } - } - - struct variable_t{ - variable_t() : value(-9){} - int value; - }; - - int get_ivars_item( int index ){ - return ivars[index]; - } -protected: - static const variable_t vars[3]; - static variable_t vars_nonconst[3]; - int ivars[10]; - int ivars2[10]; -}; -/* -namespace pointers{ - -struct tree_node_t; - -struct data_t{ - friend struct tree_node_t; - friend std::auto_ptr<tree_node_t> create_tree(); - data_t() : value( 201 ) {} -protected: - int value; - static char* reserved; -}; - -struct tree_node_t{ -protected: - data_t *data; - tree_node_t *left; - tree_node_t *right; - const tree_node_t *parent; -public: - tree_node_t(const tree_node_t* parent=0) - : data(0) - , left( 0 ) - , right( 0 ) - , parent( parent ) - {} - - ~tree_node_t(){ - std::cout << "\n~tree_node_t"; - } - friend std::auto_ptr<tree_node_t> create_tree(); -}; - -std::auto_ptr<tree_node_t> create_tree(); - -} -*/ -namespace reference{ - -enum EFruit{ apple, orange }; - -struct fundamental_t{ - fundamental_t( EFruit& fruit, const int& i ) - : m_fruit( fruit ), m_i( i ) - {} -protected: - EFruit& m_fruit; - const int& m_i; -}; - -struct A{}; - - -struct B { - B( A& a_ ): a( a_ ){} -protected: - A& a; -}; - -struct C { - C( A& a_ ): a( a_ ){} -protected: - const A& a; -}; - -} -/* -namespace statics{ - -struct mem_var_str_t{ -protected: - static std::string class_name; -public: - std::string identity(std::string x){ return x; } -}; - -} - -namespace bugs{ -struct allocator_ { - void * (*alloc) (unsigned); - void (*dispose) (void *p); -}; - -typedef struct allocator_ *allocator_t; - -struct faulty { -protected: - allocator_t allocator; -}; - -} - - -namespace ctypes{ - struct image_t{ - image_t(){ - data = new int[5]; - for(int i=0; i<5; i++){ - data[i] = i; - } - } - int* data; - - static int* none_image; - }; - - class Andy{ - protected: - Andy() : userData(NULL) {} - - virtual ~Andy() {} - - public: - void * userData; - }; - -}*/ - -} -#endif//__member_variables_protected_to_be_exported_hpp__ Deleted: pyplusplus_dev/unittests/member_variables_protected_tester.py =================================================================== --- pyplusplus_dev/unittests/member_variables_protected_tester.py 2010-03-25 21:12:47 UTC (rev 1832) +++ pyplusplus_dev/unittests/member_variables_protected_tester.py 2010-04-03 09:59:41 UTC (rev 1833) @@ -1,131 +0,0 @@ -# Copyright 2004-2008 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 ctypes -import unittest -import fundamental_tester_base -from pygccxml import declarations -from pyplusplus import decl_wrappers - -decl_wrappers.variable_t.EXPOSE_PROTECTED_VARIABLES = True - -class tester_t(fundamental_tester_base.fundamental_tester_base_t): - EXTENSION_NAME = 'member_variables_protected' - - def __init__( self, *args ): - fundamental_tester_base.fundamental_tester_base_t.__init__( - self - , tester_t.EXTENSION_NAME - , *args ) - - def customize(self, mb ): - #mb.variable( 'prefered_color' ).alias = 'PreferedColor' - mb.classes().always_expose_using_scope = True - #image = mb.class_( 'image_t' ) - #image.var( 'data' ).expose_address = True - #image.var( 'none_image' ).expose_address = True - #mb.class_( 'Andy' ).var('userData').expose_address = True - - def change_default_color( self, module ): - module.point.default_color = module.point.color.blue - - def change_prefered_color( self, module ): - xypoint = module.point() - xypoint.PreferedColor = module.point.color.blue - - def set_b( self, bf, value ): - bf.b = value - - def run_tests(self, module): - #self.failIfRaisesAny( module.point ) - #xypoint = module.point() - #self.failUnless( module.point.instance_count == 1) - #self.failUnless( xypoint.instance_count == 1) - #self.failUnless( module.point.default_color == module.point.color.red) - #self.failUnless( xypoint.default_color == module.point.color.red) - #self.failUnless( xypoint.x == -1) - #self.failUnless( xypoint.y == 2 ) - #self.failUnless( xypoint.PreferedColor == xypoint.color.blue ) - #self.failUnlessRaises( Exception, self.change_default_color ) - #self.failUnlessRaises( Exception, self.change_prefered_color ) - - bf = module.bit_fields_t() - module.set_a( bf, 1 ) - self.failUnless( 1 == bf.a ) - self.failUnless( bf.b == module.get_b( bf ) ) - self.failIfNotRaisesAny( lambda: self.set_b( bf, 23 ) ) - - #tree = module.create_tree() - #self.failUnless( tree.parent is None ) - #self.failUnless( tree.data.value == 0 ) - #self.failUnless( tree.right is None ) - #self.failUnless( tree.left ) - #self.failUnless( tree.left.data.value == 1 ) - - #tree.right = module.create_tree() - #self.failUnless( tree.right.parent is None ) - #self.failUnless( tree.right.data.value == 0 ) - #self.failUnless( tree.right.right is None ) - #self.failUnless( tree.right.left ) - #self.failUnless( tree.right.left.data.value == 1 ) - - #mem_var_str = module.mem_var_str_t() - #mem_var_str.identity( module.mem_var_str_t.class_name ) - - #image = module.image_t() - - #data_type = ctypes.POINTER( ctypes.c_int ) - #data = data_type.from_address( image.data ) - #for j in range(5): - #self.failUnless( j == data[j] ) - - #int_array = ctypes.c_int * 5 - #array = int_array() - #for i in range( 5 ): - #array[i] = 2*i - #image.data = ctypes.addressof(array) - #data = data_type.from_address( image.data ) - #for j in range(5): - #self.failUnless( j*2 == data[j] ) - - #data_type = ctypes.POINTER( ctypes.c_int ) - #data = data_type.from_address( module.image_t.none_image ) - #self.failUnless( 1997 == data.contents.value ) - - array = module.array_t() - self.failUnless( len( array.ivars ) == 10 ) - - ivars = array.ivars - del array #testing call policies - for i in range(20): - for index in range(10): - self.failUnless( ivars[index] == -index ) - - array = module.array_t() - for index in range( len(array.ivars) ): - array.ivars[index] = index * index - self.failUnless( array.get_ivars_item( index ) == index * index ) - - - self.failUnless( len( module.array_t.vars ) == 3 ) - for i in range( len( module.array_t.vars ) ): - self.failUnless( module.array_t.vars[i].value == -9 ) - - self.failUnless( len( module.array_t.vars_nonconst ) == 3 ) - for i in range( len( module.array_t.vars_nonconst ) ): - self.failUnless( module.array_t.vars_nonconst[i].value == -9 ) - -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 2010-03-25 21:12:47 UTC (rev 1832) +++ pyplusplus_dev/unittests/test_all.py 2010-04-03 09:59:41 UTC (rev 1833) @@ -126,7 +126,7 @@ import ft_output_static_matrix_tester import ft_inout_static_matrix_tester import ft_inout_static_array_tester -import member_variables_protected_tester +import inner_base_class_tester testers = [ algorithms_tester @@ -241,7 +241,7 @@ , ft_output_static_matrix_tester , ft_inout_static_matrix_tester , ft_inout_static_array_tester - , member_variables_protected_tester + , inner_base_class_tester # , ogre_generate_tester too much time ] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2010-04-29 18:39:17
|
Revision: 1840 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1840&view=rev Author: roman_yakovenko Date: 2010-04-29 18:39:11 +0000 (Thu, 29 Apr 2010) Log Message: ----------- adding "__len__" method to set, map and multimap Modified Paths: -------------- pyplusplus_dev/indexing_suite_v2/indexing_suite/map.hpp pyplusplus_dev/indexing_suite_v2/indexing_suite/multimap.hpp pyplusplus_dev/indexing_suite_v2/indexing_suite/set.hpp pyplusplus_dev/pyplusplus/code_repository/indexing_suite/map_header.py pyplusplus_dev/pyplusplus/code_repository/indexing_suite/multimap_header.py pyplusplus_dev/pyplusplus/code_repository/indexing_suite/set_header.py pyplusplus_dev/unittests/indexing_suites2_tester.py Modified: pyplusplus_dev/indexing_suite_v2/indexing_suite/map.hpp =================================================================== --- pyplusplus_dev/indexing_suite_v2/indexing_suite/map.hpp 2010-04-29 05:26:06 UTC (rev 1839) +++ pyplusplus_dev/indexing_suite_v2/indexing_suite/map.hpp 2010-04-29 18:39:11 UTC (rev 1840) @@ -12,6 +12,7 @@ // ======= // 2003/10/28 rmg File creation from algo_selector.hpp // 2008/12/08 Roman Change indexing suite layout +// 2010/04/29 Roman Adding "__len__" method // // $Id: map.hpp,v 1.1.2.6 2004/02/08 18:57:42 raoulgough Exp $ // @@ -63,6 +64,7 @@ | method_contains | method_count | method_has_key + | method_len | detail::method_set_if< base_class::is_mutable, Modified: pyplusplus_dev/indexing_suite_v2/indexing_suite/multimap.hpp =================================================================== --- pyplusplus_dev/indexing_suite_v2/indexing_suite/multimap.hpp 2010-04-29 05:26:06 UTC (rev 1839) +++ pyplusplus_dev/indexing_suite_v2/indexing_suite/multimap.hpp 2010-04-29 18:39:11 UTC (rev 1840) @@ -10,6 +10,7 @@ // ======= // 2006/10/27 Roman File creation from map.hpp // 2008/12/08 Roman Change indexing suite layout +// 2010/04/29 Roman Adding "__len__" method // #ifndef BOOST_PYTHON_INDEXING_MULTIMAP_HPP @@ -60,6 +61,7 @@ | method_contains | method_count | method_has_key + | method_len | detail::method_set_if< base_class::is_mutable, Modified: pyplusplus_dev/indexing_suite_v2/indexing_suite/set.hpp =================================================================== --- pyplusplus_dev/indexing_suite_v2/indexing_suite/set.hpp 2010-04-29 05:26:06 UTC (rev 1839) +++ pyplusplus_dev/indexing_suite_v2/indexing_suite/set.hpp 2010-04-29 18:39:11 UTC (rev 1840) @@ -12,6 +12,7 @@ // ======= // 2003/10/28 rmg File creation from algo_selector.hpp // 2008/12/08 Roman Change indexing suite layout +// 2010/04/29 Roman Adding "__len__" method // // $Id: set.hpp,v 1.1.2.6 2004/02/08 18:57:42 raoulgough Exp $ // @@ -55,6 +56,7 @@ | method_contains | method_count | method_has_key + | method_len | detail::method_set_if< base_class::is_mutable, Modified: pyplusplus_dev/pyplusplus/code_repository/indexing_suite/map_header.py =================================================================== --- pyplusplus_dev/pyplusplus/code_repository/indexing_suite/map_header.py 2010-04-29 05:26:06 UTC (rev 1839) +++ pyplusplus_dev/pyplusplus/code_repository/indexing_suite/map_header.py 2010-04-29 18:39:11 UTC (rev 1840) @@ -23,6 +23,7 @@ // ======= // 2003/10/28 rmg File creation from algo_selector.hpp // 2008/12/08 Roman Change indexing suite layout +// 2010/04/29 Roman Adding "__len__" method // // $Id: map.hpp,v 1.1.2.6 2004/02/08 18:57:42 raoulgough Exp $ // @@ -74,6 +75,7 @@ | method_contains | method_count | method_has_key + | method_len | detail::method_set_if< base_class::is_mutable, Modified: pyplusplus_dev/pyplusplus/code_repository/indexing_suite/multimap_header.py =================================================================== --- pyplusplus_dev/pyplusplus/code_repository/indexing_suite/multimap_header.py 2010-04-29 05:26:06 UTC (rev 1839) +++ pyplusplus_dev/pyplusplus/code_repository/indexing_suite/multimap_header.py 2010-04-29 18:39:11 UTC (rev 1840) @@ -21,6 +21,7 @@ // ======= // 2006/10/27 Roman File creation from map.hpp // 2008/12/08 Roman Change indexing suite layout +// 2010/04/29 Roman Adding "__len__" method // #ifndef BOOST_PYTHON_INDEXING_MULTIMAP_HPP @@ -71,6 +72,7 @@ | method_contains | method_count | method_has_key + | method_len | detail::method_set_if< base_class::is_mutable, Modified: pyplusplus_dev/pyplusplus/code_repository/indexing_suite/set_header.py =================================================================== --- pyplusplus_dev/pyplusplus/code_repository/indexing_suite/set_header.py 2010-04-29 05:26:06 UTC (rev 1839) +++ pyplusplus_dev/pyplusplus/code_repository/indexing_suite/set_header.py 2010-04-29 18:39:11 UTC (rev 1840) @@ -23,6 +23,7 @@ // ======= // 2003/10/28 rmg File creation from algo_selector.hpp // 2008/12/08 Roman Change indexing suite layout +// 2010/04/29 Roman Adding "__len__" method // // $Id: set.hpp,v 1.1.2.6 2004/02/08 18:57:42 raoulgough Exp $ // @@ -66,6 +67,7 @@ | method_contains | method_count | method_has_key + | method_len | detail::method_set_if< base_class::is_mutable, Modified: pyplusplus_dev/unittests/indexing_suites2_tester.py =================================================================== --- pyplusplus_dev/unittests/indexing_suites2_tester.py 2010-04-29 05:26:06 UTC (rev 1839) +++ pyplusplus_dev/unittests/indexing_suites2_tester.py 2010-04-29 18:39:11 UTC (rev 1840) @@ -55,6 +55,7 @@ name2value = module.name2value_t() name2value[ "x" ] = "y" + self.failUnless( len(name2value) == 1 ) self.failUnless( "x" == module.get_first_name( name2value ) ) for kv in name2value: self.failUnless( kv.key == "x" and kv.value == "y" ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2011-02-26 16:34:37
|
Revision: 1845 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1845&view=rev Author: roman_yakovenko Date: 2011-02-26 16:34:31 +0000 (Sat, 26 Feb 2011) Log Message: ----------- applying path from Alan Birtles - py++ fails on cygwin - ID: 3057341 Modified Paths: -------------- pyplusplus_dev/docs/history/history.rest pyplusplus_dev/pyplusplus/file_writers/writer.py Modified: pyplusplus_dev/docs/history/history.rest =================================================================== --- pyplusplus_dev/docs/history/history.rest 2010-07-19 06:28:14 UTC (rev 1844) +++ pyplusplus_dev/docs/history/history.rest 2011-02-26 16:34:31 UTC (rev 1845) @@ -27,6 +27,7 @@ * Pertti Kellomäki * Benoît Leveau * Nikolaus Rath +* Alan Birtles ----------- SVN Version @@ -69,6 +70,8 @@ 10. Numerous bugs in "ctypes code generator" were fixed. Many thanks to Nikolaus Rath. +11. Thanks to Alan Birtles, for fixing a small issue on cygwin + ----------- Version 1.0 ----------- Modified: pyplusplus_dev/pyplusplus/file_writers/writer.py =================================================================== --- pyplusplus_dev/pyplusplus/file_writers/writer.py 2010-07-19 06:28:14 UTC (rev 1844) +++ pyplusplus_dev/pyplusplus/file_writers/writer.py 2011-02-26 16:34:31 UTC (rev 1845) @@ -37,6 +37,9 @@ def makedirs_for_file( self, file_path ): destination_dir = os.path.dirname( file_path ) + if destination_dir == "": + return + if not os.path.exists( destination_dir ): os.makedirs( destination_dir ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2011-02-26 16:58:32
|
Revision: 1847 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1847&view=rev Author: roman_yakovenko Date: 2011-02-26 16:58:26 +0000 (Sat, 26 Feb 2011) Log Message: ----------- fixing bug on 64 bit platform, in "from_addres" transformer, reported by Minh-Tri Pham Modified Paths: -------------- pyplusplus_dev/docs/history/history.rest pyplusplus_dev/pyplusplus/function_transformers/transformers.py Modified: pyplusplus_dev/docs/history/history.rest =================================================================== --- pyplusplus_dev/docs/history/history.rest 2011-02-26 16:57:10 UTC (rev 1846) +++ pyplusplus_dev/docs/history/history.rest 2011-02-26 16:58:26 UTC (rev 1847) @@ -28,6 +28,7 @@ * Benoît Leveau * Nikolaus Rath * Alan Birtles +* Minh-Tri Pham ----------- SVN Version @@ -70,8 +71,11 @@ 10. Numerous bugs in "ctypes code generator" were fixed. Many thanks to Nikolaus Rath. -11. Thanks to Alan Birtles, for fixing a small issue on cygwin +11. Thanks to Alan Birtles, for fixing a small issue on cygwin. +12. Thanks to Minh-Tri Pham, for reporting bug and providing patch for + "from_address" transformer, on 64 bit platforms. + ----------- Version 1.0 ----------- Modified: pyplusplus_dev/pyplusplus/function_transformers/transformers.py =================================================================== --- pyplusplus_dev/pyplusplus/function_transformers/transformers.py 2011-02-26 16:57:10 UTC (rev 1846) +++ pyplusplus_dev/pyplusplus/function_transformers/transformers.py 2011-02-26 16:58:26 UTC (rev 1847) @@ -183,7 +183,7 @@ :param arg_ref: Index of the argument that is an output value :type arg_ref: int """ - modifier = lambda type_: declarations.FUNDAMENTAL_TYPES[ 'unsigned int' ] + modifier = lambda type_: declarations.dummy_type_t('size_t') type_modifier_t.__init__( self, function, arg_ref, modifier ) if not is_ptr_or_array( self.arg.type ): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rom...@us...> - 2011-03-07 20:44:40
|
Revision: 1854 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1854&view=rev Author: roman_yakovenko Date: 2011-03-07 20:44:32 +0000 (Mon, 07 Mar 2011) Log Message: ----------- remove reference to "language-binding.net" site Modified Paths: -------------- pydsc_dev/docs/pkg-info.txt pydsc_dev/pydsc.py pydsc_dev/setup.py pygccxml_dev/docs/history/history.rest pygccxml_dev/docs/pkg-info.txt pygccxml_dev/setup.py pyplusplus_dev/README.txt pyplusplus_dev/docs/documentation/apidocs/code_creators.rest pyplusplus_dev/docs/documentation/functions/transformation/input_static_matrix.rest pyplusplus_dev/docs/examples/easybmp/pkg-info.txt pyplusplus_dev/docs/pkg-info.txt pyplusplus_dev/examples/pyboost_dev/setup.py pyplusplus_dev/pyplusplus/decl_wrappers/algorithm.py pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py pyplusplus_dev/setup.py Modified: pydsc_dev/docs/pkg-info.txt =================================================================== --- pydsc_dev/docs/pkg-info.txt 2011-03-07 20:42:15 UTC (rev 1853) +++ pydsc_dev/docs/pkg-info.txt 2011-03-07 20:44:32 UTC (rev 1854) @@ -5,7 +5,7 @@ Author-email: roman yakovenko at gmail com Maintainer: Roman Yakovenko Maintainer-email: roman yakovenko at gmail com -Home-page: http://www.language-binding.net/ +Home-page: Download-url: http://sourceforge.net/project/showfiles.php?group_id=118209 Summary: Python Documentation Spell Checker License: Boost Software License @@ -16,4 +16,4 @@ Classifier: Intended Audience :: Developers Classifier: License :: Freeware Classifier: Programming Language :: Python -Classifier: Topic :: Software Development \ No newline at end of file +Classifier: Topic :: Software Development Modified: pydsc_dev/pydsc.py =================================================================== --- pydsc_dev/pydsc.py 2011-03-07 20:42:15 UTC (rev 1853) +++ pydsc_dev/pydsc.py 2011-03-07 20:44:32 UTC (rev 1854) @@ -19,7 +19,6 @@ __version__ = '0.3' #current version __author__ = 'Roman Yakovenko <rom...@gm...>' -__url__ = 'http://www.language-binding.net' __license__ = 'Boost Software License <http://boost.org/more/license_info.html>' import os Modified: pydsc_dev/setup.py =================================================================== --- pydsc_dev/setup.py 2011-03-07 20:42:15 UTC (rev 1853) +++ pydsc_dev/setup.py 2011-03-07 20:44:32 UTC (rev 1854) @@ -14,6 +14,5 @@ , description="Python documentation and comments spell checker" , author="Roman Yakovenko" , author_email="rom...@gm..." - , url='http://www.language-binding.net' , py_modules=[ 'pydsc' ] ) Modified: pygccxml_dev/docs/history/history.rest =================================================================== --- pygccxml_dev/docs/history/history.rest 2011-03-07 20:42:15 UTC (rev 1853) +++ pygccxml_dev/docs/history/history.rest 2011-03-07 20:44:32 UTC (rev 1854) @@ -62,7 +62,7 @@ as suggested by `Jakub Wilk <http://groups.google.com/group/linux.debian.bugs.dist/browse_thread/thread/572d2286ca0b2cec?pli=1>` 11. "__int128_t" and "__uint128_t" types were introduced. Many thanks to Gustavo Carneiro - for providing the patch. + for providing the patch. 12. Thanks to Aron Xu, for pointing out that it is better to use "os.name", instead of "sys.platform" for platform specific logic. Modified: pygccxml_dev/docs/pkg-info.txt =================================================================== --- pygccxml_dev/docs/pkg-info.txt 2011-03-07 20:42:15 UTC (rev 1853) +++ pygccxml_dev/docs/pkg-info.txt 2011-03-07 20:44:32 UTC (rev 1854) @@ -5,7 +5,6 @@ Author-email: roman yakovenko at gmail com Maintainer: Roman Yakovenko Maintainer-email: roman yakovenko at gmail com -Home-page: http://www.language-binding.net/ Download-url: http://sourceforge.net/project/showfiles.php?group_id=118209 Summary: Python package for easy C++ declarations navigation License: Boost Software License @@ -24,4 +23,4 @@ Classifier: Intended Audience :: Developers Classifier: License :: Freeware Classifier: Programming Language :: Python -Classifier: Topic :: Software Development \ No newline at end of file +Classifier: Topic :: Software Development Modified: pygccxml_dev/setup.py =================================================================== --- pygccxml_dev/setup.py 2011-03-07 20:42:15 UTC (rev 1853) +++ pygccxml_dev/setup.py 2011-03-07 20:44:32 UTC (rev 1854) @@ -11,7 +11,6 @@ description = "GCC-XML generated file reader", author = "Roman Yakovenko", author_email = "rom...@gm...", - url = 'http://www.language-binding.net/pygccxml/pygccxml.html', packages = [ 'pygccxml', 'pygccxml.declarations', 'pygccxml.parser', Modified: pyplusplus_dev/README.txt =================================================================== --- pyplusplus_dev/README.txt 2011-03-07 20:42:15 UTC (rev 1853) +++ pyplusplus_dev/README.txt 2011-03-07 20:44:32 UTC (rev 1854) @@ -5,17 +5,15 @@ Python bindings of a C/C++ library. The tool is implemented as a Python module which is controlled by a user script. -Homepage: http://www.language-binding.net/pyplusplus/pyplusplus.html - Requirements ------------ In order to use Py++ you need the following additional components: - Python v2.6 (or higher) -- pygccxml (http://www.language-binding.net/pygccxml/pygccxml.html) -- GCC-XML (http://www.gccxml.org) +- pygccxml +- GCC-XML Install Modified: pyplusplus_dev/docs/documentation/apidocs/code_creators.rest =================================================================== --- pyplusplus_dev/docs/documentation/apidocs/code_creators.rest 2011-03-07 20:42:15 UTC (rev 1853) +++ pyplusplus_dev/docs/documentation/apidocs/code_creators.rest 2011-03-07 20:44:32 UTC (rev 1854) @@ -111,14 +111,6 @@ :undoc-members: :show-inheritance: -ctypes_module -------------- - -.. automodule:: pyplusplus.code_creators.ctypes_module - :members: - :undoc-members: - :show-inheritance: - custom ------ Modified: pyplusplus_dev/docs/documentation/functions/transformation/input_static_matrix.rest =================================================================== --- pyplusplus_dev/docs/documentation/functions/transformation/input_static_matrix.rest 2011-03-07 20:42:15 UTC (rev 1853) +++ pyplusplus_dev/docs/documentation/functions/transformation/input_static_matrix.rest 2011-03-07 20:44:32 UTC (rev 1854) @@ -1,6 +1,6 @@ -================================== +=================================== ``input_static_matrix`` transformer -================================== +=================================== ---------- Definition Modified: pyplusplus_dev/docs/examples/easybmp/pkg-info.txt =================================================================== --- pyplusplus_dev/docs/examples/easybmp/pkg-info.txt 2011-03-07 20:42:15 UTC (rev 1853) +++ pyplusplus_dev/docs/examples/easybmp/pkg-info.txt 2011-03-07 20:44:32 UTC (rev 1854) @@ -5,7 +5,6 @@ Author-email: roman yakovenko at gmail com Maintainer: Roman Yakovenko Maintainer-email: roman yakovenko at gmail com -Home-page: http://www.language-binding.net/pyplusplus/examples/py_easybmp/py_easybmp.html Download-url: http://sourceforge.net/project/showfiles.php?group_id=118209 Summary: Python bindings for C++ EasyBMP library License: Boost Software License @@ -15,4 +14,4 @@ Classifier: Intended Audience :: Developers Classifier: License :: Freeware Classifier: Programming Language :: Python -Classifier: Topic :: Software Development \ No newline at end of file +Classifier: Topic :: Software Development Modified: pyplusplus_dev/docs/pkg-info.txt =================================================================== --- pyplusplus_dev/docs/pkg-info.txt 2011-03-07 20:42:15 UTC (rev 1853) +++ pyplusplus_dev/docs/pkg-info.txt 2011-03-07 20:44:32 UTC (rev 1854) @@ -4,8 +4,7 @@ Author: Roman Yakovenko Author-email: roman yakovenko at gmail com Maintainer: Roman Yakovenko -Maintainer-email: roman yakovenko at gmail com -Home-page: http://www.language-binding.net/ +Maintainer-email: roman yakovenko at gmail co Download-url: http://sourceforge.net/project/showfiles.php?group_id=118209 Summary: pyplusplus is an object-oriented framework for creating a code generator for boost.python library License: Boost Software License @@ -16,4 +15,4 @@ Classifier: Intended Audience :: Developers Classifier: License :: Freeware Classifier: Programming Language :: Python -Classifier: Topic :: Software Development \ No newline at end of file +Classifier: Topic :: Software Development Modified: pyplusplus_dev/examples/pyboost_dev/setup.py =================================================================== --- pyplusplus_dev/examples/pyboost_dev/setup.py 2011-03-07 20:42:15 UTC (rev 1853) +++ pyplusplus_dev/examples/pyboost_dev/setup.py 2011-03-07 20:44:32 UTC (rev 1854) @@ -16,7 +16,6 @@ , description = "" , author = "Roman Yakovenko" , author_email = "rom...@gm..." - , url = 'http://www.language-binding.net/pygccxml/pygccxml.html' , packages = [ 'pyboost' , 'pyboost.boost_random' , 'pyboost.crc' Modified: pyplusplus_dev/pyplusplus/decl_wrappers/algorithm.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/algorithm.py 2011-03-07 20:42:15 UTC (rev 1853) +++ pyplusplus_dev/pyplusplus/decl_wrappers/algorithm.py 2011-03-07 20:44:32 UTC (rev 1854) @@ -100,9 +100,7 @@ return full_name class registration_order: - """class-namespace, introduce few functions, which deals with functions - registration order problem: http://www.language-binding.net/pyplusplus/documentation/functions/registration_order.html - """ + """the class, introduces few functions, which deals with functions registration order problem""" @staticmethod def is_related( t1, t2 ): Modified: pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2011-03-07 20:42:15 UTC (rev 1853) +++ pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2011-03-07 20:44:32 UTC (rev 1854) @@ -184,7 +184,7 @@ this declaration. skip_ignored argument allows you to control the information reported to you. - For more information please read: http://www.language-binding.net/pyplusplus/documentation/warnings.html + For more information please read documentation about warnings. """ msgs = [] if not self.exportable: Modified: pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py =================================================================== --- pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py 2011-03-07 20:42:15 UTC (rev 1853) +++ pyplusplus_dev/pyplusplus/module_builder/boost_python_builder.py 2011-03-07 20:44:32 UTC (rev 1854) @@ -25,7 +25,7 @@ """ This class provides users with simple and intuitive interface to `Py++` and/or pygccxml functionality. If this is your first attempt to use `Py++` - consider to read tutorials. You can find them on `web site <http://www.language-binding.net>`_. + consider to read tutorials. """ def __init__( self Modified: pyplusplus_dev/setup.py =================================================================== --- pyplusplus_dev/setup.py 2011-03-07 20:42:15 UTC (rev 1853) +++ pyplusplus_dev/setup.py 2011-03-07 20:44:32 UTC (rev 1854) @@ -13,7 +13,6 @@ description="Py++ is a framework of components for creating C++ code generator for Boost.Python library", author="Roman Yakovenko", author_email="rom...@gm...", - url='http://www.language-binding.net/pyplusplus/pyplusplus.html', scripts = [], packages=[ 'pyplusplus', 'pyplusplus.file_writers', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |