Smart pascal source code
function CreateElement: TObject;
begin
Result := new TObject;
end;
Type
TComponent = Class(TObject)
Private
FObjRef: TObject;
Public
Property Handle: TObject read FObjRef;
Constructor Create(AOwner: TComponent); virtual;
End;
Constructor TComponent.Create(AOwner: TComponent);
Begin
FObjRef := CreateElement;
end;
Type
TCustomControl = Class(TComponent)
public
Constructor Create(AOwner: TComponent); override;
End;
Constructor TCustomControl.Create(AOwner: TComponent);
Begin
if assigned(Handle) then
writeln('We have a handle')
else
writeln('We dont have a handle');
end;
Type
TCustomControl2 = Class(TComponent)
public
Constructor Create(AOwner: TComponent); override;
End;
Constructor TCustomControl2.Create(AOwner: TComponent);
Begin
inherited Create(AOwner);
if assigned(Handle) then
writeln('We have a handle')
else
writeln('We dont have a handle');
end;
var mObj: TComponent;
mObj := TCustomControl.Create(NIL);
mObj := TCustomControl2.Create(NIL);
{<<< RESULT - CONSOLE LOG >>>
-----------------------------
Errors >>>>
Hint: "createElement" does not match case of declaration ("CreateElement") [line: 17, column: 12]
Hint: "assigned" does not match case of declaration ("Assigned") [line: 28, column: 6]
Hint: "println" does not match case of declaration ("PrintLn") [line: 29, column: 3]
Hint: "println" does not match case of declaration ("PrintLn") [line: 30, column: 3]
Hint: "assigned" does not match case of declaration ("Assigned") [line: 42, column: 6]
Hint: "println" does not match case of declaration ("PrintLn") [line: 43, column: 3]
Hint: "println" does not match case of declaration ("PrintLn") [line: 44, column: 3]
Result >>>>
We dont have a handle
We have a handle
-----------------------------
{<<<<<<<<< THE END >>>>>>>>>}
var TComponent = {
$ClassName:"TComponent",$Parent:TObject
,$Init:function ($) {
TObject.$Init($);
$.FObjRef = null;
}
,Create$3:function(Self, AOwner) {
$Check(Self,"").FObjRef = CreateElement();
return Self
}
,Destroy:TObject.Destroy
,Create$3$:function($){return $.ClassType.Create$3.apply($.ClassType, arguments)}
};
var TCustomControl2 = {
$ClassName:"TCustomControl2",$Parent:TComponent
,$Init:function ($) {
TComponent.$Init($);
}
,Create$3:function(Self, AOwner$1) {
TComponent.Create$3(Self,AOwner$1);
if ($Check(Self,"").FObjRef) {
WriteLn("We have a handle");
} else {
WriteLn("We dont have a handle");
}
return Self
}
,Destroy:TObject.Destroy
,Create$3$:function($){return $.ClassType.Create$3.apply($.ClassType, arguments)}
};
var TCustomControl = {
$ClassName:"TCustomControl",$Parent:TComponent
,$Init:function ($) {
TComponent.$Init($);
}
,Create$3:function(Self, AOwner$2) {
if ($Check(Self,"").FObjRef) {
WriteLn("We have a handle");
} else {
WriteLn("We dont have a handle");
}
return Self
}
,Destroy:TObject.Destroy
,Create$3$:function($){return $.ClassType.Create$3.apply($.ClassType, arguments)}
};
function CreateElement() {
return TObject.Create($New(TObject));
};
var mObj$4 = null;
/* <<< main JS >>> */
mObj$4 = TComponent.Create$3$($New(TCustomControl),null);
mObj$4 = TComponent.Create$3$($New(TCustomControl2),null);