Skip to content

Instantly share code, notes, and snippets.

@jdm
Created September 30, 2016 15:50
Show Gist options
  • Save jdm/4cf4904a4dbfe1626e3c13f0ab0899ea to your computer and use it in GitHub Desktop.
Save jdm/4cf4904a4dbfe1626e3c13f0ab0899ea to your computer and use it in GitHub Desktop.
/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */
#![allow(non_camel_case_types,non_upper_case_globals,unused_imports,unused_variables,unused_assignments)]
use core::nonzero::NonZero;
use dom;
use dom::bindings;
use dom::bindings::callback::CallSetup;
use dom::bindings::callback::CallbackContainer;
use dom::bindings::callback::CallbackFunction;
use dom::bindings::callback::CallbackInterface;
use dom::bindings::callback::ExceptionHandling;
use dom::bindings::callback::wrap_call_this_object;
use dom::bindings::codegen::InterfaceObjectMap;
use dom::bindings::codegen::PrototypeList;
use dom::bindings::codegen::RegisterBindings;
use dom::bindings::codegen::UnionTypes;
use dom::bindings::constant::ConstantSpec;
use dom::bindings::constant::ConstantVal;
use dom::bindings::conversions::ConversionBehavior;
use dom::bindings::conversions::ConversionResult;
use dom::bindings::conversions::DOM_OBJECT_SLOT;
use dom::bindings::conversions::FromJSValConvertible;
use dom::bindings::conversions::IDLInterface;
use dom::bindings::conversions::StringificationBehavior;
use dom::bindings::conversions::ToJSValConvertible;
use dom::bindings::conversions::is_array_like;
use dom::bindings::conversions::native_from_handlevalue;
use dom::bindings::conversions::native_from_object;
use dom::bindings::conversions::private_from_object;
use dom::bindings::conversions::root_from_handleobject;
use dom::bindings::conversions::root_from_handlevalue;
use dom::bindings::conversions::root_from_object;
use dom::bindings::conversions::string_jsid_to_string;
use dom::bindings::error::Error;
use dom::bindings::error::Error::JSFailed;
use dom::bindings::error::ErrorResult;
use dom::bindings::error::Fallible;
use dom::bindings::error::throw_dom_exception;
use dom::bindings::global::GlobalRef;
use dom::bindings::global::global_root_from_object;
use dom::bindings::global::global_root_from_object_maybe_wrapped;
use dom::bindings::global::global_root_from_reflector;
use dom::bindings::guard::Condition;
use dom::bindings::guard::Guard;
use dom::bindings::interface::ConstructorClassHook;
use dom::bindings::interface::InterfaceConstructorBehavior;
use dom::bindings::interface::NonCallbackInterfaceObjectClass;
use dom::bindings::interface::create_callback_interface_object;
use dom::bindings::interface::create_global_object;
use dom::bindings::interface::create_interface_prototype_object;
use dom::bindings::interface::create_named_constructors;
use dom::bindings::interface::create_noncallback_interface_object;
use dom::bindings::interface::define_guarded_constants;
use dom::bindings::interface::define_guarded_methods;
use dom::bindings::interface::define_guarded_properties;
use dom::bindings::interface::is_exposed_in;
use dom::bindings::iterable::Iterable;
use dom::bindings::iterable::IteratorType;
use dom::bindings::js::JS;
use dom::bindings::js::OptionalRootedReference;
use dom::bindings::js::Root;
use dom::bindings::js::RootedRcReference;
use dom::bindings::js::RootedReference;
use dom::bindings::mozmap::MozMap;
use dom::bindings::namespace::NamespaceObjectClass;
use dom::bindings::namespace::create_namespace_object;
use dom::bindings::num::Finite;
use dom::bindings::proxyhandler;
use dom::bindings::proxyhandler::ensure_expando_object;
use dom::bindings::proxyhandler::fill_property_descriptor;
use dom::bindings::proxyhandler::get_expando_object;
use dom::bindings::proxyhandler::get_property_descriptor;
use dom::bindings::reflector::MutReflectable;
use dom::bindings::reflector::Reflectable;
use dom::bindings::str::ByteString;
use dom::bindings::str::DOMString;
use dom::bindings::str::USVString;
use dom::bindings::trace::JSTraceable;
use dom::bindings::trace::RootedTraceable;
use dom::bindings::utils::DOMClass;
use dom::bindings::utils::DOMJSClass;
use dom::bindings::utils::DOM_PROTO_UNFORGEABLE_HOLDER_SLOT;
use dom::bindings::utils::JSCLASS_DOM_GLOBAL;
use dom::bindings::utils::ProtoOrIfaceArray;
use dom::bindings::utils::enumerate_global;
use dom::bindings::utils::finalize_global;
use dom::bindings::utils::find_enum_string_index;
use dom::bindings::utils::generic_getter;
use dom::bindings::utils::generic_lenient_getter;
use dom::bindings::utils::generic_lenient_setter;
use dom::bindings::utils::generic_method;
use dom::bindings::utils::generic_setter;
use dom::bindings::utils::get_array_index_from_id;
use dom::bindings::utils::get_dictionary_property;
use dom::bindings::utils::get_property_on_prototype;
use dom::bindings::utils::get_proto_or_iface_array;
use dom::bindings::utils::has_property_on_prototype;
use dom::bindings::utils::is_platform_object;
use dom::bindings::utils::resolve_global;
use dom::bindings::utils::set_dictionary_property;
use dom::bindings::utils::trace_global;
use dom::bindings::utils::wrap_panic;
use dom::bindings::weakref::DOM_WEAK_SLOT;
use dom::bindings::weakref::WeakBox;
use dom::bindings::weakref::WeakReferenceable;
use dom::browsingcontext::BrowsingContext;
use js;
use js::JSCLASS_GLOBAL_SLOT_COUNT;
use js::JSCLASS_IS_DOMJSCLASS;
use js::JSCLASS_IS_GLOBAL;
use js::JSCLASS_RESERVED_SLOTS_MASK;
use js::JS_CALLEE;
use js::error::throw_type_error;
use js::glue::AppendToAutoIdVector;
use js::glue::CallJitGetterOp;
use js::glue::CallJitMethodOp;
use js::glue::CallJitSetterOp;
use js::glue::CreateProxyHandler;
use js::glue::GetProxyPrivate;
use js::glue::NewProxyObject;
use js::glue::ProxyTraps;
use js::glue::RUST_JSID_IS_STRING;
use js::glue::RUST_SYMBOL_TO_JSID;
use js::glue::int_to_jsid;
use js::jsapi::AutoIdVector;
use js::jsapi::Call;
use js::jsapi::CallArgs;
use js::jsapi::CurrentGlobalOrNull;
use js::jsapi::FreeOp;
use js::jsapi::GetPropertyKeys;
use js::jsapi::GetWellKnownSymbol;
use js::jsapi::Handle;
use js::jsapi::HandleId;
use js::jsapi::HandleObject;
use js::jsapi::HandleValue;
use js::jsapi::HandleValueArray;
use js::jsapi::INTERNED_STRING_TO_JSID;
use js::jsapi::IsCallable;
use js::jsapi::JSAutoCompartment;
use js::jsapi::JSCLASS_RESERVED_SLOTS_SHIFT;
use js::jsapi::JSClass;
use js::jsapi::JSContext;
use js::jsapi::JSFreeOp;
use js::jsapi::JSFunctionSpec;
use js::jsapi::JSITER_HIDDEN;
use js::jsapi::JSITER_OWNONLY;
use js::jsapi::JSITER_SYMBOLS;
use js::jsapi::JSJitGetterCallArgs;
use js::jsapi::JSJitInfo;
use js::jsapi::JSJitInfo_AliasSet;
use js::jsapi::JSJitInfo_ArgType;
use js::jsapi::JSJitInfo_OpType;
use js::jsapi::JSJitMethodCallArgs;
use js::jsapi::JSJitSetterCallArgs;
use js::jsapi::JSNative;
use js::jsapi::JSNativeWrapper;
use js::jsapi::JSObject;
use js::jsapi::JSPROP_ENUMERATE;
use js::jsapi::JSPROP_PERMANENT;
use js::jsapi::JSPROP_READONLY;
use js::jsapi::JSPROP_SHARED;
use js::jsapi::JSPropertySpec;
use js::jsapi::JSString;
use js::jsapi::JSTracer;
use js::jsapi::JSType;
use js::jsapi::JSTypedMethodJitInfo;
use js::jsapi::JSValueType;
use js::jsapi::JS_AtomizeAndPinString;
use js::jsapi::JS_CallFunctionValue;
use js::jsapi::JS_CopyPropertiesFrom;
use js::jsapi::JS_DefineProperty;
use js::jsapi::JS_DefinePropertyById2;
use js::jsapi::JS_ForwardGetPropertyTo;
use js::jsapi::JS_GetClass;
use js::jsapi::JS_GetErrorPrototype;
use js::jsapi::JS_GetFunctionPrototype;
use js::jsapi::JS_GetGlobalForObject;
use js::jsapi::JS_GetIteratorPrototype;
use js::jsapi::JS_GetObjectPrototype;
use js::jsapi::JS_GetProperty;
use js::jsapi::JS_GetPropertyById;
use js::jsapi::JS_GetPropertyDescriptorById;
use js::jsapi::JS_GetReservedSlot;
use js::jsapi::JS_HasProperty;
use js::jsapi::JS_HasPropertyById;
use js::jsapi::JS_InitializePropertiesFromCompatibleNativeObject;
use js::jsapi::JS_NewObject;
use js::jsapi::JS_NewObjectWithGivenProto;
use js::jsapi::JS_NewObjectWithoutMetadata;
use js::jsapi::JS_SetImmutablePrototype;
use js::jsapi::JS_SetProperty;
use js::jsapi::JS_SetReservedSlot;
use js::jsapi::JS_SplicePrototype;
use js::jsapi::JS_WrapValue;
use js::jsapi::MutableHandle;
use js::jsapi::MutableHandleObject;
use js::jsapi::MutableHandleValue;
use js::jsapi::ObjectOpResult;
use js::jsapi::PropertyDescriptor;
use js::jsapi::RootedId;
use js::jsapi::RootedObject;
use js::jsapi::RootedString;
use js::jsapi::SymbolCode;
use js::jsapi::jsid;
use js::jsval::JSVal;
use js::jsval::NullValue;
use js::jsval::ObjectOrNullValue;
use js::jsval::ObjectValue;
use js::jsval::PrivateValue;
use js::jsval::UndefinedValue;
use js::rust::GCMethods;
use js::rust::define_methods;
use js::rust::define_properties;
use libc;
use mem::heap_size_of_raw_self_and_children;
use script_runtime::maybe_take_panic_result;
use std::borrow::ToOwned;
use std::cmp;
use std::default::Default;
use std::ffi::CString;
use std::mem;
use std::num;
use std::os;
use std::panic;
use std::ptr;
use std::rc;
use std::rc::Rc;
use std::str;
use util::prefs::PREFS;
pub use self::EventTargetBinding::{GetProtoObject, GetConstructorObject, DefineDOMInterface, EventTargetMethods};
pub mod EventTargetBinding {
#![allow(non_camel_case_types,non_upper_case_globals,unused_imports,unused_variables,unused_assignments)]
use core::nonzero::NonZero;
use dom;
use dom::bindings;
use dom::bindings::callback::CallSetup;
use dom::bindings::callback::CallbackContainer;
use dom::bindings::callback::CallbackFunction;
use dom::bindings::callback::CallbackInterface;
use dom::bindings::callback::ExceptionHandling;
use dom::bindings::callback::wrap_call_this_object;
use dom::bindings::codegen::Bindings::EventListenerBinding::EventListener;
use dom::bindings::codegen::InterfaceObjectMap;
use dom::bindings::codegen::PrototypeList;
use dom::bindings::codegen::RegisterBindings;
use dom::bindings::codegen::UnionTypes;
use dom::bindings::constant::ConstantSpec;
use dom::bindings::constant::ConstantVal;
use dom::bindings::conversions::ConversionBehavior;
use dom::bindings::conversions::ConversionResult;
use dom::bindings::conversions::DOM_OBJECT_SLOT;
use dom::bindings::conversions::FromJSValConvertible;
use dom::bindings::conversions::IDLInterface;
use dom::bindings::conversions::StringificationBehavior;
use dom::bindings::conversions::ToJSValConvertible;
use dom::bindings::conversions::is_array_like;
use dom::bindings::conversions::native_from_handlevalue;
use dom::bindings::conversions::native_from_object;
use dom::bindings::conversions::private_from_object;
use dom::bindings::conversions::root_from_handleobject;
use dom::bindings::conversions::root_from_handlevalue;
use dom::bindings::conversions::root_from_object;
use dom::bindings::conversions::string_jsid_to_string;
use dom::bindings::error::Error;
use dom::bindings::error::Error::JSFailed;
use dom::bindings::error::ErrorResult;
use dom::bindings::error::Fallible;
use dom::bindings::error::throw_dom_exception;
use dom::bindings::global::GlobalRef;
use dom::bindings::global::global_root_from_object;
use dom::bindings::global::global_root_from_object_maybe_wrapped;
use dom::bindings::global::global_root_from_reflector;
use dom::bindings::guard::Condition;
use dom::bindings::guard::Guard;
use dom::bindings::interface::ConstructorClassHook;
use dom::bindings::interface::InterfaceConstructorBehavior;
use dom::bindings::interface::NonCallbackInterfaceObjectClass;
use dom::bindings::interface::create_callback_interface_object;
use dom::bindings::interface::create_global_object;
use dom::bindings::interface::create_interface_prototype_object;
use dom::bindings::interface::create_named_constructors;
use dom::bindings::interface::create_noncallback_interface_object;
use dom::bindings::interface::define_guarded_constants;
use dom::bindings::interface::define_guarded_methods;
use dom::bindings::interface::define_guarded_properties;
use dom::bindings::interface::is_exposed_in;
use dom::bindings::iterable::Iterable;
use dom::bindings::iterable::IteratorType;
use dom::bindings::js::JS;
use dom::bindings::js::OptionalRootedReference;
use dom::bindings::js::Root;
use dom::bindings::js::RootedRcReference;
use dom::bindings::js::RootedReference;
use dom::bindings::mozmap::MozMap;
use dom::bindings::namespace::NamespaceObjectClass;
use dom::bindings::namespace::create_namespace_object;
use dom::bindings::num::Finite;
use dom::bindings::proxyhandler;
use dom::bindings::proxyhandler::ensure_expando_object;
use dom::bindings::proxyhandler::fill_property_descriptor;
use dom::bindings::proxyhandler::get_expando_object;
use dom::bindings::proxyhandler::get_property_descriptor;
use dom::bindings::reflector::MutReflectable;
use dom::bindings::reflector::Reflectable;
use dom::bindings::str::ByteString;
use dom::bindings::str::DOMString;
use dom::bindings::str::USVString;
use dom::bindings::trace::JSTraceable;
use dom::bindings::trace::RootedTraceable;
use dom::bindings::utils::DOMClass;
use dom::bindings::utils::DOMJSClass;
use dom::bindings::utils::DOM_PROTO_UNFORGEABLE_HOLDER_SLOT;
use dom::bindings::utils::JSCLASS_DOM_GLOBAL;
use dom::bindings::utils::ProtoOrIfaceArray;
use dom::bindings::utils::enumerate_global;
use dom::bindings::utils::finalize_global;
use dom::bindings::utils::find_enum_string_index;
use dom::bindings::utils::generic_getter;
use dom::bindings::utils::generic_lenient_getter;
use dom::bindings::utils::generic_lenient_setter;
use dom::bindings::utils::generic_method;
use dom::bindings::utils::generic_setter;
use dom::bindings::utils::get_array_index_from_id;
use dom::bindings::utils::get_dictionary_property;
use dom::bindings::utils::get_property_on_prototype;
use dom::bindings::utils::get_proto_or_iface_array;
use dom::bindings::utils::has_property_on_prototype;
use dom::bindings::utils::is_platform_object;
use dom::bindings::utils::resolve_global;
use dom::bindings::utils::set_dictionary_property;
use dom::bindings::utils::trace_global;
use dom::bindings::utils::wrap_panic;
use dom::bindings::weakref::DOM_WEAK_SLOT;
use dom::bindings::weakref::WeakBox;
use dom::bindings::weakref::WeakReferenceable;
use dom::browsingcontext::BrowsingContext;
use dom::types::Event;
use dom::types::EventTarget;
use js;
use js::JSCLASS_GLOBAL_SLOT_COUNT;
use js::JSCLASS_IS_DOMJSCLASS;
use js::JSCLASS_IS_GLOBAL;
use js::JSCLASS_RESERVED_SLOTS_MASK;
use js::JS_CALLEE;
use js::error::throw_type_error;
use js::glue::AppendToAutoIdVector;
use js::glue::CallJitGetterOp;
use js::glue::CallJitMethodOp;
use js::glue::CallJitSetterOp;
use js::glue::CreateProxyHandler;
use js::glue::GetProxyPrivate;
use js::glue::NewProxyObject;
use js::glue::ProxyTraps;
use js::glue::RUST_JSID_IS_STRING;
use js::glue::RUST_SYMBOL_TO_JSID;
use js::glue::int_to_jsid;
use js::jsapi::AutoIdVector;
use js::jsapi::Call;
use js::jsapi::CallArgs;
use js::jsapi::CurrentGlobalOrNull;
use js::jsapi::FreeOp;
use js::jsapi::GetPropertyKeys;
use js::jsapi::GetWellKnownSymbol;
use js::jsapi::Handle;
use js::jsapi::HandleId;
use js::jsapi::HandleObject;
use js::jsapi::HandleValue;
use js::jsapi::HandleValueArray;
use js::jsapi::INTERNED_STRING_TO_JSID;
use js::jsapi::IsCallable;
use js::jsapi::JSAutoCompartment;
use js::jsapi::JSCLASS_RESERVED_SLOTS_SHIFT;
use js::jsapi::JSClass;
use js::jsapi::JSContext;
use js::jsapi::JSFreeOp;
use js::jsapi::JSFunctionSpec;
use js::jsapi::JSITER_HIDDEN;
use js::jsapi::JSITER_OWNONLY;
use js::jsapi::JSITER_SYMBOLS;
use js::jsapi::JSJitGetterCallArgs;
use js::jsapi::JSJitInfo;
use js::jsapi::JSJitInfo_AliasSet;
use js::jsapi::JSJitInfo_ArgType;
use js::jsapi::JSJitInfo_OpType;
use js::jsapi::JSJitMethodCallArgs;
use js::jsapi::JSJitSetterCallArgs;
use js::jsapi::JSNative;
use js::jsapi::JSNativeWrapper;
use js::jsapi::JSObject;
use js::jsapi::JSPROP_ENUMERATE;
use js::jsapi::JSPROP_PERMANENT;
use js::jsapi::JSPROP_READONLY;
use js::jsapi::JSPROP_SHARED;
use js::jsapi::JSPropertySpec;
use js::jsapi::JSString;
use js::jsapi::JSTracer;
use js::jsapi::JSType;
use js::jsapi::JSTypedMethodJitInfo;
use js::jsapi::JSValueType;
use js::jsapi::JS_AtomizeAndPinString;
use js::jsapi::JS_CallFunctionValue;
use js::jsapi::JS_CopyPropertiesFrom;
use js::jsapi::JS_DefineProperty;
use js::jsapi::JS_DefinePropertyById2;
use js::jsapi::JS_ForwardGetPropertyTo;
use js::jsapi::JS_GetClass;
use js::jsapi::JS_GetErrorPrototype;
use js::jsapi::JS_GetFunctionPrototype;
use js::jsapi::JS_GetGlobalForObject;
use js::jsapi::JS_GetIteratorPrototype;
use js::jsapi::JS_GetObjectPrototype;
use js::jsapi::JS_GetProperty;
use js::jsapi::JS_GetPropertyById;
use js::jsapi::JS_GetPropertyDescriptorById;
use js::jsapi::JS_GetReservedSlot;
use js::jsapi::JS_HasProperty;
use js::jsapi::JS_HasPropertyById;
use js::jsapi::JS_InitializePropertiesFromCompatibleNativeObject;
use js::jsapi::JS_NewObject;
use js::jsapi::JS_NewObjectWithGivenProto;
use js::jsapi::JS_NewObjectWithoutMetadata;
use js::jsapi::JS_SetImmutablePrototype;
use js::jsapi::JS_SetProperty;
use js::jsapi::JS_SetReservedSlot;
use js::jsapi::JS_SplicePrototype;
use js::jsapi::JS_WrapValue;
use js::jsapi::MutableHandle;
use js::jsapi::MutableHandleObject;
use js::jsapi::MutableHandleValue;
use js::jsapi::ObjectOpResult;
use js::jsapi::PropertyDescriptor;
use js::jsapi::RootedId;
use js::jsapi::RootedObject;
use js::jsapi::RootedString;
use js::jsapi::SymbolCode;
use js::jsapi::jsid;
use js::jsval::JSVal;
use js::jsval::NullValue;
use js::jsval::ObjectOrNullValue;
use js::jsval::ObjectValue;
use js::jsval::PrivateValue;
use js::jsval::UndefinedValue;
use js::rust::GCMethods;
use js::rust::define_methods;
use js::rust::define_properties;
use libc;
use mem::heap_size_of_raw_self_and_children;
use script_runtime::maybe_take_panic_result;
use std::borrow::ToOwned;
use std::cmp;
use std::default::Default;
use std::ffi::CString;
use std::mem;
use std::num;
use std::os;
use std::panic;
use std::ptr;
use std::rc;
use std::rc::Rc;
use std::str;
use util::prefs::PREFS;
pub fn GetProtoObject(cx: *mut JSContext, global: HandleObject, rval: MutableHandleObject) {
unsafe {
/* Get the interface prototype object for this class. This will create the
object as needed. */
assert!(((*JS_GetClass(global.get())).flags & JSCLASS_DOM_GLOBAL) != 0);
/* Check to see whether the interface objects are already installed */
let proto_or_iface_array = get_proto_or_iface_array(global.get());
rval.set((*proto_or_iface_array)[PrototypeList::ID::EventTarget as usize]);
if !rval.get().is_null() {
return;
}
CreateInterfaceObjects(cx, global, proto_or_iface_array);
rval.set((*proto_or_iface_array)[PrototypeList::ID::EventTarget as usize]);
assert!(!rval.get().is_null());
}
}
pub fn GetConstructorObject(cx: *mut JSContext, global: HandleObject, rval: MutableHandleObject) {
unsafe {
/* Get the interface object for this class. This will create the object as
needed. */
assert!(((*JS_GetClass(global.get())).flags & JSCLASS_DOM_GLOBAL) != 0);
/* Check to see whether the interface objects are already installed */
let proto_or_iface_array = get_proto_or_iface_array(global.get());
rval.set((*proto_or_iface_array)[PrototypeList::Constructor::EventTarget as usize]);
if !rval.get().is_null() {
return;
}
CreateInterfaceObjects(cx, global, proto_or_iface_array);
rval.set((*proto_or_iface_array)[PrototypeList::Constructor::EventTarget as usize]);
assert!(!rval.get().is_null());
}
}
unsafe extern fn addEventListener(cx: *mut JSContext, _obj: HandleObject, this: *const EventTarget, args: *const JSJitMethodCallArgs) -> bool {
return wrap_panic(|| {
let this = &*this;
let args = &*args;
let argc = args._base.argc_;
if argc < 2 {
throw_type_error(cx, "Not enough arguments to \"EventTarget.addEventListener\".");
return false;
}
let arg0: DOMString = match FromJSValConvertible::from_jsval(cx, args.get(0), StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(cx, &error);
return false;
}
_ => { return false;
},
};
let arg1: Option<Rc<dom::bindings::codegen::Bindings::EventListenerBinding::EventListener>> = if args.get(1).get().is_object() {
Some(dom::bindings::codegen::Bindings::EventListenerBinding::EventListener::new(args.get(1).get().to_object()))
} else if args.get(1).get().is_null_or_undefined() {
None
} else {
throw_type_error(cx, "Value is not an object.");
return false;
};
let arg2: bool = if args.get(2).is_undefined() {
false
} else {
match FromJSValConvertible::from_jsval(cx, args.get(2), ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(cx, &error);
return false;
}
_ => { return false;
}
}
};
let result: () = this.AddEventListener(arg0, arg1, arg2);
(result).to_jsval(cx, args.rval());
return true;}, false);
}
const addEventListener_methodinfo: JSJitInfo = JSJitInfo {
call: addEventListener as *const os::raw::c_void,
protoID: PrototypeList::ID::EventTarget as u16,
depth: 0,
_bitfield_1:
JSJitInfo::new_bitfield_1(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNDEFINED as u8,
false,
false,
false,
false,
false,
false,
0 as u16,
)
};
unsafe extern fn removeEventListener(cx: *mut JSContext, _obj: HandleObject, this: *const EventTarget, args: *const JSJitMethodCallArgs) -> bool {
return wrap_panic(|| {
let this = &*this;
let args = &*args;
let argc = args._base.argc_;
if argc < 2 {
throw_type_error(cx, "Not enough arguments to \"EventTarget.removeEventListener\".");
return false;
}
let arg0: DOMString = match FromJSValConvertible::from_jsval(cx, args.get(0), StringificationBehavior::Default) {
Ok(ConversionResult::Success(strval)) => strval,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(cx, &error);
return false;
}
_ => { return false;
},
};
let arg1: Option<Rc<dom::bindings::codegen::Bindings::EventListenerBinding::EventListener>> = if args.get(1).get().is_object() {
Some(dom::bindings::codegen::Bindings::EventListenerBinding::EventListener::new(args.get(1).get().to_object()))
} else if args.get(1).get().is_null_or_undefined() {
None
} else {
throw_type_error(cx, "Value is not an object.");
return false;
};
let arg2: bool = if args.get(2).is_undefined() {
false
} else {
match FromJSValConvertible::from_jsval(cx, args.get(2), ()) {
Ok(ConversionResult::Success(v)) => v,
Ok(ConversionResult::Failure(error)) => {
throw_type_error(cx, &error);
return false;
}
_ => { return false;
}
}
};
let result: () = this.RemoveEventListener(arg0, arg1, arg2);
(result).to_jsval(cx, args.rval());
return true;}, false);
}
const removeEventListener_methodinfo: JSJitInfo = JSJitInfo {
call: removeEventListener as *const os::raw::c_void,
protoID: PrototypeList::ID::EventTarget as u16,
depth: 0,
_bitfield_1:
JSJitInfo::new_bitfield_1(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_UNDEFINED as u8,
false,
false,
false,
false,
false,
false,
0 as u16,
)
};
unsafe extern fn dispatchEvent(cx: *mut JSContext, _obj: HandleObject, this: *const EventTarget, args: *const JSJitMethodCallArgs) -> bool {
return wrap_panic(|| {
let this = &*this;
let args = &*args;
let argc = args._base.argc_;
if argc < 1 {
throw_type_error(cx, "Not enough arguments to \"EventTarget.dispatchEvent\".");
return false;
}
let arg0: Root<Event> = if args.get(0).get().is_object() {
match root_from_handlevalue(args.get(0)) {
Ok(val) => val,
Err(()) => {
throw_type_error(cx, "value does not implement interface Event.");
return false;
}
}
} else {
throw_type_error(cx, "Value is not an object.");
return false;
};
let result: Result<bool, Error> = this.DispatchEvent(arg0.r());
let result = match result {
Ok(result) => result,
Err(e) => {
let global = global_root_from_reflector(this);
throw_dom_exception(cx, global.r(), e);
return false;
},
};
(result).to_jsval(cx, args.rval());
return true;}, false);
}
const dispatchEvent_methodinfo: JSJitInfo = JSJitInfo {
call: dispatchEvent as *const os::raw::c_void,
protoID: PrototypeList::ID::EventTarget as u16,
depth: 0,
_bitfield_1:
JSJitInfo::new_bitfield_1(
JSJitInfo_OpType::Method as u8,
JSJitInfo_AliasSet::AliasEverything as u8,
JSValueType::JSVAL_TYPE_BOOLEAN as u8,
false,
false,
false,
false,
false,
false,
0 as u16,
)
};
static INTERFACE_OBJECT_CLASS: NonCallbackInterfaceObjectClass =
NonCallbackInterfaceObjectClass::new(
&InterfaceConstructorBehavior::throw(),
b"function EventTarget() {\n [native code]\n}",
PrototypeList::ID::EventTarget,
0);
static PrototypeClass: JSClass = JSClass {
name: b"EventTargetPrototype\0" as *const u8 as *const libc::c_char,
flags:
// JSCLASS_HAS_RESERVED_SLOTS(0)
(0 & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT,
cOps: 0 as *const _,
reserved: [0 as *mut os::raw::c_void; 3]
};
pub unsafe fn DefineDOMInterface(cx: *mut JSContext, global: HandleObject) {
assert!(!global.get().is_null());
if !ConstructorEnabled(cx, global) {
return;
}
rooted!(in(cx) let mut proto = ptr::null_mut());
GetProtoObject(cx, global, proto.handle_mut());
assert!(!proto.is_null());
}
unsafe fn ConstructorEnabled(aCx: *mut JSContext, aObj: HandleObject) -> bool {
is_exposed_in(aObj, InterfaceObjectMap::DEDICATED_WORKER_GLOBAL_SCOPE | InterfaceObjectMap::SERVICE_WORKER_GLOBAL_SCOPE | InterfaceObjectMap::WINDOW)
}
impl IDLInterface for EventTarget {
#[inline]
fn derives(class: &'static DOMClass) -> bool {
class.interface_chain[0] == PrototypeList::ID::EventTarget
}
}
impl PartialEq for EventTarget {
fn eq(&self, other: &EventTarget) -> bool {
self as *const EventTarget == &*other
}
}
pub trait EventTargetMethods {
fn AddEventListener(&self, type_: DOMString, listener: Option<Rc<dom::bindings::codegen::Bindings::EventListenerBinding::EventListener>>, capture: bool) -> ();
fn RemoveEventListener(&self, type_: DOMString, listener: Option<Rc<dom::bindings::codegen::Bindings::EventListenerBinding::EventListener>>, capture: bool) -> ();
fn DispatchEvent(&self, event: &Event) -> Fallible<bool>;
}
const sMethods_specs: &'static [&'static[JSFunctionSpec]] = &[
&[
JSFunctionSpec {
name: b"addEventListener\0" as *const u8 as *const libc::c_char,
call: JSNativeWrapper { op: Some(generic_method), info: &addEventListener_methodinfo as *const _ as *const JSJitInfo },
nargs: 2,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: b"removeEventListener\0" as *const u8 as *const libc::c_char,
call: JSNativeWrapper { op: Some(generic_method), info: &removeEventListener_methodinfo as *const _ as *const JSJitInfo },
nargs: 2,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: b"dispatchEvent\0" as *const u8 as *const libc::c_char,
call: JSNativeWrapper { op: Some(generic_method), info: &dispatchEvent_methodinfo as *const _ as *const JSJitInfo },
nargs: 1,
flags: (JSPROP_ENUMERATE) as u16,
selfHostedName: 0 as *const libc::c_char
},
JSFunctionSpec {
name: 0 as *const libc::c_char,
call: JSNativeWrapper { op: None, info: 0 as *const JSJitInfo },
nargs: 0,
flags: 0,
selfHostedName: 0 as *const libc::c_char
}]
];
const sMethods: &'static [Guard<&'static [JSFunctionSpec]>] = &[
Guard::new(Condition::Satisfied, sMethods_specs[0])
];
fn CreateInterfaceObjects(cx: *mut JSContext, global: HandleObject, cache: *mut ProtoOrIfaceArray) {
unsafe {
rooted!(in(cx) let mut prototype_proto = ptr::null_mut());
prototype_proto.set(JS_GetObjectPrototype(cx, global));
assert!(!prototype_proto.is_null());
rooted!(in(cx) let mut prototype = ptr::null_mut());
create_interface_prototype_object(cx,
prototype_proto.handle(),
&PrototypeClass,
sMethods,
&[],
&[],
&[],
prototype.handle_mut());
assert!(!prototype.is_null());
assert!((*cache)[PrototypeList::ID::EventTarget as usize].is_null());
(*cache)[PrototypeList::ID::EventTarget as usize] = prototype.get();
<*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::ID::EventTarget as isize),
ptr::null_mut(),
prototype.get());
rooted!(in(cx) let interface_proto = JS_GetFunctionPrototype(cx, global));
assert!(!interface_proto.is_null());
rooted!(in(cx) let mut interface = ptr::null_mut());
create_noncallback_interface_object(cx,
global,
interface_proto.handle(),
&INTERFACE_OBJECT_CLASS,
&[],
&[],
&[],
prototype.handle(),
b"EventTarget\0",
0,
interface.handle_mut());
assert!(!interface.is_null());
assert!((*cache)[PrototypeList::Constructor::EventTarget as usize].is_null());
(*cache)[PrototypeList::Constructor::EventTarget as usize] = interface.get();
<*mut JSObject>::post_barrier((*cache).as_mut_ptr().offset(PrototypeList::Constructor::EventTarget as isize),
ptr::null_mut(),
interface.get());
}
}
} // mod EventTargetBinding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment