Package pyplusplus :: Package decl_wrappers :: Module class_wrapper

Source Code for Module pyplusplus.decl_wrappers.class_wrapper

  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  """defines class that configure class definition and class declaration exposing""" 
  7  
 
  8  import os 
  9  import user_text 
 10  import properties 
 11  import decl_wrapper 
 12  import scopedef_wrapper 
 13  from pyplusplus import messages 
 14  from pygccxml import declarations 
 15  import indexing_suite1 as isuite1 
 16  import indexing_suite2 as isuite2 
 17  
 
 18  ACCESS_TYPES = declarations.ACCESS_TYPES 
 19  VIRTUALITY_TYPES = declarations.VIRTUALITY_TYPES 
20 21 -class impl_details:
22 - class GUESS_VALUES: #guess always expose using scope values
23 TRUE = 'true' 24 FALSE = 'false' 25 ALWAYS_TRUE = 'always true' 26 all = [ TRUE, FALSE, ALWAYS_TRUE ]
27 28 29 always_expose_using_scope_documentation = \ 30 """boolean, configures how Py++ should generate code for class. 31 Py can generate code using IDL like syntax: 32 33 class_< ... >( ... ) 34 .def( ... ); 35 36 Or it can generate code using more complex form: 37 38 typedef bp::class_< my_class > my_class_exposer_t; 39 my_class_exposer_t my_class_exposer = my_class_exposer_t( "my_class" ); 40 boost::python::scope my_class_scope( my_class_exposer ); 41 my_class_exposer.def( ... ); 42 43 Also, the second way is much longer, it solves few problems: 44 45 - you can not expose enums and internal classes defined within the class using first method 46 - you will get much better compilation errors 47 - the code looks like regular C++ code after all :-) 48 49 By default, this property is set to False. Also, Py++ knows pretty well 50 when it have to ignore this property and generate right code 51 """
52 53 -class class_common_details_t( object ):
54 """defines few properties that are common to 55 L{class declaration<pygccxml.declarations.class_declaration_t>} and 56 L{definition<pygccxml.declarations.class_t>} classes 57 """
58 - def __init__(self):
59 object.__init__( self ) 60 self._always_expose_using_scope = None 61 self._indexing_suite = None 62 self._equality_comparable = None 63 self._less_than_comparable = None 64 self._isuite_version = 1 65 self._opaque = False
66
67 - def _get_indexing_suite_version( self ):
68 return self._isuite_version
69 - def _set_indexing_suite_version( self, version ):
70 assert version in ( 1, 2 ) 71 if self._isuite_version != version: 72 self._isuite_version = version 73 self._indexing_suite = None
74 indexing_suite_version = property( _get_indexing_suite_version, _set_indexing_suite_version 75 , doc="indexing suite version") 76 77 @property
78 - def indexing_suite( self ):
79 """reference to indexing suite configuration class. 80 81 If the class is not STD container, this property will contain None" 82 """ 83 if self._indexing_suite is None: 84 if self.container_traits: 85 if self._isuite_version == 1: 86 self._indexing_suite = isuite1.indexing_suite1_t( self ) 87 else: 88 self._indexing_suite = isuite2.indexing_suite2_t( self ) 89 return self._indexing_suite
90 97
99 tmp = self.guess_always_expose_using_scope_value() 100 if tmp == impl_details.GUESS_VALUES.ALWAYS_TRUE: 101 return True 102 if None is self._always_expose_using_scope: 103 if impl_details.GUESS_VALUES.TRUE == tmp: 104 self._always_expose_using_scope = True 105 else: 106 self._always_expose_using_scope = False 107 return self._always_expose_using_scope
108
109 - def _set_always_expose_using_scope( self, value ):
110 self._always_expose_using_scope = value
111 always_expose_using_scope = property( _get_always_expose_using_scope, _set_always_expose_using_scope 112 , doc="please see L{class_wrapper.always_expose_using_scope_documentation} variable for documentation." ) 113
114 - def _get_equality_comparable( self ):
115 if None is self._equality_comparable: 116 self._equality_comparable = declarations.has_public_equal( self ) 117 return self._equality_comparable
118
119 - def _set_equality_comparable( self, value ):
120 self._equality_comparable = value
121 122 equality_comparable = property( _get_equality_comparable, _set_equality_comparable 123 , doc="indicates existence of public operator=" \ 124 +"Default value is calculated, based on information presented in the declarations tree" ) 125
126 - def _get_less_than_comparable( self ):
127 if None is self._less_than_comparable: 128 self._less_than_comparable = declarations.has_public_less( self ) 129 return self._less_than_comparable
130
131 - def _set_less_than_comparable( self, value ):
132 self._less_than_comparable = value
133 134 less_than_comparable = property( _get_less_than_comparable, _set_less_than_comparable 135 , doc="indicates existence of public operator<. " \ 136 +"Default value is calculated, based on information presented in the declarations tree" ) 137
138 - def _get_opaque( self ):
139 return self._opaque
140
141 - def _set_opaque( self, value ):
142 self._opaque = value 143 self.ignore = value #don't expose opaque type
144 145