rotable.h 850 B

1234567891011121314151617181920212223242526272829
  1. #ifndef ROTABLE_H_
  2. #define ROTABLE_H_
  3. #include "lua.h"
  4. /* exactly the same as luaL_Reg, but since we are on small embedded
  5. * microcontrollers, we don't assume that you have `lauxlib.h`
  6. * available in your build! */
  7. typedef struct rotable_Reg {
  8. char const* name;
  9. lua_CFunction func;
  10. lua_Integer value;
  11. } rotable_Reg;
  12. #ifndef ROTABLE_EXPORT
  13. # define ROTABLE_EXPORT extern
  14. #endif
  15. /* compatible with `luaL_newlib()`, and works with `luaL_Reg` *and*
  16. * `rotable_Reg` arrays (in case you don't use `lauxlib.h`) */
  17. ROTABLE_EXPORT void rotable_newlib( lua_State* L, void const* reg );
  18. /* Since userdatas can not be used as `__index` meta methods directly
  19. * this function creates a C closure that looks up keys in a given
  20. * `rotable_Reg` array. */
  21. ROTABLE_EXPORT void rotable_newidx( lua_State* L, void const* reg );
  22. #endif /* ROTABLE_H_ */