mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
make minor changes for XCode and Visual Studio Warning Level 4.
This commit is contained in:
parent
76d7195e64
commit
61d610bb70
|
@ -20,8 +20,8 @@
|
|||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// This file was generated with a script.
|
||||
// Generated 2017-09-16 18:18:13.277753 UTC
|
||||
// This header was generated with sol v2.18.3 (revision 2aecb11)
|
||||
// Generated 2017-09-21 23:23:58.410071 UTC
|
||||
// This header was generated with sol v2.18.3 (revision 76d7195)
|
||||
// https://github.com/ThePhD/sol2
|
||||
|
||||
#ifndef SOL_SINGLE_INCLUDE_HPP
|
||||
|
@ -50,12 +50,15 @@
|
|||
#if __GNUC__ > 6
|
||||
#pragma GCC diagnostic ignored "-Wnoexcept-type"
|
||||
#endif
|
||||
#elif defined __clang__
|
||||
#elif defined _MSC_VER
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4324 ) // structure was padded due to alignment specifier
|
||||
#pragma warning( disable : 4503 ) // decorated name horse shit
|
||||
#pragma warning( disable : 4702 ) // unreachable code
|
||||
#endif // g++
|
||||
#pragma warning( disable: 4127 ) // 'conditional expression is constant' yeah that's the point your old compilers don't have `if constexpr` you jerk
|
||||
#pragma warning( disable: 4505 ) // some other nonsense warning
|
||||
#endif // clang++ vs. g++ vs. VC++
|
||||
|
||||
// beginning of sol/forward.hpp
|
||||
|
||||
|
@ -2496,7 +2499,7 @@ static int compat53_skipBOM (compat53_LoadF *lf) {
|
|||
do {
|
||||
c = getc(lf->f);
|
||||
if (c == EOF || c != *(const unsigned char *)p++) return c;
|
||||
lf->buff[lf->n++] = c; /* to be read by the parser */
|
||||
lf->buff[lf->n++] = (char)c; /* to be read by the parser */
|
||||
} while (*p != '\0');
|
||||
lf->n = 0; /* prefix matched; discard it */
|
||||
return getc(lf->f); /* return next character */
|
||||
|
@ -2571,7 +2574,7 @@ COMPAT53_API int luaL_loadfilex (lua_State *L, const char *filename, const char
|
|||
compat53_skipcomment(&lf, &c); /* re-read initial portion */
|
||||
}
|
||||
if (c != EOF)
|
||||
lf.buff[lf.n++] = c; /* 'c' is the first character of the stream */
|
||||
lf.buff[lf.n++] = (char)(c); /* 'c' is the first character of the stream */
|
||||
status = lua_load(L, &compat53_getF, &lf, lua_tostring(L, -1), mode);
|
||||
readstatus = ferror(lf.f);
|
||||
if (filename) fclose(lf.f); /* close file (even in case of errors) */
|
||||
|
@ -6180,7 +6183,7 @@ namespace sol {
|
|||
ref = LUA_NOREF;
|
||||
return;
|
||||
}
|
||||
if (r.get_type() == type::nil) {
|
||||
if (r.get_type() == type::lua_nil) {
|
||||
ref = LUA_REFNIL;
|
||||
return;
|
||||
}
|
||||
|
@ -7334,7 +7337,7 @@ namespace stack {
|
|||
return true;
|
||||
}
|
||||
type t = type_of(L, -1);
|
||||
if (t == type::table || t == type::none || t == type::nil) {
|
||||
if (t == type::table || t == type::none || t == type::lua_nil) {
|
||||
lua_pop(L, 1);
|
||||
return true;
|
||||
}
|
||||
|
@ -7353,7 +7356,7 @@ namespace stack {
|
|||
static bool check(lua_State* L, int index, Handler&& handler, record& tracking) {
|
||||
tracking.use(1);
|
||||
type t = type_of(L, index);
|
||||
if (t == type::table || t == type::none || t == type::nil || t == type::userdata) {
|
||||
if (t == type::table || t == type::none || t == type::lua_nil || t == type::userdata) {
|
||||
return true;
|
||||
}
|
||||
handler(L, index, type::table, t, "value cannot not have a valid environment");
|
||||
|
@ -7370,7 +7373,7 @@ namespace stack {
|
|||
return true;
|
||||
}
|
||||
type t = type_of(L, -1);
|
||||
if (t == type::table || t == type::none || t == type::nil) {
|
||||
if (t == type::table || t == type::none || t == type::lua_nil) {
|
||||
lua_pop(L, 1);
|
||||
return true;
|
||||
}
|
||||
|
@ -7669,7 +7672,7 @@ namespace stack {
|
|||
tracking.use(1);
|
||||
|
||||
int index = lua_absindex(L, relindex);
|
||||
T arr;
|
||||
T arr{};
|
||||
std::size_t idx = 0;
|
||||
#if SOL_LUA_VERSION >= 503
|
||||
// This method is HIGHLY performant over regular table iteration thanks to the Lua API changes in 5.3
|
||||
|
@ -7701,8 +7704,8 @@ namespace stack {
|
|||
for (int vi = 0; vi < lua_size<V>::value; ++vi) {
|
||||
lua_pushinteger(L, i);
|
||||
lua_gettable(L, index);
|
||||
type t = type_of(L, -1);
|
||||
isnil = t == type::lua_nil;
|
||||
type vt = type_of(L, -1);
|
||||
isnil = vt == type::lua_nil;
|
||||
if (isnil) {
|
||||
if (i == 0) {
|
||||
break;
|
||||
|
@ -8299,7 +8302,7 @@ namespace stack {
|
|||
typedef std::variant_size<V> V_size;
|
||||
typedef std::integral_constant<bool, V_size::value == 0> V_is_empty;
|
||||
|
||||
static V get_empty(std::true_type, lua_State* L, int index, record& tracking) {
|
||||
static V get_empty(std::true_type, lua_State*, int, record&) {
|
||||
return V();
|
||||
}
|
||||
|
||||
|
@ -8308,7 +8311,7 @@ namespace stack {
|
|||
// This should never be reached...
|
||||
// please check your code and understand what you did to bring yourself here
|
||||
std::abort();
|
||||
return V(std::in_place_index<0>, stack::get<T>(L, index));
|
||||
return V(std::in_place_index<0>, stack::get<T>(L, index, tracking));
|
||||
}
|
||||
|
||||
static V get_one(std::integral_constant<std::size_t, 0>, lua_State* L, int index, record& tracking) {
|
||||
|
@ -14851,7 +14854,7 @@ namespace sol {
|
|||
|
||||
static int set(lua_State* L) {
|
||||
stack_object value = stack_object(L, raw_index(3));
|
||||
if (type_of(L, 3) == type::nil) {
|
||||
if (type_of(L, 3) == type::lua_nil) {
|
||||
return erase(L);
|
||||
}
|
||||
auto& self = get_src(L);
|
||||
|
|
6
sol.hpp
6
sol.hpp
|
@ -40,12 +40,16 @@
|
|||
#if __GNUC__ > 6
|
||||
#pragma GCC diagnostic ignored "-Wnoexcept-type"
|
||||
#endif
|
||||
#elif defined __clang__
|
||||
// we'll just let this alone for now
|
||||
#elif defined _MSC_VER
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4324 ) // structure was padded due to alignment specifier
|
||||
#pragma warning( disable : 4503 ) // decorated name horse shit
|
||||
#pragma warning( disable : 4702 ) // unreachable code
|
||||
#endif // g++
|
||||
#pragma warning( disable: 4127 ) // 'conditional expression is constant' yeah that's the point your old compilers don't have `if constexpr` you jerk
|
||||
#pragma warning( disable: 4505 ) // some other nonsense warning
|
||||
#endif // clang++ vs. g++ vs. VC++
|
||||
|
||||
#include "sol/forward.hpp"
|
||||
#include "sol/state.hpp"
|
||||
|
|
|
@ -534,7 +534,7 @@ static int compat53_skipBOM (compat53_LoadF *lf) {
|
|||
do {
|
||||
c = getc(lf->f);
|
||||
if (c == EOF || c != *(const unsigned char *)p++) return c;
|
||||
lf->buff[lf->n++] = c; /* to be read by the parser */
|
||||
lf->buff[lf->n++] = (char)c; /* to be read by the parser */
|
||||
} while (*p != '\0');
|
||||
lf->n = 0; /* prefix matched; discard it */
|
||||
return getc(lf->f); /* return next character */
|
||||
|
@ -611,7 +611,7 @@ COMPAT53_API int luaL_loadfilex (lua_State *L, const char *filename, const char
|
|||
compat53_skipcomment(&lf, &c); /* re-read initial portion */
|
||||
}
|
||||
if (c != EOF)
|
||||
lf.buff[lf.n++] = c; /* 'c' is the first character of the stream */
|
||||
lf.buff[lf.n++] = (char)(c); /* 'c' is the first character of the stream */
|
||||
status = lua_load(L, &compat53_getF, &lf, lua_tostring(L, -1), mode);
|
||||
readstatus = ferror(lf.f);
|
||||
if (filename) fclose(lf.f); /* close file (even in case of errors) */
|
||||
|
|
|
@ -1067,7 +1067,7 @@ namespace sol {
|
|||
|
||||
static int set(lua_State* L) {
|
||||
stack_object value = stack_object(L, raw_index(3));
|
||||
if (type_of(L, 3) == type::nil) {
|
||||
if (type_of(L, 3) == type::lua_nil) {
|
||||
return erase(L);
|
||||
}
|
||||
auto& self = get_src(L);
|
||||
|
|
|
@ -300,7 +300,7 @@ namespace sol {
|
|||
ref = LUA_NOREF;
|
||||
return;
|
||||
}
|
||||
if (r.get_type() == type::nil) {
|
||||
if (r.get_type() == type::lua_nil) {
|
||||
ref = LUA_REFNIL;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -349,7 +349,7 @@ namespace stack {
|
|||
return true;
|
||||
}
|
||||
type t = type_of(L, -1);
|
||||
if (t == type::table || t == type::none || t == type::nil) {
|
||||
if (t == type::table || t == type::none || t == type::lua_nil) {
|
||||
lua_pop(L, 1);
|
||||
return true;
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ namespace stack {
|
|||
static bool check(lua_State* L, int index, Handler&& handler, record& tracking) {
|
||||
tracking.use(1);
|
||||
type t = type_of(L, index);
|
||||
if (t == type::table || t == type::none || t == type::nil || t == type::userdata) {
|
||||
if (t == type::table || t == type::none || t == type::lua_nil || t == type::userdata) {
|
||||
return true;
|
||||
}
|
||||
handler(L, index, type::table, t, "value cannot not have a valid environment");
|
||||
|
@ -385,7 +385,7 @@ namespace stack {
|
|||
return true;
|
||||
}
|
||||
type t = type_of(L, -1);
|
||||
if (t == type::table || t == type::none || t == type::nil) {
|
||||
if (t == type::table || t == type::none || t == type::lua_nil) {
|
||||
lua_pop(L, 1);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ namespace stack {
|
|||
tracking.use(1);
|
||||
|
||||
int index = lua_absindex(L, relindex);
|
||||
T arr;
|
||||
T arr{};
|
||||
std::size_t idx = 0;
|
||||
#if SOL_LUA_VERSION >= 503
|
||||
// This method is HIGHLY performant over regular table iteration thanks to the Lua API changes in 5.3
|
||||
|
@ -151,8 +151,8 @@ namespace stack {
|
|||
for (int vi = 0; vi < lua_size<V>::value; ++vi) {
|
||||
lua_pushinteger(L, i);
|
||||
lua_gettable(L, index);
|
||||
type t = type_of(L, -1);
|
||||
isnil = t == type::lua_nil;
|
||||
type vt = type_of(L, -1);
|
||||
isnil = vt == type::lua_nil;
|
||||
if (isnil) {
|
||||
if (i == 0) {
|
||||
break;
|
||||
|
@ -749,7 +749,7 @@ namespace stack {
|
|||
typedef std::variant_size<V> V_size;
|
||||
typedef std::integral_constant<bool, V_size::value == 0> V_is_empty;
|
||||
|
||||
static V get_empty(std::true_type, lua_State* L, int index, record& tracking) {
|
||||
static V get_empty(std::true_type, lua_State*, int, record&) {
|
||||
return V();
|
||||
}
|
||||
|
||||
|
@ -758,7 +758,7 @@ namespace stack {
|
|||
// This should never be reached...
|
||||
// please check your code and understand what you did to bring yourself here
|
||||
std::abort();
|
||||
return V(std::in_place_index<0>, stack::get<T>(L, index));
|
||||
return V(std::in_place_index<0>, stack::get<T>(L, index, tracking));
|
||||
}
|
||||
|
||||
static V get_one(std::integral_constant<std::size_t, 0>, lua_State* L, int index, record& tracking) {
|
||||
|
|
|
@ -403,13 +403,10 @@ void unordered_container_check(sol::state& lua, T& items) {
|
|||
12, 13, 15, 16, 17, 18, 20
|
||||
};
|
||||
{
|
||||
std::size_t idx = 0;
|
||||
for (const auto& i : items) {
|
||||
const auto& v = values[idx];
|
||||
for (const auto& v : values) {
|
||||
auto it = items.find(v);
|
||||
REQUIRE((it != items.cend()));
|
||||
REQUIRE((*it == v));
|
||||
++idx;
|
||||
}
|
||||
}
|
||||
REQUIRE((s1 == 7));
|
||||
|
@ -512,13 +509,13 @@ end
|
|||
int v2 = lua["v2"];
|
||||
int v3 = lua["v3"];
|
||||
std::pair<const short, int> values[] = {
|
||||
{ 12, 31 },
|
||||
{ 13, 23 },
|
||||
{ 15, 25 },
|
||||
{ 16, 26 },
|
||||
{ 17, 27 },
|
||||
{ 18, 28 },
|
||||
{ 20, 30 }
|
||||
{ (short)12, 31 },
|
||||
{ (short)13, 23 },
|
||||
{ (short)15, 25 },
|
||||
{ (short)16, 26 },
|
||||
{ (short)17, 27 },
|
||||
{ (short)18, 28 },
|
||||
{ (short)20, 30 }
|
||||
};
|
||||
{
|
||||
std::size_t idx = 0;
|
||||
|
@ -608,23 +605,19 @@ void associative_unordered_container_check(sol::state& lua, T& items) {
|
|||
int v2 = lua["v2"];
|
||||
int v3 = lua["v3"];
|
||||
std::pair<const short, int> values[] = {
|
||||
{ 12, 31 },
|
||||
{ 13, 23 },
|
||||
{ 15, 25 },
|
||||
{ 16, 26 },
|
||||
{ 17, 27 },
|
||||
{ 18, 28 },
|
||||
{ 20, 30 }
|
||||
{ (short)12, 31 },
|
||||
{ (short)13, 23 },
|
||||
{ (short)15, 25 },
|
||||
{ (short)16, 26 },
|
||||
{ (short)17, 27 },
|
||||
{ (short)18, 28 },
|
||||
{ (short)20, 30 }
|
||||
};
|
||||
std::pair<const short, int> item_values[7];
|
||||
{
|
||||
std::size_t idx = 0;
|
||||
for (const auto& i : items) {
|
||||
const auto& v = values[idx];
|
||||
for (const auto& v : values) {
|
||||
auto it = items.find(v.first);
|
||||
REQUIRE((it != items.cend()));
|
||||
REQUIRE((it->second == v.second));
|
||||
++idx;
|
||||
}
|
||||
}
|
||||
REQUIRE((s1 == 7));
|
||||
|
@ -862,11 +855,11 @@ TEST_CASE("containers/associative ordered containers", "check associative (map)
|
|||
lua.open_libraries(sol::lib::base);
|
||||
|
||||
std::map<short, int> items{
|
||||
{ 11, 21 },
|
||||
{ 12, 22 },
|
||||
{ 13, 23 },
|
||||
{ 14, 24 },
|
||||
{ 15, 25 }
|
||||
{ (short)11, 21 },
|
||||
{ (short)12, 22 },
|
||||
{ (short)13, 23 },
|
||||
{ (short)14, 24 },
|
||||
{ (short)15, 25 }
|
||||
};
|
||||
lua["c"] = &items;
|
||||
associative_ordered_container_check(lua, items);
|
||||
|
@ -876,11 +869,11 @@ TEST_CASE("containers/associative ordered containers", "check associative (map)
|
|||
lua.open_libraries(sol::lib::base);
|
||||
|
||||
std::multimap<short, int> items{
|
||||
{ 11, 21 },
|
||||
{ 12, 22 },
|
||||
{ 13, 23 },
|
||||
{ 14, 24 },
|
||||
{ 15, 25 }
|
||||
{ (short)11, 21 },
|
||||
{ (short)12, 22 },
|
||||
{ (short)13, 23 },
|
||||
{ (short)14, 24 },
|
||||
{ (short)15, 25 }
|
||||
};
|
||||
lua["c"] = &items;
|
||||
associative_ordered_container_check(lua, items);
|
||||
|
@ -893,11 +886,11 @@ TEST_CASE("containers/associative unordered containers", "check associative (map
|
|||
lua.open_libraries(sol::lib::base);
|
||||
|
||||
std::unordered_map<short, int> items{
|
||||
{ 11, 21 },
|
||||
{ 12, 22 },
|
||||
{ 13, 23 },
|
||||
{ 14, 24 },
|
||||
{ 15, 25 }
|
||||
{ (short)11, 21 },
|
||||
{ (short)12, 22 },
|
||||
{ (short)13, 23 },
|
||||
{ (short)14, 24 },
|
||||
{ (short)15, 25 }
|
||||
};
|
||||
lua["c"] = &items;
|
||||
associative_unordered_container_check(lua, items);
|
||||
|
@ -907,11 +900,11 @@ TEST_CASE("containers/associative unordered containers", "check associative (map
|
|||
lua.open_libraries(sol::lib::base);
|
||||
|
||||
std::unordered_multimap<short, int> items{
|
||||
{ 11, 21 },
|
||||
{ 12, 22 },
|
||||
{ 13, 23 },
|
||||
{ 14, 24 },
|
||||
{ 15, 25 }
|
||||
{ (short)11, 21 },
|
||||
{ (short)12, 22 },
|
||||
{ (short)13, 23 },
|
||||
{ (short)14, 24 },
|
||||
{ (short)15, 25 }
|
||||
};
|
||||
lua["c"] = &items;
|
||||
associative_unordered_container_check(lua, items);
|
||||
|
|
|
@ -158,7 +158,6 @@ TEST_CASE("functions/return order and multi get", "Check if return order is in t
|
|||
lua.set_function("f", [] {
|
||||
return std::make_tuple(10, 11, 12);
|
||||
});
|
||||
int a = 0;
|
||||
lua.set_function("h", []() {
|
||||
return std::make_tuple(10, 10.0f);
|
||||
});
|
||||
|
|
|
@ -267,6 +267,7 @@ tc3 = TestClass03(tc1)
|
|||
TestClass01& tc1 = lua["tc1"];
|
||||
TestClass02& tc2 = lua["tc2"];
|
||||
TestClass03& tc3 = lua["tc3"];
|
||||
REQUIRE(tc0.Thing() == 123);
|
||||
REQUIRE(tc1.a == 1);
|
||||
REQUIRE(tc2.a == 1);
|
||||
REQUIRE(tc2.b == 123);
|
||||
|
|
|
@ -4,12 +4,27 @@
|
|||
#include <sol.hpp>
|
||||
|
||||
TEST_CASE("storage/registry construction", "ensure entries from the registry can be retrieved") {
|
||||
const auto& script = R"(
|
||||
const auto& code = R"(
|
||||
function f()
|
||||
return 2
|
||||
end
|
||||
)";
|
||||
|
||||
sol::state lua;
|
||||
lua.script(code);
|
||||
sol::function f = lua["f"];
|
||||
sol::reference r = lua["f"];
|
||||
sol::function regf(lua, f);
|
||||
sol::reference regr(lua, sol::ref_index(f.registry_index()));
|
||||
bool isequal = f == r;
|
||||
REQUIRE(isequal);
|
||||
isequal = f == regf;
|
||||
REQUIRE(isequal);
|
||||
isequal = f == regr;
|
||||
REQUIRE(isequal);
|
||||
}
|
||||
|
||||
TEST_CASE("storage/registry construction empty", "ensure entries from the registry can be retrieved") {
|
||||
sol::state lua;
|
||||
sol::function f = lua["f"];
|
||||
sol::reference r = lua["f"];
|
||||
|
|
|
@ -193,7 +193,7 @@ TEST_CASE("tables/for_each", "Testing the use of for_each to get values from a l
|
|||
REQUIRE((value.as<double>() == 123));
|
||||
}
|
||||
break;
|
||||
case sol::type::nil:
|
||||
case sol::type::lua_nil:
|
||||
REQUIRE((value.as<double>() == 3));
|
||||
break;
|
||||
default:
|
||||
|
@ -243,7 +243,7 @@ TEST_CASE("tables/for_each empty", "empty tables should not crash") {
|
|||
REQUIRE((value.as<double>() == 123));
|
||||
}
|
||||
break;
|
||||
case sol::type::nil:
|
||||
case sol::type::lua_nil:
|
||||
REQUIRE((value.as<double>() == 3));
|
||||
break;
|
||||
default:
|
||||
|
@ -314,7 +314,7 @@ TEST_CASE("tables/iterators", "Testing the use of iteratrs to get values from a
|
|||
REQUIRE((value.as<double>() == 123));
|
||||
}
|
||||
break;
|
||||
case sol::type::nil:
|
||||
case sol::type::lua_nil:
|
||||
REQUIRE((value.as<double>() == 3));
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -289,7 +289,7 @@ TEST_CASE("object/conversions", "make sure all basic reference types can be made
|
|||
REQUIRE(ond.get_type() == sol::type::number);
|
||||
REQUIRE(osl.get_type() == sol::type::string);
|
||||
REQUIRE(os.get_type() == sol::type::string);
|
||||
REQUIRE(omn.get_type() == sol::type::nil);
|
||||
REQUIRE(omn.get_type() == sol::type::lua_nil);
|
||||
REQUIRE(oenv.get_type() == sol::type::table);
|
||||
}
|
||||
|
||||
|
@ -343,7 +343,7 @@ TEST_CASE("object/main_* conversions", "make sure all basic reference types can
|
|||
REQUIRE(ond.get_type() == sol::type::number);
|
||||
REQUIRE(osl.get_type() == sol::type::string);
|
||||
REQUIRE(os.get_type() == sol::type::string);
|
||||
REQUIRE(omn.get_type() == sol::type::nil);
|
||||
REQUIRE(omn.get_type() == sol::type::lua_nil);
|
||||
REQUIRE(oenv.get_type() == sol::type::table);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user