@@ -12,6 +12,7 @@ use crate::avm2::{Avm2, Error, Multiname, Namespace, QName};
12
12
use crate :: string:: { AvmString , WStr } ;
13
13
use crate :: tag_utils:: { self , ControlFlow , SwfMovie , SwfSlice , SwfStream } ;
14
14
use gc_arena:: Collect ;
15
+ use ruffle_macros:: istr;
15
16
use std:: sync:: Arc ;
16
17
use swf:: TagCode ;
17
18
@@ -384,25 +385,6 @@ impl<'gc> SystemClassDefs<'gc> {
384
385
}
385
386
}
386
387
387
- /// Looks up a function defined in the script domain, and defines it on the global object.
388
- ///
389
- /// This expects the looked-up value to be a function.
390
- fn define_fn_on_global < ' gc > (
391
- activation : & mut Activation < ' _ , ' gc > ,
392
- name : & ' static str ,
393
- script : Script < ' gc > ,
394
- ) {
395
- let ( _, global, domain) = script. init ( ) ;
396
- let qname = QName :: new ( activation. avm2 ( ) . namespaces . public_all ( ) , name) ;
397
- let func = domain
398
- . get_defined_value ( activation, qname)
399
- . expect ( "Function being defined on global should be defined in domain!" ) ;
400
-
401
- Value :: from ( global)
402
- . init_property ( & qname. into ( ) , func, activation)
403
- . expect ( "Should set property" ) ;
404
- }
405
-
406
388
/// Add a fully-formed class object builtin to the global scope.
407
389
///
408
390
/// This allows the caller to pre-populate the class's prototype with dynamic
@@ -485,30 +467,14 @@ pub fn load_player_globals<'gc>(
485
467
void_def,
486
468
) ) ;
487
469
488
- // Unfortunately we need to specify the global traits manually, at least until
489
- // all the builtin classes are defined in AS.
470
+ // Unfortunately we need to specify the global traits manually
490
471
let mut global_traits = Vec :: new ( ) ;
491
472
492
473
let public_ns = activation. avm2 ( ) . namespaces . public_all ( ) ;
493
474
494
475
let class_trait_list = & [
495
- ( public_ns, "Object" , object_i_class) ,
496
- ( public_ns, "Class" , class_i_class) ,
497
- ] ;
498
-
499
- // "trace" is the only builtin function not defined on the toplevel global object
500
- let function_trait_list = & [
501
- "decodeURI" ,
502
- "decodeURIComponent" ,
503
- "encodeURI" ,
504
- "encodeURIComponent" ,
505
- "escape" ,
506
- "unescape" ,
507
- "isXMLName" ,
508
- "isFinite" ,
509
- "isNaN" ,
510
- "parseFloat" ,
511
- "parseInt" ,
476
+ ( public_ns, istr ! ( "Object" ) , object_i_class) ,
477
+ ( public_ns, istr ! ( "Class" ) , class_i_class) ,
512
478
] ;
513
479
514
480
for ( namespace, name, class) in class_trait_list {
@@ -517,19 +483,6 @@ pub fn load_player_globals<'gc>(
517
483
global_traits. push ( Trait :: from_class ( qname, * class) ) ;
518
484
}
519
485
520
- for function_name in function_trait_list {
521
- let qname = QName :: new ( public_ns, * function_name) ;
522
-
523
- // FIXME: These should be TraitKind::Methods, to match how they are when
524
- // defined on the AS global object, but we don't have the actual Methods
525
- // right now.
526
- global_traits. push ( Trait :: from_const (
527
- qname,
528
- Some ( activation. avm2 ( ) . multinames . function ) ,
529
- Some ( Value :: Null ) ,
530
- ) ) ;
531
- }
532
-
533
486
// Create the builtin globals' classdef
534
487
let global_classdef = global_scope:: create_class ( activation, global_traits) ;
535
488
@@ -595,8 +548,6 @@ pub fn load_player_globals<'gc>(
595
548
596
549
globals. set_vtable ( mc, global_obj_vtable) ;
597
550
598
- activation. context . avm2 . toplevel_global_object = Some ( globals) ;
599
-
600
551
// Initialize the script
601
552
let script = Script :: empty_script ( mc, globals, domain) ;
602
553
@@ -613,11 +564,6 @@ pub fn load_player_globals<'gc>(
613
564
// this call.
614
565
load_playerglobal ( activation, domain) ?;
615
566
616
- for function_name in function_trait_list {
617
- // Now copy those functions to the global object.
618
- define_fn_on_global ( activation, function_name, script) ;
619
- }
620
-
621
567
Ok ( ( ) )
622
568
}
623
569
0 commit comments