我正在尝试使用超级对象在类中调用一个过程,但它不起作用,我在这里做错了什么?
代码示例:
program test_rpc;
{$IFDEF FPC}
{$MODE OBJFPC}{$H+}
{$ELSE}
{$APPTYPE CONSOLE}
{$ENDIF}
uses
SysUtils, superobject;
type
TCC = class(TObject)
published
procedure controler_method1(const This, Params: ISuperObject; var Result: ISuperObject);
end;
procedure TCC.controler_method1(const This, Params: ISuperObject; var Result: ISuperObject);
var
i: Integer;
begin
write('action called with params ');
writeln(Params.AsString);
end;
var
s: ISuperObject;
CC: TCC;
begin
CC := TCC.Create;
s := TSuperObject.Create;
s.M['controler.action1'] := CC.MethodAddress('controler_method1');
try
s['controler.action1("HHAHAH")'];
finally
s := nil;
writeln('Press enter ...');
readln;
end;
end.
那会崩溃,我在这里做错了什么?
它实际上是“用参数调用的动作”,但没有显示参数......