Back to index

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

List of all members.

Public Member Functions

def __init__
def read_params
def read_result
def encodeflags
def write
def write_name

Static Public Member Functions

def decodeflags
def read

Public Attributes

 name
 getter
 setter
 notxpcom
 constructor
 hidden
 optargc
 implicit_jscontext
 params
 result

Private Attributes

 _name_offset

Static Private Attributes

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

Detailed Description

A method of an interface, defining its associated parameters
and return value.
(MethodDescriptor from the typelib specification.)

Definition at line 621 of file xpt.py.


Constructor & Destructor Documentation

def xpt.Method.__init__ (   self,
  name,
  result,
  params = [],
  getter = False,
  setter = False,
  notxpcom = False,
  constructor = False,
  hidden = False,
  optargc = False,
  implicit_jscontext = False 
)

Definition at line 633 of file xpt.py.

00633 
00634                  implicit_jscontext=False):
00635         self.name = name
00636         self._name_offset = 0
00637         self.getter = getter
00638         self.setter = setter
00639         self.notxpcom = notxpcom
00640         self.constructor = constructor
00641         self.hidden = hidden
00642         self.optargc = optargc
00643         self.implicit_jscontext = implicit_jscontext
00644         self.params = list(params)
00645         if result and not isinstance(result, Param):
00646             raise Exception("result must be a Param!")
00647         self.result = result


Member Function Documentation

def xpt.Method.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#MethodDescriptor
and return a dict of flagname: (True|False) suitable
for passing to Method.__init__ as **kwargs

Definition at line 673 of file xpt.py.

00673 
00674     def decodeflags(byte):
00675         """
00676         Given |byte|, an unsigned uint8 containing flag bits,
00677         decode the flag bits as described in
00678         http://www.mozilla.org/scriptable/typelib_file.html#MethodDescriptor
00679         and return a dict of flagname: (True|False) suitable
00680         for passing to Method.__init__ as **kwargs
00681         
00682         """
00683         return {'getter': bool(byte & 0x80),
00684                 'setter': bool(byte & 0x40),
00685                 'notxpcom': bool(byte & 0x20),
00686                 'constructor': bool(byte & 0x10),
00687                 'hidden': bool(byte & 0x08),
00688                 # Not in the spec, see
00689                 # http://hg.mozilla.org/mozilla-central/annotate/0e0e2516f04e/xpcom/typelib/xpt/public/xpt_struct.h#l489
00690                 'optargc': bool(byte & 0x04),
00691                 'implicit_jscontext': bool(byte & 0x02),
00692                 }

def xpt.Method.encodeflags (   self)
Encode the flags of this Method object, return a byte suitable
for writing to a typelib file.

Definition at line 693 of file xpt.py.

00693 
00694     def encodeflags(self):
00695         """
00696         Encode the flags of this Method object, return a byte suitable
00697         for writing to a typelib file.
00698 
00699         """
00700         flags = 0
00701         if self.getter:
00702             flags |= 0x80
00703         if self.setter:
00704             flags |= 0x40
00705         if self.notxpcom:
00706             flags |= 0x20
00707         if self.constructor:
00708             flags |= 0x10
00709         if self.hidden:
00710             flags |= 0x08
00711         if self.optargc:
00712             flags |= 0x04
00713         if self.implicit_jscontext:
00714             flags |= 0x02
00715         return flags

Here is the caller graph for this function:

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

Definition at line 717 of file xpt.py.

00717 
00718     def read(typelib, map, data_pool, offset):
00719         """
00720         Read a MethodDescriptor at |offset| from the mmaped file |map| with
00721         data pool offset |data_pool|. Returns (Method, next offset),
00722         where |next offset| is an offset suitable for reading the data
00723         following this MethodDescriptor.
00724         
00725         """
00726         start = data_pool + offset - 1
00727         flags, name_offset, num_args = Method._descriptorstart.unpack(map[start:start + Method._descriptorstart.size])
00728         # only the first seven bits are flags
00729         flags &= 0xFE
00730         flags = Method.decodeflags(flags)
00731         name = Typelib.read_string(map, data_pool, name_offset)
00732         m = Method(name, None, **flags)
00733         offset += Method._descriptorstart.size
00734         offset = m.read_params(typelib, map, data_pool, offset, num_args)
00735         offset = m.read_result(typelib, map, data_pool, offset)
00736         return m, offset

def xpt.Method.read_params (   self,
  typelib,
  map,
  data_pool,
  offset,
  num_args 
)
Read |num_args| ParamDescriptors representing this Method's arguments
from the mmaped file |map| with data pool at the offset |data_pool|,
starting at |offset| into self.params. Returns the offset
suitable for reading the data following the ParamDescriptor array.

Definition at line 648 of file xpt.py.

00648 
00649     def read_params(self, typelib, map, data_pool, offset, num_args):
00650         """
00651         Read |num_args| ParamDescriptors representing this Method's arguments
00652         from the mmaped file |map| with data pool at the offset |data_pool|,
00653         starting at |offset| into self.params. Returns the offset
00654         suitable for reading the data following the ParamDescriptor array.
00655         
00656         """
00657         for i in range(num_args):
00658             p, offset = Param.read(typelib, map, data_pool, offset)
00659             self.params.append(p)
00660         return offset

def xpt.Method.read_result (   self,
  typelib,
  map,
  data_pool,
  offset 
)
Read a ParamDescriptor representing this Method's return type
from the mmaped file |map| with data pool at the offset |data_pool|,
starting at |offset| into self.result. Returns the offset
suitable for reading the data following the ParamDescriptor.

Definition at line 661 of file xpt.py.

00661 
00662     def read_result(self, typelib, map, data_pool, offset):
00663         """
00664         Read a ParamDescriptor representing this Method's return type
00665         from the mmaped file |map| with data pool at the offset |data_pool|,
00666         starting at |offset| into self.result. Returns the offset
00667         suitable for reading the data following the ParamDescriptor.
00668         
00669         """
00670         self.result, offset = Param.read(typelib, map, data_pool, offset)
00671         return offset

def xpt.Method.write (   self,
  typelib,
  file 
)
Write a MethodDescriptor to |file|, which is assumed to be
seeked to the right position.

Definition at line 737 of file xpt.py.

00737 
00738     def write(self, typelib, file):
00739         """
00740         Write a MethodDescriptor to |file|, which is assumed to be
00741         seeked to the right position.
00742 
00743         """
00744         file.write(Method._descriptorstart.pack(self.encodeflags(),
00745                                                 self._name_offset,
00746                                                 len(self.params)))
00747         for p in self.params:
00748             p.write(typelib, file)
00749         self.result.write(typelib, file)

Here is the call graph for this function:

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

Definition at line 750 of file xpt.py.

00750 
00751     def write_name(self, file, data_pool_offset):
00752         """
00753         Write this method's name to |file|.
00754         Assumes that |file| is currently seeked to an unused portion
00755         of the data pool.
00756 
00757         """
00758         if self.name:
00759             self._name_offset = file.tell() - data_pool_offset + 1
00760             file.write(self.name + "\x00")
00761         else:
00762             self._name_offset = 0


Member Data Documentation

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

Definition at line 628 of file xpt.py.

Definition at line 635 of file xpt.py.

Definition at line 639 of file xpt.py.

Definition at line 636 of file xpt.py.

Definition at line 640 of file xpt.py.

Definition at line 642 of file xpt.py.

Definition at line 634 of file xpt.py.

Definition at line 638 of file xpt.py.

Definition at line 641 of file xpt.py.

Definition at line 643 of file xpt.py.

Definition at line 646 of file xpt.py.

Definition at line 637 of file xpt.py.


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