From e67a2baa758e0b91fbe9ea72818aa0f8a62bbd6f Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Wed, 23 Oct 2019 11:52:42 +0700 Subject: [PATCH] init dummy high level table --- sources/enduro2d/high/bindings/high_binds.cpp | 64 ++++++++++++++++++- sources/enduro2d/high/starter.cpp | 6 +- .../enduro2d/high/systems/script_system.cpp | 33 +++++++++- 3 files changed, 97 insertions(+), 6 deletions(-) diff --git a/sources/enduro2d/high/bindings/high_binds.cpp b/sources/enduro2d/high/bindings/high_binds.cpp index d4deefe0..b10dd7ec 100644 --- a/sources/enduro2d/high/bindings/high_binds.cpp +++ b/sources/enduro2d/high/bindings/high_binds.cpp @@ -6,10 +6,70 @@ #include "bindings.hpp" +#include +#include +#include + +#include +#include + +#include +#include + +namespace +{ + using namespace e2d; + + void bind_library(sol::state& l) { + l.new_usertype("library"); + } + + void bind_luasol(sol::state& l) { + l.new_usertype("luasol"); + } + + void bind_world(sol::state& l) { + l.new_usertype("world"); + } +} + +namespace +{ + using namespace e2d; + + void bind_node(sol::state& l) { + l.new_usertype("node"); + } + + void bind_gobject(sol::state& l) { + l.new_usertype("gobject"); + } +} + +namespace +{ + using namespace e2d; + + void bind_actor(sol::state& l) { + l.new_usertype("actor"); + } + + void bind_behaviour(sol::state& l) { + l.new_usertype("behaviour"); + } +} + namespace e2d::bindings { void bind_high(sol::state& l) { - //TODO(BlackMat): implme - E2D_UNUSED(l); + bind_library(l); + bind_luasol(l); + bind_world(l); + + bind_node(l); + bind_gobject(l); + + bind_actor(l); + bind_behaviour(l); } } diff --git a/sources/enduro2d/high/starter.cpp b/sources/enduro2d/high/starter.cpp index 0a693b0f..89a38626 100644 --- a/sources/enduro2d/high/starter.cpp +++ b/sources/enduro2d/high/starter.cpp @@ -192,11 +192,11 @@ namespace e2d .register_component("spine_player_evt") .register_component("sprite_renderer"); + safe_module_initialize(); + safe_module_initialize( params.library_params().root()); - safe_module_initialize(); - safe_module_initialize(); } @@ -204,8 +204,8 @@ namespace e2d the().collect_garbage(); modules::shutdown(); - modules::shutdown(); modules::shutdown(); + modules::shutdown(); modules::shutdown(); modules::shutdown(); } diff --git a/sources/enduro2d/high/systems/script_system.cpp b/sources/enduro2d/high/systems/script_system.cpp index fa6d635f..3d3888c8 100644 --- a/sources/enduro2d/high/systems/script_system.cpp +++ b/sources/enduro2d/high/systems/script_system.cpp @@ -6,6 +6,32 @@ #include +#include +#include +#include + +namespace +{ + using namespace e2d; + + void init_core_table(sol::state& s) { + auto e2d_table = s["e2d"].get_or_create(); + e2d_table["core"] = s.create_table_with( + "debug", &the(), + "engine", &the(), + "input", &the(), + "window", &the()); + } + + void init_high_table(sol::state& s) { + auto e2d_table = s["e2d"].get_or_create(); + e2d_table["high"] = s.create_table_with( + "library", &the(), + "luasol", &the(), + "world", &the()); + } +} + namespace e2d { // @@ -14,7 +40,12 @@ namespace e2d class script_system::internal_state final : private noncopyable { public: - internal_state() = default; + internal_state() { + the().with_state([](sol::state& s){ + init_core_table(s); + init_high_table(s); + }); + } ~internal_state() noexcept = default; void update_process(ecs::registry& owner) {