def _do_conversion(self, interface_names, cvt): iim = XPTI_GetInterfaceInfoManager() for interface_name in interface_names: iid = iim.GetInfoForName(interface_name).GetIID() try: prim = self._comobj_.QueryInterface(iid) return cvt(prim.data) except COMException: pass raise ValueError, "This object does not support automatic numeric conversion to this type"
def __setattr__(self, attr, val): interface_name = self._name_to_interface_name_.get(attr, None) # This may be first time trying this interface - get the nsIClassInfo if interface_name is None and not self._tried_classinfo_: self._build_all_supported_interfaces_() interface_name = self.__dict__['_name_to_interface_name_'].get( attr, None) if interface_name is not None: interface = self._interface_names_.get(interface_name, None) if interface is None: iid = XPTI_GetInterfaceInfoManager().GetInfoForName( interface_name).GetIID() self.QueryInterface(iid) interface = self.__dict__['_interface_names_'][interface_name] setattr(interface, attr, val) return raise AttributeError, "XPCOM component '%s' has no attribute '%s'" % ( self._object_name_, attr)
def __getattr__(self, attr): if attr in _special_getattr_names: raise AttributeError, attr # First allow the interface name to return the "raw" interface interface = self.__dict__['_interface_names_'].get(attr, None) if interface is not None: return interface interface_name = self.__dict__['_name_to_interface_name_'].get( attr, None) # This may be first time trying this interface - get the nsIClassInfo if interface_name is None and not self._tried_classinfo_: self._build_all_supported_interfaces_() interface_name = self.__dict__['_name_to_interface_name_'].get( attr, None) if interface_name is not None: interface = self.__dict__['_interface_names_'].get( interface_name, None) if interface is None: iid = XPTI_GetInterfaceInfoManager().GetInfoForName( interface_name).GetIID() self.QueryInterface(iid) interface = self.__dict__['_interface_names_'][interface_name] return getattr(interface, attr) # Some interfaces may provide this name via "native" support. # Loop over all interfaces, and if found, cache it for next time. for interface in self.__dict__['_interfaces_'].values(): try: ret = getattr(interface, attr) self.__dict__['_name_to_interface_name_'][ attr] = interface._iid_.name return ret except AttributeError: pass raise AttributeError, "XPCOM component '%s' has no attribute '%s'" % ( self._object_name_, attr)
# The contents of this file are subject to the Mozilla Public License Version