def writeResultDecl(f, member, varname): type = member.realtype if isVoidType(type): return # nothing to declare t = xpidl.unaliasType(type) if t.kind == 'builtin': if not t.nativename.endswith('*'): if type.kind == 'typedef': typeName = type.name # use it else: typeName = t.nativename f.write(" %s %s;\n" % (typeName, varname)) return elif t.kind == 'native': name = xpidl.getBuiltinOrNativeTypeName(t) if name in ('[domstring]', '[astring]'): f.write(" nsString %s;\n" % varname) return elif name == '[jsval]': return # nothing to declare; see special case in outParamForm elif t.kind in ('interface', 'forward'): if member.kind == 'method' and member.notxpcom: f.write(" %s *%s;\n" % (type.name, varname)) else: f.write(" nsCOMPtr<%s> %s;\n" % (type.name, varname)) return warn("Unable to declare result of type %s" % type.name) f.write(" !; // TODO - Declare out parameter `%s`.\n" % varname)
def addType(types, type, map): def getTranslatedType(type): return map.get(type, type) type = xpidl.unaliasType(type) if isInterfaceType(type) or (type.kind == 'native' and type.specialtype is None): types.add(getTranslatedType(type.name))
def writeResultDecl(f, member, varname): type = member.realtype if isVoidType(type): return # nothing to declare t = xpidl.unaliasType(type) if t.kind == "builtin": if not t.nativename.endswith("*"): if type.kind == "typedef": typeName = type.name # use it else: typeName = t.nativename f.write(" %s %s;\n" % (typeName, varname)) return elif t.kind == "native": name = xpidl.getBuiltinOrNativeTypeName(t) if name in ("[domstring]", "[astring]"): f.write(" nsString %s;\n" % varname) return elif name == "[jsval]": return # nothing to declare; see special case in outParamForm elif t.kind in ("interface", "forward"): if member.kind == "method" and member.notxpcom: f.write(" %s *%s;\n" % (type.name, varname)) else: f.write(" nsCOMPtr<%s> %s;\n" % (type.name, varname)) return warn("Unable to declare result of type %s" % type.name) f.write(" !; // TODO - Declare out parameter `%s`.\n" % varname)
def isSpecificInterfaceType(t, name): """ True if `t` is an interface type with the given name, or a forward declaration or typedef aliasing it. `name` must not be the name of a typedef but the actual name of the interface. """ t = xpidl.unaliasType(t) return t.kind in ('interface', 'forward') and t.name == name
def outParamForm(name, type): type = xpidl.unaliasType(type) # If we start allowing [jsval] return types here, we need to tack # the return value onto the arguments list in the callers, # possibly, and handle properly returning it too. See bug 604198. assert type.kind != 'native' or type.specialtype != 'jsval' if type.kind == 'builtin': return '&' + name elif type.kind == 'native': if type.specialtype == 'jsval': return 'vp' elif type.modifier == 'ref': return name else: return '&' + name else: return 'getter_AddRefs(%s)' % name
def outParamForm(name, type): type = xpidl.unaliasType(type) # If we start allowing [jsval] return types here, we need to tack # the return value onto the arguments list in the callers, # possibly, and handle properly returning it too. See bug 604198. assert type.kind != "native" or type.specialtype != "jsval" if type.kind == "builtin": return "&" + name elif type.kind == "native": if type.specialtype == "jsval": return "vp" elif type.modifier == "ref": if isStringType(type): return "(nsAString&)" + name return name else: return "&" + name else: return "getter_AddRefs(%s)" % name
def isInterfaceType(t): t = xpidl.unaliasType(t) assert t.kind in ('builtin', 'native', 'interface', 'forward') return t.kind in ('interface', 'forward')
def isStringType(t): t = xpidl.unaliasType(t) return t.kind == 'native' and (t.specialtype == 'astring' or t.specialtype == 'domstring');
def isStringType(t): t = xpidl.unaliasType(t) return t.kind == 'native' and (t.specialtype == 'astring' or t.specialtype == 'domstring')
def isInterfaceType(t): t = xpidl.unaliasType(t) assert t.kind in ("builtin", "native", "interface", "forward") return t.kind in ("interface", "forward")
def isStringType(t): t = xpidl.unaliasType(t) return t.kind == "native" and (t.specialtype == "astring" or t.specialtype == "domstring")