mirror of
https://github.com/servo/servo.git
synced 2025-06-24 00:54:32 +01:00
Use FooValue() functions.
This commit is contained in:
parent
9fbfb1909c
commit
84b0f45ed5
9 changed files with 72 additions and 87 deletions
|
@ -1152,7 +1152,7 @@ for (uint32_t i = 0; i < length; ++i) {
|
|||
|
||||
templateBody = "${declName} = %s;" % value.define()
|
||||
templateBody = handleDefaultNull(templateBody,
|
||||
"${declName} = JSVAL_NULL")
|
||||
"${declName} = NullValue()")
|
||||
|
||||
return (templateBody, declType, None, isOptional, "None" if isOptional else None)
|
||||
|
||||
|
@ -1196,7 +1196,7 @@ for (uint32_t i = 0; i < length; ++i) {
|
|||
# actually do want a jsval, and we only handle null anyway
|
||||
if defaultValue is not None:
|
||||
assert(isinstance(defaultValue, IDLNullValue))
|
||||
val = "if ${haveValue} { ${val} } else { JSVAL_NULL }"
|
||||
val = "if ${haveValue} { ${val} } else { NullValue() }"
|
||||
else:
|
||||
val = "${val}"
|
||||
|
||||
|
@ -1467,7 +1467,7 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode,
|
|||
return str
|
||||
|
||||
if type is None or type.isVoid():
|
||||
return (setValue("JSVAL_VOID"), True)
|
||||
return (setValue("UndefinedValue()"), True)
|
||||
|
||||
if type.isArray():
|
||||
raise TypeError("Can't handle array return values yet")
|
||||
|
@ -1482,7 +1482,7 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode,
|
|||
if (%s.IsNull()) {
|
||||
%s
|
||||
}
|
||||
%s""" % (result, CGIndenter(CGGeneric(setValue("JSVAL_NULL"))).define(), recTemplate), recInfall)
|
||||
%s""" % (result, CGIndenter(CGGeneric(setValue("NullValue()"))).define(), recTemplate), recInfall)
|
||||
|
||||
# Now do non-nullable sequences. We use setting the element
|
||||
# in the array as our succcess code because when we succeed in
|
||||
|
@ -1516,7 +1516,7 @@ for (uint32_t i = 0; i < length; ++i) {
|
|||
descriptor = descriptorProvider.getDescriptor(type.unroll().inner.identifier.name)
|
||||
if type.nullable():
|
||||
wrappingCode = ("if %s.is_none() {\n" % (result) +
|
||||
CGIndenter(CGGeneric(setValue("JSVAL_NULL"))).define() + "\n" +
|
||||
CGIndenter(CGGeneric(setValue("NullValue()"))).define() + "\n" +
|
||||
"}\n" +
|
||||
"let mut %s = %s.unwrap();\n" % (result, result))
|
||||
else:
|
||||
|
@ -1552,7 +1552,7 @@ if %(resultStr)s.is_null() {
|
|||
""" % { "result" : result,
|
||||
"resultStr" : result + "_str",
|
||||
"strings" : type.inner.identifier.name + "Values::strings" } +
|
||||
setValue("RUST_STRING_TO_JSVAL(%s_str)" % result), False)
|
||||
setValue("StringValue(&*(%s_str))" % result), False)
|
||||
|
||||
if type.isCallback():
|
||||
assert not type.isInterface()
|
||||
|
@ -1573,9 +1573,9 @@ if %(resultStr)s.is_null() {
|
|||
# See comments in WrapNewBindingObject explaining why we need
|
||||
# to wrap here.
|
||||
if type.nullable():
|
||||
toValue = "RUST_OBJECT_TO_JSVAL(%s)"
|
||||
toValue = "ObjectOrNullValue(%s)"
|
||||
else:
|
||||
toValue = "RUST_OBJECT_TO_JSVAL(%s)"
|
||||
toValue = "ObjectValue(&*(%s))"
|
||||
# NB: setValue(..., True) calls JS_WrapValue(), so is fallible
|
||||
return (setValue(toValue % result, True), False)
|
||||
|
||||
|
@ -2530,7 +2530,7 @@ def CreateBindingJSObject(descriptor, parent=None):
|
|||
let handler = js_info.get().get_ref().dom_static.proxy_handlers.get(&(PrototypeList::id::%s as uint));
|
||||
""" % descriptor.name
|
||||
create += handler + """ let obj = NewProxyObject(aCx, *handler,
|
||||
ptr::to_unsafe_ptr(&RUST_PRIVATE_TO_JSVAL(squirrel_away_unique(aObject) as *libc::c_void)),
|
||||
ptr::to_unsafe_ptr(&PrivateValue(squirrel_away_unique(aObject) as *libc::c_void)),
|
||||
proto, %s,
|
||||
ptr::null(), ptr::null());
|
||||
if obj.is_null() {
|
||||
|
@ -2548,7 +2548,7 @@ def CreateBindingJSObject(descriptor, parent=None):
|
|||
}
|
||||
|
||||
JS_SetReservedSlot(obj, DOM_OBJECT_SLOT as u32,
|
||||
RUST_PRIVATE_TO_JSVAL(squirrel_away_unique(aObject) as *libc::c_void));
|
||||
PrivateValue(squirrel_away_unique(aObject) as *libc::c_void));
|
||||
"""
|
||||
return create
|
||||
|
||||
|
@ -3310,7 +3310,7 @@ class CGGenericSetter(CGAbstractBindingMethod):
|
|||
|
||||
def generate_code(self):
|
||||
return CGIndenter(CGGeneric(
|
||||
"let undef = JSVAL_VOID;\n"
|
||||
"let undef = UndefinedValue();\n"
|
||||
"let argv: *JSVal = if argc != 0 { JS_ARGV(cx, vp as *JSVal) } else { &undef as *JSVal };\n"
|
||||
"let info: *JSJitInfo = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, vp as *JSVal));\n"
|
||||
"let ok = with_gc_disabled(cx, || {\n"
|
||||
|
@ -3319,7 +3319,7 @@ class CGGenericSetter(CGAbstractBindingMethod):
|
|||
"if ok == 0 {\n"
|
||||
" return 0;\n"
|
||||
"}\n"
|
||||
"*vp = JSVAL_VOID;\n"
|
||||
"*vp = UndefinedValue();\n"
|
||||
"return 1;"))
|
||||
|
||||
class CGSpecializedSetter(CGAbstractExternMethod):
|
||||
|
@ -4621,7 +4621,7 @@ if found {
|
|||
return 1;
|
||||
}
|
||||
%s
|
||||
*vp = JSVAL_VOID;
|
||||
*vp = UndefinedValue();
|
||||
return 1;""" % (getIndexedOrExpando, getNamed)
|
||||
|
||||
def definition_body(self):
|
||||
|
@ -5011,7 +5011,7 @@ class CGDictionary(CGThing):
|
|||
" }\n"
|
||||
"${initParent}"
|
||||
" let mut found: JSBool = 0;\n"
|
||||
" let temp: JSVal = JSVAL_NULL;\n"
|
||||
" let temp: JSVal = NullValue();\n"
|
||||
" let isNull = RUST_JSVAL_IS_NULL(val) != 0 || RUST_JSVAL_IS_VOID(val) != 0;\n"
|
||||
" if !isNull && RUST_JSVAL_IS_PRIMITIVE(val) != 0 {\n"
|
||||
" return 0; //XXXjdm throw properly here\n"
|
||||
|
@ -5235,8 +5235,8 @@ class CGBindingRoot(CGThing):
|
|||
'js::{JSCLASS_IS_GLOBAL, JSCLASS_RESERVED_SLOTS_SHIFT}',
|
||||
'js::{JSCLASS_RESERVED_SLOTS_MASK, JSID_VOID, JSJitInfo}',
|
||||
'js::{JSPROP_ENUMERATE, JSPROP_NATIVE_ACCESSORS, JSPROP_SHARED}',
|
||||
'js::{JSRESOLVE_ASSIGNING, JSRESOLVE_QUALIFIED, JSVAL_NULL}',
|
||||
'js::{JSVAL_IS_OBJECT, JSVAL_TO_OBJECT, JSVAL_VOID}',
|
||||
'js::{JSRESOLVE_ASSIGNING, JSRESOLVE_QUALIFIED}',
|
||||
'js::{JSVAL_IS_OBJECT, JSVAL_TO_OBJECT}',
|
||||
'js::jsapi::{JS_CallFunctionValue, JS_GetClass, JS_GetGlobalForObject}',
|
||||
'js::jsapi::{JS_GetObjectPrototype, JS_GetProperty, JS_GetPropertyById}',
|
||||
'js::jsapi::{JS_GetPropertyDescriptorById, JS_GetReservedSlot}',
|
||||
|
@ -5248,14 +5248,15 @@ class CGBindingRoot(CGThing):
|
|||
'js::jsapi::{JSPropertyOpWrapper, JSPropertySpec}',
|
||||
'js::jsapi::{JSStrictPropertyOpWrapper, JSString, JSTracer}',
|
||||
'js::jsval::JSVal',
|
||||
'js::jsval::{ObjectValue, ObjectOrNullValue, PrivateValue}',
|
||||
'js::jsval::{NullValue, UndefinedValue}',
|
||||
'js::glue::{CallJitMethodOp, CallJitPropertyOp, CreateProxyHandler}',
|
||||
'js::glue::{GetProxyPrivate, NewProxyObject, ProxyTraps}',
|
||||
'js::glue::{RUST_BOOLEAN_TO_JSVAL, RUST_FUNCTION_VALUE_TO_JITINFO}',
|
||||
'js::glue::{RUST_INT_TO_JSVAL, RUST_JS_NumberValue, RUST_JSID_IS_STRING}',
|
||||
'js::glue::{RUST_FUNCTION_VALUE_TO_JITINFO}',
|
||||
'js::glue::{RUST_JS_NumberValue, RUST_JSID_IS_STRING}',
|
||||
'js::glue::{RUST_JSVAL_IS_NULL, RUST_JSVAL_IS_PRIMITIVE}',
|
||||
'js::glue::{RUST_JSVAL_IS_VOID, RUST_JSVAL_TO_OBJECT}',
|
||||
'js::glue::{RUST_JSVAL_TO_PRIVATE, RUST_OBJECT_TO_JSVAL}',
|
||||
'js::glue::{RUST_PRIVATE_TO_JSVAL, RUST_UINT_TO_JSVAL}',
|
||||
'js::glue::{RUST_JSVAL_TO_PRIVATE}',
|
||||
'dom::types::*',
|
||||
'dom::bindings::js::JS',
|
||||
'dom::bindings::utils::{CreateDOMGlobal, CreateInterfaceObjects2}',
|
||||
|
@ -5696,7 +5697,7 @@ class CGCallback(CGClass):
|
|||
# the private method.
|
||||
argnames = [arg.name for arg in args]
|
||||
argnamesWithThis = ["s.GetContext()", "thisObjJS"] + argnames
|
||||
argnamesWithoutThis = ["s.GetContext()", "JSVAL_TO_OBJECT(JSVAL_NULL)"] + argnames
|
||||
argnamesWithoutThis = ["s.GetContext()", "ptr::null()"] + argnames
|
||||
# Now that we've recorded the argnames for our call to our private
|
||||
# method, insert our optional argument for deciding whether the
|
||||
# CallSetup should re-throw exceptions on aRv.
|
||||
|
@ -5861,7 +5862,7 @@ class CallbackMember(CGNativeMember):
|
|||
if self.argCount > 0:
|
||||
replacements["argCount"] = self.argCountStr
|
||||
replacements["argvDecl"] = string.Template(
|
||||
"let mut argv = vec::from_elem(${argCount}, JSVAL_VOID);\n"
|
||||
"let mut argv = vec::from_elem(${argCount}, UndefinedValue());\n"
|
||||
).substitute(replacements)
|
||||
else:
|
||||
# Avoid weird 0-sized arrays
|
||||
|
@ -6045,7 +6046,7 @@ class CallbackMethod(CallbackMember):
|
|||
CallbackMember.__init__(self, sig, name, descriptorProvider,
|
||||
needThisHandling, rethrowContentException)
|
||||
def getRvalDecl(self):
|
||||
return "let mut rval = JSVAL_VOID;\n"
|
||||
return "let mut rval = UndefinedValue();\n"
|
||||
|
||||
def getCall(self):
|
||||
replacements = {
|
||||
|
@ -6112,9 +6113,9 @@ class CallbackOperationBase(CallbackMethod):
|
|||
return 'JS::Rooted<JS::Value> callable(cx);\n' + getCallableFromProp
|
||||
return (
|
||||
'let isCallable = unsafe { JS_ObjectIsCallable(cx, self.parent.callback) != 0 };\n'
|
||||
'let mut callable = JSVAL_VOID;\n'
|
||||
'let mut callable = UndefinedValue();\n'
|
||||
'if isCallable {\n'
|
||||
' callable = unsafe { RUST_OBJECT_TO_JSVAL(self.parent.callback) };\n'
|
||||
' callable = unsafe { ObjectValue(&*self.parent.callback) };\n'
|
||||
'} else {\n'
|
||||
'%s'
|
||||
'}\n' % CGIndenter(CGGeneric(getCallableFromProp)).define())
|
||||
|
@ -6433,8 +6434,8 @@ class GlobalGenRoots():
|
|||
'js::{JSCLASS_IS_GLOBAL, JSCLASS_RESERVED_SLOTS_SHIFT}',
|
||||
'js::{JSCLASS_RESERVED_SLOTS_MASK, JSID_VOID, JSJitInfo}',
|
||||
'js::{JSPROP_ENUMERATE, JSPROP_NATIVE_ACCESSORS, JSPROP_SHARED}',
|
||||
'js::{JSRESOLVE_ASSIGNING, JSRESOLVE_QUALIFIED, JSVAL_NULL}',
|
||||
'js::{JSVAL_IS_OBJECT, JSVAL_TO_OBJECT, JSVAL_VOID}',
|
||||
'js::{JSRESOLVE_ASSIGNING, JSRESOLVE_QUALIFIED}',
|
||||
'js::{JSVAL_IS_OBJECT, JSVAL_TO_OBJECT}',
|
||||
'js::jsapi::{JS_CallFunctionValue, JS_GetClass, JS_GetGlobalForObject}',
|
||||
'js::jsapi::{JS_GetObjectPrototype, JS_GetProperty, JS_GetPropertyById}',
|
||||
'js::jsapi::{JS_GetPropertyDescriptorById, JS_GetReservedSlot}',
|
||||
|
@ -6446,14 +6447,14 @@ class GlobalGenRoots():
|
|||
'js::jsapi::{JSPropertyOpWrapper, JSPropertySpec}',
|
||||
'js::jsapi::{JSStrictPropertyOpWrapper, JSString, JSTracer}',
|
||||
'js::jsval::JSVal',
|
||||
'js::jsval::PrivateValue',
|
||||
'js::glue::{CallJitMethodOp, CallJitPropertyOp, CreateProxyHandler}',
|
||||
'js::glue::{GetProxyPrivate, NewProxyObject, ProxyTraps}',
|
||||
'js::glue::{RUST_BOOLEAN_TO_JSVAL, RUST_FUNCTION_VALUE_TO_JITINFO}',
|
||||
'js::glue::{RUST_INT_TO_JSVAL, RUST_JS_NumberValue, RUST_JSID_IS_STRING}',
|
||||
'js::glue::{RUST_FUNCTION_VALUE_TO_JITINFO}',
|
||||
'js::glue::{RUST_JS_NumberValue, RUST_JSID_IS_STRING}',
|
||||
'js::glue::{RUST_JSVAL_IS_NULL, RUST_JSVAL_IS_PRIMITIVE}',
|
||||
'js::glue::{RUST_JSVAL_IS_VOID, RUST_JSVAL_TO_OBJECT}',
|
||||
'js::glue::{RUST_JSVAL_TO_PRIVATE, RUST_OBJECT_TO_JSVAL}',
|
||||
'js::glue::{RUST_PRIVATE_TO_JSVAL, RUST_UINT_TO_JSVAL}',], [], curr)
|
||||
'js::glue::{RUST_JSVAL_TO_PRIVATE}',], [], curr)
|
||||
|
||||
# Add the auto-generated comment.
|
||||
curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue