mirror of
https://github.com/servo/servo.git
synced 2025-09-19 03:18:20 +01:00
Refactor the call
hook on non-callback interface objects (fixes #10744)
It's now set through the intermediate InterfaceConstructorBehavior structure, which lets us improve the abstraction around NonCallbackInterfaceObjectClass a bit better. When the interface's constructor is supposed to always throw, the error for calling `Foo()` without new is "Illegal constructor.". when the interface actually defines an interface, the error is instead "This constructor needs to be called with `new`.".
This commit is contained in:
parent
a45f117838
commit
4c2ca7a8c9
6 changed files with 64 additions and 47 deletions
|
@ -16,7 +16,6 @@ use dom::browsingcontext;
|
|||
use dom::window;
|
||||
use heapsize::HeapSizeOf;
|
||||
use js;
|
||||
use js::error::throw_type_error;
|
||||
use js::glue::{CallJitGetterOp, CallJitMethodOp, CallJitSetterOp, IsWrapper};
|
||||
use js::glue::{GetCrossCompartmentWrapper, WrapperNew};
|
||||
use js::glue::{RUST_FUNCTION_VALUE_TO_JITINFO, RUST_JSID_IS_INT, RUST_JSID_IS_STRING};
|
||||
|
@ -35,7 +34,7 @@ use js::jsval::{JSVal};
|
|||
use js::jsval::{PrivateValue, UndefinedValue};
|
||||
use js::rust::{GCMethods, ToString};
|
||||
use js::{JS_CALLEE};
|
||||
use libc::{self, c_uint};
|
||||
use libc;
|
||||
use std::default::Default;
|
||||
use std::ffi::CString;
|
||||
use std::os::raw::c_void;
|
||||
|
@ -123,16 +122,6 @@ pub fn get_proto_or_iface_array(global: *mut JSObject) -> *mut ProtoOrIfaceArray
|
|||
}
|
||||
}
|
||||
|
||||
/// A throwing constructor, for those interfaces that have neither
|
||||
/// `NoInterfaceObject` nor `Constructor`.
|
||||
pub unsafe extern "C" fn throwing_constructor(cx: *mut JSContext,
|
||||
_argc: c_uint,
|
||||
_vp: *mut JSVal)
|
||||
-> bool {
|
||||
throw_type_error(cx, "Illegal constructor.");
|
||||
false
|
||||
}
|
||||
|
||||
/// An array of *mut JSObject of size PROTO_OR_IFACE_LENGTH.
|
||||
pub type ProtoOrIfaceArray = [*mut JSObject; PROTO_OR_IFACE_LENGTH];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue