rtl: added JSDelete

This commit is contained in:
mattias 2018-06-14 13:54:31 +00:00
parent d8e91fc412
commit 8bda483894
3 changed files with 26 additions and 7 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<CONFIG> <CONFIG>
<ProjectOptions> <ProjectOptions>
<Version Value="10"/> <Version Value="11"/>
<General> <General>
<Flags> <Flags>
<MainUnitHasCreateFormStatements Value="False"/> <MainUnitHasCreateFormStatements Value="False"/>
@ -20,9 +20,10 @@
<Version Value="2"/> <Version Value="2"/>
</PublishOptions> </PublishOptions>
<RunParams> <RunParams>
<local> <FormatVersion Value="2"/>
<FormatVersion Value="1"/> <Modes Count="1">
</local> <Mode0 Name="default"/>
</Modes>
</RunParams> </RunParams>
<RequiredPackages Count="1"> <RequiredPackages Count="1">
<Item1> <Item1>
@ -45,6 +46,18 @@
<IncludeFiles Value="$(ProjOutDir)"/> <IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths> </SearchPaths>
<Parsing>
<SyntaxOptions>
<AllowLabel Value="False"/>
<CPPInline Value="False"/>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking>
<Debugging>
<GenerateDebugInfo Value="False"/>
</Debugging>
</Linking>
<Other> <Other>
<ExecuteBefore> <ExecuteBefore>
<Command Value="$MakeExe(pas2js) -Jirtl.js -Tnodejs -Fu$(ProjUnitPath) -o$NameOnly($(ProjFile)).js $Name($(ProjFile))"/> <Command Value="$MakeExe(pas2js) -Jirtl.js -Tnodejs -Fu$(ProjUnitPath) -o$NameOnly($(ProjFile)).js $Name($(ProjFile))"/>

View File

@ -1,6 +1,6 @@
program demodatetime; program demodatetime;
uses sysutils; uses sysutils, js;
Procedure DumpDate(Msg : String; Dt : TDateTime); Procedure DumpDate(Msg : String; Dt : TDateTime);

View File

@ -731,6 +731,7 @@ var
JSExceptValue: JSValue; external name '$e'; JSExceptValue: JSValue; external name '$e';
Function new(aElements: TJSValueDynArray) : TJSObject; overload; Function new(aElements: TJSValueDynArray) : TJSObject; overload;
function JSDelete(const Obj: JSValue; const PropName: string): boolean; assembler; overload;
function decodeURIComponent(encodedURI : String) : String; external name 'decodeURIComponent'; function decodeURIComponent(encodedURI : String) : String; external name 'decodeURIComponent';
function encodeURIComponent(str : String) : String; external name 'encodeURIComponent'; function encodeURIComponent(str : String) : String; external name 'encodeURIComponent';
@ -780,7 +781,7 @@ Var
implementation implementation
Function new(aElements: TJSValueDynArray) : TJSObject; function new(aElements: TJSValueDynArray): TJSObject;
function toString(I : Integer): string; external name 'String'; function toString(I : Integer): string; external name 'String';
@ -813,6 +814,11 @@ begin
end; end;
end; end;
function JSDelete(const Obj: JSValue; const PropName: string): boolean; assembler;
asm
return delete Obj[PropName];
end;
function hasValue(const v: JSValue): boolean; assembler; function hasValue(const v: JSValue): boolean; assembler;
asm asm
if(v){ return true; } else { return false; }; if(v){ return true; } else { return false; };
@ -948,7 +954,7 @@ begin
end; end;
Function GetValueType(JS : JSValue) : TJSValueType; function GetValueType(JS: JSValue): TJSValueType;
Var Var
t : string; t : string;