| 1234567891011121314151617181920212223242526272829303132333435 |
- #ifndef __SCRIPTING__PYTHON_ENGINE_H__
- #define __SCRIPTING__PYTHON_ENGINE_H__
- #include <pybind11/embed.h>
- #include <string>
- #include <functional>
- #include "../Engine.h"
- namespace py = pybind11;
- class PythonEngine
- {
- public:
- static PythonEngine& Get();
-
- void Init();
- void Shutdown();
-
- void Exec(const std::string& code, Engine& engine);
-
- py::object Call(const std::string& module, const std::string& func, py::args args = {});
-
- // Hot reload scripts for later
- void ReloadAllScripts();
- private:
- PythonEngine() = default;
- ~PythonEngine() = default;
-
- py::scoped_interpreter guard_;
- bool initialized_ = false;
- };
- #endif
|