1
1
//! Class object impl
2
2
3
3
use crate :: avm2:: activation:: Activation ;
4
- use crate :: avm2:: class:: { Allocator , AllocatorFn , Class , ClassHashWrapper } ;
4
+ use crate :: avm2:: class:: { Allocator , AllocatorFn , Class } ;
5
5
use crate :: avm2:: error:: { argument_error, make_error_1127, reference_error, type_error} ;
6
6
use crate :: avm2:: function:: exec;
7
7
use crate :: avm2:: method:: Method ;
@@ -20,7 +20,6 @@ use crate::string::AvmString;
20
20
use fnv:: FnvHashMap ;
21
21
use gc_arena:: { Collect , GcCell , GcWeakCell , Mutation } ;
22
22
use std:: cell:: { BorrowError , Ref , RefMut } ;
23
- use std:: collections:: HashSet ;
24
23
use std:: fmt:: Debug ;
25
24
use std:: hash:: { Hash , Hasher } ;
26
25
@@ -82,12 +81,6 @@ pub struct ClassObjectData<'gc> {
82
81
/// we get a param of `null`.
83
82
applications : FnvHashMap < Option < Class < ' gc > > , ClassObject < ' gc > > ,
84
83
85
- /// Interfaces implemented by this class, including interfaces
86
- /// from parent classes and superinterfaces (recursively).
87
- /// TODO - avoid cloning this when a subclass implements the
88
- /// same interface as its superclass.
89
- interfaces : Vec < Class < ' gc > > ,
90
-
91
84
/// VTable used for instances of this class.
92
85
instance_vtable : VTable < ' gc > ,
93
86
@@ -205,7 +198,6 @@ impl<'gc> ClassObject<'gc> {
205
198
native_constructor : class. native_instance_init ( ) ,
206
199
call_handler : class. call_handler ( ) ,
207
200
applications : Default :: default ( ) ,
208
- interfaces : Vec :: new ( ) ,
209
201
instance_vtable : VTable :: empty ( activation. context . gc_context ) ,
210
202
class_vtable : VTable :: empty ( activation. context . gc_context ) ,
211
203
} ,
@@ -318,43 +310,13 @@ impl<'gc> ClassObject<'gc> {
318
310
/// instance traits will be resolved to their corresponding methods at this
319
311
/// time.
320
312
pub fn link_interfaces ( self , activation : & mut Activation < ' _ , ' gc > ) -> Result < ( ) , Error < ' gc > > {
321
- let mut write = self . 0 . write ( activation. context . gc_context ) ;
322
- let class = write. class ;
323
-
324
- let mut interfaces = Vec :: with_capacity ( class. direct_interfaces ( ) . len ( ) ) ;
325
-
326
- let mut dedup = HashSet :: new ( ) ;
327
- let mut queue = vec ! [ class] ;
328
- while let Some ( cls) = queue. pop ( ) {
329
- for interface in & * cls. direct_interfaces ( ) {
330
- if !interface. is_interface ( ) {
331
- return Err ( format ! (
332
- "Class {:?} is not an interface and cannot be implemented by classes" ,
333
- interface. name( ) . local_name( )
334
- )
335
- . into ( ) ) ;
336
- }
337
-
338
- if dedup. insert ( ClassHashWrapper ( * interface) ) {
339
- queue. push ( * interface) ;
340
- interfaces. push ( * interface) ;
341
- }
342
- }
343
-
344
- if let Some ( super_class) = cls. super_class ( ) {
345
- queue. push ( super_class) ;
346
- }
347
- }
348
- write. interfaces = interfaces;
349
- drop ( write) ;
350
-
351
- let read = self . 0 . read ( ) ;
313
+ let class = self . inner_class_definition ( ) ;
352
314
353
315
// FIXME - we should only be copying properties for newly-implemented
354
316
// interfaces (i.e. those that were not already implemented by the superclass)
355
317
// Otherwise, our behavior diverges from Flash Player in certain cases.
356
318
// See the ignored test 'tests/tests/swfs/avm2/weird_superinterface_properties/'
357
- for interface in & read . interfaces {
319
+ for interface in & * class . all_interfaces ( ) {
358
320
for interface_trait in & * interface. instance_traits ( ) {
359
321
if !interface_trait. name ( ) . namespace ( ) . is_public ( ) {
360
322
let public_name = QName :: new (
@@ -760,10 +722,6 @@ impl<'gc> ClassObject<'gc> {
760
722
self . 0 . read ( ) . prototype . unwrap ( )
761
723
}
762
724
763
- pub fn interfaces ( self ) -> Vec < Class < ' gc > > {
764
- self . 0 . read ( ) . interfaces . clone ( )
765
- }
766
-
767
725
pub fn class_scope ( self ) -> ScopeChain < ' gc > {
768
726
self . 0 . read ( ) . class_scope
769
727
}
0 commit comments