11//! `flash.display.Loader` builtin/prototype
22
33use 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 } ;
66use crate :: avm2:: names:: { Namespace , QName } ;
77use crate :: avm2:: value:: Value ;
88use crate :: avm2:: { Error , Object } ;
@@ -19,13 +19,27 @@ pub fn class_init<'gc>(
1919
2020/// Implements `flash.display.Loader`'s instance constructor.
2121pub 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+
2943pub 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