luaReg.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #ifndef __LUR_REG__
  2. #define __LUR_REG__
  3. #pragma once
  4. extern "C" {
  5. #include "lua.h"
  6. #include "lualib.h"
  7. #include "lauxlib.h"
  8. }
  9. #ifdef _DEBUG
  10. #pragma comment(lib,"lua5.3d.lib")
  11. #else
  12. #pragma comment(lib,"lua5.3.lib")
  13. #endif
  14. /************************************************************************/
  15. /* 函数:[1/15/2018 Jeff];
  16. /* 描述:;
  17. /* 参数:;
  18. /* [IN] :;
  19. /* [OUT] :;
  20. /* [IN/OUT] :;
  21. /* 返回:void;
  22. /* 注意:;
  23. /* 示例:;
  24. /*
  25. /* 修改:;
  26. /* 日期:;
  27. /* 内容:;
  28. /************************************************************************/
  29. int StackDump(lua_State* luaVM);
  30. int lua_create_aos(lua_State *luaVM);
  31. // 自动内存回收;
  32. int lua_auto_gc(lua_State *luaVM);
  33. //////////////////////////////////////////////////////////////////////////
  34. // 成员函数全局化,给lua脚本调用;
  35. int lua_InitClient(lua_State *luaVM);
  36. int lua_IsObjectUploaded(lua_State *luaVM);
  37. int lua_PutObjectFromFile(lua_State *luaVM);
  38. int lua_GetObject(lua_State *luaVM);
  39. int lua_DeleteObject(lua_State *luaVM);
  40. int lua_newArray();
  41. int lua_GetListAllObjects(lua_State *luaVM);
  42. //////////////////////////////////////////////////////////////////////////
  43. // 要注册lua中的全局成员函数;
  44. static const luaL_Reg g_member_funs[] = {
  45. { "__gc", lua_auto_gc },
  46. // { "new_array", lua_newArray},
  47. // { "set_array", NULL},
  48. // { "get_array", NULL },
  49. // { "size_array", NULL },
  50. { NULL, NULL }
  51. };
  52. // 要注册到lua中的全局构造函数;
  53. static const luaL_Reg g_constructor_funs[] = {
  54. { "create", lua_create_aos },
  55. { NULL, NULL }
  56. };
  57. // 将函数注册到lua环境中;
  58. int lua_regFuns(lua_State *luaVM);
  59. // 要注册的lua中的模块;
  60. static const luaL_Reg g_libs[] = {
  61. { "io", luaopen_io },
  62. { "os", luaopen_os },
  63. { "debug", luaopen_debug },
  64. { "string", luaopen_string },
  65. { "base", luaopen_base },
  66. { "math", luaopen_math },
  67. { "package", luaopen_package },
  68. // 以上属于lua系统模块;
  69. // 以下属于用户自定义模块;
  70. { "aos", lua_regFuns },
  71. { NULL, NULL }
  72. };
  73. // 将模块注册到lua环境中;
  74. void lua_regLibs(lua_State *luaVM);
  75. int lua_new();
  76. #endif