[英]Check if function is in C or Lua implemented
I've created a table and assigned a method with lua_pushcfunction
named mytable:myfunction()
. 我创建了一个表,并使用名为
mytable:myfunction()
lua_pushcfunction
分配了一个方法。 In a different (callback) context it's necessarily that myfunction
will be overriden inside the Lua script. 在不同的(回调)上下文中,
myfunction
在Lua脚本中覆盖myfunction
。 For some reasons, if i call myfunction
from the C host, I need to know, if myfunction
is still the c function or was replaced by the script. 出于某些原因,如果我从C主机调用
myfunction
,我需要知道,如果myfunction
仍然是c函数或被脚本替换。
Is there a way to test (from C), if the C method is still attached or is replaced by some Lua code ? 有没有办法测试(从C),如果C方法仍然附加或被一些Lua代码替换?
是的,你可以使用lua_iscfunction
。
Another possibility is to use lua_tocfunction
. 另一种可能性是使用
lua_tocfunction
。 This allows you to also check if the C function you got back is the one you expect. 这允许您还检查您获得的C函数是否是您期望的函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.