17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-19 06:09:18 +02:00

pch migration to modules [wip]

This commit is contained in:
maj00r
2026-09-09 20:35:26 +02:00
parent c3007e3237
commit 3f7960aad5
350 changed files with 5958 additions and 3059 deletions

View File

@@ -1,3 +1,31 @@
module;
#include <thread>
#include <format>
#include "Python.h"
#include <iterator>
#include <memory>
#include "glad/glad.h"
#include <GLFW/glfw3.h>
#include <atomic>
#include <functional>
#include <list>
#include <tuple>
#include <vector>
#include "scripting/PyInt_macros.h"
#include "utilities/Globals_macros.h"
#include "utilities/crashreporter_macros.h"
#include <cstring>
#include <mutex>
module eu07.scripting.pyint;
import eu07.application.application;
import eu07.input.command;
import eu07.glm;
import eu07.utilities.globals;
import eu07.utilities.logs;
import eu07.utilities.dictionary;
import eu07.simulation.simulation;
import eu07.utilities.crashreporter;
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
@@ -7,18 +35,11 @@ obtain one at
http://mozilla.org/MPL/2.0/.
*/
#include "scripting/PyInt.h"
#include "stdafx.h"
#include "application/application.h"
#include "utilities/Globals.h"
#include "utilities/Logs.h"
#include "utilities/dictionary.h"
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wwrite-strings"
#endif
#include <simulation/simulation.h>
void render_task::run()
{
@@ -92,7 +113,7 @@ void render_task::run()
for (size_t i = 0; i < datapair.second.size(); i++)
{
auto const &vec = datapair.second[i];
WriteLog("passing " + glm::to_string(vec));
WriteLog("passing (" + std::to_string(vec.x) + ", " + std::to_string(vec.y) + ")");
PyObject *tuple = PyTuple_New(2);
PyTuple_SetItem(tuple, 0, PyGetFloat(vec.x)); // steals ref

View File

@@ -6,9 +6,53 @@ distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
module;
#ifdef _POSIX_C_SOURCE
#undef _POSIX_C_SOURCE
#endif
#ifdef _XOPEN_SOURCE
#undef _XOPEN_SOURCE
#endif
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wregister"
#endif
#ifdef WITH_PYTHON
#ifdef _DEBUG
#undef _DEBUG // bez tego macra Py_DECREF powoduja problemy przy linkowaniu
#include "Python.h"
#define _DEBUG
#else
#include "Python.h"
#endif
#else
// stubs for a build without Python; they must stay inside this branch, or they
// would clobber the real Python types
#define PyObject void
#define PyThreadState void
#endif
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#include <vector>
#include "scripting/PyInt_macros.h"
#include "utilities/utilities_macros.h"
#include <thread>
#include <GLFW/glfw3.h>
#include <deque>
#include <memory>
#include <mutex>
#include <unordered_map>
export module eu07.scripting.pyint;
import eu07.global_include.interfaces.itexture;
import eu07.utilities.dictionary;
import eu07.utilities.classes;
import eu07.utilities.utilities;
import eu07.model.texture;
export {
#ifndef PYINT_H
#define PYINT_H
#ifdef _POSIX_C_SOURCE
#undef _POSIX_C_SOURCE
@@ -27,33 +71,8 @@ http://mozilla.org/MPL/2.0/.
#pragma GCC diagnostic ignored "-Wregister"
#endif
#ifdef WITH_PYTHON
#ifdef _DEBUG
#undef _DEBUG // bez tego macra Py_DECREF powoduja problemy przy linkowaniu
#include "Python.h"
#define _DEBUG
#else
#include "Python.h"
#endif
#else
#define PyObject void
#define PyThreadState void
#endif
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#include "utilities/Classes.h"
#include "utilities/utilities.h"
#include "model/Texture.h"
#include <thread>
#define PyGetFloat(param) PyFloat_FromDouble(param)
#define PyGetBool(param) param ? Py_True : Py_False
// python rendertarget
struct python_rt
@@ -154,4 +173,5 @@ class python_external_utils
static std::vector<std::string> PyObjectToStringArray(PyObject *pyList);
};
#endif
} // export

View File

@@ -1,3 +1,5 @@
#include "scripting/PyInt_macros.h"
import eu07.scripting.pyint;
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
@@ -7,8 +9,6 @@ obtain one at
http://mozilla.org/MPL/2.0/.
*/
#include "stdafx.h"
#include "scripting/PyInt.h"
bool python_taskqueue::init()
{

8
scripting/PyInt_macros.h Normal file
View File

@@ -0,0 +1,8 @@
#pragma once
// Macros cannot cross a module boundary, so they live in a plain header that
// consumers pull into their global module fragment. The bodies expand at the use
// site, where the imported names are in scope, so this header includes nothing.
#define PyGetFloat(param) PyFloat_FromDouble(param)
#define PyGetBool(param) param ? Py_True : Py_False

View File

@@ -1,4 +1,14 @@
/*
module;
#include <map>
#include "utilities/utilities_macros.h"
#include <cmath>
#include <string>
module eu07.scripting.ladderlogic;
import eu07.utilities.parser;
import eu07.utilities.utilities;
import eu07.utilities.logs;
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
@@ -7,12 +17,7 @@ obtain one at
http://mozilla.org/MPL/2.0/.
*/
#include "stdafx.h"
#include "scripting/ladderlogic.h"
#include "utilities/parser.h"
#include "utilities/utilities.h"
#include "utilities/Logs.h"
namespace plc {

View File

@@ -1,4 +1,16 @@
/*
module;
#include <cstdint>
#include <map>
#include <string>
#include <variant>
#include <vector>
export module eu07.scripting.ladderlogic;
import eu07.utilities.parser;
import eu07.utilities.classes;
export {
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
@@ -7,13 +19,12 @@ obtain one at
http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "utilities/Classes.h"
namespace plc {
using element_handle = short;
// element_handle is declared and exported by eu07.utilities.classes; redeclaring it
// here would attach a second, conflicting alias to this module.
// basic logic element.
class basic_element {
@@ -167,3 +178,5 @@ auto basic_controller::find_or_insert( std::string const &Name, basic_element::t
}
} // plc
} // export

View File

@@ -1,10 +1,13 @@
#include "stdafx.h"
#include "scripting/lua.h"
#include "world/Event.h"
#include "utilities/Logs.h"
#include "world/MemCell.h"
#include "vehicle/Driver.h"
#include "simulation/simulation.h"
module;
#include <lua.hpp>
#include <stdexcept>
#include <string>
module eu07.scripting.lua;
import eu07.utilities.utilities;
import eu07.simcore;
import eu07.utilities.logs;
import eu07.simulation.simulation;
lua::lua()
{

View File

@@ -1,10 +1,12 @@
#pragma once
module;
#include <lua.hpp>
#include <stdafx.h>
#include <string>
export module eu07.scripting.lua;
import eu07.simcore;
export {
class basic_event;
class TMemCell;
class TDynamicObject;
struct memcell_values { const char *str; double num1; double num2; };
class lua
@@ -47,3 +49,5 @@ public:
static void push_memcell_values(lua_State *L, const TMemCell *mc);
static memcell_values get_memcell_values(lua_State *L, int idx);
};
} // export

View File

@@ -1,9 +1,23 @@
#include "stdafx.h"
#include "scripting/pythonscreenviewer.h"
#include "application/application.h"
#include "gl/shader.h"
#include "gl/vao.h"
#include "utilities/Logs.h"
module;
#include "utilities/Globals_macros.h"
#include <GLFW/glfw3.h>
#include <chrono>
#include <cstddef>
#include <cstring>
#include <memory>
#include <mutex>
#include <thread>
#include <vector>
#include "glad/glad.h"
module eu07.scripting.pythonscreenviewer;
import eu07.utilities.globals;
import eu07.gl.buffer;
import eu07.glm;
import eu07.application.application;
import eu07.gl.shader;
import eu07.gl.vao;
import eu07.utilities.logs;
void texture_window_resize(GLFWwindow *win, int w, int h)
{

View File

@@ -1,7 +1,22 @@
#include "rendering/renderer.h"
#include "scripting/PyInt.h"
module;
#include <thread>
#include <atomic>
#include <chrono>
#include <memory>
#include <vector>
#include "scripting/PyInt_macros.h"
#include <GLFW/glfw3.h>
export module eu07.scripting.pythonscreenviewer;
import eu07.glm;
import eu07.gl.shader;
import eu07.gl.ubo;
import eu07.gl.bindable;
import eu07.rendering.renderer;
import eu07.scripting.pyint;
export {
class python_screen_viewer
{
struct window_state {
@@ -43,3 +58,5 @@ public:
void notify_cursor_pos(GLFWwindow *window, double x, double y);
void notify_click(GLFWwindow *window, int button, int action);
};
} // export