相当于ffi的新手,寻求帮助,通过ffi将这个c / c声明编码为lua .
我读取代码的方式,我有一个函数,指向函数的指针作为传递的参数之一 . 我可能完全错了,我确实说我是新手!
这是typedef:
ffi.cdef[[typedef void (* XPLMReceiveMonitorBoundsGlobal_f)(
int inMonitorIndex,
int inLeftBx,
int inTopBx,
int inRightBx,
int inBottomBx,
void * inRefcon);]]
这是函数定义:
ffi.cdef("void XPLMGetAllMonitorBoundsGlobal(XPLMReceiveMonitorBoundsGlobal_f inMonitorBoundsCallback, void * inRefcon)")
我试图猜测如何使用我想象中的任何东西在lua中编码大约4个小时,例如:
XPLM.XPLMGetAllMonitorBoundsOS(XPLMReceiveMonitorBoundsOS_f(monindex, leftpx, toppx, rightpx, bottompx, nil), nil)
XPLM.XPLMGetAllMonitorBoundsOS(), nil)
我没有想到任何工作,谷歌搜索和大量的阅读并没有让我更接近答案 .
编码是针对XPlane飞行模拟器中的lua应用程序,我得到的错误最接近的是:
"attempt to call global 'XPLMReceiveMonitorBoundsOS_f' (a nil value)"
也许我必须通过ffi.new(),ffi.cast()等来定义一些东西,不管它是什么我当然没有想出答案 .
任何帮助非常感谢 .
伊恩