From d9ccc42cc435b4a04e27aee1e5df1d35f65d477d Mon Sep 17 00:00:00 2001 From: Mattias Gaertner Date: Mon, 7 Jan 2019 17:02:27 +0000 Subject: [PATCH] pastojs: docs git-svn-id: trunk@40799 - --- utils/pas2js/docs/translation.html | 49 +++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/utils/pas2js/docs/translation.html b/utils/pas2js/docs/translation.html index 6e56d5476e..2b56f3f925 100644 --- a/utils/pas2js/docs/translation.html +++ b/utils/pas2js/docs/translation.html @@ -628,7 +628,8 @@ End. Pascal - JavaScript + JS Pas2js 1.2 + JS Pas2js 1.3 @@ -677,6 +678,35 @@ function(){ }, }, []); + + + +
rtl.module("MyModule",
+["System"],
+function(){
+  var $mod = this;
+  rtl.createTRecord($mod, "TMyRecord", function() {
+    this.i = 0;
+    this.s = "";
+    this.d = 0.0;
+    this.$eq = function (b) {
+      return (this.i == b.i) && (this.s == b.i) && (this.d == b.d);
+    };
+    this.$assign = function (s) {
+      this.i = s.i;
+      this.s = s.s;
+      this.d = s.d;
+      return this;
+    };
+  };
+  this.r = this.TMyRecord.$new();
+  $mod.$init = function() {
+    $mod.r.i=123;
+    $mod.r.$assign($mod.s);
+    if ($mod.r.$eq($mod.s)) ;
+  },
+},
+[]);
 
@@ -686,9 +716,20 @@ function(){
  • The record variable creates a JavaScript object.
  • Variant records are not supported.
  • Supported: Assign, pass as argument, equal, not equal, - array of record, pointer of record, const, default().
  • -
  • Not yet implemented: advanced records, operators.
  • -
  • When assigning a record it is cloned. This is compatible with Delphi and FPC.
  • + array of record, pointer of record, const, default(), RTTI. +
  • Advanced record (since pas2js 1.3): + +
  • +
  • Not yet implemented: constructors, operators.
  • +
  • Until Pas2js 1.2 when assigning a record it is cloned, creating a new + JS object. Since Pas2js 1.3 only values are copied, + keeping the object, so pointer of record is compatible.
  • Since record types are JS objects it is possible to typecast a record type to the JS Object, e.g. TJSObject(TPoint)
  • A pointer of record is simply a reference.