Check if C or Lua function is enabled

I created a table and assigned a method with lua_pushcfunction called mytable:myfunction() . In another (reverse) context, it is imperative that myfunction be overridden inside a Lua script. For some reason, if I call myfunction from host C, I need to know if myfunction is still a c-function or replaced with a script.

Is there a way to check (from C) if the C method is still connected or replaced with some Lua code?

+6
source share
2 answers

Yes, you can use lua_iscfunction .

+7
source

Another possibility is to use lua_tocfunction . It also allows you to check if the C function you are expecting has returned.

0
source

Source: https://habr.com/ru/post/951544/


All Articles