1   
 2   
 3   
 4   
 5   
 6   
 7   
 8  """defines few templates, which will be used to create a function-wrapper 
 9  definition.""" 
10   
11  import os 
12  from string import Template 
13   
14   
16      body = Template( os.linesep.join([ 
17            'static $return_type $unique_function_name( $arg_declarations ){' 
18          , '    $declare_variables' 
19          , '    $pre_call' 
20          , '    $save_result$function_name($arg_expressions);' 
21          , '    $post_call' 
22          , '    $return' 
23          , '}' 
24      ])) 
25   
27      override = Template( os.linesep.join([ 
28            'virtual $return_type $function_name( $arg_declarations )$constness $throw{' 
29          , '    namespace bpl = boost::python;' 
30          , '    if( bpl::override $py_function_var = this->get_override( "$function_alias" ) ){' 
31          , '        $declare_py_variables' 
32          , '        $py_pre_call' 
33          , '        ${save_py_result}bpl::call<bpl::object>( $py_function_var.ptr()$py_arg_expressions );' 
34          , '        $py_post_call' 
35          , '        $py_return' 
36          , '    }' 
37          , '    else{' 
38          , '        $cpp_return$wrapped_class::$function_name( $cpp_arg_expressions );' 
39          , '    }' 
40          , '}' 
41      ])) 
42       
43      default = Template( os.linesep.join([ 
44            'static $return_type $unique_function_name( $arg_declarations ){' 
45          , '    $declare_variables' 
46          , '    $pre_call' 
47          , '    if( dynamic_cast< $wrapper_class $wrapped_inst_constness* >( boost::addressof( $wrapped_inst ) ) ){' 
48          , '        $save_result$wrapped_inst.$wrapped_class::$function_name($arg_expressions);' 
49          , '    }' 
50          , '    else{' 
51          , '        $save_result$wrapped_inst.$function_name($arg_expressions);' 
52          , '    }' 
53          , '    $post_call' 
54          , '    $return' 
55          , '}' 
56      ])) 
57   
58   
59   
60       
61       
62       
63             
64           
65           
66           
67           
68           
69           
70       
71   
72   
75