Skip to content

Commit 83a656a

Browse files
committed
Break all the behaviors. _All_ of them.
1 parent 21c0309 commit 83a656a

File tree

15 files changed

+242
-157
lines changed

15 files changed

+242
-157
lines changed

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ else()
9595
set(IS_X64 TRUE)
9696
endif()
9797

98+
if (PROJECT_SOURCE_DIR MATCHES ${CMAKE_SOURCE_DIR})
99+
set(SOL2_IS_TOP_LEVEL TRUE)
100+
endif()
98101

99102
# # # sol2 Source Groups
100103
# # Sources everyone is going to need
@@ -190,7 +193,7 @@ else()
190193
endif()
191194

192195
# # # Tests, Examples and other CI suites that come with sol2
193-
if (DO_TESTS OR DO_EXAMPLES)
196+
if (SOL2_IS_TOP_LEVEL)
194197
# # # General project output locations
195198
if (IS_X86 OR CMAKE_SIZEOF_VOID_P EQUAL 4)
196199
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x86/lib")
@@ -217,6 +220,8 @@ if (DO_TESTS OR DO_EXAMPLES)
217220
else()
218221
string(REGEX REPLACE "/W[0-4]" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
219222
string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
223+
string(REGEX REPLACE "/MT" "/MD" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
224+
string(REGEX REPLACE "/MT" "/MD" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
220225
endif()
221226
find_package(Threads REQUIRED)
222227

cmake/Modules/FindCatch.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ include(Common/Core)
2828
if (Catch_FIND_VERSION)
2929
set(catch_version ${Catch_FIND_VERSION})
3030
else()
31-
set(catch_version 2.1.2)
31+
set(catch_version 2.11.0)
3232
endif()
3333

3434
set(catch_lib catch_lib_${catch_version})

cmake/Modules/FindLuaBuild/LuaJIT.cmake

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,27 @@ if (MSVC)
185185
"C:/Program Files/Microsoft Visual Studio/2017/Professional/VC"
186186
"C:/Program Files/Microsoft Visual Studio/2017/Enterprise/VC/Auxiliary/Build"
187187
"C:/Program Files/Microsoft Visual Studio/2017/Enterprise/VC/Auxiliary"
188-
"C:/Program Files/Microsoft Visual Studio/2017/Enterprise/VC")
188+
"C:/Program Files/Microsoft Visual Studio/2017/Enterprise/VC"
189+
190+
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build"
191+
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary"
192+
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC"
193+
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Auxiliary/Build"
194+
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Auxiliary"
195+
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC"
196+
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build"
197+
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary"
198+
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC"
199+
200+
"C:/Program Files/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build"
201+
"C:/Program Files/Microsoft Visual Studio/2019/Community/VC/Auxiliary"
202+
"C:/Program Files/Microsoft Visual Studio/2019/Community/VC"
203+
"C:/Program Files/Microsoft Visual Studio/2019/Professional/VC/Auxiliary/Build"
204+
"C:/Program Files/Microsoft Visual Studio/2019/Professional/VC/Auxiliary"
205+
"C:/Program Files/Microsoft Visual Studio/2019/Professional/VC"
206+
"C:/Program Files/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build"
207+
"C:/Program Files/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary"
208+
"C:/Program Files/Microsoft Visual Studio/2019/Enterprise/VC")
189209
if (VCVARS_ALL_BAT MATCHES "VCVARS_ALL_BAT-NOTFOUND")
190210
MESSAGE(FATAL_ERROR "Cannot find 'vcvarsall.bat' file or similar needed to build LuaJIT ${LUA_VERSION} on Windows")
191211
endif()
@@ -195,6 +215,9 @@ if (MSVC)
195215
set(LUA_JIT_MAKE_COMMAND "${VCVARS_ALL_BAT}" x64)
196216
endif()
197217
set(LUA_JIT_MAKE_COMMAND ${LUA_JIT_MAKE_COMMAND} && cd src && msvcbuild.bat)
218+
if (CMAKE_BUILD_TYPE MATCHES "Debug")
219+
set(LUA_JIT_MAKE_COMMAND ${LUA_JIT_MAKE_COMMAND} debug)
220+
endif()
198221
if (NOT BUILD_LUA_AS_DLL)
199222
set(LUA_JIT_MAKE_COMMAND ${LUA_JIT_MAKE_COMMAND} static)
200223
endif()

examples/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,7 @@ function (MAKE_EXAMPLE example_source_file example_suffix target_sol)
7878

7979
if (MSVC)
8080
target_compile_options(${example_name}
81-
PRIVATE /std:c++latest /EHsc "$<$<CONFIG:Debug>:/MDd>"
82-
"$<$<CONFIG:Release>:/MD>"
83-
"$<$<CONFIG:RelWithDebInfo>:/MD>"
84-
"$<$<CONFIG:MinSizeRel>:/MD>")
81+
PRIVATE /std:c++latest /EHsc)
8582
target_compile_definitions(${example_name}
8683
PRIVATE UNICODE _UNICODE
8784
_CRT_SECURE_NO_WARNINGS _CRT_SECURE_NO_DEPRECATE )

examples/source/self_from_lua.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ int main() {
1515
lua_State* L = ts;
1616
// references the object that called this function
1717
// in constructors:
18-
sol::stack_object selfobj(L, -1);
19-
// the -1 (NEGATIVE one) above
20-
// means "off the top fo the stack"
21-
// (-1 is the top, -2 is one below, etc...)
18+
sol::stack_object selfobj(L, 1);
2219

2320
// definitely the same
2421
thing& self = selfobj.as<thing>();
@@ -42,10 +39,7 @@ int main() {
4239
sol::state lua;
4340
lua.open_libraries(sol::lib::base);
4441

45-
lua.new_usertype<thing>("thing",
46-
sol::constructors<thing(sol::this_state)>(),
47-
"func", &thing::func
48-
);
42+
lua.new_usertype<thing>("thing", sol::constructors<thing(sol::this_state)>(), "func", &thing::func);
4943

5044
lua.script(R"(
5145
obj = thing.new()

include/sol/call.hpp

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,17 @@ namespace sol {
217217
start,
218218
std::forward<Args>(args)...);
219219
}
220-
if (!traits::runtime_variadics_t::value && traits::free_arity != fxarity) {
221-
return overload_match_arity(types<>(),
222-
std::index_sequence<>(),
223-
std::index_sequence<traits::free_arity, M...>(),
224-
std::forward<Match>(matchfx),
225-
L,
226-
fxarity,
227-
start,
228-
std::forward<Args>(args)...);
220+
if constexpr (!traits::runtime_variadics_t::value) {
221+
if (traits::free_arity != fxarity) {
222+
return overload_match_arity(types<>(),
223+
std::index_sequence<>(),
224+
std::index_sequence<traits::free_arity, M...>(),
225+
std::forward<Match>(matchfx),
226+
L,
227+
fxarity,
228+
start,
229+
std::forward<Args>(args)...);
230+
}
229231
}
230232
return matchfx(types<Fx>(), meta::index_value<I>(), return_types(), args_list(), L, fxarity, start, std::forward<Args>(args)...);
231233
}
@@ -315,6 +317,8 @@ namespace sol {
315317
stack::stack_detail::undefined_metatable umf(L, &meta[0], &stack::stack_detail::set_undefined_methods_on<T>);
316318
umf();
317319

320+
// put userdata at the first index
321+
lua_insert(L, 1);
318322
construct_match<T, TypeLists...>(constructor_match<T, checked, clean_stack>(obj), L, argcount, 1 + static_cast<int>(syntax));
319323

320324
userdataref.push();
@@ -639,7 +643,9 @@ namespace sol {
639643
stack::stack_detail::undefined_metatable umf(L, &meta[0], &stack::stack_detail::set_undefined_methods_on<T>);
640644
umf();
641645

642-
construct_match<T, Args...>(constructor_match<T, checked, clean_stack>(obj), L, argcount, boost + 1 + static_cast<int>(syntax));
646+
// put userdata at the first index
647+
lua_insert(L, 1);
648+
construct_match<T, Args...>(constructor_match<T, checked, clean_stack>(obj), L, argcount, boost + 1 + 1 + static_cast<int>(syntax));
643649

644650
userdataref.push();
645651
return 1;
@@ -660,7 +666,9 @@ namespace sol {
660666
umf();
661667

662668
auto& func = std::get<I>(f.functions);
663-
stack::call_into_lua<checked, clean_stack>(r, a, L, boost + start, func, detail::implicit_wrapper<T>(obj));
669+
// put userdata at the first index
670+
lua_insert(L, 1);
671+
stack::call_into_lua<checked, clean_stack>(r, a, L, boost + 1 + start, func, detail::implicit_wrapper<T>(obj));
664672

665673
userdataref.push();
666674
return 1;

include/sol/dump_handler.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,24 @@ namespace sol {
5252
return result_code;
5353
}
5454

55-
inline int dump_throw_on_error(lua_State* L, int result_code, lua_Writer writer_function, void* userdata, bool strip) {
56-
#if defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS != 0
57-
return dump_panic_on_error(L, result_code, writer_function, userdata, strip);
58-
#else
55+
inline int dump_panic_on_error(lua_State* L, int result_code, lua_Writer writer_function, void* userdata, bool strip) {
5956
(void)L;
6057
(void)writer_function;
6158
(void)userdata;
6259
(void)strip;
63-
throw dump_error(result_code);
64-
#endif // no exceptions stuff
60+
return luaL_error(L, "a non-zero error code (%d) was returned by the lua_Writer for the dump function", result_code);
6561
}
6662

67-
inline int dump_panic_on_error(lua_State* L, int result_code, lua_Writer writer_function, void* userdata, bool strip) {
63+
inline int dump_throw_on_error(lua_State* L, int result_code, lua_Writer writer_function, void* userdata, bool strip) {
64+
#if defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS != 0
65+
return dump_panic_on_error(L, result_code, writer_function, userdata, strip);
66+
#else
6867
(void)L;
6968
(void)writer_function;
7069
(void)userdata;
7170
(void)strip;
72-
return luaL_error(L, "a non-zero error code (%d) was returned by the lua_Writer for the dump function", result_code);
71+
throw dump_error(result_code);
72+
#endif // no exceptions stuff
7373
}
7474

7575
} // namespace sol

include/sol/policies.hpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// sol3
1+
// sol3
22

33
// The MIT License (MIT)
44

@@ -46,10 +46,9 @@ namespace sol {
4646
std::size_t len;
4747

4848
template <typename... Args>
49-
stack_dependencies(int stack_target, Args&&... args)
50-
: target(stack_target), stack_indices(), len(sizeof...(Args)) {
49+
stack_dependencies(int stack_target, Args&&... args) : target(stack_target), stack_indices(), len(sizeof...(Args)) {
5150
std::size_t i = 0;
52-
(void)detail::swallow{int(), (stack_indices[i++] = static_cast<int>(std::forward<Args>(args)), int())...};
51+
(void)detail::swallow{ int(), (stack_indices[i++] = static_cast<int>(std::forward<Args>(args)), int())... };
5352
}
5453

5554
int& operator[](std::size_t i) {
@@ -73,8 +72,7 @@ namespace sol {
7372
std::tuple<Policies...> policies;
7473

7574
template <typename Fx, typename... Args, meta::enable<meta::neg<std::is_same<meta::unqualified_t<Fx>, policy_wrapper>>> = meta::enabler>
76-
policy_wrapper(Fx&& fx, Args&&... args)
77-
: value(std::forward<Fx>(fx)), policies(std::forward<Args>(args)...) {
75+
policy_wrapper(Fx&& fx, Args&&... args) : value(std::forward<Fx>(fx)), policies(std::forward<Args>(args)...) {
7876
}
7977

8078
policy_wrapper(const policy_wrapper&) = default;
@@ -91,10 +89,10 @@ namespace sol {
9189
namespace detail {
9290
template <typename T>
9391
using is_policy = meta::is_specialization_of<T, policy_wrapper>;
94-
92+
9593
template <typename T>
9694
inline constexpr bool is_policy_v = is_policy<T>::value;
97-
}
95+
} // namespace detail
9896
} // namespace sol
9997

10098
#endif // SOL_FILTERS_HPP

single/include/sol/forward.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
// This file was generated with a script.
23-
// Generated 2019-11-24 05:21:55.164513 UTC
24-
// This header was generated with sol v3.0.3 (revision fd9e282)
23+
// Generated 2019-11-29 18:08:19.653548 UTC
24+
// This header was generated with sol v3.0.3 (revision 21c0309)
2525
// https://github.com/ThePhD/sol2
2626

2727
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP
@@ -99,13 +99,13 @@
9999

100100
#endif // vc++ || clang++/g++
101101

102-
#if defined(SOL_CHECK_ARGUMENTS) && SOL_CHECK_ARGUMENTS
102+
#if defined(SOL_CHECK_ARGUMENTS) && SOL_CHECK_ARGUMENTS != 0
103103
#if defined(SOL_ALL_SAFETIES_ON)
104104
#define SOL_ALL_SAFETIES_ON 1
105105
#endif // turn all the safeties on
106-
#endif // Compatibility define
106+
#endif // Compatibility Define for Safety
107107

108-
#if defined(SOL_ALL_SAFETIES_ON) && SOL_ALL_SAFETIES_ON
108+
#if defined(SOL_ALL_SAFETIES_ON) && SOL_ALL_SAFETIES_ON != 0
109109

110110
// Checks low-level getter function
111111
// (and thusly, affects nearly entire framework)
@@ -174,7 +174,7 @@
174174

175175
#endif // Turn on Safety for all if top-level macro is defined
176176

177-
#if defined(SOL_IN_DEBUG_DETECTED) && SOL_IN_DEBUG_DETECTED
177+
#if defined(SOL_IN_DEBUG_DETECTED) && SOL_IN_DEBUG_DETECTED != 0
178178

179179
#if !defined(SOL_SAFE_REFERENCES)
180180
// Ensure that references are forcefully type-checked upon construction

0 commit comments

Comments
 (0)