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) )
Ejemplo n.º 2
0
def AutoArrayArgs( mb ):
    """ Fix Functions that return a pointer to a float structure..  Challenge is that all of the 
    sensible names (dVector3, dMatrix4) are typedefs to dReal (a float *) so in the gcc xml file
    we lose the names and so don't know what the real stuctures are.  
    
    So we use an external function in "defination_finfer.py" to go back to the header files for
    each function and determine what the structure really is.
    
    We also don't know if these structures are for input or output or both to the function -- so
    we look for a variable called 'result' as treat it as an output, everything else as an input
    
    Need to get a mod to Py++ to support in/out
    """
    
    defcheck = df.def_finder()
    names={'dVector3':4, 'dVector3':4, 'dMatrix3':12,'dMatrix4':16, 'dMatrix6':48, 'dQuaternion':4}
    for fun in mb.global_ns.calldefs():
        if len(fun.name) < 2 or "std::" in fun.decl_string:
            continue
        if fun.name[0] != 'd' or (fun.name[1] != fun.name[1].upper()):
            continue
# #         print "CHECKING", fun
        transforms=[]       ## we collect the transformations for a function and execute in one go
        desc=""
        arg_position = 0
        for arg in fun.arguments:
            if arg.name=='result':  # it's an output
                originalDef = defcheck(fun, arg_position)  ## here is where we go and get the real def for the arg
                for n in names:
                    if n in originalDef:
                        transforms.append(ft.output_static_array(arg_position, size=names[n]) )
                        desc=desc+"Transforming "+ arg.name+ " pos("+str(arg_position)+\
                             ") as an OUTPUT array with "+ str(names[n])+ " elements"
                        break
            else:
# #                 print "Arg Pos", arg_position, arg.name
                originalDef = defcheck(fun, arg_position)  ## here is where we go and get the real def for the arg
                for n in names:
                    if n in originalDef:
                        transforms.append(ft.input_static_array(arg_position, size=names[n]) )
                        desc=desc+"Transforming "+ arg.name+ " pos("+str(arg_position)+\
                             ") as an INPUT array with "+ str(names[n])+ "elements"
                        break
            arg_position += 1
        if transforms:
            fun.add_transformation( *transforms )
            fun.documentation = "Python-Ogre: Function Array Modified\\n\\\n" + desc
Ejemplo n.º 3
0
    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))