Herpin' that derp.

SOL_NO_COMPAT is now in the proper place and documented in the compatibility part of the API.
Basic test for `table::add`
This commit is contained in:
ThePhD 2016-06-19 19:02:40 -04:00
parent 556be8da98
commit b6928b4b4e
17 changed files with 1327 additions and 1272 deletions

View File

@ -7,6 +7,8 @@ This is a detail header used to maintain compatability with the 5.2 and 5.3 APIs
It is not fully documented as this header's only purpose is for internal use to make sure Sol compiles across all platforms / distributions with no errors or missing Lua functionality. If you think there's some compatibility features we are missing or if you are running into redefinition errors, please make an `issue in the issue tracker`_.
If you have this already in your project or you have your own compatibility layer, then please ``#define SOL_NO_COMPAT 1`` before including ``sol.hpp`` or pass this flag on the command line to turn off the compatibility wrapper.
For the licenses, see :doc:`here<../licenses>`
.. _issue in the issue tracker: https://github.com/ThePhD/sol2/issues/

View File

@ -1,4 +1,26 @@
#pragma once
// The MIT License (MIT)
// Copyright (c) 2013-2016 Rappt1101010z, ThePhD and contributors
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef SOL_BIND_TRAITS_HPP
#define SOL_BIND_TRAITS_HPP
#include "tuple.hpp"
@ -216,3 +238,5 @@ using function_return_t = typename bind_traits<Signature>::return_type;
} // meta
} // sol
#endif // SOL_BIND_TRAITS

View File

@ -1,6 +1,6 @@
// The MIT License (MIT)
// Copyright (c) 2013-2016 Rappt1101010z, ThePhD and contributors
// Copyright (c) 2013-2016 Rapptz, ThePhD and contributors
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in

View File

@ -27,9 +27,10 @@
// but has been modified in many places for use with Sol and luajit,
// though the core abstractions remain the same
#include "compatibility/version.hpp"
#ifndef SOL_NO_COMPAT
#include "compatibility/version.hpp"
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -111,5 +111,6 @@ public:
return invoke(types<Ret...>(), std::make_index_sequence<sizeof...(Ret)>(), pushcount);
}
};
}
} // sol
#endif // SOL_COUROUTINE_HPP

View File

@ -38,6 +38,9 @@ namespace detail {
struct SOL_DEPRECATED deprecate_type {
using type = T;
};
template <typename T>
using deprecate_type_t = typename deprecate_type<T>::type;
} // detail
} // sol

View File

@ -30,6 +30,7 @@ namespace detail {
struct direct_error_tag {};
const auto direct_error = direct_error_tag{};
} // detail
class error : public std::runtime_error {
private:
// Because VC++ is a fuccboi
@ -48,6 +49,7 @@ public:
return w.c_str();
}
};
} // sol
#endif // SOL_ERROR_HPP

View File

@ -142,13 +142,13 @@ namespace sol {
int make_regs(regs_t& l, int index, sol::call_construction, F&&, Args&&... args) {
callconstructfunc = call<I + 1>;
secondarymeta = true;
int endindex = make_regs<I + 2>(l, index + 1, std::forward<Args>(args)...);
int endindex = make_regs<I + 2>(l, index, std::forward<Args>(args)...);
return endindex;
}
template <std::size_t I = 0, typename... Bases, typename... Args>
int make_regs(regs_t& l, int index, base_classes_tag, bases<Bases...>, Args&&... args) {
int endindex = make_regs<I + 2>(l, index + 1, std::forward<Args>(args)...);
int endindex = make_regs<I + 2>(l, index, std::forward<Args>(args)...);
if (sizeof...(Bases) < 1) {
(void)detail::swallow{ 0, ((detail::has_derived<Bases>::value = false), 0)... };
return endindex;

View File

@ -4,6 +4,10 @@
#include <sol.hpp>
#include <iostream>
#include <map>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <vector>
#include "test_stack_guard.hpp"
std::string free_function() {
@ -531,3 +535,21 @@ TEST_CASE("tables/operator[]-optional", "Test if proxies on tables can lazily ev
REQUIRE(non_nope3.value() == 35);
REQUIRE(non_nope4.value() == 35);
}
TEST_CASE("tables/add", "Basic test to make sure the 'add' feature works") {
static const int sz = 120;
sol::state lua;
sol::table t = lua.create_table(sz, 0);
std::vector<int> bigvec( sz );
std::iota(bigvec.begin(), bigvec.end(), 1);
for (std::size_t i = 0; i < bigvec.size(); ++i) {
t.add(bigvec[i]);
}
for (std::size_t i = 0; i < bigvec.size(); ++i) {
int val = t[i + 1];
REQUIRE(val == bigvec[i]);
}
}