Package pygccxml :: Package declarations :: Module variable

# Source Code for Module pygccxml.declarations.variable

     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  """
     7  defines class that describes C++ global and member variable declaration
     8  """
     9
    10  import declaration
    11  import dependencies
    12  import class_declaration
    13
    14 -class variable_t( declaration.declaration_t ):
    15      """describes C++ global and member variable declaration"""
    16
    17 -    def __init__( self, name='', type=None, type_qualifiers=None, value=None, bits=None):
    18          """creates class that describes C++ global or member variable"""
    19          declaration.declaration_t.__init__( self, name )
    20          self._type = type
    21          self._type_qualifiers = type_qualifiers
    22          self._value = value
    23          self._bits = bits
    24          self._byte_offset = 0
    25
    26 -    def _get__cmp__items( self ):
    27          """implementation details"""
    28          return [ self.type, self.type_qualifiers, self.value ]
    29
    30 -    def __eq__(self, other):
    31          """implementation details"""
    32          if not declaration.declaration_t.__eq__( self, other ):
    33              return False
    34          return self.type == other.type \
    35                 and self.type_qualifiers == other.type_qualifiers \
    36                 and self.value == other.value \
    37                 and self.bits == other.bits
    38
    39 -    def _get_type(self):
    40          return self._type
    41 -    def _set_type(self, type):
    42          self._type = type
    43      type = property( _get_type, _set_type
    44                       , doc="reference to the variable L{type<type_t>}"    )
    45
    46 -    def _get_type_qualifiers(self):
    47          return self._type_qualifiers
    48 -    def _set_type_qualifiers(self, type_qualifiers):
    49          self._type_qualifiers = type_qualifiers
    50      type_qualifiers = property( _get_type_qualifiers, _set_type_qualifiers
    51                                  , doc="reference to the L{type_qualifiers_t} instance" )
    52
    53 -    def _get_value(self):
    54          return self._value
    55 -    def _set_value(self, value):
    56          self._value = value
    57      value = property( _get_value, _set_value
    58                        , doc="string, that contains the variable value"    )
    59
    60 -    def _get_bits(self):
    61          return self._bits
    62 -    def _set_bits(self, bits):
    63          self._bits = bits
    64      bits = property( _get_bits, _set_bits
    65                       , doc="integer, that contains information about how many bit takes bit field")
    66
    67 -    def _get_byte_offset(self):
    68          return self._byte_offset
    69 -    def _set_byte_offset(self, byte_offset):
    70          self._byte_offset = byte_offset
    71      byte_offset = property( _get_byte_offset, _set_byte_offset
    72                              , doc="integer, offset of the field from the beginning of class.")
    73
    74
    75      @property
    76 -    def access_type(self):
    77          if not isinstance( self.parent, class_declaration.class_t ):
    78              raise RuntimeError( "access_type functionality only available on member variables and not on global variables" )
    79          return self.parent.find_out_member_access_type( self )
    80
    81 -    def i_depend_on_them( self, recursive=True ):
    82          return [ dependencies.dependency_info_t( self, self.type ) ]
    83