diff --git a/src/core/include/pw/core/vector.hpp b/src/core/include/pw/core/vector.hpp index 01960dd..a3c42c7 100644 --- a/src/core/include/pw/core/vector.hpp +++ b/src/core/include/pw/core/vector.hpp @@ -60,6 +60,7 @@ struct vector3_ : matrix_<3,1,T> { using base_type::base_type; using base_type::operator = ; + vector3_() : base_type() {} vector3_(const base_type& m) : base_type(m) {} vector3_(T x_,T y_,T z_) : base_type({x_,y_,z_}) {} diff --git a/src/engine/CMakeLists.txt b/src/engine/CMakeLists.txt index 962b622..5326811 100644 --- a/src/engine/CMakeLists.txt +++ b/src/engine/CMakeLists.txt @@ -21,4 +21,8 @@ target_include_directories(pixwerx ${CMAKE_SOURCE_DIR}/src/scripting/include ) -target_link_libraries(pixwerx pwcore pwsystem pwscripting) + target_link_libraries(pixwerx + pwscripting + # -Wl,--whole-archive -lpwscripting -Wl,--no-whole-archive + pwcore + pwsystem) diff --git a/src/engine/pixwerx.cpp b/src/engine/pixwerx.cpp index 7ed8e41..0ca884b 100644 --- a/src/engine/pixwerx.cpp +++ b/src/engine/pixwerx.cpp @@ -7,6 +7,7 @@ #include #include + #include #include @@ -14,8 +15,14 @@ #include #include + +//PW_RUNTIME_LUA_USE(core) + + int main(int argc,const char** argv) { +// pw_runtime_lua_core(); + argagg::parser argparser {{ { "help", {"-h", "--help"}, "shows this help message", 0}, diff --git a/src/scripting/include/pw/scripting/script.hpp b/src/scripting/include/pw/scripting/script.hpp index 3834a0c..ac6645a 100644 --- a/src/scripting/include/pw/scripting/script.hpp +++ b/src/scripting/include/pw/scripting/script.hpp @@ -42,6 +42,7 @@ protected: }; + } #endif diff --git a/src/scripting/src/runtime_lua.cpp b/src/scripting/src/runtime_lua.cpp index ef0bcdb..f06b86f 100644 --- a/src/scripting/src/runtime_lua.cpp +++ b/src/scripting/src/runtime_lua.cpp @@ -2,8 +2,6 @@ namespace pw { -PW_RUNTIME_LUA_USE(core) - runtime_lua &runtime_lua::get() { static runtime_lua instance; diff --git a/src/scripting/src/runtime_lua.hpp b/src/scripting/src/runtime_lua.hpp index 93a925c..6bc02b9 100644 --- a/src/scripting/src/runtime_lua.hpp +++ b/src/scripting/src/runtime_lua.hpp @@ -5,6 +5,8 @@ #include #include +#include + namespace pw { class runtime_lua { @@ -26,39 +28,23 @@ protected: }; -template + +template struct runtime_lua_register { - Derived& derived() { return static_cast(*this); } - const Derived& derived() const { return static_cast(*this); } - runtime_lua_register() - { - printf("Test\n"); - runtime_lua::get().add(derived().module_name(),&Derived::register_function); + { + debug::d() << __PRETTY_FUNCTION__; + runtime_lua::get().add("test",&T::register_function); } - static runtime_lua_register _instance; + static runtime_lua_register _instance; }; - -extern "C" { - typedef void (* CModuleFunction) (void); -} - -struct ModuleFunctionProxy -{ - ModuleFunctionProxy(CModuleFunction function) { (function)(); } -}; +template runtime_lua_register runtime_lua_register::_instance; } -#define PW_RUNTIME_LUA_USE(name) \ - extern "C" void pw_runtime_lua_##name(void) { printf("Meh!\n"); }; -#define PW_RUNTIME_LUA_REGISTER(name) \ - extern "C" void pw_runtime_lua_##name(void); \ - static pw::ModuleFunctionProxy proxy_##name(pw_runtime_lua_##name); - #endif diff --git a/src/scripting/src/script.cpp b/src/scripting/src/script.cpp index 837cde1..ac90cd3 100644 --- a/src/scripting/src/script.cpp +++ b/src/scripting/src/script.cpp @@ -4,6 +4,8 @@ #include "pw/core/debug.hpp" + + namespace pw { struct script::state { diff --git a/src/scripting/src/script_core.cpp b/src/scripting/src/script_core.cpp index d2c3051..00400bc 100644 --- a/src/scripting/src/script_core.cpp +++ b/src/scripting/src/script_core.cpp @@ -11,7 +11,7 @@ namespace pw { -struct lua_core : runtime_lua_register { +struct lua_core { std::string module_name() const { return "core"; } @@ -22,35 +22,34 @@ struct lua_core : runtime_lua_register { ns.set("pi",pw::pi()); - - ns.new_usertype - ( - "vector3", - sol::constructors(), - "x", sol::property(sol::resolve(&vector3::x), [](vector3& v,vector3::value_type val){ v.x() = val;}), - "y", sol::property(sol::resolve(&vector3::y), [](vector3& v,vector3::value_type val){ v.y() = val;}), - "z", sol::property(sol::resolve(&vector3::z), [](vector3& v,vector3::value_type val){ v.z() = val;}), - "cross",&vector3::cross, - "lerp",&vector3::lerp - ); +// ns.new_usertype +// ( +// "vector3", +// sol::constructors(), +// "x", sol::property(sol::resolve(&vector3::x), [](vector3& v,vector3::value_type val){ v.x() = val;}), +// "y", sol::property(sol::resolve(&vector3::y), [](vector3& v,vector3::value_type val){ v.y() = val;}), +// "z", sol::property(sol::resolve(&vector3::z), [](vector3& v,vector3::value_type val){ v.z() = val;}), +// "cross",&vector3::cross, +// "lerp",&vector3::lerp +// ); - ns.new_usertype - ( - "quaternion", - sol::constructors(), - "x", sol::property(sol::resolve(&quaternion::x), [](quaternion& v,quaternion::value_type val){ v.x() = val;}), - "y", sol::property(sol::resolve(&quaternion::y), [](quaternion& v,quaternion::value_type val){ v.y() = val;}), - "z", sol::property(sol::resolve(&quaternion::z), [](quaternion& v,quaternion::value_type val){ v.z() = val;}), - "w", sol::property(sol::resolve(&quaternion::w), [](quaternion& v,quaternion::value_type val){ v.w() = val;}), - "identity",sol::readonly_property(&quaternion::identity), - "dot",&quaternion::dot, - "inverse",sol::readonly_property(&quaternion::inverse), - "normalized",&quaternion::normalized, - "lerp",&quaternion::lerp, - "slerp",&quaternion::slerp - ); +// ns.new_usertype +// ( +// "quaternion", +// sol::constructors(), +// "x", sol::property(sol::resolve(&quaternion::x), [](quaternion& v,quaternion::value_type val){ v.x() = val;}), +// "y", sol::property(sol::resolve(&quaternion::y), [](quaternion& v,quaternion::value_type val){ v.y() = val;}), +// "z", sol::property(sol::resolve(&quaternion::z), [](quaternion& v,quaternion::value_type val){ v.z() = val;}), +// "w", sol::property(sol::resolve(&quaternion::w), [](quaternion& v,quaternion::value_type val){ v.w() = val;}), +// "identity",sol::readonly_property(&quaternion::identity), +// "dot",&quaternion::dot, +// "inverse",sol::readonly_property(&quaternion::inverse), +// "normalized",&quaternion::normalized, +// "lerp",&quaternion::lerp, +// "slerp",&quaternion::slerp +// ); ns.new_usertype ("axisangle", @@ -99,13 +98,13 @@ struct lua_core : runtime_lua_register { // "mesh", // sol::constructors() // ); - } - - + } }; +struct lua_core_register : runtime_lua_register +{ }; -PW_RUNTIME_LUA_REGISTER(core) - +//PW_RUNTIME_LUA_REGISTER(core) +}