1
2
3
4
5
6 """
7 defines classes, that describe C++ types
8 """
9
10 import compilers
11 import algorithms_cache
14 """base class for all types"""
21
23 res = self.decl_string
24 if res[:2]=="::":
25 res = res[2:]
26 return res
27
32
34 return not self.__eq__( other )
35
37 if not isinstance( other, self.__class__ ):
38 return self.__class__.__name__ < other.__class__.__name__
39 return self.decl_string < other.decl_string
40
42 raise NotImplementedError()
43
44 @property
47
48 @property
51
53 raise NotImplementedError()
54
56 "returns new instance of the type"
57 answer = self._clone_impl()
58 return answer
59
61 return self._byte_size
63 self._byte_size = new_byte_size
64 byte_size = property( _get_byte_size, _set_byte_size
65 , doc="Size of this type in bytes @type: int")
66
72 self._byte_align = new_byte_align
73 byte_align = property( _get_byte_align, _set_byte_align
74 , doc="Alignment of this type in bytes @type: int")
75
83 """provides L{type_t} interface for a string, that defines C++ type.
84
85 This class could be very useful in the code generator.
86 """
90
92 return self._decl_string
93
96
98 "type, that represents all C++ types, that could not be parsed by GCC-XML"
101
104
107
109 """type, that represents "..." in function definition"""
112
115
118
123 """base class for all fundamental, build-in types"""
127
130
133
135 """base class for all JNI defined fundamental types"""
138
139 -class void_t( fundamental_t ):
140 """represents void type"""
141 CPPNAME = 'void'
144
145 -class char_t( fundamental_t ):
146 """represents char type"""
147 CPPNAME = 'char'
150
152 """represents signed char type"""
153 CPPNAME = 'signed char'
156
158 """represents unsigned char type"""
159 CPPNAME = 'unsigned char'
162
164 """represents wchar_t type"""
165 CPPNAME = 'wchar_t'
168
170 """represents short int type"""
171 CPPNAME = 'short int'
174
176 """represents short unsigned int type"""
177 CPPNAME = 'short unsigned int'
180
181 -class bool_t( fundamental_t ):
182 """represents bool type"""
183 CPPNAME = 'bool'
186
187 -class int_t( fundamental_t ):
188 """represents int type"""
189 CPPNAME = 'int'
192
194 """represents unsigned int type"""
195 CPPNAME = 'unsigned int'
198
200 """represents long int type"""
201 CPPNAME = 'long int'
204
206 """represents long unsigned int type"""
207 CPPNAME = 'long unsigned int'
210
212 """represents long long int type"""
213 CPPNAME = 'long long int'
216
218 """represents long long unsigned int type"""
219 CPPNAME = 'long long unsigned int'
222
224 """represents float type"""
225 CPPNAME = 'float'
228
230 """represents double type"""
231 CPPNAME = 'double'
234
236 """represents long double type"""
237 CPPNAME = 'long double'
240
242 """represents complex double type"""
243 CPPNAME = 'complex double'
246
248 """represents complex long double type"""
249 CPPNAME = 'complex long double'
252
254 """represents complex float type"""
255 CPPNAME = 'complex float'
258
259 -class jbyte_t( java_fundamental_t ):
260 """represents jbyte type"""
261 JNAME = 'jbyte'
264
266 """represents jshort type"""
267 JNAME = 'jshort'
270
271 -class jint_t( java_fundamental_t ):
272 """represents jint type"""
273 JNAME = 'jint'
276
277 -class jlong_t( java_fundamental_t ):
278 """represents jlong type"""
279 JNAME = 'jlong'
282
284 """represents jfloat type"""
285 JNAME = 'jfloat'
288
290 """represents jdouble type"""
291 JNAME = 'jdouble'
294
295 -class jchar_t( java_fundamental_t ):
296 """represents jchar type"""
297 JNAME = 'jchar'
300
302 """represents jboolean type"""
303 JNAME = 'jboolean'
306
307 FUNDAMENTAL_TYPES = {
308 void_t.CPPNAME : void_t()
309 , char_t.CPPNAME : char_t()
310 , signed_char_t.CPPNAME : signed_char_t()
311 , unsigned_char_t.CPPNAME : unsigned_char_t()
312 , wchar_t.CPPNAME : wchar_t()
313 , short_int_t.CPPNAME : short_int_t()
314 , 'signed ' + short_int_t.CPPNAME : short_int_t()
315 , short_unsigned_int_t.CPPNAME : short_unsigned_int_t()
316 , bool_t.CPPNAME : bool_t()
317 , int_t.CPPNAME : int_t()
318 , 'signed ' + int_t.CPPNAME : int_t()
319 , unsigned_int_t.CPPNAME : unsigned_int_t()
320 , long_int_t.CPPNAME : long_int_t()
321 , long_unsigned_int_t.CPPNAME : long_unsigned_int_t()
322 , long_long_int_t.CPPNAME : long_long_int_t()
323 , long_long_unsigned_int_t.CPPNAME : long_long_unsigned_int_t()
324 , float_t.CPPNAME : float_t()
325 , double_t.CPPNAME : double_t()
326 , long_double_t.CPPNAME : long_double_t()
327 , complex_long_double_t.CPPNAME : complex_long_double_t()
328 , complex_double_t.CPPNAME : complex_double_t()
329 , complex_float_t.CPPNAME : complex_float_t()
330
331 , jbyte_t.JNAME : jbyte_t()
332 , jshort_t.JNAME : jshort_t()
333 , jint_t.JNAME : jint_t()
334 , jlong_t.JNAME : jlong_t()
335 , jfloat_t.JNAME : jfloat_t()
336 , jdouble_t.JNAME : jdouble_t()
337 , jchar_t.JNAME : jchar_t()
338 , jboolean_t.JNAME : jboolean_t()
339 , '__java_byte' : jbyte_t()
340 , '__java_short' : jshort_t()
341 , '__java_int' : jint_t()
342 , '__java_long' : jlong_t()
343 , '__java_float' : jfloat_t()
344 , '__java_double' : jdouble_t()
345 , '__java_char' : jchar_t()
346 , '__java_boolean' : jboolean_t()
347 }
348 """
349 defines a mapping between fundamental type name and its synonym to the instance
350 of class that describes the type
351 """
357 """class that allows to represent compound types like C{const int*}"""
361
365 self._base = new_base
366
367 base = property( _get_base, _set_base
368 , doc="reference to internal/base class")
369
371 """represents C{volatile whatever} type"""
374
377
380
382 """represents C{restrict whatever} type"""
383
384
385
386
387
388
389
390
391
392
395
398
401
403 """represents C{whatever const} type"""
406
409
412
414 """represents C{whatever*} type"""
417
420
423
425 """represents C{whatever&} type"""
428
431
434
447 size = property( _get_size, _set_size,
448 doc="returns array size" )
449
452
455
482
485 """describes free function type"""
486 NAME_TEMPLATE = '%(return_type)s (*)( %(arguments)s )'
487 TYPEDEF_NAME_TEMPLATE = '%(return_type)s ( *%(typedef_name)s )( %(arguments)s )'
488 - def __init__( self, return_type=None, arguments_types=None ):
491
492 @staticmethod
508
511
518
519
520 - def create_typedef( self, typedef_name, unused=None, with_defaults=True):
531
533 """describes member function type"""
534 NAME_TEMPLATE = '%(return_type)s ( %(class)s::* )( %(arguments)s ) %(has_const)s'
535 TYPEDEF_NAME_TEMPLATE = '%(return_type)s ( %(class)s::*%(typedef_name)s )( %(arguments)s ) %(has_const)s'
536
537 - def __init__( self, class_inst=None, return_type=None, arguments_types=None, has_const=False):
542
544 return self._has_const
547 has_const = property( _get_has_const, _set_has_const
548 , doc="describes, whether function has const modifier")
549
551 return self._class_inst
554 class_inst = property( _get_class_inst, _set_class_inst
555 ,doc="reference to parent L{class<declaration_t>}" )
556
557
558 - def create_typedef( self, typedef_name, class_alias=None, with_defaults=True):
579
585
586
587 @staticmethod
588 - def create_decl_string(return_type, class_decl_string, arguments_types, has_const, with_defaults=True):
601
608
618
641
647 """class that binds between to hierarchies: L{type_t} and L{declaration_t}"""
651
653 return self._declaration
655 self._declaration = new_declaration
656 declaration = property( _get_declaration, _set_declaration
657 , doc="reference to L{declaration<declaration_t>}")
658
664
667
668 @property
670 "Size of this type in bytes @type: int"
671 return self._declaration.byte_size
672
673 @property
675 "alignment of this type in bytes @type: int"
676 return self._declaration.byte_align
677
711