QsLua.h 570 B

12345678910111213141516171819202122232425262728293031
  1. #pragma once
  2. #include <QtWidgets/qwidget.h>
  3. #include <string>
  4. #include <functional>
  5. #include <Kaguya/kaguya.hpp>
  6. #include "ybase/buffer.h"
  7. #include "yutil/file.h"
  8. class QsLua
  9. {
  10. public:
  11. QsLua();
  12. ~QsLua();
  13. // 启动
  14. bool start(
  15. std::function<void(kaguya::State* L)> regist_callback,
  16. const std::string& init_lua_filepath,
  17. std::string error_filepath
  18. );
  19. void close();
  20. // 制作LUA包
  21. ylib::buffer package();
  22. // 释放LUA包
  23. void unpack(const ylib::buffer& data);
  24. private:
  25. void addLuaPath();
  26. private:
  27. kaguya::State *L = nullptr;
  28. ylib::file_io m_error;
  29. };