|
@@ -637,14 +637,14 @@ type
|
|
|
Procedure TestClassHelper_MethodRefObjFPC;
|
|
|
Procedure TestClassHelper_Constructor;
|
|
|
Procedure TestClassHelper_InheritedObjFPC;
|
|
|
- //Procedure TestClassHelper_InheritedDelphi;
|
|
|
- // todo: TestClassHelper_Property
|
|
|
+ Procedure TestClassHelper_Property;
|
|
|
// todo: TestClassHelper_Property_Array
|
|
|
// todo: TestClassHelper_Property_Index
|
|
|
// todo: TestClassHelper_ClassProperty
|
|
|
// todo: TestClassHelper_ClassProperty_Array
|
|
|
// todo: TestClassHelper_ClassProperty_Index
|
|
|
// todo: TestClassHelper_Overload
|
|
|
+ // todo: TestClassHelper_ForIn
|
|
|
// todo: TestRecordHelper_ClassVar
|
|
|
// todo: TestRecordHelper_Method
|
|
|
// todo: TestRecordHelper_ClassMethod
|
|
@@ -19303,11 +19303,11 @@ begin
|
|
|
' end;',
|
|
|
' TBirdHelper = class helper for TBird',
|
|
|
' procedure Fly;',
|
|
|
- ' procedure Walk;',
|
|
|
+ ' procedure Walk(w: word);',
|
|
|
' end;',
|
|
|
' TEagleHelper = class helper(TBirdHelper) for TBird',
|
|
|
' procedure Fly;',
|
|
|
- ' procedure Walk;',
|
|
|
+ ' procedure Walk(w: word);',
|
|
|
' end;',
|
|
|
'procedure Tobject.fly;',
|
|
|
'begin',
|
|
@@ -19328,7 +19328,7 @@ begin
|
|
|
' {@TBird_Fly}inherited;',
|
|
|
' inherited {@TBird_Fly}Fly;',
|
|
|
'end;',
|
|
|
- 'procedure Tbirdhelper.walk;',
|
|
|
+ 'procedure Tbirdhelper.walk(w: word);',
|
|
|
'begin',
|
|
|
'end;',
|
|
|
'procedure teagleHelper.fly;',
|
|
@@ -19336,10 +19336,10 @@ begin
|
|
|
' {@TBird_Fly}inherited;',
|
|
|
' inherited {@TBird_Fly}Fly;',
|
|
|
'end;',
|
|
|
- 'procedure teagleHelper.walk;',
|
|
|
+ 'procedure teagleHelper.walk(w: word);',
|
|
|
'begin',
|
|
|
' {@TBirdHelper_Walk}inherited;',
|
|
|
- ' inherited {@TBirdHelper_Walk}Walk;',
|
|
|
+ ' inherited {@TBirdHelper_Walk}Walk(3);',
|
|
|
'end;',
|
|
|
'begin',
|
|
|
'']);
|
|
@@ -19371,7 +19371,7 @@ begin
|
|
|
' $mod.TBird.Fly$1.call(this);',
|
|
|
' $mod.TBird.Fly$1.call(this);',
|
|
|
' };',
|
|
|
- ' this.Walk = function () {',
|
|
|
+ ' this.Walk = function (w) {',
|
|
|
' };',
|
|
|
'});',
|
|
|
'rtl.createHelper($mod, "TEagleHelper", $mod.TBirdHelper, function () {',
|
|
@@ -19379,13 +19379,158 @@ begin
|
|
|
' $mod.TBird.Fly$1.call(this);',
|
|
|
' $mod.TBird.Fly$1.call(this);',
|
|
|
' };',
|
|
|
- ' this.Walk$1 = function () {',
|
|
|
- ' $mod.TBirdHelper.Walk.call(this);',
|
|
|
- ' $mod.TBirdHelper.Walk.call(this);',
|
|
|
+ ' this.Walk$1 = function (w) {',
|
|
|
+ ' $mod.TBirdHelper.Walk.apply(this, arguments);',
|
|
|
+ ' $mod.TBirdHelper.Walk.call(this, 3);',
|
|
|
+ ' };',
|
|
|
+ '});',
|
|
|
+ '']),
|
|
|
+ LinesToStr([ // $mod.$main
|
|
|
+ '']));
|
|
|
+end;
|
|
|
+
|
|
|
+procedure TTestModule.TestClassHelper_Property;
|
|
|
+begin
|
|
|
+ StartProgram(false);
|
|
|
+ Add([
|
|
|
+ 'type',
|
|
|
+ ' TObject = class',
|
|
|
+ ' FSize: word;',
|
|
|
+ ' function GetSpeed: word;',
|
|
|
+ ' procedure SetSpeed(Value: word);',
|
|
|
+ ' end;',
|
|
|
+ ' TObjHelper = class helper for TObject',
|
|
|
+ ' function GetLeft: word;',
|
|
|
+ ' procedure SetLeft(Value: word);',
|
|
|
+ ' property Size: word read FSize write FSize;',
|
|
|
+ ' property Speed: word read GetSpeed write SetSpeed;',
|
|
|
+ ' property Left: word read GetLeft write SetLeft;',
|
|
|
+ ' end;',
|
|
|
+ ' TBird = class',
|
|
|
+ ' property NotRight: word read GetLeft write SetLeft;',
|
|
|
+ ' procedure DoIt;',
|
|
|
+ ' end;',
|
|
|
+ 'var',
|
|
|
+ ' b: TBird;',
|
|
|
+ 'function Tobject.GetSpeed: word;',
|
|
|
+ 'begin',
|
|
|
+ ' Size:=Size+11;',
|
|
|
+ ' Speed:=Speed+12;',
|
|
|
+ ' Result:=Left+13;',
|
|
|
+ ' Left:=13;',
|
|
|
+ ' Left:=Left+13;',
|
|
|
+ ' Self.Size:=Self.Size+21;',
|
|
|
+ ' Self.Speed:=Self.Speed+22;',
|
|
|
+ ' Self.Left:=Self.Left+23;',
|
|
|
+ ' with Self do begin',
|
|
|
+ ' Size:=Size+31;',
|
|
|
+ ' Speed:=Speed+32;',
|
|
|
+ ' Left:=Left+33;',
|
|
|
+ ' end;',
|
|
|
+ 'end;',
|
|
|
+ 'procedure Tobject.SetSpeed(Value: word);',
|
|
|
+ 'begin',
|
|
|
+ 'end;',
|
|
|
+ 'function TObjHelper.GetLeft: word;',
|
|
|
+ 'begin',
|
|
|
+ ' Size:=Size+11;',
|
|
|
+ ' Speed:=Speed+12;',
|
|
|
+ ' Left:=Left+13;',
|
|
|
+ ' Self.Size:=Self.Size+21;',
|
|
|
+ ' Self.Speed:=Self.Speed+22;',
|
|
|
+ ' Self.Left:=Self.Left+23;',
|
|
|
+ ' with Self do begin',
|
|
|
+ ' Size:=Size+31;',
|
|
|
+ ' Speed:=Speed+32;',
|
|
|
+ ' Left:=Left+33;',
|
|
|
+ ' end;',
|
|
|
+ 'end;',
|
|
|
+ 'procedure TObjHelper.SetLeft(Value: word);',
|
|
|
+ 'begin',
|
|
|
+ 'end;',
|
|
|
+ 'procedure TBird.DoIt;',
|
|
|
+ 'begin',
|
|
|
+ ' NotRight:=NotRight+11;',
|
|
|
+ ' Self.NotRight:=Self.NotRight+21;',
|
|
|
+ ' with Self do begin',
|
|
|
+ ' NotRight:=NotRight+31;',
|
|
|
+ ' end;',
|
|
|
+ 'end;',
|
|
|
+ 'begin',
|
|
|
+ ' b.Size:=b.Size+11;',
|
|
|
+ ' b.Speed:=b.Speed+12;',
|
|
|
+ ' b.Left:=b.Left+13;',
|
|
|
+ ' b.NotRight:=b.NotRight+14;',
|
|
|
+ ' with b do begin',
|
|
|
+ ' Size:=Size+31;',
|
|
|
+ ' Speed:=Speed+32;',
|
|
|
+ ' Left:=Left+33;',
|
|
|
+ ' NotRight:=NotRight+34;',
|
|
|
+ ' end;',
|
|
|
+ '']);
|
|
|
+ ConvertProgram;
|
|
|
+ CheckSource('TestClassHelper_Property',
|
|
|
+ LinesToStr([ // statements
|
|
|
+ 'rtl.createClass($mod, "TObject", null, function () {',
|
|
|
+ ' this.$init = function () {',
|
|
|
+ ' this.FSize = 0;',
|
|
|
+ ' };',
|
|
|
+ ' this.$final = function () {',
|
|
|
+ ' };',
|
|
|
+ ' this.GetSpeed = function () {',
|
|
|
+ ' var Result = 0;',
|
|
|
+ ' this.FSize = this.FSize + 11;',
|
|
|
+ ' this.SetSpeed(this.GetSpeed() + 12);',
|
|
|
+ ' Result = $mod.TObjHelper.GetLeft.apply(this) + 13;',
|
|
|
+ ' $mod.TObjHelper.SetLeft.apply(this, 13);',
|
|
|
+ ' $mod.TObjHelper.SetLeft.apply(this, $mod.TObjHelper.GetLeft.apply(this) + 13);',
|
|
|
+ ' this.FSize = this.FSize + 21;',
|
|
|
+ ' this.SetSpeed(this.GetSpeed() + 22);',
|
|
|
+ ' $mod.TObjHelper.SetLeft.apply(this, $mod.TObjHelper.GetLeft.apply(this) + 23);',
|
|
|
+ ' this.FSize = this.FSize + 31;',
|
|
|
+ ' this.SetSpeed(this.GetSpeed() + 32);',
|
|
|
+ ' $mod.TObjHelper.SetLeft.apply(this, $mod.TObjHelper.GetLeft.apply(this) + 33);',
|
|
|
+ ' return Result;',
|
|
|
+ ' };',
|
|
|
+ ' this.SetSpeed = function (Value) {',
|
|
|
+ ' };',
|
|
|
+ '});',
|
|
|
+ 'rtl.createHelper($mod, "TObjHelper", null, function () {',
|
|
|
+ ' this.GetLeft = function () {',
|
|
|
+ ' var Result = 0;',
|
|
|
+ ' this.FSize = this.FSize + 11;',
|
|
|
+ ' this.SetSpeed(this.GetSpeed() + 12);',
|
|
|
+ ' $mod.TObjHelper.SetLeft.apply(this, $mod.TObjHelper.GetLeft.apply(this) + 13);',
|
|
|
+ ' this.FSize = this.FSize + 21;',
|
|
|
+ ' this.SetSpeed(this.GetSpeed() + 22);',
|
|
|
+ ' $mod.TObjHelper.SetLeft.apply(this, $mod.TObjHelper.GetLeft.apply(this) + 23);',
|
|
|
+ ' this.FSize = this.FSize + 31;',
|
|
|
+ ' this.SetSpeed(this.GetSpeed() + 32);',
|
|
|
+ ' $mod.TObjHelper.SetLeft.apply(this, $mod.TObjHelper.GetLeft.apply(this) + 33);',
|
|
|
+ ' return Result;',
|
|
|
+ ' };',
|
|
|
+ ' this.SetLeft = function (Value) {',
|
|
|
+ ' };',
|
|
|
+ '});',
|
|
|
+ 'rtl.createClass($mod, "TBird", $mod.TObject, function () {',
|
|
|
+ ' this.DoIt = function () {',
|
|
|
+ ' $mod.TObjHelper.SetLeft.apply(this, $mod.TObjHelper.GetLeft.apply(this) + 11);',
|
|
|
+ ' $mod.TObjHelper.SetLeft.apply(this, $mod.TObjHelper.GetLeft.apply(this) + 21);',
|
|
|
+ ' $mod.TObjHelper.SetLeft.apply(this, $mod.TObjHelper.GetLeft.apply(this) + 31);',
|
|
|
' };',
|
|
|
'});',
|
|
|
+ 'this.b = null;',
|
|
|
'']),
|
|
|
LinesToStr([ // $mod.$main
|
|
|
+ '$mod.b.FSize = $mod.b.FSize + 11;',
|
|
|
+ '$mod.b.SetSpeed($mod.b.GetSpeed() + 12);',
|
|
|
+ '$mod.TObjHelper.SetLeft.apply($mod.b, $mod.TObjHelper.GetLeft.apply($mod.b) + 13);',
|
|
|
+ '$mod.TObjHelper.SetLeft.apply($mod.b, $mod.TObjHelper.GetLeft.apply($mod.b) + 14);',
|
|
|
+ 'var $with1 = $mod.b;',
|
|
|
+ '$with1.FSize = $with1.FSize + 31;',
|
|
|
+ '$with1.SetSpeed($with1.GetSpeed() + 32);',
|
|
|
+ '$mod.TObjHelper.SetLeft.apply($with1, $mod.TObjHelper.GetLeft.apply($with1) + 33);',
|
|
|
+ '$mod.TObjHelper.SetLeft.apply($with1, $mod.TObjHelper.GetLeft.apply($with1) + 34);',
|
|
|
'']));
|
|
|
end;
|
|
|
|