Back to index

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

List of all members.

Public Member Functions

def __init__
def write
def __str__
def encodeflags

Static Public Member Functions

def read
def decodeflags
def read

Public Attributes

 element_type
 size_is_arg_num
 length_is_arg_num
 tag
 pointer
 reference

Static Public Attributes

tuple Tags

Static Private Attributes

tuple _descriptor = struct.Struct(">BB")

Detailed Description

A type representing an Array of elements of another type, whose
size and length are passed as separate parameters to a method.
(ArrayTypeDescriptor from the typelib specification.)

Definition at line 359 of file xpt.py.


Constructor & Destructor Documentation

def xpt.ArrayType.__init__ (   self,
  element_type,
  size_is_arg_num,
  length_is_arg_num,
  pointer = True,
  kwargs 
)

Definition at line 369 of file xpt.py.

00369 
00370                  pointer=True, **kwargs):
00371         if not pointer:
00372             raise DataError, "ArrayType is not valid with pointer=False"
00373         Type.__init__(self, pointer=pointer, **kwargs)
00374         self.element_type = element_type
00375         self.size_is_arg_num = size_is_arg_num
00376         self.length_is_arg_num = length_is_arg_num
00377         self.tag = Type.Tags.Array


Member Function Documentation

def xpt.ArrayType.__str__ (   self)

Definition at line 406 of file xpt.py.

00406 
00407     def __str__(self):
00408         return "%s []" % str(self.element_type)

def xpt.Type.decodeflags (   byte) [static, inherited]
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) [inherited]
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, inherited]
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.ArrayType.read (   typelib,
  map,
  data_pool,
  offset,
  flags 
) [static]
Read an ArrayTypeDescriptor at |offset| from the mmaped
file |map| with data pool offset |data_pool|.
Returns (ArrayType, next offset),
where |next offset| is an offset suitable for reading the data
following this ArrayTypeDescriptor.

Definition at line 379 of file xpt.py.

00379 
00380     def read(typelib, map, data_pool, offset, flags):
00381         """
00382         Read an ArrayTypeDescriptor at |offset| from the mmaped
00383         file |map| with data pool offset |data_pool|.
00384         Returns (ArrayType, next offset),
00385         where |next offset| is an offset suitable for reading the data
00386         following this ArrayTypeDescriptor.
00387         """
00388         if not flags['pointer']:
00389             return None, offset
00390         start = data_pool + offset - 1
00391         (size_is_arg_num, length_is_arg_num) = ArrayType._descriptor.unpack(map[start:start + ArrayType._descriptor.size])
00392         offset += ArrayType._descriptor.size
00393         t, offset = Type.read(typelib, map, data_pool, offset)
00394         return ArrayType(t, size_is_arg_num, length_is_arg_num, **flags), offset

def xpt.ArrayType.write (   self,
  typelib,
  file 
)
Write an ArrayTypeDescriptor to |file|, which is assumed
to be seeked to the proper position.

Reimplemented from xpt.Type.

Definition at line 395 of file xpt.py.

00395 
00396     def write(self, typelib, file):
00397         """
00398         Write an ArrayTypeDescriptor to |file|, which is assumed
00399         to be seeked to the proper position.
00400 
00401         """
00402         Type.write(self, typelib, file)
00403         file.write(ArrayType._descriptor.pack(self.size_is_arg_num,
00404                                               self.length_is_arg_num))
00405         self.element_type.write(typelib, file)


Member Data Documentation

tuple xpt.ArrayType._descriptor = struct.Struct(">BB") [static, private]

Definition at line 366 of file xpt.py.

Definition at line 373 of file xpt.py.

Definition at line 375 of file xpt.py.

xpt.Type.pointer [inherited]

Definition at line 145 of file xpt.py.

xpt.Type.reference [inherited]

Definition at line 146 of file xpt.py.

Definition at line 374 of file xpt.py.

Definition at line 376 of file xpt.py.

tuple xpt.Type.Tags [static, inherited]

Definition at line 105 of file xpt.py.


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