Pas2JS pascal source code
type
TProc = procedure;
type
IMY = interface
procedure Dummy;
end;
type
TMy = class(IMy)
procedure Dummy;
begin
end;
class procedure CDummy;
begin
end;
end;
procedure test;
begin
{ just to test it out }
end;
{ unit1.pas }
var
m := New TMy;
i := m;
a: array of TProc;
begin
a.add(test);
a.Add(TMy.CDummy);
a.Add(m.Dummy);
a.Add(i.Dummy);
Writeln(a.IndexOf(test)); // 0
Writeln(a.IndexOf(nil)); // -1
Writeln(a.IndexOf(@test)); // 0
Writeln(a.IndexOf(TMy.CDummy)); // 1
Writeln(a.IndexOf(m.Dummy)); // 2
Writeln(a.IndexOf(i.Dummy)); // 2
Writeln(a.IndexOf(i.Dummy, 3)); // 3
function $Event0(i,f) {
var li=i,lf=f;
return function() {
return lf.call(li,li)
}
}
var m = null,
m = TObject.Create($New(TMy));
var i = null,
i = m;
var a = [];
a.push(test);
a.push($Event0(TMy,TMy.CDummy));
a.push($Event0(m,TMy.Dummy));
a.push($Event0(i,TMy.Dummy));
WriteLn(a.indexOf(test));
WriteLn(a.indexOf(null));
WriteLn(a.indexOf(test));
WriteLn(a.indexOf($Event0(TMy,TMy.CDummy)));
WriteLn(a.indexOf($Event0(m,TMy.Dummy)));
WriteLn(a.indexOf($Event0(i,TMy.Dummy)));
WriteLn(a.indexOf($Event0(i,TMy.Dummy),3));
function test() {
/* null */
};
var TMy = {
$ClassName:"TMy",$Parent:TObject
,$Init:function ($) {
TObject.$Init($);
}
,Dummy:function(Self) {
/* null */
}
,CDummy:function(Self) {
/* null */
}
,Destroy:TObject.Destroy
};
TMy.$Intf={
IMY:[TMy.Dummy]
}