mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +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 = "${declName} = %s;" % value.define()
|
||||||
templateBody = handleDefaultNull(templateBody,
|
templateBody = handleDefaultNull(templateBody,
|
||||||
"${declName} = JSVAL_NULL")
|
"${declName} = NullValue()")
|
||||||
|
|
||||||
return (templateBody, declType, None, isOptional, "None" if isOptional else None)
|
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
|
# actually do want a jsval, and we only handle null anyway
|
||||||
if defaultValue is not None:
|
if defaultValue is not None:
|
||||||
assert(isinstance(defaultValue, IDLNullValue))
|
assert(isinstance(defaultValue, IDLNullValue))
|
||||||
val = "if ${haveValue} { ${val} } else { JSVAL_NULL }"
|
val = "if ${haveValue} { ${val} } else { NullValue() }"
|
||||||
else:
|
else:
|
||||||
val = "${val}"
|
val = "${val}"
|
||||||
|
|
||||||
|
@ -1467,7 +1467,7 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode,
|
||||||
return str
|
return str
|
||||||
|
|
||||||
if type is None or type.isVoid():
|
if type is None or type.isVoid():
|
||||||
return (setValue("JSVAL_VOID"), True)
|
return (setValue("UndefinedValue()"), True)
|
||||||
|
|
||||||
if type.isArray():
|
if type.isArray():
|
||||||
raise TypeError("Can't handle array return values yet")
|
raise TypeError("Can't handle array return values yet")
|
||||||
|
@ -1482,7 +1482,7 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode,
|
||||||
if (%s.IsNull()) {
|
if (%s.IsNull()) {
|
||||||
%s
|
%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
|
# Now do non-nullable sequences. We use setting the element
|
||||||
# in the array as our succcess code because when we succeed in
|
# 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)
|
descriptor = descriptorProvider.getDescriptor(type.unroll().inner.identifier.name)
|
||||||
if type.nullable():
|
if type.nullable():
|
||||||
wrappingCode = ("if %s.is_none() {\n" % (result) +
|
wrappingCode = ("if %s.is_none() {\n" % (result) +
|
||||||
CGIndenter(CGGeneric(setValue("JSVAL_NULL"))).define() + "\n" +
|
CGIndenter(CGGeneric(setValue("NullValue()"))).define() + "\n" +
|
||||||
"}\n" +
|
"}\n" +
|
||||||
"let mut %s = %s.unwrap();\n" % (result, result))
|
"let mut %s = %s.unwrap();\n" % (result, result))
|
||||||
else:
|
else:
|
||||||
|
@ -1552,7 +1552,7 @@ if %(resultStr)s.is_null() {
|
||||||
""" % { "result" : result,
|
""" % { "result" : result,
|
||||||
"resultStr" : result + "_str",
|
"resultStr" : result + "_str",
|
||||||
"strings" : type.inner.identifier.name + "Values::strings" } +
|
"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():
|
if type.isCallback():
|
||||||
assert not type.isInterface()
|
assert not type.isInterface()
|
||||||
|
@ -1573,9 +1573,9 @@ if %(resultStr)s.is_null() {
|
||||||
# See comments in WrapNewBindingObject explaining why we need
|
# See comments in WrapNewBindingObject explaining why we need
|
||||||
# to wrap here.
|
# to wrap here.
|
||||||
if type.nullable():
|
if type.nullable():
|
||||||
toValue = "RUST_OBJECT_TO_JSVAL(%s)"
|
toValue = "ObjectOrNullValue(%s)"
|
||||||
else:
|
else:
|
||||||
toValue = "RUST_OBJECT_TO_JSVAL(%s)"
|
toValue = "ObjectValue(&*(%s))"
|
||||||
# NB: setValue(..., True) calls JS_WrapValue(), so is fallible
|
# NB: setValue(..., True) calls JS_WrapValue(), so is fallible
|
||||||
return (setValue(toValue % result, True), False)
|
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));
|
let handler = js_info.get().get_ref().dom_static.proxy_handlers.get(&(PrototypeList::id::%s as uint));
|
||||||
""" % descriptor.name
|
""" % descriptor.name
|
||||||
create += handler + """ let obj = NewProxyObject(aCx, *handler,
|
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,
|
proto, %s,
|
||||||
ptr::null(), ptr::null());
|
ptr::null(), ptr::null());
|
||||||
if obj.is_null() {
|
if obj.is_null() {
|
||||||
|
@ -2548,7 +2548,7 @@ def CreateBindingJSObject(descriptor, parent=None):
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_SetReservedSlot(obj, DOM_OBJECT_SLOT as u32,
|
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
|
return create
|
||||||
|
|
||||||
|
@ -3310,7 +3310,7 @@ class CGGenericSetter(CGAbstractBindingMethod):
|
||||||
|
|
||||||
def generate_code(self):
|
def generate_code(self):
|
||||||
return CGIndenter(CGGeneric(
|
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 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 info: *JSJitInfo = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, vp as *JSVal));\n"
|
||||||
"let ok = with_gc_disabled(cx, || {\n"
|
"let ok = with_gc_disabled(cx, || {\n"
|
||||||
|
@ -3319,7 +3319,7 @@ class CGGenericSetter(CGAbstractBindingMethod):
|
||||||
"if ok == 0 {\n"
|
"if ok == 0 {\n"
|
||||||
" return 0;\n"
|
" return 0;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"*vp = JSVAL_VOID;\n"
|
"*vp = UndefinedValue();\n"
|
||||||
"return 1;"))
|
"return 1;"))
|
||||||
|
|
||||||
class CGSpecializedSetter(CGAbstractExternMethod):
|
class CGSpecializedSetter(CGAbstractExternMethod):
|
||||||
|
@ -4621,7 +4621,7 @@ if found {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
%s
|
%s
|
||||||
*vp = JSVAL_VOID;
|
*vp = UndefinedValue();
|
||||||
return 1;""" % (getIndexedOrExpando, getNamed)
|
return 1;""" % (getIndexedOrExpando, getNamed)
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
|
@ -5011,7 +5011,7 @@ class CGDictionary(CGThing):
|
||||||
" }\n"
|
" }\n"
|
||||||
"${initParent}"
|
"${initParent}"
|
||||||
" let mut found: JSBool = 0;\n"
|
" 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"
|
" let isNull = RUST_JSVAL_IS_NULL(val) != 0 || RUST_JSVAL_IS_VOID(val) != 0;\n"
|
||||||
" if !isNull && RUST_JSVAL_IS_PRIMITIVE(val) != 0 {\n"
|
" if !isNull && RUST_JSVAL_IS_PRIMITIVE(val) != 0 {\n"
|
||||||
" return 0; //XXXjdm throw properly here\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_IS_GLOBAL, JSCLASS_RESERVED_SLOTS_SHIFT}',
|
||||||
'js::{JSCLASS_RESERVED_SLOTS_MASK, JSID_VOID, JSJitInfo}',
|
'js::{JSCLASS_RESERVED_SLOTS_MASK, JSID_VOID, JSJitInfo}',
|
||||||
'js::{JSPROP_ENUMERATE, JSPROP_NATIVE_ACCESSORS, JSPROP_SHARED}',
|
'js::{JSPROP_ENUMERATE, JSPROP_NATIVE_ACCESSORS, JSPROP_SHARED}',
|
||||||
'js::{JSRESOLVE_ASSIGNING, JSRESOLVE_QUALIFIED, JSVAL_NULL}',
|
'js::{JSRESOLVE_ASSIGNING, JSRESOLVE_QUALIFIED}',
|
||||||
'js::{JSVAL_IS_OBJECT, JSVAL_TO_OBJECT, JSVAL_VOID}',
|
'js::{JSVAL_IS_OBJECT, JSVAL_TO_OBJECT}',
|
||||||
'js::jsapi::{JS_CallFunctionValue, JS_GetClass, JS_GetGlobalForObject}',
|
'js::jsapi::{JS_CallFunctionValue, JS_GetClass, JS_GetGlobalForObject}',
|
||||||
'js::jsapi::{JS_GetObjectPrototype, JS_GetProperty, JS_GetPropertyById}',
|
'js::jsapi::{JS_GetObjectPrototype, JS_GetProperty, JS_GetPropertyById}',
|
||||||
'js::jsapi::{JS_GetPropertyDescriptorById, JS_GetReservedSlot}',
|
'js::jsapi::{JS_GetPropertyDescriptorById, JS_GetReservedSlot}',
|
||||||
|
@ -5248,14 +5248,15 @@ class CGBindingRoot(CGThing):
|
||||||
'js::jsapi::{JSPropertyOpWrapper, JSPropertySpec}',
|
'js::jsapi::{JSPropertyOpWrapper, JSPropertySpec}',
|
||||||
'js::jsapi::{JSStrictPropertyOpWrapper, JSString, JSTracer}',
|
'js::jsapi::{JSStrictPropertyOpWrapper, JSString, JSTracer}',
|
||||||
'js::jsval::JSVal',
|
'js::jsval::JSVal',
|
||||||
|
'js::jsval::{ObjectValue, ObjectOrNullValue, PrivateValue}',
|
||||||
|
'js::jsval::{NullValue, UndefinedValue}',
|
||||||
'js::glue::{CallJitMethodOp, CallJitPropertyOp, CreateProxyHandler}',
|
'js::glue::{CallJitMethodOp, CallJitPropertyOp, CreateProxyHandler}',
|
||||||
'js::glue::{GetProxyPrivate, NewProxyObject, ProxyTraps}',
|
'js::glue::{GetProxyPrivate, NewProxyObject, ProxyTraps}',
|
||||||
'js::glue::{RUST_BOOLEAN_TO_JSVAL, RUST_FUNCTION_VALUE_TO_JITINFO}',
|
'js::glue::{RUST_FUNCTION_VALUE_TO_JITINFO}',
|
||||||
'js::glue::{RUST_INT_TO_JSVAL, RUST_JS_NumberValue, RUST_JSID_IS_STRING}',
|
'js::glue::{RUST_JS_NumberValue, RUST_JSID_IS_STRING}',
|
||||||
'js::glue::{RUST_JSVAL_IS_NULL, RUST_JSVAL_IS_PRIMITIVE}',
|
'js::glue::{RUST_JSVAL_IS_NULL, RUST_JSVAL_IS_PRIMITIVE}',
|
||||||
'js::glue::{RUST_JSVAL_IS_VOID, RUST_JSVAL_TO_OBJECT}',
|
'js::glue::{RUST_JSVAL_IS_VOID, RUST_JSVAL_TO_OBJECT}',
|
||||||
'js::glue::{RUST_JSVAL_TO_PRIVATE, RUST_OBJECT_TO_JSVAL}',
|
'js::glue::{RUST_JSVAL_TO_PRIVATE}',
|
||||||
'js::glue::{RUST_PRIVATE_TO_JSVAL, RUST_UINT_TO_JSVAL}',
|
|
||||||
'dom::types::*',
|
'dom::types::*',
|
||||||
'dom::bindings::js::JS',
|
'dom::bindings::js::JS',
|
||||||
'dom::bindings::utils::{CreateDOMGlobal, CreateInterfaceObjects2}',
|
'dom::bindings::utils::{CreateDOMGlobal, CreateInterfaceObjects2}',
|
||||||
|
@ -5696,7 +5697,7 @@ class CGCallback(CGClass):
|
||||||
# the private method.
|
# the private method.
|
||||||
argnames = [arg.name for arg in args]
|
argnames = [arg.name for arg in args]
|
||||||
argnamesWithThis = ["s.GetContext()", "thisObjJS"] + argnames
|
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
|
# Now that we've recorded the argnames for our call to our private
|
||||||
# method, insert our optional argument for deciding whether the
|
# method, insert our optional argument for deciding whether the
|
||||||
# CallSetup should re-throw exceptions on aRv.
|
# CallSetup should re-throw exceptions on aRv.
|
||||||
|
@ -5861,7 +5862,7 @@ class CallbackMember(CGNativeMember):
|
||||||
if self.argCount > 0:
|
if self.argCount > 0:
|
||||||
replacements["argCount"] = self.argCountStr
|
replacements["argCount"] = self.argCountStr
|
||||||
replacements["argvDecl"] = string.Template(
|
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)
|
).substitute(replacements)
|
||||||
else:
|
else:
|
||||||
# Avoid weird 0-sized arrays
|
# Avoid weird 0-sized arrays
|
||||||
|
@ -6045,7 +6046,7 @@ class CallbackMethod(CallbackMember):
|
||||||
CallbackMember.__init__(self, sig, name, descriptorProvider,
|
CallbackMember.__init__(self, sig, name, descriptorProvider,
|
||||||
needThisHandling, rethrowContentException)
|
needThisHandling, rethrowContentException)
|
||||||
def getRvalDecl(self):
|
def getRvalDecl(self):
|
||||||
return "let mut rval = JSVAL_VOID;\n"
|
return "let mut rval = UndefinedValue();\n"
|
||||||
|
|
||||||
def getCall(self):
|
def getCall(self):
|
||||||
replacements = {
|
replacements = {
|
||||||
|
@ -6112,9 +6113,9 @@ class CallbackOperationBase(CallbackMethod):
|
||||||
return 'JS::Rooted<JS::Value> callable(cx);\n' + getCallableFromProp
|
return 'JS::Rooted<JS::Value> callable(cx);\n' + getCallableFromProp
|
||||||
return (
|
return (
|
||||||
'let isCallable = unsafe { JS_ObjectIsCallable(cx, self.parent.callback) != 0 };\n'
|
'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'
|
'if isCallable {\n'
|
||||||
' callable = unsafe { RUST_OBJECT_TO_JSVAL(self.parent.callback) };\n'
|
' callable = unsafe { ObjectValue(&*self.parent.callback) };\n'
|
||||||
'} else {\n'
|
'} else {\n'
|
||||||
'%s'
|
'%s'
|
||||||
'}\n' % CGIndenter(CGGeneric(getCallableFromProp)).define())
|
'}\n' % CGIndenter(CGGeneric(getCallableFromProp)).define())
|
||||||
|
@ -6433,8 +6434,8 @@ class GlobalGenRoots():
|
||||||
'js::{JSCLASS_IS_GLOBAL, JSCLASS_RESERVED_SLOTS_SHIFT}',
|
'js::{JSCLASS_IS_GLOBAL, JSCLASS_RESERVED_SLOTS_SHIFT}',
|
||||||
'js::{JSCLASS_RESERVED_SLOTS_MASK, JSID_VOID, JSJitInfo}',
|
'js::{JSCLASS_RESERVED_SLOTS_MASK, JSID_VOID, JSJitInfo}',
|
||||||
'js::{JSPROP_ENUMERATE, JSPROP_NATIVE_ACCESSORS, JSPROP_SHARED}',
|
'js::{JSPROP_ENUMERATE, JSPROP_NATIVE_ACCESSORS, JSPROP_SHARED}',
|
||||||
'js::{JSRESOLVE_ASSIGNING, JSRESOLVE_QUALIFIED, JSVAL_NULL}',
|
'js::{JSRESOLVE_ASSIGNING, JSRESOLVE_QUALIFIED}',
|
||||||
'js::{JSVAL_IS_OBJECT, JSVAL_TO_OBJECT, JSVAL_VOID}',
|
'js::{JSVAL_IS_OBJECT, JSVAL_TO_OBJECT}',
|
||||||
'js::jsapi::{JS_CallFunctionValue, JS_GetClass, JS_GetGlobalForObject}',
|
'js::jsapi::{JS_CallFunctionValue, JS_GetClass, JS_GetGlobalForObject}',
|
||||||
'js::jsapi::{JS_GetObjectPrototype, JS_GetProperty, JS_GetPropertyById}',
|
'js::jsapi::{JS_GetObjectPrototype, JS_GetProperty, JS_GetPropertyById}',
|
||||||
'js::jsapi::{JS_GetPropertyDescriptorById, JS_GetReservedSlot}',
|
'js::jsapi::{JS_GetPropertyDescriptorById, JS_GetReservedSlot}',
|
||||||
|
@ -6446,14 +6447,14 @@ class GlobalGenRoots():
|
||||||
'js::jsapi::{JSPropertyOpWrapper, JSPropertySpec}',
|
'js::jsapi::{JSPropertyOpWrapper, JSPropertySpec}',
|
||||||
'js::jsapi::{JSStrictPropertyOpWrapper, JSString, JSTracer}',
|
'js::jsapi::{JSStrictPropertyOpWrapper, JSString, JSTracer}',
|
||||||
'js::jsval::JSVal',
|
'js::jsval::JSVal',
|
||||||
|
'js::jsval::PrivateValue',
|
||||||
'js::glue::{CallJitMethodOp, CallJitPropertyOp, CreateProxyHandler}',
|
'js::glue::{CallJitMethodOp, CallJitPropertyOp, CreateProxyHandler}',
|
||||||
'js::glue::{GetProxyPrivate, NewProxyObject, ProxyTraps}',
|
'js::glue::{GetProxyPrivate, NewProxyObject, ProxyTraps}',
|
||||||
'js::glue::{RUST_BOOLEAN_TO_JSVAL, RUST_FUNCTION_VALUE_TO_JITINFO}',
|
'js::glue::{RUST_FUNCTION_VALUE_TO_JITINFO}',
|
||||||
'js::glue::{RUST_INT_TO_JSVAL, RUST_JS_NumberValue, RUST_JSID_IS_STRING}',
|
'js::glue::{RUST_JS_NumberValue, RUST_JSID_IS_STRING}',
|
||||||
'js::glue::{RUST_JSVAL_IS_NULL, RUST_JSVAL_IS_PRIMITIVE}',
|
'js::glue::{RUST_JSVAL_IS_NULL, RUST_JSVAL_IS_PRIMITIVE}',
|
||||||
'js::glue::{RUST_JSVAL_IS_VOID, RUST_JSVAL_TO_OBJECT}',
|
'js::glue::{RUST_JSVAL_IS_VOID, RUST_JSVAL_TO_OBJECT}',
|
||||||
'js::glue::{RUST_JSVAL_TO_PRIVATE, RUST_OBJECT_TO_JSVAL}',
|
'js::glue::{RUST_JSVAL_TO_PRIVATE}',], [], curr)
|
||||||
'js::glue::{RUST_PRIVATE_TO_JSVAL, RUST_UINT_TO_JSVAL}',], [], curr)
|
|
||||||
|
|
||||||
# Add the auto-generated comment.
|
# Add the auto-generated comment.
|
||||||
curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT)
|
curr = CGWrapper(curr, pre=AUTOGENERATED_WARNING_COMMENT)
|
||||||
|
|
|
@ -7,8 +7,8 @@ use js::jsapi::{JS_ValueToUint64, JS_ValueToInt64};
|
||||||
use js::jsapi::{JS_ValueToECMAUint32, JS_ValueToECMAInt32};
|
use js::jsapi::{JS_ValueToECMAUint32, JS_ValueToECMAInt32};
|
||||||
use js::jsapi::{JS_ValueToUint16, JS_ValueToNumber, JS_ValueToBoolean};
|
use js::jsapi::{JS_ValueToUint16, JS_ValueToNumber, JS_ValueToBoolean};
|
||||||
use js::jsval::JSVal;
|
use js::jsval::JSVal;
|
||||||
use js::{JSVAL_FALSE, JSVAL_TRUE, JSVAL_NULL};
|
use js::jsval::{NullValue, BooleanValue, Int32Value, UInt32Value};
|
||||||
use js::glue::{RUST_INT_TO_JSVAL, RUST_UINT_TO_JSVAL, RUST_JS_NumberValue};
|
use js::glue::RUST_JS_NumberValue;
|
||||||
use js::glue::{RUST_JSVAL_IS_NULL, RUST_JSVAL_IS_VOID};
|
use js::glue::{RUST_JSVAL_IS_NULL, RUST_JSVAL_IS_VOID};
|
||||||
|
|
||||||
pub trait JSValConvertible {
|
pub trait JSValConvertible {
|
||||||
|
@ -31,11 +31,7 @@ unsafe fn convert_from_jsval<T: Default>(
|
||||||
|
|
||||||
impl JSValConvertible for bool {
|
impl JSValConvertible for bool {
|
||||||
fn to_jsval(&self) -> JSVal {
|
fn to_jsval(&self) -> JSVal {
|
||||||
if *self {
|
BooleanValue(*self)
|
||||||
JSVAL_TRUE
|
|
||||||
} else {
|
|
||||||
JSVAL_FALSE
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_jsval(cx: *JSContext, val: JSVal) -> Result<bool, ()> {
|
fn from_jsval(cx: *JSContext, val: JSVal) -> Result<bool, ()> {
|
||||||
|
@ -46,9 +42,7 @@ impl JSValConvertible for bool {
|
||||||
|
|
||||||
impl JSValConvertible for i8 {
|
impl JSValConvertible for i8 {
|
||||||
fn to_jsval(&self) -> JSVal {
|
fn to_jsval(&self) -> JSVal {
|
||||||
unsafe {
|
Int32Value(*self as i32)
|
||||||
RUST_INT_TO_JSVAL(*self as i32)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_jsval(cx: *JSContext, val: JSVal) -> Result<i8, ()> {
|
fn from_jsval(cx: *JSContext, val: JSVal) -> Result<i8, ()> {
|
||||||
|
@ -59,9 +53,7 @@ impl JSValConvertible for i8 {
|
||||||
|
|
||||||
impl JSValConvertible for u8 {
|
impl JSValConvertible for u8 {
|
||||||
fn to_jsval(&self) -> JSVal {
|
fn to_jsval(&self) -> JSVal {
|
||||||
unsafe {
|
Int32Value(*self as i32)
|
||||||
RUST_INT_TO_JSVAL(*self as i32)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_jsval(cx: *JSContext, val: JSVal) -> Result<u8, ()> {
|
fn from_jsval(cx: *JSContext, val: JSVal) -> Result<u8, ()> {
|
||||||
|
@ -72,9 +64,7 @@ impl JSValConvertible for u8 {
|
||||||
|
|
||||||
impl JSValConvertible for i16 {
|
impl JSValConvertible for i16 {
|
||||||
fn to_jsval(&self) -> JSVal {
|
fn to_jsval(&self) -> JSVal {
|
||||||
unsafe {
|
Int32Value(*self as i32)
|
||||||
RUST_INT_TO_JSVAL(*self as i32)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_jsval(cx: *JSContext, val: JSVal) -> Result<i16, ()> {
|
fn from_jsval(cx: *JSContext, val: JSVal) -> Result<i16, ()> {
|
||||||
|
@ -85,9 +75,7 @@ impl JSValConvertible for i16 {
|
||||||
|
|
||||||
impl JSValConvertible for u16 {
|
impl JSValConvertible for u16 {
|
||||||
fn to_jsval(&self) -> JSVal {
|
fn to_jsval(&self) -> JSVal {
|
||||||
unsafe {
|
Int32Value(*self as i32)
|
||||||
RUST_UINT_TO_JSVAL(*self as u32)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_jsval(cx: *JSContext, val: JSVal) -> Result<u16, ()> {
|
fn from_jsval(cx: *JSContext, val: JSVal) -> Result<u16, ()> {
|
||||||
|
@ -97,9 +85,7 @@ impl JSValConvertible for u16 {
|
||||||
|
|
||||||
impl JSValConvertible for i32 {
|
impl JSValConvertible for i32 {
|
||||||
fn to_jsval(&self) -> JSVal {
|
fn to_jsval(&self) -> JSVal {
|
||||||
unsafe {
|
Int32Value(*self)
|
||||||
RUST_INT_TO_JSVAL(*self)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_jsval(cx: *JSContext, val: JSVal) -> Result<i32, ()> {
|
fn from_jsval(cx: *JSContext, val: JSVal) -> Result<i32, ()> {
|
||||||
|
@ -109,9 +95,7 @@ impl JSValConvertible for i32 {
|
||||||
|
|
||||||
impl JSValConvertible for u32 {
|
impl JSValConvertible for u32 {
|
||||||
fn to_jsval(&self) -> JSVal {
|
fn to_jsval(&self) -> JSVal {
|
||||||
unsafe {
|
UInt32Value(*self)
|
||||||
RUST_UINT_TO_JSVAL(*self)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_jsval(cx: *JSContext, val: JSVal) -> Result<u32, ()> {
|
fn from_jsval(cx: *JSContext, val: JSVal) -> Result<u32, ()> {
|
||||||
|
@ -172,7 +156,7 @@ impl<T: JSValConvertible> JSValConvertible for Option<T> {
|
||||||
fn to_jsval(&self) -> JSVal {
|
fn to_jsval(&self) -> JSVal {
|
||||||
match self {
|
match self {
|
||||||
&Some(ref value) => value.to_jsval(),
|
&Some(ref value) => value.to_jsval(),
|
||||||
&None => JSVAL_NULL,
|
&None => NullValue(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,8 @@ use dom::bindings::utils::is_dom_proxy;
|
||||||
use js::jsapi::{JSContext, jsid, JSPropertyDescriptor, JSObject, JSString, jschar};
|
use js::jsapi::{JSContext, jsid, JSPropertyDescriptor, JSObject, JSString, jschar};
|
||||||
use js::jsapi::{JS_GetPropertyDescriptorById, JS_NewUCString, JS_malloc, JS_free};
|
use js::jsapi::{JS_GetPropertyDescriptorById, JS_NewUCString, JS_malloc, JS_free};
|
||||||
use js::jsapi::{JSBool, JS_DefinePropertyById, JS_NewObjectWithGivenProto};
|
use js::jsapi::{JSBool, JS_DefinePropertyById, JS_NewObjectWithGivenProto};
|
||||||
use js::glue::{RUST_JSVAL_IS_VOID, RUST_JSVAL_TO_OBJECT, GetProxyExtra, RUST_OBJECT_TO_JSVAL};
|
use js::jsval::ObjectValue;
|
||||||
|
use js::glue::{RUST_JSVAL_IS_VOID, RUST_JSVAL_TO_OBJECT, GetProxyExtra};
|
||||||
use js::glue::{GetObjectProto, GetObjectParent, SetProxyExtra, GetProxyHandler};
|
use js::glue::{GetObjectProto, GetObjectParent, SetProxyExtra, GetProxyHandler};
|
||||||
use js::glue::InvokeGetOwnPropertyDescriptor;
|
use js::glue::InvokeGetOwnPropertyDescriptor;
|
||||||
use js::crust::{JS_StrictPropertyStub};
|
use js::crust::{JS_StrictPropertyStub};
|
||||||
|
@ -116,7 +117,7 @@ pub fn EnsureExpandoObject(cx: *JSContext, obj: *JSObject) -> *JSObject {
|
||||||
return ptr::null();
|
return ptr::null();
|
||||||
}
|
}
|
||||||
|
|
||||||
SetProxyExtra(obj, JSPROXYSLOT_EXPANDO, RUST_OBJECT_TO_JSVAL(expando));
|
SetProxyExtra(obj, JSPROXYSLOT_EXPANDO, ObjectValue(&*expando));
|
||||||
}
|
}
|
||||||
return expando;
|
return expando;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ use std::str;
|
||||||
use std::vec;
|
use std::vec;
|
||||||
use std::unstable::raw::Box;
|
use std::unstable::raw::Box;
|
||||||
use js::glue::*;
|
use js::glue::*;
|
||||||
use js::glue::{RUST_OBJECT_TO_JSVAL};
|
|
||||||
use js::glue::{js_IsObjectProxyClass, js_IsFunctionProxyClass, IsProxyHandlerFamily};
|
use js::glue::{js_IsObjectProxyClass, js_IsFunctionProxyClass, IsProxyHandlerFamily};
|
||||||
use js::jsapi::{JS_AlreadyHasOwnProperty, JS_NewFunction};
|
use js::jsapi::{JS_AlreadyHasOwnProperty, JS_NewFunction};
|
||||||
use js::jsapi::{JS_DefineProperties, JS_WrapValue, JS_ForwardGetPropertyTo};
|
use js::jsapi::{JS_DefineProperties, JS_WrapValue, JS_ForwardGetPropertyTo};
|
||||||
|
@ -36,9 +35,11 @@ use js::jsapi::{JSString};
|
||||||
use js::jsapi::{JS_AllowGC, JS_InhibitGC};
|
use js::jsapi::{JS_AllowGC, JS_InhibitGC};
|
||||||
use js::jsfriendapi::bindgen::JS_NewObjectWithUniqueType;
|
use js::jsfriendapi::bindgen::JS_NewObjectWithUniqueType;
|
||||||
use js::jsval::JSVal;
|
use js::jsval::JSVal;
|
||||||
use js::{JSPROP_ENUMERATE, JSVAL_NULL, JSCLASS_IS_GLOBAL, JSCLASS_IS_DOMJSCLASS};
|
use js::jsval::{StringValue, PrivateValue, ObjectValue, NullValue, Int32Value};
|
||||||
|
use js::jsval::{UInt32Value, DoubleValue, BooleanValue, UndefinedValue};
|
||||||
|
use js::{JSPROP_ENUMERATE, JSCLASS_IS_GLOBAL, JSCLASS_IS_DOMJSCLASS};
|
||||||
use js::{JSPROP_PERMANENT, JSID_VOID, JSPROP_NATIVE_ACCESSORS, JSPROP_GETTER};
|
use js::{JSPROP_PERMANENT, JSID_VOID, JSPROP_NATIVE_ACCESSORS, JSPROP_GETTER};
|
||||||
use js::{JSPROP_SETTER, JSVAL_VOID, JSVAL_TRUE, JSVAL_FALSE};
|
use js::JSPROP_SETTER;
|
||||||
use js::{JSFUN_CONSTRUCTOR, JSPROP_READONLY};
|
use js::{JSFUN_CONSTRUCTOR, JSPROP_READONLY};
|
||||||
use js;
|
use js;
|
||||||
|
|
||||||
|
@ -214,12 +215,12 @@ pub unsafe fn str_to_jsval(cx: *JSContext, string: DOMString) -> JSVal {
|
||||||
if jsstr.is_null() {
|
if jsstr.is_null() {
|
||||||
fail!("JS_NewUCStringCopyN failed");
|
fail!("JS_NewUCStringCopyN failed");
|
||||||
}
|
}
|
||||||
RUST_STRING_TO_JSVAL(jsstr)
|
StringValue(&*jsstr)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn domstring_to_jsval(cx: *JSContext, string: Option<DOMString>) -> JSVal {
|
pub unsafe fn domstring_to_jsval(cx: *JSContext, string: Option<DOMString>) -> JSVal {
|
||||||
match string {
|
match string {
|
||||||
None => JSVAL_NULL,
|
None => NullValue(),
|
||||||
Some(s) => str_to_jsval(cx, s),
|
Some(s) => str_to_jsval(cx, s),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -334,7 +335,7 @@ pub fn CreateInterfaceObjects2(cx: *JSContext, global: *JSObject, receiver: *JSO
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
JS_SetReservedSlot(proto, DOM_PROTO_INSTANCE_CLASS_SLOT,
|
JS_SetReservedSlot(proto, DOM_PROTO_INSTANCE_CLASS_SLOT,
|
||||||
RUST_PRIVATE_TO_JSVAL(domClass as *libc::c_void));
|
PrivateValue(domClass as *libc::c_void));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,7 +394,7 @@ fn CreateInterfaceObject(cx: *JSContext, global: *JSObject, receiver: *JSObject,
|
||||||
}
|
}
|
||||||
|
|
||||||
if alreadyDefined == 0 &&
|
if alreadyDefined == 0 &&
|
||||||
JS_DefineProperty(cx, receiver, name, RUST_OBJECT_TO_JSVAL(constructor),
|
JS_DefineProperty(cx, receiver, name, ObjectValue(&*constructor),
|
||||||
None, None, 0) == 0 {
|
None, None, 0) == 0 {
|
||||||
return ptr::null();
|
return ptr::null();
|
||||||
}
|
}
|
||||||
|
@ -411,13 +412,12 @@ fn DefineConstants(cx: *JSContext, obj: *JSObject, constants: *ConstantSpec) ->
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
let jsval = match spec.value {
|
let jsval = match spec.value {
|
||||||
NullVal => JSVAL_NULL,
|
NullVal => NullValue(),
|
||||||
IntVal(i) => RUST_INT_TO_JSVAL(i),
|
IntVal(i) => Int32Value(i),
|
||||||
UintVal(u) => RUST_UINT_TO_JSVAL(u),
|
UintVal(u) => UInt32Value(u),
|
||||||
DoubleVal(d) => RUST_DOUBLE_TO_JSVAL(d),
|
DoubleVal(d) => DoubleValue(d),
|
||||||
BoolVal(b) if b => JSVAL_TRUE,
|
BoolVal(b) => BooleanValue(b),
|
||||||
BoolVal(_) => JSVAL_FALSE,
|
VoidVal => UndefinedValue(),
|
||||||
VoidVal => JSVAL_VOID
|
|
||||||
};
|
};
|
||||||
if JS_DefineProperty(cx, obj, spec.name,
|
if JS_DefineProperty(cx, obj, spec.name,
|
||||||
jsval, None,
|
jsval, None,
|
||||||
|
@ -481,7 +481,7 @@ pub fn initialize_global(global: *JSObject) {
|
||||||
let box_ = squirrel_away_unboxed(protoArray);
|
let box_ = squirrel_away_unboxed(protoArray);
|
||||||
JS_SetReservedSlot(global,
|
JS_SetReservedSlot(global,
|
||||||
DOM_PROTOTYPE_SLOT,
|
DOM_PROTOTYPE_SLOT,
|
||||||
RUST_PRIVATE_TO_JSVAL(box_ as *libc::c_void));
|
PrivateValue(box_ as *libc::c_void));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,7 +529,7 @@ pub fn GetReflector(cx: *JSContext, reflector: &Reflector,
|
||||||
let obj = reflector.get_jsobject();
|
let obj = reflector.get_jsobject();
|
||||||
assert!(obj.is_not_null());
|
assert!(obj.is_not_null());
|
||||||
unsafe {
|
unsafe {
|
||||||
*vp = RUST_OBJECT_TO_JSVAL(obj);
|
*vp = ObjectValue(&*obj);
|
||||||
return JS_WrapValue(cx, cast::transmute(vp));
|
return JS_WrapValue(cx, cast::transmute(vp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,7 @@ use dom::element::{Element, ElementTypeId, HTMLElementTypeId};
|
||||||
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
|
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
|
||||||
use dom::node::{Node, ElementNodeTypeId};
|
use dom::node::{Node, ElementNodeTypeId};
|
||||||
use js::jsapi::JSContext;
|
use js::jsapi::JSContext;
|
||||||
use js::jsval::JSVal;
|
use js::jsval::{JSVal, NullValue};
|
||||||
use js::JSVAL_NULL;
|
|
||||||
use servo_util::namespace;
|
use servo_util::namespace;
|
||||||
use servo_util::str::DOMString;
|
use servo_util::str::DOMString;
|
||||||
|
|
||||||
|
@ -67,7 +66,7 @@ impl HTMLElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn GetItemValue(&self, _cx: *JSContext) -> Fallible<JSVal> {
|
pub fn GetItemValue(&self, _cx: *JSContext) -> Fallible<JSVal> {
|
||||||
Ok(JSVAL_NULL)
|
Ok(NullValue())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn SetItemValue(&mut self, _cx: *JSContext, _val: JSVal) -> ErrorResult {
|
pub fn SetItemValue(&mut self, _cx: *JSContext, _val: JSVal) -> ErrorResult {
|
||||||
|
|
|
@ -8,9 +8,8 @@ use dom::blob::Blob;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use servo_util::str::DOMString;
|
use servo_util::str::DOMString;
|
||||||
|
|
||||||
use js::JSVAL_NULL;
|
|
||||||
use js::jsapi::JSContext;
|
use js::jsapi::JSContext;
|
||||||
use js::jsval::JSVal;
|
use js::jsval::{JSVal, NullValue};
|
||||||
|
|
||||||
#[deriving(Encodable)]
|
#[deriving(Encodable)]
|
||||||
pub struct TestBinding {
|
pub struct TestBinding {
|
||||||
|
@ -45,7 +44,7 @@ impl TestBinding {
|
||||||
pub fn SetStringAttribute(&self, _: DOMString) {}
|
pub fn SetStringAttribute(&self, _: DOMString) {}
|
||||||
pub fn InterfaceAttribute(&self) -> JS<Blob> { Blob::new(&self.window) }
|
pub fn InterfaceAttribute(&self) -> JS<Blob> { Blob::new(&self.window) }
|
||||||
pub fn SetInterfaceAttribute(&self, _: &JS<Blob>) {}
|
pub fn SetInterfaceAttribute(&self, _: &JS<Blob>) {}
|
||||||
pub fn AnyAttribute(&self, _: *JSContext) -> JSVal { JSVAL_NULL }
|
pub fn AnyAttribute(&self, _: *JSContext) -> JSVal { NullValue() }
|
||||||
pub fn SetAnyAttribute(&self, _: *JSContext, _: JSVal) {}
|
pub fn SetAnyAttribute(&self, _: *JSContext, _: JSVal) {}
|
||||||
|
|
||||||
pub fn GetBooleanAttributeNullable(&self) -> Option<bool> { Some(false) }
|
pub fn GetBooleanAttributeNullable(&self) -> Option<bool> { Some(false) }
|
||||||
|
|
|
@ -22,7 +22,8 @@ use servo_util::task::{spawn_named};
|
||||||
use js::glue::*;
|
use js::glue::*;
|
||||||
use js::jsapi::{JSObject, JSContext, JS_DefineProperty};
|
use js::jsapi::{JSObject, JSContext, JS_DefineProperty};
|
||||||
use js::jsval::JSVal;
|
use js::jsval::JSVal;
|
||||||
use js::{JSVAL_NULL, JSPROP_ENUMERATE};
|
use js::jsval::{NullValue, ObjectValue};
|
||||||
|
use js::JSPROP_ENUMERATE;
|
||||||
|
|
||||||
use std::cast;
|
use std::cast;
|
||||||
use std::comm::SharedChan;
|
use std::comm::SharedChan;
|
||||||
|
@ -209,7 +210,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ShowModalDialog(&self, _cx: *JSContext, _url: DOMString, _argument: Option<JSVal>) -> JSVal {
|
pub fn ShowModalDialog(&self, _cx: *JSContext, _url: DOMString, _argument: Option<JSVal>) -> JSVal {
|
||||||
JSVAL_NULL
|
NullValue()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +319,7 @@ impl Window {
|
||||||
for str in fn_names.iter() {
|
for str in fn_names.iter() {
|
||||||
(*str).to_c_str().with_ref(|name| {
|
(*str).to_c_str().with_ref(|name| {
|
||||||
JS_DefineProperty(cx, global, name,
|
JS_DefineProperty(cx, global, name,
|
||||||
RUST_OBJECT_TO_JSVAL(global),
|
ObjectValue(&*global),
|
||||||
Some(cast::transmute(GetJSClassHookStubPointer(PROPERTY_STUB))),
|
Some(cast::transmute(GetJSClassHookStubPointer(PROPERTY_STUB))),
|
||||||
Some(cast::transmute(GetJSClassHookStubPointer(STRICT_PROPERTY_STUB))),
|
Some(cast::transmute(GetJSClassHookStubPointer(STRICT_PROPERTY_STUB))),
|
||||||
JSPROP_ENUMERATE);
|
JSPROP_ENUMERATE);
|
||||||
|
|
|
@ -32,10 +32,10 @@ use layout_interface;
|
||||||
use extra::url::Url;
|
use extra::url::Url;
|
||||||
use geom::point::Point2D;
|
use geom::point::Point2D;
|
||||||
use geom::size::Size2D;
|
use geom::size::Size2D;
|
||||||
use js::JSVAL_NULL;
|
|
||||||
use js::global::DEBUG_FNS;
|
use js::global::DEBUG_FNS;
|
||||||
use js::glue::RUST_JSVAL_TO_OBJECT;
|
use js::glue::RUST_JSVAL_TO_OBJECT;
|
||||||
use js::jsapi::{JSObject, JS_InhibitGC, JS_AllowGC, JS_CallFunctionValue};
|
use js::jsapi::{JSObject, JS_InhibitGC, JS_AllowGC, JS_CallFunctionValue};
|
||||||
|
use js::jsval::NullValue;
|
||||||
use js::rust::{Compartment, Cx, CxUtils, RtUtils};
|
use js::rust::{Compartment, Cx, CxUtils, RtUtils};
|
||||||
use js;
|
use js;
|
||||||
use servo_msg::compositor_msg::{FinishedLoading, Loading, PerformingLayout, ScriptListener};
|
use servo_msg::compositor_msg::{FinishedLoading, Loading, PerformingLayout, ScriptListener};
|
||||||
|
@ -659,7 +659,7 @@ impl ScriptTask {
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Support extra arguments. This requires passing a `*JSVal` array as `argv`.
|
// TODO: Support extra arguments. This requires passing a `*JSVal` array as `argv`.
|
||||||
let rval = JSVAL_NULL;
|
let rval = NullValue();
|
||||||
let cx = js_info.get().get_ref().js_context.borrow().ptr;
|
let cx = js_info.get().get_ref().js_context.borrow().ptr;
|
||||||
with_gc_enabled(cx, || {
|
with_gc_enabled(cx, || {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 06d2780bfea9a084b8b78c643be4e7423ab75e42
|
Subproject commit e993175799354c94224f89e2e2bdc5676998dcd5
|
Loading…
Add table
Add a link
Reference in a new issue