瀏覽代碼

rtl: added JSDelete

mattias 7 年之前
父節點
當前提交
8bda483894
共有 3 個文件被更改,包括 26 次插入7 次删除
  1. 17 4
      demo/rtl/demodatetime.lpi
  2. 1 1
      demo/rtl/demodatetime.pas
  3. 8 2
      packages/rtl/js.pas

+ 17 - 4
demo/rtl/demodatetime.lpi

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

+ 1 - 1
demo/rtl/demodatetime.pas

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

+ 8 - 2
packages/rtl/js.pas

@@ -731,6 +731,7 @@ var
   JSExceptValue: JSValue; external name '$e';
 
 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 encodeURIComponent(str : String) : String; external name 'encodeURIComponent';
@@ -780,7 +781,7 @@ Var
 
 implementation
 
-Function new(aElements: TJSValueDynArray) : TJSObject;
+function new(aElements: TJSValueDynArray): TJSObject;
 
   function toString(I : Integer): string; external name 'String';
 
@@ -813,6 +814,11 @@ begin
     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;
 asm
   if(v){ return true; } else { return false; };
@@ -948,7 +954,7 @@ begin
 end;
 
 
-Function GetValueType(JS : JSValue) : TJSValueType;
+function GetValueType(JS: JSValue): TJSValueType;
 
 Var
   t : string;