Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions | Variables
xpcom.client Namespace Reference

Classes

class  _XPCOMBase
class  Component
class  _Interface
class  WeakReference

Functions

def _MakeMethodCode
def _shutdown
def BuildMethod
def BuildInterfaceInfo
def MakeInterfaceResult

Variables

list _special_getattr_names = ["__del__", "__len__", "__nonzero__"]
list _just_int_interfaces = ["nsISupportsPRInt32", "nsISupportsPRInt16", "nsISupportsPRUint32", "nsISupportsPRUint16", "nsISupportsPRUint8", "nsISupportsPRBool"]
list _just_long_interfaces = ["nsISupportsPRInt64", "nsISupportsPRUint64"]
list _just_float_interfaces = ["nsISupportsDouble", "nsISupportsFloat"]
 _int_interfaces = _just_int_interfaces+_just_float_interfaces
 _long_interfaces = _just_long_interfaces+_just_int_interfaces+_just_float_interfaces
 _float_interfaces = _just_float_interfaces+_just_long_interfaces+_just_int_interfaces
string method_template
dictionary interface_cache = {}
dictionary interface_method_cache = {}
dictionary contractid_info_cache = {}
int have_shutdown = 0
tuple codeObject = compile(method_code, "<XPCOMObject method '%s'>" % (name,), "exec")
 print "Method Code for %s (%s):" % (name, iid) print method_code
dictionary tempNameSpace = {}
list ret = tempNameSpace[name]
 FLAGS_TO_IGNORE = XPT_MD_NOTXPCOM|XPT_MD_CTOR|XPT_MD_HIDDEN

Function Documentation

def xpcom.client._MakeMethodCode (   method) [private]

Definition at line 62 of file __init__.py.

00062 
00063 def _MakeMethodCode(method):
00064     # Build a declaration
00065     param_no = 0
00066     param_decls = []
00067     param_flags = []
00068     param_names = []
00069     used_default = 0
00070     for param in method.params:
00071         param_no = param_no + 1
00072         param_name = "Param%d" % (param_no,)
00073         param_default = ""
00074         if not param.hidden_indicator and param.IsIn() and not param.IsDipper():
00075             if param.IsOut() or used_default: # If the param is "inout", provide a useful default for the "in" direction.
00076                 param_default = " = None"
00077                 used_default = 1 # Once we have used one once, we must for the rest!
00078             param_decls.append(param_name + param_default)
00079             param_names.append(param_name)
00080 
00081         type_repr = xpt.MakeReprForInvoke(param)
00082         param_flags.append( (param.param_flags,) +  type_repr )
00083     sep = ", "
00084     param_decls = sep.join(param_decls)
00085     if len(param_names)==1: # Damn tuple reprs.
00086         param_names = param_names[0] + ","
00087     else:
00088         param_names = sep.join(param_names)
00089     # A couple of extra newlines make them easier to read for debugging :-)
00090     return method_template % (method.name, param_decls, method.method_index, tuple(param_flags), param_names)
00091 
# Keyed by IID, each item is a tuple of (methods, getters, setters)

Here is the caller graph for this function:

def xpcom.client._shutdown ( ) [private]

Definition at line 100 of file __init__.py.

00100 
00101 def _shutdown():
00102     interface_cache.clear()
00103     interface_method_cache.clear()
00104     contractid_info_cache.clear()
00105     global have_shutdown
00106     have_shutdown = 1
00107 
# Fully process the named method, generating method code etc.

Here is the caller graph for this function:

Definition at line 137 of file __init__.py.

00137 
00138 def BuildInterfaceInfo(iid):
00139     assert not have_shutdown, "Can't build interface info after a shutdown"
00140     ret = interface_cache.get(iid, None)
00141     if ret is None:
00142         # Build the data for the cache.
00143         method_code_blocks = []
00144         getters = {}
00145         setters = {}
00146         method_infos = {}
00147         
00148         interface = xpt.Interface(iid)
00149         for m in interface.methods:
00150             flags = m.flags
00151             if flags & FLAGS_TO_IGNORE == 0:
00152                 if flags & XPT_MD_SETTER:
00153                     param_flags = map(lambda x: (x.param_flags,) + xpt.MakeReprForInvoke(x), m.params)
00154                     setters[m.name] = m.method_index, param_flags
00155                 elif flags & XPT_MD_GETTER:
00156                     param_flags = map(lambda x: (x.param_flags,) + xpt.MakeReprForInvoke(x), m.params)
00157                     getters[m.name] = m.method_index, param_flags
00158                 else:
00159                     method_infos[m.name] = m
00160 
00161         # Build the constants.
00162         constants = {}
00163         for c in interface.constants:
00164             constants[c.name] = c.value
00165         ret = method_infos, getters, setters, constants
00166         interface_cache[iid] = ret
00167     return ret

Here is the caller graph for this function:

def xpcom.client.BuildMethod (   method_info,
  iid 
)

Definition at line 108 of file __init__.py.

00108 
00109 def BuildMethod(method_info, iid):
00110     name = method_info.name
00111     try:
00112         return interface_method_cache[iid][name]
00113     except KeyError:
00114         pass
00115     # Generate it.
00116     assert not (method_info.IsSetter() or method_info.IsGetter()), "getters and setters should have been weeded out by now"
00117     method_code = _MakeMethodCode(method_info)
00118     # Build the method - We only build a function object here
00119     # - they are bound to each instance as needed.
    

Here is the call graph for this function:

Here is the caller graph for this function:

def xpcom.client.MakeInterfaceResult (   ob,
  iid 
)

Definition at line 442 of file __init__.py.

00442 
00443 def MakeInterfaceResult(ob, iid):
00444     return Component(ob, iid)


Variable Documentation

Definition at line 56 of file __init__.py.

Definition at line 54 of file __init__.py.

Definition at line 52 of file __init__.py.

Definition at line 50 of file __init__.py.

Definition at line 51 of file __init__.py.

Definition at line 55 of file __init__.py.

list xpcom.client._special_getattr_names = ["__del__", "__len__", "__nonzero__"]

Definition at line 48 of file __init__.py.

tuple xpcom.client.codeObject = compile(method_code, "<XPCOMObject method '%s'>" % (name,), "exec")

print "Method Code for %s (%s):" % (name, iid) print method_code

Definition at line 122 of file __init__.py.

Definition at line 97 of file __init__.py.

Definition at line 133 of file __init__.py.

Definition at line 98 of file __init__.py.

Definition at line 92 of file __init__.py.

Definition at line 94 of file __init__.py.

Initial value:
00001 """
00002 def %s(self, %s):
00003     return XPTC_InvokeByIndex(self._comobj_, %d, (%s, (%s)))
00004 """

Definition at line 58 of file __init__.py.

Definition at line 126 of file __init__.py.

Definition at line 124 of file __init__.py.