File tree Expand file tree Collapse file tree 9 files changed +148
-5
lines changed Expand file tree Collapse file tree 9 files changed +148
-5
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ pub mod capabilities;
66pub mod security;
77pub mod security_domain;
88pub mod system;
9+ pub mod worker;
10+ pub mod worker_domain;
911
1012use crate :: avm2:: activation:: Activation ;
1113use crate :: avm2:: parameters:: ParametersExt ;
Original file line number Diff line number Diff line change 11package flash.system {
22 import flash.events.EventDispatcher ;
3+ import __ruffle__.stub_method ;
34
45 [API ("682" )]
56 [Ruffle (Abstract)]
67 public final class MessageChannel extends EventDispatcher {
7- public function MessageChannel () {
8- super ( );
8+ public function send ( arg : * , queueLimit : int = - 1 ): void {
9+ stub_method( "flash.system.MessageChannel" , "send" );
910 }
1011 }
1112}
Original file line number Diff line number Diff line change 11package flash.system {
2+
3+ import flash.events.Event ;
24 import flash.events.EventDispatcher ;
5+ import flash.system.MessageChannel ;
6+ import __ruffle__.stub_getter ;
7+ import __ruffle__.stub_method ;
38
49 [API ("682" )]
510 [Ruffle (Abstract)]
611 public final class Worker extends EventDispatcher {
712 public static function get isSupported ():Boolean {
813 return false ;
914 }
15+
16+ private static var _current : Worker;
17+
18+ public static function get current ():Worker {
19+ stub_getter("flash.system.Worker" , "current" );
20+
21+ if (! _current ) {
22+ _current = instantiateInternal();
23+ }
24+
25+ return _current ;
26+ }
27+
28+ public native function createMessageChannel(receiver: Worker): MessageChannel;
29+
30+ public function setSharedProperty (key :String , value :* ):void {
31+ stub_method("flash.system.Worker" , "setSharedProperty" );
32+ }
33+
34+ public function getSharedProperty (key :String ):* {
35+ stub_method("flash.system.Worker" , "getSharedProperty" );
36+ }
37+
38+ public function start ():void {
39+ this . dispatchEvent (new Event (Event . WORKER_STATE ));
40+
41+ stub_method("flash.system.Worker" , "start" );
42+ }
43+
44+ private static native function instantiateInternal(): Worker;
1045 }
1146}
Original file line number Diff line number Diff line change 11package flash.system {
2+
3+ import flash.utils.ByteArray ;
4+ import flash.system.Worker ;
5+ import __ruffle__.stub_getter ;
6+
27 [API ("680" )] // the docs say 682, that's wrong
38 [Ruffle (Abstract)]
49 public final class WorkerDomain {
5- public static const isSupported: Boolean = false ;
10+ public static function get isSupported ():Boolean {
11+ return false ;
12+ }
13+
14+ private static var _current : WorkerDomain;
15+
16+ public static function get current ():WorkerDomain {
17+ stub_getter("flash.system.WorkerDomain" , "current" );
18+
19+ if (! _current ) {
20+ _current = instantiateInternal();
21+ }
22+
23+ return _current ;
24+ }
25+
26+ public native function createWorker(swf: ByteArray , giveAppPrivileges: Boolean = false ): Worker;
27+
28+ private static native function instantiateInternal(): WorkerDomain;
629 }
730}
Original file line number Diff line number Diff line change 1+ //! `flash.system.Worker` native methods
2+
3+ use crate :: avm2:: activation:: Activation ;
4+ use crate :: avm2:: object:: { MessageChannelObject , WorkerObject } ;
5+ use crate :: avm2:: parameters:: ParametersExt ;
6+ use crate :: avm2:: value:: Value ;
7+ use crate :: avm2:: Error ;
8+ use crate :: avm2_stub_method;
9+
10+ /// Implements `Worker.createMessageChannel`
11+ pub fn create_message_channel < ' gc > (
12+ activation : & mut Activation < ' _ , ' gc > ,
13+ _this : Value < ' gc > ,
14+ args : & [ Value < ' gc > ] ,
15+ ) -> Result < Value < ' gc > , Error < ' gc > > {
16+ avm2_stub_method ! ( activation, "flash.system.Worker" , "createMessageChannel" ) ;
17+
18+ let _receiver = args. get_object ( activation, 0 , "receiver" ) ?;
19+
20+ let message_channel = MessageChannelObject :: new ( activation) ;
21+
22+ Ok ( message_channel. into ( ) )
23+ }
24+
25+ pub fn instantiate_internal < ' gc > (
26+ activation : & mut Activation < ' _ , ' gc > ,
27+ _this : Value < ' gc > ,
28+ _args : & [ Value < ' gc > ] ,
29+ ) -> Result < Value < ' gc > , Error < ' gc > > {
30+ let worker = WorkerObject :: new ( activation) ;
31+
32+ Ok ( worker. into ( ) )
33+ }
Original file line number Diff line number Diff line change 1+ //! `flash.system.WorkerDomain` native methods
2+
3+ use crate :: avm2:: activation:: Activation ;
4+ use crate :: avm2:: object:: { WorkerDomainObject , WorkerObject } ;
5+ use crate :: avm2:: parameters:: ParametersExt ;
6+ use crate :: avm2:: value:: Value ;
7+ use crate :: avm2:: Error ;
8+ use crate :: avm2_stub_method;
9+
10+ /// Implements `WorkerDomain.createWorker`
11+ pub fn create_worker < ' gc > (
12+ activation : & mut Activation < ' _ , ' gc > ,
13+ _this : Value < ' gc > ,
14+ args : & [ Value < ' gc > ] ,
15+ ) -> Result < Value < ' gc > , Error < ' gc > > {
16+ avm2_stub_method ! ( activation, "flash.system.WorkerDomain" , "createWorker" ) ;
17+
18+ let _swf = args. get_object ( activation, 0 , "swf" ) ?;
19+ let _give_app_privileges = args. get_bool ( 1 ) ;
20+
21+ let worker = WorkerObject :: new ( activation) ;
22+
23+ Ok ( worker. into ( ) )
24+ }
25+
26+ pub fn instantiate_internal < ' gc > (
27+ activation : & mut Activation < ' _ , ' gc > ,
28+ _this : Value < ' gc > ,
29+ _args : & [ Value < ' gc > ] ,
30+ ) -> Result < Value < ' gc > , Error < ' gc > > {
31+ let worker_domain = WorkerDomainObject :: new ( activation) ;
32+
33+ Ok ( worker_domain. into ( ) )
34+ }
Original file line number Diff line number Diff line change 11package flash.utils {
2+
3+ import __ruffle__.stub_setter ;
4+
25 [Ruffle (InstanceAllocator)]
36 public class ByteArray implements IDataInput2 , IDataOutput2 {
47 private static var _defaultObjectEncoding : uint = 3 ;
58
9+ private var _shareable : Boolean = false ;
10+
11+ [API ("684" )]
12+ public function set shareable (shareable : Boolean ):void {
13+ stub_setter("flash.utils.ByteArray" , "shareable" );
14+
15+ this . _shareable = shareable;
16+ }
17+
18+ [API ("684" )]
19+ public function get shareable ():Boolean {
20+ return this . _shareable ;
21+ }
22+
623 public static function get defaultObjectEncoding ():uint {
724 return _defaultObjectEncoding ;
825 }
Original file line number Diff line number Diff line change @@ -40,7 +40,6 @@ impl<'gc> TObject<'gc> for WorkerDomainObject<'gc> {
4040}
4141
4242impl < ' gc > WorkerDomainObject < ' gc > {
43- #[ allow( dead_code) ]
4443 pub fn new ( activation : & mut Activation < ' _ , ' gc > ) -> Self {
4544 let class = activation. avm2 ( ) . classes ( ) . workerdomain ;
4645 let base = ScriptObjectData :: new ( class) ;
Original file line number Diff line number Diff line change @@ -40,7 +40,6 @@ impl<'gc> TObject<'gc> for WorkerObject<'gc> {
4040}
4141
4242impl < ' gc > WorkerObject < ' gc > {
43- #[ allow( dead_code) ]
4443 pub fn new ( activation : & mut Activation < ' _ , ' gc > ) -> Self {
4544 let class = activation. avm2 ( ) . classes ( ) . worker ;
4645 let base = ScriptObjectData :: new ( class) ;
You can’t perform that action at this time.
0 commit comments