def customize(self, mb): event_clss = mb.classes(lambda cls: cls.name in ('event_t', 'do_nothing_t')) for cls in event_clss: cls.add_destructor_code(decref_code) cls.add_wrapper_code('PyObject* m_pyobj;') cls.set_constructors_body('m_pyobj=0;') cls.mem_fun('notify').add_override_precall_code(incref_code) cls.mem_fun('notify').add_default_precall_code(incref_code) cls.held_type = 'std::auto_ptr< %s >' % cls.wrapper_alias cls.add_registration_code( impl_conv_code % { 'from': cls.wrapper_alias, 'to': cls.decl_string }, False) for base in cls.recursive_bases: if base.access_type == 'public': cls.add_registration_code( #from class to its base impl_conv_code % { 'from' : cls.decl_string , 'to' : base.related_class.decl_string } , False) cls.add_registration_code( #from wrapper to clas base class impl_conv_code % { 'from' : cls.wrapper_alias , 'to' : base.related_class.decl_string } , False) schedule = mb.mem_fun('schedule') schedule.add_transformation(ft.transfer_ownership(0), alias='schedule') simulator = mb.class_('simulator_t') simulator.mem_fun( 'get_event' ).call_policies \ = call_policies.return_internal_reference()
def customize( self, mb ): event_clss = mb.classes( lambda cls: cls.name in ( 'event_t', 'do_nothing_t' ) ) for cls in event_clss: cls.exposed_class_type = cls.EXPOSED_CLASS_TYPE.WRAPPER cls.held_type = 'std::auto_ptr< %s >' % cls.wrapper_alias cls.add_registration_code( register_sptr % 'std::auto_ptr< %s >' % cls.decl_string, False ) cls.add_registration_code( impl_conv_code % { 'from' : cls.wrapper_alias , 'to' : cls.decl_string } , False) for base in cls.recursive_bases: if base.access_type == 'public': cls.add_registration_code( #from class to its base impl_conv_code % { 'from' : cls.decl_string , 'to' : base.related_class.decl_string } , False) cls.add_registration_code( #from wrapper to clas base class impl_conv_code % { 'from' : cls.wrapper_alias , 'to' : base.related_class.decl_string } , False) simulator = mb.class_( 'simulator_t' ) simulator.member_function( 'get_event' ).call_policies \ = call_policies.return_internal_reference() schedule = mb.member_function( 'schedule' ) schedule.add_transformation( ft.transfer_ownership(0), alias='schedule' )
def customize( self, mb ): event_clss = mb.classes( lambda cls: cls.name in ( 'event_t', 'do_nothing_t' ) ) for cls in event_clss: cls.add_wrapper_code( decref_code % { 'cls' : cls.wrapper_alias } ) cls.add_wrapper_code( 'PyObject* m_pyobj;' ) cls.set_constructors_body( 'm_pyobj=0;' ) cls.mem_fun( 'notify' ).add_override_precall_code( incref_code ) cls.mem_fun( 'notify' ).add_default_precall_code( incref_code ) cls.held_type = 'std::auto_ptr< %s >' % cls.wrapper_alias cls.add_registration_code( impl_conv_code % { 'from' : cls.wrapper_alias , 'to' : cls.decl_string } , False) for base in cls.recursive_bases: if base.access_type == 'public': cls.add_registration_code( #from class to its base impl_conv_code % { 'from' : cls.decl_string , 'to' : base.related_class.decl_string } , False) cls.add_registration_code( #from wrapper to clas base class impl_conv_code % { 'from' : cls.wrapper_alias , 'to' : base.related_class.decl_string } , False) schedule = mb.mem_fun( 'schedule' ) schedule.add_transformation( ft.transfer_ownership(0), alias='schedule' ) simulator = mb.class_( 'simulator_t' ) simulator.mem_fun( 'get_event' ).call_policies \ = call_policies.return_internal_reference()
def customize( self, mb ): event_clss = mb.classes( lambda cls: cls.name in ( 'event_t', 'do_nothing_t' ) ) for cls in event_clss: cls.exposed_class_type = cls.EXPOSED_CLASS_TYPE.WRAPPER cls.held_type = 'std::auto_ptr< %s >' % cls.wrapper_alias cls.add_registration_code( register_sptr % 'std::auto_ptr< %s >' % cls.decl_string, False ) cls.add_registration_code( impl_conv_code % { 'from' : cls.wrapper_alias , 'to' : cls.decl_string } , False) for base in cls.recursive_bases: if base.access_type == 'public': cls.add_registration_code( #from class to its base impl_conv_code % { 'from' : cls.decl_string , 'to' : base.related_class.decl_string } , False) cls.add_registration_code( #from wrapper to clas base class impl_conv_code % { 'from' : cls.wrapper_alias , 'to' : base.related_class.decl_string } , False) simulator = mb.class_( 'simulator_t' ) simulator.mem_fun( 'get_event' ).call_policies \ = call_policies.return_internal_reference() schedule = mb.mem_fun( 'schedule' ) schedule.add_transformation( ft.transfer_ownership(0), alias='schedule' )
def customize(self, mb): event_clss = mb.classes(lambda cls: cls.name in ("event_t", "do_nothing_t")) for cls in event_clss: cls.add_destructor_code(decref_code) cls.add_wrapper_code("PyObject* m_pyobj;") cls.set_constructors_body("m_pyobj=0;") cls.mem_fun("notify").add_override_precall_code(incref_code) cls.mem_fun("notify").add_default_precall_code(incref_code) cls.held_type = "std::auto_ptr< %s >" % cls.wrapper_alias cls.add_registration_code(impl_conv_code % {"from": cls.wrapper_alias, "to": cls.decl_string}, False) for base in cls.recursive_bases: if base.access_type == "public": cls.add_registration_code( # from class to its base impl_conv_code % {"from": cls.decl_string, "to": base.related_class.decl_string}, False ) cls.add_registration_code( # from wrapper to clas base class impl_conv_code % {"from": cls.wrapper_alias, "to": base.related_class.decl_string}, False ) schedule = mb.mem_fun("schedule") schedule.add_transformation(ft.transfer_ownership(0), alias="schedule") simulator = mb.class_("simulator_t") simulator.mem_fun("get_event").call_policies = call_policies.return_internal_reference()
def customize(self, mb): event_clss = mb.classes(lambda cls: cls.name in ("event_t", "do_nothing_t")) for cls in event_clss: cls.exposed_class_type = cls.EXPOSED_CLASS_TYPE.WRAPPER cls.held_type = "std::auto_ptr< %s >" % cls.wrapper_alias cls.add_registration_code(register_sptr % "std::auto_ptr< %s >" % cls.decl_string, False) cls.add_registration_code(impl_conv_code % {"from": cls.wrapper_alias, "to": cls.decl_string}, False) for base in cls.recursive_bases: if base.access_type == "public": cls.add_registration_code( # from class to its base impl_conv_code % {"from": cls.decl_string, "to": base.related_class.decl_string}, False ) cls.add_registration_code( # from wrapper to clas base class impl_conv_code % {"from": cls.wrapper_alias, "to": base.related_class.decl_string}, False ) simulator = mb.class_("simulator_t") simulator.mem_fun("get_event").call_policies = call_policies.return_internal_reference() schedule = mb.mem_fun("schedule") schedule.add_transformation(ft.transfer_ownership(0), alias="schedule")
def customize( self, mb ): mb.global_ns.calldefs().create_with_signature = True hello_world = mb.free_fun( 'hello_world' ) hello_world.add_transformation( ft.output(0) ) calc = mb.class_('calculator_t' ) assign_funs = calc.mem_funs( lambda decl: decl.name.startswith( 'assign' ) ) assign_funs.add_transformation( ft.output(0), ft.output(1) ) clone_and_assign_5 = calc.mem_fun( 'clone_and_assign_5' ) clone_and_assign_5.add_transformation( ft.output(0) ) clone_and_assign_5.call_policies = call_policies.return_value_policy( call_policies.manage_new_object ) window = mb.class_( 'window_t' ) window.mem_fun( 'resize' ).add_transformation( ft.input(0), ft.input(1) ) window.mem_fun( 'resize_in_out' ).add_transformation( ft.inout(0), ft.inout(1) ) point3d = mb.class_( 'point3d_t' ) point3d.add_wrapper_code( '' ) 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) ) point3d.mem_fun( 'distance' ).add_transformation( ft.output(1) ) image = mb.class_( "image_t" ) image.always_expose_using_scope = True image.member_function( "get_size" ) image.member_function( "get_size" ).add_transformation( ft.output(0), ft.output(1) ) image.member_function( "get_one_value" ).add_transformation( ft.output(0) ) image.member_function( "get_size2" ).add_transformation( ft.output(0), ft.output(1) ) image.member_function( "input_arg" ).add_transformation( ft.input(0) ) image.member_function( "fixed_input_array" ).add_transformation( ft.input_static_array(0,3) ) image.member_function( "fixed_output_array" ).add_transformation( ft.output_static_array(0,3) ) mb.free_function("get_cpp_instance").call_policies \ = call_policies.return_value_policy(call_policies.reference_existing_object) mb.variable( "cpp_instance" ).exclude() cls = mb.class_("no_virtual_members_t") cls.member_function("member").add_transformation( ft.output(0) ) cls = mb.class_("ft_private_destructor_t") cls.member_function("get_value").add_transformation( ft.output(0) ) mb.decls(lambda decl: decl.name.startswith("_")).exclude() cls = mb.class_("bug_render_target_t") cls.mem_fun("get_statistics", arg_types=['float &']*2).add_transformation( ft.output(0), ft.output(1) ) cls = mb.class_( 'modify_type_tester_t' ) do_nothing = cls.mem_fun( 'do_nothing' ) do_nothing.add_transformation( ft.modify_type(0, declarations.remove_reference ) ) clone = cls.mem_fun( 'clone' ) clone.call_policies = call_policies.return_value_policy( call_policies.manage_new_object ) clone.add_transformation( ft.modify_type(0, declarations.remove_reference ) ) cls = mb.class_( 'input_c_buffer_tester_t') write_mf = cls.mem_fun( 'write' ) write_mf.add_transformation( ft.input_c_buffer( 'buffer', 'size' ) ) write_s = cls.mem_fun( 'write_s' ) write_s.add_transformation( ft.input_c_buffer( 'buffer', 'size' ) ) resource = mb.class_( 'resources_t' ) resource.held_type = 'std::auto_ptr< %s >' % resource.decl_string transfer_ownership_tester = mb.class_( 'transfer_ownership_tester_t' ) tester = transfer_ownership_tester.mem_fun( 'tester' ) tester.add_transformation( ft.transfer_ownership( 0 ) ) render_queue_listener_t = mb.class_( 'render_queue_listener_t' ) render_queue_ended = render_queue_listener_t.mem_fun( 'render_queue_ended' ) render_queue_ended.add_transformation( ft.inout(2) )
def customize( self, mb ): mb.global_ns.calldefs().create_with_signature = True hello_world = mb.free_fun( 'hello_world' ) hello_world.add_transformation( ft.output(0) ) calc = mb.class_('calculator_t' ) assign_funs = calc.mem_funs( lambda decl: decl.name.startswith( 'assign' ) ) assign_funs.add_transformation( ft.output(0), ft.output(1) ) clone_and_assign_5 = calc.mem_fun( 'clone_and_assign_5' ) clone_and_assign_5.add_transformation( ft.output(0) ) clone_and_assign_5.call_policies = call_policies.return_value_policy( call_policies.manage_new_object ) window = mb.class_( 'window_t' ) window.mem_fun( 'resize' ).add_transformation( ft.input(0), ft.input(1) ) window.mem_fun( 'resize_in_out' ).add_transformation( ft.inout(0), ft.inout(1) ) point3d = mb.class_( 'point3d_t' ) point3d.add_wrapper_code( '' ) 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) ) distance = point3d.mem_fun( 'distance' ) distance.add_transformation( ft.output(1) ) distance.transformations[0].controller.add_pre_call_code( '//dddddddddddddd' ) distance.transformations[0].controller.add_post_call_code( '//qqqqqqqqqqqqq' ) image = mb.class_( "image_t" ) image.always_expose_using_scope = True image.member_function( "get_size" ) image.member_function( "get_size" ).add_transformation( ft.output(0), ft.output(1) ) image.member_function( "get_one_value" ).add_transformation( ft.output(0) ) image.member_function( "get_size2" ).add_transformation( ft.output(0), ft.output(1) ) image.member_function( "input_arg" ).add_transformation( ft.input(0) ) image.member_function( "fixed_input_array" ).add_transformation( ft.input_static_array(0,3) ) image.member_function( "fixed_output_array" ).add_transformation( ft.output_static_array(0,3) ) mb.free_function("get_cpp_instance").call_policies \ = call_policies.return_value_policy(call_policies.reference_existing_object) mb.variable( "cpp_instance" ).exclude() cls = mb.class_("no_virtual_members_t") cls.member_function("member").add_transformation( ft.output(0) ) cls = mb.class_("ft_private_destructor_t") cls.member_function("get_value").add_transformation( ft.output(0) ) mb.decls(lambda decl: decl.name.startswith("_")).exclude() cls = mb.class_("bug_render_target_t") cls.mem_fun("get_statistics", arg_types=['float &']*2).add_transformation( ft.output(0), ft.output(1) ) cls = mb.class_( 'modify_type_tester_t' ) do_nothing = cls.mem_fun( 'do_nothing' ) do_nothing.add_transformation( ft.modify_type(0, declarations.remove_reference ) ) clone = cls.mem_fun( 'clone' ) clone.call_policies = call_policies.return_value_policy( call_policies.manage_new_object ) clone.add_transformation( ft.modify_type(0, declarations.remove_reference ) ) cls = mb.class_( 'input_c_buffer_tester_t') write_mf = cls.mem_fun( 'write' ) write_mf.add_transformation( ft.input_c_buffer( 'buffer', 'size' ) ) write_s = cls.mem_fun( 'write_s' ) write_s.add_transformation( ft.input_c_buffer( 'buffer', 'size' ) ) resource = mb.class_( 'resources_t' ) resource.held_type = 'std::auto_ptr< %s >' % resource.decl_string transfer_ownership_tester = mb.class_( 'transfer_ownership_tester_t' ) tester = transfer_ownership_tester.mem_fun( 'tester' ) tester.add_transformation( ft.transfer_ownership( 0 ) ) render_queue_listener_t = mb.class_( 'render_queue_listener_t' ) render_queue_ended = render_queue_listener_t.mem_fun( 'render_queue_ended' ) render_queue_ended.add_transformation( ft.inout(2) ) ft_bugs = mb.namespace( 'ft_bugs' ) h = ft_bugs.mem_fun( 'h' ) h.add_transformation( ft.modify_type(0, remove_const_ref ) ) h.call_policies = call_policies.return_internal_reference() h2 = ft_bugs.mem_fun( 'h2' ) h2.add_transformation( ft.modify_type(0, remove_const_ref ) ) h2.call_policies = call_policies.return_internal_reference() ft_bugs.class_( 'B' ).always_expose_using_scope = True ft_bugs.mem_fun( 'get_a' ).call_policies \ = call_policies.return_value_policy( call_policies.reference_existing_object ) ft_bugs2 = mb.namespace( 'ft_bugs2' ) g = ft_bugs2.mem_fun( 'g' ) g.add_transformation( ft.modify_type(0, remove_const_ref ) ) g.call_policies = call_policies.return_internal_reference()
def customize(self, mb): mb.global_ns.calldefs().create_with_signature = True hello_world = mb.free_fun("hello_world") hello_world.add_transformation(ft.output(0)) calc = mb.class_("calculator_t") assign_funs = calc.mem_funs(lambda decl: decl.name.startswith("assign")) assign_funs.add_transformation(ft.output(0), ft.output(1)) clone_and_assign_5 = calc.mem_fun("clone_and_assign_5") clone_and_assign_5.add_transformation(ft.output(0)) clone_and_assign_5.call_policies = call_policies.return_value_policy(call_policies.manage_new_object) window = mb.class_("window_t") window.mem_fun("resize").add_transformation(ft.input(0), ft.input(1)) window.mem_fun("resize_in_out").add_transformation(ft.inout(0), ft.inout(1)) point3d = mb.class_("point3d_t") point3d.add_wrapper_code("") 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)) point3d.mem_fun("distance").add_transformation(ft.output(1)) image = mb.class_("image_t") image.always_expose_using_scope = True image.member_function("get_size") image.member_function("get_size").add_transformation(ft.output(0), ft.output(1)) image.member_function("get_one_value").add_transformation(ft.output(0)) image.member_function("get_size2").add_transformation(ft.output(0), ft.output(1)) image.member_function("input_arg").add_transformation(ft.input(0)) image.member_function("fixed_input_array").add_transformation(ft.input_static_array(0, 3)) image.member_function("fixed_output_array").add_transformation(ft.output_static_array(0, 3)) mb.free_function("get_cpp_instance").call_policies = call_policies.return_value_policy( call_policies.reference_existing_object ) mb.variable("cpp_instance").exclude() cls = mb.class_("no_virtual_members_t") cls.member_function("member").add_transformation(ft.output(0)) cls = mb.class_("ft_private_destructor_t") cls.member_function("get_value").add_transformation(ft.output(0)) mb.decls(lambda decl: decl.name.startswith("_")).exclude() cls = mb.class_("bug_render_target_t") cls.mem_fun("get_statistics", arg_types=["float &"] * 2).add_transformation(ft.output(0), ft.output(1)) cls = mb.class_("modify_type_tester_t") do_nothing = cls.mem_fun("do_nothing") do_nothing.add_transformation(ft.modify_type(0, declarations.remove_reference)) clone = cls.mem_fun("clone") clone.call_policies = call_policies.return_value_policy(call_policies.manage_new_object) clone.add_transformation(ft.modify_type(0, declarations.remove_reference)) cls = mb.class_("input_c_buffer_tester_t") write_mf = cls.mem_fun("write") write_mf.add_transformation(ft.input_c_buffer("buffer", "size")) write_s = cls.mem_fun("write_s") write_s.add_transformation(ft.input_c_buffer("buffer", "size")) resource = mb.class_("resources_t") resource.held_type = "std::auto_ptr< %s >" % resource.decl_string transfer_ownership_tester = mb.class_("transfer_ownership_tester_t") tester = transfer_ownership_tester.mem_fun("tester") tester.add_transformation(ft.transfer_ownership(0)) render_queue_listener_t = mb.class_("render_queue_listener_t") render_queue_ended = render_queue_listener_t.mem_fun("render_queue_ended") render_queue_ended.add_transformation(ft.inout(2))
def handle_ownership_transfers(self): for class_name, member_name, arg_names in self.ownership_transfers: cl = self.module_builder.class_(class_name) m = cl.member_function(member_name) for a in arg_names: m.add_transformation(FT.transfer_ownership(a))
def handle_ownership_transfers(self): for class_name, member_name, arg_names in self.ownership_transfers: cl = self.module_builder.class_(class_name) m = cl.member_function(member_name) for a in arg_names: m.add_transformation(FT.transfer_ownership(a))