def customize(self, mb ): mb.calldef( 'return_second_arg' ).call_policies = call_policies.return_arg( 2 ) mb.calldef( 'return_self' ).call_policies = call_policies.return_self() mb.class_( 'impl_details_t' ).opaque = True mb.calldef( 'get_opaque' ).call_policies \ = call_policies.return_value_policy( call_policies.return_opaque_pointer ) mb.calldef( 'get_fundamental_ptr_value' ).call_policies \ = call_policies.return_value_policy( call_policies.return_pointee_value ) mb.calldef( 'get_fundamental_ptr_value_null' ).call_policies \ = call_policies.return_value_policy( call_policies.return_pointee_value ) mb.calldef( 'create_arr_3' ).call_policies \ = call_policies.convert_array_to_tuple( 3, call_policies.memory_managers.delete_ ) image = mb.class_('return_range_image_t') image.add_declaration_code( get_size_code ) image.add_declaration_code( get_create_images_size ) get_raw_data = image.mem_fun( 'get_raw_data' ) get_raw_data.call_policies \ = call_policies.return_range( get_raw_data, 'raw_data_size_t' ) get_raw_data_const = image.mem_fun( 'get_raw_data_const' ) get_raw_data_const.call_policies \ = call_policies.return_range( get_raw_data_const, 'raw_data_size_t' ) create_images = image.mem_fun( 'create_images' ) create_images.call_policies \ = call_policies.return_range( create_images , 'get_create_images_size_t' , call_policies.return_value_policy(call_policies.reference_existing_object) )
def ReturnReals( mb ): """ many functions return dReal * which we need to make tuples however we don't relaly know how big to make the tuple so we use a dictionary to determine the size based upon the function name """ names = {'Rotation':12, 'Position':3, 'Quaternion':4, 'Vel':3, 'Force':3, 'Torque':3 } for fun in mb.global_ns.calldefs(): if fun.return_type: if "::dReal const *" == fun.return_type.decl_string: ## OK we need to process it for n in names: if fun.name.endswith (n): # # print "Fixing return on",fun.name fun.call_policies = call_policies.convert_array_to_tuple( names[n], call_policies.memory_managers.none ) fun.include() break
def generate(module_builder, local_ns, global_ns): """ global_ns: is the module builder for the entire library local_ns: is the namespace that coresponds to the given namespace """ classes = [] # Find all the classes to wrap Radian = local_ns.class_('Radian') Degree = local_ns.class_('Degree') Vector2 = local_ns.class_('Vector2') Vector3 = local_ns.class_('Vector3') Quaternion = local_ns.class_('Quaternion') Matrix2 = local_ns.class_('Matrix2') Matrix3 = local_ns.class_('Matrix3') # Include them Radian.include() Degree.include() Vector2.include() Vector3.include() Quaternion.include() Matrix2.include() Matrix3.include() classes.extend( [Radian, Degree, Vector2, Vector3, Quaternion, Matrix2, Matrix3]) # Map operator<< to __str__ wrap.str_from_ostream(local_ns) # Fix '[]' operators on matrices c = Matrix2.operators('[]') c.call_policies= call_policies.convert_array_to_tuple(2, \ call_policies.memory_managers.none) c.include() c.documentation = wrap.docit("Return Type Change", "None", "Tuple with 2 floats's (the matrix 'line')") c = Matrix3.operators('[]') c.call_policies= call_policies.convert_array_to_tuple(3, \ call_policies.memory_managers.none) c.include() c.documentation = wrap.docit("Return Type Change", "None", "Tuple with 3 floats's (the matrix 'line')") # Handle the 'ptr' functions wrap.fix_pointer_returns([Vector2, Vector3, Quaternion, Matrix2, Matrix3], ignore_names=['ptr']) wrap.fix_pointer_args([Vector2, Vector3, Quaternion, Matrix2, Matrix3]) # Remove float -> Radian/Degree implicit conversions Degree.constructor(arg_types=['double']).allow_implicit_conversion = False Radian.constructor(arg_types=['double']).allow_implicit_conversion = False # Wrap Events events = wrap.expose_events(local_ns) if events: module_builder.class_('::ram::core::Event').already_exposed = True classes += events # Append the approaite include files wrap.add_needed_includes(classes) Quaternion.include_files.append(Matrix3.location.file_name) # Remove implicit conversions wrap.set_implicit_conversions( [Vector2, Vector3, Quaternion, Matrix2, Matrix3], False) include_files = set([cls.location.file_name for cls in classes]) for cls in classes: include_files.update(cls.include_files) return ['math/include/Math.h'] + list(include_files)
def generate(module_builder, local_ns, global_ns): """ global_ns: is the module builder for the entire library local_ns: is the namespace that coresponds to the given namespace """ classes = [] # Find all the classes to wrap Radian = local_ns.class_('Radian') Degree = local_ns.class_('Degree') Vector2 = local_ns.class_('Vector2') Vector3 = local_ns.class_('Vector3') Quaternion = local_ns.class_('Quaternion') Matrix2 = local_ns.class_('Matrix2') Matrix3 = local_ns.class_('Matrix3') # Include them Radian.include() Degree.include() Vector2.include() Vector3.include() Quaternion.include() Matrix2.include() Matrix3.include() classes.extend([Radian, Degree, Vector2, Vector3, Quaternion, Matrix2, Matrix3]) # Map operator<< to __str__ wrap.str_from_ostream(local_ns) # Fix '[]' operators on matrices c = Matrix2.operators('[]') c.call_policies= call_policies.convert_array_to_tuple(2, \ call_policies.memory_managers.none) c.include() c.documentation = wrap.docit("Return Type Change", "None", "Tuple with 2 floats's (the matrix 'line')") c = Matrix3.operators('[]') c.call_policies= call_policies.convert_array_to_tuple(3, \ call_policies.memory_managers.none) c.include() c.documentation = wrap.docit("Return Type Change", "None", "Tuple with 3 floats's (the matrix 'line')") # Handle the 'ptr' functions wrap.fix_pointer_returns([Vector2, Vector3, Quaternion, Matrix2, Matrix3], ignore_names = ['ptr']) wrap.fix_pointer_args([Vector2, Vector3, Quaternion, Matrix2, Matrix3]) # Remove float -> Radian/Degree implicit conversions Degree.constructor(arg_types = ['double']).allow_implicit_conversion = False Radian.constructor(arg_types = ['double']).allow_implicit_conversion = False # Wrap Events events = wrap.expose_events(local_ns) if events: module_builder.class_('::ram::core::Event').already_exposed = True classes += events # Append the approaite include files wrap.add_needed_includes(classes) Quaternion.include_files.append(Matrix3.location.file_name) # Remove implicit conversions wrap.set_implicit_conversions([Vector2, Vector3, Quaternion, Matrix2, Matrix3], False) include_files = set([cls.location.file_name for cls in classes]) for cls in classes: include_files.update(cls.include_files) return ['math/include/Math.h'] + list(include_files)