Trees | Indices | Help |
|
---|
|
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 declaration_based 9 import registration_based 1011 -class enum_t( registration_based.registration_based_t 12 , declaration_based.declaration_based_t ):13 """ 14 Creates boost.python code that expose C++ enum 15 """6917 registration_based.registration_based_t.__init__( self ) 18 declaration_based.declaration_based_t.__init__( self, declaration=enum) 19 self.works_on_instance = False20 25 value_aliases = property( _get_value_aliases, _set_value_aliases ) 26 31 export_values = property( _get_export_values, _set_export_values ) 3234 #in C++ you can't write namespace::enum::value, you should write namespace::value 35 full_name = self.declaration.parent.decl_string 36 return '.value("%(alias)s", %(name)s)' \ 37 % { 'alias' : self.value_aliases.get( value_name, value_name ) 38 , 'name' : algorithm.create_identifier( self, full_name + '::' + value_name ) }3941 if self.declaration.already_exposed: 42 return '' 43 44 bpl_enum = '%(bpl::enum_)s< %(name)s>("%(alias)s")' \ 45 % { 'bpl::enum_' : algorithm.create_identifier( self, '::boost::python::enum_' ) 46 , 'name' : algorithm.create_identifier( self, self.declaration.decl_string ) 47 , 'alias' : self.alias } 48 49 values = [] 50 # Add the values that should be exported 51 for value_name in self.declaration.export_values: 52 values.append( self._generate_value_code( value_name ) ) 53 54 # Export the values 55 if len(self.declaration.export_values)>0: 56 values.append( '.export_values()' ) 57 58 # Add the values that should not be exported 59 for name in self.declaration.no_export_values: 60 values.append( self._generate_value_code( name ) ) 61 62 values.append( ';' ) 63 64 values = self.indent( os.linesep.join( values ) ) 65 return bpl_enum + os.linesep + values66
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Mon Oct 20 08:51:40 2008 | http://epydoc.sourceforge.net |