registerFunction method

void registerFunction(
  1. String name,
  2. Pointer<NativeFunction<Int32 Function(Pointer<lua_State>)>> fn
)

Implementation

void registerFunction(
  String name,
  Pointer<NativeFunction<Int32 Function(Pointer<lua_State>)>> fn,
) {
  // cast the function pointer to lua_CFunction
  lua.lua_pushcclosure(L, fn as lua_CFunction, 0);
  lua.lua_setglobal(L, name.toNativeUtf8().cast());
}