Back to index

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

List of all members.

Public Member Functions

def __init__
def __repr__
def __str__
def __cmp__
def read_descriptor
def write_directory_entry
def write
def write_names

Public Attributes

 resolved
 iid
 name
 namespace
 parent
 methods
 constants
 scriptable
 function
 builtinclass
 xpt_filename

Static Public Attributes

string UNRESOLVED_IID = "00000000-0000-0000-0000-000000000000"

Private Attributes

 _descriptor_offset
 _name_offset
 _namespace_offset

Static Private Attributes

tuple _direntry = struct.Struct(">16sIII")
tuple _descriptorstart = struct.Struct(">HH")

Detailed Description

An Interface represents an object, with its associated methods
and constant values.
(InterfaceDescriptor from the typelib specification.)

Definition at line 835 of file xpt.py.


Constructor & Destructor Documentation

def xpt.Interface.__init__ (   self,
  name,
  iid = UNRESOLVED_IID,
  namespace = "",
  resolved = False,
  parent = None,
  methods = [],
  constants = [],
  scriptable = False,
  function = False,
  builtinclass = False 
)

Definition at line 849 of file xpt.py.

00849 
00850                  scriptable=False, function=False, builtinclass=False):
00851         self.resolved = resolved
00852         #TODO: should validate IIDs!
00853         self.iid = iid
00854         self.name = name
00855         self.namespace = namespace
00856         # if unresolved, all the members following this are unusable
00857         self.parent = parent
00858         self.methods = list(methods)
00859         self.constants = list(constants)
00860         self.scriptable = scriptable
00861         self.function = function
00862         self.builtinclass = builtinclass
00863         # For sanity, if someone constructs an Interface and passes
00864         # in methods or constants, then it's resolved.
00865         if self.methods or self.constants:
00866             # make sure it has a valid IID
00867             if self.iid == Interface.UNRESOLVED_IID:
00868                 raise DataError, "Cannot instantiate Interface %s containing methods or constants with an unresolved IID" % self.name
00869             self.resolved = True
00870         # These are only used for writing out the interface
00871         self._descriptor_offset = 0
00872         self._name_offset = 0
00873         self._namespace_offset = 0
00874         self.xpt_filename = None


Member Function Documentation

def xpt.Interface.__cmp__ (   self,
  other 
)

Definition at line 881 of file xpt.py.

00881 
00882     def __cmp__(self, other):
00883         c = cmp(self.iid, other.iid)
00884         if c != 0:
00885             return c
00886         c = cmp(self.name, other.name)
00887         if c != 0:
00888             return c
00889         c = cmp(self.namespace, other.namespace)
00890         if c != 0:
00891             return c
00892         # names and IIDs are the same, check resolved
00893         if self.resolved != other.resolved:
00894             if self.resolved:
00895                 return -1
00896             else:
00897                 return 1
00898         else:
00899             # both unresolved, but names and IIDs are the same, so equal
00900             return 0
00901         #TODO: actually compare methods etc
00902         return 0

def xpt.Interface.__repr__ (   self)

Definition at line 875 of file xpt.py.

00875 
00876     def __repr__(self):
00877         return "Interface('%s', '%s', '%s', methods=%s)" % (self.name, self.iid, self.namespace, self.methods)

def xpt.Interface.__str__ (   self)

Definition at line 878 of file xpt.py.

00878 
00879     def __str__(self):
00880         return "Interface(name='%s', iid='%s')" % (self.name, self.iid)

def xpt.Interface.read_descriptor (   self,
  typelib,
  map,
  data_pool 
)

Definition at line 903 of file xpt.py.

00903 
00904     def read_descriptor(self, typelib, map, data_pool):
00905         offset = self._descriptor_offset
00906         if offset == 0:
00907             return
00908         start = data_pool + offset - 1
00909         parent, num_methods = Interface._descriptorstart.unpack(map[start:start + Interface._descriptorstart.size])
00910         if parent > 0 and parent <= len(typelib.interfaces):
00911             self.parent = typelib.interfaces[parent - 1]
00912         # Read methods
00913         offset += Interface._descriptorstart.size
00914         for i in range(num_methods):
00915             m, offset = Method.read(typelib, map, data_pool, offset)
00916             self.methods.append(m)
00917         # Read constants
00918         start = data_pool + offset - 1
00919         (num_constants, ) = struct.unpack(">H", map[start:start + struct.calcsize(">H")])
00920         offset = offset + struct.calcsize(">H")
00921         for i in range(num_constants):
00922             c, offset = Constant.read(typelib, map, data_pool, offset)
00923             self.constants.append(c)
00924         # Read flags
00925         start = data_pool + offset - 1
00926         (flags, ) = struct.unpack(">B", map[start:start + struct.calcsize(">B")])
00927         offset = offset + struct.calcsize(">B")
00928         # only the first two bits are flags
00929         flags &= 0xE0
00930         if flags & 0x80:
00931             self.scriptable = True
00932         if flags & 0x40:
00933             self.function = True
00934         if flags & 0x20:
00935             self.builtinclass = True
00936         self.resolved = True

def xpt.Interface.write (   self,
  typelib,
  file,
  data_pool_offset 
)
Write an InterfaceDescriptor to |file|, which is assumed
to be seeked to the proper position. If this interface
is not resolved, do not write any data.

Definition at line 948 of file xpt.py.

00948 
00949     def write(self, typelib, file, data_pool_offset):
00950         """
00951         Write an InterfaceDescriptor to |file|, which is assumed
00952         to be seeked to the proper position. If this interface
00953         is not resolved, do not write any data.
00954 
00955         """
00956         if not self.resolved:
00957             self._descriptor_offset = 0
00958             return
00959         self._descriptor_offset = file.tell() - data_pool_offset + 1
00960         parent_idx = 0
00961         if self.parent:
00962             parent_idx = typelib.interfaces.index(self.parent) + 1
00963         file.write(Interface._descriptorstart.pack(parent_idx, len(self.methods)))
00964         for m in self.methods:
00965             m.write(typelib, file)
00966         file.write(struct.pack(">H", len(self.constants)))
00967         for c in self.constants:
00968             c.write(typelib, file)
00969         flags = 0
00970         if self.scriptable:
00971             flags |= 0x80
00972         if self.function:
00973             flags |= 0x40
00974         if self.builtinclass:
00975             flags |= 0x20
00976         file.write(struct.pack(">B", flags))

def xpt.Interface.write_directory_entry (   self,
  file 
)
Write an InterfaceDirectoryEntry for this interface
to |file|, which is assumed to be seeked to the correct offset.

Definition at line 937 of file xpt.py.

00937 
00938     def write_directory_entry(self, file):
00939         """
00940         Write an InterfaceDirectoryEntry for this interface
00941         to |file|, which is assumed to be seeked to the correct offset.
00942 
00943         """
00944         file.write(Interface._direntry.pack(Typelib.string_to_iid(self.iid),
00945                                             self._name_offset,
00946                                             self._namespace_offset,
00947                                             self._descriptor_offset))

def xpt.Interface.write_names (   self,
  file,
  data_pool_offset 
)
Write this interface's name and namespace to |file|,
as well as the names of all of its methods and constants.
Assumes that |file| is currently seeked to an unused portion
of the data pool.

Definition at line 977 of file xpt.py.

00977 
00978     def write_names(self, file, data_pool_offset):
00979         """
00980         Write this interface's name and namespace to |file|,
00981         as well as the names of all of its methods and constants.
00982         Assumes that |file| is currently seeked to an unused portion
00983         of the data pool.
00984 
00985         """
00986         if self.name:
00987             self._name_offset = file.tell() - data_pool_offset + 1
00988             file.write(self.name + "\x00")
00989         else:
00990             self._name_offset = 0
00991         if self.namespace:
00992             self._namespace_offset = file.tell() - data_pool_offset + 1
00993             file.write(self.namespace + "\x00")
00994         else:
00995             self._namespace_offset = 0
00996         for m in self.methods:
00997             m.write_name(file, data_pool_offset)
00998         for c in self.constants:
00999             c.write_name(file, data_pool_offset)


Member Data Documentation

Definition at line 870 of file xpt.py.

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

Definition at line 843 of file xpt.py.

tuple xpt.Interface._direntry = struct.Struct(">16sIII") [static, private]

Definition at line 842 of file xpt.py.

Definition at line 871 of file xpt.py.

Definition at line 872 of file xpt.py.

Definition at line 861 of file xpt.py.

Definition at line 858 of file xpt.py.

Definition at line 860 of file xpt.py.

Definition at line 852 of file xpt.py.

Definition at line 857 of file xpt.py.

Definition at line 853 of file xpt.py.

Definition at line 854 of file xpt.py.

Definition at line 856 of file xpt.py.

Definition at line 850 of file xpt.py.

Definition at line 859 of file xpt.py.

string xpt.Interface.UNRESOLVED_IID = "00000000-0000-0000-0000-000000000000" [static]

Definition at line 845 of file xpt.py.

Definition at line 873 of file xpt.py.


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