2020-02-05 18:52:11 +00:00
|
|
|
//! AVM2 objects.
|
|
|
|
|
2020-02-06 04:15:03 +00:00
|
|
|
use crate::avm2::function::FunctionObject;
|
2020-02-05 18:52:11 +00:00
|
|
|
use crate::avm2::names::QName;
|
2020-02-06 04:15:03 +00:00
|
|
|
use crate::avm2::return_value::ReturnValue;
|
2020-02-05 18:52:11 +00:00
|
|
|
use crate::avm2::script_object::ScriptObject;
|
|
|
|
use crate::avm2::value::Value;
|
2020-02-06 04:15:03 +00:00
|
|
|
use crate::avm2::{Avm2, Error};
|
|
|
|
use crate::context::UpdateContext;
|
2020-02-05 18:52:11 +00:00
|
|
|
use gc_arena::Collect;
|
|
|
|
use ruffle_macros::enum_trait_object;
|
|
|
|
use std::fmt::Debug;
|
|
|
|
|
|
|
|
/// Represents an object that can be directly interacted with by the AVM2
|
|
|
|
/// runtime.
|
|
|
|
#[enum_trait_object(
|
|
|
|
#[derive(Clone, Collect, Debug, Copy)]
|
|
|
|
#[collect(no_drop)]
|
|
|
|
pub enum Object<'gc> {
|
2020-02-06 04:15:03 +00:00
|
|
|
ScriptObject(ScriptObject<'gc>),
|
|
|
|
FunctionObject(FunctionObject<'gc>)
|
2020-02-05 18:52:11 +00:00
|
|
|
}
|
|
|
|
)]
|
|
|
|
pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy {
|
|
|
|
/// Retrieve a property by it's QName.
|
2020-02-06 04:15:03 +00:00
|
|
|
fn get_property(
|
|
|
|
self,
|
|
|
|
_name: &QName,
|
|
|
|
_avm: &mut Avm2<'gc>,
|
|
|
|
_context: &mut UpdateContext<'_, 'gc, '_>,
|
|
|
|
) -> Result<ReturnValue<'gc>, Error> {
|
|
|
|
Ok(Value::Undefined.into())
|
2020-02-05 18:52:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Set a property by it's QName.
|
2020-02-06 04:15:03 +00:00
|
|
|
fn set_property(
|
|
|
|
self,
|
|
|
|
_name: &QName,
|
|
|
|
_value: Value<'gc>,
|
|
|
|
_avm: &mut Avm2<'gc>,
|
|
|
|
_context: &mut UpdateContext<'_, 'gc, '_>,
|
|
|
|
) -> Result<(), Error> {
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Get a raw pointer value for this object.
|
|
|
|
fn as_ptr(&self) -> *const ObjectPtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub enum ObjectPtr {}
|
|
|
|
|
|
|
|
impl<'gc> Object<'gc> {
|
|
|
|
pub fn ptr_eq(a: Object<'gc>, b: Object<'gc>) -> bool {
|
|
|
|
a.as_ptr() == b.as_ptr()
|
|
|
|
}
|
2020-02-05 18:52:11 +00:00
|
|
|
}
|