Back to index

enigmail  1.4.3
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes | Static Private Attributes
xpt.Constant Class Reference

List of all members.

Public Member Functions

def __init__
def write
def write_name
def __repr__

Static Public Member Functions

def read

Public Attributes

 name
 type
 value

Static Public Attributes

dictionary typemap

Private Attributes

 _name_offset

Static Private Attributes

tuple _descriptorstart = struct.Struct(">I")

Detailed Description

A constant value of a specific type defined on an interface.
(ConstantDesciptor from the typelib specification.)

Definition at line 763 of file xpt.py.


Constructor & Destructor Documentation

def xpt.Constant.__init__ (   self,
  name,
  type,
  value 
)

Definition at line 778 of file xpt.py.

00778 
00779     def __init__(self, name, type, value):
00780         self.name = name
00781         self._name_offset = 0
00782         self.type = type
00783         self.value = value


Member Function Documentation

def xpt.Constant.__repr__ (   self)

Definition at line 832 of file xpt.py.

00832 
00833     def __repr__(self):
00834         return "Constant(%s, %s, %d)" % (self.name, str(self.type), self.value)

def xpt.Constant.read (   typelib,
  map,
  data_pool,
  offset 
) [static]
Read a ConstDescriptor at |offset| from the mmaped file |map| with
data pool offset |data_pool|. Returns (Constant, next offset),
where |next offset| is an offset suitable for reading the data
following this ConstDescriptor.

Definition at line 785 of file xpt.py.

00785 
00786     def read(typelib, map, data_pool, offset):
00787         """
00788         Read a ConstDescriptor at |offset| from the mmaped file |map| with
00789         data pool offset |data_pool|. Returns (Constant, next offset),
00790         where |next offset| is an offset suitable for reading the data
00791         following this ConstDescriptor.
00792         
00793         """
00794         start = data_pool + offset - 1
00795         (name_offset,) = Constant._descriptorstart.unpack(map[start:start + Constant._descriptorstart.size])
00796         name = Typelib.read_string(map, data_pool, name_offset)
00797         offset += Constant._descriptorstart.size
00798         # Read TypeDescriptor
00799         t, offset = Type.read(typelib, map, data_pool, offset)
00800         c = None
00801         if isinstance(t, SimpleType) and t.tag in Constant.typemap:
00802             tt = Constant.typemap[t.tag]
00803             start = data_pool + offset - 1
00804             (val,) = struct.unpack(tt, map[start:start + struct.calcsize(tt)])
00805             offset += struct.calcsize(tt)
00806             c = Constant(name, t, val)
00807         return c, offset

def xpt.Constant.write (   self,
  typelib,
  file 
)
Write a ConstDescriptor to |file|, which is assumed
to be seeked to the proper position.

Definition at line 808 of file xpt.py.

00808 
00809     def write(self, typelib, file):
00810         """
00811         Write a ConstDescriptor to |file|, which is assumed
00812         to be seeked to the proper position.
00813 
00814         """
00815         file.write(Constant._descriptorstart.pack(self._name_offset))
00816         self.type.write(typelib, file)
00817         tt = Constant.typemap[self.type.tag]
00818         file.write(struct.pack(tt, self.value))

def xpt.Constant.write_name (   self,
  file,
  data_pool_offset 
)
Write this constants's name to |file|.
Assumes that |file| is currently seeked to an unused portion
of the data pool.

Definition at line 819 of file xpt.py.

00819 
00820     def write_name(self, file, data_pool_offset):
00821         """
00822         Write this constants's name to |file|.
00823         Assumes that |file| is currently seeked to an unused portion
00824         of the data pool.
00825 
00826         """
00827         if self.name:
00828             self._name_offset = file.tell() - data_pool_offset + 1
00829             file.write(self.name + "\x00")
00830         else:
00831             self._name_offset = 0


Member Data Documentation

tuple xpt.Constant._descriptorstart = struct.Struct(">I") [static, private]

Definition at line 769 of file xpt.py.

Definition at line 780 of file xpt.py.

Definition at line 779 of file xpt.py.

Definition at line 781 of file xpt.py.

dictionary xpt.Constant.typemap [static]
Initial value:
{Type.Tags.int16: '>h',
               Type.Tags.uint16: '>H',
               Type.Tags.int32: '>i',
               Type.Tags.uint32: '>I'}

Definition at line 773 of file xpt.py.

Definition at line 782 of file xpt.py.


The documentation for this class was generated from the following file: