@@ -12,7 +12,7 @@ use crate::avm1::globals::glow_filter::GlowFilter;
1212use crate :: avm1:: globals:: gradient_filter:: GradientFilter ;
1313use crate :: avm1:: object:: NativeObject ;
1414use crate :: avm1:: property_decl:: { DeclContext , Declaration , SystemClass } ;
15- use crate :: avm1:: { Attribute , Object , Value } ;
15+ use crate :: avm1:: { Object , Value } ;
1616use crate :: context:: UpdateContext ;
1717use ruffle_macros:: istr;
1818use ruffle_render:: filters:: Filter ;
@@ -66,7 +66,7 @@ pub fn clone<'gc>(
6666 _ => return Ok ( Value :: Undefined ) ,
6767 } ;
6868 let proto = this. get_local_stored ( istr ! ( "__proto__" ) , activation) ;
69- Ok ( create_instance ( activation, native , proto ) . into ( ) )
69+ Ok ( Object :: new_with_native ( activation. strings ( ) , proto , native ) . into ( ) )
7070}
7171
7272pub fn avm1_to_filter < ' gc > (
@@ -149,26 +149,5 @@ pub fn filter_to_avm1<'gc>(activation: &mut Activation<'_, 'gc>, filter: Filter)
149149 )
150150 }
151151 } ;
152-
153- create_instance ( activation, native, Some ( proto. into ( ) ) ) . into ( )
154- }
155-
156- pub fn create_instance < ' gc > (
157- activation : & mut Activation < ' _ , ' gc > ,
158- native : NativeObject < ' gc > ,
159- proto : Option < Value < ' gc > > ,
160- ) -> Object < ' gc > {
161- let result = Object :: new ( activation. strings ( ) , None ) ;
162- // Set `__proto__` manually since `Object::new()` doesn't support primitive prototypes.
163- // TODO: Pass `proto` to `Object::new()` once possible.
164- if let Some ( proto) = proto {
165- result. define_value (
166- activation. gc ( ) ,
167- istr ! ( "__proto__" ) ,
168- proto,
169- Attribute :: DONT_ENUM | Attribute :: DONT_DELETE ,
170- ) ;
171- }
172- result. set_native ( activation. gc ( ) , native) ;
173- result
152+ Object :: new_with_native ( activation. strings ( ) , Some ( proto) , native) . into ( )
174153}
0 commit comments