Back to index

enigmail  1.4.3
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Static Private Attributes
xpt.Type Class Reference
Inheritance diagram for xpt.Type:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
def encodeflags
def write

Static Public Member Functions

def decodeflags
def read

Public Attributes

 pointer
 reference

Static Public Attributes

tuple Tags

Static Private Attributes

tuple _prefixdescriptor = struct.Struct(">B")

Detailed Description

Data type of a method parameter or return value. Do not instantiate
this class directly. Rather, use one of its subclasses.

Definition at line 98 of file xpt.py.


Constructor & Destructor Documentation

def xpt.Type.__init__ (   self,
  pointer = False,
  reference = False 
)

Reimplemented in xpt.SimpleType.

Definition at line 144 of file xpt.py.

00144 
00145     def __init__(self, pointer=False, reference=False):
00146         self.pointer = pointer
00147         self.reference = reference
00148         if reference and not pointer:
00149             raise Exception("If reference is True pointer must be True too")


Member Function Documentation

def xpt.Type.decodeflags (   byte) [static]
Given |byte|, an unsigned uint8 containing flag bits,
decode the flag bits as described in
http://www.mozilla.org/scriptable/typelib_file.html#TypeDescriptor
and return a dict of flagname: (True|False) suitable
for passing to Type.__init__ as **kwargs.

Definition at line 151 of file xpt.py.

00151 
00152     def decodeflags(byte):
00153         """
00154         Given |byte|, an unsigned uint8 containing flag bits,
00155         decode the flag bits as described in
00156         http://www.mozilla.org/scriptable/typelib_file.html#TypeDescriptor
00157         and return a dict of flagname: (True|False) suitable
00158         for passing to Type.__init__ as **kwargs.
00159         
00160         """
00161         return {'pointer': bool(byte & 0x80),
00162                 'reference': bool(byte & 0x20),
00163                 }

def xpt.Type.encodeflags (   self)
Encode the flag bits of this Type object. Returns a byte.

Definition at line 164 of file xpt.py.

00164 
00165     def encodeflags(self):
00166         """
00167         Encode the flag bits of this Type object. Returns a byte.
00168 
00169         """
00170         flags = 0
00171         if self.pointer:
00172             flags |= 0x80
00173         if self.reference:
00174             flags |= 0x20
00175         return flags

Here is the caller graph for this function:

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

Definition at line 177 of file xpt.py.

00177 
00178     def read(typelib, map, data_pool, offset):
00179         """
00180         Read a TypeDescriptor at |offset| from the mmaped file |map| with
00181         data pool offset |data_pool|. Returns (Type, next offset),
00182         where |next offset| is an offset suitable for reading the data
00183         following this TypeDescriptor.
00184         
00185         """
00186         start = data_pool + offset - 1
00187         (data,) = Type._prefixdescriptor.unpack(map[start:start + Type._prefixdescriptor.size])
00188         # first three bits are the flags
00189         flags = data & 0xE0
00190         flags = Type.decodeflags(flags)
00191         # last five bits is the tag
00192         tag = data & 0x1F
00193         offset += Type._prefixdescriptor.size
00194         t = None
00195         if tag <= Type.Tags.wchar_t_ptr or tag >= Type.Tags.UTF8String:
00196             t = SimpleType.get(data, tag, flags)
00197         elif tag == Type.Tags.Interface:
00198             t, offset = InterfaceType.read(typelib, map, data_pool, offset, flags)
00199         elif tag == Type.Tags.InterfaceIs:
00200             t, offset = InterfaceIsType.read(typelib, map, data_pool, offset, flags)
00201         elif tag == Type.Tags.Array:
00202             t, offset = ArrayType.read(typelib, map, data_pool, offset, flags)
00203         elif tag == Type.Tags.StringWithSize:
00204             t, offset = StringWithSizeType.read(typelib, map, data_pool, offset, flags)
00205         elif tag == Type.Tags.WideStringWithSize:
00206             t, offset = WideStringWithSizeType.read(typelib, map, data_pool, offset, flags)
00207         return t, offset

def xpt.Type.write (   self,
  typelib,
  file 
)
Write a TypeDescriptor to |file|, which is assumed
to be seeked to the proper position. For types other than
SimpleType, this is not sufficient for writing the TypeDescriptor,
and the subclass method must be called.

Reimplemented in xpt.WideStringWithSizeType, xpt.StringWithSizeType, xpt.ArrayType, xpt.InterfaceIsType, and xpt.InterfaceType.

Definition at line 208 of file xpt.py.

00208 
00209     def write(self, typelib, file):
00210         """
00211         Write a TypeDescriptor to |file|, which is assumed
00212         to be seeked to the proper position. For types other than
00213         SimpleType, this is not sufficient for writing the TypeDescriptor,
00214         and the subclass method must be called.
00215 
00216         """
00217         file.write(Type._prefixdescriptor.pack(self.encodeflags() | self.tag))

Here is the call graph for this function:


Member Data Documentation

tuple xpt.Type._prefixdescriptor = struct.Struct(">B") [static, private]

Definition at line 104 of file xpt.py.

Definition at line 145 of file xpt.py.

Definition at line 146 of file xpt.py.

tuple xpt.Type.Tags [static]

Definition at line 105 of file xpt.py.


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