mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Update ProxyTraps to use real bools.
This commit is contained in:
parent
b0c2e09ed7
commit
16510963b5
3 changed files with 58 additions and 53 deletions
|
@ -3547,10 +3547,10 @@ return box_;""" % self.descriptor.concreteType)
|
||||||
class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
||||||
def __init__(self, descriptor):
|
def __init__(self, descriptor):
|
||||||
args = [Argument('*mut JSContext', 'cx'), Argument('*mut JSObject', 'proxy'),
|
args = [Argument('*mut JSContext', 'cx'), Argument('*mut JSObject', 'proxy'),
|
||||||
Argument('jsid', 'id'), Argument('JSBool', 'set'),
|
Argument('jsid', 'id'), Argument('bool', 'set'),
|
||||||
Argument('*mut JSPropertyDescriptor', 'desc')]
|
Argument('*mut JSPropertyDescriptor', 'desc')]
|
||||||
CGAbstractExternMethod.__init__(self, descriptor, "getOwnPropertyDescriptor",
|
CGAbstractExternMethod.__init__(self, descriptor, "getOwnPropertyDescriptor",
|
||||||
"JSBool", args)
|
"bool", args)
|
||||||
self.descriptor = descriptor
|
self.descriptor = descriptor
|
||||||
def getBody(self):
|
def getBody(self):
|
||||||
indexedGetter = self.descriptor.operations['IndexedGetter']
|
indexedGetter = self.descriptor.operations['IndexedGetter']
|
||||||
|
@ -3562,7 +3562,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
||||||
|
|
||||||
if indexedGetter:
|
if indexedGetter:
|
||||||
readonly = toStringBool(self.descriptor.operations['IndexedSetter'] is None)
|
readonly = toStringBool(self.descriptor.operations['IndexedSetter'] is None)
|
||||||
fillDescriptor = "FillPropertyDescriptor(&mut *desc, proxy, %s);\nreturn 1;" % readonly
|
fillDescriptor = "FillPropertyDescriptor(&mut *desc, proxy, %s);\nreturn true;" % readonly
|
||||||
templateValues = {'jsvalRef': '(*desc).value', 'successCode': fillDescriptor}
|
templateValues = {'jsvalRef': '(*desc).value', 'successCode': fillDescriptor}
|
||||||
get = ("if index.is_some() {\n" +
|
get = ("if index.is_some() {\n" +
|
||||||
" let index = index.unwrap();\n" +
|
" let index = index.unwrap();\n" +
|
||||||
|
@ -3581,7 +3581,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
||||||
# FIXME need to check that this is a 'supported property index'
|
# FIXME need to check that this is a 'supported property index'
|
||||||
assert False
|
assert False
|
||||||
setOrIndexedGet += (" FillPropertyDescriptor(&mut *desc, proxy, false);\n" +
|
setOrIndexedGet += (" FillPropertyDescriptor(&mut *desc, proxy, false);\n" +
|
||||||
" return 1;\n" +
|
" return true;\n" +
|
||||||
" }\n")
|
" }\n")
|
||||||
if self.descriptor.operations['NamedSetter']:
|
if self.descriptor.operations['NamedSetter']:
|
||||||
setOrIndexedGet += " if RUST_JSID_IS_STRING(id) {\n"
|
setOrIndexedGet += " if RUST_JSID_IS_STRING(id) {\n"
|
||||||
|
@ -3589,7 +3589,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
||||||
# FIXME need to check that this is a 'supported property name'
|
# FIXME need to check that this is a 'supported property name'
|
||||||
assert False
|
assert False
|
||||||
setOrIndexedGet += (" FillPropertyDescriptor(&mut *desc, proxy, false);\n" +
|
setOrIndexedGet += (" FillPropertyDescriptor(&mut *desc, proxy, false);\n" +
|
||||||
" return 1;\n" +
|
" return true;\n" +
|
||||||
" }\n")
|
" }\n")
|
||||||
setOrIndexedGet += "}"
|
setOrIndexedGet += "}"
|
||||||
if indexedGetter:
|
if indexedGetter:
|
||||||
|
@ -3598,20 +3598,20 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
||||||
"}")
|
"}")
|
||||||
setOrIndexedGet += "\n\n"
|
setOrIndexedGet += "\n\n"
|
||||||
elif indexedGetter:
|
elif indexedGetter:
|
||||||
setOrIndexedGet += ("if set == 0 {\n" +
|
setOrIndexedGet += ("if !set {\n" +
|
||||||
CGIndenter(CGGeneric(get)).define() +
|
CGIndenter(CGGeneric(get)).define() +
|
||||||
"}\n\n")
|
"}\n\n")
|
||||||
|
|
||||||
namedGetter = self.descriptor.operations['NamedGetter']
|
namedGetter = self.descriptor.operations['NamedGetter']
|
||||||
if namedGetter:
|
if namedGetter:
|
||||||
readonly = toStringBool(self.descriptor.operations['NamedSetter'] is None)
|
readonly = toStringBool(self.descriptor.operations['NamedSetter'] is None)
|
||||||
fillDescriptor = "FillPropertyDescriptor(&mut *desc, proxy, %s);\nreturn 1;" % readonly
|
fillDescriptor = "FillPropertyDescriptor(&mut *desc, proxy, %s);\nreturn true;" % readonly
|
||||||
templateValues = {'jsvalRef': '(*desc).value', 'successCode': fillDescriptor}
|
templateValues = {'jsvalRef': '(*desc).value', 'successCode': fillDescriptor}
|
||||||
# Once we start supporting OverrideBuiltins we need to make
|
# Once we start supporting OverrideBuiltins we need to make
|
||||||
# ResolveOwnProperty or EnumerateOwnProperties filter out named
|
# ResolveOwnProperty or EnumerateOwnProperties filter out named
|
||||||
# properties that shadow prototype properties.
|
# properties that shadow prototype properties.
|
||||||
namedGet = ("\n" +
|
namedGet = ("\n" +
|
||||||
"if set == 0 && RUST_JSID_IS_STRING(id) != 0 && !HasPropertyOnPrototype(cx, proxy, id) {\n" +
|
"if !set && RUST_JSID_IS_STRING(id) != 0 && !HasPropertyOnPrototype(cx, proxy, id) {\n" +
|
||||||
" let name = jsid_to_str(cx, id);\n" +
|
" let name = jsid_to_str(cx, id);\n" +
|
||||||
" let this = UnwrapProxy(proxy);\n" +
|
" let this = UnwrapProxy(proxy);\n" +
|
||||||
" let this = JS::from_raw(this);\n" +
|
" let this = JS::from_raw(this);\n" +
|
||||||
|
@ -3624,19 +3624,19 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
||||||
return setOrIndexedGet + """let expando: *mut JSObject = GetExpandoObject(proxy);
|
return setOrIndexedGet + """let expando: *mut JSObject = GetExpandoObject(proxy);
|
||||||
//if (!xpc::WrapperFactory::IsXrayWrapper(proxy) && (expando = GetExpandoObject(proxy))) {
|
//if (!xpc::WrapperFactory::IsXrayWrapper(proxy) && (expando = GetExpandoObject(proxy))) {
|
||||||
if expando.is_not_null() {
|
if expando.is_not_null() {
|
||||||
let flags = if set != 0 { JSRESOLVE_ASSIGNING } else { 0 } | JSRESOLVE_QUALIFIED;
|
let flags = if set { JSRESOLVE_ASSIGNING } else { 0 } | JSRESOLVE_QUALIFIED;
|
||||||
if JS_GetPropertyDescriptorById(cx, expando, id, flags, desc) == 0 {
|
if JS_GetPropertyDescriptorById(cx, expando, id, flags, desc) == 0 {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
if (*desc).obj.is_not_null() {
|
if (*desc).obj.is_not_null() {
|
||||||
// Pretend the property lives on the wrapper.
|
// Pretend the property lives on the wrapper.
|
||||||
(*desc).obj = proxy;
|
(*desc).obj = proxy;
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
""" + namedGet + """
|
""" + namedGet + """
|
||||||
(*desc).obj = ptr::mut_null();
|
(*desc).obj = ptr::mut_null();
|
||||||
return 1;"""
|
return true;"""
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
return CGGeneric(self.getBody())
|
return CGGeneric(self.getBody())
|
||||||
|
@ -3646,7 +3646,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
||||||
args = [Argument('*mut JSContext', 'cx'), Argument('*mut JSObject', 'proxy'),
|
args = [Argument('*mut JSContext', 'cx'), Argument('*mut JSObject', 'proxy'),
|
||||||
Argument('jsid', 'id'),
|
Argument('jsid', 'id'),
|
||||||
Argument('*const JSPropertyDescriptor', 'desc')]
|
Argument('*const JSPropertyDescriptor', 'desc')]
|
||||||
CGAbstractExternMethod.__init__(self, descriptor, "defineProperty", "JSBool", args)
|
CGAbstractExternMethod.__init__(self, descriptor, "defineProperty", "bool", args)
|
||||||
self.descriptor = descriptor
|
self.descriptor = descriptor
|
||||||
def getBody(self):
|
def getBody(self):
|
||||||
set = ""
|
set = ""
|
||||||
|
@ -3662,11 +3662,11 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
||||||
" let this = JS::from_raw(this);\n" +
|
" let this = JS::from_raw(this);\n" +
|
||||||
" let this = this.root();\n" +
|
" let this = this.root();\n" +
|
||||||
CGIndenter(CGProxyIndexedSetter(self.descriptor)).define() +
|
CGIndenter(CGProxyIndexedSetter(self.descriptor)).define() +
|
||||||
" return 1;\n" +
|
" return true;\n" +
|
||||||
"}\n")
|
"}\n")
|
||||||
elif self.descriptor.operations['IndexedGetter']:
|
elif self.descriptor.operations['IndexedGetter']:
|
||||||
set += ("if GetArrayIndexFromId(cx, id).is_some() {\n" +
|
set += ("if GetArrayIndexFromId(cx, id).is_some() {\n" +
|
||||||
" return 0;\n" +
|
" return false;\n" +
|
||||||
" //return ThrowErrorMessage(cx, MSG_NO_PROPERTY_SETTER, \"%s\");\n" +
|
" //return ThrowErrorMessage(cx, MSG_NO_PROPERTY_SETTER, \"%s\");\n" +
|
||||||
"}\n") % self.descriptor.name
|
"}\n") % self.descriptor.name
|
||||||
|
|
||||||
|
@ -3689,10 +3689,10 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
||||||
" let this = this.root();\n" +
|
" let this = this.root();\n" +
|
||||||
CGIndenter(CGProxyNamedGetter(self.descriptor)).define() +
|
CGIndenter(CGProxyNamedGetter(self.descriptor)).define() +
|
||||||
" if (found) {\n"
|
" if (found) {\n"
|
||||||
" return 0;\n" +
|
" return false;\n" +
|
||||||
" //return ThrowErrorMessage(cx, MSG_NO_PROPERTY_SETTER, \"%s\");\n" +
|
" //return ThrowErrorMessage(cx, MSG_NO_PROPERTY_SETTER, \"%s\");\n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
" return 1;\n"
|
" return true;\n"
|
||||||
"}\n") % (self.descriptor.name)
|
"}\n") % (self.descriptor.name)
|
||||||
return set + """return proxyhandler::defineProperty_(%s);""" % ", ".join(a.name for a in self.args)
|
return set + """return proxyhandler::defineProperty_(%s);""" % ", ".join(a.name for a in self.args)
|
||||||
|
|
||||||
|
@ -3702,8 +3702,8 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
||||||
class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
|
class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
|
||||||
def __init__(self, descriptor):
|
def __init__(self, descriptor):
|
||||||
args = [Argument('*mut JSContext', 'cx'), Argument('*mut JSObject', 'proxy'),
|
args = [Argument('*mut JSContext', 'cx'), Argument('*mut JSObject', 'proxy'),
|
||||||
Argument('jsid', 'id'), Argument('*mut JSBool', 'bp')]
|
Argument('jsid', 'id'), Argument('*mut bool', 'bp')]
|
||||||
CGAbstractExternMethod.__init__(self, descriptor, "hasOwn", "JSBool", args)
|
CGAbstractExternMethod.__init__(self, descriptor, "hasOwn", "bool", args)
|
||||||
self.descriptor = descriptor
|
self.descriptor = descriptor
|
||||||
def getBody(self):
|
def getBody(self):
|
||||||
indexedGetter = self.descriptor.operations['IndexedGetter']
|
indexedGetter = self.descriptor.operations['IndexedGetter']
|
||||||
|
@ -3715,8 +3715,8 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
|
||||||
" let this = JS::from_raw(this);\n" +
|
" let this = JS::from_raw(this);\n" +
|
||||||
" let this = this.root();\n" +
|
" let this = this.root();\n" +
|
||||||
CGIndenter(CGProxyIndexedGetter(self.descriptor)).define() + "\n" +
|
CGIndenter(CGProxyIndexedGetter(self.descriptor)).define() + "\n" +
|
||||||
" *bp = found as JSBool;\n" +
|
" *bp = found;\n" +
|
||||||
" return 1;\n" +
|
" return true;\n" +
|
||||||
"}\n\n")
|
"}\n\n")
|
||||||
else:
|
else:
|
||||||
indexed = ""
|
indexed = ""
|
||||||
|
@ -3729,8 +3729,8 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
|
||||||
" let this = JS::from_raw(this);\n" +
|
" let this = JS::from_raw(this);\n" +
|
||||||
" let this = this.root();\n" +
|
" let this = this.root();\n" +
|
||||||
CGIndenter(CGProxyNamedGetter(self.descriptor)).define() + "\n" +
|
CGIndenter(CGProxyNamedGetter(self.descriptor)).define() + "\n" +
|
||||||
" *bp = found as JSBool;\n"
|
" *bp = found;\n"
|
||||||
" return 1;\n"
|
" return true;\n"
|
||||||
"}\n" +
|
"}\n" +
|
||||||
"\n")
|
"\n")
|
||||||
else:
|
else:
|
||||||
|
@ -3739,15 +3739,15 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
|
||||||
return indexed + """let expando: *mut JSObject = GetExpandoObject(proxy);
|
return indexed + """let expando: *mut JSObject = GetExpandoObject(proxy);
|
||||||
if expando.is_not_null() {
|
if expando.is_not_null() {
|
||||||
let mut b: JSBool = 1;
|
let mut b: JSBool = 1;
|
||||||
let ok: JSBool = JS_HasPropertyById(cx, expando, id, &mut b);
|
let ok = JS_HasPropertyById(cx, expando, id, &mut b) != 0;
|
||||||
*bp = !!b;
|
*bp = b != 0;
|
||||||
if ok == 0 || *bp != 0 {
|
if !ok || *bp {
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
""" + named + """*bp = 0;
|
""" + named + """*bp = false;
|
||||||
return 1;"""
|
return true;"""
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
return CGGeneric(self.getBody())
|
return CGGeneric(self.getBody())
|
||||||
|
@ -3757,22 +3757,25 @@ class CGDOMJSProxyHandler_get(CGAbstractExternMethod):
|
||||||
args = [Argument('*mut JSContext', 'cx'), Argument('*mut JSObject', 'proxy'),
|
args = [Argument('*mut JSContext', 'cx'), Argument('*mut JSObject', 'proxy'),
|
||||||
Argument('*mut JSObject', 'receiver'), Argument('jsid', 'id'),
|
Argument('*mut JSObject', 'receiver'), Argument('jsid', 'id'),
|
||||||
Argument('*mut JSVal', 'vp')]
|
Argument('*mut JSVal', 'vp')]
|
||||||
CGAbstractExternMethod.__init__(self, descriptor, "get", "JSBool", args)
|
CGAbstractExternMethod.__init__(self, descriptor, "get", "bool", args)
|
||||||
self.descriptor = descriptor
|
self.descriptor = descriptor
|
||||||
def getBody(self):
|
def getBody(self):
|
||||||
getFromExpando = """let expando = GetExpandoObject(proxy);
|
getFromExpando = """let expando = GetExpandoObject(proxy);
|
||||||
if expando.is_not_null() {
|
if expando.is_not_null() {
|
||||||
let mut hasProp = 0;
|
let mut hasProp = 0;
|
||||||
if JS_HasPropertyById(cx, expando, id, &mut hasProp) == 0 {
|
if JS_HasPropertyById(cx, expando, id, &mut hasProp) == 0 {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if hasProp != 0 {
|
if hasProp != 0 {
|
||||||
return JS_GetPropertyById(cx, expando, id, vp);
|
return JS_GetPropertyById(cx, expando, id, vp) != 0;
|
||||||
}
|
}
|
||||||
}"""
|
}"""
|
||||||
|
|
||||||
templateValues = {'jsvalRef': '*vp'}
|
templateValues = {
|
||||||
|
'jsvalRef': '*vp',
|
||||||
|
'successCode': 'return true;',
|
||||||
|
}
|
||||||
|
|
||||||
indexedGetter = self.descriptor.operations['IndexedGetter']
|
indexedGetter = self.descriptor.operations['IndexedGetter']
|
||||||
if indexedGetter:
|
if indexedGetter:
|
||||||
|
@ -3811,15 +3814,15 @@ if expando.is_not_null() {
|
||||||
%s
|
%s
|
||||||
let mut found = false;
|
let mut found = false;
|
||||||
if !GetPropertyOnPrototype(cx, proxy, id, &mut found, vp) {
|
if !GetPropertyOnPrototype(cx, proxy, id, &mut found, vp) {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if found {
|
if found {
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
%s
|
%s
|
||||||
*vp = UndefinedValue();
|
*vp = UndefinedValue();
|
||||||
return 1;""" % (getIndexedOrExpando, getNamed)
|
return true;""" % (getIndexedOrExpando, getNamed)
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
return CGGeneric(self.getBody())
|
return CGGeneric(self.getBody())
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
use dom::bindings::utils::is_dom_proxy;
|
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::{JS_DefinePropertyById, JS_NewObjectWithGivenProto};
|
||||||
use js::jsapi::{JS_ReportErrorFlagsAndNumber, JS_StrictPropertyStub};
|
use js::jsapi::{JS_ReportErrorFlagsAndNumber, JS_StrictPropertyStub};
|
||||||
use js::jsapi::{JSREPORT_WARNING, JSREPORT_STRICT, JSREPORT_STRICT_MODE_ERROR};
|
use js::jsapi::{JSREPORT_WARNING, JSREPORT_STRICT, JSREPORT_STRICT_MODE_ERROR};
|
||||||
use js::jsapi::JS_DeletePropertyById2;
|
use js::jsapi::JS_DeletePropertyById2;
|
||||||
|
@ -26,30 +26,32 @@ use std::mem::size_of;
|
||||||
|
|
||||||
static JSPROXYSLOT_EXPANDO: u32 = 0;
|
static JSPROXYSLOT_EXPANDO: u32 = 0;
|
||||||
|
|
||||||
pub extern fn getPropertyDescriptor(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
|
pub extern fn getPropertyDescriptor(cx: *mut JSContext, proxy: *mut JSObject,
|
||||||
set: libc::c_int, desc: *mut JSPropertyDescriptor) -> libc::c_int {
|
id: jsid, set: bool,
|
||||||
|
desc: *mut JSPropertyDescriptor)
|
||||||
|
-> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let handler = GetProxyHandler(proxy);
|
let handler = GetProxyHandler(proxy);
|
||||||
if InvokeGetOwnPropertyDescriptor(handler, cx, proxy, id, set, desc) == 0 {
|
if !InvokeGetOwnPropertyDescriptor(handler, cx, proxy, id, set, desc) {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
if (*desc).obj.is_not_null() {
|
if (*desc).obj.is_not_null() {
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//let proto = JS_GetPrototype(proxy);
|
//let proto = JS_GetPrototype(proxy);
|
||||||
let proto = GetObjectProto(proxy);
|
let proto = GetObjectProto(proxy);
|
||||||
if proto.is_null() {
|
if proto.is_null() {
|
||||||
(*desc).obj = ptr::mut_null();
|
(*desc).obj = ptr::mut_null();
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_GetPropertyDescriptorById(cx, proto, id, JSRESOLVE_QUALIFIED, mem::transmute(desc))
|
JS_GetPropertyDescriptorById(cx, proto, id, JSRESOLVE_QUALIFIED, desc) != 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn defineProperty_(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
|
pub fn defineProperty_(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
|
||||||
desc: *mut JSPropertyDescriptor) -> JSBool {
|
desc: *mut JSPropertyDescriptor) -> bool {
|
||||||
static JSMSG_GETTER_ONLY: libc::c_uint = 160;
|
static JSMSG_GETTER_ONLY: libc::c_uint = 160;
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -61,39 +63,39 @@ pub fn defineProperty_(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
|
||||||
JSREPORT_WARNING | JSREPORT_STRICT |
|
JSREPORT_WARNING | JSREPORT_STRICT |
|
||||||
JSREPORT_STRICT_MODE_ERROR,
|
JSREPORT_STRICT_MODE_ERROR,
|
||||||
Some(RUST_js_GetErrorMessage), ptr::mut_null(),
|
Some(RUST_js_GetErrorMessage), ptr::mut_null(),
|
||||||
JSMSG_GETTER_ONLY);
|
JSMSG_GETTER_ONLY) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
let expando = EnsureExpandoObject(cx, proxy);
|
let expando = EnsureExpandoObject(cx, proxy);
|
||||||
if expando.is_null() {
|
if expando.is_null() {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return JS_DefinePropertyById(cx, expando, id, (*desc).value, (*desc).getter,
|
return JS_DefinePropertyById(cx, expando, id, (*desc).value, (*desc).getter,
|
||||||
(*desc).setter, (*desc).attrs);
|
(*desc).setter, (*desc).attrs) != 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub extern fn defineProperty(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
|
pub extern fn defineProperty(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
|
||||||
desc: *mut JSPropertyDescriptor) -> JSBool {
|
desc: *mut JSPropertyDescriptor) -> bool {
|
||||||
defineProperty_(cx, proxy, id, desc)
|
defineProperty_(cx, proxy, id, desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub extern fn delete_(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
|
pub extern fn delete_(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
|
||||||
bp: *mut bool) -> JSBool {
|
bp: *mut bool) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let expando = EnsureExpandoObject(cx, proxy);
|
let expando = EnsureExpandoObject(cx, proxy);
|
||||||
if expando.is_null() {
|
if expando.is_null() {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut value = UndefinedValue();
|
let mut value = UndefinedValue();
|
||||||
if JS_DeletePropertyById2(cx, expando, id, &mut value) == 0 {
|
if JS_DeletePropertyById2(cx, expando, id, &mut value) == 0 {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*bp = value.to_boolean();
|
*bp = value.to_boolean();
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 33bcfb764e9ab2d8b065915764cd0223e43a3770
|
Subproject commit 4a360199a4e87427234339bc3c1362ab355dcde1
|
Loading…
Add table
Add a link
Reference in a new issue