From 86ecf361a58f38cfc3debf98c94859d61f85de53 Mon Sep 17 00:00:00 2001 From: Peter Van der Beken Date: Thu, 6 May 2010 14:16:32 +0200 Subject: [PATCH] Fix for bug 560462 (Use fast unwrapping for more quickstubs) - add support for non-templated custom quickstubs for an interface. r=jst. --- js/src/xpconnect/src/qsgen.py | 41 ++++++++++++++++++---------- js/src/xpconnect/src/xpcquickstubs.h | 6 ++++ 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/js/src/xpconnect/src/qsgen.py b/js/src/xpconnect/src/qsgen.py index cb498c778005..4fb2e7ddd425 100644 --- a/js/src/xpconnect/src/qsgen.py +++ b/js/src/xpconnect/src/qsgen.py @@ -680,9 +680,9 @@ def writeResultConv(f, type, jsvalPtr, jsvalRef): % jsvalPtr) return else: - f.write(" return xpc_qsXPCOMObjectToJsval(lccx, result, " - "xpc_qsGetWrapperCache(result), &NS_GET_IID(%s), " - "&interfaces[k_%s], %s);\n" + f.write(" return xpc_qsXPCOMObjectToJsval(lccx, " + "ToSupports(result), xpc_qsGetWrapperCache(result), " + "&NS_GET_IID(%s), &interfaces[k_%s], %s);\n" % (type.name, type.name, jsvalPtr)) return @@ -742,6 +742,16 @@ def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False): if customMethodCall is None: customMethodCall = customMethodCalls.get(member.iface.name + '_', None) if customMethodCall is not None: + if isMethod: + code = customMethodCall.get('code', None) + elif isGetter: + code = customMethodCall.get('getter_code', None) + else: + code = customMethodCall.get('setter_code', None) + else: + code = None + + if code is not None: templateName = member.iface.name if isGetter: templateName += '_Get' @@ -775,15 +785,9 @@ def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False): return customMethodCall[templateGenerated] = True - if isMethod: - code = customMethodCall['code'] - elif isGetter: - code = customMethodCall['getter_code'] - else: - code = customMethodCall['setter_code'] stubName = templateName else: - code = None + callTemplate = "" else: callTemplate = "" code = customMethodCall.get('code', None) @@ -903,7 +907,8 @@ def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False): if debugGetter: f.write("#ifdef DEBUG\n") f.write(" nsresult debug_rv;\n") - f.write(" nsCOMPtr<%s> debug_self = do_QueryInterface(self);\n" + f.write(" nsCOMPtr<%s> debug_self;\n" + " CallQueryInterface(self, getter_AddRefs(debug_self));\n" % member.iface.name); prefix = 'debug_' else: @@ -1196,10 +1201,10 @@ def writeTraceableResultConv(f, type): f.write(" JSBool ok = xpc_qsVariantToJsval(lccx, result, " "&vp.array[0]);\n") else: - f.write(" JSBool ok = xpc_qsXPCOMObjectToJsval(lccx, result, " - "xpc_qsGetWrapperCache(result), &NS_GET_IID(%s), " - "&interfaces[k_%s], &vp.array[0]);" - "\n" % (type.name, type.name)) + f.write(" JSBool ok = xpc_qsXPCOMObjectToJsval(lccx, " + "ToSupports(result), xpc_qsGetWrapperCache(result), " + "&NS_GET_IID(%s), &interfaces[k_%s], &vp.array[0]);\n" + % (type.name, type.name)) f.write(" if (!ok) {\n"); writeFailure(f, getTraceInfoDefaultReturn(type), 2) f.write(" return vp.array[0];\n") @@ -1221,6 +1226,12 @@ def writeTraceableQuickStub(f, customMethodCalls, member, stubName): customMethodCall = customMethodCalls.get(stubName, None) + if customMethodCall is None: + customMethodCall = customMethodCalls.get(member.iface.name + '_', None) + if customMethodCall is not None: + # We don't support traceable templated quickstubs yet + assert not 'code' in customMethodCall + if customMethodCall is not None and customMethodCall.get('skipgen', False): return diff --git a/js/src/xpconnect/src/xpcquickstubs.h b/js/src/xpconnect/src/xpcquickstubs.h index ed62b7eb2446..977f5d9643d5 100644 --- a/js/src/xpconnect/src/xpcquickstubs.h +++ b/js/src/xpconnect/src/xpcquickstubs.h @@ -560,6 +560,12 @@ xpc_qsVariantToJsval(XPCLazyCallContext &ccx, nsIVariant *p, jsval *rval); +inline nsISupports* +ToSupports(nsISupports *p) +{ + return p; +} + #ifdef DEBUG void xpc_qsAssertContextOK(JSContext *cx);