Skip to content

Commit

Permalink
Auto merge of #8195 - Ms2ger:update-js, r=jdm
Browse files Browse the repository at this point in the history
Update js.



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8195)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Oct 25, 2015
2 parents 41df37c + 54d3462 commit 1982ae3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 43 deletions.
58 changes: 18 additions & 40 deletions components/script/dom/bindings/utils.rs
Expand Up @@ -28,7 +28,6 @@ use js::jsapi::JS_GetFunctionObject;
use js::jsapi::JS_IsExceptionPending;
use js::jsapi::JS_NewObjectWithUniqueType;
use js::jsapi::JS_ObjectToOuterObject;
use js::jsapi::PropertyDefinitionBehavior;
use js::jsapi::{CallArgs, GetGlobalForObjectCrossCompartment, JSJitInfo};
use js::jsapi::{CompartmentOptions, OnNewGlobalHookOption};
use js::jsapi::{DOMCallbacks, JSWrapObjectCallbacks};
Expand All @@ -38,16 +37,15 @@ use js::jsapi::{JSClass, JSContext, JSObject, JSTracer};
use js::jsapi::{JSFunctionSpec, JSPropertySpec};
use js::jsapi::{JSTraceOp, JS_AlreadyHasOwnProperty, JS_NewFunction};
use js::jsapi::{JSVersion, JS_FireOnNewGlobalObject};
use js::jsapi::{JS_DefineFunctions, JS_DefineProperty, JS_DefineProperty1};
use js::jsapi::{JS_DefineProperties, JS_ForwardGetPropertyTo};
use js::jsapi::{JS_DefineProperty, JS_DefineProperty1, JS_ForwardGetPropertyTo};
use js::jsapi::{JS_GetClass, JS_LinkConstructorAndPrototype};
use js::jsapi::{JS_GetProperty, JS_HasProperty, JS_SetProperty};
use js::jsapi::{JS_GetPrototype, JS_HasPropertyById};
use js::jsapi::{JS_GetReservedSlot, JS_SetReservedSlot};
use js::jsapi::{JS_InitStandardClasses, JS_NewGlobalObject};
use js::jsval::{BooleanValue, DoubleValue, Int32Value, JSVal, NullValue};
use js::jsval::{PrivateValue, UInt32Value, UndefinedValue};
use js::rust::{GCMethods, ToString};
use js::rust::{GCMethods, ToString, define_methods, define_properties};
use js::{JSFUN_CONSTRUCTOR, JSPROP_ENUMERATE, JS_CALLEE};
use js::{JSPROP_PERMANENT, JSPROP_READONLY};
use libc::{self, c_uint};
Expand Down Expand Up @@ -305,28 +303,28 @@ fn create_interface_object(cx: *mut JSContext,
ctor_nargs: u32, proto: HandleObject,
members: &'static NativeProperties,
name: *const libc::c_char) {
let constructor = RootedObject::new(cx, create_constructor(cx, constructor_native, ctor_nargs, name));
assert!(!constructor.ptr.is_null());
unsafe {
let constructor = RootedObject::new(cx, create_constructor(cx, constructor_native, ctor_nargs, name));
assert!(!constructor.ptr.is_null());

if let Some(static_methods) = members.static_methods {
define_methods(cx, constructor.handle(), static_methods);
}
if let Some(static_methods) = members.static_methods {
define_methods(cx, constructor.handle(), static_methods).unwrap();
}

if let Some(static_properties) = members.static_attrs {
define_properties(cx, constructor.handle(), static_properties);
}
if let Some(static_properties) = members.static_attrs {
define_properties(cx, constructor.handle(), static_properties).unwrap();
}

if let Some(constants) = members.consts {
define_constants(cx, constructor.handle(), constants);
}
if let Some(constants) = members.consts {
define_constants(cx, constructor.handle(), constants);
}

unsafe {
if !proto.get().is_null() {
assert!(JS_LinkConstructorAndPrototype(cx, constructor.handle(), proto));
}
}

define_constructor(cx, receiver, name, constructor.handle());
define_constructor(cx, receiver, name, constructor.handle());
}
}

/// Defines constants on `obj`.
Expand All @@ -344,26 +342,6 @@ fn define_constants(cx: *mut JSContext, obj: HandleObject,
}
}

/// Defines methods on `obj`. The last entry of `methods` must contain zeroed
/// memory.
/// Fails on JSAPI failure.
fn define_methods(cx: *mut JSContext, obj: HandleObject,
methods: &'static [JSFunctionSpec]) {
unsafe {
assert!(JS_DefineFunctions(cx, obj, methods.as_ptr(), PropertyDefinitionBehavior::DefineAllProperties));
}
}

/// Defines attributes on `obj`. The last entry of `properties` must contain
/// zeroed memory.
/// Fails on JSAPI failure.
fn define_properties(cx: *mut JSContext, obj: HandleObject,
properties: &'static [JSPropertySpec]) {
unsafe {
assert!(JS_DefineProperties(cx, obj, properties.as_ptr()));
}
}

/// Creates the *interface prototype object*.
/// Fails on JSAPI failure.
fn create_interface_prototype_object(cx: *mut JSContext, global: HandleObject,
Expand All @@ -375,11 +353,11 @@ fn create_interface_prototype_object(cx: *mut JSContext, global: HandleObject,
assert!(!rval.get().is_null());

if let Some(methods) = members.methods {
define_methods(cx, rval.handle(), methods);
define_methods(cx, rval.handle(), methods).unwrap();
}

if let Some(properties) = members.attrs {
define_properties(cx, rval.handle(), properties);
define_properties(cx, rval.handle(), properties).unwrap();
}

if let Some(constants) = members.consts {
Expand Down
2 changes: 1 addition & 1 deletion components/servo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ports/cef/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ports/gonk/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1982ae3

Please sign in to comment.