Skip to content

Commit 908074e

Browse files
committed
wew lad
1 parent 97279aa commit 908074e

File tree

10 files changed

+81
-41
lines changed

10 files changed

+81
-41
lines changed

docs/source/errors.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,16 @@ Typical of Visual Studio, the compiler will complain that it is out of heap spac
4747
</PropertyGroup>
4848

4949

50-
This should use the 64-bit tools by default, and increase your maximum heap space to whatever a 64-bit windows machine can handle. If you do not have more than 4 GB of RAM, or you still encounter issues, you should look into using ``create_simple_usertype`` and adding functions 1 by 1 using ``.set( ... )``, as shown in `the simple usertype example here`_.
50+
This should use the 64-bit tools by default, and increase your maximum heap space to whatever a 64-bit windows machine can handle. If you do not have more than 4 GB of RAM, or you still encounter issues, you should look into breaking up your usertype across C++ files. Also, it is imperative to not put all the functions inside single calls to the `new_usertype(...)` function directly: instead, use `my_usertype["func"] = func;` like so:
51+
52+
.. code-block:: cpp
53+
54+
auto my_usertype = lua.new_usertype<my_class>("my_class");
55+
my_usertype["talkin"] = &about;
56+
my_usertype["this"] = &my_class::that;
57+
my_usertype["and_the"] = sol::property(&my_class::third);
58+
59+
5160
5261
5362
Linker Errors

docs/source/mentions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Okay, so the features don't convince you, the documentation doesn't convince you
2323
| |before| | |after| |
2424
+----------+---------+
2525

26-
* In `Perforce`_
26+
* In `Perforce`_ (later versions of the code using sol2 more directly can be requested by e-mailing support@perforce.com !)
2727
* In `High Performance Computing research`_
2828
- `Published research, too!`_
2929
* The `Multiple Arcade Machine Emulator (MAME)`_ project switched from using LuaBridge to sol3!
@@ -42,7 +42,7 @@ Okay, so the features don't convince you, the documentation doesn't convince you
4242
- Elias Daler: `"sol3 saved my life."`_
4343
- Racod's Lair: `"from outdated LuaBridge to superior #sol3"`_
4444
* (Reddit) Posts on reddit about it!
45-
- `sol3's initial reddit release`_
45+
- `sol2's initial reddit release`_
4646
- `Benchmarking Discussing`_
4747
* Somehow landed on a Torque3D thread...
4848
- http://forums.torque3d.org/viewtopic.php?f=32&t=629&p=5246&sid=8e759990ab1ce38a48e896fc9fd62653#p5241

docs/source/performance.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ As shown by the :doc:`benchmarks<benchmarks>`, sol is very performant with its a
1313
* Member variables can sometimes cost an extra lookup to occur within the Lua system (as mentioned :doc:`bottom of the usertype page<api/usertype>`); until we find out a safe way around this, member variables will always incur that extra lookup cost
1414

1515

16-
That's it as far as different performance options are avilable to make sol run faster. Again, please make sure to invoke these only when you know sol is the bottleneck. If you find some form of the performance unacceptable to you, also feel free to open an issue at the github.
16+
Working with things that are already on the stack can also boost performance. Last time regular, call overhead was measured, it was around 5-11 nanoseconds for a single C++ call on a recent (2015) machine. The range is for how slim you make the call, what kind of arguments, et cetera.
17+
18+
If you find some form of the performance unacceptable to you, also feel free to open an issue at the github.

include/sol/function.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ namespace sol {
114114
template <typename... R>
115115
static std::function<Signature> get_std_func(types<R...>, lua_State* L, int index) {
116116
detail::std_shim<R...> fx(unsafe_function(L, index));
117-
return std::move(fx);
117+
return fx;
118118
}
119119

120120
static std::function<Signature> get(lua_State* L, int index, record& tracking) {

include/sol/optional_implementation.hpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ namespace sol { namespace detail {
109109
/// \exclude
110110
#define SOL_TL_OPTIONAL_11_CONSTEXPR
111111
#else
112-
/// \exclude
112+
/// \exclude
113113
#define SOL_TL_OPTIONAL_11_CONSTEXPR constexpr
114114
#endif
115115

@@ -448,10 +448,12 @@ namespace sol {
448448
// This specialization is for when T is not trivially copy constructible
449449
template <class T>
450450
struct optional_copy_base<T, false> : optional_operations_base<T> {
451-
using optional_operations_base<T>::optional_operations_base;
451+
using base_t = optional_operations_base<T>;
452+
453+
using base_t::base_t;
452454

453455
optional_copy_base() = default;
454-
optional_copy_base(const optional_copy_base& rhs) {
456+
optional_copy_base(const optional_copy_base& rhs) : base_t() {
455457
if (rhs.has_value()) {
456458
this->construct(rhs.get());
457459
}
@@ -500,7 +502,8 @@ namespace sol {
500502

501503
// This class manages conditionally having a trivial copy assignment operator
502504
template <class T,
503-
bool = SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(T) && SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) && SOL_TL_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE(T)>
505+
bool = SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(T) && SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T)
506+
&& SOL_TL_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE(T)>
504507
struct optional_copy_assign_base : optional_move_base<T> {
505508
using optional_move_base<T>::optional_move_base;
506509
};
@@ -1124,8 +1127,8 @@ namespace sol {
11241127
}
11251128

11261129
#if 0 // SOL_MODIFICATION
1127-
/// Constructs the stored value with `u`.
1128-
/// \synopsis template <class U=T> constexpr optional(U &&u);
1130+
/// Constructs the stored value with `u`.
1131+
/// \synopsis template <class U=T> constexpr optional(U &&u);
11291132
template <class U = T, detail::enable_if_t<std::is_convertible<U&&, T>::value>* = nullptr, detail::enable_forward_value<T, U>* = nullptr>
11301133
constexpr optional(U&& u) : base(in_place, std::forward<U>(u)) {
11311134
}
@@ -2259,12 +2262,12 @@ namespace sol {
22592262
namespace std {
22602263
// TODO SFINAE
22612264
template <class T>
2262-
struct hash< ::sol::optional<T> > {
2265+
struct hash<::sol::optional<T>> {
22632266
::std::size_t operator()(const ::sol::optional<T>& o) const {
22642267
if (!o.has_value())
22652268
return 0;
22662269

2267-
return ::std::hash< ::sol::detail::remove_const_t<T>>()(*o);
2270+
return ::std::hash<::sol::detail::remove_const_t<T>>()(*o);
22682271
}
22692272
};
22702273
} // namespace std

include/sol/unique_usertype_traits.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ namespace sol {
9595
inline constexpr bool is_unique_usertype_v = is_unique_usertype<T>::value;
9696

9797
namespace detail {
98-
template <typename T>
99-
using is_base_rebindable_test = decltype(T::rebind_base);
98+
template <typename T, typename Rebind = void>
99+
using is_base_rebindable_test = typename T::template rebind_base<Rebind>;
100100
}
101101

102102
template <typename T>
@@ -106,7 +106,7 @@ namespace sol {
106106
inline constexpr bool is_base_rebindable_v = is_base_rebindable<T>::value;
107107

108108
namespace detail {
109-
template <typename T, typename>
109+
template <typename T, typename = void>
110110
struct is_base_rebindable_non_void_sfinae : std::false_type {};
111111

112112
template <typename T>

include/sol/usertype_container.hpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,13 +1258,23 @@ namespace sol {
12581258
}
12591259

12601260
static iterator begin(lua_State*, T& self) {
1261-
using std::begin;
1262-
return begin(self);
1261+
if constexpr (meta::has_begin_end_v<T>) {
1262+
return self.begin();
1263+
}
1264+
else {
1265+
using std::begin;
1266+
return begin(self);
1267+
}
12631268
}
12641269

12651270
static iterator end(lua_State*, T& self) {
1266-
using std::end;
1267-
return end(self);
1271+
if constexpr (meta::has_begin_end_v<T>) {
1272+
return self.end();
1273+
}
1274+
else {
1275+
using std::end;
1276+
return end(self);
1277+
}
12681278
}
12691279

12701280
static int size(lua_State* L) {

include/sol/usertype_storage.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@ namespace sol { namespace u_detail {
658658
this->named_index_table.pop();
659659
}
660660
else if constexpr (std::is_same_v<KeyU, base_classes_tag>) {
661+
(void)key;
661662
this->update_bases<T>(L, std::forward<Value>(value));
662663
}
663664
else if constexpr ((meta::is_string_like_or_constructible<KeyU>::value || std::is_same_v<KeyU, meta_function>)) {

single/include/sol/forward.hpp

Lines changed: 3 additions & 3 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-09-15 04:36:38.687873 UTC
24-
// This header was generated with sol v3.0.3 (revision b2c22ea)
23+
// Generated 2019-10-02 06:37:27.657219 UTC
24+
// This header was generated with sol v3.0.3 (revision 3768063)
2525
// https://github.com/ThePhD/sol2
2626

2727
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP
@@ -34,7 +34,7 @@
3434

3535
// beginning of sol/feature_test.hpp
3636

37-
#if (defined(__cplusplus) && __cplusplus == 201703L) || (defined(_MSC_VER) && _MSC_VER > 1900 && ((defined(_HAS_CXX17) && _HAS_CXX17 == 1) || (defined(_MSVC_LANG) && (_MSVC_LANG > 201402L))))
37+
#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_MSC_VER) && _MSC_VER > 1900 && ((defined(_HAS_CXX17) && _HAS_CXX17 == 1) || (defined(_MSVC_LANG) && (_MSVC_LANG > 201402L))))
3838
#ifndef SOL_CXX17_FEATURES
3939
#define SOL_CXX17_FEATURES 1
4040
#endif // C++17 features macro

single/include/sol/sol.hpp

Lines changed: 33 additions & 18 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-09-15 04:36:35.549872 UTC
24-
// This header was generated with sol v3.0.3 (revision b2c22ea)
23+
// Generated 2019-10-02 06:37:26.989637 UTC
24+
// This header was generated with sol v3.0.3 (revision 3768063)
2525
// https://github.com/ThePhD/sol2
2626

2727
#ifndef SOL_SINGLE_INCLUDE_HPP
@@ -60,7 +60,7 @@
6060

6161
// beginning of sol/feature_test.hpp
6262

63-
#if (defined(__cplusplus) && __cplusplus == 201703L) || (defined(_MSC_VER) && _MSC_VER > 1900 && ((defined(_HAS_CXX17) && _HAS_CXX17 == 1) || (defined(_MSVC_LANG) && (_MSVC_LANG > 201402L))))
63+
#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_MSC_VER) && _MSC_VER > 1900 && ((defined(_HAS_CXX17) && _HAS_CXX17 == 1) || (defined(_MSVC_LANG) && (_MSVC_LANG > 201402L))))
6464
#ifndef SOL_CXX17_FEATURES
6565
#define SOL_CXX17_FEATURES 1
6666
#endif // C++17 features macro
@@ -3752,6 +3752,7 @@ namespace sol { namespace detail {
37523752
#if (__cplusplus == 201103L || defined(SOL_TL_OPTIONAL_MSVC2015) || defined(SOL_TL_OPTIONAL_GCC49))
37533753
#define SOL_TL_OPTIONAL_11_CONSTEXPR
37543754
#else
3755+
/// \exclude
37553756
#define SOL_TL_OPTIONAL_11_CONSTEXPR constexpr
37563757
#endif
37573758

@@ -4087,10 +4088,12 @@ namespace sol {
40874088
// This specialization is for when T is not trivially copy constructible
40884089
template <class T>
40894090
struct optional_copy_base<T, false> : optional_operations_base<T> {
4090-
using optional_operations_base<T>::optional_operations_base;
4091+
using base_t = optional_operations_base<T>;
4092+
4093+
using base_t::base_t;
40914094

40924095
optional_copy_base() = default;
4093-
optional_copy_base(const optional_copy_base& rhs) {
4096+
optional_copy_base(const optional_copy_base& rhs) : base_t() {
40944097
if (rhs.has_value()) {
40954098
this->construct(rhs.get());
40964099
}
@@ -4134,7 +4137,8 @@ namespace sol {
41344137

41354138
// This class manages conditionally having a trivial copy assignment operator
41364139
template <class T,
4137-
bool = SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(T) && SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) && SOL_TL_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE(T)>
4140+
bool = SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(T) && SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T)
4141+
&& SOL_TL_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE(T)>
41384142
struct optional_copy_assign_base : optional_move_base<T> {
41394143
using optional_move_base<T>::optional_move_base;
41404144
};
@@ -4749,8 +4753,8 @@ namespace sol {
47494753
}
47504754

47514755
#if 0 // SOL_MODIFICATION
4752-
/// Constructs the stored value with `u`.
4753-
/// \synopsis template <class U=T> constexpr optional(U &&u);
4756+
/// Constructs the stored value with `u`.
4757+
/// \synopsis template <class U=T> constexpr optional(U &&u);
47544758
template <class U = T, detail::enable_if_t<std::is_convertible<U&&, T>::value>* = nullptr, detail::enable_forward_value<T, U>* = nullptr>
47554759
constexpr optional(U&& u) : base(in_place, std::forward<U>(u)) {
47564760
}
@@ -5880,12 +5884,12 @@ namespace sol {
58805884
namespace std {
58815885
// TODO SFINAE
58825886
template <class T>
5883-
struct hash< ::sol::optional<T> > {
5887+
struct hash<::sol::optional<T>> {
58845888
::std::size_t operator()(const ::sol::optional<T>& o) const {
58855889
if (!o.has_value())
58865890
return 0;
58875891

5888-
return ::std::hash< ::sol::detail::remove_const_t<T>>()(*o);
5892+
return ::std::hash<::sol::detail::remove_const_t<T>>()(*o);
58895893
}
58905894
};
58915895
} // namespace std
@@ -8064,8 +8068,8 @@ namespace sol {
80648068
inline constexpr bool is_unique_usertype_v = is_unique_usertype<T>::value;
80658069

80668070
namespace detail {
8067-
template <typename T>
8068-
using is_base_rebindable_test = decltype(T::rebind_base);
8071+
template <typename T, typename Rebind = void>
8072+
using is_base_rebindable_test = typename T::template rebind_base<Rebind>;
80698073
}
80708074

80718075
template <typename T>
@@ -8075,7 +8079,7 @@ namespace sol {
80758079
inline constexpr bool is_base_rebindable_v = is_base_rebindable<T>::value;
80768080

80778081
namespace detail {
8078-
template <typename T, typename>
8082+
template <typename T, typename = void>
80798083
struct is_base_rebindable_non_void_sfinae : std::false_type {};
80808084

80818085
template <typename T>
@@ -18973,7 +18977,7 @@ namespace sol {
1897318977
template <typename... R>
1897418978
static std::function<Signature> get_std_func(types<R...>, lua_State* L, int index) {
1897518979
detail::std_shim<R...> fx(unsafe_function(L, index));
18976-
return std::move(fx);
18980+
return fx;
1897718981
}
1897818982

1897918983
static std::function<Signature> get(lua_State* L, int index, record& tracking) {
@@ -20285,13 +20289,23 @@ namespace sol {
2028520289
}
2028620290

2028720291
static iterator begin(lua_State*, T& self) {
20288-
using std::begin;
20289-
return begin(self);
20292+
if constexpr (meta::has_begin_end_v<T>) {
20293+
return self.begin();
20294+
}
20295+
else {
20296+
using std::begin;
20297+
return begin(self);
20298+
}
2029020299
}
2029120300

2029220301
static iterator end(lua_State*, T& self) {
20293-
using std::end;
20294-
return end(self);
20302+
if constexpr (meta::has_begin_end_v<T>) {
20303+
return self.end();
20304+
}
20305+
else {
20306+
using std::end;
20307+
return end(self);
20308+
}
2029520309
}
2029620310

2029720311
static int size(lua_State* L) {
@@ -21723,6 +21737,7 @@ namespace sol { namespace u_detail {
2172321737
this->named_index_table.pop();
2172421738
}
2172521739
else if constexpr (std::is_same_v<KeyU, base_classes_tag>) {
21740+
(void)key;
2172621741
this->update_bases<T>(L, std::forward<Value>(value));
2172721742
}
2172821743
else if constexpr ((meta::is_string_like_or_constructible<KeyU>::value || std::is_same_v<KeyU, meta_function>)) {

0 commit comments

Comments
 (0)