[Pas2js] Class constant with "external" class
warleyalex
warleyalex at yahoo.com.br
Sat Jan 27 13:30:21 CET 2018
It seems when I use "class const" the code completion stop working :(
------------------------------------------------------------------
Class variables basically means that you can define a variable (or multiple
variables) in a class that can be altered regardless of an instance
construction. This is a handy technique for setting conditions before an
object is created from the class prototype.
--------------
TMyClass = Class(TObject)
Public
class var driverMode: Integer;
class var cPublic: String;
class const cTemp = '{"page:about2"}';
End;
TMyClass.driverMode:=1200;
TMyClass.cPublic := '{"name":"warleyx"}';
console.log(TMyClass.cTemp);
----------
JS output:
//------------------------------------------------------------------
rtl.createClass($mod,"TMyClass",pas.System.TObject,function () {
this.driverMode = 0;
this.cPublic$1 = "";
this.cTemp$1 = '{"page:about2"}';
});
$mod.$main = function () {
$mod.TMyClass.driverMode = 1200;
$mod.TMyClass.cPublic$1 = '{"name":"warleyx"}';
window.console.log($mod.TMyClass.cTemp$1);
};
//-------------------------------------------------------------------
class variable with "regular" classes, I believe is working as expected!
class variable with "external" classes, I think should be a handy technique
for setting conditions "before" an object is created from the class
prototype.
type
TBase = class external name 'TBase' (TJSObject)
public
//class var cPublic : String = '{"name":"warleyx"}';
class var cPublic : String;
class const cTemp = '{"page:about2"}';
end;
so I think the compiler should emit this:
//----------------------------------------
this.cPublic = "";
this.cTemp = "{\"page\":\"about2\"}";
$mod.$main = function () {
$mod.cPublic = "abcdef";
window.console.log($mod.cPublic);
window.console.log($mod.cTemp);
};
//----------------------------------------
--
Sent from: http://pas2js.38893.n8.nabble.com/
More information about the Pas2js
mailing list