use super::*;
#[derive(Clone, Debug, PartialEq, PartialOrd)]
#[repr(transparent)]
pub struct ErrorEvent {
inner: Event,
}
impl FromVal for ErrorEvent {
fn from_val(v: &Any) -> Self {
ErrorEvent {
inner: Event::from_val(v),
}
}
fn take_ownership(v: AnyHandle) -> Self {
Self::from_val(&Any::take_ownership(v))
}
fn as_handle(&self) -> AnyHandle {
self.inner.as_handle()
}
}
impl core::ops::Deref for ErrorEvent {
type Target = Event;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
impl core::ops::DerefMut for ErrorEvent {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<Any> for ErrorEvent {
fn as_ref(&self) -> &Any {
&self.inner
}
}
impl AsMut<Any> for ErrorEvent {
fn as_mut(&mut self) -> &mut Any {
&mut self.inner
}
}
impl From<ErrorEvent> for Any {
fn from(s: ErrorEvent) -> Any {
let handle = s.inner.as_handle();
core::mem::forget(s);
Any::take_ownership(handle)
}
}
impl From<&ErrorEvent> for Any {
fn from(s: &ErrorEvent) -> Any {
s.inner.clone().into()
}
}
jsbind::utils::impl_dyn_cast!(ErrorEvent);
impl ErrorEvent {
pub fn message(&self) -> JsString {
self.inner.get("message").as_::<JsString>()
}
}
impl ErrorEvent {
pub fn filename(&self) -> JsString {
self.inner.get("filename").as_::<JsString>()
}
}
impl ErrorEvent {
pub fn lineno(&self) -> u32 {
self.inner.get("lineno").as_::<u32>()
}
}
impl ErrorEvent {
pub fn colno(&self) -> u32 {
self.inner.get("colno").as_::<u32>()
}
}
impl ErrorEvent {
pub fn error(&self) -> Any {
self.inner.get("error").as_::<Any>()
}
}
impl ErrorEvent {
pub fn new(type_: &JsString) -> ErrorEvent {
Self {
inner: Any::global("ErrorEvent")
.new(&[type_.into()])
.as_::<Event>(),
}
}
}
impl ErrorEvent {
pub fn new_with_event_init_dict(
type_: &JsString,
event_init_dict: &ErrorEventInit,
) -> ErrorEvent {
Self {
inner: Any::global("ErrorEvent")
.new(&[type_.into(), event_init_dict.into()])
.as_::<Event>(),
}
}
}