mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-09-01 10:50:17 +02:00
wasi: updated example, some clean up
This commit is contained in:
parent
35f32843ca
commit
7d78964c52
@ -42,16 +42,6 @@
|
|||||||
<Item0 Name="PasJSIsProjectHTMLFile" Value="1"/>
|
<Item0 Name="PasJSIsProjectHTMLFile" Value="1"/>
|
||||||
</CustomData>
|
</CustomData>
|
||||||
</Unit>
|
</Unit>
|
||||||
<Unit>
|
|
||||||
<Filename Value="../../../packages/job/job_browser.pp"/>
|
|
||||||
<IsPartOfProject Value="True"/>
|
|
||||||
<UnitName Value="JOB_Browser"/>
|
|
||||||
</Unit>
|
|
||||||
<Unit>
|
|
||||||
<Filename Value="../../../packages/job/job_shared.pp"/>
|
|
||||||
<IsPartOfProject Value="True"/>
|
|
||||||
<UnitName Value="JOB_Shared"/>
|
|
||||||
</Unit>
|
|
||||||
</Units>
|
</Units>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
<CompilerOptions>
|
<CompilerOptions>
|
||||||
@ -61,14 +51,13 @@
|
|||||||
</Target>
|
</Target>
|
||||||
<SearchPaths>
|
<SearchPaths>
|
||||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
<OtherUnitFiles Value="../../../packages/job"/>
|
|
||||||
<UnitOutputDirectory Value="js"/>
|
<UnitOutputDirectory Value="js"/>
|
||||||
</SearchPaths>
|
</SearchPaths>
|
||||||
<Parsing>
|
<Parsing>
|
||||||
<SyntaxOptions>
|
<SyntaxOptions>
|
||||||
<AllowLabel Value="False"/>
|
<AllowLabel Value="False"/>
|
||||||
<CPPInline Value="False"/>
|
|
||||||
<UseAnsiStrings Value="False"/>
|
<UseAnsiStrings Value="False"/>
|
||||||
|
<CPPInline Value="False"/>
|
||||||
</SyntaxOptions>
|
</SyntaxOptions>
|
||||||
</Parsing>
|
</Parsing>
|
||||||
<CodeGeneration>
|
<CodeGeneration>
|
||||||
|
@ -5,7 +5,7 @@ library WasiButton1;
|
|||||||
{$codepage UTF8}
|
{$codepage UTF8}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
SysUtils, JOB_Shared, JOB_Web, JOB_JS;
|
SysUtils, JOB.Shared, JOB_Web, JOB.JS;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ end;
|
|||||||
// workaround: fpc wasm does not yet support exporting functions from units
|
// workaround: fpc wasm does not yet support exporting functions from units
|
||||||
function JOBCallback(const Func: TJOBCallback; Data, Code: Pointer; Args: PByte): PByte;
|
function JOBCallback(const Func: TJOBCallback; Data, Code: Pointer; Args: PByte): PByte;
|
||||||
begin
|
begin
|
||||||
Result:=JOB_JS.JOBCallback(Func,Data,Code,Args);
|
Result:=JOB.JS.JOBCallback(Func,Data,Code,Args);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
exports
|
exports
|
||||||
|
@ -13,7 +13,7 @@ unit JOB_Web;
|
|||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses SysUtils, JOB_JS;
|
uses SysUtils, JOB.JS;
|
||||||
|
|
||||||
Type
|
Type
|
||||||
// Forward class definitions
|
// Forward class definitions
|
||||||
|
@ -754,25 +754,18 @@ function TWASIHost.CreateWebAssembly(aPath: string; aImportObject: TJSObject
|
|||||||
): TJSPromise;
|
): TJSPromise;
|
||||||
|
|
||||||
Function InstantiateOK(Res : JSValue) : JSValue;
|
Function InstantiateOK(Res : JSValue) : JSValue;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=res;
|
Result:=res;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function InstantiateFail(Res : JSValue) : JSValue;
|
Function InstantiateFail(Res : JSValue) : JSValue;
|
||||||
|
|
||||||
var
|
|
||||||
S : String;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=False;
|
Result:=False;
|
||||||
console.Log('Instantiating of WebAssembly from '+aPath+' failed '+ValueToMessage(Res));
|
console.Log('Instantiating of WebAssembly from '+aPath+' failed '+ValueToMessage(Res));
|
||||||
DoInstantiateFail(res);
|
DoInstantiateFail(res);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function ArrayOK(res2 : jsValue) : JSValue;
|
Function ArrayOK(res2 : jsValue) : JSValue;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
DoBeforeInstantiate;
|
DoBeforeInstantiate;
|
||||||
Result:=TJSWebAssembly.instantiate(TJSArrayBuffer(res2),aImportObject)._then(@InstantiateOK,@InstantiateFail);
|
Result:=TJSWebAssembly.instantiate(TJSArrayBuffer(res2),aImportObject)._then(@InstantiateOK,@InstantiateFail);
|
||||||
|
Loading…
Reference in New Issue
Block a user