|
@@ -77,6 +77,7 @@ type
|
|
|
procedure TestGenMethod_ObjFPC;
|
|
|
|
|
|
// generic array
|
|
|
+ procedure TestGen_Array_OtherUnit;
|
|
|
procedure TestGen_ArrayOfUnitImplRec;
|
|
|
|
|
|
// generic procedure type
|
|
@@ -102,7 +103,7 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGen_RecordEmpty',
|
|
|
LinesToStr([ // statements
|
|
|
- 'rtl.recNewT($mod, "TRecA$G1", function () {',
|
|
|
+ 'rtl.recNewT(this, "TRecA$G1", function () {',
|
|
|
' this.$eq = function (b) {',
|
|
|
' return true;',
|
|
|
' };',
|
|
@@ -110,8 +111,8 @@ begin
|
|
|
' return this;',
|
|
|
' };',
|
|
|
'});',
|
|
|
- 'this.a = $mod.TRecA$G1.$new();',
|
|
|
- 'this.b = $mod.TRecA$G1.$new();',
|
|
|
+ 'this.a = this.TRecA$G1.$new();',
|
|
|
+ 'this.b = this.TRecA$G1.$new();',
|
|
|
'']),
|
|
|
LinesToStr([ // $mod.$main
|
|
|
'if ($mod.a.$eq($mod.b)) ;'
|
|
@@ -144,7 +145,7 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGen_Record_ClassProc',
|
|
|
LinesToStr([ // statements
|
|
|
- 'rtl.recNewT($mod, "TPoint$G1", function () {',
|
|
|
+ 'rtl.recNewT(this, "TPoint$G1", function () {',
|
|
|
' this.x = 0;',
|
|
|
' this.$eq = function (b) {',
|
|
|
' return true;',
|
|
@@ -159,7 +160,7 @@ begin
|
|
|
' $mod.TPoint$G1.Fly();',
|
|
|
' };',
|
|
|
'}, true);',
|
|
|
- 'this.p = $mod.TPoint$G1.$new();',
|
|
|
+ 'this.p = this.TPoint$G1.$new();',
|
|
|
'']),
|
|
|
LinesToStr([ // $mod.$main
|
|
|
'$mod.TPoint$G1.x = $mod.p.x + 10;',
|
|
@@ -187,7 +188,7 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGen_Record_ClassVarRecord_Program',
|
|
|
LinesToStr([ // statements
|
|
|
- 'rtl.recNewT($mod, "TBird", function () {',
|
|
|
+ 'rtl.recNewT(this, "TBird", function () {',
|
|
|
' this.b = 0;',
|
|
|
' this.$eq = function (b) {',
|
|
|
' return this.b === b.b;',
|
|
@@ -197,7 +198,7 @@ begin
|
|
|
' return this;',
|
|
|
' };',
|
|
|
'});',
|
|
|
- 'rtl.recNewT($mod, "TAnt$G1", function () {',
|
|
|
+ 'rtl.recNewT(this, "TAnt$G1", function () {',
|
|
|
' this.x = $mod.TBird.$new();',
|
|
|
' this.$eq = function (b) {',
|
|
|
' return true;',
|
|
@@ -206,7 +207,7 @@ begin
|
|
|
' return this;',
|
|
|
' };',
|
|
|
'}, true);',
|
|
|
- 'this.f = $mod.TAnt$G1.$new();',
|
|
|
+ 'this.f = this.TAnt$G1.$new();',
|
|
|
'']),
|
|
|
LinesToStr([ // $mod.$main
|
|
|
'$mod.f.x.b = $mod.f.x.b + 10;',
|
|
@@ -244,7 +245,7 @@ begin
|
|
|
'rtl.module("UnitA", ["system"], function () {',
|
|
|
' var $mod = this;',
|
|
|
' var $impl = $mod.$impl;',
|
|
|
- ' rtl.recNewT($mod, "TAnt$G1", function () {',
|
|
|
+ ' rtl.recNewT(this, "TAnt$G1", function () {',
|
|
|
' this.$initSpec = function () {',
|
|
|
' this.x = $impl.TBird.$new();',
|
|
|
' this.a = rtl.arraySetLength(null, $impl.TBird, 2);',
|
|
@@ -307,7 +308,7 @@ begin
|
|
|
CheckSource('TestGen_Record_RTTI_UnitImpl',
|
|
|
LinesToStr([ // statements
|
|
|
'var $impl = $mod.$impl;',
|
|
|
- 'rtl.recNewT($mod, "TAnt$G1", function () {',
|
|
|
+ 'rtl.recNewT(this, "TAnt$G1", function () {',
|
|
|
' var $r = $mod.$rtti.$Record("TAnt<Test1.TBird>", {});',
|
|
|
' this.$initSpec = function () {',
|
|
|
' this.x = $impl.TBird.$new();',
|
|
@@ -356,13 +357,13 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGen_ClassEmpty',
|
|
|
LinesToStr([ // statements
|
|
|
- 'rtl.createClass($mod, "TObject", null, function () {',
|
|
|
+ 'rtl.createClass(this, "TObject", null, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' };',
|
|
|
' this.$final = function () {',
|
|
|
' };',
|
|
|
'});',
|
|
|
- 'rtl.createClass($mod, "TBird$G1", $mod.TObject, function () {',
|
|
|
+ 'rtl.createClass(this, "TBird$G1", this.TObject, function () {',
|
|
|
'});',
|
|
|
'this.a = null;',
|
|
|
'this.b = null;',
|
|
@@ -390,13 +391,13 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGen_Class_EmptyMethod',
|
|
|
LinesToStr([ // statements
|
|
|
- 'rtl.createClass($mod, "TObject", null, function () {',
|
|
|
+ 'rtl.createClass(this, "TObject", null, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' };',
|
|
|
' this.$final = function () {',
|
|
|
' };',
|
|
|
'});',
|
|
|
- 'rtl.createClass($mod, "TBird$G1", $mod.TObject, function () {',
|
|
|
+ 'rtl.createClass(this, "TBird$G1", this.TObject, function () {',
|
|
|
' this.Fly = function (w) {',
|
|
|
' var Result = 0;',
|
|
|
' return Result;',
|
|
@@ -449,13 +450,13 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGen_Class_TList',
|
|
|
LinesToStr([ // statements
|
|
|
- 'rtl.createClass($mod, "TObject", null, function () {',
|
|
|
+ 'rtl.createClass(this, "TObject", null, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' };',
|
|
|
' this.$final = function () {',
|
|
|
' };',
|
|
|
'});',
|
|
|
- 'rtl.createClass($mod, "TList$G1", $mod.TObject, function () {',
|
|
|
+ 'rtl.createClass(this, "TList$G1", this.TObject, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' $mod.TObject.$init.call(this);',
|
|
|
' this.FItems = [];',
|
|
@@ -518,19 +519,19 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGen_Class_TCustomList',
|
|
|
LinesToStr([ // statements
|
|
|
- 'rtl.createClass($mod, "TObject", null, function () {',
|
|
|
+ 'rtl.createClass(this, "TObject", null, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' };',
|
|
|
' this.$final = function () {',
|
|
|
' };',
|
|
|
'});',
|
|
|
- 'rtl.createClass($mod, "TCustomList$G2", $mod.TObject, function () {',
|
|
|
+ 'rtl.createClass(this, "TCustomList$G2", this.TObject, function () {',
|
|
|
' this.PrepareAddingItem = function () {',
|
|
|
' var Result = 0;',
|
|
|
' return Result;',
|
|
|
' };',
|
|
|
'});',
|
|
|
- 'rtl.createClass($mod, "TList$G1", $mod.TCustomList$G2, function () {',
|
|
|
+ 'rtl.createClass(this, "TList$G1", this.TCustomList$G2, function () {',
|
|
|
' this.Add = function () {',
|
|
|
' var Result = 0;',
|
|
|
' Result = this.PrepareAddingItem();',
|
|
@@ -559,15 +560,15 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGen_ClassAncestor',
|
|
|
LinesToStr([ // statements
|
|
|
- 'rtl.createClass($mod, "TObject", null, function () {',
|
|
|
+ 'rtl.createClass(this, "TObject", null, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' };',
|
|
|
' this.$final = function () {',
|
|
|
' };',
|
|
|
'});',
|
|
|
- 'rtl.createClass($mod, "TBird$G2", $mod.TObject, function () {',
|
|
|
+ 'rtl.createClass(this, "TBird$G2", this.TObject, function () {',
|
|
|
'});',
|
|
|
- 'rtl.createClass($mod, "TEagle$G1", $mod.TBird$G2, function () {',
|
|
|
+ 'rtl.createClass(this, "TEagle$G1", this.TBird$G2, function () {',
|
|
|
'});',
|
|
|
'this.a = null;',
|
|
|
'']),
|
|
@@ -598,13 +599,13 @@ begin
|
|
|
CheckSource('TestGen_Class_TypeInfo',
|
|
|
LinesToStr([ // statements
|
|
|
'$mod.$rtti.$Class("TBird<System.Word>");',
|
|
|
- 'rtl.createClass($mod, "TObject", null, function () {',
|
|
|
+ 'rtl.createClass(this, "TObject", null, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' };',
|
|
|
' this.$final = function () {',
|
|
|
' };',
|
|
|
'});',
|
|
|
- 'rtl.createClass($mod, "TBird$G1", $mod.TObject, function () {',
|
|
|
+ 'rtl.createClass(this, "TBird$G1", this.TObject, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' $mod.TObject.$init.call(this);',
|
|
|
' this.m = 0;',
|
|
@@ -643,7 +644,7 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGen_Class_TypeOverload',
|
|
|
LinesToStr([ // statements
|
|
|
- 'rtl.createClass($mod, "TObject", null, function () {',
|
|
|
+ 'rtl.createClass(this, "TObject", null, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' };',
|
|
|
' this.$final = function () {',
|
|
@@ -674,13 +675,13 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGen_Class_ClassProperty',
|
|
|
LinesToStr([ // statements
|
|
|
- 'rtl.createClass($mod, "TObject", null, function () {',
|
|
|
+ 'rtl.createClass(this, "TObject", null, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' };',
|
|
|
' this.$final = function () {',
|
|
|
' };',
|
|
|
'});',
|
|
|
- 'rtl.createClass($mod, "TBird$G1", $mod.TObject, function () {',
|
|
|
+ 'rtl.createClass(this, "TBird$G1", this.TObject, function () {',
|
|
|
' this.fSize = 0;',
|
|
|
'});',
|
|
|
'']),
|
|
@@ -724,13 +725,13 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGen_Class_ClassProc',
|
|
|
LinesToStr([ // statements
|
|
|
- 'rtl.createClass($mod, "TObject", null, function () {',
|
|
|
+ 'rtl.createClass(this, "TObject", null, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' };',
|
|
|
' this.$final = function () {',
|
|
|
' };',
|
|
|
'});',
|
|
|
- 'rtl.createClass($mod, "TPoint$G1", $mod.TObject, function () {',
|
|
|
+ 'rtl.createClass(this, "TPoint$G1", this.TObject, function () {',
|
|
|
' this.x = 0;',
|
|
|
' this.Fly = function () {',
|
|
|
' $mod.TPoint$G1.x = $mod.TPoint$G1.x + 3;',
|
|
@@ -787,20 +788,20 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGen_Class_ClassConstructor',
|
|
|
LinesToStr([ // statements
|
|
|
- 'rtl.createClass($mod, "TObject", null, function () {',
|
|
|
+ 'rtl.createClass(this, "TObject", null, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' };',
|
|
|
' this.$final = function () {',
|
|
|
' };',
|
|
|
'});',
|
|
|
'this.count = 0;',
|
|
|
- 'rtl.createClass($mod, "TPoint$G1", $mod.TObject, function () {',
|
|
|
+ 'rtl.createClass(this, "TPoint$G1", this.TObject, function () {',
|
|
|
' this.x = 0;',
|
|
|
' this.Fly = function () {',
|
|
|
' };',
|
|
|
'});',
|
|
|
'this.r = null;',
|
|
|
- 'rtl.createClass($mod, "TPoint$G2", $mod.TObject, function () {',
|
|
|
+ 'rtl.createClass(this, "TPoint$G2", this.TObject, function () {',
|
|
|
' this.x = 0;',
|
|
|
' this.Fly = function () {',
|
|
|
' };',
|
|
@@ -845,19 +846,19 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGen_Class_TypeCastSpecializesWarn',
|
|
|
LinesToStr([ // statements
|
|
|
- 'rtl.createClass($mod, "TObject", null, function () {',
|
|
|
+ 'rtl.createClass(this, "TObject", null, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' };',
|
|
|
' this.$final = function () {',
|
|
|
' };',
|
|
|
'});',
|
|
|
- 'rtl.createClass($mod, "TBird$G1", $mod.TObject, function () {',
|
|
|
+ 'rtl.createClass(this, "TBird$G1", this.TObject, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' $mod.TObject.$init.call(this);',
|
|
|
' this.F = 0;',
|
|
|
' };',
|
|
|
'});',
|
|
|
- 'rtl.createClass($mod, "TBird$G2", $mod.TObject, function () {',
|
|
|
+ 'rtl.createClass(this, "TBird$G2", this.TObject, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' $mod.TObject.$init.call(this);',
|
|
|
' this.F = "";',
|
|
@@ -893,19 +894,19 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGen_Class_TypeCastSpecializesJSValueNoWarn',
|
|
|
LinesToStr([ // statements
|
|
|
- 'rtl.createClass($mod, "TObject", null, function () {',
|
|
|
+ 'rtl.createClass(this, "TObject", null, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' };',
|
|
|
' this.$final = function () {',
|
|
|
' };',
|
|
|
'});',
|
|
|
- 'rtl.createClass($mod, "TBird$G1", $mod.TObject, function () {',
|
|
|
+ 'rtl.createClass(this, "TBird$G1", this.TObject, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' $mod.TObject.$init.call(this);',
|
|
|
' this.F = 0;',
|
|
|
' };',
|
|
|
'});',
|
|
|
- 'rtl.createClass($mod, "TBird$G2", $mod.TObject, function () {',
|
|
|
+ 'rtl.createClass(this, "TBird$G2", this.TObject, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' $mod.TObject.$init.call(this);',
|
|
|
' this.F = undefined;',
|
|
@@ -1001,7 +1002,7 @@ begin
|
|
|
LinesToStr([ // statements
|
|
|
'rtl.module("UnitA", ["system"], function () {',
|
|
|
' var $mod = this;',
|
|
|
- ' rtl.createClass($mod, "TBird$G1", pas.system.TObject, function () {',
|
|
|
+ ' rtl.createClass(this, "TBird$G1", pas.system.TObject, function () {',
|
|
|
' this.c = 13;',
|
|
|
' var c$1 = 14;',
|
|
|
' this.Create$1 = function (w) {',
|
|
@@ -1012,7 +1013,7 @@ begin
|
|
|
' return this;',
|
|
|
' };',
|
|
|
' });',
|
|
|
- ' rtl.createClass($mod, "TBird$G2", pas.system.TObject, function () {',
|
|
|
+ ' rtl.createClass(this, "TBird$G2", pas.system.TObject, function () {',
|
|
|
' this.c = 13;',
|
|
|
' var c$1 = 14;',
|
|
|
' this.Create$1 = function (w) {',
|
|
@@ -1072,15 +1073,15 @@ begin
|
|
|
LinesToStr([ // statements
|
|
|
'$mod.$rtti.$Class("TAnt<System.Word>");',
|
|
|
'$mod.$rtti.$Class("TFish<System.Word>");',
|
|
|
- 'rtl.createClass($mod, "TObject", null, function () {',
|
|
|
+ 'rtl.createClass(this, "TObject", null, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' };',
|
|
|
' this.$final = function () {',
|
|
|
' };',
|
|
|
'});',
|
|
|
- 'rtl.createClass($mod, "TPersistent", $mod.TObject, function () {',
|
|
|
+ 'rtl.createClass(this, "TPersistent", this.TObject, function () {',
|
|
|
'});',
|
|
|
- 'rtl.createClass($mod, "TAnt$G2", $mod.TPersistent, function () {',
|
|
|
+ 'rtl.createClass(this, "TAnt$G2", this.TPersistent, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' $mod.TPersistent.$init.call(this);',
|
|
|
' this.f = null;',
|
|
@@ -1092,7 +1093,7 @@ begin
|
|
|
' var $r = this.$rtti;',
|
|
|
' $r.addField("f", $mod.$rtti["TFish<System.Word>"]);',
|
|
|
'}, "TAnt<System.Word>");',
|
|
|
- 'rtl.createClass($mod, "TFish$G2", $mod.TPersistent, function () {',
|
|
|
+ 'rtl.createClass(this, "TFish$G2", this.TPersistent, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' $mod.TPersistent.$init.call(this);',
|
|
|
' this.a = null;',
|
|
@@ -1144,7 +1145,7 @@ begin
|
|
|
'rtl.module("UnitA", ["system"], function () {',
|
|
|
' var $mod = this;',
|
|
|
' var $impl = $mod.$impl;',
|
|
|
- ' rtl.createClass($mod, "TAnt$G1", pas.system.TObject, function () {',
|
|
|
+ ' rtl.createClass(this, "TAnt$G1", pas.system.TObject, function () {',
|
|
|
' this.$initSpec = function () {',
|
|
|
' this.x = $impl.TBird.$new();',
|
|
|
' this.a = rtl.arraySetLength(null, $impl.TBird, 2);',
|
|
@@ -1312,11 +1313,11 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGen_ExtClass_RTTI',
|
|
|
LinesToStr([ // statements
|
|
|
- '$mod.$rtti.$ExtClass("TGJSSET<System.JSValue>", {',
|
|
|
+ 'this.$rtti.$ExtClass("TGJSSET<System.JSValue>", {',
|
|
|
' jsclass: "SET"',
|
|
|
'});',
|
|
|
- '$mod.$rtti.$RefToProcVar("TJSSetEventProc", {',
|
|
|
- ' procsig: rtl.newTIProcSig([["value", rtl.jsvalue], ["key", rtl.nativeint], ["set_", $mod.$rtti["TGJSSET<System.JSValue>"]]])',
|
|
|
+ 'this.$rtti.$RefToProcVar("TJSSetEventProc", {',
|
|
|
+ ' procsig: rtl.newTIProcSig([["value", rtl.jsvalue], ["key", rtl.nativeint], ["set_", this.$rtti["TGJSSET<System.JSValue>"]]])',
|
|
|
'});',
|
|
|
'this.p = null;',
|
|
|
'']),
|
|
@@ -1358,7 +1359,7 @@ begin
|
|
|
'rtl.module("UnitA", ["system"], function () {',
|
|
|
' var $mod = this;',
|
|
|
' var $impl = $mod.$impl;',
|
|
|
- ' $mod.$rtti.$ExtClass("TAnt<UnitA.TBird>", {',
|
|
|
+ ' this.$rtti.$ExtClass("TAnt<UnitA.TBird>", {',
|
|
|
' jsclass: "SET"',
|
|
|
' });',
|
|
|
' $mod.$implcode = function () {',
|
|
@@ -1422,15 +1423,15 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGen_ClassInterface_Corba',
|
|
|
LinesToStr([ // statements
|
|
|
- 'rtl.createInterface($mod, "IUnknown", "{00000000-0000-0000-C000-000000000046}", [], null);',
|
|
|
- 'rtl.createClass($mod, "TObject", null, function () {',
|
|
|
+ 'rtl.createInterface(this, "IUnknown", "{00000000-0000-0000-C000-000000000046}", [], null);',
|
|
|
+ 'rtl.createClass(this, "TObject", null, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' };',
|
|
|
' this.$final = function () {',
|
|
|
' };',
|
|
|
'});',
|
|
|
- 'rtl.createInterface($mod, "IBird$G2", "{33AB51C6-6240-3BDF-B4B0-D48A593EAB0A}", ["GetSize", "SetSize", "DoIt"], $mod.IUnknown);',
|
|
|
- 'rtl.createClass($mod, "TBird$G1", $mod.TObject, function () {',
|
|
|
+ 'rtl.createInterface(this, "IBird$G2", "{33AB51C6-6240-3BDF-B4B0-D48A593EAB0A}", ["GetSize", "SetSize", "DoIt"], this.IUnknown);',
|
|
|
+ 'rtl.createClass(this, "TBird$G1", this.TObject, function () {',
|
|
|
' rtl.addIntf(this, $mod.IBird$G2);',
|
|
|
'});',
|
|
|
'this.BirdIntf = null;',
|
|
@@ -1461,9 +1462,9 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGen_ClassInterface_InterfacedObject',
|
|
|
LinesToStr([ // statements
|
|
|
- 'rtl.createInterface($mod, "IComparer$G2", "{505778ED-F783-4456-9691-32F419CC5E18}", ["Compare"], pas.system.IUnknown);',
|
|
|
+ 'rtl.createInterface(this, "IComparer$G2", "{505778ED-F783-4456-9691-32F419CC5E18}", ["Compare"], pas.system.IUnknown);',
|
|
|
'this.aComparer = null;',
|
|
|
- 'rtl.createClass($mod, "TComparer$G1", pas.system.TInterfacedObject, function () {',
|
|
|
+ 'rtl.createClass(this, "TComparer$G1", pas.system.TInterfacedObject, function () {',
|
|
|
' this.Compare = function (Left, Right) {',
|
|
|
' var Result = 0;',
|
|
|
' return Result;',
|
|
@@ -1497,7 +1498,7 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGen_InlineSpec_Constructor',
|
|
|
LinesToStr([ // statements
|
|
|
- 'rtl.createClass($mod, "TObject", null, function () {',
|
|
|
+ 'rtl.createClass(this, "TObject", null, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' };',
|
|
|
' this.$final = function () {',
|
|
@@ -1506,7 +1507,7 @@ begin
|
|
|
' return this;',
|
|
|
' };',
|
|
|
'});',
|
|
|
- 'rtl.createClass($mod, "TBird$G1", $mod.TObject, function () {',
|
|
|
+ 'rtl.createClass(this, "TBird$G1", this.TObject, function () {',
|
|
|
'});',
|
|
|
'this.b = null;',
|
|
|
'']),
|
|
@@ -1546,13 +1547,13 @@ begin
|
|
|
'rtl.module("UnitA", ["system"], function () {',
|
|
|
' var $mod = this;',
|
|
|
' var $impl = $mod.$impl;',
|
|
|
- ' rtl.createClass($mod, "TBird$G1", pas.system.TObject, function () {',
|
|
|
+ ' rtl.createClass(this, "TBird$G1", pas.system.TObject, function () {',
|
|
|
' this.Fly = function () {',
|
|
|
' $impl.DoIt();',
|
|
|
' };',
|
|
|
' });',
|
|
|
' this.b = null;',
|
|
|
- ' rtl.createClass($mod, "TBird$G2", pas.system.TObject, function () {',
|
|
|
+ ' rtl.createClass(this, "TBird$G2", pas.system.TObject, function () {',
|
|
|
' this.Fly = function () {',
|
|
|
' $impl.DoIt();',
|
|
|
' };',
|
|
@@ -1589,13 +1590,13 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGen_IntAssignTemplVar',
|
|
|
LinesToStr([ // statements
|
|
|
- 'rtl.createClass($mod, "TObject", null, function () {',
|
|
|
+ 'rtl.createClass(this, "TObject", null, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' };',
|
|
|
' this.$final = function () {',
|
|
|
' };',
|
|
|
'});',
|
|
|
- 'rtl.createClass($mod, "TBird$G1", $mod.TObject, function () {',
|
|
|
+ 'rtl.createClass(this, "TBird$G1", this.TObject, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' $mod.TObject.$init.call(this);',
|
|
|
' this.m = 0;',
|
|
@@ -1636,14 +1637,14 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGen_TypeCastDotField',
|
|
|
LinesToStr([ // statements
|
|
|
- 'rtl.createClass($mod, "TObject", null, function () {',
|
|
|
+ 'rtl.createClass(this, "TObject", null, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' };',
|
|
|
' this.$final = function () {',
|
|
|
' };',
|
|
|
'});',
|
|
|
'this.o = null;',
|
|
|
- 'rtl.createClass($mod, "TBird$G1", $mod.TObject, function () {',
|
|
|
+ 'rtl.createClass(this, "TBird$G1", this.TObject, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' $mod.TObject.$init.call(this);',
|
|
|
' this.Field = 0;',
|
|
@@ -1682,7 +1683,7 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGen_HelperForArray',
|
|
|
LinesToStr([ // statements
|
|
|
- 'rtl.createHelper($mod, "TWordArrHelper", null, function () {',
|
|
|
+ 'rtl.createHelper(this, "TWordArrHelper", null, function () {',
|
|
|
' this.Fly = function (w) {',
|
|
|
' };',
|
|
|
'});',
|
|
@@ -2013,7 +2014,7 @@ begin
|
|
|
ConvertProgram;
|
|
|
CheckSource('TestGenMethod_ObjFPC',
|
|
|
LinesToStr([ // statements
|
|
|
- 'rtl.createClass($mod, "TObject", null, function () {',
|
|
|
+ 'rtl.createClass(this, "TObject", null, function () {',
|
|
|
' this.$init = function () {',
|
|
|
' };',
|
|
|
' this.$final = function () {',
|
|
@@ -2037,6 +2038,62 @@ begin
|
|
|
'']));
|
|
|
end;
|
|
|
|
|
|
+procedure TTestGenerics.TestGen_Array_OtherUnit;
|
|
|
+begin
|
|
|
+ WithTypeInfo:=true;
|
|
|
+ StartProgram(true,[supTObject]);
|
|
|
+ AddModuleWithIntfImplSrc('UnitA.pas',
|
|
|
+ LinesToStr([
|
|
|
+ 'type',
|
|
|
+ ' generic TDyn<T> = array of T;',
|
|
|
+ ' generic TStatic<T> = array[1..2] of T;',
|
|
|
+ '']),
|
|
|
+ '');
|
|
|
+ AddModuleWithIntfImplSrc('UnitB.pas',
|
|
|
+ LinesToStr([
|
|
|
+ 'uses UnitA;',
|
|
|
+ 'type',
|
|
|
+ ' TAnt = class end;',
|
|
|
+ ' TAntArray = specialize TDyn<TAnt>;',
|
|
|
+ 'procedure Run;',
|
|
|
+ '']),
|
|
|
+ LinesToStr([
|
|
|
+ 'procedure Run;',
|
|
|
+ 'begin',
|
|
|
+ ' if typeinfo(TAntArray)=nil then ;',
|
|
|
+ 'end;',
|
|
|
+ '']));
|
|
|
+ Add([
|
|
|
+ 'uses UnitB;',
|
|
|
+ 'begin',
|
|
|
+ ' Run;',
|
|
|
+ '']);
|
|
|
+ ConvertProgram;
|
|
|
+ CheckUnit('UnitA.pas',
|
|
|
+ LinesToStr([ // statements
|
|
|
+ 'rtl.module("UnitA", ["system"], function () {',
|
|
|
+ ' var $mod = this;',
|
|
|
+ ' this.$rtti.$DynArray("TDyn<UnitB.TAnt>", {});',
|
|
|
+ '});']));
|
|
|
+ CheckUnit('UnitB.pas',
|
|
|
+ LinesToStr([ // statements
|
|
|
+ 'rtl.module("UnitB", ["system", "UnitA"], function () {',
|
|
|
+ ' var $mod = this;',
|
|
|
+ ' rtl.createClass(this, "TAnt", pas.system.TObject, function () {',
|
|
|
+ ' });',
|
|
|
+ ' this.Run = function () {',
|
|
|
+ ' if (pas.UnitA.$rtti["TDyn<UnitB.TAnt>"] === null) ;',
|
|
|
+ ' };',
|
|
|
+ '});']));
|
|
|
+ CheckSource('TestGen_Array_OtherUnit',
|
|
|
+ LinesToStr([ // statements
|
|
|
+ 'pas.UnitA.$rtti["TDyn<UnitB.TAnt>"].eltype = pas.UnitB.$rtti["TAnt"];',
|
|
|
+ '']),
|
|
|
+ LinesToStr([ // $mod.$main
|
|
|
+ ' pas.UnitB.Run();',
|
|
|
+ '']));
|
|
|
+end;
|
|
|
+
|
|
|
procedure TTestGenerics.TestGen_ArrayOfUnitImplRec;
|
|
|
begin
|
|
|
WithTypeInfo:=true;
|
|
@@ -2052,12 +2109,16 @@ begin
|
|
|
' TBird = record',
|
|
|
' b: word;',
|
|
|
' end;',
|
|
|
+ ' TAnt = class end;',
|
|
|
+ ' TAntArray = specialize TDyn<TAnt>;',
|
|
|
'var',
|
|
|
' d: specialize TDyn<TBird>;',
|
|
|
' s: specialize TStatic<TBird>;',
|
|
|
+ ' p: pointer;',
|
|
|
'begin',
|
|
|
' d[0].b:=s[1].b;',
|
|
|
' s:=s;',
|
|
|
+ ' p:=typeinfo(TAntArray);',
|
|
|
'']));
|
|
|
Add([
|
|
|
'uses UnitA;',
|
|
@@ -2069,13 +2130,14 @@ begin
|
|
|
'rtl.module("UnitA", ["system"], function () {',
|
|
|
' var $mod = this;',
|
|
|
' var $impl = $mod.$impl;',
|
|
|
- ' $mod.$rtti.$DynArray("TDyn<UnitA.TBird>", {});',
|
|
|
+ ' this.$rtti.$DynArray("TDyn<UnitA.TAnt>", {});',
|
|
|
+ ' this.$rtti.$DynArray("TDyn<UnitA.TBird>", {});',
|
|
|
' this.TStatic$G1$clone = function (a) {',
|
|
|
' var r = [];',
|
|
|
' for (var i = 0; i < 2; i++) r.push($impl.TBird.$clone(a[i]));',
|
|
|
' return r;',
|
|
|
' };',
|
|
|
- ' $mod.$rtti.$StaticArray("TStatic<UnitA.TBird>", {',
|
|
|
+ ' this.$rtti.$StaticArray("TStatic<UnitA.TBird>", {',
|
|
|
' dims: [2]',
|
|
|
' });',
|
|
|
' $mod.$implcode = function () {',
|
|
@@ -2091,16 +2153,21 @@ begin
|
|
|
' var $r = $mod.$rtti.$Record("TBird", {});',
|
|
|
' $r.addField("b", rtl.word);',
|
|
|
' });',
|
|
|
+ ' rtl.createClass($impl, "TAnt", pas.system.TObject, function () {',
|
|
|
+ ' });',
|
|
|
' $impl.d = [];',
|
|
|
' $impl.s = rtl.arraySetLength(null, $impl.TBird, 2);',
|
|
|
+ ' $impl.p = null;',
|
|
|
' };',
|
|
|
' $mod.$init = function () {',
|
|
|
' $impl.d[0].b = $impl.s[0].b;',
|
|
|
' $impl.s = $mod.TStatic$G1$clone($impl.s);',
|
|
|
+ ' $impl.p = $mod.$rtti["TDyn<UnitA.TAnt>"];',
|
|
|
' };',
|
|
|
'}, []);']));
|
|
|
- CheckSource('TestGen_Class_ClassVarRecord_UnitImpl',
|
|
|
+ CheckSource('TestGen_ArrayOfUnitImplRec',
|
|
|
LinesToStr([ // statements
|
|
|
+ 'pas.UnitA.$rtti["TDyn<UnitA.TAnt>"].eltype = pas.UnitA.$rtti["TAnt"];',
|
|
|
'pas.UnitA.$rtti["TDyn<UnitA.TBird>"].eltype = pas.UnitA.$rtti["TBird"];',
|
|
|
'pas.UnitA.$rtti["TStatic<UnitA.TBird>"].eltype = pas.UnitA.$rtti["TBird"];',
|
|
|
'']),
|
|
@@ -2195,7 +2262,7 @@ begin
|
|
|
'rtl.module("UnitA", ["system"], function () {',
|
|
|
' var $mod = this;',
|
|
|
' var $impl = $mod.$impl;',
|
|
|
- ' $mod.$rtti.$ProcVar("TAnt<UnitA.TBird>", {',
|
|
|
+ ' this.$rtti.$ProcVar("TAnt<UnitA.TBird>", {',
|
|
|
' init: function () {',
|
|
|
' this.procsig = rtl.newTIProcSig([["a", $mod.$rtti["TBird"], 2]], $mod.$rtti["TBird"]);',
|
|
|
' }',
|