[Pas2js] Subclassing TJSArray
Ryan Joseph
ryan at thealchemistguild.com
Fri May 11 11:47:49 CEST 2018
I was curious if I could subclass an array without it being external but I got a compile error as seen below. If I move Get/SetElements to public then it compiles but the JavaScript seems wrong. Bugs or not implemented yet?
========
type
TVec2 = class (TJSArray)
private
procedure SetX (newValue: GLfloat);
procedure SetY (newValue: GLfloat);
function GetX: GLfloat;
function GetY: GLfloat;
public
property x: GLfloat read GetX write SetX;
property y: GLfloat read GetY write SetY;
end;
procedure TVec2.SetX (newValue: GLfloat);
begin
SetElements(0, newValue);
end;
procedure TVec2.SetY (newValue: GLfloat);
begin
SetElements(1, newValue);
end;
function TVec2.GetX: GLfloat;
begin
result := GLfloat(GetElements(0)); // Illegal type conversion: "set" to "Double"
end;
function TVec2.GetY: GLfloat;
begin
result := GLfloat(GetElements(1));
end;
v := TVec2.new(2);
v.x := 100;
v.y := 200;
======
this.SetX = function (newValue) {
this[](0,newValue); // ERROR HERE
};
this.SetY = function (newValue) {
this[](1,newValue);
};
Regards,
Ryan Joseph
More information about the Pas2js
mailing list