LuaCompiler.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include "LuaCompiler.h"
  2. #include "FileStream.h"
  3. #include "lua.hpp"
  4. namespace crown
  5. {
  6. //-----------------------------------------------------------------------------
  7. LuaCompiler::LuaCompiler(const char* root_path, const char* dest_path, const char* resource, uint32_t seed) :
  8. Compiler(root_path, dest_path, resource, seed),
  9. m_file_size(0),
  10. m_file_data(NULL)
  11. {
  12. }
  13. //-----------------------------------------------------------------------------
  14. bool LuaCompiler::compile()
  15. {
  16. int32_t status;
  17. lua_State *L;
  18. luaL_openlibs(L); // Load Lua libraries
  19. char* file;
  20. strcpy(file, root_path());
  21. strcat(file, resource_path());
  22. /* Load the file containing the script we are going to run */
  23. status = luaL_loadfile(L, file);
  24. if (status)
  25. {
  26. printf("Couldn't load file: %s\n", lua_tostring(L, -1));
  27. return -1;
  28. }
  29. else
  30. {
  31. printf("yeah!\n");
  32. }
  33. return true;
  34. }
  35. //-----------------------------------------------------------------------------
  36. void LuaCompiler::write()
  37. {
  38. }
  39. } // namespace crown