From 32aac45162288418d67a3bbd60effc9c5bd1844a Mon Sep 17 00:00:00 2001 From: Hartmut Seichter Date: Sun, 1 Apr 2018 15:45:12 +0200 Subject: [PATCH] move code into a module structure --- src/core/{ => include/pw/core}/context.hpp | 0 src/core/{ => include/pw/core}/core.hpp | 0 src/core/include/pw/core/script.hpp | 51 ++++++++++++++++++++++ src/core/include/pw/core/scripting.hpp | 13 ++++++ src/core/{ => include/pw/core}/window.hpp | 1 - src/core/script.hpp | 29 ------------ src/core/{ => src}/context.cpp | 0 src/core/{ => src}/core.cpp | 0 src/core/{ => src}/script.cpp | 0 src/core/{ => src}/window.cpp | 0 10 files changed, 64 insertions(+), 30 deletions(-) rename src/core/{ => include/pw/core}/context.hpp (100%) rename src/core/{ => include/pw/core}/core.hpp (100%) create mode 100644 src/core/include/pw/core/script.hpp create mode 100644 src/core/include/pw/core/scripting.hpp rename src/core/{ => include/pw/core}/window.hpp (99%) delete mode 100644 src/core/script.hpp rename src/core/{ => src}/context.cpp (100%) rename src/core/{ => src}/core.cpp (100%) rename src/core/{ => src}/script.cpp (100%) rename src/core/{ => src}/window.cpp (100%) diff --git a/src/core/context.hpp b/src/core/include/pw/core/context.hpp similarity index 100% rename from src/core/context.hpp rename to src/core/include/pw/core/context.hpp diff --git a/src/core/core.hpp b/src/core/include/pw/core/core.hpp similarity index 100% rename from src/core/core.hpp rename to src/core/include/pw/core/core.hpp diff --git a/src/core/include/pw/core/script.hpp b/src/core/include/pw/core/script.hpp new file mode 100644 index 0000000..711da29 --- /dev/null +++ b/src/core/include/pw/core/script.hpp @@ -0,0 +1,51 @@ +#ifndef PW_SCRIPT_HPP +#define PW_SCRIPT_HPP + +#include +#include + + +#include + + +namespace pw { + + +class script; + +class main_loop { + + script &_s; + bool _stop = false; + + main_loop(script& s); + +}; + +class script { +protected: + + scripting::state _lua; + +public: + + script(); + ~script(); + + bool update(); + + bool load(const std::string &s); + + int run(const std::string& s); + + void load(sol::table &ns); + + friend class main_loop; + +}; + +} + + + +#endif diff --git a/src/core/include/pw/core/scripting.hpp b/src/core/include/pw/core/scripting.hpp new file mode 100644 index 0000000..68c8947 --- /dev/null +++ b/src/core/include/pw/core/scripting.hpp @@ -0,0 +1,13 @@ +#ifndef PW_SCRIPTING_HPP +#define PW_SCRIPTING_HPP + +#include "sol.hpp" + +namespace pw { + +// include external namespace of sol +namespace scripting = sol; + +} + +#endif diff --git a/src/core/window.hpp b/src/core/include/pw/core/window.hpp similarity index 99% rename from src/core/window.hpp rename to src/core/include/pw/core/window.hpp index 89dcc07..1415ede 100644 --- a/src/core/window.hpp +++ b/src/core/include/pw/core/window.hpp @@ -27,7 +27,6 @@ public: window(); ~window(); - bool update(); void set_title(const char* t); diff --git a/src/core/script.hpp b/src/core/script.hpp deleted file mode 100644 index a369a5c..0000000 --- a/src/core/script.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef PW_SCRIPT_HPP -#define PW_SCRIPT_HPP - -#include -#include -#include - -namespace pw { - -class script { - - sol::state _lua; - -public: - - script(); - ~script(); - - bool update(); - - void run(const char* s); - -}; - -} - - - -#endif diff --git a/src/core/context.cpp b/src/core/src/context.cpp similarity index 100% rename from src/core/context.cpp rename to src/core/src/context.cpp diff --git a/src/core/core.cpp b/src/core/src/core.cpp similarity index 100% rename from src/core/core.cpp rename to src/core/src/core.cpp diff --git a/src/core/script.cpp b/src/core/src/script.cpp similarity index 100% rename from src/core/script.cpp rename to src/core/src/script.cpp diff --git a/src/core/window.cpp b/src/core/src/window.cpp similarity index 100% rename from src/core/window.cpp rename to src/core/src/window.cpp