Package pyplusplus :: Package code_creators :: Module calldef_transformed

Source Code for Module pyplusplus.code_creators.calldef_transformed

  1  # Copyright 2004-2008 Roman Yakovenko 
  2  # Distributed under the Boost Software License, Version 1.0. (See 
  3  # accompanying file LICENSE_1_0.txt or copy at 
  4  # http://www.boost.org/LICENSE_1_0.txt) 
  5   
  6  import os 
  7  import algorithm 
  8  import code_creator 
  9  import calldef_utils 
 10  import class_declaration 
 11  from pygccxml import declarations 
 12  from pyplusplus import code_repository 
 13  from calldef import calldef_t, calldef_wrapper_t 
 14  import pyplusplus.function_transformers as function_transformers 
15 16 #TODO: constructors also can have transformation defined. We should use make _init 17 # function for this purpose 18 19 -def remove_duplicate_linesep( code ):
20 lines = code.split( os.linesep ) 21 lines = filter( lambda line: line.strip(), lines ) 22 return os.linesep.join( lines )
23
24 -class sealed_fun_transformed_t( calldef_t ):
25 - def __init__( self, function, wrapper=None ):
27 28 @property
29 - def ft( self ): #function transformation
30 return self.declaration.transformations[0]
31 32 @property
33 - def controller( self ):
34 return self.ft.controller
35
36 - def _get_alias_impl( self ):
37 return self.wrapper.ft.alias
38
39 - def create_function_type_alias_code( self, exported_class_alias=None ):
40 ftype = self.wrapper.function_type() 41 return 'typedef %s;' % ftype.create_typedef( self.function_type_alias, exported_class_alias )
42
43 - def create_function_ref_code(self, use_function_alias=False):
44 full_name = self.wrapper.full_name() 45 46 if use_function_alias: 47 return '%s( &%s )' \ 48 % ( self.function_type_alias, full_name ) 49 elif self.declaration.create_with_signature: 50 func_type = self.wrapper.function_type() 51 return '(%s)( &%s )' % ( func_type, full_name ) 52 else: 53 return '&%s' % full_name
54
55 - def create_call_policies( self ):
56 return ''
57
58 -class sealed_fun_transformed_wrapper_t( calldef_wrapper_t ):
59 - def __init__( self, function ):