Symphony Of Empires
pyvm.hpp
Go to the documentation of this file.
1 // Eng3D - General purpouse game engine
2 // Copyright (C) 2021, Eng3D contributors
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <https://www.gnu.org/licenses/>.
16 //
17 // ----------------------------------------------------------------------------
18 // Name:
19 // pyvm.hpp
20 //
21 // Abstract:
22 // Does some important stuff.
23 // ----------------------------------------------------------------------------
24 
25 #pragma once
26 
27 #include <string_view>
28 #include <string>
29 #include <vector>
30 
31 namespace Eng3D {
32  class PythonException : public std::exception {
33  std::string buffer;
34  public:
35  PythonException(const std::string& message) {
36  buffer = message;
37  }
38  virtual const char* what() const noexcept {
39  return buffer.c_str();
40  }
41  };
42 
43  class PythonObj {
44  void* obj = nullptr;
45  public:
46  PythonObj() = default;
47  PythonObj(void* _obj);
49  PythonObj(PythonObj&&) noexcept;
51  };
52 
53  class State;
54  class PythonVM {
55  State& s;
56  public:
59 
60  void run_string(const std::string_view name, const std::string_view path);
61  void add_module(const std::string_view path);
62 
63  std::vector<PythonObj> modules;
64  };
65 }
virtual const char * what() const noexcept
Definition: pyvm.hpp:38
PythonException(const std::string &message)
Definition: pyvm.hpp:35
PythonObj()=default
PythonObj(PythonObj &&) noexcept
PythonObj(const PythonObj &)
PythonObj(void *_obj)
void add_module(const std::string_view path)
void run_string(const std::string_view name, const std::string_view path)
PythonVM(Eng3D::State &_s)
std::vector< PythonObj > modules
Definition: pyvm.hpp:63