Back to index

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

List of all members.

Public Member Functions

def __init__
def encodeflags
def write
def prefix
def __str__

Static Public Member Functions

def decodeflags
def read

Public Attributes

 type
 in_
 out
 retval
 shared
 dipper
 optional

Static Private Attributes

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

Detailed Description

A parameter to a method, or the return value of a method.
(ParamDescriptor from the typelib specification.)

Definition at line 503 of file xpt.py.


Constructor & Destructor Documentation

def xpt.Param.__init__ (   self,
  type,
  in_ = True,
  out = False,
  retval = False,
  shared = False,
  dipper = False,
  optional = False 
)
Construct a Param object with the specified |type| and
flags. Params default to "in".

Definition at line 512 of file xpt.py.

00512 
00513                  shared=False, dipper=False, optional=False):
00514         """
00515         Construct a Param object with the specified |type| and
00516         flags. Params default to "in".
00517 
00518         """
00519 
00520         self.type = type
00521         self.in_ = in_
00522         self.out = out
00523         self.retval = retval
00524         self.shared = shared
00525         self.dipper = dipper
00526         self.optional = optional


Member Function Documentation

def xpt.Param.__str__ (   self)

Definition at line 618 of file xpt.py.

00618 
00619     def __str__(self):
00620         return self.prefix() + str(self.type)

Here is the call graph for this function:

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

Definition at line 528 of file xpt.py.

00528 
00529     def decodeflags(byte):
00530         """
00531         Given |byte|, an unsigned uint8 containing flag bits,
00532         decode the flag bits as described in
00533         http://www.mozilla.org/scriptable/typelib_file.html#ParamDescriptor
00534         and return a dict of flagname: (True|False) suitable
00535         for passing to Param.__init__ as **kwargs
00536         """
00537         return {'in_': bool(byte & 0x80),
00538                 'out': bool(byte & 0x40),
00539                 'retval': bool(byte & 0x20),
00540                 'shared': bool(byte & 0x10),
00541                 'dipper': bool(byte & 0x08),
00542                 #XXX: Not in the spec, see:
00543                 # http://hg.mozilla.org/mozilla-central/annotate/0e0e2516f04e/xpcom/typelib/xpt/public/xpt_struct.h#l456
00544                 'optional': bool(byte & 0x04),
00545                 }

def xpt.Param.encodeflags (   self)
Encode the flags of this Param. Return a byte suitable for
writing to a typelib file.

Definition at line 546 of file xpt.py.

00546 
00547     def encodeflags(self):
00548         """
00549         Encode the flags of this Param. Return a byte suitable for
00550         writing to a typelib file.
00551 
00552         """
00553         flags = 0
00554         if self.in_:
00555             flags |= 0x80
00556         if self.out:
00557             flags |= 0x40
00558         if self.retval:
00559             flags |= 0x20
00560         if self.shared:
00561             flags |= 0x10
00562         if self.dipper:
00563             flags |= 0x08
00564         if self.optional:
00565             flags |= 0x04
00566         return flags

Here is the caller graph for this function:

def xpt.Param.prefix (   self)
Return a human-readable string representing the flags set
on this Param.

Definition at line 594 of file xpt.py.

00594 
00595     def prefix(self):
00596         """
00597         Return a human-readable string representing the flags set
00598         on this Param.
00599 
00600         """
00601         s = ""
00602         if self.out:
00603             if self.in_:
00604                 s = "inout "
00605             else:
00606                 s = "out "
00607         else:
00608             s = "in "
00609         if self.dipper:
00610             s += "dipper "
00611         if self.retval:
00612             s += "retval "
00613         if self.shared:
00614             s += "shared "
00615         if self.optional:
00616             s += "optional "
00617         return s

Here is the caller graph for this function:

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

Definition at line 568 of file xpt.py.

00568 
00569     def read(typelib, map, data_pool, offset):
00570         """
00571         Read a ParamDescriptor at |offset| from the mmaped file |map| with
00572         data pool offset |data_pool|. Returns (Param, next offset),
00573         where |next offset| is an offset suitable for reading the data
00574         following this ParamDescriptor.
00575         """
00576         start = data_pool + offset - 1
00577         (flags,) = Param._descriptorstart.unpack(map[start:start + Param._descriptorstart.size])
00578         # only the first five bits are flags
00579         flags &= 0xFC
00580         flags = Param.decodeflags(flags)
00581         offset += Param._descriptorstart.size
00582         t, offset = Type.read(typelib, map, data_pool, offset)
00583         p = Param(t, **flags)
00584         return p, offset

def xpt.Param.write (   self,
  typelib,
  file 
)
Write a ParamDescriptor to |file|, which is assumed to be seeked
to the correct position.

Definition at line 585 of file xpt.py.

00585 
00586     def write(self, typelib, file):
00587         """
00588         Write a ParamDescriptor to |file|, which is assumed to be seeked
00589         to the correct position.
00590 
00591         """
00592         file.write(Param._descriptorstart.pack(self.encodeflags()))
00593         self.type.write(typelib, file)

Here is the call graph for this function:


Member Data Documentation

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

Definition at line 509 of file xpt.py.

Definition at line 524 of file xpt.py.

Definition at line 520 of file xpt.py.

Definition at line 525 of file xpt.py.

Definition at line 521 of file xpt.py.

Definition at line 522 of file xpt.py.

Definition at line 523 of file xpt.py.

Definition at line 519 of file xpt.py.


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