From 06304a9ba14494699d5898e4500941d5efd602d5 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 26 Aug 2014 14:00:55 +0200 Subject: [PATCH] Use bool in the Rust definition of ProxyTraps. This matches the C++ definition. This also changes InvokeGetOwnPropertyDescriptor, since it is little more than an alias for the proxy trap. --- glue.rs | 38 ++++++++++++++++++-------------------- jsglue.cpp | 4 ++-- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/glue.rs b/glue.rs index 36b6f504a..81ccd30f3 100644 --- a/glue.rs +++ b/glue.rs @@ -9,39 +9,37 @@ use jsapi::*; use jsfriendapi::JSJitInfo; use jsval::JSVal; -pub type c_bool = libc::c_int; - pub static JS_STRUCTURED_CLONE_VERSION: u32 = 1; pub struct ProxyTraps { - pub getPropertyDescriptor: Option c_bool>, - pub getOwnPropertyDescriptor: Option JSBool>, - pub defineProperty: Option JSBool>, + pub getPropertyDescriptor: Option bool>, + pub getOwnPropertyDescriptor: Option bool>, + pub defineProperty: Option bool>, pub getOwnPropertyNames: *const u8, //XXX need a representation for AutoIdVector& - pub delete_: Option JSBool>, + pub delete_: Option bool>, pub enumerate: *const u8, //XXX need a representation for AutoIdVector& - pub has: Option JSBool>, - pub hasOwn: Option JSBool>, - pub get: Option JSBool>, - pub set: Option JSBool>, + pub has: Option bool>, + pub hasOwn: Option bool>, + pub get: Option bool>, + pub set: Option bool>, pub keys: *const u8, //XXX need a representation for AutoIdVector& - pub iterate: Option JSBool>, + pub iterate: Option bool>, - pub call: Option JSBool>, - pub construct: Option JSBool>, + pub call: Option bool>, + pub construct: Option bool>, pub nativeCall: *const u8, //XXX need a representation for IsAcceptableThis, NativeImpl, and CallArgs - pub hasInstance: Option JSBool>, + pub hasInstance: Option bool>, pub typeOf: Option uint>, //XXX JSType enum - pub objectClassIs: Option JSBool>, //XXX ESClassValue enum + pub objectClassIs: Option bool>, //XXX ESClassValue enum pub obj_toString: Option *mut JSString>, pub fun_toString: Option *mut JSString>, //regexp_toShared: *u8, - pub defaultValue: Option JSBool>, //XXX JSType enum - pub iteratorNext: Option JSBool>, + pub defaultValue: Option bool>, //XXX JSType enum + pub iteratorNext: Option bool>, pub finalize: Option, - pub getElementIfPresent: Option JSBool>, - pub getPrototypeOf: Option JSBool>, + pub getElementIfPresent: Option bool>, + pub getPrototypeOf: Option bool>, pub trace: Option, } @@ -107,7 +105,7 @@ pub fn js_IsFunctionProxyClass(obj: *mut JSObject) -> bool; pub fn IsProxyHandlerFamily(obj: *mut JSObject) -> bool; pub fn GetProxyHandlerExtra(obj: *mut JSObject) -> *const libc::c_void; pub fn GetProxyHandler(obj: *mut JSObject) -> *mut libc::c_void; -pub fn InvokeGetOwnPropertyDescriptor(handler: *mut libc::c_void, cx: *mut JSContext, proxy: *mut JSObject, id: jsid, set: JSBool, desc: *mut JSPropertyDescriptor) -> JSBool; +pub fn InvokeGetOwnPropertyDescriptor(handler: *mut libc::c_void, cx: *mut JSContext, proxy: *mut JSObject, id: jsid, set: bool, desc: *mut JSPropertyDescriptor) -> bool; pub fn GetGlobalForObjectCrossCompartment(obj: *mut JSObject) -> *mut JSObject; pub fn ReportError(cx: *mut JSContext, error: *const libc::c_char); pub fn IsWrapper(obj: *mut JSObject) -> JSBool; diff --git a/jsglue.cpp b/jsglue.cpp index a9f6763b1..0d8ce5773 100644 --- a/jsglue.cpp +++ b/jsglue.cpp @@ -330,11 +330,11 @@ class ForwardingProxyHandler : public js::BaseProxyHandler extern "C" { -JSBool +bool InvokeGetOwnPropertyDescriptor( void* handler, JSContext *cx, JSObject *proxy, - jsid id, JSBool set, + jsid id, bool set, JSPropertyDescriptor *desc) { return static_cast(handler)->getOwnPropertyDescriptor(cx, proxy,