Back to index

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

List of all members.

Public Member Functions

def __init__
def resolve
def isScriptable
def __str__
def toIDL
def needsJSTypes
def count

Public Attributes

 type
 name
 attlist
 params
 location
 doccomments
 raises
 namemap
 iface
 realtype

Static Public Attributes

string kind = 'method'
 noscript = False
 notxpcom = False
 binaryname = None
 implicit_jscontext = False
 nostdcall = False
 optional_argc = False
 deprecated = False
 getter = False
 setter = False
 stringifier = False
 forward = None

Detailed Description

Definition at line 834 of file xpidl.py.


Constructor & Destructor Documentation

def xpidl.Method.__init__ (   self,
  type,
  name,
  attlist,
  paramlist,
  location,
  doccomments,
  raises 
)

Definition at line 848 of file xpidl.py.

00848 
00849     def __init__(self, type, name, attlist, paramlist, location, doccomments, raises):
00850         self.type = type
00851         self.name = name
00852         self.attlist = attlist
00853         self.params = paramlist
00854         self.location = location
00855         self.doccomments = doccomments
00856         self.raises = raises
00857 
00858         for name, value, aloc in attlist:
00859             if name == 'binaryname':
00860                 if value is None:
00861                     raise IDLError("binaryname attribute requires a value",
00862                                    aloc)
00863 
00864                 self.binaryname = value
00865                 continue
00866             if name == 'forward':
00867                 if value is None:
00868                     raise IDLError("forward attribute requires a value",
00869                                    aloc)
00870 
00871                 self.forward = value
00872                 continue
00873 
00874             if value is not None:
00875                 raise IDLError("Unexpected attribute value", aloc)
00876 
00877             if name == 'noscript':
00878                 self.noscript = True
00879             elif name == 'notxpcom':
00880                 self.notxpcom = True
00881             elif name == 'implicit_jscontext':
00882                 self.implicit_jscontext = True
00883             elif name == 'optional_argc':
00884                 self.optional_argc = True
00885             elif name == 'deprecated':
00886                 self.deprecated = True
00887             elif name == 'nostdcall':
00888                 self.nostdcall = True
00889             elif name == 'getter':
00890                 if (len(self.params) != 1):
00891                     raise IDLError("Methods marked as getter must take 1 argument", aloc)
00892                 self.getter = True
00893             elif name == 'setter':
00894                 if (len(self.params) != 2):
00895                     raise IDLError("Methods marked as setter must take 2 arguments", aloc)
00896                 self.setter = True
00897             elif name == 'stringifier':
00898                 if (len(self.params) != 0):
00899                     raise IDLError("Methods marked as stringifier must take 0 arguments", aloc)
00900                 self.stringifier = True
00901             else:
00902                 raise IDLError("Unexpected attribute '%s'" % name, aloc)
00903 
00904         self.namemap = NameMap()
00905         for p in paramlist:
00906             self.namemap.set(p)


Member Function Documentation

def xpidl.Method.__str__ (   self)

Definition at line 955 of file xpidl.py.

00955 
00956     def __str__(self):
00957         return "\t%s %s(%s)\n" % (self.type, self.name, ", ".join([p.name for p in self.params]))

def xpidl.Method.count (   self)

Definition at line 982 of file xpidl.py.

00982 
00983     def count(self):
00984         return 1

def xpidl.Method.isScriptable (   self)

Definition at line 951 of file xpidl.py.

00951 
00952     def isScriptable(self):
00953         if not self.iface.attributes.scriptable: return False
00954         return not (self.noscript or self.notxpcom)

def xpidl.Method.needsJSTypes (   self)

Definition at line 971 of file xpidl.py.

00971 
00972     def needsJSTypes(self):
00973         if self.implicit_jscontext:
00974             return True
00975         if self.type == "jsval":
00976             return True
00977         for p in self.params:
00978             t = p.realtype
00979             if isinstance(t, Native) and t.specialtype == "jsval":
00980                 return True
00981         return False

def xpidl.Method.resolve (   self,
  iface 
)

Definition at line 907 of file xpidl.py.

00907 
00908     def resolve(self, iface):
00909         self.iface = iface
00910         self.realtype = self.iface.idl.getName(self.type, self.location)
00911         for p in self.params:
00912             p.resolve(self)
00913         if self.getter:
00914             if getBuiltinOrNativeTypeName(self.params[0].realtype) == 'unsigned long':
00915                 ops = 'index'
00916             else:
00917                 if getBuiltinOrNativeTypeName(self.params[0].realtype) != '[domstring]':
00918                     raise IDLError("a getter must take a single unsigned long or DOMString argument" % self.iface.name, self.location)
00919                 ops = 'name'
00920             if self.iface.ops[ops]['getter']:
00921                 raise IDLError("a %s getter was already defined on interface '%s'" % (ops, self.iface.name), self.location)
00922             self.iface.ops[ops]['getter'] = self
00923         if self.setter:
00924             if getBuiltinOrNativeTypeName(self.params[0].realtype) == 'unsigned long':
00925                 ops = 'index'
00926             else:
00927                 if getBuiltinOrNativeTypeName(self.params[0].realtype) != '[domstring]':
00928                     print getBuiltinOrNativeTypeName(self.params[0].realtype)
00929                     raise IDLError("a setter must take a unsigned long or DOMString argument" % self.iface.name, self.location)
00930                 ops = 'name'
00931             if self.iface.ops[ops]['setter']:
00932                 raise IDLError("a %s setter was already defined on interface '%s'" % (ops, self.iface.name), self.location)
00933             self.iface.ops[ops]['setter'] = self
00934         if self.stringifier:
00935             if self.iface.ops['stringifier']:
00936                 raise IDLError("a stringifier was already defined on interface '%s'" % self.iface.name, self.location)
00937             if getBuiltinOrNativeTypeName(self.realtype) != '[domstring]':
00938                 raise IDLError("'stringifier' attribute can only be used on methods returning DOMString",
00939                                self.location)
00940             self.iface.ops['stringifier'] = self
00941         for p in self.params:
00942             if p.size_is:
00943                 found_size_param = False
00944                 for size_param in self.params:
00945                     if p.size_is == size_param.name:
00946                         found_size_param = True
00947                         if getBuiltinOrNativeTypeName(size_param.realtype) != 'unsigned long':
00948                             raise IDLError("is_size parameter must have type 'unsigned long'", self.location)
00949                 if not found_size_param:
00950                     raise IDLError("could not find is_size parameter '%s'" % p.size_is, self.location)

def xpidl.Method.toIDL (   self)

Definition at line 958 of file xpidl.py.

00958 
00959     def toIDL(self):
00960         if len(self.raises):
00961             raises = ' raises (%s)' % ','.join(self.raises)
00962         else:
00963             raises = ''
00964 
00965         return "%s%s %s (%s)%s;" % (attlistToIDL(self.attlist),
00966                                     self.type,
00967                                     self.name,
00968                                     ", ".join([p.toIDL()
00969                                                for p in self.params]),
00970                                     raises)

Here is the call graph for this function:


Member Data Documentation

Definition at line 851 of file xpidl.py.

xpidl.Method.binaryname = None [static]

Definition at line 838 of file xpidl.py.

Definition at line 842 of file xpidl.py.

Definition at line 854 of file xpidl.py.

xpidl.Method.forward = None [static]

Definition at line 846 of file xpidl.py.

Definition at line 843 of file xpidl.py.

Definition at line 908 of file xpidl.py.

Definition at line 839 of file xpidl.py.

string xpidl.Method.kind = 'method' [static]

Definition at line 835 of file xpidl.py.

Definition at line 853 of file xpidl.py.

Definition at line 850 of file xpidl.py.

Definition at line 903 of file xpidl.py.

Definition at line 836 of file xpidl.py.

Definition at line 840 of file xpidl.py.

Definition at line 837 of file xpidl.py.

Definition at line 841 of file xpidl.py.

Definition at line 852 of file xpidl.py.

Definition at line 855 of file xpidl.py.

Definition at line 909 of file xpidl.py.

Definition at line 844 of file xpidl.py.

Definition at line 845 of file xpidl.py.

Definition at line 849 of file xpidl.py.


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