Back to index

enigmail  1.4.3
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Static Private Attributes
xpt.StringWithSizeType Class Reference
Inheritance diagram for xpt.StringWithSizeType:
Inheritance graph
[legend]
Collaboration diagram for xpt.StringWithSizeType:
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

 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 a UTF-8 encoded string whose size and length
are passed as separate arguments to a method. (StringWithSizeTypeDescriptor
from the typelib specification.)

Definition at line 409 of file xpt.py.


Constructor & Destructor Documentation

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

Definition at line 419 of file xpt.py.

00419 
00420                  pointer=True, **kwargs):
00421         if not pointer:
00422             raise DataError, "StringWithSizeType is not valid with pointer=False"
00423         Type.__init__(self, pointer=pointer, **kwargs)
00424         self.size_is_arg_num = size_is_arg_num
00425         self.length_is_arg_num = length_is_arg_num
00426         self.tag = Type.Tags.StringWithSize


Member Function Documentation

Definition at line 453 of file xpt.py.

00453 
00454     def __str__(self):
00455         return "string_s"

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

Definition at line 428 of file xpt.py.

00428 
00429     def read(typelib, map, data_pool, offset, flags):
00430         """
00431         Read an StringWithSizeTypeDescriptor at |offset| from the mmaped
00432         file |map| with data pool offset |data_pool|.
00433         Returns (StringWithSizeType, next offset),
00434         where |next offset| is an offset suitable for reading the data
00435         following this StringWithSizeTypeDescriptor.
00436         """
00437         if not flags['pointer']:
00438             return None, offset
00439         start = data_pool + offset - 1
00440         (size_is_arg_num, length_is_arg_num) = StringWithSizeType._descriptor.unpack(map[start:start + StringWithSizeType._descriptor.size])
00441         offset += StringWithSizeType._descriptor.size
00442         return StringWithSizeType(size_is_arg_num, length_is_arg_num, **flags), offset

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

Reimplemented from xpt.Type.

Definition at line 443 of file xpt.py.

00443 
00444     def write(self, typelib, file):
00445         """
00446         Write a StringWithSizeTypeDescriptor to |file|, which is assumed
00447         to be seeked to the proper position.
00448 
00449         """
00450         Type.write(self, typelib, file)
00451         file.write(StringWithSizeType._descriptor.pack(self.size_is_arg_num,
00452                                                        self.length_is_arg_num))


Member Data Documentation

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

Definition at line 416 of file xpt.py.

Definition at line 424 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 423 of file xpt.py.

Definition at line 425 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: