Nimbin[12]?SDL & Graphics / sdl_runtime_compiler / commits / 85f2ee9

sdl_runtime_compiler git · main

SDL3 game for running and compiling code at runtime

sdl3 c++ compiler dlopen cmake · first commit 2026-04-19 · last commit 2026-07-03 (3 months ago) · synced 3 days ago · upstream: git.ide3.de/hsnr/sdl-runtime-compiler

C++ 72.3% C 26.2%
git clone https://git.christianimmanuel.de/sdl-graphics/sdl_runtime_compiler.gitwget https://git.christianimmanuel.de/sdl-graphics/sdl_runtime_compiler/archive/sdl_runtime_compiler.tar.gz

Rename Vars AND move files

Christian Immanuel · 2026-05-31 21:38 · 85f2ee90b4e5f456329fca8161a61f0d947bba35

 src/states/game_state.cpp                          |  52 +++++-----
 src/states/game_state.hpp                          | 110 +++++++++++----------
 .../level_runner_system.cpp}                       |   2 +-
 .../level_runner_system.hpp}                       |   2 +-
 .../{mod_loader.cpp => mod_loader_system.cpp}      |   2 +-
 .../{mod_loader.hpp => mod_loader_system.hpp}      |   0
 6 files changed, 87 insertions(+), 81 deletions(-)

diff --git a/src/states/game_state.cpp b/src/states/game_state.cpp
index 5316795..fae00be 100644
--- a/src/states/game_state.cpp
+++ b/src/states/game_state.cpp
@@ -40,7 +40,7 @@ GameState::GameState(size_t starting_level)
     word_anim_sys   = cpputils::make_unique<WordAnimSystem>();
     freelook_sys    = cpputils::make_unique<FreelookSystem>();
     particle_sys    = cpputils::make_unique<ParticleSystem>();
-    mod_loader      = cpputils::make_unique<ModLoader>();
+    mod_loader_sys      = cpputils::make_unique<ModLoader>();
     celebration_sys = cpputils::make_unique<CelebrationSystem>();
 
     floor_sys       = cpputils::make_unique<FloorMandelbrot>();
@@ -53,20 +53,20 @@ GameState::GameState(size_t starting_level)
     pult_sys->init(ctx.scenery, ctx.buttons, ctx.world->scale());
 
     if (starting_level >= level_Count()) starting_level = 0;
-    level_runner    = cpputils::make_unique<LevelRunner>(get_Level(starting_level));
+    level_runner_sys    = cpputils::make_unique<LevelRunner>(get_Level(starting_level));
 
-    DynArray<std::string> tokens = level_runner->grants_for_step();
+    DynArray<std::string> tokens = level_runner_sys->grants_for_step();
     step_Spawn(tokens);
 
-    scene_Setup(level_runner->current().scene);
+    scene_Setup(level_runner_sys->current().scene);
     step_SettingsApply();
     infowall_StepdetailsShow();
 
     hint_sys        = cpputils::make_unique<HintSystem>();
-    if (level_runner && !level_runner->complete())
-        hint_sys->set_Hint(level_runner->current().hint);
+    if (level_runner_sys && !level_runner_sys->complete())
+        hint_sys->set_Hint(level_runner_sys->current().hint);
 
-    if (level_runner && level_runner->dynamic_lib())
+    if (level_runner_sys && level_runner_sys->dynamic_lib())
         sandbox_LoadFileToWall();
 
     /*
@@ -299,14 +299,14 @@ GameState::on_ShootAll()
 void GameState::on_Compile() {
     std::string src = TextWall::extract_Text(ctx.wall_texts, Wall::Role::Editor);
 
-    if (level_runner && !level_runner->complete() && level_runner->dynamic_lib()) {
+    if (level_runner_sys && !level_runner_sys->complete() && level_runner_sys->dynamic_lib()) {
         const std::string path = sandbox_CanonicalPath();
         std::string stripped;
         for (char c : src) if (!std::isspace((unsigned char)c)) { stripped = src; break; }
         if (!path.empty() && !stripped.empty())
             SourceTokens::write_File(path, src);
 
-        mod_loader->build(ctx.wall_texts, src, ctx.world->scale(), true);
+        mod_loader_sys->build(ctx.wall_texts, src, ctx.world->scale(), true);
     } else {
         compiler_sys->compile(ctx.wall_texts, src);
     }
@@ -606,10 +606,10 @@ GameState::update(double dt)
             step_ledger.compile_ok = true;
         }
 
-        mod_loader->update(ctx.wall_texts, ctx.world->scale());
-        if (mod_loader->last_build_ok) {
-            mod_loader->last_build_ok = false;
-            mod_Apply(mod_loader->load_Objects());
+        mod_loader_sys->update(ctx.wall_texts, ctx.world->scale());
+        if (mod_loader_sys->last_build_ok) {
+            mod_loader_sys->last_build_ok = false;
+            mod_Apply(mod_loader_sys->load_Objects());
             SourceTokens::copy_File(sandbox_CanonicalPath(), sandbox_BackupPath());
         }
     }
@@ -717,12 +717,12 @@ GameState::infowall_Clear()
 void
 GameState::step_SettingsApply()
 {
-    if (!level_runner || level_runner->complete()) {
+    if (!level_runner_sys || level_runner_sys->complete()) {
         word_ai_sys->set_MaxActiveAi(0);
         return;
     }
 
-    const LevelStep& step = level_runner->current();
+    const LevelStep& step = level_runner_sys->current();
     word_ai_sys->set_MaxActiveAi(step.max_ai_words);
 }
 
@@ -731,9 +731,9 @@ GameState::infowall_StepdetailsShow()
 {
     infowall_Clear();
 
-    if (!level_runner || level_runner->complete()) return;
+    if (!level_runner_sys || level_runner_sys->complete()) return;
 
-    const std::string& details = level_runner->current().details;
+    const std::string& details = level_runner_sys->current().details;
     if (details.empty()) return;
 
     const float      world_scale    = ctx.world->scale();
@@ -993,11 +993,11 @@ GameState::level_TryAdvance()
     }
 
     GoalContext gctx = goal_ContextBuild();
-    if (!goal_Satisfied(level_runner->current().goal, gctx))
+    if (!goal_Satisfied(level_runner_sys->current().goal, gctx))
         return false;
     if (step_age < SETTLE_TIME_FOR_STEP)
         return false;
-    if (!level_runner || level_runner->complete())
+    if (!level_runner_sys || level_runner_sys->complete())
         return false;
 
     auto [anchor, right, glyph_yaw] = anchorframe_Current();
@@ -1012,8 +1012,8 @@ GameState::level_Advance()
     scene_Teardown();
     step_ledger.clear();
 
-    if (level_runner->advance()) {
-        if (level_runner->current().reset_carry) {
+    if (level_runner_sys->advance()) {
+        if (level_runner_sys->current().reset_carry) {
             ctx.words  .clear();
             projectiles.clear();
             anims_add  .clear();
@@ -1021,12 +1021,12 @@ GameState::level_Advance()
             carried = CarriedLine();
         }
 
-        DynArray<std::string> tokens = level_runner->grants_for_step();
+        DynArray<std::string> tokens = level_runner_sys->grants_for_step();
         step_Spawn(tokens);
-        scene_Setup(level_runner->current().scene);
+        scene_Setup(level_runner_sys->current().scene);
         step_SettingsApply();
         infowall_StepdetailsShow();
-        hint_sys->set_Hint(level_runner->current().hint);
+        hint_sys->set_Hint(level_runner_sys->current().hint);
     } else {
         hint_sys->clear();
         infowall_StepdetailsShow();
@@ -1080,7 +1080,7 @@ GameState::mod_Apply(const DynArray<ModObject>& objs)
 }
 
 std::string GameState::sandbox_CanonicalPath() const {
-    return level_runner ? level_runner->source_file() : std::string{};
+    return level_runner_sys ? level_runner_sys->source_file() : std::string{};
 }
 std::string GameState::sandbox_BackupPath() const {
     std::string c = sandbox_CanonicalPath();
@@ -1142,7 +1142,7 @@ GameState::sandbox_LoadFileToWall()
 
 
 void GameState::sandbox_Restore() {
-    if (!level_runner || !level_runner->dynamic_lib()) return;
+    if (!level_runner_sys || !level_runner_sys->dynamic_lib()) return;
     if (SourceTokens::copy_File(sandbox_BackupPath(), sandbox_CanonicalPath()))
         sandbox_LoadFileToWall();
 }
diff --git a/src/states/game_state.hpp b/src/states/game_state.hpp
index 11260d8..7fb2fe0 100644
--- a/src/states/game_state.hpp
+++ b/src/states/game_state.hpp
@@ -6,7 +6,6 @@
 #include "entities/plate.hpp"
 #include "istate.hpp"
 #include "levels/goal.hpp"
-#include "levels/level_runner.hpp"
 #include "levels/scene.hpp"
 #include "rendering/floor_mandelbrot.hpp"
 #include "states/game_context.hpp"
@@ -16,7 +15,8 @@
 #include "systems/freelook_system.hpp"
 #include "systems/hint_system.hpp"
 #include "systems/input_system.hpp"
-#include "systems/mod_loader.hpp"
+#include "systems/level_runner_system.hpp"
+#include "systems/mod_loader_system.hpp"
 #include "systems/particle_system.hpp"
 #include "systems/physics_system.hpp"
 #include "systems/plate_system.hpp"
@@ -72,7 +72,7 @@ class GameState : public IState
     double alpha          { 0.0 };
 
     DynArray<Text3d*> typing_words;
-    std::string          typing_last;
+    std::string       typing_last;
 
     DynArray<Projectile>    projectiles;
     DynArray<WordAnim_Add>  anims_add;
@@ -94,64 +94,70 @@ class GameState : public IState
     cpputils::unique_ptr<PlateSystem>      plate_sys;
     cpputils::unique_ptr<ParticleSystem>   particle_sys;
     cpputils::unique_ptr<FloorMandelbrot>  floor_sys;
-    cpputils::unique_ptr<LevelRunner>      level_runner;
-    cpputils::unique_ptr<ModLoader>        mod_loader;
+    cpputils::unique_ptr<LevelRunner>      level_runner_sys;
+    cpputils::unique_ptr<ModLoader>        mod_loader_sys;
     cpputils::unique_ptr<CelebrationSystem>celebration_sys;
 
 
-    bool on_Pick();
-    void on_Click();
-    void on_DropLast();
-    bool on_ShootOne();
-    void on_ShootAll();
-    void on_DebugPrint();
-    void on_Jump();
+    bool on_Pick         ();
+    void on_Click        ();
+    void on_DropLast     ();
+    bool on_ShootOne     ();
+    void on_ShootAll     ();
+    void on_DebugPrint   ();
+    void on_Jump         ();
     void on_FreelookStart();
-    void on_FreelookEnd();
-    void on_Compile();
-    void on_NumberAdjust(int dt);
-    void on_TextStart (FrameInput&);
-    void on_TextCommit(FrameInput&);
-    void on_TextCancel(FrameInput&);
+    void on_FreelookEnd  ();
+    void on_Compile      ();
+    void on_NumberAdjust (int dt);
+    void on_TextStart    (FrameInput&);
+    void on_TextCommit   (FrameInput&);
+    void on_TextCancel   (FrameInput&);
+
+    void scene_Setup       (const Scene& scene);
+    void scene_Teardown    ();
+    void substep           (double dt);
+
+    void step_Spawn        (const DynArray<std::string>& tokens);
+    void step_SettingsApply();
 
-    void scene_Setup(const Scene& scene);
-    void scene_Teardown();
-    void substep(double dt);
+    bool level_TryAdvance  ();
+    void level_Advance     ();
+    GoalContext
+         goal_ContextBuild () const;
 
-    std::tuple<Vec3, Vec3, double>
-         anchorframe_Current() const;
-    void carriedline_Update();
-    void carry_BeginAnim(Text3dPtr word, bool with_pitch);
-    void pult_DispatchAction(PultAction act);
-    void step_Spawn(const DynArray<std::string>& tokens);
-    void step_SettingsApply();
-    void infowall_Clear();
-    void infowall_StepdetailsShow();
-
-    // dynamic-lib sandbox
-    void mod_Clear();
-    void mod_Apply(const DynArray<ModObject>& objs);
-    void sandbox_LoadFileToWall();
-    void sandbox_Restore();
-    std::string sandbox_CanonicalPath() const;
-    std::string sandbox_BackupPath()    const;
-    void typing_RebuildPreview(const std::string& s);
-    void typing_ClearPreview();
+    void carriedline_Update    ();
+    void carry_BeginAnim       (Text3dPtr word, bool with_pitch);
+    void typing_RebuildPreview (const std::string& s);
+    void typing_ClearPreview   ();
+
+    void infowall_Clear           ();
+    void infowall_StepdetailsShow ();
+    void walltext_HandleShootDown (ProjectileResult& result, DynArray<size_t>& to_erase);
 
-    bool        level_TryAdvance();
-    void        level_Advance();
-    GoalContext goal_ContextBuild() const;
+    void projectile_LandOnFloor   (ProjectileResult& result);
+    void projectile_LandOnWall    (ProjectileResult& result);
 
-    void projectile_LandOnFloor(ProjectileResult& result);
-    void projectile_LandOnWall (ProjectileResult& result);
-    void walltext_HandleShootDown(ProjectileResult& result, DynArray<size_t>& to_erase);
+    void pult_DispatchAction (PultAction act);
 
-    void debug_SpawnWords(size_t n);
+    void debug_SpawnWords    (size_t n);
+
+    std::tuple<Vec3, Vec3, double>
+         anchorframe_Current () const;
+
+    // dynamic-lib sandbox START
+    void mod_Clear                   ();
+    void mod_Apply                   (const DynArray<ModObject>& objs);
+    void sandbox_LoadFileToWall      ();
+    void sandbox_Restore             ();
+    std::string sandbox_CanonicalPath() const;
+    std::string sandbox_BackupPath   () const;
+    // dynamic-lib sandbox END
 
 public:
-    explicit GameState(size_t starting_level = 0);
-    ~GameState() = default;
-    void handle_Event(Game&, const SDL_Event&) override;
-    void update(double dt)                     override;
-    void render(SDL_Window&, GlRenderer&)      override;
+    explicit GameState    (size_t starting_level = 0);
+            ~GameState    () = default;
+    void     handle_Event (Game&, const SDL_Event&)  override;
+    void     update       (double dt)                override;
+    void     render       (SDL_Window&, GlRenderer&) override;
 };
diff --git a/src/levels/level_runner.cpp b/src/systems/level_runner_system.cpp
similarity index 91%
rename from src/levels/level_runner.cpp
rename to src/systems/level_runner_system.cpp
index 62b809e..6345e38 100644
--- a/src/levels/level_runner.cpp
+++ b/src/systems/level_runner_system.cpp
@@ -1,4 +1,4 @@
-#include "level_runner.hpp"
+#include "level_runner_system.hpp"
 
 LevelRunner::LevelRunner(const Level& l) : level(&l) {}
 
diff --git a/src/levels/level_runner.hpp b/src/systems/level_runner_system.hpp
similarity index 96%
rename from src/levels/level_runner.hpp
rename to src/systems/level_runner_system.hpp
index a141034..277bbef 100644
--- a/src/levels/level_runner.hpp
+++ b/src/systems/level_runner_system.hpp
@@ -1,5 +1,5 @@
 #pragma once
-#include "level.hpp"
+#include "levels/level.hpp"
 
 class LevelRunner {
 public:
diff --git a/src/systems/mod_loader.cpp b/src/systems/mod_loader_system.cpp
similarity index 99%
rename from src/systems/mod_loader.cpp
rename to src/systems/mod_loader_system.cpp
index 0bb5008..c8566dd 100644
--- a/src/systems/mod_loader.cpp
+++ b/src/systems/mod_loader_system.cpp
@@ -4,7 +4,7 @@
 #include <string>
 #include <sys/select.h>
 
-#include "systems/mod_loader.hpp"
+#include "systems/mod_loader_system.hpp"
 #include "text_3d/text_3d.hpp"
 #include "utils/ascii.hpp"
 
diff --git a/src/systems/mod_loader.hpp b/src/systems/mod_loader_system.hpp
similarity index 100%
rename from src/systems/mod_loader.hpp
rename to src/systems/mod_loader_system.hpp