Skip to content

Commit 17f090d

Browse files
adrian17relrelb
authored andcommitted
avm2: Stub Loader.contentLoaderInfo
1 parent 820196d commit 17f090d

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

core/src/avm2/globals/flash/display/loader.rs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! `flash.display.Loader` builtin/prototype
22
33
use crate::avm2::activation::Activation;
4-
use crate::avm2::class::Class;
5-
use crate::avm2::method::Method;
4+
use crate::avm2::class::{Class, ClassAttributes};
5+
use crate::avm2::method::{Method, NativeMethodImpl};
66
use crate::avm2::names::{Namespace, QName};
77
use crate::avm2::value::Value;
88
use crate::avm2::{Error, Object};
@@ -19,13 +19,27 @@ pub fn class_init<'gc>(
1919

2020
/// Implements `flash.display.Loader`'s instance constructor.
2121
pub fn instance_init<'gc>(
22-
_activation: &mut Activation<'_, 'gc, '_>,
23-
_this: Option<Object<'gc>>,
22+
activation: &mut Activation<'_, 'gc, '_>,
23+
this: Option<Object<'gc>>,
2424
_args: &[Value<'gc>],
2525
) -> Result<Value<'gc>, Error> {
26+
if let Some(this) = this {
27+
activation.super_init(this, &[])?;
28+
}
29+
2630
Ok(Value::Undefined)
2731
}
2832

33+
// TODO: this is entirely stubbed, just to get addEventListener to not crash
34+
fn content_loader_info<'gc>(
35+
_activation: &mut Activation<'_, 'gc, '_>,
36+
this: Option<Object<'gc>>,
37+
_args: &[Value<'gc>],
38+
) -> Result<Value<'gc>, Error> {
39+
log::warn!("Loader::contentLoaderInfo is a stub");
40+
Ok(this.unwrap().into())
41+
}
42+
2943
pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>> {
3044
let class = Class::new(
3145
QName::new(Namespace::package("flash.display"), "Loader"),
@@ -41,5 +55,16 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
4155
mc,
4256
);
4357

58+
let mut write = class.write(mc);
59+
60+
write.set_attributes(ClassAttributes::SEALED);
61+
62+
const PUBLIC_INSTANCE_PROPERTIES: &[(
63+
&str,
64+
Option<NativeMethodImpl>,
65+
Option<NativeMethodImpl>,
66+
)] = &[("contentLoaderInfo", Some(content_loader_info), None)];
67+
write.define_public_builtin_instance_properties(mc, PUBLIC_INSTANCE_PROPERTIES);
68+
4469
class
4570
}

0 commit comments

Comments
 (0)