Bug 939294 - Change xpidl header generation code to use JS handles. r=bsmedberg

This commit is contained in:
Tom Schuster 2014-01-09 18:39:36 +01:00
parent 7231bd727d
commit bf23659c60
3 changed files with 11 additions and 7 deletions

View File

@ -26,7 +26,6 @@ class nsAXPCNativeCallContext;
[ptr] native JSClassPtr(JSClass);
[ptr] native JSFreeOpPtr(JSFreeOp);
[ptr] native JSObjectPtr(JSObject);
[ptr] native JSValPtr(JS::Value);
[ptr] native JSValConstPtr(const JS::Value);
native JSPropertyOp(JSPropertyOp);
native JSEqualityOp(JSEqualityOp);
@ -409,7 +408,7 @@ interface nsIXPConnect : nsISupports
* Wraps the given jsval in a nsIVariant and returns the new variant.
*/
nsIVariant
jSValToVariant(in JSContextPtr cx, in JSValPtr aJSVal);
jSValToVariant(in JSContextPtr cx, in jsval aJSVal);
/**
* This only succeeds if the JSObject is a nsIXPConnectWrappedNative.

View File

@ -134,8 +134,8 @@ include = """
#endif
"""
jspubtd_include = """
#include "jspubtd.h"
jsvalue_include = """
#include "js/Value.h"
"""
infallible_includes = """
@ -173,7 +173,7 @@ def print_header(idl, fd, filename):
fd.write(include % {'basename': idl_basename(inc.filename)})
if idl.needsJSTypes():
fd.write(jspubtd_include)
fd.write(jsvalue_include)
# Include some extra files if any attributes are infallible.
for iface in [p for p in idl.productions if p.kind == 'interface']:

View File

@ -429,10 +429,10 @@ class Native(object):
return self.modifier == 'ref'
def isPtr(self, calltype):
return self.modifier == 'ptr' or (self.modifier == 'ref' and self.specialtype == 'jsval' and calltype == 'out')
return self.modifier == 'ptr'
def isRef(self, calltype):
return self.modifier == 'ref' and not (self.specialtype == 'jsval' and calltype == 'out')
return self.modifier == 'ref'
def nativeType(self, calltype, const=False, shared=False):
if shared:
@ -443,6 +443,11 @@ class Native(object):
if self.specialtype is not None and calltype == 'in':
const = True
if self.specialtype == 'jsval':
if calltype == 'out' or calltype == 'inout':
return "JS::MutableHandleValue "
return "JS::HandleValue "
if self.isRef(calltype):
m = '& '
elif self.isPtr(calltype):