LuaDocument.cpp 612 B

1234567891011121314151617181920212223242526272829303132
  1. #include "precompiled.h"
  2. #include "LuaDocument.h"
  3. #include <Rocket/Core/Lua/lua.hpp>
  4. #include <Rocket/Core/Lua/Interpreter.h>
  5. namespace Rocket {
  6. namespace Core {
  7. namespace Lua {
  8. LuaDocument::LuaDocument(const String& tag) : ElementDocument(tag)
  9. {
  10. }
  11. void LuaDocument::LoadScript(Stream* stream, const String& source_name)
  12. {
  13. //if it is loaded from a file
  14. if(source_name != "")
  15. {
  16. Interpreter::LoadFile(source_name);
  17. }
  18. else
  19. {
  20. String buffer = "";
  21. stream->Read(buffer,stream->Length()); //just do the whole thing
  22. Interpreter::DoString(buffer);
  23. }
  24. }
  25. }
  26. }
  27. }