* Namespaced WASI and JOB APIs

This commit is contained in:
Michaël Van Canneyt 2023-11-28 00:52:22 +01:00
parent ed15d85e7a
commit 1afdbeda6a
18 changed files with 80 additions and 6 deletions

View File

@ -0,0 +1,3 @@
{$DEFINE FPC_DOTTEDUNITS}
unit JOB.Browser;
{$include ../src/job_browser.pp}

View File

@ -0,0 +1,3 @@
{$DEFINE FPC_DOTTEDUNITS}
unit JOB.Shared;
{$include ../src/job_shared.pp}

View File

@ -3,13 +3,20 @@
Browser side.
}
{$IFNDEF FPC_DOTTEDUNITS}
unit JOB_Browser;
{$ENDIF}
{$mode objfpc}
interface
uses sysutils, types, js, web, wasienv, JOB_Shared;
uses
{$IFDEF FPC_DOTTEDUNITS}
System.SysUtils, System.Types, JSApi.JS, BrowserApi.Web, Wasi.Env, JOB.Shared;
{$ELSE}
sysutils, types, js, web, wasienv, JOB_Shared;
{$ENDIF}
Type
EJOBBridge = class(Exception);

View File

@ -3,7 +3,9 @@
These types and constants are shared between pas2js and webassembly.
}
{$IFNDEF FPC_DOTTEDUNITS}
unit JOB_Shared;
{$ENDIF}
interface

View File

@ -0,0 +1,3 @@
{$DEFINE FPC_DOTTEDUNITS}
unit Fcl.App.Wasi.Host;
{$include ../src/wasihostapp.pas}

View File

@ -0,0 +1,3 @@
{$DEFINE FPC_DOTTEDUNITS}
unit Fcl.App.Wasi.Service;
{$include ../src/wasiserviceapp.pas}

View File

@ -0,0 +1,3 @@
{$DEFINE FPC_DOTTEDUNITS}
unit Fcl.App.Wasi.Threaded;
{$include ../src/wasithreadedapp.pas}

View File

@ -0,0 +1,3 @@
{$DEFINE FPC_DOTTEDUNITS}
unit Fcl.App.Wasi.ThreadedHost;
{$include ../src/wasiworkerthreadhost.pas}

View File

@ -0,0 +1,3 @@
{$DEFINE FPC_DOTTEDUNITS}
unit System.WebThreads;
{$include ../src/rtl.webthreads.pas}

View File

@ -0,0 +1,3 @@
{$DEFINE FPC_DOTTEDUNITS}
unit Wasi.Env;
{$include ../src/wasienv.pas}

View File

@ -24,7 +24,7 @@ interface
uses
{$IFDEF FPC_DOTTEDUNITS}
JSApi.JS, System.SysUtils, System.WasiEnv, BrowserApi.WebAssembly;
JSApi.JS, System.SysUtils, Wasi.Env, BrowserApi.WebAssembly;
{$ELSE}
JS, SysUtils, wasienv, webassembly;
{$ENDIF}

View File

@ -1,5 +1,6 @@
{$IFNDEF FPC_DOTTEDUNITS}
unit wasienv;
{$ENDIF}
{$mode ObjFPC}
{$modeswitch externalclass}
@ -11,7 +12,11 @@ unit wasienv;
interface
uses
{$IFDEF FPC_DOTTEDUNITS}
System.SysUtils, System.Classes, JSApi.JS, BrowserApi.WebAssembly, System.Types;
{$ELSE}
SysUtils, Classes, JS, WebAssembly, types;
{$ENDIF}
Const
@ -588,7 +593,12 @@ type
implementation
uses weborworker;
uses
{$IFDEF FPC_DOTTEDUNITS}
BrowserApi.WebOrWorker;
{$ELSE}
WebOrWorker;
{$ENDIF}
{ TWASIHost }

View File

@ -1,11 +1,17 @@
{$IFNDEF FPC_DOTTEDUNITS}
unit wasihostapp;
{$ENDIF}
{$mode ObjFPC}
interface
uses
{$IFDEF FPC_DOTTEDUNITS}
System.Classes, System.SysUtils, Fcl.App.Browser, JSApi.JS, BrowserApi.WebAssembly, Wasi.Env;
{$ELSE}
Classes, SysUtils, browserapp, js, webassembly, wasienv;
{$ENDIF}
Type

View File

@ -1,11 +1,17 @@
{$IFNDEF FPC_DOTTEDUNITS}
unit wasiserviceapp;
{$ENDIF}
{$mode ObjFPC}
interface
uses
{$IFDEF FPC_DOTTEDUNITS}
System.Classes, System.SysUtils, Fcl.App.ServiceWorker, BrowserApi.WebAssembly, Wasi.Env;
{$ELSE}
Classes, SysUtils, serviceworkerapp, webassembly, wasienv;
{$ENDIF}
Type
{ TWASIServiceApplication }

View File

@ -1,4 +1,6 @@
{$IFNDEF FPC_DOTTEDUNITS}
unit wasithreadedapp;
{$ENDIF}
{$mode ObjFPC}
{$modeswitch externalclass}
@ -7,7 +9,12 @@ unit wasithreadedapp;
interface
uses
{$IFDEF FPC_DOTTEDUNITS}
JSApi.JS, System.Classes, System.SysUtils, System.WebThreads, Wasi.Env, Fcl.App.Wasi.Host,
BrowserApi.WebOrWorker;
{$ELSE}
JS, Classes, SysUtils, Rtl.WebThreads, wasienv, wasihostapp, weborworker;
{$ENDIF}
Type
{ TWasmThread }

View File

@ -1,4 +1,6 @@
{$IFNDEF FPC_DOTTEDUNITS}
unit wasiworkerthreadhost;
{$ENDIF}
{$mode ObjFPC}
{$modeswitch externalclass}
@ -6,7 +8,12 @@ unit wasiworkerthreadhost;
interface
uses
{$IFDEF FPC_DOTTEDUNITS}
System.Classes, System.SysUtils, JSApi.JS, Fcl.CustApp, BrowserApi.WebOrWorker,
BrowserApi.Worker, BrowserApi.WebAssembly, Wasi.Env, System.WebThreads;
{$ELSE}
Classes, SysUtils, JS, custapp, weborworker, webworker, webassembly, wasienv, Rtl.WebThreads;
{$ENDIF}
Type
TWorkerThreadSupport = Class;
@ -144,7 +151,12 @@ Type
implementation
uses Types;
uses
{$IFDEF FPC_DOTTEDUNITS}
System.Types;
{$ELSE}
Types;
{$ENDIF}
var
Self_ : TJSDedicatedWorkerGlobalScope; external name 'self';
@ -610,7 +622,7 @@ end;
function TWorkerWASIHostApplication.GetLocation: String;
begin
Result:=webworker.Location.pathname;
Result:={$IFDEF FPC_DOTTEDUNITS}BrowserApi.Worker.{$ELSE}}WebWorker.{$ENDIF}Location.pathname;
end;
constructor TWorkerWASIHostApplication.Create(aOwner: TComponent);