From 5a69ad0a97a537dcf88a0eb98dab178d766e297e Mon Sep 17 00:00:00 2001 From: mihacooper Date: Mon, 25 Sep 2017 21:06:00 +0300 Subject: [PATCH] fixes to build effil on windows (#71) --- src/cpp/lua-module.cpp | 8 ++++++-- src/cpp/shared-table.cpp | 2 +- src/cpp/stored-object.h | 1 - tests/lua/thread.lua | 11 +++++++---- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/cpp/lua-module.cpp b/src/cpp/lua-module.cpp index a811bdd..a89f154 100644 --- a/src/cpp/lua-module.cpp +++ b/src/cpp/lua-module.cpp @@ -49,8 +49,12 @@ std::string userdataType(const sol::object& something) { } // namespace -extern "C" int luaopen_libeffil(lua_State* L) { - sol::state_view lua(L); +extern "C" +#ifdef _WIN32 + __declspec(dllexport) +#endif +int luaopen_libeffil(lua_State* L) { + sol::state_view lua(L); Thread::getUserType(lua); SharedTable::getUserType(lua); Channel::getUserType(lua); diff --git a/src/cpp/shared-table.cpp b/src/cpp/shared-table.cpp index 7de49f0..25f9096 100644 --- a/src/cpp/shared-table.cpp +++ b/src/cpp/shared-table.cpp @@ -246,7 +246,7 @@ SharedTable::PairsIterator SharedTable::luaPairs(sol::this_state state) { sol::make_object(state, *this)); } -std::pair ipairsNext(sol::this_state lua, SharedTable table, sol::optional key) { +std::pair ipairsNext(sol::this_state lua, SharedTable table, const sol::optional& key) { size_t index = key ? key.value() + 1 : 1; auto objKey = createStoredObject(static_cast(index)); sol::object value = table.get(objKey, lua); diff --git a/src/cpp/stored-object.h b/src/cpp/stored-object.h index bedc2ed..4b9ac30 100644 --- a/src/cpp/stored-object.h +++ b/src/cpp/stored-object.h @@ -26,7 +26,6 @@ public: private: BaseHolder(const BaseHolder&) = delete; - BaseHolder(BaseHolder&) = delete; }; typedef std::shared_ptr StoredObject; diff --git a/tests/lua/thread.lua b/tests/lua/thread.lua index 61c08b6..de916c4 100644 --- a/tests/lua/thread.lua +++ b/tests/lua/thread.lua @@ -220,9 +220,9 @@ end test.thread.timed_cancel = function () local thread = effil.thread(function() - require("effil").sleep(2) + require("effil").sleep(4) end)() - test.is_false(thread:cancel(1)) + test.is_false(thread:cancel(100, "ms")) thread:wait() end @@ -317,9 +317,9 @@ test.this_thread.cancel_with_yield = function () end test.this_thread.pause_with_yield = function () - local share = effil.table() + local share = effil.table({stop = false}) local spec = effil.thread(function (share) - for i=1,10000 do + while not share.stop do require("effil").yield() end share.done = true @@ -331,6 +331,9 @@ test.this_thread.pause_with_yield = function () thr:pause() test.is_nil(share.done) test.equal(thr:status(), "paused") + share.stop = true + effil.sleep(100, "ms") + test.is_nil(share.done) thr:resume() test.is_true(thr:get())