Function 将delphi函数自动注册到Lua

Function 将delphi函数自动注册到Lua,function,oop,delphi,lua,registering,Function,Oop,Delphi,Lua,Registering,我正在为Lua脚本扩展delphi应用程序。我想知道是否有办法自动注册我所有的对象函数? 我知道当我想注册某个函数时,它必须是luaCFunction。 我得到了这样的东西: function RegisterMyPersonFunction(l : PLua_State) : Integer; cdecl; var person : TLuaPerson; Age: Integer; begin if (lua_gettop(l) < 1) then ex

我正在为Lua脚本扩展delphi应用程序。我想知道是否有办法自动注册我所有的对象函数? 我知道当我想注册某个函数时,它必须是luaCFunction。 我得到了这样的东西:

function RegisterMyPersonFunction(l : PLua_State) : Integer; cdecl;
var
  person : TLuaPerson;    
  Age: Integer;
begin

  if (lua_gettop(l) < 1) then 
    exit;

  person := TLuaPerson(LuaToTLuaObject(l, 1)); 
  Age:=luaL_checkinteger(l,2);
  person.SetAge(Age);
  result := 0;

end;
函数寄存器TypersonFunction(l:PLua\u状态):整数;cdecl;
变量
个人:TLuaPerson;
年龄:整数;
开始
如果(lua_gettop(l)<1),那么
出口
person:=TLuaPerson(luattluaobject(l,1));
年龄:=luaL_checkinteger(l,2);
人.体位(年龄);
结果:=0;
结束;
我想要的是,我不想为每个函数编写我自己的函数,就像这样。有没有办法将所有这些函数从delphi对象注册到lua? 我在用这个


感谢您的帮助。

编写一个工具,从列出要注册的函数的文本文件中生成注册码。我不确定我是否理解您的意思……您能更具体一点,或者您能给我一些简单的例子吗?@larkone-换句话说,您需要编写一个程序来为您编写程序。