Ejemplo n.º 1
0
    def create_default(self):
        cntrl = self.controller.default_controller

        make_object = algorithm.create_identifier(
            self, 'pyplusplus::call_policies::make_object')
        make_tuple = algorithm.create_identifier(self,
                                                 'boost::python::make_tuple')

        tmpl_values = dict()

        tmpl_values['unique_function_name'] = self.default_name()
        tmpl_values['return_type'] = cntrl.wrapper_return_type.decl_string
        tmpl_values['arg_declarations'] = self.args_default_declaration()
        tmpl_values['wrapper_class'] = self.parent.wrapper_alias
        tmpl_values['wrapped_class'] = declarations.full_name(
            self.declaration.parent)
        tmpl_values['wrapped_inst'] = cntrl.inst_arg.name
        tmpl_values['wrapped_inst_constness'] = ''
        if declarations.is_const(
                declarations.remove_reference(cntrl.inst_arg.type)):
            tmpl_values['wrapped_inst_constness'] = 'const'

        decl_vars = cntrl.variables[:]
        if not declarations.is_void(self.declaration.return_type):
            decl_vars.append(cntrl.result_variable)
        tmpl_values['declare_variables'] \
            = os.linesep + os.linesep.join( map( lambda var: self.indent( var.declare_var_string() )
                                                 , decl_vars ) )

        tmpl_values['pre_call'] = os.linesep + self.indent(
            os.linesep.join(cntrl.pre_call))

        tmpl_values['save_result'] = ''
        if not declarations.is_void(self.declaration.return_type):
            tmpl_tmp = '%(result_var_name)s = '
            if declarations.is_reference(self.declaration.return_type):
                tmpl_tmp = tmpl_tmp + '&'
            tmpl_values['save_result'] = tmpl_tmp % dict(
                result_var_name=cntrl.result_variable.name)

        tmpl_values['function_name'] = self.declaration.name
        tmpl_values['arg_expressions'] = self.PARAM_SEPARATOR.join(
            cntrl.arg_expressions)
        return_stmt_creator = calldef_utils.return_stmt_creator_t(
            self, cntrl, cntrl.result_variable, cntrl.return_variables)

        tmpl_values['post_call'] = os.linesep + self.indent(
            os.linesep.join(cntrl.post_call))
        if return_stmt_creator.pre_return_code:
            tmpl_values['post_call'] \
                = os.linesep.join([ tmpl_values['post_call']
                                    , self.indent( return_stmt_creator.pre_return_code )])
        tmpl_values['return'] = os.linesep + self.indent(
            return_stmt_creator.statement)

        f_def = cntrl.template.substitute(tmpl_values)
        return remove_duplicate_linesep(f_def)
Ejemplo n.º 2
0
    def create_fun_definition(self):
        cntrl = self.controller

        make_object = algorithm.create_identifier(
            self, 'pyplusplus::call_policies::make_object')
        make_tuple = algorithm.create_identifier(self,
                                                 'boost::python::make_tuple')

        tmpl_values = dict()

        tmpl_values['unique_function_name'] = self.wrapper_name()
        tmpl_values[
            'return_type'] = self.controller.wrapper_return_type.decl_string
        tmpl_values['arg_declarations'] = self.args_declaration()

        tmpl_values['declare_variables'] \
            = os.linesep + os.linesep.join( map( lambda var: self.indent( var.declare_var_string() )
                                                 , cntrl.variables ) )

        tmpl_values['pre_call'] = os.linesep + self.indent(
            os.linesep.join(cntrl.pre_call))

        tmpl_values['save_result'] = ''
        if not declarations.is_void(self.declaration.return_type):
            tmpl_tmp = '%(type)s %(name)s = '
            if declarations.is_reference(self.declaration.return_type):
                tmpl_tmp = tmpl_tmp + '&'

            tmpl_values['save_result'] = tmpl_tmp \
                                         % { 'type': cntrl.result_variable.type.decl_string
                                             , 'name' : cntrl.result_variable.name }

        tmpl_values['function_name'] = self.resolve_function_ref()
        tmpl_values['arg_expressions'] = self.PARAM_SEPARATOR.join(
            cntrl.arg_expressions)
        return_stmt_creator = calldef_utils.return_stmt_creator_t(
            self, self.controller, self.controller.result_variable,
            self.controller.return_variables)

        tmpl_values['post_call'] = os.linesep + self.indent(
            os.linesep.join(cntrl.post_call))
        if return_stmt_creator.pre_return_code:
            tmpl_values['post_call'] \
                = os.linesep.join([ tmpl_values['post_call']
                                    , self.indent( return_stmt_creator.pre_return_code )])
        tmpl_values['return'] = os.linesep + self.indent(
            return_stmt_creator.statement)

        f_def = self.controller.template.substitute(tmpl_values)
        return remove_duplicate_linesep(f_def)
Ejemplo n.º 3
0
    def create_default(self):
        cntrl = self.controller.default_controller

        make_object = algorithm.create_identifier( self, 'pyplusplus::call_policies::make_object' )
        make_tuple = algorithm.create_identifier( self, 'boost::python::make_tuple' )
        
        tmpl_values = dict()

        tmpl_values['unique_function_name'] = self.default_name()
        tmpl_values['return_type'] = cntrl.wrapper_return_type.decl_string
        tmpl_values['arg_declarations'] = self.args_default_declaration()        
        tmpl_values['wrapper_class'] = self.parent.wrapper_alias
        tmpl_values['wrapped_class'] = declarations.full_name( self.declaration.parent )
        tmpl_values['wrapped_inst'] = cntrl.inst_arg.name
        tmpl_values['wrapped_inst_constness'] = ''
        if declarations.is_const( declarations.remove_reference( cntrl.inst_arg.type ) ):
            tmpl_values['wrapped_inst_constness'] = 'const'
            
        decl_vars = cntrl.variables[:]
        if not declarations.is_void( self.declaration.return_type ):
            decl_vars.append( cntrl.result_variable )
        tmpl_values['declare_variables'] \
            = os.linesep + os.linesep.join( map( lambda var: self.indent( var.declare_var_string() )
                                                 , decl_vars ) )
                
        tmpl_values['pre_call'] = os.linesep + self.indent( os.linesep.join( cntrl.pre_call ) )

        tmpl_values['save_result'] = ''
        if not declarations.is_void( self.declaration.return_type ):
            tmpl_tmp = '%(result_var_name)s = '
            if declarations.is_reference( self.declaration.return_type ):
                tmpl_tmp = tmpl_tmp + '&'
            tmpl_values['save_result'] = tmpl_tmp % dict( result_var_name=cntrl.result_variable.name )

        tmpl_values['function_name'] = self.declaration.name
        tmpl_values['arg_expressions'] = self.PARAM_SEPARATOR.join( cntrl.arg_expressions )
        return_stmt_creator = calldef_utils.return_stmt_creator_t( self
                                    , cntrl
                                    , cntrl.result_variable
                                    , cntrl.return_variables )

        tmpl_values['post_call'] = os.linesep + self.indent( os.linesep.join( cntrl.post_call ) )
        if return_stmt_creator.pre_return_code:
            tmpl_values['post_call'] \
                = os.linesep.join([ tmpl_values['post_call']
                                    , self.indent( return_stmt_creator.pre_return_code )])
        tmpl_values['return'] = os.linesep + self.indent( return_stmt_creator.statement )
            
        f_def = cntrl.template.substitute(tmpl_values)
        return remove_duplicate_linesep( f_def )
Ejemplo n.º 4
0
    def create_fun_definition(self):
        cntrl = self.controller

        make_object = algorithm.create_identifier( self, 'pyplusplus::call_policies::make_object' )
        make_tuple = algorithm.create_identifier( self, 'boost::python::make_tuple' )
        
        tmpl_values = dict()

        tmpl_values['unique_function_name'] = self.wrapper_name()
        tmpl_values['return_type'] = self.controller.wrapper_return_type.decl_string
        tmpl_values['arg_declarations'] = self.args_declaration()
        
        tmpl_values['declare_variables'] \
            = os.linesep + os.linesep.join( map( lambda var: self.indent( var.declare_var_string() )
                                                 , cntrl.variables ) )
                
        tmpl_values['pre_call'] = os.linesep + self.indent( os.linesep.join( cntrl.pre_call ) )

        tmpl_values['save_result'] = ''
        if not declarations.is_void( self.declaration.return_type ):
            tmpl_tmp = '%(type)s %(name)s = '
            if declarations.is_reference( self.declaration.return_type ):
                tmpl_tmp = tmpl_tmp + '&'

            tmpl_values['save_result'] = tmpl_tmp \
                                         % { 'type': cntrl.result_variable.type.decl_string
                                             , 'name' : cntrl.result_variable.name }

        tmpl_values['function_name'] = self.resolve_function_ref()
        tmpl_values['arg_expressions'] = self.PARAM_SEPARATOR.join( cntrl.arg_expressions )
        return_stmt_creator = calldef_utils.return_stmt_creator_t( self
                                    , self.controller
                                    , self.controller.result_variable
                                    , self.controller.return_variables )

        tmpl_values['post_call'] = os.linesep + self.indent( os.linesep.join( cntrl.post_call ) )
        if return_stmt_creator.pre_return_code:
            tmpl_values['post_call'] \
                = os.linesep.join([ tmpl_values['post_call']
                                    , self.indent( return_stmt_creator.pre_return_code )])
        tmpl_values['return'] = os.linesep + self.indent( return_stmt_creator.statement )
            
        f_def = self.controller.template.substitute(tmpl_values)
        return remove_duplicate_linesep( f_def )