Browse Source

* Add Symbol

Michael Van Canneyt 1 year ago
parent
commit
eb8e63aa30
1 changed files with 29 additions and 1 deletions
  1. 29 1
      packages/rtl/src/js.pas

+ 29 - 1
packages/rtl/src/js.pas

@@ -253,6 +253,19 @@ type
     property Milliseconds: NativeInt read getMilliseconds write setMilliseconds;
     property Milliseconds: NativeInt read getMilliseconds write setMilliseconds;
   end;
   end;
 
 
+  { TJSSymbol }
+
+  TJSSymbol = class external name 'Symbol' (TJSFunction)
+  private
+  Private
+    FDescription: String; external name 'description';
+  Public
+    constructor new (aValue : JSValue);
+    class function for_ (key : string) : TJSSymbol;
+    class function keyFor (aSymbol : TJSSymbol) : string;
+    property Description : String Read FDescription;
+  end;
+
   TLocaleCompareOptions = record
   TLocaleCompareOptions = record
     localematched : string;
     localematched : string;
     usage: string;
     usage: string;
@@ -960,6 +973,7 @@ type
     Property Encoding : string Read FEncoding;
     Property Encoding : string Read FEncoding;
   end;
   end;
 
 
+
 var
 var
   // JSArguments can be used in procedures/functions to provide access to the 'arguments' array.
   // JSArguments can be used in procedures/functions to provide access to the 'arguments' array.
   JSArguments: TJSFunctionArguments; external name 'arguments';
   JSArguments: TJSFunctionArguments; external name 'arguments';
@@ -968,7 +982,10 @@ var
   // JSExceptValue can be used in catch blocks to access the JS throw value
   // JSExceptValue can be used in catch blocks to access the JS throw value
   JSExceptValue: JSValue; external name '$e';
   JSExceptValue: JSValue; external name '$e';
 
 
-  Function JSValueArrayOf(Args : Array of const) : TJSValueDynArray;
+function Symbol : TJSSymbol;
+function Symbol(Description : String) : TJSSymbol;
+
+Function JSValueArrayOf(Args : Array of const) : TJSValueDynArray;
 function new(aElements: TJSValueDynArray) : TJSObject; overload;
 function new(aElements: TJSValueDynArray) : TJSObject; overload;
 function JSDelete(const Obj: JSValue; const PropName: string): boolean; assembler; overload;
 function JSDelete(const Obj: JSValue; const PropName: string): boolean; assembler; overload;
 
 
@@ -1252,5 +1269,16 @@ begin
     end;
     end;
 end;
 end;
 
 
+function Symbol : TJSSymbol; assembler;
+asm
+  return Symbol();
+end;
+
+function Symbol(Description : String) : TJSSymbol; assembler;
+
+asm
+  return Symbol(Description);
+end;
+
 end.
 end.