mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-04-14 20:50:03 +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"/>
|
||||
</CustomData>
|
||||
</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>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
@ -61,14 +51,13 @@
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<OtherUnitFiles Value="../../../packages/job"/>
|
||||
<UnitOutputDirectory Value="js"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<AllowLabel Value="False"/>
|
||||
<CPPInline Value="False"/>
|
||||
<UseAnsiStrings Value="False"/>
|
||||
<CPPInline Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
|
@ -5,7 +5,7 @@ library WasiButton1;
|
||||
{$codepage UTF8}
|
||||
|
||||
uses
|
||||
SysUtils, JOB_Shared, JOB_Web, JOB_JS;
|
||||
SysUtils, JOB.Shared, JOB_Web, JOB.JS;
|
||||
|
||||
type
|
||||
|
||||
@ -58,7 +58,7 @@ end;
|
||||
// workaround: fpc wasm does not yet support exporting functions from units
|
||||
function JOBCallback(const Func: TJOBCallback; Data, Code: Pointer; Args: PByte): PByte;
|
||||
begin
|
||||
Result:=JOB_JS.JOBCallback(Func,Data,Code,Args);
|
||||
Result:=JOB.JS.JOBCallback(Func,Data,Code,Args);
|
||||
end;
|
||||
|
||||
exports
|
||||
|
@ -13,7 +13,7 @@ unit JOB_Web;
|
||||
|
||||
interface
|
||||
|
||||
uses SysUtils, JOB_JS;
|
||||
uses SysUtils, JOB.JS;
|
||||
|
||||
Type
|
||||
// Forward class definitions
|
||||
|
@ -754,25 +754,18 @@ function TWASIHost.CreateWebAssembly(aPath: string; aImportObject: TJSObject
|
||||
): TJSPromise;
|
||||
|
||||
Function InstantiateOK(Res : JSValue) : JSValue;
|
||||
|
||||
begin
|
||||
Result:=res;
|
||||
end;
|
||||
|
||||
Function InstantiateFail(Res : JSValue) : JSValue;
|
||||
|
||||
var
|
||||
S : String;
|
||||
|
||||
begin
|
||||
Result:=False;
|
||||
console.Log('Instantiating of WebAssembly from '+aPath+' failed '+ValueToMessage(Res));
|
||||
DoInstantiateFail(res);
|
||||
end;
|
||||
|
||||
|
||||
Function ArrayOK(res2 : jsValue) : JSValue;
|
||||
|
||||
begin
|
||||
DoBeforeInstantiate;
|
||||
Result:=TJSWebAssembly.instantiate(TJSArrayBuffer(res2),aImportObject)._then(@InstantiateOK,@InstantiateFail);
|
||||
|
Loading…
Reference in New Issue
Block a user