Code:
program cmd;
{$APPTYPE CONSOLE}
uses SysUtils,Chip;
function _Open(const fileName:string):integer;stdcall;
begin
Result:=FileOpen(fileName,fmOpenRead)
end;
function _Read(handle:integer; count:integer):string;stdcall;
var buf:string;
begin
SetLength(buf,count);
count:=FileRead(handle,buf[1],count);
if count<0 then
Result:=''
else begin
SetLength(buf,count);
Result:=buf
end
end;
procedure _Close(handle:integer);stdcall;
begin
FileClose(handle)
end;
procedure _Test(a,b,c,d,e:integer);
begin
WriteLn(Format('a=%d b=%d c=%d d=%d e=%d',[a,b,c,d,e]))
end;
type
TMBasic=class(TBasic)
private
counter:integer;
protected
function Hallo:integer;
end;
function TMBasic.Hallo;
begin
inc(counter);
Result:=counter
end;
var scr,scr2:TMBasic;
var m:TMethod;
type tf=procedure of object;
type tp=function:integer of object;
var p:tp;
var pf:tf;
var p1:pointer;
begin
_Test(1,2,3,4,5);
scr:=TMBasic.Create;
scr2:=TMBasic.Create;
try
scr.Map('System.Open',vkHandle or vkStdCall,chr(vkConst or vkString),@_Open);
scr.Map('System.Read',vkString or vkStdCall,chr(vkHandle)+chr(vkInteger),@_Read);
scr.Map('System.Close',vkNone or vkStdCall,chr(vkHandle),@_Close);
scr.Map('Test',vkNone,chr(vkInteger)+chr(vkInteger)+chr(vkInteger)+chr(vkInteger)+chr(vkInteger),@_Test);
scr.MapMethod('Hi',vkInteger,'',scr,@TMBasic.Hallo);
scr.MapMethod('Hi2',vkInteger,'',scr2,@TMBasic.Hallo);
// scr.MapMethod('TObject.Free',vkNone,[vkHandle],TObject,@TObject.Free);
// pf:=tf(TMethod(@scr.Hallo));
{ p:=tp(@scr.Hallo);
p1:=@scr.Hallo;
m:=TMethod(tp(@scr.Hallo));
scr.MapMethod('Hi',vkInteger,[vkNone],TMethod(@scr.Hallo));}
// scr.Map('Hi',vkInteger or vkSelfMethod,[vkNone],@TMBasic.Hallo);
scr.Run('')
finally
scr.Free;
scr2.Free
end
end.
Good night, I go to sleep, too ...
Bookmarks