sol.hpp
Go to the documentation of this file.
1 // The MIT License (MIT)
2 
3 // Copyright (c) 2013-2020 Rapptz, ThePhD and contributors
4 
5 // Permission is hereby granted, free of charge, to any person obtaining a copy of
6 // this software and associated documentation files (the "Software"), to deal in
7 // the Software without restriction, including without limitation the rights to
8 // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 // the Software, and to permit persons to whom the Software is furnished to do so,
10 // subject to the following conditions:
11 
12 // The above copyright notice and this permission notice shall be included in all
13 // copies or substantial portions of the Software.
14 
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 
22 // This file was generated with a script.
23 // Generated 2022-06-25 08:14:19.151876 UTC
24 // This header was generated with sol v3.3.0 (revision eba86625)
25 // https://github.com/ThePhD/sol2
26 
27 #ifndef SOL_SINGLE_INCLUDE_HPP
28 #define SOL_SINGLE_INCLUDE_HPP
29 
30 // beginning of sol/sol.hpp
31 
32 #ifndef SOL_HPP
33 #define SOL_HPP
34 
35 // beginning of sol/version.hpp
36 
37 #include <sol/config.hpp>
38 
39 #define SOL_VERSION_MAJOR 3
40 #define SOL_VERSION_MINOR 2
41 #define SOL_VERSION_PATCH 3
42 #define SOL_VERSION_STRING "3.2.3"
43 #define SOL_VERSION ((SOL_VERSION_MAJOR * 100000) + (SOL_VERSION_MINOR * 100) + (SOL_VERSION_PATCH))
44 
45 #define SOL_TOKEN_TO_STRING_POST_EXPANSION_I_(_TOKEN) #_TOKEN
46 #define SOL_TOKEN_TO_STRING_I_(_TOKEN) SOL_TOKEN_TO_STRING_POST_EXPANSION_I_(_TOKEN)
47 
48 #define SOL_CONCAT_TOKENS_POST_EXPANSION_I_(_LEFT, _RIGHT) _LEFT##_RIGHT
49 #define SOL_CONCAT_TOKENS_I_(_LEFT, _RIGHT) SOL_CONCAT_TOKENS_POST_EXPANSION_I_(_LEFT, _RIGHT)
50 
51 #define SOL_RAW_IS_ON(OP_SYMBOL) ((3 OP_SYMBOL 3) != 0)
52 #define SOL_RAW_IS_OFF(OP_SYMBOL) ((3 OP_SYMBOL 3) == 0)
53 #define SOL_RAW_IS_DEFAULT_ON(OP_SYMBOL) ((3 OP_SYMBOL 3) > 3)
54 #define SOL_RAW_IS_DEFAULT_OFF(OP_SYMBOL) ((3 OP_SYMBOL 3 OP_SYMBOL 3) < 0)
55 
56 #define SOL_IS_ON(OP_SYMBOL) SOL_RAW_IS_ON(OP_SYMBOL ## _I_)
57 #define SOL_IS_OFF(OP_SYMBOL) SOL_RAW_IS_OFF(OP_SYMBOL ## _I_)
58 #define SOL_IS_DEFAULT_ON(OP_SYMBOL) SOL_RAW_IS_DEFAULT_ON(OP_SYMBOL ## _I_)
59 #define SOL_IS_DEFAULT_OFF(OP_SYMBOL) SOL_RAW_IS_DEFAULT_OFF(OP_SYMBOL ## _I_)
60 
61 #define SOL_ON |
62 #define SOL_OFF ^
63 #define SOL_DEFAULT_ON +
64 #define SOL_DEFAULT_OFF -
65 
66 #if defined(SOL_BUILD_CXX_MODE)
67  #if (SOL_BUILD_CXX_MODE != 0)
68  #define SOL_BUILD_CXX_MODE_I_ SOL_ON
69  #else
70  #define SOL_BUILD_CXX_MODE_I_ SOL_OFF
71  #endif
72 #elif defined(__cplusplus)
73  #define SOL_BUILD_CXX_MODE_I_ SOL_DEFAULT_ON
74 #else
75  #define SOL_BUILD_CXX_MODE_I_ SOL_DEFAULT_OFF
76 #endif
77 
78 #if defined(SOL_BUILD_C_MODE)
79  #if (SOL_BUILD_C_MODE != 0)
80  #define SOL_BUILD_C_MODE_I_ SOL_ON
81  #else
82  #define SOL_BUILD_C_MODE_I_ SOL_OFF
83  #endif
84 #elif defined(__STDC__)
85  #define SOL_BUILD_C_MODE_I_ SOL_DEFAULT_ON
86 #else
87  #define SOL_BUILD_C_MODE_I_ SOL_DEFAULT_OFF
88 #endif
89 
90 #if SOL_IS_ON(SOL_BUILD_C_MODE)
91  #include <stddef.h>
92  #include <stdint.h>
93  #include <limits.h>
94 #else
95  #include <cstddef>
96  #include <cstdint>
97  #include <climits>
98 #endif
99 
100 #if defined(SOL_COMPILER_VCXX)
101  #if defined(SOL_COMPILER_VCXX != 0)
102  #define SOL_COMPILER_VCXX_I_ SOL_ON
103  #else
104  #define SOL_COMPILER_VCXX_I_ SOL_OFF
105  #endif
106 #elif defined(_MSC_VER)
107  #define SOL_COMPILER_VCXX_I_ SOL_DEFAULT_ON
108 #else
109  #define SOL_COMPILER_VCXX_I_ SOL_DEFAULT_OFF
110 #endif
111 
112 #if defined(SOL_COMPILER_GCC)
113  #if defined(SOL_COMPILER_GCC != 0)
114  #define SOL_COMPILER_GCC_I_ SOL_ON
115  #else
116  #define SOL_COMPILER_GCC_I_ SOL_OFF
117  #endif
118 #elif defined(__GNUC__)
119  #define SOL_COMPILER_GCC_I_ SOL_DEFAULT_ON
120 #else
121  #define SOL_COMPILER_GCC_I_ SOL_DEFAULT_OFF
122 #endif
123 
124 #if defined(SOL_COMPILER_CLANG)
125  #if defined(SOL_COMPILER_CLANG != 0)
126  #define SOL_COMPILER_CLANG_I_ SOL_ON
127  #else
128  #define SOL_COMPILER_CLANG_I_ SOL_OFF
129  #endif
130 #elif defined(__clang__)
131  #define SOL_COMPILER_CLANG_I_ SOL_DEFAULT_ON
132 #else
133  #define SOL_COMPILER_CLANG_I_ SOL_DEFAULT_OFF
134 #endif
135 
136 #if defined(SOL_COMPILER_EDG)
137  #if defined(SOL_COMPILER_EDG != 0)
138  #define SOL_COMPILER_EDG_I_ SOL_ON
139  #else
140  #define SOL_COMPILER_EDG_I_ SOL_OFF
141  #endif
142 #else
143  #define SOL_COMPILER_EDG_I_ SOL_DEFAULT_OFF
144 #endif
145 
146 #if defined(SOL_COMPILER_MINGW)
147  #if (SOL_COMPILER_MINGW != 0)
148  #define SOL_COMPILER_MINGW_I_ SOL_ON
149  #else
150  #define SOL_COMPILER_MINGW_I_ SOL_OFF
151  #endif
152 #elif defined(__MINGW32__)
153  #define SOL_COMPILER_MINGW_I_ SOL_DEFAULT_ON
154 #else
155  #define SOL_COMPILER_MINGW_I_ SOL_DEFAULT_OFF
156 #endif
157 
158 #if SIZE_MAX <= 0xFFFFULL
159  #define SOL_PLATFORM_X16_I_ SOL_ON
160  #define SOL_PLATFORM_X86_I_ SOL_OFF
161  #define SOL_PLATFORM_X64_I_ SOL_OFF
162 #elif SIZE_MAX <= 0xFFFFFFFFULL
163  #define SOL_PLATFORM_X16_I_ SOL_OFF
164  #define SOL_PLATFORM_X86_I_ SOL_ON
165  #define SOL_PLATFORM_X64_I_ SOL_OFF
166 #else
167  #define SOL_PLATFORM_X16_I_ SOL_OFF
168  #define SOL_PLATFORM_X86_I_ SOL_OFF
169  #define SOL_PLATFORM_X64_I_ SOL_ON
170 #endif
171 
172 #define SOL_PLATFORM_ARM32_I_ SOL_OFF
173 #define SOL_PLATFORM_ARM64_I_ SOL_OFF
174 
175 #if defined(SOL_PLATFORM_WINDOWS)
176  #if (SOL_PLATFORM_WINDOWS != 0)
177  #define SOL_PLATFORM_WINDOWS_I_ SOL_ON
178  #else
179  #define SOL_PLATFORM_WINDOWS_I_ SOL_OFF
180  #endif
181 #elif defined(_WIN32)
182  #define SOL_PLATFORM_WINDOWS_I_ SOL_DEFAULT_ON
183 #else
184  #define SOL_PLATFORM_WINDOWS_I_ SOL_DEFAULT_OFF
185 #endif
186 
187 #if defined(SOL_PLATFORM_CYGWIN)
188  #if (SOL_PLATFORM_CYGWIN != 0)
189  #define SOL_PLATFORM_CYGWIN_I_ SOL_ON
190  #else
191  #define SOL_PLATFORM_CYGWIN_I_ SOL_ON
192  #endif
193 #elif defined(__CYGWIN__)
194  #define SOL_PLATFORM_CYGWIN_I_ SOL_DEFAULT_ON
195 #else
196  #define SOL_PLATFORM_CYGWIN_I_ SOL_DEFAULT_OFF
197 #endif
198 
199 #if defined(SOL_PLATFORM_APPLE)
200  #if (SOL_PLATFORM_APPLE != 0)
201  #define SOL_PLATFORM_APPLE_I_ SOL_ON
202  #else
203  #define SOL_PLATFORM_APPLE_I_ SOL_OFF
204  #endif
205 #elif defined(__APPLE__)
206  #define SOL_PLATFORM_APPLE_I_ SOL_DEFAULT_ON
207 #else
208  #define SOL_PLATFORM_APPLE_I_ SOL_DEFAULT_OFF
209 #endif
210 
211 #if defined(SOL_PLATFORM_UNIX)
212  #if (SOL_PLATFORM_UNIX != 0)
213  #define SOL_PLATFORM_UNIXLIKE_I_ SOL_ON
214  #else
215  #define SOL_PLATFORM_UNIXLIKE_I_ SOL_OFF
216  #endif
217 #elif defined(__unix__)
218  #define SOL_PLATFORM_UNIXLIKE_I_ SOL_DEFAUKT_ON
219 #else
220  #define SOL_PLATFORM_UNIXLIKE_I_ SOL_DEFAULT_OFF
221 #endif
222 
223 #if defined(SOL_PLATFORM_LINUX)
224  #if (SOL_PLATFORM_LINUX != 0)
225  #define SOL_PLATFORM_LINUXLIKE_I_ SOL_ON
226  #else
227  #define SOL_PLATFORM_LINUXLIKE_I_ SOL_OFF
228  #endif
229 #elif defined(__LINUX__)
230  #define SOL_PLATFORM_LINUXLIKE_I_ SOL_DEFAUKT_ON
231 #else
232  #define SOL_PLATFORM_LINUXLIKE_I_ SOL_DEFAULT_OFF
233 #endif
234 
235 #define SOL_PLATFORM_APPLE_IPHONE_I_ SOL_OFF
236 #define SOL_PLATFORM_BSDLIKE_I_ SOL_OFF
237 
238 #if defined(SOL_IN_DEBUG_DETECTED)
239  #if SOL_IN_DEBUG_DETECTED != 0
240  #define SOL_DEBUG_BUILD_I_ SOL_ON
241  #else
242  #define SOL_DEBUG_BUILD_I_ SOL_OFF
243  #endif
244 #elif !defined(NDEBUG)
245  #if SOL_IS_ON(SOL_COMPILER_VCXX) && defined(_DEBUG)
246  #define SOL_DEBUG_BUILD_I_ SOL_ON
247  #elif (SOL_IS_ON(SOL_COMPILER_CLANG) || SOL_IS_ON(SOL_COMPILER_GCC)) && !defined(__OPTIMIZE__)
248  #define SOL_DEBUG_BUILD_I_ SOL_ON
249  #else
250  #define SOL_DEBUG_BUILD_I_ SOL_OFF
251  #endif
252 #else
253  #define SOL_DEBUG_BUILD_I_ SOL_DEFAULT_OFF
254 #endif // We are in a debug mode of some sort
255 
256 #if defined(SOL_NO_EXCEPTIONS)
257  #if (SOL_NO_EXCEPTIONS != 0)
258  #define SOL_EXCEPTIONS_I_ SOL_OFF
259  #else
260  #define SOL_EXCEPTIONS_I_ SOL_ON
261  #endif
262 #elif SOL_IS_ON(SOL_COMPILER_VCXX)
263  #if !defined(_CPPUNWIND)
264  #define SOL_EXCEPTIONS_I_ SOL_OFF
265  #else
266  #define SOL_EXCEPTIONS_I_ SOL_ON
267  #endif
268 #elif SOL_IS_ON(SOL_COMPILER_CLANG) || SOL_IS_ON(SOL_COMPILER_GCC)
269  #if !defined(__EXCEPTIONS)
270  #define SOL_EXCEPTIONS_I_ SOL_OFF
271  #else
272  #define SOL_EXCEPTIONS_I_ SOL_ON
273  #endif
274 #else
275  #define SOL_EXCEPTIONS_I_ SOL_DEFAULT_ON
276 #endif
277 
278 #if defined(SOL_NO_RTTI)
279  #if (SOL_NO_RTTI != 0)
280  #define SOL_RTTI_I_ SOL_OFF
281  #else
282  #define SOL_RTTI_I_ SOL_ON
283  #endif
284 #elif SOL_IS_ON(SOL_COMPILER_VCXX)
285  #if !defined(_CPPRTTI)
286  #define SOL_RTTI_I_ SOL_OFF
287  #else
288  #define SOL_RTTI_I_ SOL_ON
289  #endif
290 #elif SOL_IS_ON(SOL_COMPILER_CLANG) || SOL_IS_ON(SOL_COMPILER_GCC)
291  #if !defined(__GXX_RTTI)
292  #define SOL_RTTI_I_ SOL_OFF
293  #else
294  #define SOL_RTTI_I_ SOL_ON
295  #endif
296 #else
297  #define SOL_RTTI_I_ SOL_DEFAULT_ON
298 #endif
299 
300 #if defined(SOL_NO_THREAD_LOCAL)
301  #if SOL_NO_THREAD_LOCAL != 0
302  #define SOL_USE_THREAD_LOCAL_I_ SOL_OFF
303  #else
304  #define SOL_USE_THREAD_LOCAL_I_ SOL_ON
305  #endif
306 #else
307  #define SOL_USE_THREAD_LOCAL_I_ SOL_DEFAULT_ON
308 #endif // thread_local keyword is bjorked on some platforms
309 
310 #if defined(SOL_ALL_SAFETIES_ON)
311  #if SOL_ALL_SAFETIES_ON != 0
312  #define SOL_ALL_SAFETIES_ON_I_ SOL_ON
313  #else
314  #define SOL_ALL_SAFETIES_ON_I_ SOL_OFF
315  #endif
316 #else
317  #define SOL_ALL_SAFETIES_ON_I_ SOL_DEFAULT_OFF
318 #endif
319 
320 #if defined(SOL_SAFE_GETTER)
321  #if SOL_SAFE_GETTER != 0
322  #define SOL_SAFE_GETTER_I_ SOL_ON
323  #else
324  #define SOL_SAFE_GETTER_I_ SOL_OFF
325  #endif
326 #else
327  #if SOL_IS_ON(SOL_ALL_SAFETIES_ON)
328  #define SOL_SAFE_GETTER_I_ SOL_ON
329  #elif SOL_IS_ON(SOL_DEBUG_BUILD)
330  #define SOL_SAFE_GETTER_I_ SOL_DEFAULT_ON
331  #else
332  #define SOL_SAFE_GETTER_I_ SOL_DEFAULT_OFF
333  #endif
334 #endif
335 
336 #if defined(SOL_SAFE_USERTYPE)
337  #if SOL_SAFE_USERTYPE != 0
338  #define SOL_SAFE_USERTYPE_I_ SOL_ON
339  #else
340  #define SOL_SAFE_USERTYPE_I_ SOL_OFF
341  #endif
342 #else
343  #if SOL_IS_ON(SOL_ALL_SAFETIES_ON)
344  #define SOL_SAFE_USERTYPE_I_ SOL_ON
345  #elif SOL_IS_ON(SOL_DEBUG_BUILD)
346  #define SOL_SAFE_USERTYPE_I_ SOL_DEFAULT_ON
347  #else
348  #define SOL_SAFE_USERTYPE_I_ SOL_DEFAULT_OFF
349  #endif
350 #endif
351 
352 #if defined(SOL_SAFE_REFERENCES)
353  #if SOL_SAFE_REFERENCES != 0
354  #define SOL_SAFE_REFERENCES_I_ SOL_ON
355  #else
356  #define SOL_SAFE_REFERENCES_I_ SOL_OFF
357  #endif
358 #else
359  #if SOL_IS_ON(SOL_ALL_SAFETIES_ON)
360  #define SOL_SAFE_REFERENCES_I_ SOL_ON
361  #elif SOL_IS_ON(SOL_DEBUG_BUILD)
362  #define SOL_SAFE_REFERENCES_I_ SOL_DEFAULT_ON
363  #else
364  #define SOL_SAFE_REFERENCES_I_ SOL_DEFAULT_OFF
365  #endif
366 #endif
367 
368 #if defined(SOL_SAFE_FUNCTIONS)
369  #if SOL_SAFE_FUNCTIONS != 0
370  #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_ON
371  #else
372  #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_OFF
373  #endif
374 #elif defined (SOL_SAFE_FUNCTION_OBJECTS)
375  #if SOL_SAFE_FUNCTION_OBJECTS != 0
376  #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_ON
377  #else
378  #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_OFF
379  #endif
380 #else
381  #if SOL_IS_ON(SOL_ALL_SAFETIES_ON)
382  #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_ON
383  #elif SOL_IS_ON(SOL_DEBUG_BUILD)
384  #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_DEFAULT_ON
385  #else
386  #define SOL_SAFE_FUNCTION_OBJECTS_I_ SOL_DEFAULT_OFF
387  #endif
388 #endif
389 
390 #if defined(SOL_SAFE_FUNCTION_CALLS)
391  #if SOL_SAFE_FUNCTION_CALLS != 0
392  #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_ON
393  #else
394  #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_OFF
395  #endif
396 #else
397  #if SOL_IS_ON(SOL_ALL_SAFETIES_ON)
398  #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_ON
399  #elif SOL_IS_ON(SOL_DEBUG_BUILD)
400  #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_DEFAULT_ON
401  #else
402  #define SOL_SAFE_FUNCTION_CALLS_I_ SOL_DEFAULT_OFF
403  #endif
404 #endif
405 
406 #if defined(SOL_SAFE_PROXIES)
407  #if SOL_SAFE_PROXIES != 0
408  #define SOL_SAFE_PROXIES_I_ SOL_ON
409  #else
410  #define SOL_SAFE_PROXIES_I_ SOL_OFF
411  #endif
412 #else
413  #if SOL_IS_ON(SOL_ALL_SAFETIES_ON)
414  #define SOL_SAFE_PROXIES_I_ SOL_ON
415  #elif SOL_IS_ON(SOL_DEBUG_BUILD)
416  #define SOL_SAFE_PROXIES_I_ SOL_DEFAULT_ON
417  #else
418  #define SOL_SAFE_PROXIES_I_ SOL_DEFAULT_OFF
419  #endif
420 #endif
421 
422 #if defined(SOL_SAFE_NUMERICS)
423  #if SOL_SAFE_NUMERICS != 0
424  #define SOL_SAFE_NUMERICS_I_ SOL_ON
425  #else
426  #define SOL_SAFE_NUMERICS_I_ SOL_OFF
427  #endif
428 #else
429  #if SOL_IS_ON(SOL_ALL_SAFETIES_ON)
430  #define SOL_SAFE_NUMERICS_I_ SOL_ON
431  #elif SOL_IS_ON(SOL_DEBUG_BUILD)
432  #define SOL_SAFE_NUMERICS_I_ SOL_DEFAULT_ON
433  #else
434  #define SOL_SAFE_NUMERICS_I_ SOL_DEFAULT_OFF
435  #endif
436 #endif
437 
438 #if defined(SOL_ALL_INTEGER_VALUES_FIT)
439  #if (SOL_ALL_INTEGER_VALUES_FIT != 0)
440  #define SOL_ALL_INTEGER_VALUES_FIT_I_ SOL_ON
441  #else
442  #define SOL_ALL_INTEGER_VALUES_FIT_I_ SOL_OFF
443  #endif
444 #elif !SOL_IS_DEFAULT_OFF(SOL_SAFE_NUMERICS) && SOL_IS_OFF(SOL_SAFE_NUMERICS)
445  // if numerics is intentionally turned off, flip this on
446  #define SOL_ALL_INTEGER_VALUES_FIT_I_ SOL_DEFAULT_ON
447 #else
448  // default to off
449  #define SOL_ALL_INTEGER_VALUES_FIT_I_ SOL_DEFAULT_OFF
450 #endif
451 
452 #if defined(SOL_SAFE_STACK_CHECK)
453  #if SOL_SAFE_STACK_CHECK != 0
454  #define SOL_SAFE_STACK_CHECK_I_ SOL_ON
455  #else
456  #define SOL_SAFE_STACK_CHECK_I_ SOL_OFF
457  #endif
458 #else
459  #if SOL_IS_ON(SOL_ALL_SAFETIES_ON)
460  #define SOL_SAFE_STACK_CHECK_I_ SOL_ON
461  #elif SOL_IS_ON(SOL_DEBUG_BUILD)
462  #define SOL_SAFE_STACK_CHECK_I_ SOL_DEFAULT_ON
463  #else
464  #define SOL_SAFE_STACK_CHECK_I_ SOL_DEFAULT_OFF
465  #endif
466 #endif
467 
468 #if defined(SOL_NO_CHECK_NUMBER_PRECISION)
469  #if SOL_NO_CHECK_NUMBER_PRECISION != 0
470  #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_OFF
471  #else
472  #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON
473  #endif
474 #elif defined(SOL_NO_CHECKING_NUMBER_PRECISION)
475  #if SOL_NO_CHECKING_NUMBER_PRECISION != 0
476  #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_OFF
477  #else
478  #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON
479  #endif
480 #else
481  #if SOL_IS_ON(SOL_ALL_SAFETIES_ON)
482  #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON
483  #elif SOL_IS_ON(SOL_SAFE_NUMERICS)
484  #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_ON
485  #elif SOL_IS_ON(SOL_DEBUG_BUILD)
486  #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_DEFAULT_ON
487  #else
488  #define SOL_NUMBER_PRECISION_CHECKS_I_ SOL_DEFAULT_OFF
489  #endif
490 #endif
491 
492 #if defined(SOL_STRINGS_ARE_NUMBERS)
493  #if (SOL_STRINGS_ARE_NUMBERS != 0)
494  #define SOL_STRINGS_ARE_NUMBERS_I_ SOL_ON
495  #else
496  #define SOL_STRINGS_ARE_NUMBERS_I_ SOL_OFF
497  #endif
498 #else
499  #define SOL_STRINGS_ARE_NUMBERS_I_ SOL_DEFAULT_OFF
500 #endif
501 
502 #if defined(SOL_ENABLE_INTEROP)
503  #if SOL_ENABLE_INTEROP != 0
504  #define SOL_USE_INTEROP_I_ SOL_ON
505  #else
506  #define SOL_USE_INTEROP_I_ SOL_OFF
507  #endif
508 #elif defined(SOL_USE_INTEROP)
509  #if SOL_USE_INTEROP != 0
510  #define SOL_USE_INTEROP_I_ SOL_ON
511  #else
512  #define SOL_USE_INTEROP_I_ SOL_OFF
513  #endif
514 #else
515  #define SOL_USE_INTEROP_I_ SOL_DEFAULT_OFF
516 #endif
517 
518 #if defined(SOL_NO_NIL)
519  #if (SOL_NO_NIL != 0)
520  #define SOL_NIL_I_ SOL_OFF
521  #else
522  #define SOL_NIL_I_ SOL_ON
523  #endif
524 #elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED) || defined(__OBJC__) || defined(nil)
525  #define SOL_NIL_I_ SOL_DEFAULT_OFF
526 #else
527  #define SOL_NIL_I_ SOL_DEFAULT_ON
528 #endif
529 
530 #if defined(SOL_USERTYPE_TYPE_BINDING_INFO)
531  #if (SOL_USERTYPE_TYPE_BINDING_INFO != 0)
532  #define SOL_USERTYPE_TYPE_BINDING_INFO_I_ SOL_ON
533  #else
534  #define SOL_USERTYPE_TYPE_BINDING_INFO_I_ SOL_OFF
535  #endif
536 #else
537  #define SOL_USERTYPE_TYPE_BINDING_INFO_I_ SOL_DEFAULT_ON
538 #endif // We should generate a my_type.__type table with lots of class information for usertypes
539 
540 #if defined(SOL_AUTOMAGICAL_TYPES_BY_DEFAULT)
541  #if (SOL_AUTOMAGICAL_TYPES_BY_DEFAULT != 0)
542  #define SOL_DEFAULT_AUTOMAGICAL_USERTYPES_I_ SOL_ON
543  #else
544  #define SOL_DEFAULT_AUTOMAGICAL_USERTYPES_I_ SOL_OFF
545  #endif
546 #elif defined(SOL_DEFAULT_AUTOMAGICAL_USERTYPES)
547  #if (SOL_DEFAULT_AUTOMAGICAL_USERTYPES != 0)
548  #define SOL_DEFAULT_AUTOMAGICAL_USERTYPES_I_ SOL_ON
549  #else
550  #define SOL_DEFAULT_AUTOMAGICAL_USERTYPES_I_ SOL_OFF
551  #endif
552 #else
553  #define SOL_DEFAULT_AUTOMAGICAL_USERTYPES_I_ SOL_DEFAULT_ON
554 #endif // make is_automagical on/off by default
555 
556 #if defined(SOL_STD_VARIANT)
557  #if (SOL_STD_VARIANT != 0)
558  #define SOL_STD_VARIANT_I_ SOL_ON
559  #else
560  #define SOL_STD_VARIANT_I_ SOL_OFF
561  #endif
562 #else
563  #if SOL_IS_ON(SOL_COMPILER_CLANG) && SOL_IS_ON(SOL_PLATFORM_APPLE)
564  #if defined(__has_include)
565  #if __has_include(<variant>)
566  #define SOL_STD_VARIANT_I_ SOL_DEFAULT_ON
567  #else
568  #define SOL_STD_VARIANT_I_ SOL_DEFAULT_OFF
569  #endif
570  #else
571  #define SOL_STD_VARIANT_I_ SOL_DEFAULT_OFF
572  #endif
573  #else
574  #define SOL_STD_VARIANT_I_ SOL_DEFAULT_ON
575  #endif
576 #endif // make is_automagical on/off by default
577 
578 #if defined(SOL_NOEXCEPT_FUNCTION_TYPE)
579  #if (SOL_NOEXCEPT_FUNCTION_TYPE != 0)
580  #define SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_ SOL_ON
581  #else
582  #define SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_ SOL_OFF
583  #endif
584 #else
585  #if defined(__cpp_noexcept_function_type)
586  #define SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_ SOL_ON
587  #elif SOL_IS_ON(SOL_COMPILER_VCXX) && (defined(_MSVC_LANG) && (_MSVC_LANG < 201403L))
588  // There is a bug in the VC++ compiler??
589  // on /std:c++latest under x86 conditions (VS 15.5.2),
590  // compiler errors are tossed for noexcept markings being on function types
591  // that are identical in every other way to their non-noexcept marked types function types...
592  // VS 2019: There is absolutely a bug.
593  #define SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_ SOL_OFF
594  #else
595  #define SOL_USE_NOEXCEPT_FUNCTION_TYPE_I_ SOL_DEFAULT_ON
596  #endif
597 #endif // noexcept is part of a function's type
598 
599 #if defined(SOL_STACK_STRING_OPTIMIZATION_SIZE) && SOL_STACK_STRING_OPTIMIZATION_SIZE > 0
600  #define SOL_OPTIMIZATION_STRING_CONVERSION_STACK_SIZE_I_ SOL_STACK_STRING_OPTIMIZATION_SIZE
601 #else
602  #define SOL_OPTIMIZATION_STRING_CONVERSION_STACK_SIZE_I_ 1024
603 #endif
604 
605 #if defined(SOL_ID_SIZE) && SOL_ID_SIZE > 0
606  #define SOL_ID_SIZE_I_ SOL_ID_SIZE
607 #else
608  #define SOL_ID_SIZE_I_ 512
609 #endif
610 
611 #if defined(LUA_IDSIZE) && LUA_IDSIZE > 0
612  #define SOL_FILE_ID_SIZE_I_ LUA_IDSIZE
613 #elif defined(SOL_ID_SIZE) && SOL_ID_SIZE > 0
614  #define SOL_FILE_ID_SIZE_I_ SOL_FILE_ID_SIZE
615 #else
616  #define SOL_FILE_ID_SIZE_I_ 2048
617 #endif
618 
619 #if defined(SOL_PRINT_ERRORS)
620  #if (SOL_PRINT_ERRORS != 0)
621  #define SOL_PRINT_ERRORS_I_ SOL_ON
622  #else
623  #define SOL_PRINT_ERRORS_I_ SOL_OFF
624  #endif
625 #else
626  #if SOL_IS_ON(SOL_ALL_SAFETIES_ON)
627  #define SOL_PRINT_ERRORS_I_ SOL_ON
628  #elif SOL_IS_ON(SOL_DEBUG_BUILD)
629  #define SOL_PRINT_ERRORS_I_ SOL_DEFAULT_ON
630  #else
631  #define SOL_PRINT_ERRORS_I_ SOL_OFF
632  #endif
633 #endif
634 
635 #if defined(SOL_DEFAULT_PASS_ON_ERROR)
636  #if (SOL_DEFAULT_PASS_ON_ERROR != 0)
637  #define SOL_DEFAULT_PASS_ON_ERROR_I_ SOL_ON
638  #else
639  #define SOL_DEFAULT_PASS_ON_ERROR_I_ SOL_OFF
640  #endif
641 #else
642  #define SOL_DEFAULT_PASS_ON_ERROR_I_ SOL_DEFAULT_OFF
643 #endif
644 
645 #if defined(SOL_USING_CXX_LUA)
646  #if (SOL_USING_CXX_LUA != 0)
647  #define SOL_USE_CXX_LUA_I_ SOL_ON
648  #else
649  #define SOL_USE_CXX_LUA_I_ SOL_OFF
650  #endif
651 #elif defined(SOL_USE_CXX_LUA)
652  #if (SOL_USE_CXX_LUA != 0)
653  #define SOL_USE_CXX_LUA_I_ SOL_ON
654  #else
655  #define SOL_USE_CXX_LUA_I_ SOL_OFF
656  #endif
657 #else
658  #define SOL_USE_CXX_LUA_I_ SOL_DEFAULT_OFF
659 #endif
660 
661 #if defined(SOL_USING_CXX_LUAJIT)
662  #if (SOL_USING_CXX_LUA != 0)
663  #define SOL_USE_CXX_LUAJIT_I_ SOL_ON
664  #else
665  #define SOL_USE_CXX_LUAJIT_I_ SOL_OFF
666  #endif
667 #elif defined(SOL_USE_CXX_LUAJIT)
668  #if (SOL_USE_CXX_LUA != 0)
669  #define SOL_USE_CXX_LUAJIT_I_ SOL_ON
670  #else
671  #define SOL_USE_CXX_LUAJIT_I_ SOL_OFF
672  #endif
673 #else
674  #define SOL_USE_CXX_LUAJIT_I_ SOL_DEFAULT_OFF
675 #endif
676 
677 #if defined(SOL_NO_LUA_HPP)
678  #if (SOL_NO_LUA_HPP != 0)
679  #define SOL_USE_LUA_HPP_I_ SOL_OFF
680  #else
681  #define SOL_USE_LUA_HPP_I_ SOL_ON
682  #endif
683 #elif defined(SOL_USING_CXX_LUA)
684  #define SOL_USE_LUA_HPP_I_ SOL_OFF
685 #elif defined(__has_include)
686  #if __has_include(<lua.hpp>)
687  #define SOL_USE_LUA_HPP_I_ SOL_ON
688  #else
689  #define SOL_USE_LUA_HPP_I_ SOL_OFF
690  #endif
691 #else
692  #define SOL_USE_LUA_HPP_I_ SOL_DEFAULT_ON
693 #endif
694 
695 #if defined(SOL_CONTAINERS_START)
696  #define SOL_CONTAINER_START_INDEX_I_ SOL_CONTAINERS_START
697 #elif defined(SOL_CONTAINERS_START_INDEX)
698  #define SOL_CONTAINER_START_INDEX_I_ SOL_CONTAINERS_START_INDEX
699 #elif defined(SOL_CONTAINER_START_INDEX)
700  #define SOL_CONTAINER_START_INDEX_I_ SOL_CONTAINER_START_INDEX
701 #else
702  #define SOL_CONTAINER_START_INDEX_I_ 1
703 #endif
704 
705 #if defined (SOL_NO_MEMORY_ALIGNMENT)
706  #if (SOL_NO_MEMORY_ALIGNMENT != 0)
707  #define SOL_ALIGN_MEMORY_I_ SOL_OFF
708  #else
709  #define SOL_ALIGN_MEMORY_I_ SOL_ON
710  #endif
711 #else
712  #define SOL_ALIGN_MEMORY_I_ SOL_DEFAULT_ON
713 #endif
714 
715 #if defined(SOL_USE_BOOST)
716  #if (SOL_USE_BOOST != 0)
717  #define SOL_USE_BOOST_I_ SOL_ON
718  #else
719  #define SOL_USE_BOOST_I_ SOL_OFF
720  #endif
721 #else
722  #define SOL_USE_BOOST_I_ SOL_DEFAULT_OFF
723 #endif
724 
725 #if defined(SOL_USE_UNSAFE_BASE_LOOKUP)
726  #if (SOL_USE_UNSAFE_BASE_LOOKUP != 0)
727  #define SOL_USE_UNSAFE_BASE_LOOKUP_I_ SOL_ON
728  #else
729  #define SOL_USE_UNSAFE_BASE_LOOKUP_I_ SOL_OFF
730  #endif
731 #else
732  #define SOL_USE_UNSAFE_BASE_LOOKUP_I_ SOL_DEFAULT_OFF
733 #endif
734 
735 #if defined(SOL_INSIDE_UNREAL)
736  #if (SOL_INSIDE_UNREAL != 0)
737  #define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_ON
738  #else
739  #define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_OFF
740  #endif
741 #else
742  #if defined(UE_BUILD_DEBUG) || defined(UE_BUILD_DEVELOPMENT) || defined(UE_BUILD_TEST) || defined(UE_BUILD_SHIPPING) || defined(UE_SERVER)
743  #define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_DEFAULT_ON
744  #else
745  #define SOL_INSIDE_UNREAL_ENGINE_I_ SOL_DEFAULT_OFF
746  #endif
747 #endif
748 
749 #if defined(SOL_NO_COMPAT)
750  #if (SOL_NO_COMPAT != 0)
751  #define SOL_USE_COMPATIBILITY_LAYER_I_ SOL_OFF
752  #else
753  #define SOL_USE_COMPATIBILITY_LAYER_I_ SOL_ON
754  #endif
755 #else
756  #define SOL_USE_COMPATIBILITY_LAYER_I_ SOL_DEFAULT_ON
757 #endif
758 
759 #if defined(SOL_GET_FUNCTION_POINTER_UNSAFE)
760  #if (SOL_GET_FUNCTION_POINTER_UNSAFE != 0)
761  #define SOL_GET_FUNCTION_POINTER_UNSAFE_I_ SOL_ON
762  #else
763  #define SOL_GET_FUNCTION_POINTER_UNSAFE_I_ SOL_OFF
764  #endif
765 #else
766  #define SOL_GET_FUNCTION_POINTER_UNSAFE_I_ SOL_DEFAULT_OFF
767 #endif
768 
769 #if defined(SOL_FUNCTION_CALL_VALUE_SEMANTICS)
770  #if (SOL_FUNCTION_CALL_VALUE_SEMANTICS != 0)
771  #define SOL_FUNCTION_CALL_VALUE_SEMANTICS_I_ SOL_ON
772  #else
773  #define SOL_FUNCTION_CALL_VALUE_SEMANTICS_I_ SOL_OFF
774  #endif
775 #else
776  #define SOL_FUNCTION_CALL_VALUE_SEMANTICS_I_ SOL_DEFAULT_OFF
777 #endif
778 
779 #if defined(SOL_MINGW_CCTYPE_IS_POISONED)
780  #if (SOL_MINGW_CCTYPE_IS_POISONED != 0)
781  #define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_ON
782  #else
783  #define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_OFF
784  #endif
785 #elif SOL_IS_ON(SOL_COMPILER_MINGW) && defined(__GNUC__) && (__GNUC__ < 6)
786  // MinGW is off its rocker in some places...
787  #define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_DEFAULT_ON
788 #else
789  #define SOL_MINGW_CCTYPE_IS_POISONED_I_ SOL_DEFAULT_OFF
790 #endif
791 
792 #if defined(SOL_CHAR8_T)
793  #if (SOL_CHAR8_T != 0)
794  #define SOL_CHAR8_T_I_ SOL_ON
795  #else
796  #define SOL_CHAR8_T_I_ SOL_OFF
797  #endif
798 #else
799  #if defined(__cpp_char8_t)
800  #define SOL_CHAR8_T_I_ SOL_DEFAULT_ON
801  #else
802  #define SOL_CHAR8_T_I_ SOL_DEFAULT_OFF
803  #endif
804 #endif
805 
806 #if SOL_IS_ON(SOL_USE_BOOST)
807  #include <boost/version.hpp>
808 
809  #if BOOST_VERSION >= 107500 // Since Boost 1.75.0 boost::none is constexpr
810  #define SOL_BOOST_NONE_CONSTEXPR_I_ constexpr
811  #else
812  #define SOL_BOOST_NONE_CONSTEXPR_I_ const
813  #endif // BOOST_VERSION
814 #else
815  // assume boost isn't using a garbage version
816  #define SOL_BOOST_NONE_CONSTEXPR_I_ constexpr
817 #endif
818 
819 #if defined(SOL2_CI)
820  #if (SOL2_CI != 0)
821  #define SOL2_CI_I_ SOL_ON
822  #else
823  #define SOL2_CI_I_ SOL_OFF
824  #endif
825 #else
826  #define SOL2_CI_I_ SOL_DEFAULT_OFF
827 #endif
828 
829 #if defined(SOL_C_ASSERT)
830  #define SOL_USER_C_ASSERT_I_ SOL_ON
831 #else
832  #define SOL_USER_C_ASSERT_I_ SOL_DEFAULT_OFF
833 #endif
834 
835 #if defined(SOL_M_ASSERT)
836  #define SOL_USER_M_ASSERT_I_ SOL_ON
837 #else
838  #define SOL_USER_M_ASSERT_I_ SOL_DEFAULT_OFF
839 #endif
840 
841 // beginning of sol/prologue.hpp
842 
843 #if defined(SOL_PROLOGUE_I_)
844  #error "[sol2] Library Prologue was already included in translation unit and not properly ended with an epilogue."
845 #endif
846 
847 #define SOL_PROLOGUE_I_ 1
848 
849 #if SOL_IS_ON(SOL_BUILD_CXX_MODE)
850  #define _FWD(...) static_cast<decltype( __VA_ARGS__ )&&>( __VA_ARGS__ )
851 
852  #if SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG)
853  #define _MOVE(...) static_cast<__typeof( __VA_ARGS__ )&&>( __VA_ARGS__ )
854  #else
855  #include <type_traits>
856 
857  #define _MOVE(...) static_cast<::std::remove_reference_t<( __VA_ARGS__ )>&&>( __VA_OPT__(,) )
858  #endif
859 #endif
860 
861 // end of sol/prologue.hpp
862 
863 // beginning of sol/epilogue.hpp
864 
865 #if !defined(SOL_PROLOGUE_I_)
866  #error "[sol2] Library Prologue is missing from this translation unit."
867 #else
868  #undef SOL_PROLOGUE_I_
869 #endif
870 
871 #if SOL_IS_ON(SOL_BUILD_CXX_MODE)
872  #undef _FWD
873  #undef _MOVE
874 #endif
875 
876 // end of sol/epilogue.hpp
877 
878 // beginning of sol/detail/build_version.hpp
879 
880 #if defined(SOL_DLL)
881  #if (SOL_DLL != 0)
882  #define SOL_DLL_I_ SOL_ON
883  #else
884  #define SOL_DLL_I_ SOL_OFF
885  #endif
886 #elif SOL_IS_ON(SOL_COMPILER_VCXX) && (defined(DLL_) || defined(_DLL))
887  #define SOL_DLL_I_ SOL_DEFAULT_ON
888 #else
889  #define SOL_DLL_I_ SOL_DEFAULT_OFF
890 #endif // DLL definition
891 
892 #if defined(SOL_HEADER_ONLY)
893  #if (SOL_HEADER_ONLY != 0)
894  #define SOL_HEADER_ONLY_I_ SOL_ON
895  #else
896  #define SOL_HEADER_ONLY_I_ SOL_OFF
897  #endif
898 #else
899  #define SOL_HEADER_ONLY_I_ SOL_DEFAULT_OFF
900 #endif // Header only library
901 
902 #if defined(SOL_BUILD)
903  #if (SOL_BUILD != 0)
904  #define SOL_BUILD_I_ SOL_ON
905  #else
906  #define SOL_BUILD_I_ SOL_OFF
907  #endif
908 #elif SOL_IS_ON(SOL_HEADER_ONLY)
909  #define SOL_BUILD_I_ SOL_DEFAULT_OFF
910 #else
911  #define SOL_BUILD_I_ SOL_DEFAULT_ON
912 #endif
913 
914 #if defined(SOL_UNITY_BUILD)
915  #if (SOL_UNITY_BUILD != 0)
916  #define SOL_UNITY_BUILD_I_ SOL_ON
917  #else
918  #define SOL_UNITY_BUILD_I_ SOL_OFF
919  #endif
920 #else
921  #define SOL_UNITY_BUILD_I_ SOL_DEFAULT_OFF
922 #endif // Header only library
923 
924 #if defined(SOL_C_FUNCTION_LINKAGE)
925  #define SOL_C_FUNCTION_LINKAGE_I_ SOL_C_FUNCTION_LINKAGE
926 #else
927  #if SOL_IS_ON(SOL_BUILD_CXX_MODE)
928  // C++
929  #define SOL_C_FUNCTION_LINKAGE_I_ extern "C"
930  #else
931  // normal
932  #define SOL_C_FUNCTION_LINKAGE_I_
933  #endif // C++ or not
934 #endif // Linkage specification for C functions
935 
936 #if defined(SOL_API_LINKAGE)
937  #define SOL_API_LINKAGE_I_ SOL_API_LINKAGE
938 #else
939  #if SOL_IS_ON(SOL_DLL)
940  #if SOL_IS_ON(SOL_COMPILER_VCXX) || SOL_IS_ON(SOL_PLATFORM_WINDOWS) || SOL_IS_ON(SOL_PLATFORM_CYGWIN)
941  // MSVC Compiler; or, Windows, or Cygwin platforms
942  #if SOL_IS_ON(SOL_BUILD)
943  // Building the library
944  #if SOL_IS_ON(SOL_COMPILER_GCC)
945  // Using GCC
946  #define SOL_API_LINKAGE_I_ __attribute__((dllexport))
947  #else
948  // Using Clang, MSVC, etc...
949  #define SOL_API_LINKAGE_I_ __declspec(dllexport)
950  #endif
951  #else
952  #if SOL_IS_ON(SOL_COMPILER_GCC)
953  #define SOL_API_LINKAGE_I_ __attribute__((dllimport))
954  #else
955  #define SOL_API_LINKAGE_I_ __declspec(dllimport)
956  #endif
957  #endif
958  #else
959  // extern if building normally on non-MSVC
960  #define SOL_API_LINKAGE_I_ extern
961  #endif
962  #elif SOL_IS_ON(SOL_UNITY_BUILD)
963  // Built-in library, like how stb typical works
964  #if SOL_IS_ON(SOL_HEADER_ONLY)
965  // Header only, so functions are defined "inline"
966  #define SOL_API_LINKAGE_I_ inline
967  #else
968  // Not header only, so seperately compiled files
969  #define SOL_API_LINKAGE_I_ extern
970  #endif
971  #else
972  // Normal static library
973  #if SOL_IS_ON(SOL_BUILD_CXX_MODE)
974  #define SOL_API_LINKAGE_I_
975  #else
976  #define SOL_API_LINKAGE_I_ extern
977  #endif
978  #endif // DLL or not
979 #endif // Build definitions
980 
981 #if defined(SOL_PUBLIC_FUNC_DECL)
982  #define SOL_PUBLIC_FUNC_DECL_I_ SOL_PUBLIC_FUNC_DECL
983 #else
984  #define SOL_PUBLIC_FUNC_DECL_I_ SOL_API_LINKAGE_I_
985 #endif
986 
987 #if defined(SOL_INTERNAL_FUNC_DECL_)
988  #define SOL_INTERNAL_FUNC_DECL_I_ SOL_INTERNAL_FUNC_DECL_
989 #else
990  #define SOL_INTERNAL_FUNC_DECL_I_ SOL_API_LINKAGE_I_
991 #endif
992 
993 #if defined(SOL_PUBLIC_FUNC_DEF)
994  #define SOL_PUBLIC_FUNC_DEF_I_ SOL_PUBLIC_FUNC_DEF
995 #else
996  #define SOL_PUBLIC_FUNC_DEF_I_ SOL_API_LINKAGE_I_
997 #endif
998 
999 #if defined(SOL_INTERNAL_FUNC_DEF)
1000  #define SOL_INTERNAL_FUNC_DEF_I_ SOL_INTERNAL_FUNC_DEF
1001 #else
1002  #define SOL_INTERNAL_FUNC_DEF_I_ SOL_API_LINKAGE_I_
1003 #endif
1004 
1005 #if defined(SOL_FUNC_DECL)
1006  #define SOL_FUNC_DECL_I_ SOL_FUNC_DECL
1007 #elif SOL_IS_ON(SOL_HEADER_ONLY)
1008  #define SOL_FUNC_DECL_I_
1009 #elif SOL_IS_ON(SOL_DLL)
1010  #if SOL_IS_ON(SOL_COMPILER_VCXX)
1011  #if SOL_IS_ON(SOL_BUILD)
1012  #define SOL_FUNC_DECL_I_ extern __declspec(dllexport)
1013  #else
1014  #define SOL_FUNC_DECL_I_ extern __declspec(dllimport)
1015  #endif
1016  #elif SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG)
1017  #define SOL_FUNC_DECL_I_ extern __attribute__((visibility("default")))
1018  #else
1019  #define SOL_FUNC_DECL_I_ extern
1020  #endif
1021 #endif
1022 
1023 #if defined(SOL_FUNC_DEFN)
1024  #define SOL_FUNC_DEFN_I_ SOL_FUNC_DEFN
1025 #elif SOL_IS_ON(SOL_HEADER_ONLY)
1026  #define SOL_FUNC_DEFN_I_ inline
1027 #elif SOL_IS_ON(SOL_DLL)
1028  #if SOL_IS_ON(SOL_COMPILER_VCXX)
1029  #if SOL_IS_ON(SOL_BUILD)
1030  #define SOL_FUNC_DEFN_I_ __declspec(dllexport)
1031  #else
1032  #define SOL_FUNC_DEFN_I_ __declspec(dllimport)
1033  #endif
1034  #elif SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG)
1035  #define SOL_FUNC_DEFN_I_ __attribute__((visibility("default")))
1036  #else
1037  #define SOL_FUNC_DEFN_I_
1038  #endif
1039 #endif
1040 
1041 #if defined(SOL_HIDDEN_FUNC_DECL)
1042  #define SOL_HIDDEN_FUNC_DECL_I_ SOL_HIDDEN_FUNC_DECL
1043 #elif SOL_IS_ON(SOL_HEADER_ONLY)
1044  #define SOL_HIDDEN_FUNC_DECL_I_
1045 #elif SOL_IS_ON(SOL_DLL)
1046  #if SOL_IS_ON(SOL_COMPILER_VCXX)
1047  #if SOL_IS_ON(SOL_BUILD)
1048  #define SOL_HIDDEN_FUNC_DECL_I_ extern __declspec(dllexport)
1049  #else
1050  #define SOL_HIDDEN_FUNC_DECL_I_ extern __declspec(dllimport)
1051  #endif
1052  #elif SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG)
1053  #define SOL_HIDDEN_FUNC_DECL_I_ extern __attribute__((visibility("default")))
1054  #else
1055  #define SOL_HIDDEN_FUNC_DECL_I_ extern
1056  #endif
1057 #endif
1058 
1059 #if defined(SOL_HIDDEN_FUNC_DEFN)
1060  #define SOL_HIDDEN_FUNC_DEFN_I_ SOL_HIDDEN_FUNC_DEFN
1061 #elif SOL_IS_ON(SOL_HEADER_ONLY)
1062  #define SOL_HIDDEN_FUNC_DEFN_I_ inline
1063 #elif SOL_IS_ON(SOL_DLL)
1064  #if SOL_IS_ON(SOL_COMPILER_VCXX)
1065  #if SOL_IS_ON(SOL_BUILD)
1066  #define SOL_HIDDEN_FUNC_DEFN_I_
1067  #else
1068  #define SOL_HIDDEN_FUNC_DEFN_I_
1069  #endif
1070  #elif SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG)
1071  #define SOL_HIDDEN_FUNC_DEFN_I_ __attribute__((visibility("hidden")))
1072  #else
1073  #define SOL_HIDDEN_FUNC_DEFN_I_
1074  #endif
1075 #endif
1076 
1077 // end of sol/detail/build_version.hpp
1078 
1079 // end of sol/version.hpp
1080 
1081 #if SOL_IS_ON(SOL_INSIDE_UNREAL_ENGINE)
1082 #ifdef check
1083 #pragma push_macro("check")
1084 #undef check
1085 #endif
1086 #endif // Unreal Engine 4 Bullshit
1087 
1088 #if SOL_IS_ON(SOL_COMPILER_GCC)
1089 #pragma GCC diagnostic push
1090 #pragma GCC diagnostic ignored "-Wshadow"
1091 #pragma GCC diagnostic ignored "-Wconversion"
1092 #if __GNUC__ > 6
1093 #pragma GCC diagnostic ignored "-Wnoexcept-type"
1094 #endif
1095 #elif SOL_IS_ON(SOL_COMPILER_CLANG)
1096 #elif SOL_IS_ON(SOL_COMPILER_VCXX)
1097 #pragma warning(push)
1098 #pragma warning(disable : 4505) // unreferenced local function has been removed GEE THANKS
1099 #endif // clang++ vs. g++ vs. VC++
1100 
1101 // beginning of sol/forward.hpp
1102 
1103 #ifndef SOL_FORWARD_HPP
1104 #define SOL_FORWARD_HPP
1105 
1106 #include <utility>
1107 #include <type_traits>
1108 #include <string_view>
1109 
1110 #if SOL_IS_ON(SOL_USE_CXX_LUA) || SOL_IS_ON(SOL_USE_CXX_LUAJIT)
1111 struct lua_State;
1112 #else
1113 extern "C" {
1114 struct lua_State;
1115 }
1116 #endif // C++ Mangling for Lua vs. Not
1117 
1118 namespace sol {
1119 
1120  enum class type;
1121 
1122  class stateless_reference;
1123  template <bool b>
1124  class basic_reference;
1125  using reference = basic_reference<false>;
1126  using main_reference = basic_reference<true>;
1127  class stateless_stack_reference;
1128  class stack_reference;
1129 
1130  template <typename A>
1131  class basic_bytecode;
1132 
1133  struct lua_value;
1134 
1135  struct proxy_base_tag;
1136  template <typename>
1137  struct proxy_base;
1138  template <typename, typename>
1139  struct table_proxy;
1140 
1141  template <bool, typename>
1142  class basic_table_core;
1143  template <bool b>
1144  using table_core = basic_table_core<b, reference>;
1145  template <bool b>
1146  using main_table_core = basic_table_core<b, main_reference>;
1147  template <bool b>
1148  using stack_table_core = basic_table_core<b, stack_reference>;
1149  template <typename base_type>
1150  using basic_table = basic_table_core<false, base_type>;
1151  using table = table_core<false>;
1152  using global_table = table_core<true>;
1153  using main_table = main_table_core<false>;
1154  using main_global_table = main_table_core<true>;
1155  using stack_table = stack_table_core<false>;
1156  using stack_global_table = stack_table_core<true>;
1157 
1158  template <typename>
1159  struct basic_lua_table;
1160  using lua_table = basic_lua_table<reference>;
1161  using stack_lua_table = basic_lua_table<stack_reference>;
1162 
1163  template <typename T, typename base_type>
1164  class basic_usertype;
1165  template <typename T>
1166  using usertype = basic_usertype<T, reference>;
1167  template <typename T>
1168  using stack_usertype = basic_usertype<T, stack_reference>;
1169 
1170  template <typename base_type>
1171  class basic_metatable;
1172  using metatable = basic_metatable<reference>;
1173  using stack_metatable = basic_metatable<stack_reference>;
1174 
1175  template <typename base_t>
1176  struct basic_environment;
1177  using environment = basic_environment<reference>;
1178  using main_environment = basic_environment<main_reference>;
1179  using stack_environment = basic_environment<stack_reference>;
1180 
1181  template <typename T, bool>
1182  class basic_function;
1183  template <typename T, bool, typename H>
1184  class basic_protected_function;
1185  using unsafe_function = basic_function<reference, false>;
1186  using safe_function = basic_protected_function<reference, false, reference>;
1187  using main_unsafe_function = basic_function<main_reference, false>;
1188  using main_safe_function = basic_protected_function<main_reference, false, reference>;
1189  using stack_unsafe_function = basic_function<stack_reference, false>;
1190  using stack_safe_function = basic_protected_function<stack_reference, false, reference>;
1191  using stack_aligned_unsafe_function = basic_function<stack_reference, true>;
1192  using stack_aligned_safe_function = basic_protected_function<stack_reference, true, reference>;
1197 #if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS)
1198  using function = protected_function;
1202 #else
1203  using function = unsafe_function;
1207 #endif
1208  using stack_aligned_stack_handler_function = basic_protected_function<stack_reference, true, stack_reference>;
1209 
1210  struct unsafe_function_result;
1211  struct protected_function_result;
1212  using safe_function_result = protected_function_result;
1213 #if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS)
1215 #else
1216  using function_result = unsafe_function_result;
1217 #endif
1218 
1219  template <typename base_t>
1220  class basic_object_base;
1221  template <typename base_t>
1222  class basic_object;
1223  template <typename base_t>
1224  class basic_userdata;
1225  template <typename base_t>
1226  class basic_lightuserdata;
1227  template <typename base_t>
1228  class basic_coroutine;
1229  template <typename base_t>
1230  class basic_packaged_coroutine;
1231  template <typename base_t>
1232  class basic_thread;
1233 
1234  using object = basic_object<reference>;
1235  using userdata = basic_userdata<reference>;
1236  using lightuserdata = basic_lightuserdata<reference>;
1237  using thread = basic_thread<reference>;
1238  using coroutine = basic_coroutine<reference>;
1239  using packaged_coroutine = basic_packaged_coroutine<reference>;
1240  using main_object = basic_object<main_reference>;
1241  using main_userdata = basic_userdata<main_reference>;
1242  using main_lightuserdata = basic_lightuserdata<main_reference>;
1243  using main_coroutine = basic_coroutine<main_reference>;
1244  using stack_object = basic_object<stack_reference>;
1245  using stack_userdata = basic_userdata<stack_reference>;
1246  using stack_lightuserdata = basic_lightuserdata<stack_reference>;
1247  using stack_thread = basic_thread<stack_reference>;
1248  using stack_coroutine = basic_coroutine<stack_reference>;
1249 
1250  struct stack_proxy_base;
1251  struct stack_proxy;
1252  struct variadic_args;
1253  struct variadic_results;
1254  struct stack_count;
1255  struct this_state;
1256  struct this_main_state;
1257  struct this_environment;
1258 
1259  class state_view;
1260  class state;
1261 
1262  template <typename T>
1263  struct as_table_t;
1264  template <typename T>
1265  struct as_container_t;
1266  template <typename T>
1267  struct nested;
1268  template <typename T>
1269  struct light;
1270  template <typename T>
1271  struct user;
1272  template <typename T>
1273  struct as_args_t;
1274  template <typename T>
1275  struct protect_t;
1276  template <typename F, typename... Policies>
1277  struct policy_wrapper;
1278 
1279  template <typename T>
1280  struct usertype_traits;
1281  template <typename T>
1282  struct unique_usertype_traits;
1283 
1284  template <typename... Args>
1285  struct types {
1286  typedef std::make_index_sequence<sizeof...(Args)> indices;
1287  static constexpr std::size_t size() {
1288  return sizeof...(Args);
1289  }
1290  };
1291 
1292  template <typename T>
1293  struct derive : std::false_type {
1294  typedef types<> type;
1295  };
1296 
1297  template <typename T>
1298  struct base : std::false_type {
1299  typedef types<> type;
1300  };
1301 
1302  template <typename T>
1303  struct weak_derive {
1304  static bool value;
1305  };
1306 
1307  template <typename T>
1308  bool weak_derive<T>::value = false;
1309 
1310  namespace stack {
1311  struct record;
1312  }
1313 
1314 #if SOL_IS_OFF(SOL_USE_BOOST)
1315  template <class T>
1316  class optional;
1317 
1318  template <class T>
1319  class optional<T&>;
1320 #endif
1321 
1322  using check_handler_type = int(lua_State*, int, type, type, const char*);
1323 
1324 } // namespace sol
1325 
1326 #define SOL_BASE_CLASSES(T, ...) \
1327  namespace sol { \
1328  template <> \
1329  struct base<T> : std::true_type { \
1330  typedef ::sol::types<__VA_ARGS__> type; \
1331  }; \
1332  } \
1333  void a_sol3_detail_function_decl_please_no_collide()
1334 #define SOL_DERIVED_CLASSES(T, ...) \
1335  namespace sol { \
1336  template <> \
1337  struct derive<T> : std::true_type { \
1338  typedef ::sol::types<__VA_ARGS__> type; \
1339  }; \
1340  } \
1341  void a_sol3_detail_function_decl_please_no_collide()
1342 
1343 #endif // SOL_FORWARD_HPP
1344 // end of sol/forward.hpp
1345 
1346 // beginning of sol/forward_detail.hpp
1347 
1348 #ifndef SOL_FORWARD_DETAIL_HPP
1349 #define SOL_FORWARD_DETAIL_HPP
1350 
1351 // beginning of sol/traits.hpp
1352 
1353 // beginning of sol/tuple.hpp
1354 
1355 // beginning of sol/base_traits.hpp
1356 
1357 #include <type_traits>
1358 
1359 namespace sol {
1360  namespace detail {
1361  struct unchecked_t { };
1363  } // namespace detail
1364 
1365  namespace meta {
1368 
1369  template <typename...>
1370  using void_t = void;
1371 
1372  template <typename T>
1373  using unqualified = std::remove_cv<std::remove_reference_t<T>>;
1374 
1375  template <typename T>
1377 
1378  namespace meta_detail {
1379  template <typename T>
1381 
1382  template <template <class...> class Test, class, class... Args>
1384 
1385  template <template <class...> class Test, class... Args>
1386  struct is_detected<Test, void_t<Test<Args...>>, Args...> : std::true_type { };
1387  } // namespace meta_detail
1388 
1389  template <template <class...> class Trait, class... Args>
1390  using is_detected = typename meta_detail::is_detected<Trait, void, Args...>::type;
1391 
1392  template <template <class...> class Trait, class... Args>
1393  constexpr inline bool is_detected_v = is_detected<Trait, Args...>::value;
1394 
1395  template <std::size_t I>
1396  using index_value = std::integral_constant<std::size_t, I>;
1397 
1398  template <bool>
1399  struct conditional {
1400  template <typename T, typename U>
1401  using type = T;
1402  };
1403 
1404  template <>
1405  struct conditional<false> {
1406  template <typename T, typename U>
1407  using type = U;
1408  };
1409 
1410  template <bool B, typename T, typename U>
1412 
1413  namespace meta_detail {
1414  template <typename T, template <typename...> class Templ>
1416  template <typename... T, template <typename...> class Templ>
1417  struct is_specialization_of<Templ<T...>, Templ> : std::true_type { };
1418  } // namespace meta_detail
1419 
1420  template <typename T, template <typename...> class Templ>
1422 
1423  template <typename T, template <typename...> class Templ>
1425 
1426  template <typename T>
1427  struct identity {
1428  typedef T type;
1429  };
1430 
1431  template <typename T>
1432  using identity_t = typename identity<T>::type;
1433 
1434  template <typename T>
1435  using is_builtin_type = std::integral_constant<bool, std::is_arithmetic<T>::value || std::is_pointer<T>::value || std::is_array<T>::value>;
1436 
1437  namespace meta_detail {
1438  template <typename T, typename = void>
1440  template <typename T>
1441  struct has_internal_marker_impl<T, void_t<typename T::SOL_INTERNAL_UNSPECIALIZED_MARKER_>> : std::true_type { };
1442 
1443  template <typename T>
1445 
1446  template <typename T>
1448  } // namespace meta_detail
1449 
1450  } // namespace meta
1451 } // namespace sol
1452 
1453 // end of sol/base_traits.hpp
1454 
1455 #include <tuple>
1456 #include <cstddef>
1457 
1458 namespace sol {
1459  namespace detail {
1460  using swallow = std::initializer_list<int>;
1461  } // namespace detail
1462 
1463  namespace meta {
1464  template <typename T>
1466 
1467  template <typename T>
1468  constexpr inline bool is_tuple_v = is_tuple<T>::value;
1469 
1470  namespace detail {
1471  template <typename... Args>
1472  struct tuple_types_ {
1473  typedef types<Args...> type;
1474  };
1475 
1476  template <typename... Args>
1477  struct tuple_types_<std::tuple<Args...>> {
1478  typedef types<Args...> type;
1479  };
1480  } // namespace detail
1481 
1482  template <typename... Args>
1483  using tuple_types = typename detail::tuple_types_<Args...>::type;
1484 
1485  template <typename Arg>
1487 
1488  template <typename Arg>
1490 
1491  template <typename... Args>
1492  struct pop_front_type<types<Args...>> {
1493  typedef void front_type;
1494  typedef types<Args...> type;
1495  };
1496 
1497  template <typename Arg, typename... Args>
1498  struct pop_front_type<types<Arg, Args...>> {
1499  typedef Arg front_type;
1500  typedef types<Args...> type;
1501  };
1502 
1503  template <std::size_t N, typename Tuple>
1504  using tuple_element = std::tuple_element<N, std::remove_reference_t<Tuple>>;
1505 
1506  template <std::size_t N, typename Tuple>
1507  using tuple_element_t = std::tuple_element_t<N, std::remove_reference_t<Tuple>>;
1508 
1509  template <std::size_t N, typename Tuple>
1511 
1512  template <std::size_t N, typename Tuple>
1514 
1515  } // namespace meta
1516 } // namespace sol
1517 
1518 // end of sol/tuple.hpp
1519 
1520 // beginning of sol/bind_traits.hpp
1521 
1522 namespace sol { namespace meta {
1523  namespace meta_detail {
1524  template <typename F>
1525  using detect_deducible_signature = decltype(&F::operator());
1526  } // namespace meta_detail
1527 
1528  template <typename F>
1530 
1531  template <typename F>
1533 
1534  namespace meta_detail {
1535 
1536  template <std::size_t I, typename T>
1538 
1539  template <std::size_t I>
1540  struct void_tuple_element<I, std::tuple<>> {
1541  typedef void type;
1542  };
1543 
1544  template <std::size_t I, typename T>
1546 
1547  template <bool it_is_noexcept, bool has_c_variadic, typename T, typename R, typename... Args>
1548  struct basic_traits {
1549  private:
1551 
1552  public:
1553  inline static constexpr const bool is_noexcept = it_is_noexcept;
1554  inline static constexpr bool is_member_function = std::is_void<T>::value;
1555  inline static constexpr bool has_c_var_arg = has_c_variadic;
1556  inline static constexpr std::size_t arity = sizeof...(Args);
1557  inline static constexpr std::size_t free_arity = sizeof...(Args) + static_cast<std::size_t>(!std::is_void<T>::value);
1558  typedef types<Args...> args_list;
1559  typedef std::tuple<Args...> args_tuple;
1560  typedef T object_type;
1561  typedef R return_type;
1563  typedef R(function_type)(Args...);
1567  typedef std::remove_pointer_t<free_function_pointer_type> signature_type;
1568  template <std::size_t i>
1570  };
1571 
1572  template <typename Signature, bool b = call_operator_deducible<Signature>::value>
1573  struct fx_traits : public basic_traits<false, false, void, void> { };
1574 
1575  // Free Functions
1576  template <typename R, typename... Args>
1577  struct fx_traits<R(Args...), false> : public basic_traits<false, false, void, R, Args...> {
1578  typedef R (*function_pointer_type)(Args...);
1579  };
1580 
1581  template <typename R, typename... Args>
1582  struct fx_traits<R (*)(Args...), false> : public basic_traits<false, false, void, R, Args...> {
1583  typedef R (*function_pointer_type)(Args...);
1584  };
1585 
1586  template <typename R, typename... Args>
1587  struct fx_traits<R(Args..., ...), false> : public basic_traits<false, true, void, R, Args...> {
1588  typedef R (*function_pointer_type)(Args..., ...);
1589  };
1590 
1591  template <typename R, typename... Args>
1592  struct fx_traits<R (*)(Args..., ...), false> : public basic_traits<false, true, void, R, Args...> {
1593  typedef R (*function_pointer_type)(Args..., ...);
1594  };
1595 
1596  // Member Functions
1597  /* C-Style Variadics */
1598  template <typename T, typename R, typename... Args>
1599  struct fx_traits<R (T::*)(Args...), false> : public basic_traits<false, false, T, R, Args...> {
1600  typedef R (T::*function_pointer_type)(Args...);
1601  };
1602 
1603  template <typename T, typename R, typename... Args>
1604  struct fx_traits<R (T::*)(Args..., ...), false> : public basic_traits<false, true, T, R, Args...> {
1605  typedef R (T::*function_pointer_type)(Args..., ...);
1606  };
1607 
1608  /* Const Volatile */
1609  template <typename T, typename R, typename... Args>
1610  struct fx_traits<R (T::*)(Args...) const, false> : public basic_traits<false, false, T, R, Args...> {
1611  typedef R (T::*function_pointer_type)(Args...) const;
1612  };
1613 
1614  template <typename T, typename R, typename... Args>
1615  struct fx_traits<R (T::*)(Args..., ...) const, false> : public basic_traits<false, true, T, R, Args...> {
1616  typedef R (T::*function_pointer_type)(Args..., ...) const;
1617  };
1618 
1619  template <typename T, typename R, typename... Args>
1620  struct fx_traits<R (T::*)(Args...) const volatile, false> : public basic_traits<false, false, T, R, Args...> {
1621  typedef R (T::*function_pointer_type)(Args...) const volatile;
1622  };
1623 
1624  template <typename T, typename R, typename... Args>
1625  struct fx_traits<R (T::*)(Args..., ...) const volatile, false> : public basic_traits<false, true, T, R, Args...> {
1626  typedef R (T::*function_pointer_type)(Args..., ...) const volatile;
1627  };
1628 
1629  /* Member Function Qualifiers */
1630  template <typename T, typename R, typename... Args>
1631  struct fx_traits<R (T::*)(Args...)&, false> : public basic_traits<false, false, T, R, Args...> {
1632  typedef R (T::*function_pointer_type)(Args...) &;
1633  };
1634 
1635  template <typename T, typename R, typename... Args>
1636  struct fx_traits<R (T::*)(Args..., ...)&, false> : public basic_traits<false, true, T, R, Args...> {
1637  typedef R (T::*function_pointer_type)(Args..., ...) &;
1638  };
1639 
1640  template <typename T, typename R, typename... Args>
1641  struct fx_traits<R (T::*)(Args...) const&, false> : public basic_traits<false, false, T, R, Args...> {
1642  typedef R (T::*function_pointer_type)(Args...) const&;
1643  };
1644 
1645  template <typename T, typename R, typename... Args>
1646  struct fx_traits<R (T::*)(Args..., ...) const&, false> : public basic_traits<false, true, T, R, Args...> {
1647  typedef R (T::*function_pointer_type)(Args..., ...) const&;
1648  };
1649 
1650  template <typename T, typename R, typename... Args>
1651  struct fx_traits<R (T::*)(Args...) const volatile&, false> : public basic_traits<false, false, T, R, Args...> {
1652  typedef R (T::*function_pointer_type)(Args...) const volatile&;
1653  };
1654 
1655  template <typename T, typename R, typename... Args>
1656  struct fx_traits<R (T::*)(Args..., ...) const volatile&, false> : public basic_traits<false, true, T, R, Args...> {
1657  typedef R (T::*function_pointer_type)(Args..., ...) const volatile&;
1658  };
1659 
1660  template <typename T, typename R, typename... Args>
1661  struct fx_traits<R (T::*)(Args...)&&, false> : public basic_traits<false, false, T, R, Args...> {
1662  typedef R (T::*function_pointer_type)(Args...) &&;
1663  };
1664 
1665  template <typename T, typename R, typename... Args>
1666  struct fx_traits<R (T::*)(Args..., ...)&&, false> : public basic_traits<false, true, T, R, Args...> {
1667  typedef R (T::*function_pointer_type)(Args..., ...) &&;
1668  };
1669 
1670  template <typename T, typename R, typename... Args>
1671  struct fx_traits<R (T::*)(Args...) const&&, false> : public basic_traits<false, false, T, R, Args...> {
1672  typedef R (T::*function_pointer_type)(Args...) const&&;
1673  };
1674 
1675  template <typename T, typename R, typename... Args>
1676  struct fx_traits<R (T::*)(Args..., ...) const&&, false> : public basic_traits<false, true, T, R, Args...> {
1677  typedef R (T::*function_pointer_type)(Args..., ...) const&&;
1678  };
1679 
1680  template <typename T, typename R, typename... Args>
1681  struct fx_traits<R (T::*)(Args...) const volatile&&, false> : public basic_traits<false, false, T, R, Args...> {
1682  typedef R (T::*function_pointer_type)(Args...) const volatile&&;
1683  };
1684 
1685  template <typename T, typename R, typename... Args>
1686  struct fx_traits<R (T::*)(Args..., ...) const volatile&&, false> : public basic_traits<false, true, T, R, Args...> {
1687  typedef R (T::*function_pointer_type)(Args..., ...) const volatile&&;
1688  };
1689 
1690 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE)
1691 
1692  template <typename R, typename... Args>
1693  struct fx_traits<R(Args...) noexcept, false> : public basic_traits<true, false, void, R, Args...> {
1694  typedef R (*function_pointer_type)(Args...) noexcept;
1695  };
1696 
1697  template <typename R, typename... Args>
1698  struct fx_traits<R (*)(Args...) noexcept, false> : public basic_traits<true, false, void, R, Args...> {
1699  typedef R (*function_pointer_type)(Args...) noexcept;
1700  };
1701 
1702  template <typename R, typename... Args>
1703  struct fx_traits<R(Args..., ...) noexcept, false> : public basic_traits<true, true, void, R, Args...> {
1704  typedef R (*function_pointer_type)(Args..., ...) noexcept;
1705  };
1706 
1707  template <typename R, typename... Args>
1708  struct fx_traits<R (*)(Args..., ...) noexcept, false> : public basic_traits<true, true, void, R, Args...> {
1709  typedef R (*function_pointer_type)(Args..., ...) noexcept;
1710  };
1711 
1712  template <typename T, typename R, typename... Args>
1713  struct fx_traits<R (T::*)(Args...) noexcept, false> : public basic_traits<true, false, T, R, Args...> {
1714  typedef R (T::*function_pointer_type)(Args...) noexcept;
1715  };
1716 
1717  template <typename T, typename R, typename... Args>
1718  struct fx_traits<R (T::*)(Args..., ...) noexcept, false> : public basic_traits<true, true, T, R, Args...> {
1719  typedef R (T::*function_pointer_type)(Args..., ...) noexcept;
1720  };
1721 
1722  /* Const Volatile */
1723  template <typename T, typename R, typename... Args>
1724  struct fx_traits<R (T::*)(Args...) const noexcept, false> : public basic_traits<true, false, T, R, Args...> {
1725  typedef R (T::*function_pointer_type)(Args...) const noexcept;
1726  };
1727 
1728  template <typename T, typename R, typename... Args>
1729  struct fx_traits<R (T::*)(Args..., ...) const noexcept, false> : public basic_traits<true, true, T, R, Args...> {
1730  typedef R (T::*function_pointer_type)(Args..., ...) const noexcept;
1731  };
1732 
1733  template <typename T, typename R, typename... Args>
1734  struct fx_traits<R (T::*)(Args...) const volatile noexcept, false> : public basic_traits<true, false, T, R, Args...> {
1735  typedef R (T::*function_pointer_type)(Args...) const volatile noexcept;
1736  };
1737 
1738  template <typename T, typename R, typename... Args>
1739  struct fx_traits<R (T::*)(Args..., ...) const volatile noexcept, false> : public basic_traits<true, true, T, R, Args...> {
1740  typedef R (T::*function_pointer_type)(Args..., ...) const volatile noexcept;
1741  };
1742 
1743  template <typename T, typename R, typename... Args>
1744  struct fx_traits<R (T::*)(Args...)& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
1745  typedef R (T::*function_pointer_type)(Args...) & noexcept;
1746  };
1747 
1748  template <typename T, typename R, typename... Args>
1749  struct fx_traits<R (T::*)(Args..., ...)& noexcept, false> : public basic_traits<true, true, T, R, Args...> {
1750  typedef R (T::*function_pointer_type)(Args..., ...) & noexcept;
1751  };
1752 
1753  template <typename T, typename R, typename... Args>
1754  struct fx_traits<R (T::*)(Args...) const& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
1755  typedef R (T::*function_pointer_type)(Args...) const& noexcept;
1756  };
1757 
1758  template <typename T, typename R, typename... Args>
1759  struct fx_traits<R (T::*)(Args..., ...) const& noexcept, false> : public basic_traits<true, true, T, R, Args...> {
1760  typedef R (T::*function_pointer_type)(Args..., ...) const& noexcept;
1761  };
1762 
1763  template <typename T, typename R, typename... Args>
1764  struct fx_traits<R (T::*)(Args...) const volatile& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
1765  typedef R (T::*function_pointer_type)(Args...) const volatile& noexcept;
1766  };
1767 
1768  template <typename T, typename R, typename... Args>
1769  struct fx_traits<R (T::*)(Args..., ...) const volatile& noexcept, false> : public basic_traits<true, true, T, R, Args...> {
1770  typedef R (T::*function_pointer_type)(Args..., ...) const volatile& noexcept;
1771  };
1772 
1773  template <typename T, typename R, typename... Args>
1774  struct fx_traits<R (T::*)(Args...)&& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
1775  typedef R (T::*function_pointer_type)(Args...) && noexcept;
1776  };
1777 
1778  template <typename T, typename R, typename... Args>
1779  struct fx_traits<R (T::*)(Args..., ...)&& noexcept, false> : public basic_traits<true, true, T, R, Args...> {
1780  typedef R (T::*function_pointer_type)(Args..., ...) && noexcept;
1781  };
1782 
1783  template <typename T, typename R, typename... Args>
1784  struct fx_traits<R (T::*)(Args...) const&& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
1785  typedef R (T::*function_pointer_type)(Args...) const&& noexcept;
1786  };
1787 
1788  template <typename T, typename R, typename... Args>
1789  struct fx_traits<R (T::*)(Args..., ...) const&& noexcept, false> : public basic_traits<true, true, T, R, Args...> {
1790  typedef R (T::*function_pointer_type)(Args..., ...) const&& noexcept;
1791  };
1792 
1793  template <typename T, typename R, typename... Args>
1794  struct fx_traits<R (T::*)(Args...) const volatile&& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
1795  typedef R (T::*function_pointer_type)(Args...) const volatile&& noexcept;
1796  };
1797 
1798  template <typename T, typename R, typename... Args>
1799  struct fx_traits<R (T::*)(Args..., ...) const volatile&& noexcept, false> : public basic_traits<true, true, T, R, Args...> {
1800  typedef R (T::*function_pointer_type)(Args..., ...) const volatile&& noexcept;
1801  };
1802 
1803 #endif // noexcept is part of a function's type
1804 
1805 #if SOL_IS_ON(SOL_COMPILER_VCXX) && SOL_IS_ON(SOL_PLATFORM_X86)
1806  template <typename R, typename... Args>
1807  struct fx_traits<R __stdcall(Args...), false> : public basic_traits<false, false, void, R, Args...> {
1808  typedef R(__stdcall* function_pointer_type)(Args...);
1809  };
1810 
1811  template <typename R, typename... Args>
1812  struct fx_traits<R(__stdcall*)(Args...), false> : public basic_traits<false, false, void, R, Args...> {
1813  typedef R(__stdcall* function_pointer_type)(Args...);
1814  };
1815 
1816  template <typename T, typename R, typename... Args>
1817  struct fx_traits<R (__stdcall T::*)(Args...), false> : public basic_traits<false, false, T, R, Args...> {
1818  typedef R (__stdcall T::*function_pointer_type)(Args...);
1819  };
1820 
1821  /* Const Volatile */
1822  template <typename T, typename R, typename... Args>
1823  struct fx_traits<R (__stdcall T::*)(Args...) const, false> : public basic_traits<false, false, T, R, Args...> {
1824  typedef R (__stdcall T::*function_pointer_type)(Args...) const;
1825  };
1826 
1827  template <typename T, typename R, typename... Args>
1828  struct fx_traits<R (__stdcall T::*)(Args...) const volatile, false> : public basic_traits<false, false, T, R, Args...> {
1829  typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile;
1830  };
1831 
1832  /* Member Function Qualifiers */
1833  template <typename T, typename R, typename... Args>
1834  struct fx_traits<R (__stdcall T::*)(Args...)&, false> : public basic_traits<false, false, T, R, Args...> {
1835  typedef R (__stdcall T::*function_pointer_type)(Args...) &;
1836  };
1837 
1838  template <typename T, typename R, typename... Args>
1839  struct fx_traits<R (__stdcall T::*)(Args...) const&, false> : public basic_traits<false, false, T, R, Args...> {
1840  typedef R (__stdcall T::*function_pointer_type)(Args...) const&;
1841  };
1842 
1843  template <typename T, typename R, typename... Args>
1844  struct fx_traits<R (__stdcall T::*)(Args...) const volatile&, false> : public basic_traits<false, false, T, R, Args...> {
1845  typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile&;
1846  };
1847 
1848  template <typename T, typename R, typename... Args>
1849  struct fx_traits<R (__stdcall T::*)(Args...)&&, false> : public basic_traits<false, false, T, R, Args...> {
1850  typedef R (__stdcall T::*function_pointer_type)(Args...) &&;
1851  };
1852 
1853  template <typename T, typename R, typename... Args>
1854  struct fx_traits<R (__stdcall T::*)(Args...) const&&, false> : public basic_traits<false, false, T, R, Args...> {
1855  typedef R (__stdcall T::*function_pointer_type)(Args...) const&&;
1856  };
1857 
1858  template <typename T, typename R, typename... Args>
1859  struct fx_traits<R (__stdcall T::*)(Args...) const volatile&&, false> : public basic_traits<false, false, T, R, Args...> {
1860  typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile&&;
1861  };
1862 
1863 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE)
1864 
1865  template <typename R, typename... Args>
1866  struct fx_traits<R __stdcall(Args...) noexcept, false> : public basic_traits<true, false, void, R, Args...> {
1867  typedef R(__stdcall* function_pointer_type)(Args...) noexcept;
1868  };
1869 
1870  template <typename R, typename... Args>
1871  struct fx_traits<R(__stdcall*)(Args...) noexcept, false> : public basic_traits<true, false, void, R, Args...> {
1872  typedef R(__stdcall* function_pointer_type)(Args...) noexcept;
1873  };
1874 
1875  /* __stdcall cannot be applied to functions with varargs*/
1876  /*template <typename R, typename... Args>
1877  struct fx_traits<__stdcall R(Args..., ...) noexcept, false> : public basic_traits<true, true, void, R, Args...> {
1878  typedef R(__stdcall* function_pointer_type)(Args..., ...) noexcept;
1879  };
1880 
1881  template <typename R, typename... Args>
1882  struct fx_traits<R (__stdcall *)(Args..., ...) noexcept, false> : public basic_traits<true, true, void, R, Args...> {
1883  typedef R(__stdcall* function_pointer_type)(Args..., ...) noexcept;
1884  };*/
1885 
1886  template <typename T, typename R, typename... Args>
1887  struct fx_traits<R (__stdcall T::*)(Args...) noexcept, false> : public basic_traits<true, false, T, R, Args...> {
1888  typedef R (__stdcall T::*function_pointer_type)(Args...) noexcept;
1889  };
1890 
1891  /* __stdcall does not work with varargs */
1892  /*template <typename T, typename R, typename... Args>
1893  struct fx_traits<R (__stdcall T::*)(Args..., ...) noexcept, false> : public basic_traits<true, true, T, R, Args...> {
1894  typedef R (__stdcall T::*function_pointer_type)(Args..., ...) noexcept;
1895  };*/
1896 
1897  /* Const Volatile */
1898  template <typename T, typename R, typename... Args>
1899  struct fx_traits<R (__stdcall T::*)(Args...) const noexcept, false> : public basic_traits<true, false, T, R, Args...> {
1900  typedef R (__stdcall T::*function_pointer_type)(Args...) const noexcept;
1901  };
1902 
1903  /* __stdcall does not work with varargs */
1904  /*template <typename T, typename R, typename... Args>
1905  struct fx_traits<R (__stdcall T::*)(Args..., ...) const noexcept, false> : public basic_traits<true, true, T, R, Args...> {
1906  typedef R (__stdcall T::*function_pointer_type)(Args..., ...) const noexcept;
1907  };*/
1908 
1909  template <typename T, typename R, typename... Args>
1910  struct fx_traits<R (__stdcall T::*)(Args...) const volatile noexcept, false> : public basic_traits<true, false, T, R, Args...> {
1911  typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile noexcept;
1912  };
1913 
1914  /* __stdcall does not work with varargs */
1915  /*template <typename T, typename R, typename... Args>
1916  struct fx_traits<R (__stdcall T::*)(Args..., ...) const volatile noexcept, false> : public basic_traits<true, true, T, R, Args...> {
1917  typedef R (__stdcall T::*function_pointer_type)(Args..., ...) const volatile noexcept;
1918  };*/
1919 
1920  template <typename T, typename R, typename... Args>
1921  struct fx_traits<R (__stdcall T::*)(Args...)& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
1922  typedef R (__stdcall T::*function_pointer_type)(Args...) & noexcept;
1923  };
1924 
1925  /* __stdcall does not work with varargs */
1926  /*template <typename T, typename R, typename... Args>
1927  struct fx_traits<R (__stdcall T::*)(Args..., ...) & noexcept, false> : public basic_traits<true, true, T, R, Args...> {
1928  typedef R (__stdcall T::*function_pointer_type)(Args..., ...) & noexcept;
1929  };*/
1930 
1931  template <typename T, typename R, typename... Args>
1932  struct fx_traits<R (__stdcall T::*)(Args...) const& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
1933  typedef R (__stdcall T::*function_pointer_type)(Args...) const& noexcept;
1934  };
1935 
1936  /* __stdcall does not work with varargs */
1937  /*template <typename T, typename R, typename... Args>
1938  struct fx_traits<R (__stdcall T::*)(Args..., ...) const& noexcept, false> : public basic_traits<true, true, T, R, Args...> {
1939  typedef R (__stdcall T::*function_pointer_type)(Args..., ...) const& noexcept;
1940  };*/
1941 
1942  template <typename T, typename R, typename... Args>
1943  struct fx_traits<R (__stdcall T::*)(Args...) const volatile& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
1944  typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile& noexcept;
1945  };
1946 
1947  /* __stdcall does not work with varargs */
1948  /*template <typename T, typename R, typename... Args>
1949  struct fx_traits<R (__stdcall T::*)(Args..., ...) const volatile& noexcept, false> : public basic_traits<true, true, T, R, Args...> {
1950  typedef R (__stdcall T::*function_pointer_type)(Args..., ...) const volatile& noexcept;
1951  };*/
1952 
1953  template <typename T, typename R, typename... Args>
1954  struct fx_traits<R (__stdcall T::*)(Args...)&& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
1955  typedef R (__stdcall T::*function_pointer_type)(Args...) && noexcept;
1956  };
1957 
1958  /* __stdcall does not work with varargs */
1959  /*template <typename T, typename R, typename... Args>
1960  struct fx_traits<R (__stdcall T::*)(Args..., ...) && noexcept, false> : public basic_traits<true, true, T, R, Args...> {
1961  typedef R (__stdcall T::*function_pointer_type)(Args..., ...) && noexcept;
1962  };*/
1963 
1964  template <typename T, typename R, typename... Args>
1965  struct fx_traits<R (__stdcall T::*)(Args...) const&& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
1966  typedef R (__stdcall T::*function_pointer_type)(Args...) const&& noexcept;
1967  };
1968 
1969  /* __stdcall does not work with varargs */
1970  /*template <typename T, typename R, typename... Args>
1971  struct fx_traits<R (__stdcall T::*)(Args..., ...) const&& noexcept, false> : public basic_traits<true, true, T, R, Args...> {
1972  typedef R (__stdcall T::*function_pointer_type)(Args..., ...) const&& noexcept;
1973  };*/
1974 
1975  template <typename T, typename R, typename... Args>
1976  struct fx_traits<R (__stdcall T::*)(Args...) const volatile&& noexcept, false> : public basic_traits<true, false, T, R, Args...> {
1977  typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile&& noexcept;
1978  };
1979 
1980  /* __stdcall does not work with varargs */
1981  /*template <typename T, typename R, typename... Args>
1982  struct fx_traits<R (__stdcall T::*)(Args..., ...) const volatile&& noexcept, false> : public basic_traits<true, true, T, R, Args...> {
1983  typedef R (__stdcall T::*function_pointer_type)(Args..., ...) const volatile&& noexcept;
1984  };*/
1985 #endif // noexcept is part of a function's type
1986 #endif // __stdcall x86 VC++ bug
1987 
1988  template <typename Signature>
1989  struct fx_traits<Signature, true> : public fx_traits<typename fx_traits<decltype(&Signature::operator())>::function_type, false> { };
1990 
1991  template <typename Signature, bool b = std::is_member_object_pointer<Signature>::value>
1992  struct callable_traits : public fx_traits<std::decay_t<Signature>> { };
1993 
1994  template <typename R, typename T>
1995  struct callable_traits<R(T::*), true> {
1996  typedef meta::conditional_t<std::is_array_v<R>, std::add_lvalue_reference_t<R>, R> return_type;
1997  typedef return_type Arg;
1998  typedef T object_type;
1999  using signature_type = R(T::*);
2000  inline static constexpr bool is_noexcept = false;
2001  inline static constexpr bool is_member_function = false;
2002  inline static constexpr std::size_t arity = 1;
2003  inline static constexpr std::size_t free_arity = 2;
2004  typedef std::tuple<Arg> args_tuple;
2009  typedef return_type (*function_pointer_type)(T&, Arg);
2011  template <std::size_t i>
2013  };
2014 
2015  } // namespace meta_detail
2016 
2017  template <typename Signature>
2019 
2020  namespace meta_detail {
2021  template <typename, bool>
2023 
2024  template <typename T>
2025  struct is_probably_stateless_lambda<T, true> : std::is_convertible<T, typename bind_traits<T>::function_type*>::type { };
2026  } // namespace meta_detail
2027 
2028  template <typename T>
2030 
2031  template <typename T>
2033 
2034  template <typename Signature>
2036 
2037  template <typename Signature>
2039 
2040  template <typename Signature>
2042 }} // namespace sol::meta
2043 
2044 // end of sol/bind_traits.hpp
2045 
2046 // beginning of sol/pointer_like.hpp
2047 
2048 #include <utility>
2049 #include <type_traits>
2050 #include <memory>
2051 
2052 namespace sol {
2053 
2054  namespace meta {
2055  namespace meta_detail {
2056  template <typename T>
2057  using is_dereferenceable_test = decltype(*std::declval<T>());
2058 
2059  template <typename T>
2060  using is_explicitly_dereferenceable_test = decltype(std::declval<T>().operator*());
2061  } // namespace meta_detail
2062 
2063  template <typename T>
2064  using is_pointer_like = std::integral_constant<bool,
2065  !std::is_array_v<T> && (std::is_pointer_v<T> || is_detected_v<meta_detail::is_explicitly_dereferenceable_test, T>)>;
2066 
2067  template <typename T>
2069  } // namespace meta
2070 
2071  namespace detail {
2072 
2073  template <typename T>
2074  auto unwrap(T&& item) -> decltype(std::forward<T>(item)) {
2075  return std::forward<T>(item);
2076  }
2077 
2078  template <typename T>
2079  T& unwrap(std::reference_wrapper<T> arg) {
2080  return arg.get();
2081  }
2082 
2083  template <typename T>
2084  inline decltype(auto) deref(T&& item) {
2085  using Tu = meta::unqualified_t<T>;
2086  if constexpr (meta::is_pointer_like_v<Tu>) {
2087  return *std::forward<T>(item);
2088  }
2089  else {
2090  return std::forward<T>(item);
2091  }
2092  }
2093 
2094  template <typename T>
2095  inline decltype(auto) deref_move_only(T&& item) {
2096  using Tu = meta::unqualified_t<T>;
2097  if constexpr (meta::is_pointer_like_v<Tu> && !std::is_pointer_v<Tu> && !std::is_copy_constructible_v<Tu>) {
2098  return *std::forward<T>(item);
2099  }
2100  else {
2101  return std::forward<T>(item);
2102  }
2103  }
2104 
2105  template <typename T>
2106  inline T* ptr(T& val) {
2107  return std::addressof(val);
2108  }
2109 
2110  template <typename T>
2111  inline T* ptr(std::reference_wrapper<T> val) {
2112  return std::addressof(val.get());
2113  }
2114 
2115  template <typename T>
2116  inline T* ptr(T* val) {
2117  return val;
2118  }
2119  } // namespace detail
2120 } // namespace sol
2121 
2122 // end of sol/pointer_like.hpp
2123 
2124 // beginning of sol/string_view.hpp
2125 
2126 #include <cstddef>
2127 #include <string>
2128 #include <string_view>
2129 #include <functional>
2130 
2131 namespace sol {
2132  template <typename C, typename T = std::char_traits<C>>
2133  using basic_string_view = std::basic_string_view<C, T>;
2134 
2139  typedef std::hash<std::string_view> string_view_hash;
2140 } // namespace sol
2141 
2142 // end of sol/string_view.hpp
2143 
2144 #include <type_traits>
2145 #include <cstdint>
2146 #include <memory>
2147 #include <functional>
2148 #include <array>
2149 #include <iterator>
2150 #include <iosfwd>
2151 #if SOL_IS_ON(SOL_STD_VARIANT)
2152 #include <variant>
2153 #endif // variant is weird on XCode, thanks XCode
2154 
2155 namespace sol { namespace meta {
2156  template <typename T>
2157  struct unwrapped {
2158  typedef T type;
2159  };
2160 
2161  template <typename T>
2162  struct unwrapped<std::reference_wrapper<T>> {
2163  typedef T type;
2164  };
2165 
2166  template <typename T>
2168 
2169  template <typename T>
2170  struct unwrap_unqualified : unwrapped<unqualified_t<T>> { };
2171 
2172  template <typename T>
2174 
2175  template <typename T>
2177 
2178  template <typename R, typename T>
2179  struct remove_member_pointer<R T::*> {
2180  typedef R type;
2181  };
2182 
2183  template <typename R, typename T>
2184  struct remove_member_pointer<R T::*const> {
2185  typedef R type;
2186  };
2187 
2188  template <typename T>
2190 
2191  template <typename T, typename...>
2192  struct all_same : std::true_type { };
2193 
2194  template <typename T, typename U, typename... Args>
2195  struct all_same<T, U, Args...> : std::integral_constant<bool, std::is_same<T, U>::value && all_same<T, Args...>::value> { };
2196 
2197  template <typename T, typename...>
2199 
2200  template <typename T, typename U, typename... Args>
2201  struct any_same<T, U, Args...> : std::integral_constant<bool, std::is_same<T, U>::value || any_same<T, Args...>::value> { };
2202 
2203  template <typename T, typename... Args>
2204  constexpr inline bool any_same_v = any_same<T, Args...>::value;
2205 
2206  template <bool B>
2207  using boolean = std::integral_constant<bool, B>;
2208 
2209  template <bool B>
2210  constexpr inline bool boolean_v = boolean<B>::value;
2211 
2212  template <typename T>
2214 
2215  template <typename T>
2216  constexpr inline bool neg_v = neg<T>::value;
2217 
2218  template <typename... Args>
2219  struct all : boolean<true> { };
2220 
2221  template <typename T, typename... Args>
2222  struct all<T, Args...> : std::conditional_t<T::value, all<Args...>, boolean<false>> { };
2223 
2224  template <typename... Args>
2225  struct any : boolean<false> { };
2226 
2227  template <typename T, typename... Args>
2228  struct any<T, Args...> : std::conditional_t<T::value, boolean<true>, any<Args...>> { };
2229 
2230  template <typename... Args>
2231  constexpr inline bool all_v = all<Args...>::value;
2232 
2233  template <typename... Args>
2234  constexpr inline bool any_v = any<Args...>::value;
2235 
2236  enum class enable_t { _ };
2237 
2238  constexpr const auto enabler = enable_t::_;
2239 
2240  template <bool value, typename T = void>
2241  using disable_if_t = std::enable_if_t<!value, T>;
2242 
2243  template <typename... Args>
2244  using enable = std::enable_if_t<all<Args...>::value, enable_t>;
2245 
2246  template <typename... Args>
2247  using disable = std::enable_if_t<neg<all<Args...>>::value, enable_t>;
2248 
2249  template <typename... Args>
2250  using enable_any = std::enable_if_t<any<Args...>::value, enable_t>;
2251 
2252  template <typename... Args>
2253  using disable_any = std::enable_if_t<neg<any<Args...>>::value, enable_t>;
2254 
2255  template <typename V, typename... Vs>
2256  struct find_in_pack_v : boolean<false> { };
2257 
2258  template <typename V, typename Vs1, typename... Vs>
2259  struct find_in_pack_v<V, Vs1, Vs...> : any<boolean<(V::value == Vs1::value)>, find_in_pack_v<V, Vs...>> { };
2260 
2261  namespace meta_detail {
2262  template <std::size_t I, typename T, typename... Args>
2263  struct index_in_pack : std::integral_constant<std::size_t, SIZE_MAX> { };
2264 
2265  template <std::size_t I, typename T, typename T1, typename... Args>
2266  struct index_in_pack<I, T, T1, Args...>
2267  : conditional_t<std::is_same<T, T1>::value, std::integral_constant<std::ptrdiff_t, I>, index_in_pack<I + 1, T, Args...>> { };
2268  } // namespace meta_detail
2269 
2270  template <typename T, typename... Args>
2271  struct index_in_pack : meta_detail::index_in_pack<0, T, Args...> { };
2272 
2273  template <typename T, typename List>
2274  struct index_in : meta_detail::index_in_pack<0, T, List> { };
2275 
2276  template <typename T, typename... Args>
2277  struct index_in<T, types<Args...>> : meta_detail::index_in_pack<0, T, Args...> { };
2278 
2279  template <std::size_t I, typename... Args>
2280  struct at_in_pack { };
2281 
2282  template <std::size_t I, typename... Args>
2283  using at_in_pack_t = typename at_in_pack<I, Args...>::type;
2284 
2285  template <std::size_t I, typename Arg, typename... Args>
2286  struct at_in_pack<I, Arg, Args...> : std::conditional<I == 0, Arg, at_in_pack_t<I - 1, Args...>> { };
2287 
2288  template <typename Arg, typename... Args>
2289  struct at_in_pack<0, Arg, Args...> {
2290  typedef Arg type;
2291  };
2292 
2293  namespace meta_detail {
2294  template <typename, typename TI>
2295  using on_even = meta::boolean<(TI::value % 2) == 0>;
2296 
2297  template <typename, typename TI>
2298  using on_odd = meta::boolean<(TI::value % 2) == 1>;
2299 
2300  template <typename, typename>
2302 
2303  template <template <typename...> class When, std::size_t Limit, std::size_t I, template <typename...> class Pred, typename... Ts>
2304  struct count_when_for_pack : std::integral_constant<std::size_t, 0> { };
2305  template <template <typename...> class When, std::size_t Limit, std::size_t I, template <typename...> class Pred, typename T, typename... Ts>
2306  struct count_when_for_pack<When, Limit, I, Pred, T, Ts...> : conditional_t < sizeof...(Ts)
2307  == 0
2308  || Limit<2, std::integral_constant<std::size_t, I + static_cast<std::size_t>(Limit != 0 && Pred<T>::value)>,
2309  count_when_for_pack<When, Limit - static_cast<std::size_t>(When<T, std::integral_constant<std::size_t, I>>::value),
2310  I + static_cast<std::size_t>(When<T, std::integral_constant<std::size_t, I>>::value&& Pred<T>::value), Pred, Ts...>> { };
2311  } // namespace meta_detail
2312 
2313  template <template <typename...> class Pred, typename... Ts>
2314  struct count_for_pack : meta_detail::count_when_for_pack<meta_detail::on_always, sizeof...(Ts), 0, Pred, Ts...> { };
2315 
2316  template <template <typename...> class Pred, typename... Ts>
2317  inline constexpr std::size_t count_for_pack_v = count_for_pack<Pred, Ts...>::value;
2318 
2319  template <template <typename...> class Pred, typename List>
2320  struct count_for;
2321 
2322  template <template <typename...> class Pred, typename... Args>
2323  struct count_for<Pred, types<Args...>> : count_for_pack<Pred, Args...> { };
2324 
2325  template <std::size_t Limit, template <typename...> class Pred, typename... Ts>
2326  struct count_for_to_pack : meta_detail::count_when_for_pack<meta_detail::on_always, Limit, 0, Pred, Ts...> { };
2327 
2328  template <std::size_t Limit, template <typename...> class Pred, typename... Ts>
2329  inline constexpr std::size_t count_for_to_pack_v = count_for_to_pack<Limit, Pred, Ts...>::value;
2330 
2331  template <template <typename...> class When, std::size_t Limit, template <typename...> class Pred, typename... Ts>
2332  struct count_when_for_to_pack : meta_detail::count_when_for_pack<When, Limit, 0, Pred, Ts...> { };
2333 
2334  template <template <typename...> class When, std::size_t Limit, template <typename...> class Pred, typename... Ts>
2335  inline constexpr std::size_t count_when_for_to_pack_v = count_when_for_to_pack<When, Limit, Pred, Ts...>::value;
2336 
2337  template <template <typename...> class Pred, typename... Ts>
2338  using count_even_for_pack = count_when_for_to_pack<meta_detail::on_even, sizeof...(Ts), Pred, Ts...>;
2339 
2340  template <template <typename...> class Pred, typename... Ts>
2341  inline constexpr std::size_t count_even_for_pack_v = count_even_for_pack<Pred, Ts...>::value;
2342 
2343  template <template <typename...> class Pred, typename... Ts>
2344  using count_odd_for_pack = count_when_for_to_pack<meta_detail::on_odd, sizeof...(Ts), Pred, Ts...>;
2345 
2346  template <template <typename...> class Pred, typename... Ts>
2347  inline constexpr std::size_t count_odd_for_pack_v = count_odd_for_pack<Pred, Ts...>::value;
2348 
2349  template <typename... Args>
2350  struct return_type {
2351  typedef std::tuple<Args...> type;
2352  };
2353 
2354  template <typename T>
2355  struct return_type<T> {
2356  typedef T type;
2357  };
2358 
2359  template <>
2360  struct return_type<> {
2361  typedef void type;
2362  };
2363 
2364  template <typename... Args>
2365  using return_type_t = typename return_type<Args...>::type;
2366 
2367  namespace meta_detail {
2368  template <typename>
2369  struct always_true : std::true_type { };
2370  struct is_invokable_tester {
2371  template <typename Fun, typename... Args>
2372  static always_true<decltype(std::declval<Fun>()(std::declval<Args>()...))> test(int);
2373  template <typename...>
2374  static std::false_type test(...);
2375  };
2376  } // namespace meta_detail
2377 
2378  template <typename T>
2379  struct is_invokable;
2380  template <typename Fun, typename... Args>
2381  struct is_invokable<Fun(Args...)> : decltype(meta_detail::is_invokable_tester::test<Fun, Args...>(0)) { };
2382 
2383  namespace meta_detail {
2384 
2385  template <typename T, typename = void>
2386  struct is_invocable : std::is_function<std::remove_pointer_t<T>> { };
2387 
2388  template <typename T>
2389  struct is_invocable<T,
2390  std::enable_if_t<std::is_final<unqualified_t<T>>::value && std::is_class<unqualified_t<T>>::value
2391  && std::is_same<decltype(void(&T::operator())), void>::value>> { };
2392 
2393  template <typename T>
2394  struct is_invocable<T,
2395  std::enable_if_t<!std::is_final<unqualified_t<T>>::value && std::is_class<unqualified_t<T>>::value
2396  && std::is_destructible<unqualified_t<T>>::value>> {
2397  struct F {
2398  void operator()() {};
2399  };
2400  struct Derived : T, F { };
2401  template <typename U, U>
2402  struct Check;
2403 
2404  template <typename V>
2405  static sfinae_no_t test(Check<void (F::*)(), &V::operator()>*);
2406 
2407  template <typename>
2408  static sfinae_yes_t test(...);
2409 
2410  static constexpr bool value = std::is_same_v<decltype(test<Derived>(0)), sfinae_yes_t>;
2411  };
2412 
2413  template <typename T>
2414  struct is_invocable<T,
2415  std::enable_if_t<!std::is_final<unqualified_t<T>>::value && std::is_class<unqualified_t<T>>::value
2416  && !std::is_destructible<unqualified_t<T>>::value>> {
2417  struct F {
2418  void operator()() {};
2419  };
2420  struct Derived : T, F {
2421  ~Derived() = delete;
2422  };
2423  template <typename U, U>
2424  struct Check;
2425 
2426  template <typename V>
2427  static sfinae_no_t test(Check<void (F::*)(), &V::operator()>*);
2428 
2429  template <typename>
2430  static sfinae_yes_t test(...);
2431 
2432  static constexpr bool value = std::is_same_v<decltype(test<Derived>(0)), sfinae_yes_t>;
2433  };
2434 
2435  struct has_begin_end_impl {
2436  template <typename T, typename U = unqualified_t<T>, typename B = decltype(std::declval<U&>().begin()),
2437  typename E = decltype(std::declval<U&>().end())>
2438  static std::true_type test(int);
2439 
2440  template <typename...>
2441  static std::false_type test(...);
2442  };
2443 
2444  struct has_key_type_impl {
2445  template <typename T, typename U = unqualified_t<T>, typename V = typename U::key_type>
2446  static std::true_type test(int);
2447 
2448  template <typename...>
2449  static std::false_type test(...);
2450  };
2451 
2452  struct has_key_comp_impl {
2453  template <typename T, typename V = decltype(std::declval<unqualified_t<T>>().key_comp())>
2454  static std::true_type test(int);
2455 
2456  template <typename...>
2457  static std::false_type test(...);
2458  };
2459 
2460  struct has_load_factor_impl {
2461  template <typename T, typename V = decltype(std::declval<unqualified_t<T>>().load_factor())>
2462  static std::true_type test(int);
2463 
2464  template <typename...>
2465  static std::false_type test(...);
2466  };
2467 
2468  struct has_mapped_type_impl {
2469  template <typename T, typename V = typename unqualified_t<T>::mapped_type>
2470  static std::true_type test(int);
2471 
2472  template <typename...>
2473  static std::false_type test(...);
2474  };
2475 
2476  struct has_value_type_impl {
2477  template <typename T, typename V = typename unqualified_t<T>::value_type>
2478  static std::true_type test(int);
2479 
2480  template <typename...>
2481  static std::false_type test(...);
2482  };
2483 
2484  struct has_iterator_impl {
2485  template <typename T, typename V = typename unqualified_t<T>::iterator>
2486  static std::true_type test(int);
2487 
2488  template <typename...>
2489  static std::false_type test(...);
2490  };
2491 
2492  struct has_key_value_pair_impl {
2493  template <typename T, typename U = unqualified_t<T>, typename V = typename U::value_type, typename F = decltype(std::declval<V&>().first),
2494  typename S = decltype(std::declval<V&>().second)>
2495  static std::true_type test(int);
2496 
2497  template <typename...>
2498  static std::false_type test(...);
2499  };
2500 
2501  template <typename T>
2502  struct has_push_back_test {
2503  private:
2504  template <typename C>
2505  static sfinae_yes_t test(decltype(std::declval<C>().push_back(std::declval<std::add_rvalue_reference_t<typename C::value_type>>()))*);
2506  template <typename C>
2507  static sfinae_no_t test(...);
2508 
2509  public:
2510  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), sfinae_yes_t>;
2511  };
2512 
2513  template <typename T>
2514  struct has_insert_with_iterator_test {
2515  private:
2516  template <typename C>
2517  static sfinae_yes_t test(decltype(std::declval<C>().insert(
2518  std::declval<std::add_rvalue_reference_t<typename C::iterator>>(), std::declval<std::add_rvalue_reference_t<typename C::value_type>>()))*);
2519  template <typename C>
2520  static sfinae_no_t test(...);
2521 
2522  public:
2523  static constexpr bool value = !std::is_same_v<decltype(test<T>(0)), sfinae_no_t>;
2524  };
2525 
2526  template <typename T>
2527  struct has_insert_test {
2528  private:
2529  template <typename C>
2530  static sfinae_yes_t test(decltype(std::declval<C>().insert(std::declval<std::add_rvalue_reference_t<typename C::value_type>>()))*);
2531  template <typename C>
2532  static sfinae_no_t test(...);
2533 
2534  public:
2535  static constexpr bool value = !std::is_same_v<decltype(test<T>(0)), sfinae_no_t>;
2536  };
2537 
2538  template <typename T>
2539  struct has_insert_after_test {
2540  private:
2541  template <typename C>
2542  static sfinae_yes_t test(decltype(std::declval<C>().insert_after(std::declval<std::add_rvalue_reference_t<typename C::const_iterator>>(),
2543  std::declval<std::add_rvalue_reference_t<typename C::value_type>>()))*);
2544  template <typename C>
2545  static sfinae_no_t test(...);
2546 
2547  public:
2548  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), sfinae_yes_t>;
2549  };
2550 
2551  template <typename T>
2552  struct has_size_test {
2553  private:
2554  template <typename C>
2555  static sfinae_yes_t test(decltype(std::declval<C>().size())*);
2556  template <typename C>
2557  static sfinae_no_t test(...);
2558 
2559  public:
2560  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), sfinae_yes_t>;
2561  };
2562 
2563  template <typename T>
2564  struct has_max_size_test {
2565  private:
2566  template <typename C>
2567  static sfinae_yes_t test(decltype(std::declval<C>().max_size())*);
2568  template <typename C>
2569  static sfinae_no_t test(...);
2570 
2571  public:
2572  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), sfinae_yes_t>;
2573  };
2574 
2575  template <typename T>
2576  struct has_to_string_test {
2577  private:
2578  template <typename C>
2579  static sfinae_yes_t test(decltype(std::declval<C>().to_string())*);
2580  template <typename C>
2581  static sfinae_no_t test(...);
2582 
2583  public:
2584  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), sfinae_yes_t>;
2585  };
2586 
2587  template <typename T, typename U, typename = void>
2588  class supports_op_less_test : public std::false_type { };
2589  template <typename T, typename U>
2590  class supports_op_less_test<T, U, void_t<decltype(std::declval<T&>() < std::declval<U&>())>>
2591  : public std::integral_constant<bool,
2592 #if SOL_IS_ON(SOL_STD_VARIANT)
2593  !is_specialization_of_v<unqualified_t<T>, std::variant> && !is_specialization_of_v<unqualified_t<U>, std::variant>
2594 #else
2595  true
2596 #endif
2597  > {
2598  };
2599 
2600  template <typename T, typename U, typename = void>
2601  class supports_op_equal_test : public std::false_type { };
2602  template <typename T, typename U>
2603  class supports_op_equal_test<T, U, void_t<decltype(std::declval<T&>() == std::declval<U&>())>>
2604  : public std::integral_constant<bool,
2605 #if SOL_IS_ON(SOL_STD_VARIANT)
2606  !is_specialization_of_v<unqualified_t<T>, std::variant> && !is_specialization_of_v<unqualified_t<U>, std::variant>
2607 #else
2608  true
2609 #endif
2610  > {
2611  };
2612 
2613  template <typename T, typename U, typename = void>
2614  class supports_op_less_equal_test : public std::false_type { };
2615  template <typename T, typename U>
2616  class supports_op_less_equal_test<T, U, void_t<decltype(std::declval<T&>() <= std::declval<U&>())>>
2617  : public std::integral_constant<bool,
2618 #if SOL_IS_ON(SOL_STD_VARIANT)
2619  !is_specialization_of_v<unqualified_t<T>, std::variant> && !is_specialization_of_v<unqualified_t<U>, std::variant>
2620 #else
2621  true
2622 #endif
2623  > {
2624  };
2625 
2626  template <typename T, typename U, typename = void>
2627  class supports_op_left_shift_test : public std::false_type { };
2628  template <typename T, typename U>
2629  class supports_op_left_shift_test<T, U, void_t<decltype(std::declval<T&>() << std::declval<U&>())>> : public std::true_type { };
2630 
2631  template <typename T, typename = void>
2632  class supports_adl_to_string_test : public std::false_type { };
2633  template <typename T>
2634  class supports_adl_to_string_test<T, void_t<decltype(to_string(std::declval<const T&>()))>> : public std::true_type { };
2635 
2636  template <typename T, bool b>
2637  struct is_matched_lookup_impl : std::false_type { };
2638  template <typename T>
2639  struct is_matched_lookup_impl<T, true> : std::is_same<typename T::key_type, typename T::value_type> { };
2640 
2641  template <typename T>
2642  using non_void_t = meta::conditional_t<std::is_void_v<T>, ::sol::detail::unchecked_t, T>;
2643  } // namespace meta_detail
2644 
2645  template <typename T, typename U = T>
2646  class supports_op_less : public meta_detail::supports_op_less_test<T, U> { };
2647 
2648  template <typename T, typename U = T>
2649  class supports_op_equal : public meta_detail::supports_op_equal_test<T, U> { };
2650 
2651  template <typename T, typename U = T>
2652  class supports_op_less_equal : public meta_detail::supports_op_less_equal_test<T, U> { };
2653 
2654  template <typename T, typename U = T>
2655  class supports_op_left_shift : public meta_detail::supports_op_left_shift_test<T, U> { };
2656 
2657  template <typename T>
2658  class supports_adl_to_string : public meta_detail::supports_adl_to_string_test<T> { };
2659 
2660  template <typename T>
2661  class supports_to_string_member : public meta::boolean<meta_detail::has_to_string_test<meta_detail::non_void_t<T>>::value> { };
2662 
2663  template <typename T>
2664  using is_invocable = boolean<meta_detail::is_invocable<T>::value>;
2665 
2666  template <typename T>
2667  constexpr inline bool is_invocable_v = is_invocable<T>::value;
2668 
2669  template <typename T>
2670  struct has_begin_end : decltype(meta_detail::has_begin_end_impl::test<T>(0)) { };
2671 
2672  template <typename T>
2673  constexpr inline bool has_begin_end_v = has_begin_end<T>::value;
2674 
2675  template <typename T>
2676  struct has_key_value_pair : decltype(meta_detail::has_key_value_pair_impl::test<T>(0)) { };
2677 
2678  template <typename T>
2679  struct has_key_type : decltype(meta_detail::has_key_type_impl::test<T>(0)) { };
2680 
2681  template <typename T>
2682  struct has_key_comp : decltype(meta_detail::has_key_comp_impl::test<T>(0)) { };
2683 
2684  template <typename T>
2685  struct has_load_factor : decltype(meta_detail::has_load_factor_impl::test<T>(0)) { };
2686 
2687  template <typename T>
2688  struct has_mapped_type : decltype(meta_detail::has_mapped_type_impl::test<T>(0)) { };
2689 
2690  template <typename T>
2691  struct has_iterator : decltype(meta_detail::has_iterator_impl::test<T>(0)) { };
2692 
2693  template <typename T>
2694  struct has_value_type : decltype(meta_detail::has_value_type_impl::test<T>(0)) { };
2695 
2696  template <typename T>
2697  using has_push_back = meta::boolean<meta_detail::has_push_back_test<T>::value>;
2698 
2699  template <typename T>
2700  using has_max_size = meta::boolean<meta_detail::has_max_size_test<T>::value>;
2701 
2702  template <typename T>
2703  using has_insert = meta::boolean<meta_detail::has_insert_test<T>::value>;
2704 
2705  template <typename T>
2706  using has_insert_with_iterator = meta::boolean<meta_detail::has_insert_with_iterator_test<T>::value>;
2707 
2708  template <typename T>
2709  using has_insert_after = meta::boolean<meta_detail::has_insert_after_test<T>::value>;
2710 
2711  template <typename T>
2712  using has_size = meta::boolean<meta_detail::has_size_test<T>::value>;
2713 
2714  template <typename T>
2715  using is_associative = meta::all<has_key_type<T>, has_key_value_pair<T>, has_mapped_type<T>>;
2716 
2717  template <typename T>
2718  using is_lookup = meta::all<has_key_type<T>, has_value_type<T>>;
2719 
2720  template <typename T>
2721  using is_ordered = meta::all<has_key_comp<T>, meta::neg<has_load_factor<T>>>;
2722 
2723  template <typename T>
2724  using is_matched_lookup = meta_detail::is_matched_lookup_impl<T, is_lookup<T>::value>;
2725 
2726  template <typename T>
2727  using is_initializer_list = meta::is_specialization_of<T, std::initializer_list>;
2728 
2729  template <typename T>
2730  constexpr inline bool is_initializer_list_v = is_initializer_list<T>::value;
2731 
2732  template <typename T, typename CharT = char>
2733  using is_string_literal_array_of = boolean<std::is_array_v<T> && std::is_same_v<std::remove_all_extents_t<T>, CharT>>;
2734 
2735  template <typename T, typename CharT = char>
2736  constexpr inline bool is_string_literal_array_of_v = is_string_literal_array_of<T, CharT>::value;
2737 
2738  template <typename T>
2739  using is_string_literal_array = boolean<std::is_array_v<T> && any_same_v<std::remove_all_extents_t<T>, char,
2740 #if SOL_IS_ON(SOL_CHAR8_T)
2741  char8_t,
2742 #endif
2743  char16_t, char32_t, wchar_t>>;
2744 
2745  template <typename T>
2746  constexpr inline bool is_string_literal_array_v = is_string_literal_array<T>::value;
2747 
2748  template <typename T, typename CharT>
2749  struct is_string_of : std::false_type { };
2750 
2751  template <typename CharT, typename CharTargetT, typename TraitsT, typename AllocT>
2752  struct is_string_of<std::basic_string<CharT, TraitsT, AllocT>, CharTargetT> : std::is_same<CharT, CharTargetT> { };
2753 
2754  template <typename T, typename CharT>
2755  constexpr inline bool is_string_of_v = is_string_of<T, CharT>::value;
2756 
2757  template <typename T, typename CharT>
2758  struct is_string_view_of : std::false_type { };
2759 
2760  template <typename CharT, typename CharTargetT, typename TraitsT>
2761  struct is_string_view_of<std::basic_string_view<CharT, TraitsT>, CharTargetT> : std::is_same<CharT, CharTargetT> { };
2762 
2763  template <typename T, typename CharT>
2764  constexpr inline bool is_string_view_of_v = is_string_view_of<T, CharT>::value;
2765 
2766  template <typename T>
2767  using is_string_like
2768  = meta::boolean<is_specialization_of_v<T, std::basic_string> || is_specialization_of_v<T, std::basic_string_view> || is_string_literal_array_v<T>>;
2769 
2770  template <typename T>
2771  constexpr inline bool is_string_like_v = is_string_like<T>::value;
2772 
2773  template <typename T, typename CharT = char>
2774  using is_string_constructible = meta::boolean<
2775  is_string_literal_array_of_v<T,
2776  CharT> || std::is_same_v<T, const CharT*> || std::is_same_v<T, CharT> || is_string_of_v<T, CharT> || std::is_same_v<T, std::initializer_list<CharT>> || is_string_view_of_v<T, CharT> || std::is_null_pointer_v<T>>;
2777 
2778  template <typename T, typename CharT = char>
2779  constexpr inline bool is_string_constructible_v = is_string_constructible<T, CharT>::value;
2780 
2781  template <typename T>
2782  using is_string_like_or_constructible = meta::boolean<is_string_like_v<T> || is_string_constructible_v<T>>;
2783 
2784  template <typename T>
2785  struct is_pair : std::false_type { };
2786 
2787  template <typename T1, typename T2>
2788  struct is_pair<std::pair<T1, T2>> : std::true_type { };
2789 
2790  template <typename T, typename Char>
2791  using is_c_str_of = any<std::is_same<T, const Char*>, std::is_same<T, Char const* const>, std::is_same<T, Char*>, is_string_literal_array_of<T, Char>>;
2792 
2793  template <typename T, typename Char>
2794  constexpr inline bool is_c_str_of_v = is_c_str_of<T, Char>::value;
2795 
2796  template <typename T>
2797  using is_c_str = is_c_str_of<T, char>;
2798 
2799  template <typename T>
2800  constexpr inline bool is_c_str_v = is_c_str<T>::value;
2801 
2802  template <typename T, typename Char>
2803  using is_c_str_or_string_of = any<is_c_str_of<T, Char>, is_string_of<T, Char>>;
2804 
2805  template <typename T, typename Char>
2806  constexpr inline bool is_c_str_or_string_of_v = is_c_str_or_string_of<T, Char>::value;
2807 
2808  template <typename T>
2809  using is_c_str_or_string = is_c_str_or_string_of<T, char>;
2810 
2811  template <typename T>
2812  constexpr inline bool is_c_str_or_string_v = is_c_str_or_string<T>::value;
2813 
2814  template <typename T>
2815  struct is_move_only : all<neg<std::is_reference<T>>, neg<std::is_copy_constructible<unqualified_t<T>>>, std::is_move_constructible<unqualified_t<T>>> { };
2816 
2817  template <typename T>
2818  using is_not_move_only = neg<is_move_only<T>>;
2819 
2820  namespace meta_detail {
2821  template <typename T>
2822  decltype(auto) force_tuple(T&& x) {
2823  if constexpr (meta::is_specialization_of_v<meta::unqualified_t<T>, std::tuple>) {
2824  return std::forward<T>(x);
2825  }
2826  else {
2827  return std::tuple<T>(std::forward<T>(x));
2828  }
2829  }
2830  } // namespace meta_detail
2831 
2832  template <typename... X>
2833  decltype(auto) tuplefy(X&&... x) {
2834  return std::tuple_cat(meta_detail::force_tuple(std::forward<X>(x))...);
2835  }
2836 
2837  template <typename T, typename = void>
2838  struct iterator_tag {
2839  using type = std::input_iterator_tag;
2840  };
2841 
2842  template <typename T>
2843  struct iterator_tag<T, conditional_t<false, typename std::iterator_traits<T>::iterator_category, void>> {
2844  using type = typename std::iterator_traits<T>::iterator_category;
2845  };
2846 
2847 }} // namespace sol::meta
2848 
2849 // end of sol/traits.hpp
2850 
2851 namespace sol {
2852  namespace detail {
2853  const bool default_safe_function_calls =
2854 #if SOL_IS_ON(SOL_SAFE_FUNCTION_CALLS)
2855  true;
2856 #else
2857  false;
2858 #endif
2859  } // namespace detail
2860 
2861  namespace meta { namespace meta_detail {
2862  }} // namespace meta::meta_detail
2863 
2864  namespace stack { namespace stack_detail {
2865  using undefined_method_func = void (*)(stack_reference);
2866 
2867  template <typename T>
2868  void set_undefined_methods_on(stack_reference);
2869 
2870  struct undefined_metatable;
2871  }} // namespace stack::stack_detail
2872 } // namespace sol
2873 
2874 #endif // SOL_FORWARD_DETAIL_HPP
2875 // end of sol/forward_detail.hpp
2876 
2877 // beginning of sol/assert.hpp
2878 
2879 #if SOL_IS_ON(SOL2_CI)
2880 
2881 struct pre_main {
2882  pre_main() {
2883 #ifdef _MSC_VER
2884  _set_abort_behavior(0, _WRITE_ABORT_MSG);
2885 #endif
2886  }
2887 } inline sol2_ci_dont_lock_ci_please = {};
2888 
2889 #endif // Prevent lockup when doing Continuous Integration
2890 
2891 #if SOL_IS_ON(SOL_USER_C_ASSERT)
2892  #define sol_c_assert(...) SOL_C_ASSERT(__VA_ARGS__)
2893 #else
2894  #if SOL_IS_ON(SOL_DEBUG_BUILD)
2895  #include <exception>
2896  #include <iostream>
2897  #include <cstdlib>
2898 
2899  #define sol_c_assert(...) \
2900  do { \
2901  if (!(__VA_ARGS__)) { \
2902  std::cerr << "Assertion `" #__VA_ARGS__ "` failed in " << __FILE__ << " line " << __LINE__ << std::endl; \
2903  std::terminate(); \
2904  } \
2905  } while (false)
2906  #else
2907  #define sol_c_assert(...) \
2908  do { \
2909  if (false) { \
2910  (void)(__VA_ARGS__); \
2911  } \
2912  } while (false)
2913  #endif
2914 #endif
2915 
2916 #if SOL_IS_ON(SOL_USER_M_ASSERT)
2917  #define sol_m_assert(message, ...) SOL_M_ASSERT(message, __VA_ARGS__)
2918 #else
2919  #if SOL_IS_ON(SOL_DEBUG_BUILD)
2920  #include <exception>
2921  #include <iostream>
2922  #include <cstdlib>
2923 
2924  #define sol_m_assert(message, ...) \
2925  do { \
2926  if (!(__VA_ARGS__)) { \
2927  std::cerr << "Assertion `" #__VA_ARGS__ "` failed in " << __FILE__ << " line " << __LINE__ << ": " << message << std::endl; \
2928  std::terminate(); \
2929  } \
2930  } while (false)
2931  #else
2932  #define sol_m_assert(message, ...) \
2933  do { \
2934  if (false) { \
2935  (void)(__VA_ARGS__); \
2936  (void)sizeof(message); \
2937  } \
2938  } while (false)
2939  #endif
2940 #endif
2941 
2942 // end of sol/assert.hpp
2943 
2944 // beginning of sol/bytecode.hpp
2945 
2946 // beginning of sol/compatibility.hpp
2947 
2948 // beginning of sol/compatibility/lua_version.hpp
2949 
2950 #if SOL_IS_ON(SOL_USE_CXX_LUA)
2951  #include <lua.h>
2952  #include <lualib.h>
2953  #include <lauxlib.h>
2954 #elif SOL_IS_ON(SOL_USE_LUA_HPP)
2955  #include <lua.hpp>
2956 #else
2957  extern "C" {
2958  #include <lua.h>
2959  #include <lauxlib.h>
2960  #include <lualib.h>
2961  }
2962 #endif // C++ Mangling for Lua vs. Not
2963 
2964 #if defined(SOL_LUAJIT)
2965  #if (SOL_LUAJIT != 0)
2966  #define SOL_USE_LUAJIT_I_ SOL_ON
2967  #else
2968  #define SOL_USE_LUAJIT_I_ SOL_OFF
2969  #endif
2970 #elif defined(LUAJIT_VERSION)
2971  #define SOL_USE_LUAJIT_I_ SOL_ON
2972 #else
2973  #define SOL_USE_LUAJIT_I_ SOL_DEFAULT_OFF
2974 #endif // luajit
2975 
2976 #if SOL_IS_ON(SOL_USE_CXX_LUAJIT)
2977  #include <luajit.h>
2978 #elif SOL_IS_ON(SOL_USE_LUAJIT)
2979  extern "C" {
2980  #include <luajit.h>
2981  }
2982 #endif // C++ LuaJIT ... whatever that means
2983 
2984 #if defined(SOL_LUAJIT_VERSION)
2985  #define SOL_LUAJIT_VERSION_I_ SOL_LUAJIT_VERSION
2986 #elif SOL_IS_ON(SOL_USE_LUAJIT)
2987  #define SOL_LUAJIT_VERSION_I_ LUAJIT_VERSION_NUM
2988 #else
2989  #define SOL_LUAJIT_VERSION_I_ 0
2990 #endif
2991 
2992 #if defined(SOL_LUAJIT_FFI_DISABLED)
2993  #define SOL_LUAJIT_FFI_DISABLED_I_ SOL_ON
2994 #elif defined(LUAJIT_DISABLE_FFI)
2995  #define SOL_LUAJIT_FFI_DISABLED_I_ SOL_ON
2996 #else
2997  #define SOL_LUAJIT_FFI_DISABLED_I_ SOL_DEFAULT_OFF
2998 #endif
2999 
3000 #if defined(MOONJIT_VERSION)
3001  #define SOL_USE_MOONJIT_I_ SOL_ON
3002 #else
3003  #define SOL_USE_MOONJIT_I_ SOL_OFF
3004 #endif
3005 
3006 #if !defined(SOL_LUA_VERSION)
3007  #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 502
3008  #define SOL_LUA_VERSION LUA_VERSION_NUM
3009  #elif defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 501
3010  #define SOL_LUA_VERSION LUA_VERSION_NUM
3011  #elif !defined(LUA_VERSION_NUM) || !(LUA_VERSION_NUM)
3012  // Definitely 5.0
3013  #define SOL_LUA_VERSION 500
3014  #else
3015  // ??? Not sure, assume latest?
3016  #define SOL_LUA_VERSION 504
3017  #endif // Lua Version 503, 502, 501 || luajit, 500
3018 #endif // SOL_LUA_VERSION
3019 
3020 #if defined(SOL_LUA_VERSION)
3021  #define SOL_LUA_VERSION_I_ SOL_LUA_VERSION
3022 #else
3023  #define SOL_LUA_VERSION_I_ 504
3024 #endif
3025 
3026 #if defined(SOL_EXCEPTIONS_ALWAYS_UNSAFE)
3027  #if (SOL_EXCEPTIONS_ALWAYS_UNSAFE != 0)
3028  #define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_OFF
3029  #else
3030  #define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_ON
3031  #endif
3032 #elif defined(SOL_EXCEPTIONS_SAFE_PROPAGATION)
3033  #if (SOL_EXCEPTIONS_SAFE_PROPAGATION != 0)
3034  #define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_ON
3035  #else
3036  #define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_OFF
3037  #endif
3038 #elif SOL_LUAJIT_VERSION_I_ >= 20100
3039  // LuaJIT 2.1.0-beta3 and better have exception support locked in for all platforms (mostly)
3040  #define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_DEFAULT_ON
3041 #elif SOL_LUAJIT_VERSION_I_ >= 20000
3042  // LuaJIT 2.0.x have exception support only on x64 builds
3043  #if SOL_IS_ON(SOL_PLATFORM_X64)
3044  #define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_DEFAULT_ON
3045  #else
3046  #define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_OFF
3047  #endif
3048 #else
3049  // otherwise, there is no exception safety for
3050  // shoving exceptions through Lua and errors should
3051  // always be serialized
3052  #define SOL_PROPAGATE_EXCEPTIONS_I_ SOL_DEFAULT_OFF
3053 #endif
3054 
3055 #if defined(SOL_EXCEPTIONS_CATCH_ALL)
3056  #if (SOL_EXCEPTIONS_CATCH_ALL != 0)
3057  #define SOL_EXCEPTIONS_CATCH_ALL_I_ SOL_ON
3058  #else
3059  #define SOL_EXCEPTIONS_CATCH_ALL_I_ SOL_OFF
3060  #endif
3061 #else
3062  #if SOL_IS_ON(SOL_USE_LUAJIT)
3063  #define SOL_EXCEPTIONS_CATCH_ALL_I_ SOL_DEFAULT_OFF
3064  #elif SOL_IS_ON(SOL_USE_CXX_LUAJIT)
3065  #define SOL_EXCEPTIONS_CATCH_ALL_I_ SOL_DEFAULT_OFF
3066  #elif SOL_IS_ON(SOL_USE_CXX_LUA)
3067  #define SOL_EXCEPTIONS_CATCH_ALL_I_ SOL_DEFAULT_OFF
3068  #else
3069  #define SOL_EXCEPTIONS_CATCH_ALL_I_ SOL_DEFAULT_ON
3070  #endif
3071 #endif
3072 
3073 #if defined(SOL_LUAJIT_USE_EXCEPTION_TRAMPOLINE)
3074  #if (SOL_LUAJIT_USE_EXCEPTION_TRAMPOLINE != 0)
3075  #define SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_ SOL_ON
3076  #else
3077  #define SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_ SOL_OFF
3078  #endif
3079 #else
3080  #if SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS) && SOL_IS_ON(SOL_USE_LUAJIT)
3081  #define SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_ SOL_ON
3082  #else
3083  #define SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE_I_ SOL_DEFAULT_OFF
3084  #endif
3085 #endif
3086 
3087 #if defined(SOL_LUAL_STREAM_HAS_CLOSE_FUNCTION)
3088  #if (SOL_LUAL_STREAM_HAS_CLOSE_FUNCTION != 0)
3089  #define SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_ SOL_ON
3090  #else
3091  #define SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_ SOL_OFF
3092  #endif
3093 #else
3094  #if SOL_IS_OFF(SOL_USE_LUAJIT) && (SOL_LUA_VERSION > 501)
3095  #define SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_ SOL_ON
3096  #else
3097  #define SOL_LUAL_STREAM_USE_CLOSE_FUNCTION_I_ SOL_DEFAULT_OFF
3098  #endif
3099 #endif
3100 
3101 #if defined (SOL_LUA_BIT32_LIB)
3102  #if SOL_LUA_BIT32_LIB != 0
3103  #define SOL_LUA_BIT32_LIB_I_ SOL_ON
3104  #else
3105  #define SOL_LUA_BIT32_LIB_I_ SOL_OFF
3106  #endif
3107 #else
3108  // Lua 5.2 only (deprecated in 5.3 (503)) (Can be turned on with Compat flags)
3109  // Lua 5.2, or other versions of Lua with the compat flag, or Lua that is not 5.2 with the specific define (5.4.1 either removed it entirely or broke it)
3110  #if (SOL_LUA_VERSION_I_ == 502) || (defined(LUA_COMPAT_BITLIB) && (LUA_COMPAT_BITLIB != 0)) || (SOL_LUA_VERSION_I_ < 504 && (defined(LUA_COMPAT_5_2) && (LUA_COMPAT_5_2 != 0)))
3111  #define SOL_LUA_BIT32_LIB_I_ SOL_ON
3112  #else
3113  #define SOL_LUA_BIT32_LIB_I_ SOL_DEFAULT_OFF
3114  #endif
3115 #endif
3116 
3117 #if defined (SOL_LUA_NIL_IN_TABLES)
3118  #if SOL_LUA_NIL_IN_TABLES != 0
3119  #define SOL_LUA_NIL_IN_TABLES_I_ SOL_ON
3120  #else
3121  #define SOL_LUA_NIL_IN_TABLES_I_ SOL_OFF
3122  #endif
3123 #else
3124  #if defined(LUA_NILINTABLE) && (LUA_NILINTABLE != 0)
3125  #define SOL_LUA_NIL_IN_TABLES_I_ SOL_DEFAULT_ON
3126  #else
3127  #define SOL_LUA_NIL_IN_TABLES_I_ SOL_DEFAULT_OFF
3128  #endif
3129 #endif
3130 
3131 // end of sol/compatibility/lua_version.hpp
3132 
3133 #if SOL_IS_ON(SOL_USE_COMPATIBILITY_LAYER)
3134 
3135 #if SOL_IS_ON(SOL_USE_CXX_LUA) || SOL_IS_ON(SOL_USE_CXX_LUAJIT)
3136 #ifndef COMPAT53_LUA_CPP
3137 #define COMPAT53_LUA_CPP 1
3138 #endif // Build Lua Compat layer as C++
3139 #endif
3140 #ifndef COMPAT53_INCLUDE_SOURCE
3141 #define COMPAT53_INCLUDE_SOURCE 1
3142 #endif // Build Compat Layer Inline
3143 
3144 // beginning of sol/compatibility/compat-5.3.h
3145 
3146 #ifndef KEPLER_PROJECT_COMPAT53_H_
3147 #define KEPLER_PROJECT_COMPAT53_H_
3148 
3149 #include <stddef.h>
3150 #include <limits.h>
3151 #include <string.h>
3152 #if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP)
3153 extern "C" {
3154 #endif
3155 #include <lua.h>
3156 #include <lauxlib.h>
3157 #include <lualib.h>
3158 #if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP)
3159 }
3160 #endif
3161 
3162 #ifndef COMPAT53_PREFIX
3163 /* we chose this name because many other lua bindings / libs have
3164 * their own compatibility layer, and that use the compat53 declaration
3165 * frequently, causing all kinds of linker / compiler issues
3166 */
3167 # define COMPAT53_PREFIX kp_compat53
3168 #endif // COMPAT53_PREFIX
3169 
3170 #ifndef COMPAT53_API
3171 # if defined(COMPAT53_INCLUDE_SOURCE) && COMPAT53_INCLUDE_SOURCE
3172 # if defined(__GNUC__) || defined(__clang__)
3173 # define COMPAT53_API __attribute__((__unused__)) static inline
3174 # else
3175 # define COMPAT53_API static inline
3176 # endif /* Clang/GCC */
3177 # else /* COMPAT53_INCLUDE_SOURCE */
3178 /* we are not including source, so everything is extern */
3179 # define COMPAT53_API extern
3180 # endif /* COMPAT53_INCLUDE_SOURCE */
3181 #endif /* COMPAT53_PREFIX */
3182 
3183 #define COMPAT53_CONCAT_HELPER(a, b) a##b
3184 #define COMPAT53_CONCAT(a, b) COMPAT53_CONCAT_HELPER(a, b)
3185 
3186 /* declarations for Lua 5.1 */
3187 #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 501
3188 
3189 /* XXX not implemented:
3190 * lua_arith (new operators)
3191 * lua_upvalueid
3192 * lua_upvaluejoin
3193 * lua_version
3194 * lua_yieldk
3195 */
3196 
3197 #ifndef LUA_OK
3198 # define LUA_OK 0
3199 #endif
3200 #ifndef LUA_OPADD
3201 # define LUA_OPADD 0
3202 #endif
3203 #ifndef LUA_OPSUB
3204 # define LUA_OPSUB 1
3205 #endif
3206 #ifndef LUA_OPMUL
3207 # define LUA_OPMUL 2
3208 #endif
3209 #ifndef LUA_OPDIV
3210 # define LUA_OPDIV 3
3211 #endif
3212 #ifndef LUA_OPMOD
3213 # define LUA_OPMOD 4
3214 #endif
3215 #ifndef LUA_OPPOW
3216 # define LUA_OPPOW 5
3217 #endif
3218 #ifndef LUA_OPUNM
3219 # define LUA_OPUNM 6
3220 #endif
3221 #ifndef LUA_OPEQ
3222 # define LUA_OPEQ 0
3223 #endif
3224 #ifndef LUA_OPLT
3225 # define LUA_OPLT 1
3226 #endif
3227 #ifndef LUA_OPLE
3228 # define LUA_OPLE 2
3229 #endif
3230 
3231 /* LuaJIT/Lua 5.1 does not have the updated
3232 * error codes for thread status/function returns (but some patched versions do)
3233 * define it only if it's not found
3234 */
3235 #if !defined(LUA_ERRGCMM)
3236 /* Use + 2 because in some versions of Lua (Lua 5.1)
3237 * LUA_ERRFILE is defined as (LUA_ERRERR+1)
3238 * so we need to avoid it (LuaJIT might have something at this
3239 * integer value too)
3240 */
3241 # define LUA_ERRGCMM (LUA_ERRERR + 2)
3242 #endif /* LUA_ERRGCMM define */
3243 
3244 #if !defined(MOONJIT_VERSION)
3245 typedef size_t lua_Unsigned;
3246 #endif
3247 
3248 typedef struct luaL_Buffer_53 {
3249  luaL_Buffer b; /* make incorrect code crash! */
3250  char *ptr;
3251  size_t nelems;
3252  size_t capacity;
3253  lua_State *L2;
3254 } luaL_Buffer_53;
3255 #define luaL_Buffer luaL_Buffer_53
3256 
3257 /* In PUC-Rio 5.1, userdata is a simple FILE*
3258 * In LuaJIT, it's a struct where the first member is a FILE*
3259 * We can't support the `closef` member
3260 */
3261 typedef struct luaL_Stream {
3262  FILE *f;
3263 } luaL_Stream;
3264 
3265 #define lua_absindex COMPAT53_CONCAT(COMPAT53_PREFIX, _absindex)
3266 COMPAT53_API int lua_absindex(lua_State *L, int i);
3267 
3268 #define lua_arith COMPAT53_CONCAT(COMPAT53_PREFIX, _arith)
3269 COMPAT53_API void lua_arith(lua_State *L, int op);
3270 
3271 #define lua_compare COMPAT53_CONCAT(COMPAT53_PREFIX, _compare)
3272 COMPAT53_API int lua_compare(lua_State *L, int idx1, int idx2, int op);
3273 
3274 #define lua_copy COMPAT53_CONCAT(COMPAT53_PREFIX, _copy)
3275 COMPAT53_API void lua_copy(lua_State *L, int from, int to);
3276 
3277 #define lua_getuservalue(L, i) \
3278  (lua_getfenv((L), (i)), lua_type((L), -1))
3279 #define lua_setuservalue(L, i) \
3280  (luaL_checktype((L), -1, LUA_TTABLE), lua_setfenv((L), (i)))
3281 
3282 #define lua_len COMPAT53_CONCAT(COMPAT53_PREFIX, _len)
3283 COMPAT53_API void lua_len(lua_State *L, int i);
3284 
3285 #define lua_pushstring(L, s) \
3286  (lua_pushstring((L), (s)), lua_tostring((L), -1))
3287 
3288 #define lua_pushlstring(L, s, len) \
3289  ((((len) == 0) ? lua_pushlstring((L), "", 0) : lua_pushlstring((L), (s), (len))), lua_tostring((L), -1))
3290 
3291 #ifndef luaL_newlibtable
3292 # define luaL_newlibtable(L, l) \
3293  (lua_createtable((L), 0, sizeof((l))/sizeof(*(l))-1))
3294 #endif
3295 #ifndef luaL_newlib
3296 # define luaL_newlib(L, l) \
3297  (luaL_newlibtable((L), (l)), luaL_register((L), NULL, (l)))
3298 #endif
3299 
3300 #ifndef lua_pushglobaltable
3301 # define lua_pushglobaltable(L) \
3302  lua_pushvalue((L), LUA_GLOBALSINDEX)
3303 #endif
3304 #define lua_rawgetp COMPAT53_CONCAT(COMPAT53_PREFIX, _rawgetp)
3305 COMPAT53_API int lua_rawgetp(lua_State *L, int i, const void *p);
3306 
3307 #define lua_rawsetp COMPAT53_CONCAT(COMPAT53_PREFIX, _rawsetp)
3308 COMPAT53_API void lua_rawsetp(lua_State *L, int i, const void *p);
3309 
3310 #define lua_rawlen(L, i) lua_objlen((L), (i))
3311 
3312 #define lua_tointeger(L, i) lua_tointegerx((L), (i), NULL)
3313 
3314 #define lua_tonumberx COMPAT53_CONCAT(COMPAT53_PREFIX, _tonumberx)
3315 COMPAT53_API lua_Number lua_tonumberx(lua_State *L, int i, int *isnum);
3316 
3317 #define luaL_checkversion COMPAT53_CONCAT(COMPAT53_PREFIX, L_checkversion)
3318 COMPAT53_API void luaL_checkversion(lua_State *L);
3319 
3320 #define lua_load COMPAT53_CONCAT(COMPAT53_PREFIX, _load_53)
3321 COMPAT53_API int lua_load(lua_State *L, lua_Reader reader, void *data, const char* source, const char* mode);
3322 
3323 #define luaL_loadfilex COMPAT53_CONCAT(COMPAT53_PREFIX, L_loadfilex)
3324 COMPAT53_API int luaL_loadfilex(lua_State *L, const char *filename, const char *mode);
3325 
3326 #define luaL_loadbufferx COMPAT53_CONCAT(COMPAT53_PREFIX, L_loadbufferx)
3327 COMPAT53_API int luaL_loadbufferx(lua_State *L, const char *buff, size_t sz, const char *name, const char *mode);
3328 
3329 #define luaL_checkstack COMPAT53_CONCAT(COMPAT53_PREFIX, L_checkstack_53)
3330 COMPAT53_API void luaL_checkstack(lua_State *L, int sp, const char *msg);
3331 
3332 #define luaL_getsubtable COMPAT53_CONCAT(COMPAT53_PREFIX, L_getsubtable)
3333 COMPAT53_API int luaL_getsubtable(lua_State* L, int i, const char *name);
3334 
3335 #define luaL_len COMPAT53_CONCAT(COMPAT53_PREFIX, L_len)
3336 COMPAT53_API lua_Integer luaL_len(lua_State *L, int i);
3337 
3338 #define luaL_setfuncs COMPAT53_CONCAT(COMPAT53_PREFIX, L_setfuncs)
3339 COMPAT53_API void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup);
3340 
3341 #define luaL_setmetatable COMPAT53_CONCAT(COMPAT53_PREFIX, L_setmetatable)
3342 COMPAT53_API void luaL_setmetatable(lua_State *L, const char *tname);
3343 
3344 #define luaL_testudata COMPAT53_CONCAT(COMPAT53_PREFIX, L_testudata)
3345 COMPAT53_API void *luaL_testudata(lua_State *L, int i, const char *tname);
3346 
3347 #define luaL_traceback COMPAT53_CONCAT(COMPAT53_PREFIX, L_traceback)
3348 COMPAT53_API void luaL_traceback(lua_State *L, lua_State *L1, const char *msg, int level);
3349 
3350 #define luaL_fileresult COMPAT53_CONCAT(COMPAT53_PREFIX, L_fileresult)
3351 COMPAT53_API int luaL_fileresult(lua_State *L, int stat, const char *fname);
3352 
3353 #define luaL_execresult COMPAT53_CONCAT(COMPAT53_PREFIX, L_execresult)
3354 COMPAT53_API int luaL_execresult(lua_State *L, int stat);
3355 
3356 #define lua_callk(L, na, nr, ctx, cont) \
3357  ((void)(ctx), (void)(cont), lua_call((L), (na), (nr)))
3358 #define lua_pcallk(L, na, nr, err, ctx, cont) \
3359  ((void)(ctx), (void)(cont), lua_pcall((L), (na), (nr), (err)))
3360 
3361 #define lua_resume(L, from, nargs) \
3362  ((void)(from), lua_resume((L), (nargs)))
3363 
3364 #define luaL_buffinit COMPAT53_CONCAT(COMPAT53_PREFIX, _buffinit_53)
3365 COMPAT53_API void luaL_buffinit(lua_State *L, luaL_Buffer_53 *B);
3366 
3367 #define luaL_prepbuffsize COMPAT53_CONCAT(COMPAT53_PREFIX, _prepbufsize_53)
3368 COMPAT53_API char *luaL_prepbuffsize(luaL_Buffer_53 *B, size_t s);
3369 
3370 #define luaL_addlstring COMPAT53_CONCAT(COMPAT53_PREFIX, _addlstring_53)
3371 COMPAT53_API void luaL_addlstring(luaL_Buffer_53 *B, const char *s, size_t l);
3372 
3373 #define luaL_addvalue COMPAT53_CONCAT(COMPAT53_PREFIX, _addvalue_53)
3374 COMPAT53_API void luaL_addvalue(luaL_Buffer_53 *B);
3375 
3376 #define luaL_pushresult COMPAT53_CONCAT(COMPAT53_PREFIX, _pushresult_53)
3377 COMPAT53_API void luaL_pushresult(luaL_Buffer_53 *B);
3378 
3379 #undef luaL_buffinitsize
3380 #define luaL_buffinitsize(L, B, s) \
3381  (luaL_buffinit((L), (B)), luaL_prepbuffsize((B), (s)))
3382 
3383 #undef luaL_prepbuffer
3384 #define luaL_prepbuffer(B) \
3385  luaL_prepbuffsize((B), LUAL_BUFFERSIZE)
3386 
3387 #undef luaL_addchar
3388 #define luaL_addchar(B, c) \
3389  ((void)((B)->nelems < (B)->capacity || luaL_prepbuffsize((B), 1)), \
3390  ((B)->ptr[(B)->nelems++] = (c)))
3391 
3392 #undef luaL_addsize
3393 #define luaL_addsize(B, s) \
3394  ((B)->nelems += (s))
3395 
3396 #undef luaL_addstring
3397 #define luaL_addstring(B, s) \
3398  luaL_addlstring((B), (s), strlen((s)))
3399 
3400 #undef luaL_pushresultsize
3401 #define luaL_pushresultsize(B, s) \
3402  (luaL_addsize((B), (s)), luaL_pushresult((B)))
3403 
3404 #if defined(LUA_COMPAT_APIINTCASTS)
3405 #define lua_pushunsigned(L, n) \
3406  lua_pushinteger((L), (lua_Integer)(n))
3407 #define lua_tounsignedx(L, i, is) \
3408  ((lua_Unsigned)lua_tointegerx((L), (i), (is)))
3409 #define lua_tounsigned(L, i) \
3410  lua_tounsignedx((L), (i), NULL)
3411 #define luaL_checkunsigned(L, a) \
3412  ((lua_Unsigned)luaL_checkinteger((L), (a)))
3413 #define luaL_optunsigned(L, a, d) \
3414  ((lua_Unsigned)luaL_optinteger((L), (a), (lua_Integer)(d)))
3415 #endif
3416 
3417 #endif /* Lua 5.1 only */
3418 
3419 /* declarations for Lua 5.1 and 5.2 */
3420 #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM <= 502
3421 
3422 typedef int lua_KContext;
3423 
3424 typedef int(*lua_KFunction)(lua_State *L, int status, lua_KContext ctx);
3425 
3426 #define lua_dump(L, w, d, s) \
3427  ((void)(s), lua_dump((L), (w), (d)))
3428 
3429 #define lua_getfield(L, i, k) \
3430  (lua_getfield((L), (i), (k)), lua_type((L), -1))
3431 
3432 #define lua_gettable(L, i) \
3433  (lua_gettable((L), (i)), lua_type((L), -1))
3434 
3435 #define lua_geti COMPAT53_CONCAT(COMPAT53_PREFIX, _geti)
3436 COMPAT53_API int lua_geti(lua_State *L, int index, lua_Integer i);
3437 
3438 #define lua_isinteger COMPAT53_CONCAT(COMPAT53_PREFIX, _isinteger)
3439 COMPAT53_API int lua_isinteger(lua_State *L, int index);
3440 
3441 #define lua_tointegerx COMPAT53_CONCAT(COMPAT53_PREFIX, _tointegerx_53)
3442 COMPAT53_API lua_Integer lua_tointegerx(lua_State *L, int i, int *isnum);
3443 
3444 #define lua_numbertointeger(n, p) \
3445  ((*(p) = (lua_Integer)(n)), 1)
3446 
3447 #define lua_rawget(L, i) \
3448  (lua_rawget((L), (i)), lua_type((L), -1))
3449 
3450 #define lua_rawgeti(L, i, n) \
3451  (lua_rawgeti((L), (i), (n)), lua_type((L), -1))
3452 
3453 #define lua_rotate COMPAT53_CONCAT(COMPAT53_PREFIX, _rotate)
3454 COMPAT53_API void lua_rotate(lua_State *L, int idx, int n);
3455 
3456 #define lua_seti COMPAT53_CONCAT(COMPAT53_PREFIX, _seti)
3457 COMPAT53_API void lua_seti(lua_State *L, int index, lua_Integer i);
3458 
3459 #define lua_stringtonumber COMPAT53_CONCAT(COMPAT53_PREFIX, _stringtonumber)
3460 COMPAT53_API size_t lua_stringtonumber(lua_State *L, const char *s);
3461 
3462 #define luaL_tolstring COMPAT53_CONCAT(COMPAT53_PREFIX, L_tolstring)
3463 COMPAT53_API const char *luaL_tolstring(lua_State *L, int idx, size_t *len);
3464 
3465 #define luaL_getmetafield(L, o, e) \
3466  (luaL_getmetafield((L), (o), (e)) ? lua_type((L), -1) : LUA_TNIL)
3467 
3468 #define luaL_newmetatable(L, tn) \
3469  (luaL_newmetatable((L), (tn)) ? (lua_pushstring((L), (tn)), lua_setfield((L), -2, "__name"), 1) : 0)
3470 
3471 #define luaL_requiref COMPAT53_CONCAT(COMPAT53_PREFIX, L_requiref_53)
3472 COMPAT53_API void luaL_requiref(lua_State *L, const char *modname,
3473  lua_CFunction openf, int glb);
3474 
3475 #endif /* Lua 5.1 and Lua 5.2 */
3476 
3477 /* declarations for Lua 5.2 */
3478 #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 502
3479 
3480 /* XXX not implemented:
3481 * lua_isyieldable
3482 * lua_getextraspace
3483 * lua_arith (new operators)
3484 * lua_pushfstring (new formats)
3485 */
3486 
3487 #define lua_getglobal(L, n) \
3488  (lua_getglobal((L), (n)), lua_type((L), -1))
3489 
3490 #define lua_getuservalue(L, i) \
3491  (lua_getuservalue((L), (i)), lua_type((L), -1))
3492 
3493 #define lua_pushlstring(L, s, len) \
3494  (((len) == 0) ? lua_pushlstring((L), "", 0) : lua_pushlstring((L), (s), (len)))
3495 
3496 #define lua_rawgetp(L, i, p) \
3497  (lua_rawgetp((L), (i), (p)), lua_type((L), -1))
3498 
3499 #define LUA_KFUNCTION(_name) \
3500  static int (_name)(lua_State *L, int status, lua_KContext ctx); \
3501  static int (_name ## _52)(lua_State *L) { \
3502  lua_KContext ctx; \
3503  int status = lua_getctx(L, &ctx); \
3504  return (_name)(L, status, ctx); \
3505  } \
3506  static int (_name)(lua_State *L, int status, lua_KContext ctx)
3507 
3508 #define lua_pcallk(L, na, nr, err, ctx, cont) \
3509  lua_pcallk((L), (na), (nr), (err), (ctx), cont ## _52)
3510 
3511 #define lua_callk(L, na, nr, ctx, cont) \
3512  lua_callk((L), (na), (nr), (ctx), cont ## _52)
3513 
3514 #define lua_yieldk(L, nr, ctx, cont) \
3515  lua_yieldk((L), (nr), (ctx), cont ## _52)
3516 
3517 #ifdef lua_call
3518 # undef lua_call
3519 # define lua_call(L, na, nr) \
3520  (lua_callk)((L), (na), (nr), 0, NULL)
3521 #endif
3522 
3523 #ifdef lua_pcall
3524 # undef lua_pcall
3525 # define lua_pcall(L, na, nr, err) \
3526  (lua_pcallk)((L), (na), (nr), (err), 0, NULL)
3527 #endif
3528 
3529 #ifdef lua_yield
3530 # undef lua_yield
3531 # define lua_yield(L, nr) \
3532  (lua_yieldk)((L), (nr), 0, NULL)
3533 #endif
3534 
3535 #endif /* Lua 5.2 only */
3536 
3537 /* other Lua versions */
3538 #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 || LUA_VERSION_NUM > 504
3539 
3540 # error "unsupported Lua version (i.e. not Lua 5.1, 5.2, 5.3, or 5.4)"
3541 
3542 #endif /* other Lua versions except 5.1, 5.2, 5.3, and 5.4 */
3543 
3544 /* helper macro for defining continuation functions (for every version
3545 * *except* Lua 5.2) */
3546 #ifndef LUA_KFUNCTION
3547 #define LUA_KFUNCTION(_name) \
3548  static int (_name)(lua_State *L, int status, lua_KContext ctx)
3549 #endif
3550 
3551 #if defined(COMPAT53_INCLUDE_SOURCE) && COMPAT53_INCLUDE_SOURCE == 1
3552 // beginning of sol/compatibility/compat-5.3.c.h
3553 
3554 #include <stddef.h>
3555 #include <stdlib.h>
3556 #include <string.h>
3557 #include <ctype.h>
3558 #include <errno.h>
3559 #include <stdio.h>
3560 
3561 /* don't compile it again if it already is included via compat53.h */
3562 #ifndef KEPLER_PROJECT_COMPAT53_C_
3563 #define KEPLER_PROJECT_COMPAT53_C_
3564 
3565 /* definitions for Lua 5.1 only */
3566 #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 501
3567 
3568 #ifndef COMPAT53_FOPEN_NO_LOCK
3569 #if defined(_MSC_VER)
3570 #define COMPAT53_FOPEN_NO_LOCK 1
3571 #else /* otherwise */
3572 #define COMPAT53_FOPEN_NO_LOCK 0
3573 #endif /* VC++ only so far */
3574 #endif /* No-lock fopen_s usage if possible */
3575 
3576 #if defined(_MSC_VER) && COMPAT53_FOPEN_NO_LOCK
3577 #include <share.h>
3578 #endif /* VC++ _fsopen for share-allowed file read */
3579 
3580 #ifndef COMPAT53_HAVE_STRERROR_R
3581 #if defined(__GLIBC__) || defined(_POSIX_VERSION) || defined(__APPLE__) || (!defined(__MINGW32__) && defined(__GNUC__) && (__GNUC__ < 6))
3582 #define COMPAT53_HAVE_STRERROR_R 1
3583 #else /* none of the defines matched: define to 0 */
3584 #define COMPAT53_HAVE_STRERROR_R 0
3585 #endif /* have strerror_r of some form */
3586 #endif /* strerror_r */
3587 
3588 #ifndef COMPAT53_HAVE_STRERROR_S
3589 #if defined(_MSC_VER) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || (defined(__STDC_LIB_EXT1__) && __STDC_LIB_EXT1__)
3590 #define COMPAT53_HAVE_STRERROR_S 1
3591 #else /* not VC++ or C11 */
3592 #define COMPAT53_HAVE_STRERROR_S 0
3593 #endif /* strerror_s from VC++ or C11 */
3594 #endif /* strerror_s */
3595 
3596 #ifndef COMPAT53_LUA_FILE_BUFFER_SIZE
3597 #define COMPAT53_LUA_FILE_BUFFER_SIZE 4096
3598 #endif /* Lua File Buffer Size */
3599 
3600 static char* compat53_strerror(int en, char* buff, size_t sz) {
3601 #if COMPAT53_HAVE_STRERROR_R
3602  /* use strerror_r here, because it's available on these specific platforms */
3603  if (sz > 0) {
3604  buff[0] = '\0';
3605  /* we don't care whether the GNU version or the XSI version is used: */
3606  if (strerror_r(en, buff, sz)) {
3607  /* Yes, we really DO want to ignore the return value!
3608  * GCC makes that extra hard, not even a (void) cast will do. */
3609  }
3610  if (buff[0] == '\0') {
3611  /* Buffer is unchanged, so we probably have called GNU strerror_r which
3612  * returned a static constant string. Chances are that strerror will
3613  * return the same static constant string and therefore be thread-safe. */
3614  return strerror(en);
3615  }
3616  }
3617  return buff; /* sz is 0 *or* strerror_r wrote into the buffer */
3618 #elif COMPAT53_HAVE_STRERROR_S
3619  /* for MSVC and other C11 implementations, use strerror_s since it's
3620  * provided by default by the libraries */
3621  strerror_s(buff, sz, en);
3622  return buff;
3623 #else
3624  /* fallback, but strerror is not guaranteed to be threadsafe due to modifying
3625  * errno itself and some impls not locking a static buffer for it ... but most
3626  * known systems have threadsafe errno: this might only change if the locale
3627  * is changed out from under someone while this function is being called */
3628  (void)buff;
3629  (void)sz;
3630  return strerror(en);
3631 #endif
3632 }
3633 
3634 COMPAT53_API int lua_absindex(lua_State* L, int i) {
3635  if (i < 0 && i > LUA_REGISTRYINDEX)
3636  i += lua_gettop(L) + 1;
3637  return i;
3638 }
3639 
3640 static void compat53_call_lua(lua_State* L, char const code[], size_t len, int nargs, int nret) {
3641  lua_rawgetp(L, LUA_REGISTRYINDEX, (void*)code);
3642  if (lua_type(L, -1) != LUA_TFUNCTION) {
3643  lua_pop(L, 1);
3644  if (luaL_loadbuffer(L, code, len, "=none"))
3645  lua_error(L);
3646  lua_pushvalue(L, -1);
3647  lua_rawsetp(L, LUA_REGISTRYINDEX, (void*)code);
3648  }
3649  lua_insert(L, -nargs - 1);
3650  lua_call(L, nargs, nret);
3651 }
3652 
3653 COMPAT53_API void lua_arith(lua_State* L, int op) {
3654  static const char compat53_arith_code[]
3655  = "local op,a,b=...\n"
3656  "if op==0 then return a+b\n"
3657  "elseif op==1 then return a-b\n"
3658  "elseif op==2 then return a*b\n"
3659  "elseif op==3 then return a/b\n"
3660  "elseif op==4 then return a%b\n"
3661  "elseif op==5 then return a^b\n"
3662  "elseif op==6 then return -a\n"
3663  "end\n";
3664 
3665  if (op < LUA_OPADD || op > LUA_OPUNM)
3666  luaL_error(L, "invalid 'op' argument for lua_arith");
3667  luaL_checkstack(L, 5, "not enough stack slots");
3668  if (op == LUA_OPUNM)
3669  lua_pushvalue(L, -1);
3670  lua_pushnumber(L, op);
3671  lua_insert(L, -3);
3672  compat53_call_lua(L, compat53_arith_code, sizeof(compat53_arith_code) - 1, 3, 1);
3673 }
3674 
3675 COMPAT53_API int lua_compare(lua_State* L, int idx1, int idx2, int op) {
3676  static const char compat53_compare_code[]
3677  = "local a,b=...\n"
3678  "return a<=b\n";
3679 
3680  int result = 0;
3681  switch (op) {
3682  case LUA_OPEQ:
3683  return lua_equal(L, idx1, idx2);
3684  case LUA_OPLT:
3685  return lua_lessthan(L, idx1, idx2);
3686  case LUA_OPLE:
3687  luaL_checkstack(L, 5, "not enough stack slots");
3688  idx1 = lua_absindex(L, idx1);
3689  idx2 = lua_absindex(L, idx2);
3690  lua_pushvalue(L, idx1);
3691  lua_pushvalue(L, idx2);
3692  compat53_call_lua(L, compat53_compare_code, sizeof(compat53_compare_code) - 1, 2, 1);
3693  result = lua_toboolean(L, -1);
3694  lua_pop(L, 1);
3695  return result;
3696  default:
3697  luaL_error(L, "invalid 'op' argument for lua_compare");
3698  }
3699  return 0;
3700 }
3701 
3702 COMPAT53_API void lua_copy(lua_State* L, int from, int to) {
3703  int abs_to = lua_absindex(L, to);
3704  luaL_checkstack(L, 1, "not enough stack slots");
3705  lua_pushvalue(L, from);
3706  lua_replace(L, abs_to);
3707 }
3708 
3709 COMPAT53_API void lua_len(lua_State* L, int i) {
3710  switch (lua_type(L, i)) {
3711  case LUA_TSTRING:
3712  lua_pushnumber(L, (lua_Number)lua_objlen(L, i));
3713  break;
3714  case LUA_TTABLE:
3715  if (!luaL_callmeta(L, i, "__len"))
3716  lua_pushnumber(L, (lua_Number)lua_objlen(L, i));
3717  break;
3718  case LUA_TUSERDATA:
3719  if (luaL_callmeta(L, i, "__len"))
3720  break;
3721  /* FALLTHROUGH */
3722  default:
3723  luaL_error(L, "attempt to get length of a %s value", lua_typename(L, lua_type(L, i)));
3724  }
3725 }
3726 
3727 COMPAT53_API int lua_rawgetp(lua_State* L, int i, const void* p) {
3728  int abs_i = lua_absindex(L, i);
3729  lua_pushlightuserdata(L, (void*)p);
3730  lua_rawget(L, abs_i);
3731  return lua_type(L, -1);
3732 }
3733 
3734 COMPAT53_API void lua_rawsetp(lua_State* L, int i, const void* p) {
3735  int abs_i = lua_absindex(L, i);
3736  luaL_checkstack(L, 1, "not enough stack slots");
3737  lua_pushlightuserdata(L, (void*)p);
3738  lua_insert(L, -2);
3739  lua_rawset(L, abs_i);
3740 }
3741 
3742 COMPAT53_API lua_Number lua_tonumberx(lua_State* L, int i, int* isnum) {
3743  lua_Number n = lua_tonumber(L, i);
3744  if (isnum != NULL) {
3745  *isnum = (n != 0 || lua_isnumber(L, i));
3746  }
3747  return n;
3748 }
3749 
3750 COMPAT53_API void luaL_checkversion(lua_State* L) {
3751  (void)L;
3752 }
3753 
3754 COMPAT53_API void luaL_checkstack(lua_State* L, int sp, const char* msg) {
3755  if (!lua_checkstack(L, sp + LUA_MINSTACK)) {
3756  if (msg != NULL)
3757  luaL_error(L, "stack overflow (%s)", msg);
3758  else {
3759  lua_pushliteral(L, "stack overflow");
3760  lua_error(L);
3761  }
3762  }
3763 }
3764 
3765 COMPAT53_API int luaL_getsubtable(lua_State* L, int i, const char* name) {
3766  int abs_i = lua_absindex(L, i);
3767  luaL_checkstack(L, 3, "not enough stack slots");
3768  lua_pushstring(L, name);
3769  lua_gettable(L, abs_i);
3770  if (lua_istable(L, -1))
3771  return 1;
3772  lua_pop(L, 1);
3773  lua_newtable(L);
3774  lua_pushstring(L, name);
3775  lua_pushvalue(L, -2);
3776  lua_settable(L, abs_i);
3777  return 0;
3778 }
3779 
3780 COMPAT53_API lua_Integer luaL_len(lua_State* L, int i) {
3781  lua_Integer res = 0;
3782  int isnum = 0;
3783  luaL_checkstack(L, 1, "not enough stack slots");
3784  lua_len(L, i);
3785  res = lua_tointegerx(L, -1, &isnum);
3786  lua_pop(L, 1);
3787  if (!isnum)
3788  luaL_error(L, "object length is not an integer");
3789  return res;
3790 }
3791 
3792 COMPAT53_API void luaL_setfuncs(lua_State* L, const luaL_Reg* l, int nup) {
3793  luaL_checkstack(L, nup + 1, "too many upvalues");
3794  for (; l->name != NULL; l++) { /* fill the table with given functions */
3795  int i;
3796  lua_pushstring(L, l->name);
3797  for (i = 0; i < nup; i++) /* copy upvalues to the top */
3798  lua_pushvalue(L, -(nup + 1));
3799  lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */
3800  lua_settable(L, -(nup + 3)); /* table must be below the upvalues, the name and the closure */
3801  }
3802  lua_pop(L, nup); /* remove upvalues */
3803 }
3804 
3805 COMPAT53_API void luaL_setmetatable(lua_State* L, const char* tname) {
3806  luaL_checkstack(L, 1, "not enough stack slots");
3807  luaL_getmetatable(L, tname);
3808  lua_setmetatable(L, -2);
3809 }
3810 
3811 COMPAT53_API void* luaL_testudata(lua_State* L, int i, const char* tname) {
3812  void* p = lua_touserdata(L, i);
3813  luaL_checkstack(L, 2, "not enough stack slots");
3814  if (p == NULL || !lua_getmetatable(L, i))
3815  return NULL;
3816  else {
3817  int res = 0;
3818  luaL_getmetatable(L, tname);
3819  res = lua_rawequal(L, -1, -2);
3820  lua_pop(L, 2);
3821  if (!res)
3822  p = NULL;
3823  }
3824  return p;
3825 }
3826 
3827 static int compat53_countlevels(lua_State* L) {
3828  lua_Debug ar;
3829  int li = 1, le = 1;
3830  /* find an upper bound */
3831  while (lua_getstack(L, le, &ar)) {
3832  li = le;
3833  le *= 2;
3834  }
3835  /* do a binary search */
3836  while (li < le) {
3837  int m = (li + le) / 2;
3838  if (lua_getstack(L, m, &ar))
3839  li = m + 1;
3840  else
3841  le = m;
3842  }
3843  return le - 1;
3844 }
3845 
3846 static int compat53_findfield(lua_State* L, int objidx, int level) {
3847  if (level == 0 || !lua_istable(L, -1))
3848  return 0; /* not found */
3849  lua_pushnil(L); /* start 'next' loop */
3850  while (lua_next(L, -2)) { /* for each pair in table */
3851  if (lua_type(L, -2) == LUA_TSTRING) { /* ignore non-string keys */
3852  if (lua_rawequal(L, objidx, -1)) { /* found object? */
3853  lua_pop(L, 1); /* remove value (but keep name) */
3854  return 1;
3855  }
3856  else if (compat53_findfield(L, objidx, level - 1)) { /* try recursively */
3857  lua_remove(L, -2); /* remove table (but keep name) */
3858  lua_pushliteral(L, ".");
3859  lua_insert(L, -2); /* place '.' between the two names */
3860  lua_concat(L, 3);
3861  return 1;
3862  }
3863  }
3864  lua_pop(L, 1); /* remove value */
3865  }
3866  return 0; /* not found */
3867 }
3868 
3869 static int compat53_pushglobalfuncname(lua_State* L, lua_Debug* ar) {
3870  int top = lua_gettop(L);
3871  lua_getinfo(L, "f", ar); /* push function */
3872  lua_pushvalue(L, LUA_GLOBALSINDEX);
3873  if (compat53_findfield(L, top + 1, 2)) {
3874  lua_copy(L, -1, top + 1); /* move name to proper place */
3875  lua_pop(L, 2); /* remove pushed values */
3876  return 1;
3877  }
3878  else {
3879  lua_settop(L, top); /* remove function and global table */
3880  return 0;
3881  }
3882 }
3883 
3884 static void compat53_pushfuncname(lua_State* L, lua_Debug* ar) {
3885  if (*ar->namewhat != '\0') /* is there a name? */
3886  lua_pushfstring(L, "function " LUA_QS, ar->name);
3887  else if (*ar->what == 'm') /* main? */
3888  lua_pushliteral(L, "main chunk");
3889  else if (*ar->what == 'C') {
3890  if (compat53_pushglobalfuncname(L, ar)) {
3891  lua_pushfstring(L, "function " LUA_QS, lua_tostring(L, -1));
3892  lua_remove(L, -2); /* remove name */
3893  }
3894  else
3895  lua_pushliteral(L, "?");
3896  }
3897  else
3898  lua_pushfstring(L, "function <%s:%d>", ar->short_src, ar->linedefined);
3899 }
3900 
3901 #define COMPAT53_LEVELS1 12 /* size of the first part of the stack */
3902 #define COMPAT53_LEVELS2 10 /* size of the second part of the stack */
3903 
3904 COMPAT53_API void luaL_traceback(lua_State* L, lua_State* L1, const char* msg, int level) {
3905  lua_Debug ar;
3906  int top = lua_gettop(L);
3907  int numlevels = compat53_countlevels(L1);
3908  int mark = (numlevels > COMPAT53_LEVELS1 + COMPAT53_LEVELS2) ? COMPAT53_LEVELS1 : 0;
3909  if (msg)
3910  lua_pushfstring(L, "%s\n", msg);
3911  lua_pushliteral(L, "stack traceback:");
3912  while (lua_getstack(L1, level++, &ar)) {
3913  if (level == mark) { /* too many levels? */
3914  lua_pushliteral(L, "\n\t..."); /* add a '...' */
3915  level = numlevels - COMPAT53_LEVELS2; /* and skip to last ones */
3916  }
3917  else {
3918  lua_getinfo(L1, "Slnt", &ar);
3919  lua_pushfstring(L, "\n\t%s:", ar.short_src);
3920  if (ar.currentline > 0)
3921  lua_pushfstring(L, "%d:", ar.currentline);
3922  lua_pushliteral(L, " in ");
3923  compat53_pushfuncname(L, &ar);
3924  lua_concat(L, lua_gettop(L) - top);
3925  }
3926  }
3927  lua_concat(L, lua_gettop(L) - top);
3928 }
3929 
3930 COMPAT53_API int luaL_fileresult(lua_State* L, int stat, const char* fname) {
3931  const char* serr = NULL;
3932  int en = errno; /* calls to Lua API may change this value */
3933  char buf[512] = { 0 };
3934  if (stat) {
3935  lua_pushboolean(L, 1);
3936  return 1;
3937  }
3938  else {
3939  lua_pushnil(L);
3940  serr = compat53_strerror(en, buf, sizeof(buf));
3941  if (fname)
3942  lua_pushfstring(L, "%s: %s", fname, serr);
3943  else
3944  lua_pushstring(L, serr);
3945  lua_pushnumber(L, (lua_Number)en);
3946  return 3;
3947  }
3948 }
3949 
3950 static int compat53_checkmode(lua_State* L, const char* mode, const char* modename, int err) {
3951  if (mode && strchr(mode, modename[0]) == NULL) {
3952  lua_pushfstring(L, "attempt to load a %s chunk (mode is '%s')", modename, mode);
3953  return err;
3954  }
3955  return LUA_OK;
3956 }
3957 
3958 typedef struct {
3959  lua_Reader reader;
3960  void* ud;
3961  int has_peeked_data;
3962  const char* peeked_data;
3963  size_t peeked_data_size;
3964 } compat53_reader_data;
3965 
3966 static const char* compat53_reader(lua_State* L, void* ud, size_t* size) {
3967  compat53_reader_data* data = (compat53_reader_data*)ud;
3968  if (data->has_peeked_data) {
3969  data->has_peeked_data = 0;
3970  *size = data->peeked_data_size;
3971  return data->peeked_data;
3972  }
3973  else
3974  return data->reader(L, data->ud, size);
3975 }
3976 
3977 COMPAT53_API int lua_load(lua_State* L, lua_Reader reader, void* data, const char* source, const char* mode) {
3978  int status = LUA_OK;
3979  compat53_reader_data compat53_data = { reader, data, 1, 0, 0 };
3980  compat53_data.peeked_data = reader(L, data, &(compat53_data.peeked_data_size));
3981  if (compat53_data.peeked_data && compat53_data.peeked_data_size && compat53_data.peeked_data[0] == LUA_SIGNATURE[0]) /* binary file? */
3982  status = compat53_checkmode(L, mode, "binary", LUA_ERRSYNTAX);
3983  else
3984  status = compat53_checkmode(L, mode, "text", LUA_ERRSYNTAX);
3985  if (status != LUA_OK)
3986  return status;
3987  /* we need to call the original 5.1 version of lua_load! */
3988 #undef lua_load
3989  return lua_load(L, compat53_reader, &compat53_data, source);
3990 #define lua_load COMPAT53_CONCAT(COMPAT53_PREFIX, _load_53)
3991 }
3992 
3993 typedef struct {
3994  int n; /* number of pre-read characters */
3995  FILE* f; /* file being read */
3996  char buff[COMPAT53_LUA_FILE_BUFFER_SIZE]; /* area for reading file */
3997 } compat53_LoadF;
3998 
3999 static const char* compat53_getF(lua_State* L, void* ud, size_t* size) {
4000  compat53_LoadF* lf = (compat53_LoadF*)ud;
4001  (void)L; /* not used */
4002  if (lf->n > 0) { /* are there pre-read characters to be read? */
4003  *size = lf->n; /* return them (chars already in buffer) */
4004  lf->n = 0; /* no more pre-read characters */
4005  }
4006  else { /* read a block from file */
4007  /* 'fread' can return > 0 *and* set the EOF flag. If next call to
4008  'compat53_getF' called 'fread', it might still wait for user input.
4009  The next check avoids this problem. */
4010  if (feof(lf->f))
4011  return NULL;
4012  *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); /* read block */
4013  }
4014  return lf->buff;
4015 }
4016 
4017 static int compat53_errfile(lua_State* L, const char* what, int fnameindex) {
4018  char buf[512] = { 0 };
4019  const char* serr = compat53_strerror(errno, buf, sizeof(buf));
4020  const char* filename = lua_tostring(L, fnameindex) + 1;
4021  lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr);
4022  lua_remove(L, fnameindex);
4023  return LUA_ERRFILE;
4024 }
4025 
4026 static int compat53_skipBOM(compat53_LoadF* lf) {
4027  const char* p = "\xEF\xBB\xBF"; /* UTF-8 BOM mark */
4028  int c;
4029  lf->n = 0;
4030  do {
4031  c = getc(lf->f);
4032  if (c == EOF || c != *(const unsigned char*)p++)
4033  return c;
4034  lf->buff[lf->n++] = (char)c; /* to be read by the parser */
4035  } while (*p != '\0');
4036  lf->n = 0; /* prefix matched; discard it */
4037  return getc(lf->f); /* return next character */
4038 }
4039 
4040 /*
4041 ** reads the first character of file 'f' and skips an optional BOM mark
4042 ** in its beginning plus its first line if it starts with '#'. Returns
4043 ** true if it skipped the first line. In any case, '*cp' has the
4044 ** first "valid" character of the file (after the optional BOM and
4045 ** a first-line comment).
4046 */
4047 static int compat53_skipcomment(compat53_LoadF* lf, int* cp) {
4048  int c = *cp = compat53_skipBOM(lf);
4049  if (c == '#') { /* first line is a comment (Unix exec. file)? */
4050  do { /* skip first line */
4051  c = getc(lf->f);
4052  } while (c != EOF && c != '\n');
4053  *cp = getc(lf->f); /* skip end-of-line, if present */
4054  return 1; /* there was a comment */
4055  }
4056  else
4057  return 0; /* no comment */
4058 }
4059 
4060 COMPAT53_API int luaL_loadfilex(lua_State* L, const char* filename, const char* mode) {
4061  compat53_LoadF lf;
4062  int status, readstatus;
4063  int c;
4064  int fnameindex = lua_gettop(L) + 1; /* index of filename on the stack */
4065  if (filename == NULL) {
4066  lua_pushliteral(L, "=stdin");
4067  lf.f = stdin;
4068  }
4069  else {
4070  lua_pushfstring(L, "@%s", filename);
4071 #if defined(_MSC_VER)
4072  /* This code is here to stop a deprecation error that stops builds
4073  * if a certain macro is defined. While normally not caring would
4074  * be best, some header-only libraries and builds can't afford to
4075  * dictate this to the user. A quick check shows that fopen_s this
4076  * goes back to VS 2005, and _fsopen goes back to VS 2003 .NET,
4077  * possibly even before that so we don't need to do any version
4078  * number checks, since this has been there since forever. */
4079 
4080  /* TO USER: if you want the behavior of typical fopen_s/fopen,
4081  * which does lock the file on VC++, define the macro used below to 0 */
4082 #if COMPAT53_FOPEN_NO_LOCK
4083  lf.f = _fsopen(filename, "r", _SH_DENYNO); /* do not lock the file in any way */
4084  if (lf.f == NULL)
4085  return compat53_errfile(L, "open", fnameindex);
4086 #else /* use default locking version */
4087  if (fopen_s(&lf.f, filename, "r") != 0)
4088  return compat53_errfile(L, "open", fnameindex);
4089 #endif /* Locking vs. No-locking fopen variants */
4090 #else
4091  lf.f = fopen(filename, "r"); /* default stdlib doesn't forcefully lock files here */
4092  if (lf.f == NULL)
4093  return compat53_errfile(L, "open", fnameindex);
4094 #endif
4095  }
4096  if (compat53_skipcomment(&lf, &c)) /* read initial portion */
4097  lf.buff[lf.n++] = '\n'; /* add line to correct line numbers */
4098  if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */
4099 #if defined(_MSC_VER)
4100  if (freopen_s(&lf.f, filename, "rb", lf.f) != 0)
4101  return compat53_errfile(L, "reopen", fnameindex);
4102 #else
4103  lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */
4104  if (lf.f == NULL)
4105  return compat53_errfile(L, "reopen", fnameindex);
4106 #endif
4107  compat53_skipcomment(&lf, &c); /* re-read initial portion */
4108  }
4109  if (c != EOF)
4110  lf.buff[lf.n++] = (char)c; /* 'c' is the first character of the stream */
4111  status = lua_load(L, &compat53_getF, &lf, lua_tostring(L, -1), mode);
4112  readstatus = ferror(lf.f);
4113  if (filename)
4114  fclose(lf.f); /* close file (even in case of errors) */
4115  if (readstatus) {
4116  lua_settop(L, fnameindex); /* ignore results from 'lua_load' */
4117  return compat53_errfile(L, "read", fnameindex);
4118  }
4119  lua_remove(L, fnameindex);
4120  return status;
4121 }
4122 
4123 COMPAT53_API int luaL_loadbufferx(lua_State* L, const char* buff, size_t sz, const char* name, const char* mode) {
4124  int status = LUA_OK;
4125  if (sz > 0 && buff[0] == LUA_SIGNATURE[0]) {
4126  status = compat53_checkmode(L, mode, "binary", LUA_ERRSYNTAX);
4127  }
4128  else {
4129  status = compat53_checkmode(L, mode, "text", LUA_ERRSYNTAX);
4130  }
4131  if (status != LUA_OK)
4132  return status;
4133  return luaL_loadbuffer(L, buff, sz, name);
4134 }
4135 
4136 #if !defined(l_inspectstat) \
4137  && (defined(unix) || defined(__unix) || defined(__unix__) || defined(__TOS_AIX__) || defined(_SYSTYPE_BSD) || (defined(__APPLE__) && defined(__MACH__)))
4138 /* some form of unix; check feature macros in unistd.h for details */
4139 #include <unistd.h>
4140 /* check posix version; the relevant include files and macros probably
4141  * were available before 2001, but I'm not sure */
4142 #if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L
4143 #include <sys/wait.h>
4144 #define l_inspectstat(stat, what) \
4145  if (WIFEXITED(stat)) { \
4146  stat = WEXITSTATUS(stat); \
4147  } \
4148  else if (WIFSIGNALED(stat)) { \
4149  stat = WTERMSIG(stat); \
4150  what = "signal"; \
4151  }
4152 #endif
4153 #endif
4154 
4155 /* provide default (no-op) version */
4156 #if !defined(l_inspectstat)
4157 #define l_inspectstat(stat, what) ((void)0)
4158 #endif
4159 
4160 COMPAT53_API int luaL_execresult(lua_State* L, int stat) {
4161  const char* what = "exit";
4162  if (stat == -1)
4163  return luaL_fileresult(L, 0, NULL);
4164  else {
4165  l_inspectstat(stat, what);
4166  if (*what == 'e' && stat == 0)
4167  lua_pushboolean(L, 1);
4168  else
4169  lua_pushnil(L);
4170  lua_pushstring(L, what);
4171  lua_pushinteger(L, stat);
4172  return 3;
4173  }
4174 }
4175 
4176 COMPAT53_API void luaL_buffinit(lua_State* L, luaL_Buffer_53* B) {
4177  /* make it crash if used via pointer to a 5.1-style luaL_Buffer */
4178  B->b.p = NULL;
4179  B->b.L = NULL;
4180  B->b.lvl = 0;
4181  /* reuse the buffer from the 5.1-style luaL_Buffer though! */
4182  B->ptr = B->b.buffer;
4183  B->capacity = LUAL_BUFFERSIZE;
4184  B->nelems = 0;
4185  B->L2 = L;
4186 }
4187 
4188 COMPAT53_API char* luaL_prepbuffsize(luaL_Buffer_53* B, size_t s) {
4189  if (B->capacity - B->nelems < s) { /* needs to grow */
4190  char* newptr = NULL;
4191  size_t newcap = B->capacity * 2;
4192  if (newcap - B->nelems < s)
4193  newcap = B->nelems + s;
4194  if (newcap < B->capacity) /* overflow */
4195  luaL_error(B->L2, "buffer too large");
4196 #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 504
4197  newptr = (char*)lua_newuserdatauv(B->L2, newcap, 0);
4198 #else
4199  newptr = (char*)lua_newuserdata(B->L2, newcap);
4200 #endif
4201  memcpy(newptr, B->ptr, B->nelems);
4202  if (B->ptr != B->b.buffer)
4203  lua_replace(B->L2, -2); /* remove old buffer */
4204  B->ptr = newptr;
4205  B->capacity = newcap;
4206  }
4207  return B->ptr + B->nelems;
4208 }
4209 
4210 COMPAT53_API void luaL_addlstring(luaL_Buffer_53* B, const char* s, size_t l) {
4211  memcpy(luaL_prepbuffsize(B, l), s, l);
4212  luaL_addsize(B, l);
4213 }
4214 
4215 COMPAT53_API void luaL_addvalue(luaL_Buffer_53* B) {
4216  size_t len = 0;
4217  const char* s = lua_tolstring(B->L2, -1, &len);
4218  if (!s)
4219  luaL_error(B->L2, "cannot convert value to string");
4220  if (B->ptr != B->b.buffer)
4221  lua_insert(B->L2, -2); /* userdata buffer must be at stack top */
4222  luaL_addlstring(B, s, len);
4223  lua_remove(B->L2, B->ptr != B->b.buffer ? -2 : -1);
4224 }
4225 
4226 void luaL_pushresult(luaL_Buffer_53* B) {
4227  lua_pushlstring(B->L2, B->ptr, B->nelems);
4228  if (B->ptr != B->b.buffer)
4229  lua_replace(B->L2, -2); /* remove userdata buffer */
4230 }
4231 
4232 #endif /* Lua 5.1 */
4233 
4234 /* definitions for Lua 5.1 and Lua 5.2 */
4235 #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM <= 502
4236 
4237 COMPAT53_API int lua_geti(lua_State* L, int index, lua_Integer i) {
4238  index = lua_absindex(L, index);
4239  lua_pushinteger(L, i);
4240  lua_gettable(L, index);
4241  return lua_type(L, -1);
4242 }
4243 
4244 COMPAT53_API int lua_isinteger(lua_State* L, int index) {
4245  if (lua_type(L, index) == LUA_TNUMBER) {
4246  lua_Number n = lua_tonumber(L, index);
4247  lua_Integer i = lua_tointeger(L, index);
4248  if (i == n)
4249  return 1;
4250  }
4251  return 0;
4252 }
4253 
4254 COMPAT53_API lua_Integer lua_tointegerx(lua_State* L, int i, int* isnum) {
4255  int ok = 0;
4256  lua_Number n = lua_tonumberx(L, i, &ok);
4257  if (ok) {
4258  if (n == (lua_Integer)n) {
4259  if (isnum)
4260  *isnum = 1;
4261  return (lua_Integer)n;
4262  }
4263  }
4264  if (isnum)
4265  *isnum = 0;
4266  return 0;
4267 }
4268 
4269 static void compat53_reverse(lua_State* L, int a, int b) {
4270  for (; a < b; ++a, --b) {
4271  lua_pushvalue(L, a);
4272  lua_pushvalue(L, b);
4273  lua_replace(L, a);
4274  lua_replace(L, b);
4275  }
4276 }
4277 
4278 COMPAT53_API void lua_rotate(lua_State* L, int idx, int n) {
4279  int n_elems = 0;
4280  idx = lua_absindex(L, idx);
4281  n_elems = lua_gettop(L) - idx + 1;
4282  if (n < 0)
4283  n += n_elems;
4284  if (n > 0 && n < n_elems) {
4285  luaL_checkstack(L, 2, "not enough stack slots available");
4286  n = n_elems - n;
4287  compat53_reverse(L, idx, idx + n - 1);
4288  compat53_reverse(L, idx + n, idx + n_elems - 1);
4289  compat53_reverse(L, idx, idx + n_elems - 1);
4290  }
4291 }
4292 
4293 COMPAT53_API void lua_seti(lua_State* L, int index, lua_Integer i) {
4294  luaL_checkstack(L, 1, "not enough stack slots available");
4295  index = lua_absindex(L, index);
4296  lua_pushinteger(L, i);
4297  lua_insert(L, -2);
4298  lua_settable(L, index);
4299 }
4300 
4301 #if !defined(lua_str2number)
4302 #define lua_str2number(s, p) strtod((s), (p))
4303 #endif
4304 
4305 COMPAT53_API size_t lua_stringtonumber(lua_State* L, const char* s) {
4306  char* endptr;
4307  lua_Number n = lua_str2number(s, &endptr);
4308  if (endptr != s) {
4309  while (*endptr != '\0' && isspace((unsigned char)*endptr))
4310  ++endptr;
4311  if (*endptr == '\0') {
4312  lua_pushnumber(L, n);
4313  return endptr - s + 1;
4314  }
4315  }
4316  return 0;
4317 }
4318 
4319 COMPAT53_API const char* luaL_tolstring(lua_State* L, int idx, size_t* len) {
4320  if (!luaL_callmeta(L, idx, "__tostring")) {
4321  int t = lua_type(L, idx), tt = 0;
4322  char const* name = NULL;
4323  switch (t) {
4324  case LUA_TNIL:
4325  lua_pushliteral(L, "nil");
4326  break;
4327  case LUA_TSTRING:
4328  case LUA_TNUMBER:
4329  lua_pushvalue(L, idx);
4330  break;
4331  case LUA_TBOOLEAN:
4332  if (lua_toboolean(L, idx))
4333  lua_pushliteral(L, "true");
4334  else
4335  lua_pushliteral(L, "false");
4336  break;
4337  default:
4338  tt = luaL_getmetafield(L, idx, "__name");
4339  name = (tt == LUA_TSTRING) ? lua_tostring(L, -1) : lua_typename(L, t);
4340  lua_pushfstring(L, "%s: %p", name, lua_topointer(L, idx));
4341  if (tt != LUA_TNIL)
4342  lua_replace(L, -2);
4343  break;
4344  }
4345  }
4346  else {
4347  if (!lua_isstring(L, -1))
4348  luaL_error(L, "'__tostring' must return a string");
4349  }
4350  return lua_tolstring(L, -1, len);
4351 }
4352 
4353 COMPAT53_API void luaL_requiref(lua_State* L, const char* modname, lua_CFunction openf, int glb) {
4354  luaL_checkstack(L, 3, "not enough stack slots available");
4355  luaL_getsubtable(L, LUA_REGISTRYINDEX, "_LOADED");
4356  if (lua_getfield(L, -1, modname) == LUA_TNIL) {
4357  lua_pop(L, 1);
4358  lua_pushcfunction(L, openf);
4359  lua_pushstring(L, modname);
4360  lua_call(L, 1, 1);
4361  lua_pushvalue(L, -1);
4362  lua_setfield(L, -3, modname);
4363  }
4364  if (glb) {
4365  lua_pushvalue(L, -1);
4366  lua_setglobal(L, modname);
4367  }
4368  lua_replace(L, -2);
4369 }
4370 
4371 #endif /* Lua 5.1 and 5.2 */
4372 
4373 #endif /* KEPLER_PROJECT_COMPAT53_C_ */
4374 
4375 /*********************************************************************
4376  * This file contains parts of Lua 5.2's and Lua 5.3's source code:
4377  *
4378  * Copyright (C) 1994-2014 Lua.org, PUC-Rio.
4379  *
4380  * Permission is hereby granted, free of charge, to any person obtaining
4381  * a copy of this software and associated documentation files (the
4382  * "Software"), to deal in the Software without restriction, including
4383  * without limitation the rights to use, copy, modify, merge, publish,
4384  * distribute, sublicense, and/or sell copies of the Software, and to
4385  * permit persons to whom the Software is furnished to do so, subject to
4386  * the following conditions:
4387  *
4388  * The above copyright notice and this permission notice shall be
4389  * included in all copies or substantial portions of the Software.
4390  *
4391  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
4392  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
4393  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
4394  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
4395  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
4396  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
4397  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4398  *********************************************************************/
4399 // end of sol/compatibility/compat-5.3.c.h
4400 
4401 #endif
4402 
4403 #endif /* KEPLER_PROJECT_COMPAT53_H_ */
4404 
4405 // end of sol/compatibility/compat-5.3.h
4406 
4407 // beginning of sol/compatibility/compat-5.4.h
4408 
4409 #ifndef NOT_KEPLER_PROJECT_COMPAT54_H_
4410 #define NOT_KEPLER_PROJECT_COMPAT54_H_
4411 
4412 #if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP)
4413 extern "C" {
4414 #endif
4415 #include <lua.h>
4416 #include <lauxlib.h>
4417 #include <lualib.h>
4418 #if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP)
4419 }
4420 #endif
4421 
4422 #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 504
4423 
4424 #if !defined(LUA_ERRGCMM)
4425 /* So Lua 5.4 actually removes this, which breaks sol2...
4426  man, this API is quite unstable...!
4427 */
4428 # define LUA_ERRGCMM (LUA_ERRERR + 2)
4429 #endif /* LUA_ERRGCMM define */
4430 
4431 #endif // Lua 5.4 only
4432 
4433 #endif // NOT_KEPLER_PROJECT_COMPAT54_H_// end of sol/compatibility/compat-5.4.h
4434 
4435 #endif
4436 
4437 // end of sol/compatibility.hpp
4438 
4439 #include <vector>
4440 #include <cstdint>
4441 #include <cstddef>
4442 
4443 namespace sol {
4444 
4445  template <typename Allocator = std::allocator<std::byte>>
4446  class basic_bytecode : private std::vector<std::byte, Allocator> {
4447  private:
4448  using base_t = std::vector<std::byte, Allocator>;
4449 
4450  public:
4451  using typename base_t::allocator_type;
4452  using typename base_t::const_iterator;
4453  using typename base_t::const_pointer;
4454  using typename base_t::const_reference;
4455  using typename base_t::const_reverse_iterator;
4456  using typename base_t::difference_type;
4457  using typename base_t::iterator;
4458  using typename base_t::pointer;
4459  using typename base_t::reference;
4460  using typename base_t::reverse_iterator;
4461  using typename base_t::size_type;
4462  using typename base_t::value_type;
4463 
4464  using base_t::base_t;
4465  using base_t::operator=;
4466 
4467  using base_t::data;
4468  using base_t::empty;
4469  using base_t::max_size;
4470  using base_t::size;
4471 
4472  using base_t::at;
4473  using base_t::operator[];
4474  using base_t::back;
4475  using base_t::front;
4476 
4477  using base_t::begin;
4478  using base_t::cbegin;
4479  using base_t::cend;
4480  using base_t::end;
4481 
4482  using base_t::crbegin;
4483  using base_t::crend;
4484  using base_t::rbegin;
4485  using base_t::rend;
4486 
4487  using base_t::get_allocator;
4488  using base_t::swap;
4489 
4490  using base_t::clear;
4491  using base_t::emplace;
4492  using base_t::emplace_back;
4493  using base_t::erase;
4494  using base_t::insert;
4495  using base_t::pop_back;
4496  using base_t::push_back;
4497  using base_t::reserve;
4498  using base_t::resize;
4499  using base_t::shrink_to_fit;
4500 
4502  return string_view(reinterpret_cast<const char*>(this->data()), this->size());
4503  }
4504  };
4505 
4506  template <typename Container>
4507  inline int basic_insert_dump_writer(lua_State*, const void* memory, size_t memory_size, void* userdata_pointer) {
4508  using storage_t = Container;
4509  const std::byte* p_code = static_cast<const std::byte*>(memory);
4510  storage_t& bc = *static_cast<storage_t*>(userdata_pointer);
4511 #if SOL_IS_OFF(SOL_EXCEPTIONS)
4512  bc.insert(bc.cend(), p_code, p_code + memory_size);
4513 #else
4514  try {
4515  bc.insert(bc.cend(), p_code, p_code + memory_size);
4516  }
4517  catch (...) {
4518  return -1;
4519  }
4520 #endif
4521  return 0;
4522  }
4523 
4525 
4526  constexpr inline auto bytecode_dump_writer = &basic_insert_dump_writer<bytecode>;
4527 
4528 } // namespace sol
4529 
4530 // end of sol/bytecode.hpp
4531 
4532 // beginning of sol/stack.hpp
4533 
4534 // beginning of sol/trampoline.hpp
4535 
4536 // beginning of sol/types.hpp
4537 
4538 // beginning of sol/error.hpp
4539 
4540 #include <stdexcept>
4541 #include <string>
4542 #include <array>
4543 
4544 namespace sol {
4545  namespace detail {
4546  struct direct_error_tag { };
4548 
4549  struct error_result {
4550  int results;
4551  const char* format_string;
4552  std::array<const char*, 4> argument_strings;
4553 
4555  }
4556 
4557  error_result(int results_) : results(results_), format_string(nullptr) {
4558  }
4559 
4560  error_result(const char* format_string_, const char* first_message_) : results(0), format_string(format_string_), argument_strings() {
4561  argument_strings[0] = first_message_;
4562  }
4563  };
4564 
4565  inline int handle_errors(lua_State* L, const error_result& er) {
4566  if (er.format_string == nullptr) {
4567  return er.results;
4568  }
4570  }
4571  } // namespace detail
4572 
4573  class error : public std::runtime_error {
4574  private:
4575  // Because VC++ is upsetting, most of the time!
4576  std::string what_reason;
4577 
4578  public:
4579  error(const std::string& str) : error(detail::direct_error, "lua: error: " + str) {
4580  }
4581  error(std::string&& str) : error(detail::direct_error, "lua: error: " + std::move(str)) {
4582  }
4583  error(detail::direct_error_tag, const std::string& str) : std::runtime_error(""), what_reason(str) {
4584  }
4585  error(detail::direct_error_tag, std::string&& str) : std::runtime_error(""), what_reason(std::move(str)) {
4586  }
4587 
4588  error(const error& e) = default;
4589  error(error&& e) = default;
4590  error& operator=(const error& e) = default;
4591  error& operator=(error&& e) = default;
4592 
4593  virtual const char* what() const noexcept override {
4594  return what_reason.c_str();
4595  }
4596  };
4597 
4598 } // namespace sol
4599 
4600 // end of sol/error.hpp
4601 
4602 // beginning of sol/optional.hpp
4603 
4604 // beginning of sol/in_place.hpp
4605 
4606 #include <cstddef>
4607 #include <utility>
4608 
4609 namespace sol {
4610 
4614 
4615  template <typename T>
4616  using in_place_type_t = std::in_place_type_t<T>;
4617  template <typename T>
4618  constexpr std::in_place_type_t<T> in_place_type {};
4619 
4620  template <size_t I>
4621  using in_place_index_t = std::in_place_index_t<I>;
4622  template <size_t I>
4624 
4625 } // namespace sol
4626 
4627 // end of sol/in_place.hpp
4628 
4629 #if SOL_IS_ON(SOL_USE_BOOST)
4630 #include <boost/optional.hpp>
4631 #else
4632 // beginning of sol/optional_implementation.hpp
4633 
4634 #define SOL_TL_OPTIONAL_VERSION_MAJOR 0
4635 #define SOL_TL_OPTIONAL_VERSION_MINOR 5
4636 
4637 #include <exception>
4638 #include <functional>
4639 #include <new>
4640 #include <type_traits>
4641 #include <utility>
4642 #include <cstdlib>
4643 #include <optional>
4644 
4645 #if (defined(_MSC_VER) && _MSC_VER == 1900)
4646 #define SOL_TL_OPTIONAL_MSVC2015
4647 #endif
4648 
4649 #if (defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 9 && !defined(__clang__))
4650 #define SOL_TL_OPTIONAL_GCC49
4651 #endif
4652 
4653 #if (defined(__GNUC__) && __GNUC__ == 5 && __GNUC_MINOR__ <= 4 && !defined(__clang__))
4654 #define SOL_TL_OPTIONAL_GCC54
4655 #endif
4656 
4657 #if (defined(__GNUC__) && __GNUC__ == 5 && __GNUC_MINOR__ <= 5 && !defined(__clang__))
4658 #define SOL_TL_OPTIONAL_GCC55
4659 #endif
4660 
4661 #if (defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 9 && !defined(__clang__))
4662 #define SOL_TL_OPTIONAL_NO_CONSTRR
4663 
4664 #define SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) std::has_trivial_copy_constructor<T>::value
4665 #define SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(T) std::has_trivial_copy_assign<T>::value
4666 
4667 #define SOL_TL_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE(T) std::is_trivially_destructible<T>::value
4668 
4669 #elif (defined(__GNUC__) && __GNUC__ < 8 && !defined(__clang__))
4670 #ifndef SOL_TL_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX
4671 #define SOL_TL_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX
4672 namespace sol { namespace detail {
4673  template <class T>
4674  struct is_trivially_copy_constructible : std::is_trivially_copy_constructible<T> { };
4675 #ifdef _GLIBCXX_VECTOR
4676  template <class T, class A>
4677  struct is_trivially_copy_constructible<std::vector<T, A>> : std::is_trivially_copy_constructible<T> { };
4678 #endif
4679 }} // namespace sol::detail
4680 #endif
4681 
4682 #define SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) sol::detail::is_trivially_copy_constructible<T>::value
4683 #define SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(T) std::is_trivially_copy_assignable<T>::value
4684 #define SOL_TL_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE(T) std::is_trivially_destructible<T>::value
4685 #else
4686 #define SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) std::is_trivially_copy_constructible<T>::value
4687 #define SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(T) std::is_trivially_copy_assignable<T>::value
4688 #define SOL_TL_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE(T) std::is_trivially_destructible<T>::value
4689 #endif
4690 
4691 #if __cplusplus > 201103L
4692 #define SOL_TL_OPTIONAL_CXX14
4693 #endif
4694 
4695 #if (__cplusplus == 201103L || defined(SOL_TL_OPTIONAL_MSVC2015) || defined(SOL_TL_OPTIONAL_GCC49))
4696 #define SOL_TL_OPTIONAL_11_CONSTEXPR
4697 #else
4698 #define SOL_TL_OPTIONAL_11_CONSTEXPR constexpr
4700 #endif
4701 
4702 namespace sol {
4703 #ifndef SOL_TL_MONOSTATE_INPLACE_MUTEX
4704 #define SOL_TL_MONOSTATE_INPLACE_MUTEX
4705  class monostate { };
4707 #endif
4708 
4709  template <class T>
4710  class optional;
4711 
4713  namespace detail {
4714 #ifndef SOL_TL_TRAITS_MUTEX
4715 #define SOL_TL_TRAITS_MUTEX
4716  // C++14-style aliases for brevity
4717  template <class T>
4719  template <class T>
4721  template <class T>
4722  using decay_t = typename std::decay<T>::type;
4723  template <bool E, class T = void>
4725  template <bool B, class T, class F>
4727 
4728  // std::conjunction from C++17
4729  template <class...>
4731  template <class B>
4732  struct conjunction<B> : B { };
4733  template <class B, class... Bs>
4734  struct conjunction<B, Bs...> : std::conditional<bool(B::value), conjunction<Bs...>, B>::type { };
4735 
4736 #if defined(_LIBCPP_VERSION) && __cplusplus == 201103L
4737 #define SOL_TL_OPTIONAL_LIBCXX_MEM_FN_WORKAROUND
4738 #endif
4739 
4740 #ifdef SOL_TL_OPTIONAL_LIBCXX_MEM_FN_WORKAROUND
4741  template <class T>
4742  struct is_pointer_to_non_const_member_func : std::false_type { };
4743  template <class T, class Ret, class... Args>
4744  struct is_pointer_to_non_const_member_func<Ret (T::*)(Args...)> : std::true_type { };
4745  template <class T, class Ret, class... Args>
4746  struct is_pointer_to_non_const_member_func<Ret (T::*)(Args...)&> : std::true_type { };
4747  template <class T, class Ret, class... Args>
4748  struct is_pointer_to_non_const_member_func<Ret (T::*)(Args...) &&> : std::true_type { };
4749  template <class T, class Ret, class... Args>
4750  struct is_pointer_to_non_const_member_func<Ret (T::*)(Args...) volatile> : std::true_type { };
4751  template <class T, class Ret, class... Args>
4752  struct is_pointer_to_non_const_member_func<Ret (T::*)(Args...) volatile&> : std::true_type { };
4753  template <class T, class Ret, class... Args>
4754  struct is_pointer_to_non_const_member_func<Ret (T::*)(Args...) volatile&&> : std::true_type { };
4755 
4756  template <class T>
4757  struct is_const_or_const_ref : std::false_type { };
4758  template <class T>
4759  struct is_const_or_const_ref<T const&> : std::true_type { };
4760  template <class T>
4761  struct is_const_or_const_ref<T const> : std::true_type { };
4762 #endif
4763 
4764  // std::invoke from C++17
4765  // https://stackoverflow.com/questions/38288042/c11-14-invoke-workaround
4766  template <typename Fn, typename... Args,
4767 #ifdef SOL_TL_OPTIONAL_LIBCXX_MEM_FN_WORKAROUND
4768  typename = enable_if_t<!(is_pointer_to_non_const_member_func<Fn>::value && is_const_or_const_ref<Args...>::value)>,
4769 #endif
4770  typename = enable_if_t<std::is_member_pointer<decay_t<Fn>>::value>, int = 0>
4771  constexpr auto invoke(Fn&& f, Args&&... args) noexcept(noexcept(std::mem_fn(f)(std::forward<Args>(args)...)))
4772  -> decltype(std::mem_fn(f)(std::forward<Args>(args)...)) {
4773  return std::mem_fn(f)(std::forward<Args>(args)...);
4774  }
4775 
4776  template <typename Fn, typename... Args, typename = enable_if_t<!std::is_member_pointer<decay_t<Fn>>::value>>
4777  constexpr auto invoke(Fn&& f, Args&&... args) noexcept(noexcept(std::forward<Fn>(f)(std::forward<Args>(args)...)))
4778  -> decltype(std::forward<Fn>(f)(std::forward<Args>(args)...)) {
4779  return std::forward<Fn>(f)(std::forward<Args>(args)...);
4780  }
4781 
4782  // std::invoke_result from C++17
4783  template <class F, class, class... Us>
4785 
4786  template <class F, class... Us>
4787  struct invoke_result_impl<F, decltype(detail::invoke(std::declval<F>(), std::declval<Us>()...), void()), Us...> {
4788  using type = decltype(detail::invoke(std::declval<F>(), std::declval<Us>()...));
4789  };
4790 
4791  template <class F, class... Us>
4793 
4794  template <class F, class... Us>
4795  using invoke_result_t = typename invoke_result<F, Us...>::type;
4796 #endif
4797 
4798  // std::void_t from C++17
4799  template <class...>
4800  struct voider {
4801  using type = void;
4802  };
4803  template <class... Ts>
4804  using void_t = typename voider<Ts...>::type;
4805 
4806  // Trait for checking if a type is a sol::optional
4807  template <class T>
4809  template <class T>
4811  template <class T>
4813 
4814  // Change void to sol::monostate
4815  template <class U>
4817 
4818  template <class F, class U, class = invoke_result_t<F, U>>
4820 
4821  // Check if invoking F for some Us returns void
4822  template <class F, class = void, class... U>
4824  template <class F, class... U>
4825  struct returns_void_impl<F, void_t<invoke_result_t<F, U...>>, U...> : std::is_void<invoke_result_t<F, U...>> { };
4826  template <class F, class... U>
4828 
4829  template <class T, class... U>
4830  using enable_if_ret_void = enable_if_t<returns_void<T&&, U...>::value>;
4831 
4832  template <class T, class... U>
4833  using disable_if_ret_void = enable_if_t<!returns_void<T&&, U...>::value>;
4834 
4835  template <class T, class U>
4836  using enable_forward_value = detail::enable_if_t<std::is_constructible<T, U&&>::value && !std::is_same<detail::decay_t<U>, in_place_t>::value
4837  && !std::is_same<optional<T>, detail::decay_t<U>>::value>;
4838 
4839  template <class T, class U, class Other>
4840  using enable_from_other = detail::enable_if_t<std::is_constructible<T, Other>::value && !std::is_constructible<T, optional<U>&>::value
4841  && !std::is_constructible<T, optional<U>&&>::value && !std::is_constructible<T, const optional<U>&>::value
4842  && !std::is_constructible<T, const optional<U>&&>::value && !std::is_convertible<optional<U>&, T>::value
4843  && !std::is_convertible<optional<U>&&, T>::value && !std::is_convertible<const optional<U>&, T>::value
4844  && !std::is_convertible<const optional<U>&&, T>::value>;
4845 
4846  template <class T, class U>
4848  && !detail::conjunction<std::is_scalar<T>, std::is_same<T, detail::decay_t<U>>>::value && std::is_constructible<T, U>::value
4849  && std::is_assignable<T&, U>::value>;
4850 
4851  template <class T, class U, class Other>
4852  using enable_assign_from_other = detail::enable_if_t<std::is_constructible<T, Other>::value && std::is_assignable<T&, Other>::value
4853  && !std::is_constructible<T, optional<U>&>::value && !std::is_constructible<T, optional<U>&&>::value
4854  && !std::is_constructible<T, const optional<U>&>::value && !std::is_constructible<T, const optional<U>&&>::value
4855  && !std::is_convertible<optional<U>&, T>::value && !std::is_convertible<optional<U>&&, T>::value
4856  && !std::is_convertible<const optional<U>&, T>::value && !std::is_convertible<const optional<U>&&, T>::value
4857  && !std::is_assignable<T&, optional<U>&>::value && !std::is_assignable<T&, optional<U>&&>::value
4858  && !std::is_assignable<T&, const optional<U>&>::value && !std::is_assignable<T&, const optional<U>&&>::value>;
4859 
4860 #ifdef _MSC_VER
4861  // TODO make a version which works with MSVC
4862  template <class T, class U = T>
4863  struct is_swappable : std::true_type { };
4864 
4865  template <class T, class U = T>
4866  struct is_nothrow_swappable : std::true_type { };
4867 #else
4868  // https://stackoverflow.com/questions/26744589/what-is-a-proper-way-to-implement-is-swappable-to-test-for-the-swappable-concept
4869  namespace swap_adl_tests {
4870  // if swap ADL finds this then it would call std::swap otherwise (same
4871  // signature)
4872  struct tag { };
4873 
4874  template <class T>
4875  tag swap(T&, T&);
4876  template <class T, std::size_t N>
4877  tag swap(T (&a)[N], T (&b)[N]);
4878 
4879  // helper functions to test if an unqualified swap is possible, and if it
4880  // becomes std::swap
4881  template <class, class>
4882  std::false_type can_swap(...) noexcept(false);
4883  template <class T, class U, class = decltype(swap(std::declval<T&>(), std::declval<U&>()))>
4884  std::true_type can_swap(int) noexcept(noexcept(swap(std::declval<T&>(), std::declval<U&>())));
4885 
4886  template <class, class>
4887  std::false_type uses_std(...);
4888  template <class T, class U>
4889  std::is_same<decltype(swap(std::declval<T&>(), std::declval<U&>())), tag> uses_std(int);
4890 
4891  template <class T>
4893  : std::integral_constant<bool, std::is_nothrow_move_constructible<T>::value && std::is_nothrow_move_assignable<T>::value> { };
4894 
4895  template <class T, std::size_t N>
4897 
4898  template <class T, class U>
4899  struct is_adl_swap_noexcept : std::integral_constant<bool, noexcept(can_swap<T, U>(0))> { };
4900  } // namespace swap_adl_tests
4901 
4902  template <class T, class U = T>
4903  struct is_swappable : std::integral_constant<bool,
4904  decltype(detail::swap_adl_tests::can_swap<T, U>(0))::value
4905  && (!decltype(detail::swap_adl_tests::uses_std<T, U>(0))::value
4906  || (std::is_move_assignable<T>::value && std::is_move_constructible<T>::value))> { };
4907 
4908  template <class T, std::size_t N>
4909  struct is_swappable<T[N], T[N]> : std::integral_constant<bool,
4910  decltype(detail::swap_adl_tests::can_swap<T[N], T[N]>(0))::value
4911  && (!decltype(detail::swap_adl_tests::uses_std<T[N], T[N]>(0))::value || is_swappable<T, T>::value)> { };
4912 
4913  template <class T, class U = T>
4915  : std::integral_constant<bool,
4916  is_swappable<T, U>::value
4917  && ((decltype(detail::swap_adl_tests::uses_std<T, U>(0))::value&& detail::swap_adl_tests::is_std_swap_noexcept<T>::value)
4918  || (!decltype(detail::swap_adl_tests::uses_std<T, U>(0))::value&& detail::swap_adl_tests::is_adl_swap_noexcept<T, U>::value))> { };
4919 #endif
4920 
4921  // The storage base manages the actual storage, and correctly propagates
4922  // trivial destroyion from T. This case is for when T is not trivially
4923  // destructible.
4924  template <class T, bool = ::std::is_trivially_destructible<T>::value>
4926  SOL_TL_OPTIONAL_11_CONSTEXPR optional_storage_base() noexcept : m_dummy(), m_has_value(false) {
4927  }
4928 
4929  template <class... U>
4930  SOL_TL_OPTIONAL_11_CONSTEXPR optional_storage_base(in_place_t, U&&... u) : m_value(std::forward<U>(u)...), m_has_value(true) {
4931  }
4932 
4934  if (m_has_value) {
4935  m_value.~T();
4936  m_has_value = false;
4937  }
4938  }
4939 
4940  struct dummy { };
4941  union {
4944  };
4945 
4947  };
4948 
4949  // This case is for when T is trivially destructible.
4950  template <class T>
4951  struct optional_storage_base<T, true> {
4952  SOL_TL_OPTIONAL_11_CONSTEXPR optional_storage_base() noexcept : m_dummy(), m_has_value(false) {
4953  }
4954 
4955  template <class... U>
4956  SOL_TL_OPTIONAL_11_CONSTEXPR optional_storage_base(in_place_t, U&&... u) : m_value(std::forward<U>(u)...), m_has_value(true) {
4957  }
4958 
4959  // No destructor, so this class is trivially destructible
4960 
4961  struct dummy { };
4962  union {
4965  };
4966 
4967  bool m_has_value = false;
4968  };
4969 
4970  // This base class provides some handy member functions which can be used in
4971  // further derived classes
4972  template <class T>
4975 
4976  void hard_reset() noexcept {
4977  get().~T();
4978  this->m_has_value = false;
4979  }
4980 
4981  template <class... Args>
4982  void construct(Args&&... args) noexcept {
4983  new (std::addressof(this->m_value)) T(std::forward<Args>(args)...);
4984  this->m_has_value = true;
4985  }
4986 
4987  template <class Opt>
4988  void assign(Opt&& rhs) {
4989  if (this->has_value()) {
4990  if (rhs.has_value()) {
4991  this->m_value = std::forward<Opt>(rhs).get();
4992  }
4993  else {
4994  this->m_value.~T();
4995  this->m_has_value = false;
4996  }
4997  }
4998 
4999  else if (rhs.has_value()) {
5000  construct(std::forward<Opt>(rhs).get());
5001  }
5002  }
5003 
5004  bool has_value() const {
5005  return this->m_has_value;
5006  }
5007 
5009  return this->m_value;
5010  }
5011  SOL_TL_OPTIONAL_11_CONSTEXPR const T& get() const& {
5012  return this->m_value;
5013  }
5015  return std::move(this->m_value);
5016  }
5017 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR
5018  constexpr const T&& get() const&& {
5019  return std::move(this->m_value);
5020  }
5021 #endif
5022  };
5023 
5024  // This class manages conditionally having a trivial copy constructor
5025  // This specialization is for when T is trivially copy constructible
5026  template <class T, bool = SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T)>
5029  };
5030 
5031  // This specialization is for when T is not trivially copy constructible
5032  template <class T>
5035 
5036  using base_t::base_t;
5037 
5038  optional_copy_base() = default;
5040  if (rhs.has_value()) {
5041  this->construct(rhs.get());
5042  }
5043  else {
5044  this->m_has_value = false;
5045  }
5046  }
5047 
5048  optional_copy_base(optional_copy_base&& rhs) = default;
5049  optional_copy_base& operator=(const optional_copy_base& rhs) = default;
5050  optional_copy_base& operator=(optional_copy_base&& rhs) = default;
5051  };
5052 
5053 #ifndef SOL_TL_OPTIONAL_GCC49
5054  template <class T, bool = std::is_trivially_move_constructible<T>::value>
5057  };
5058 #else
5059  template <class T, bool = false>
5060  struct optional_move_base;
5061 #endif
5062  template <class T>
5063  struct optional_move_base<T, false> : optional_copy_base<T> {
5065 
5066  optional_move_base() = default;
5067  optional_move_base(const optional_move_base& rhs) = default;
5068 
5069  optional_move_base(optional_move_base&& rhs) noexcept(std::is_nothrow_move_constructible<T>::value) {
5070  if (rhs.has_value()) {
5071  this->construct(std::move(rhs.get()));
5072  }
5073  else {
5074  this->m_has_value = false;
5075  }
5076  }
5077  optional_move_base& operator=(const optional_move_base& rhs) = default;
5078  optional_move_base& operator=(optional_move_base&& rhs) = default;
5079  };
5080 
5081  // This class manages conditionally having a trivial copy assignment operator
5082  template <class T,
5087  };
5088 
5089  template <class T>
5092 
5093  optional_copy_assign_base() = default;
5095 
5098  this->assign(rhs);
5099  return *this;
5100  }
5101  optional_copy_assign_base& operator=(optional_copy_assign_base&& rhs) = default;
5102  };
5103 
5104 #ifndef SOL_TL_OPTIONAL_GCC49
5105  template <class T,
5106  bool = std::is_trivially_destructible<T>::value&& std::is_trivially_move_constructible<T>::value&& std::is_trivially_move_assignable<T>::value>
5109  };
5110 #else
5111  template <class T, bool = false>
5113 #endif
5114 
5115  template <class T>
5118 
5119  optional_move_assign_base() = default;
5121 
5123 
5124  optional_move_assign_base& operator=(const optional_move_assign_base& rhs) = default;
5125 
5127  std::is_nothrow_move_constructible<T>::value&& std::is_nothrow_move_assignable<T>::value) {
5128  this->assign(std::move(rhs));
5129  return *this;
5130  }
5131  };
5132 
5133  // optional_delete_ctor_base will conditionally delete copy and move
5134  // constructors depending on whether T is copy/move constructible
5135  template <class T, bool EnableCopy = std::is_copy_constructible<T>::value, bool EnableMove = std::is_move_constructible<T>::value>
5137  optional_delete_ctor_base() = default;
5140  optional_delete_ctor_base& operator=(const optional_delete_ctor_base&) = default;
5141  optional_delete_ctor_base& operator=(optional_delete_ctor_base&&) noexcept = default;
5142  };
5143 
5144  template <class T>
5145  struct optional_delete_ctor_base<T, true, false> {
5146  optional_delete_ctor_base() = default;
5149  optional_delete_ctor_base& operator=(const optional_delete_ctor_base&) = default;
5150  optional_delete_ctor_base& operator=(optional_delete_ctor_base&&) noexcept = default;
5151  };
5152 
5153  template <class T>
5154  struct optional_delete_ctor_base<T, false, true> {
5155  optional_delete_ctor_base() = default;
5158  optional_delete_ctor_base& operator=(const optional_delete_ctor_base&) = default;
5159  optional_delete_ctor_base& operator=(optional_delete_ctor_base&&) noexcept = default;
5160  };
5161 
5162  template <class T>
5163  struct optional_delete_ctor_base<T, false, false> {
5164  optional_delete_ctor_base() = default;
5167  optional_delete_ctor_base& operator=(const optional_delete_ctor_base&) = default;
5168  optional_delete_ctor_base& operator=(optional_delete_ctor_base&&) noexcept = default;
5169  };
5170 
5171  // optional_delete_assign_base will conditionally delete copy and move
5172  // constructors depending on whether T is copy/move constructible + assignable
5173  template <class T, bool EnableCopy = (std::is_copy_constructible<T>::value && std::is_copy_assignable<T>::value),
5174  bool EnableMove = (std::is_move_constructible<T>::value && std::is_move_assignable<T>::value)>
5176  optional_delete_assign_base() = default;
5179  optional_delete_assign_base& operator=(const optional_delete_assign_base&) = default;
5180  optional_delete_assign_base& operator=(optional_delete_assign_base&&) noexcept = default;
5181  };
5182 
5183  template <class T>
5184  struct optional_delete_assign_base<T, true, false> {
5185  optional_delete_assign_base() = default;
5188  optional_delete_assign_base& operator=(const optional_delete_assign_base&) = default;
5189  optional_delete_assign_base& operator=(optional_delete_assign_base&&) noexcept = delete;
5190  };
5191 
5192  template <class T>
5193  struct optional_delete_assign_base<T, false, true> {
5194  optional_delete_assign_base() = default;
5197  optional_delete_assign_base& operator=(const optional_delete_assign_base&) = delete;
5198  optional_delete_assign_base& operator=(optional_delete_assign_base&&) noexcept = default;
5199  };
5200 
5201  template <class T>
5202  struct optional_delete_assign_base<T, false, false> {
5203  optional_delete_assign_base() = default;
5206  optional_delete_assign_base& operator=(const optional_delete_assign_base&) = delete;
5207  optional_delete_assign_base& operator=(optional_delete_assign_base&&) noexcept = delete;
5208  };
5209 
5210  } // namespace detail
5211 
5214 
5224  using std::nullopt;
5225 
5227  class bad_optional_access : public std::exception {
5228  public:
5230  bad_optional_access() = default;
5232  const char* what() const noexcept override {
5233  return "Optional has no value";
5234  }
5235  };
5236 
5243  template <class T>
5244  class optional : private detail::optional_move_assign_base<T>,
5245  private detail::optional_delete_ctor_base<T>,
5246  private detail::optional_delete_assign_base<T> {
5248 
5249  static_assert(!std::is_same<T, in_place_t>::value, "instantiation of optional with in_place_t is ill-formed");
5250  static_assert(!std::is_same<detail::decay_t<T>, nullopt_t>::value, "instantiation of optional with nullopt_t is ill-formed");
5251 
5252  public:
5253 #if defined(SOL_TL_OPTIONAL_CXX14) && !defined(SOL_TL_OPTIONAL_GCC49) && !defined(SOL_TL_OPTIONAL_GCC54) && !defined(SOL_TL_OPTIONAL_GCC55)
5254  template <class F>
5265  SOL_TL_OPTIONAL_11_CONSTEXPR auto and_then(F&& f) & {
5266  using result = detail::invoke_result_t<F, T&>;
5267  static_assert(detail::is_optional<result>::value, "F must return an optional");
5268 
5269  return has_value() ? detail::invoke(std::forward<F>(f), **this) : result(nullopt);
5270  }
5271 
5274  template <class F>
5275  SOL_TL_OPTIONAL_11_CONSTEXPR auto and_then(F&& f) && {
5276  using result = detail::invoke_result_t<F, T&&>;
5277  static_assert(detail::is_optional<result>::value, "F must return an optional");
5278 
5279  return has_value() ? detail::invoke(std::forward<F>(f), std::move(**this)) : result(nullopt);
5280  }
5281 
5284  template <class F>
5285  constexpr auto and_then(F&& f) const& {
5286  using result = detail::invoke_result_t<F, const T&>;
5287  static_assert(detail::is_optional<result>::value, "F must return an optional");
5288 
5289  return has_value() ? detail::invoke(std::forward<F>(f), **this) : result(nullopt);
5290  }
5291 
5292 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR
5293  template <class F>
5296  constexpr auto and_then(F&& f) const&& {
5297  using result = detail::invoke_result_t<F, const T&&>;
5298  static_assert(detail::is_optional<result>::value, "F must return an optional");
5299 
5300  return has_value() ? detail::invoke(std::forward<F>(f), std::move(**this)) : result(nullopt);
5301  }
5302 #endif
5303 #else
5304  template <class F>
5316  using result = detail::invoke_result_t<F, T&>;
5317  static_assert(detail::is_optional<result>::value, "F must return an optional");
5318 
5319  return has_value() ? detail::invoke(std::forward<F>(f), **this) : result(nullopt);
5320  }
5321 
5324  template <class F>
5326  using result = detail::invoke_result_t<F, T&&>;
5327  static_assert(detail::is_optional<result>::value, "F must return an optional");
5328 
5329  return has_value() ? detail::invoke(std::forward<F>(f), std::move(**this)) : result(nullopt);
5330  }
5331 
5334  template <class F>
5336  using result = detail::invoke_result_t<F, const T&>;
5337  static_assert(detail::is_optional<result>::value, "F must return an optional");
5338 
5339  return has_value() ? detail::invoke(std::forward<F>(f), **this) : result(nullopt);
5340  }
5341 
5342 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR
5343  template <class F>
5348  static_assert(detail::is_optional<result>::value, "F must return an optional");
5349 
5350  return has_value() ? detail::invoke(std::forward<F>(f), std::move(**this)) : result(nullopt);
5351  }
5352 #endif
5353 #endif
5354 
5355 #if defined(SOL_TL_OPTIONAL_CXX14) && !defined(SOL_TL_OPTIONAL_GCC49) && !defined(SOL_TL_OPTIONAL_GCC54) && !defined(SOL_TL_OPTIONAL_GCC55)
5356  template <class F>
5366  SOL_TL_OPTIONAL_11_CONSTEXPR auto map(F&& f) & {
5367  return optional_map_impl(*this, std::forward<F>(f));
5368  }
5369 
5372  template <class F>
5373  SOL_TL_OPTIONAL_11_CONSTEXPR auto map(F&& f) && {
5374  return optional_map_impl(std::move(*this), std::forward<F>(f));
5375  }
5376 
5379  template <class F>
5380  constexpr auto map(F&& f) const& {
5381  return optional_map_impl(*this, std::forward<F>(f));
5382  }
5383 
5386  template <class F>
5387  constexpr auto map(F&& f) const&& {
5388  return optional_map_impl(std::move(*this), std::forward<F>(f));
5389  }
5390 #else
5391  template <class F>
5401  SOL_TL_OPTIONAL_11_CONSTEXPR decltype(optional_map_impl(std::declval<optional&>(), std::declval<F&&>())) map(F&& f) & {
5402  return optional_map_impl(*this, std::forward<F>(f));
5403  }
5404 
5407  template <class F>
5408  SOL_TL_OPTIONAL_11_CONSTEXPR decltype(optional_map_impl(std::declval<optional&&>(), std::declval<F&&>())) map(F&& f) && {
5409  return optional_map_impl(std::move(*this), std::forward<F>(f));
5410  }
5411 
5414  template <class F>
5415  constexpr decltype(optional_map_impl(std::declval<const optional&>(), std::declval<F&&>())) map(F&& f) const& {
5416  return optional_map_impl(*this, std::forward<F>(f));
5417  }
5418 
5419 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR
5420  template <class F>
5423  constexpr decltype(optional_map_impl(std::declval<const optional&&>(), std::declval<F&&>())) map(F&& f) const&& {
5424  return optional_map_impl(std::move(*this), std::forward<F>(f));
5425  }
5426 #endif
5427 #endif
5428 
5438  template <class F, detail::enable_if_ret_void<F>* = nullptr>
5440  if (has_value())
5441  return *this;
5442 
5443  std::forward<F>(f)();
5444  return nullopt;
5445  }
5446 
5448  template <class F, detail::disable_if_ret_void<F>* = nullptr>
5450  return has_value() ? *this : std::forward<F>(f)();
5451  }
5452 
5455  template <class F, detail::enable_if_ret_void<F>* = nullptr>
5456  optional<T> or_else(F&& f) && {
5457  if (has_value())
5458  return std::move(*this);
5459 
5460  std::forward<F>(f)();
5461  return nullopt;
5462  }
5463 
5465  template <class F, detail::disable_if_ret_void<F>* = nullptr>
5467  return has_value() ? std::move(*this) : std::forward<F>(f)();
5468  }
5469 
5472  template <class F, detail::enable_if_ret_void<F>* = nullptr>
5473  optional<T> or_else(F&& f) const& {
5474  if (has_value())
5475  return *this;
5476 
5477  std::forward<F>(f)();
5478  return nullopt;
5479  }
5480 
5482  template <class F, detail::disable_if_ret_void<F>* = nullptr>
5484  return has_value() ? *this : std::forward<F>(f)();
5485  }
5486 
5487 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR
5488  template <class F, detail::enable_if_ret_void<F>* = nullptr>
5490  optional<T> or_else(F&& f) const&& {
5491  if (has_value())
5492  return std::move(*this);
5493 
5494  std::forward<F>(f)();
5495  return nullopt;
5496  }
5497 
5499  template <class F, detail::disable_if_ret_void<F>* = nullptr>
5500  optional<T> or_else(F&& f) const&& {
5501  return has_value() ? std::move(*this) : std::forward<F>(f)();
5502  }
5503 #endif
5504 
5512  template <class F, class U>
5513  U map_or(F&& f, U&& u) & {
5514  return has_value() ? detail::invoke(std::forward<F>(f), **this) : std::forward<U>(u);
5515  }
5516 
5518  template <class F, class U>
5519  U map_or(F&& f, U&& u) && {
5520  return has_value() ? detail::invoke(std::forward<F>(f), std::move(**this)) : std::forward<U>(u);
5521  }
5522 
5524  template <class F, class U>
5525  U map_or(F&& f, U&& u) const& {
5526  return has_value() ? detail::invoke(std::forward<F>(f), **this) : std::forward<U>(u);
5527  }
5528 
5529 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR
5530  template <class F, class U>
5532  U map_or(F&& f, U&& u) const&& {
5533  return has_value() ? detail::invoke(std::forward<F>(f), std::move(**this)) : std::forward<U>(u);
5534  }
5535 #endif
5536 
5546  template <class F, class U>
5548  return has_value() ? detail::invoke(std::forward<F>(f), **this) : std::forward<U>(u)();
5549  }
5550 
5554  template <class F, class U>
5556  return has_value() ? detail::invoke(std::forward<F>(f), std::move(**this)) : std::forward<U>(u)();
5557  }
5558 
5562  template <class F, class U>
5564  return has_value() ? detail::invoke(std::forward<F>(f), **this) : std::forward<U>(u)();
5565  }
5566 
5567 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR
5568  template <class F, class U>
5572  detail::invoke_result_t<U> map_or_else(F&& f, U&& u) const&& {
5573  return has_value() ? detail::invoke(std::forward<F>(f), std::move(**this)) : std::forward<U>(u)();
5574  }
5575 #endif
5576 
5578  template <class U>
5580  using result = optional<detail::decay_t<U>>;
5581  return has_value() ? result { u } : result { nullopt };
5582  }
5583 
5587  return has_value() ? *this : rhs;
5588  }
5589 
5591  constexpr optional disjunction(const optional& rhs) const& {
5592  return has_value() ? *this : rhs;
5593  }
5594 
5597  return has_value() ? std::move(*this) : rhs;
5598  }
5599 
5600 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR
5601  constexpr optional disjunction(const optional& rhs) const&& {
5603  return has_value() ? std::move(*this) : rhs;
5604  }
5605 #endif
5606 
5609  return has_value() ? *this : std::move(rhs);
5610  }
5611 
5613  constexpr optional disjunction(optional&& rhs) const& {
5614  return has_value() ? *this : std::move(rhs);
5615  }
5616 
5619  return has_value() ? std::move(*this) : std::move(rhs);
5620  }
5621 
5622 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR
5623  constexpr optional disjunction(optional&& rhs) const&& {
5625  return has_value() ? std::move(*this) : std::move(rhs);
5626  }
5627 #endif
5628 
5632  optional ret = *this;
5633  reset();
5634  return ret;
5635  }
5636 
5638  optional take() const& {
5639  optional ret = *this;
5640  reset();
5641  return ret;
5642  }
5643 
5646  optional ret = std::move(*this);
5647  reset();
5648  return ret;
5649  }
5650 
5651 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR
5652  optional take() const&& {
5654  optional ret = std::move(*this);
5655  reset();
5656  return ret;
5657  }
5658 #endif
5659 
5660  using value_type = T;
5661 
5664  constexpr optional() noexcept = default;
5665 
5667  constexpr optional(nullopt_t) noexcept {
5668  }
5669 
5674  SOL_TL_OPTIONAL_11_CONSTEXPR optional(const optional& rhs) = default;
5675 
5681 
5685  template <class... Args>
5686  constexpr explicit optional(detail::enable_if_t<std::is_constructible<T, Args...>::value, in_place_t>, Args&&... args)
5687  : base(in_place, std::forward<Args>(args)...) {
5688  }
5689 
5692  template <class U, class... Args>
5693  SOL_TL_OPTIONAL_11_CONSTEXPR explicit optional(detail::enable_if_t<std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value, in_place_t>,
5694  std::initializer_list<U> il, Args&&... args) {
5695  this->construct(il, std::forward<Args>(args)...);
5696  }
5697 
5698 #if 0 // SOL_MODIFICATION
5699  template <class U = T, detail::enable_if_t<std::is_convertible<U&&, T>::value>* = nullptr, detail::enable_forward_value<T, U>* = nullptr>
5702  constexpr optional(U&& u) : base(in_place, std::forward<U>(u)) {
5703  }
5704 
5706  template <class U = T, detail::enable_if_t<!std::is_convertible<U&&, T>::value>* = nullptr, detail::enable_forward_value<T, U>* = nullptr>
5707  constexpr explicit optional(U&& u) : base(in_place, std::forward<U>(u)) {
5708  }
5709 #else
5710  constexpr optional(T&& u) : base(in_place, std::move(u)) {
5713  }
5714 
5716  constexpr optional(const T& u) : base(in_place, u) {
5717  }
5718 #endif // sol2 modification
5719 
5722  template <class U, detail::enable_from_other<T, U, const U&>* = nullptr, detail::enable_if_t<std::is_convertible<const U&, T>::value>* = nullptr>
5723  optional(const optional<U>& rhs) {
5724  if (rhs.has_value()) {
5725  this->construct(*rhs);
5726  }
5727  }
5728 
5730  template <class U, detail::enable_from_other<T, U, const U&>* = nullptr, detail::enable_if_t<!std::is_convertible<const U&, T>::value>* = nullptr>
5731  explicit optional(const optional<U>& rhs) {
5732  if (rhs.has_value()) {
5733  this->construct(*rhs);
5734  }
5735  }
5736 
5739  template <class U, detail::enable_from_other<T, U, U&&>* = nullptr, detail::enable_if_t<std::is_convertible<U&&, T>::value>* = nullptr>
5741  if (rhs.has_value()) {
5742  this->construct(std::move(*rhs));
5743  }
5744  }
5745 
5747  template <class U, detail::enable_from_other<T, U, U&&>* = nullptr, detail::enable_if_t<!std::is_convertible<U&&, T>::value>* = nullptr>
5748  explicit optional(optional<U>&& rhs) {
5749  this->construct(std::move(*rhs));
5750  }
5751 
5753  ~optional() = default;
5754 
5759  if (has_value()) {
5760  this->m_value.~T();
5761  this->m_has_value = false;
5762  }
5763 
5764  return *this;
5765  }
5766 
5771  optional& operator=(const optional& rhs) = default;
5772 
5777  optional& operator=(optional&& rhs) = default;
5778 
5782  template <class U = T, detail::enable_assign_forward<T, U>* = nullptr>
5784  if (has_value()) {
5785  this->m_value = std::forward<U>(u);
5786  }
5787  else {
5788  this->construct(std::forward<U>(u));
5789  }
5790 
5791  return *this;
5792  }
5793 
5799  template <class U, detail::enable_assign_from_other<T, U, const U&>* = nullptr>
5801  if (has_value()) {
5802  if (rhs.has_value()) {
5803  this->m_value = *rhs;
5804  }
5805  else {
5806  this->hard_reset();
5807  }
5808  }
5809 
5810  if (rhs.has_value()) {
5811  this->construct(*rhs);
5812  }
5813 
5814  return *this;
5815  }
5816 
5817  // TODO check exception guarantee
5823  template <class U, detail::enable_assign_from_other<T, U, U>* = nullptr>
5825  if (has_value()) {
5826  if (rhs.has_value()) {
5827  this->m_value = std::move(*rhs);
5828  }
5829  else {
5830  this->hard_reset();
5831  }
5832  }
5833 
5834  if (rhs.has_value()) {
5835  this->construct(std::move(*rhs));
5836  }
5837 
5838  return *this;
5839  }
5840 
5844  template <class... Args>
5845  T& emplace(Args&&... args) {
5846  static_assert(std::is_constructible<T, Args&&...>::value, "T must be constructible with Args");
5847 
5848  *this = nullopt;
5849  this->construct(std::forward<Args>(args)...);
5850  return value();
5851  }
5852 
5855  template <class U, class... Args>
5856  detail::enable_if_t<std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value, T&> emplace(std::initializer_list<U> il, Args&&... args) {
5857  *this = nullopt;
5858  this->construct(il, std::forward<Args>(args)...);
5859  return value();
5860  }
5861 
5868  void swap(optional& rhs) noexcept(std::is_nothrow_move_constructible<T>::value&& detail::is_nothrow_swappable<T>::value) {
5869  if (has_value()) {
5870  if (rhs.has_value()) {
5871  using std::swap;
5872  swap(**this, *rhs);
5873  }
5874  else {
5875  new (std::addressof(rhs.m_value)) T(std::move(this->m_value));
5876  this->m_value.T::~T();
5877  }
5878  }
5879  else if (rhs.has_value()) {
5880  new (std::addressof(this->m_value)) T(std::move(rhs.m_value));
5881  rhs.m_value.T::~T();
5882  }
5883  }
5884 
5889  constexpr const T* operator->() const {
5890  return std::addressof(this->m_value);
5891  }
5892 
5896  return std::addressof(this->m_value);
5897  }
5898 
5904  return this->m_value;
5905  }
5906 
5909  constexpr const T& operator*() const& {
5910  return this->m_value;
5911  }
5912 
5915  return std::move(this->m_value);
5916  }
5917 
5918 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR
5919  constexpr const T&& operator*() const&& {
5921  return std::move(this->m_value);
5922  }
5923 #endif
5924 
5927  constexpr bool has_value() const noexcept {
5928  return this->m_has_value;
5929  }
5930 
5932  constexpr explicit operator bool() const noexcept {
5933  return this->m_has_value;
5934  }
5935 
5941  if (has_value())
5942  return this->m_value;
5943 #if SOL_IS_OFF(SOL_EXCEPTIONS)
5944  std::abort();
5945 #else
5946  throw bad_optional_access();
5947 #endif // No exceptions allowed
5948  }
5952  if (has_value())
5953  return this->m_value;
5954 #if SOL_IS_OFF(SOL_EXCEPTIONS)
5955  std::abort();
5956 #else
5957  throw bad_optional_access();
5958 #endif // No exceptions allowed
5959  }
5962  if (has_value())
5963  return std::move(this->m_value);
5964 #if SOL_IS_OFF(SOL_EXCEPTIONS)
5965  std::abort();
5966 #else
5967  throw bad_optional_access();
5968 #endif // No exceptions allowed
5969  }
5970 
5971 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR
5972  SOL_TL_OPTIONAL_11_CONSTEXPR const T&& value() const&& {
5974  if (has_value())
5975  return std::move(this->m_value);
5976 #if SOL_IS_OFF(SOL_EXCEPTIONS)
5977  std::abort();
5978 #else
5979  throw bad_optional_access();
5980 #endif // No exceptions allowed
5981  }
5982 #endif
5983 
5986  template <class U>
5987  constexpr T value_or(U&& u) const& {
5988  static_assert(std::is_copy_constructible<T>::value && std::is_convertible<U&&, T>::value, "T must be copy constructible and convertible from U");
5989  return has_value() ? **this : static_cast<T>(std::forward<U>(u));
5990  }
5991 
5993  template <class U>
5995  static_assert(std::is_move_constructible<T>::value && std::is_convertible<U&&, T>::value, "T must be move constructible and convertible from U");
5996  return has_value() ? **this : static_cast<T>(std::forward<U>(u));
5997  }
5998 
6000  void reset() noexcept {
6001  if (has_value()) {
6002  this->m_value.~T();
6003  this->m_has_value = false;
6004  }
6005  }
6006  }; // namespace sol
6007 
6014  template <class T, class U>
6015  inline constexpr bool operator==(const optional<T>& lhs, const optional<U>& rhs) {
6016  return lhs.has_value() == rhs.has_value() && (!lhs.has_value() || *lhs == *rhs);
6017  }
6019  template <class T, class U>
6020  inline constexpr bool operator!=(const optional<T>& lhs, const optional<U>& rhs) {
6021  return lhs.has_value() != rhs.has_value() || (lhs.has_value() && *lhs != *rhs);
6022  }
6024  template <class T, class U>
6025  inline constexpr bool operator<(const optional<T>& lhs, const optional<U>& rhs) {
6026  return rhs.has_value() && (!lhs.has_value() || *lhs < *rhs);
6027  }
6029  template <class T, class U>
6030  inline constexpr bool operator>(const optional<T>& lhs, const optional<U>& rhs) {
6031  return lhs.has_value() && (!rhs.has_value() || *lhs > *rhs);
6032  }
6034  template <class T, class U>
6035  inline constexpr bool operator<=(const optional<T>& lhs, const optional<U>& rhs) {
6036  return !lhs.has_value() || (rhs.has_value() && *lhs <= *rhs);
6037  }
6039  template <class T, class U>
6040  inline constexpr bool operator>=(const optional<T>& lhs, const optional<U>& rhs) {
6041  return !rhs.has_value() || (lhs.has_value() && *lhs >= *rhs);
6042  }
6043 
6047  template <class T>
6048  inline constexpr bool operator==(const optional<T>& lhs, nullopt_t) noexcept {
6049  return !lhs.has_value();
6050  }
6052  template <class T>
6053  inline constexpr bool operator==(nullopt_t, const optional<T>& rhs) noexcept {
6054  return !rhs.has_value();
6055  }
6057  template <class T>
6058  inline constexpr bool operator!=(const optional<T>& lhs, nullopt_t) noexcept {
6059  return lhs.has_value();
6060  }
6062  template <class T>
6063  inline constexpr bool operator!=(nullopt_t, const optional<T>& rhs) noexcept {
6064  return rhs.has_value();
6065  }
6067  template <class T>
6068  inline constexpr bool operator<(const optional<T>&, nullopt_t) noexcept {
6069  return false;
6070  }
6072  template <class T>
6073  inline constexpr bool operator<(nullopt_t, const optional<T>& rhs) noexcept {
6074  return rhs.has_value();
6075  }
6077  template <class T>
6078  inline constexpr bool operator<=(const optional<T>& lhs, nullopt_t) noexcept {
6079  return !lhs.has_value();
6080  }
6082  template <class T>
6083  inline constexpr bool operator<=(nullopt_t, const optional<T>&) noexcept {
6084  return true;
6085  }
6087  template <class T>
6088  inline constexpr bool operator>(const optional<T>& lhs, nullopt_t) noexcept {
6089  return lhs.has_value();
6090  }
6092  template <class T>
6093  inline constexpr bool operator>(nullopt_t, const optional<T>&) noexcept {
6094  return false;
6095  }
6097  template <class T>
6098  inline constexpr bool operator>=(const optional<T>&, nullopt_t) noexcept {
6099  return true;
6100  }
6102  template <class T>
6103  inline constexpr bool operator>=(nullopt_t, const optional<T>& rhs) noexcept {
6104  return !rhs.has_value();
6105  }
6106 
6112  template <class T, class U>
6113  inline constexpr bool operator==(const optional<T>& lhs, const U& rhs) {
6114  return lhs.has_value() ? *lhs == rhs : false;
6115  }
6117  template <class T, class U>
6118  inline constexpr bool operator==(const U& lhs, const optional<T>& rhs) {
6119  return rhs.has_value() ? lhs == *rhs : false;
6120  }
6122  template <class T, class U>
6123  inline constexpr bool operator!=(const optional<T>& lhs, const U& rhs) {
6124  return lhs.has_value() ? *lhs != rhs : true;
6125  }
6127  template <class T, class U>
6128  inline constexpr bool operator!=(const U& lhs, const optional<T>& rhs) {
6129  return rhs.has_value() ? lhs != *rhs : true;
6130  }
6132  template <class T, class U>
6133  inline constexpr bool operator<(const optional<T>& lhs, const U& rhs) {
6134  return lhs.has_value() ? *lhs < rhs : true;
6135  }
6137  template <class T, class U>
6138  inline constexpr bool operator<(const U& lhs, const optional<T>& rhs) {
6139  return rhs.has_value() ? lhs < *rhs : false;
6140  }
6142  template <class T, class U>
6143  inline constexpr bool operator<=(const optional<T>& lhs, const U& rhs) {
6144  return lhs.has_value() ? *lhs <= rhs : true;
6145  }
6147  template <class T, class U>
6148  inline constexpr bool operator<=(const U& lhs, const optional<T>& rhs) {
6149  return rhs.has_value() ? lhs <= *rhs : false;
6150  }
6152  template <class T, class U>
6153  inline constexpr bool operator>(const optional<T>& lhs, const U& rhs) {
6154  return lhs.has_value() ? *lhs > rhs : false;
6155  }
6157  template <class T, class U>
6158  inline constexpr bool operator>(const U& lhs, const optional<T>& rhs) {
6159  return rhs.has_value() ? lhs > *rhs : true;
6160  }
6162  template <class T, class U>
6163  inline constexpr bool operator>=(const optional<T>& lhs, const U& rhs) {
6164  return lhs.has_value() ? *lhs >= rhs : false;
6165  }
6167  template <class T, class U>
6168  inline constexpr bool operator>=(const U& lhs, const optional<T>& rhs) {
6169  return rhs.has_value() ? lhs >= *rhs : true;
6170  }
6171 
6173  template <class T, detail::enable_if_t<std::is_move_constructible<T>::value>* = nullptr, detail::enable_if_t<detail::is_swappable<T>::value>* = nullptr>
6174  void swap(optional<T>& lhs, optional<T>& rhs) noexcept(noexcept(lhs.swap(rhs))) {
6175  return lhs.swap(rhs);
6176  }
6177 
6178  namespace detail {
6179  struct i_am_secret { };
6180  } // namespace detail
6181 
6182  template <class T = detail::i_am_secret, class U, class Ret = detail::conditional_t<std::is_same<T, detail::i_am_secret>::value, detail::decay_t<U>, T>>
6183  inline constexpr optional<Ret> make_optional(U&& v) {
6184  return optional<Ret>(std::forward<U>(v));
6185  }
6186 
6187  template <class T, class... Args>
6188  inline constexpr optional<T> make_optional(Args&&... args) {
6189  return optional<T>(in_place, std::forward<Args>(args)...);
6190  }
6191  template <class T, class U, class... Args>
6192  inline constexpr optional<T> make_optional(std::initializer_list<U> il, Args&&... args) {
6193  return optional<T>(in_place, il, std::forward<Args>(args)...);
6194  }
6195 
6196 #if __cplusplus >= 201703L
6197  template <class T>
6198  optional(T) -> optional<T>;
6199 #endif
6200 
6202  namespace detail {
6203 #ifdef SOL_TL_OPTIONAL_CXX14
6204  template <class Opt, class F, class Ret = decltype(detail::invoke(std::declval<F>(), *std::declval<Opt>())),
6205  detail::enable_if_t<!std::is_void<Ret>::value>* = nullptr>
6206  constexpr auto optional_map_impl(Opt&& opt, F&& f) {
6207  return opt.has_value() ? detail::invoke(std::forward<F>(f), *std::forward<Opt>(opt)) : optional<Ret>(nullopt);
6208  }
6209 
6210  template <class Opt, class F, class Ret = decltype(detail::invoke(std::declval<F>(), *std::declval<Opt>())),
6211  detail::enable_if_t<std::is_void<Ret>::value>* = nullptr>
6212  auto optional_map_impl(Opt&& opt, F&& f) {
6213  if (opt.has_value()) {
6214  detail::invoke(std::forward<F>(f), *std::forward<Opt>(opt));
6215  return make_optional(monostate {});
6216  }
6217 
6218  return optional<monostate>(nullopt);
6219  }
6220 #else
6221  template <class Opt, class F, class Ret = decltype(detail::invoke(std::declval<F>(), *std::declval<Opt>())),
6222  detail::enable_if_t<!std::is_void<Ret>::value>* = nullptr>
6223 
6224  constexpr auto optional_map_impl(Opt&& opt, F&& f) -> optional<Ret> {
6225  return opt.has_value() ? detail::invoke(std::forward<F>(f), *std::forward<Opt>(opt)) : optional<Ret>(nullopt);
6226  }
6227 
6228  template <class Opt, class F, class Ret = decltype(detail::invoke(std::declval<F>(), *std::declval<Opt>())),
6230 
6231  auto optional_map_impl(Opt&& opt, F&& f) -> optional<monostate> {
6232  if (opt.has_value()) {
6233  detail::invoke(std::forward<F>(f), *std::forward<Opt>(opt));
6234  return monostate {};
6235  }
6236 
6237  return nullopt;
6238  }
6239 #endif
6240  } // namespace detail
6241 
6264  template <class T>
6265  class optional<T&> {
6266  public:
6267 #if defined(SOL_TL_OPTIONAL_CXX14) && !defined(SOL_TL_OPTIONAL_GCC49) && !defined(SOL_TL_OPTIONAL_GCC54) && !defined(SOL_TL_OPTIONAL_GCC55)
6268  template <class F>
6279  SOL_TL_OPTIONAL_11_CONSTEXPR auto and_then(F&& f) & {
6280  using result = detail::invoke_result_t<F, T&>;
6281  static_assert(detail::is_optional<result>::value, "F must return an optional");
6282 
6283  return has_value() ? detail::invoke(std::forward<F>(f), **this) : result(nullopt);
6284  }
6285 
6288  template <class F>
6289  SOL_TL_OPTIONAL_11_CONSTEXPR auto and_then(F&& f) && {
6290  using result = detail::invoke_result_t<F, T&>;
6291  static_assert(detail::is_optional<result>::value, "F must return an optional");
6292 
6293  return has_value() ? detail::invoke(std::forward<F>(f), **this) : result(nullopt);
6294  }
6295 
6298  template <class F>
6299  constexpr auto and_then(F&& f) const& {
6300  using result = detail::invoke_result_t<F, const T&>;
6301  static_assert(detail::is_optional<result>::value, "F must return an optional");
6302 
6303  return has_value() ? detail::invoke(std::forward<F>(f), **this) : result(nullopt);
6304  }
6305 
6306 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR
6307  template <class F>
6310  constexpr auto and_then(F&& f) const&& {
6311  using result = detail::invoke_result_t<F, const T&>;
6312  static_assert(detail::is_optional<result>::value, "F must return an optional");
6313 
6314  return has_value() ? detail::invoke(std::forward<F>(f), **this) : result(nullopt);
6315  }
6316 #endif
6317 #else
6318  template <class F>
6330  using result = detail::invoke_result_t<F, T&>;
6331  static_assert(detail::is_optional<result>::value, "F must return an optional");
6332 
6333  return has_value() ? detail::invoke(std::forward<F>(f), **this) : result(nullopt);
6334  }
6335 
6338  template <class F>
6340  using result = detail::invoke_result_t<F, T&>;
6341  static_assert(detail::is_optional<result>::value, "F must return an optional");
6342 
6343  return has_value() ? detail::invoke(std::forward<F>(f), **this) : result(nullopt);
6344  }
6345 
6348  template <class F>
6350  using result = detail::invoke_result_t<F, const T&>;
6351  static_assert(detail::is_optional<result>::value, "F must return an optional");
6352 
6353  return has_value() ? detail::invoke(std::forward<F>(f), **this) : result(nullopt);
6354  }
6355 
6356 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR
6357  template <class F>
6361  using result = detail::invoke_result_t<F, const T&>;
6362  static_assert(detail::is_optional<result>::value, "F must return an optional");
6363 
6364  return has_value() ? detail::invoke(std::forward<F>(f), **this) : result(nullopt);
6365  }
6366 #endif
6367 #endif
6368 
6369 #if defined(SOL_TL_OPTIONAL_CXX14) && !defined(SOL_TL_OPTIONAL_GCC49) && !defined(SOL_TL_OPTIONAL_GCC54) && !defined(SOL_TL_OPTIONAL_GCC55)
6370  template <class F>
6380  SOL_TL_OPTIONAL_11_CONSTEXPR auto map(F&& f) & {
6381  return detail::optional_map_impl(*this, std::forward<F>(f));
6382  }
6383 
6386  template <class F>
6387  SOL_TL_OPTIONAL_11_CONSTEXPR auto map(F&& f) && {
6388  return detail::optional_map_impl(std::move(*this), std::forward<F>(f));
6389  }
6390 
6393  template <class F>
6394  constexpr auto map(F&& f) const& {
6395  return detail::optional_map_impl(*this, std::forward<F>(f));
6396  }
6397 
6400  template <class F>
6401  constexpr auto map(F&& f) const&& {
6402  return detail::optional_map_impl(std::move(*this), std::forward<F>(f));
6403  }
6404 #else
6405  template <class F>
6415  SOL_TL_OPTIONAL_11_CONSTEXPR decltype(detail::optional_map_impl(std::declval<optional&>(), std::declval<F&&>())) map(F&& f) & {
6416  return detail::optional_map_impl(*this, std::forward<F>(f));
6417  }
6418 
6421  template <class F>
6422  SOL_TL_OPTIONAL_11_CONSTEXPR decltype(detail::optional_map_impl(std::declval<optional&&>(), std::declval<F&&>())) map(F&& f) && {
6423  return detail::optional_map_impl(std::move(*this), std::forward<F>(f));
6424  }
6425 
6428  template <class F>
6429  constexpr decltype(detail::optional_map_impl(std::declval<const optional&>(), std::declval<F&&>())) map(F&& f) const& {
6430  return detail::optional_map_impl(*this, std::forward<F>(f));
6431  }
6432 
6433 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR
6434  template <class F>
6437  constexpr decltype(detail::optional_map_impl(std::declval<const optional&&>(), std::declval<F&&>())) map(F&& f) const&& {
6438  return detail::optional_map_impl(std::move(*this), std::forward<F>(f));
6439  }
6440 #endif
6441 #endif
6442 
6451  template <class F, detail::enable_if_ret_void<F>* = nullptr>
6453  if (has_value())
6454  return *this;
6455 
6456  std::forward<F>(f)();
6457  return nullopt;
6458  }
6459 
6461  template <class F, detail::disable_if_ret_void<F>* = nullptr>
6463  return has_value() ? *this : std::forward<F>(f)();
6464  }
6465 
6468  template <class F, detail::enable_if_ret_void<F>* = nullptr>
6469  optional<T> or_else(F&& f) && {
6470  if (has_value())
6471  return std::move(*this);
6472 
6473  std::forward<F>(f)();
6474  return nullopt;
6475  }
6476 
6478  template <class F, detail::disable_if_ret_void<F>* = nullptr>
6480  return has_value() ? std::move(*this) : std::forward<F>(f)();
6481  }
6482 
6485  template <class F, detail::enable_if_ret_void<F>* = nullptr>
6486  optional<T> or_else(F&& f) const& {
6487  if (has_value())
6488  return *this;
6489 
6490  std::forward<F>(f)();
6491  return nullopt;
6492  }
6493 
6495  template <class F, detail::disable_if_ret_void<F>* = nullptr>
6497  return has_value() ? *this : std::forward<F>(f)();
6498  }
6499 
6500 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR
6501  template <class F, detail::enable_if_ret_void<F>* = nullptr>
6503  optional<T> or_else(F&& f) const&& {
6504  if (has_value())
6505  return std::move(*this);
6506 
6507  std::forward<F>(f)();
6508  return nullopt;
6509  }
6510 
6512  template <class F, detail::disable_if_ret_void<F>* = nullptr>
6513  optional<T> or_else(F&& f) const&& {
6514  return has_value() ? std::move(*this) : std::forward<F>(f)();
6515  }
6516 #endif
6517 
6525  template <class F, class U>
6526  U map_or(F&& f, U&& u) & {
6527  return has_value() ? detail::invoke(std::forward<F>(f), **this) : std::forward<U>(u);
6528  }
6529 
6531  template <class F, class U>
6532  U map_or(F&& f, U&& u) && {
6533  return has_value() ? detail::invoke(std::forward<F>(f), std::move(**this)) : std::forward<U>(u);
6534  }
6535 
6537  template <class F, class U>
6538  U map_or(F&& f, U&& u) const& {
6539  return has_value() ? detail::invoke(std::forward<F>(f), **this) : std::forward<U>(u);
6540  }
6541 
6542 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR
6543  template <class F, class U>
6545  U map_or(F&& f, U&& u) const&& {
6546  return has_value() ? detail::invoke(std::forward<F>(f), std::move(**this)) : std::forward<U>(u);
6547  }
6548 #endif
6549 
6559  template <class F, class U>
6561  return has_value() ? detail::invoke(std::forward<F>(f), **this) : std::forward<U>(u)();
6562  }
6563 
6567  template <class F, class U>
6569  return has_value() ? detail::invoke(std::forward<F>(f), std::move(**this)) : std::forward<U>(u)();
6570  }
6571 
6575  template <class F, class U>
6577  return has_value() ? detail::invoke(std::forward<F>(f), **this) : std::forward<U>(u)();
6578  }
6579 
6580 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR
6581  template <class F, class U>
6585  detail::invoke_result_t<U> map_or_else(F&& f, U&& u) const&& {
6586  return has_value() ? detail::invoke(std::forward<F>(f), std::move(**this)) : std::forward<U>(u)();
6587  }
6588 #endif
6589 
6591  template <class U>
6593  using result = optional<detail::decay_t<U>>;
6594  return has_value() ? result { u } : result { nullopt };
6595  }
6596 
6600  return has_value() ? *this : rhs;
6601  }
6602 
6604  constexpr optional disjunction(const optional& rhs) const& {
6605  return has_value() ? *this : rhs;
6606  }
6607 
6610  return has_value() ? std::move(*this) : rhs;
6611  }
6612 
6613 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR
6614  constexpr optional disjunction(const optional& rhs) const&& {
6616  return has_value() ? std::move(*this) : rhs;
6617  }
6618 #endif
6619 
6622  return has_value() ? *this : std::move(rhs);
6623  }
6624 
6626  constexpr optional disjunction(optional&& rhs) const& {
6627  return has_value() ? *this : std::move(rhs);
6628  }
6629 
6632  return has_value() ? std::move(*this) : std::move(rhs);
6633  }
6634 
6635 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR
6636  constexpr optional disjunction(optional&& rhs) const&& {
6638  return has_value() ? std::move(*this) : std::move(rhs);
6639  }
6640 #endif
6641 
6645  optional ret = *this;
6646  reset();
6647  return ret;
6648  }
6649 
6651  optional take() const& {
6652  optional ret = *this;
6653  reset();
6654  return ret;
6655  }
6656 
6659  optional ret = std::move(*this);
6660  reset();
6661  return ret;
6662  }
6663 
6664 #ifndef SOL_TL_OPTIONAL_NO_CONSTRR
6665  optional take() const&& {
6667  optional ret = std::move(*this);
6668  reset();
6669  return ret;
6670  }
6671 #endif
6672 
6673  using value_type = T&;
6674 
6677  constexpr optional() noexcept : m_value(nullptr) {
6678  }
6679 
6681  constexpr optional(nullopt_t) noexcept : m_value(nullptr) {
6682  }
6683 
6688  SOL_TL_OPTIONAL_11_CONSTEXPR optional(const optional& rhs) noexcept = default;
6689 
6695 
6698  template <class U = T, detail::enable_if_t<!detail::is_optional<detail::decay_t<U>>::value>* = nullptr>
6699  constexpr optional(U&& u) : m_value(std::addressof(u)) {
6700  static_assert(std::is_lvalue_reference<U>::value, "U must be an lvalue");
6701  }
6702 
6704  template <class U>
6705  constexpr explicit optional(const optional<U>& rhs) : optional(*rhs) {
6706  }
6707 
6709  ~optional() = default;
6710 
6715  m_value = nullptr;
6716  return *this;
6717  }
6718 
6723  optional& operator=(const optional& rhs) = default;
6724 
6729  template <class U = T, detail::enable_if_t<!detail::is_optional<detail::decay_t<U>>::value>* = nullptr>
6731  static_assert(std::is_lvalue_reference<U>::value, "U must be an lvalue");
6732  m_value = std::addressof(u);
6733  return *this;
6734  }
6735 
6740  template <class U>
6742  m_value = std::addressof(rhs.value());
6743  return *this;
6744  }
6745 
6750  template <class... Args>
6751  T& emplace(Args&&... args) noexcept {
6752  static_assert(std::is_constructible<T, Args&&...>::value, "T must be constructible with Args");
6753 
6754  *this = nullopt;
6755  this->construct(std::forward<Args>(args)...);
6756  }
6757 
6764  void swap(optional& rhs) noexcept {
6765  std::swap(m_value, rhs.m_value);
6766  }
6767 
6772  constexpr const T* operator->() const {
6773  return m_value;
6774  }
6775 
6779  return m_value;
6780  }
6781 
6787  return *m_value;
6788  }
6789 
6792  constexpr const T& operator*() const {
6793  return *m_value;
6794  }
6795 
6798  constexpr bool has_value() const noexcept {
6799  return m_value != nullptr;
6800  }
6801 
6803  constexpr explicit operator bool() const noexcept {
6804  return m_value != nullptr;
6805  }
6806 
6812  if (has_value())
6813  return *m_value;
6814 #if SOL_IS_OFF(SOL_EXCEPTIONS)
6815  std::abort();
6816 #else
6817  throw bad_optional_access();
6818 #endif // No exceptions allowed
6819  }
6823  if (has_value())
6824  return *m_value;
6825 #if SOL_IS_OFF(SOL_EXCEPTIONS)
6826  std::abort();
6827 #else
6828  throw bad_optional_access();
6829 #endif // No exceptions allowed
6830  }
6831 
6834  template <class U>
6835  constexpr T& value_or(U&& u) const {
6836  static_assert(std::is_convertible<U&&, T&>::value, "T must be convertible from U");
6837  return has_value() ? const_cast<T&>(**this) : static_cast<T&>(std::forward<U>(u));
6838  }
6839 
6841  void reset() noexcept {
6842  m_value = nullptr;
6843  }
6844 
6845  private:
6847  };
6848 
6849 } // namespace sol
6850 
6851 namespace std {
6852  // TODO SFINAE
6853  template <class T>
6854  struct hash<::sol::optional<T>> {
6855  ::std::size_t operator()(const ::sol::optional<T>& o) const {
6856  if (!o.has_value())
6857  return 0;
6858 
6859  return ::std::hash<::sol::detail::remove_const_t<T>>()(*o);
6860  }
6861  };
6862 } // namespace std
6863 
6864 // end of sol/optional_implementation.hpp
6865 
6866 #endif // Boost vs. Better optional
6867 
6868 #include <optional>
6869 
6870 namespace sol {
6871 
6872 #if SOL_IS_ON(SOL_USE_BOOST)
6873  template <typename T>
6874  using optional = boost::optional<T>;
6875  using nullopt_t = boost::none_t;
6877 #endif // Boost vs. Better optional
6878 
6879  namespace meta {
6880  template <typename T>
6882 
6883  template <typename T>
6884  constexpr inline bool is_optional_v = is_optional<T>::value;
6885  } // namespace meta
6886 
6887  namespace detail {
6888  template <typename T>
6890  inline static constexpr std::nullopt_t value = std::nullopt;
6891  };
6892 
6893 #if SOL_IS_ON(SOL_USE_BOOST)
6894  template <typename T>
6895  struct associated_nullopt<boost::optional<T>> {
6896  inline static SOL_BOOST_NONE_CONSTEXPR_I_ boost::none_t value = boost::none;
6897  };
6898 #endif // Boost nullopt
6899 
6900 #if SOL_IS_ON(SOL_USE_BOOST)
6901  template <typename T>
6902  inline SOL_BOOST_NONE_CONSTEXPR_I_ auto associated_nullopt_v = associated_nullopt<T>::value;
6903 #else
6904  template <typename T>
6906 #endif // Boost continues to lag behind, to not many people's surprise...
6907  } // namespace detail
6908 } // namespace sol
6909 
6910 #if SOL_IS_ON(SOL_USE_BOOST)
6911 #undef SOL_BOOST_NONE_CONSTEXPR_I_
6912 #endif
6913 
6914 // end of sol/optional.hpp
6915 
6916 // beginning of sol/raii.hpp
6917 
6918 #include <memory>
6919 
6920 namespace sol {
6921  namespace detail {
6923  template <typename T, typename... Args>
6924  static void construct(T&& obj, Args&&... args) {
6925  typedef meta::unqualified_t<T> Tu;
6926  std::allocator<Tu> alloc {};
6927  std::allocator_traits<std::allocator<Tu>>::construct(alloc, std::forward<T>(obj), std::forward<Args>(args)...);
6928  }
6929 
6930  template <typename T, typename... Args>
6931  void operator()(T&& obj, Args&&... args) const {
6932  construct(std::forward<T>(obj), std::forward<Args>(args)...);
6933  }
6934  };
6935 
6937  template <typename T>
6938  static void destroy(T&& obj) {
6940  alloc.destroy(obj);
6941  }
6942 
6943  template <typename T>
6944  void operator()(T&& obj) const {
6945  destroy(std::forward<T>(obj));
6946  }
6947  };
6948 
6949  struct deleter {
6950  template <typename T>
6951  void operator()(T* p) const {
6952  delete p;
6953  }
6954  };
6955 
6956  struct state_deleter {
6957  void operator()(lua_State* L) const {
6958  lua_close(L);
6959  }
6960  };
6961 
6962  template <typename T, typename Dx, typename... Args>
6963  inline std::unique_ptr<T, Dx> make_unique_deleter(Args&&... args) {
6964  return std::unique_ptr<T, Dx>(new T(std::forward<Args>(args)...));
6965  }
6966 
6967  template <typename Tag, typename T>
6968  struct tagged {
6969  private:
6971 
6972  public:
6973  template <typename Arg, typename... Args, meta::disable<std::is_same<meta::unqualified_t<Arg>, tagged>> = meta::enabler>
6974  tagged(Arg&& arg, Args&&... args) : value_(std::forward<Arg>(arg), std::forward<Args>(args)...) {
6975  }
6976 
6977  T& value() & {
6978  return value_;
6979  }
6980 
6981  T const& value() const& {
6982  return value_;
6983  }
6984 
6985  T&& value() && {
6986  return std::move(value_);
6987  }
6988  };
6989  } // namespace detail
6990 
6991  template <typename... Args>
6992  struct constructor_list { };
6993 
6994  template <typename... Args>
6995  using constructors = constructor_list<Args...>;
6996 
6998 
6999  struct no_construction { };
7001 
7002  struct call_construction { };
7004 
7005  template <typename... Functions>
7007  std::tuple<Functions...> functions;
7008  template <typename Arg, typename... Args, meta::disable<std::is_same<meta::unqualified_t<Arg>, constructor_wrapper>> = meta::enabler>
7009  constructor_wrapper(Arg&& arg, Args&&... args) : functions(std::forward<Arg>(arg), std::forward<Args>(args)...) {
7010  }
7011  };
7012 
7013  template <typename... Functions>
7014  inline auto initializers(Functions&&... functions) {
7015  return constructor_wrapper<std::decay_t<Functions>...>(std::forward<Functions>(functions)...);
7016  }
7017 
7018  template <typename... Functions>
7020  std::tuple<Functions...> functions;
7021  template <typename Arg, typename... Args, meta::disable<std::is_same<meta::unqualified_t<Arg>, factory_wrapper>> = meta::enabler>
7022  factory_wrapper(Arg&& arg, Args&&... args) : functions(std::forward<Arg>(arg), std::forward<Args>(args)...) {
7023  }
7024  };
7025 
7026  template <typename... Functions>
7027  inline auto factories(Functions&&... functions) {
7028  return factory_wrapper<std::decay_t<Functions>...>(std::forward<Functions>(functions)...);
7029  }
7030 
7031  template <typename Function>
7033  Function fx;
7034  destructor_wrapper(Function f) : fx(std::move(f)) {
7035  }
7036  };
7037 
7038  template <>
7040 
7042 
7043  template <typename Fx>
7044  inline auto destructor(Fx&& fx) {
7045  return destructor_wrapper<std::decay_t<Fx>>(std::forward<Fx>(fx));
7046  }
7047 
7048 } // namespace sol
7049 
7050 // end of sol/raii.hpp
7051 
7052 // beginning of sol/policies.hpp
7053 
7054 #include <array>
7055 
7056 namespace sol {
7057  namespace detail {
7058  struct policy_base_tag { };
7059  } // namespace detail
7060 
7061  template <int Target, int... In>
7064  template <int... In>
7067 
7069  int target;
7070  std::array<int, 64> stack_indices;
7072 
7073  template <typename... Args>
7074  stack_dependencies(int stack_target, Args&&... args) : target(stack_target), stack_indices(), len(sizeof...(Args)) {
7075  std::size_t i = 0;
7076  (void)detail::swallow { int(), (stack_indices[i++] = static_cast<int>(std::forward<Args>(args)), int())... };
7077  }
7078 
7080  return stack_indices[i];
7081  }
7082 
7083  const int& operator[](std::size_t i) const {
7084  return stack_indices[i];
7085  }
7086 
7087  std::size_t size() const {
7088  return len;
7089  }
7090  };
7091 
7092  template <typename F, typename... Policies>
7093  struct policy_wrapper {
7094  typedef std::index_sequence_for<Policies...> indices;
7095 
7097  std::tuple<Policies...> policies;
7098 
7099  template <typename Fx, typename... Args, meta::enable<meta::neg<std::is_same<meta::unqualified_t<Fx>, policy_wrapper>>> = meta::enabler>
7100  policy_wrapper(Fx&& fx, Args&&... args) : value(std::forward<Fx>(fx)), policies(std::forward<Args>(args)...) {
7101  }
7102 
7103  policy_wrapper(const policy_wrapper&) = default;
7104  policy_wrapper& operator=(const policy_wrapper&) = default;
7105  policy_wrapper(policy_wrapper&&) = default;
7106  policy_wrapper& operator=(policy_wrapper&&) = default;
7107  };
7108 
7109  template <typename F, typename... Args>
7110  auto policies(F&& f, Args&&... args) {
7111  return policy_wrapper<std::decay_t<F>, std::decay_t<Args>...>(std::forward<F>(f), std::forward<Args>(args)...);
7112  }
7113 
7114  namespace detail {
7115  template <typename T>
7117 
7118  template <typename T>
7119  inline constexpr bool is_policy_v = is_policy<T>::value;
7120  } // namespace detail
7121 } // namespace sol
7122 
7123 // end of sol/policies.hpp
7124 
7125 // beginning of sol/ebco.hpp
7126 
7127 #include <type_traits>
7128 #include <utility>
7129 #include <memory>
7130 
7131 namespace sol { namespace detail {
7132 
7133  template <typename T, std::size_t tag = 0, typename = void>
7134  struct ebco {
7136 
7137  ebco() = default;
7138  ebco(const ebco&) = default;
7139  ebco(ebco&&) = default;
7140  ebco& operator=(const ebco&) = default;
7141  ebco& operator=(ebco&&) = default;
7142  ebco(const T& v) noexcept(std::is_nothrow_copy_constructible_v<T>) : m_value(v) {};
7143  ebco(T&& v) noexcept(std::is_nothrow_move_constructible_v<T>) : m_value(std::move(v)) {};
7144  ebco& operator=(const T& v) noexcept(std::is_nothrow_copy_assignable_v<T>) {
7145  m_value = v;
7146  return *this;
7147  }
7148  ebco& operator=(T&& v) noexcept(std::is_nothrow_move_assignable_v<T>) {
7149  m_value = std::move(v);
7150  return *this;
7151  };
7152  template <typename Arg, typename... Args,
7153  typename = std::enable_if_t<
7154  !std::is_same_v<std::remove_reference_t<std::remove_cv_t<Arg>>,
7155  ebco> && !std::is_same_v<std::remove_reference_t<std::remove_cv_t<Arg>>, T> && (sizeof...(Args) > 0 || !std::is_convertible_v<Arg, T>)>>
7156  ebco(Arg&& arg, Args&&... args) noexcept(std::is_nothrow_constructible_v<T, Arg, Args...>)
7157  : m_value(std::forward<Arg>(arg), std::forward<Args>(args)...) {
7158  }
7159 
7160  T& value() & noexcept {
7161  return m_value;
7162  }
7163 
7164  T const& value() const& noexcept {
7165  return m_value;
7166  }
7167 
7168  T&& value() && noexcept {
7169  return std::move(m_value);
7170  }
7171  };
7172 
7173  template <typename T, std::size_t tag>
7174  struct ebco<T, tag, std::enable_if_t<!std::is_reference_v<T> && std::is_class_v<T> && !std::is_final_v<T>>> : T {
7175  ebco() = default;
7176  ebco(const ebco&) = default;
7177  ebco(ebco&&) = default;
7178  ebco(const T& v) noexcept(std::is_nothrow_copy_constructible_v<T>) : T(v) {};
7179  ebco(T&& v) noexcept(std::is_nothrow_move_constructible_v<T>) : T(std::move(v)) {};
7180  template <typename Arg, typename... Args,
7181  typename = std::enable_if_t<
7182  !std::is_same_v<std::remove_reference_t<std::remove_cv_t<Arg>>,
7183  ebco> && !std::is_same_v<std::remove_reference_t<std::remove_cv_t<Arg>>, T> && (sizeof...(Args) > 0 || !std::is_convertible_v<Arg, T>)>>
7184  ebco(Arg&& arg, Args&&... args) noexcept(std::is_nothrow_constructible_v<T, Arg, Args...>) : T(std::forward<Arg>(arg), std::forward<Args>(args)...) {
7185  }
7186 
7187  ebco& operator=(const ebco&) = default;
7188  ebco& operator=(ebco&&) = default;
7189  ebco& operator=(const T& v) noexcept(std::is_nothrow_copy_assignable_v<T>) {
7190  static_cast<T&>(*this) = v;
7191  return *this;
7192  }
7193  ebco& operator=(T&& v) noexcept(std::is_nothrow_move_assignable_v<T>) {
7194  static_cast<T&>(*this) = std::move(v);
7195  return *this;
7196  };
7197 
7198  T& value() & noexcept {
7199  return static_cast<T&>(*this);
7200  }
7201 
7202  T const& value() const& noexcept {
7203  return static_cast<T const&>(*this);
7204  }
7205 
7206  T&& value() && noexcept {
7207  return std::move(static_cast<T&>(*this));
7208  }
7209  };
7210 
7211  template <typename T, std::size_t tag>
7212  struct ebco<T&, tag> {
7213  private:
7214  T* m_ref;
7215 
7216  public:
7217  ebco() = default;
7218  ebco(const ebco&) = default;
7219  ebco(ebco&&) = default;
7220  ebco(T& v) noexcept : m_ref(std::addressof(v)) {};
7221 
7222  ebco& operator=(const ebco&) = default;
7223  ebco& operator=(ebco&&) = default;
7224  ebco& operator=(T& v) noexcept {
7225  m_ref = std::addressof(v);
7226  return *this;
7227  }
7228 
7229  T& value() const noexcept {
7230  return *(const_cast<ebco<T&, tag>&>(*this).m_ref);
7231  }
7232  };
7233 
7234  template <typename T, std::size_t tag>
7235  struct ebco<T&&, tag> {
7236  T&& ref;
7237 
7238  ebco() = default;
7239  ebco(const ebco&) = delete;
7240  ebco(ebco&&) = default;
7241  ebco(T&& v) noexcept : ref(v) {};
7242 
7243  ebco& operator=(const ebco&) = delete;
7244  ebco& operator=(ebco&&) = delete;
7245 
7246  T& value() & noexcept {
7247  return ref;
7248  }
7249 
7250  const T& value() const& noexcept {
7251  return ref;
7252  }
7253 
7254  T&& value() && noexcept {
7255  return std::move(ref);
7256  }
7257  };
7258 
7259 }} // namespace sol::detail
7260 
7261 // end of sol/ebco.hpp
7262 
7263 #include <array>
7264 #include <initializer_list>
7265 #include <string>
7266 #include <string_view>
7267 #include <optional>
7268 #include <memory>
7269 #if SOL_IS_ON(SOL_STD_VARIANT)
7270 #include <variant>
7271 #endif // variant shenanigans (thanks, Mac OSX)
7272 
7273 namespace sol {
7274  namespace d {
7275  // shortest possible hidden detail namespace
7276  // when types are transcribed, this saves
7277  // quite a bit of space, actually.
7278  // it's a little unfortunate, but here we are?
7279  template <typename T>
7280  struct u { };
7281  } // namespace d
7282 
7283  namespace detail {
7284 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE)
7285  typedef int (*lua_CFunction_noexcept)(lua_State* L) noexcept;
7286 #else
7287  typedef int (*lua_CFunction_noexcept)(lua_State* L);
7288 #endif // noexcept function type for lua_CFunction
7289 
7290  template <typename T>
7292  T& value;
7293 
7294  implicit_wrapper(T* value_) : value(*value_) {
7295  }
7296 
7297  implicit_wrapper(T& value_) : value(value_) {
7298  }
7299 
7300  operator T&() {
7301  return value;
7302  }
7303 
7304  operator T*() {
7305  return std::addressof(value);
7306  }
7307  };
7308 
7309  struct yield_tag_t { };
7310  inline constexpr yield_tag_t yield_tag {};
7311  } // namespace detail
7312 
7313  struct lua_nil_t { };
7314  inline constexpr lua_nil_t lua_nil {};
7316  return true;
7317  }
7319  return false;
7320  }
7321 #if SOL_IS_ON(SOL_NIL)
7322  using nil_t = lua_nil_t;
7323  inline constexpr const nil_t& nil = lua_nil;
7324 #endif
7325 
7326  namespace detail {
7327  struct non_lua_nil_t { };
7328  } // namespace detail
7329 
7330  struct metatable_key_t { };
7331  inline constexpr metatable_key_t metatable_key {};
7332 
7333  struct global_tag_t {
7334  } inline constexpr global_tag {};
7335 
7336  struct env_key_t { };
7337  inline constexpr env_key_t env_key {};
7338 
7339  struct no_metatable_t { };
7340  inline constexpr no_metatable_t no_metatable {};
7341 
7342  template <typename T>
7343  struct yielding_t {
7344  T func;
7345 
7346  yielding_t() = default;
7347  yielding_t(const yielding_t&) = default;
7348  yielding_t(yielding_t&&) = default;
7349  yielding_t& operator=(const yielding_t&) = default;
7350  yielding_t& operator=(yielding_t&&) = default;
7351  template <typename Arg,
7354  yielding_t(Arg&& arg) : func(std::forward<Arg>(arg)) {
7355  }
7356  template <typename Arg0, typename Arg1, typename... Args>
7357  yielding_t(Arg0&& arg0, Arg1&& arg1, Args&&... args) : func(std::forward<Arg0>(arg0), std::forward<Arg1>(arg1), std::forward<Args>(args)...) {
7358  }
7359  };
7360 
7361  template <typename F>
7363  return yielding_t<std::decay_t<F>>(std::forward<F>(f));
7364  }
7365 
7366  typedef std::remove_pointer_t<lua_CFunction> lua_CFunction_ref;
7367 
7368  template <typename T>
7369  struct non_null { };
7370 
7371  template <typename... Args>
7372  struct function_sig { };
7373 
7374  struct upvalue_index {
7375  int index;
7377  }
7378 
7379  operator int() const {
7380  return index;
7381  }
7382  };
7383 
7384  struct raw_index {
7385  int index;
7386  raw_index(int i) : index(i) {
7387  }
7388 
7389  operator int() const {
7390  return index;
7391  }
7392  };
7393 
7395  int index;
7396  absolute_index(lua_State* L, int idx) : index(lua_absindex(L, idx)) {
7397  }
7398 
7399  operator int() const {
7400  return index;
7401  }
7402  };
7403 
7404  struct ref_index {
7405  int index;
7406  ref_index(int idx) : index(idx) {
7407  }
7408 
7409  operator int() const {
7410  return index;
7411  }
7412  };
7413 
7414  struct stack_count {
7415  int count;
7416 
7417  stack_count(int cnt) : count(cnt) {
7418  }
7419  };
7420 
7422  void* value;
7423  lightuserdata_value(void* data) : value(data) {
7424  }
7425  operator void*() const {
7426  return value;
7427  }
7428  };
7429 
7431  private:
7432  void* m_value;
7433 
7434  public:
7435  userdata_value(void* data) : m_value(data) {
7436  }
7437 
7438  void* value() const {
7439  return m_value;
7440  }
7441 
7442  operator void*() const {
7443  return value();
7444  }
7445  };
7446 
7447  template <typename T>
7448  struct light {
7449  private:
7450  static_assert(!std::is_void_v<T>, "the type for light will never be void");
7451  T* m_value;
7452 
7453  public:
7454  light(T& x) : m_value(std::addressof(x)) {
7455  }
7456  light(T* x) : m_value(x) {
7457  }
7458  explicit light(void* x) : m_value(static_cast<T*>(x)) {
7459  }
7460 
7461  T* value() const {
7462  return m_value;
7463  }
7464 
7465  operator T*() const {
7466  return m_value;
7467  }
7468  operator T&() const {
7469  return *m_value;
7470  }
7471 
7472  void* void_value() const {
7473  return m_value;
7474  }
7475  };
7476 
7477  template <typename T>
7478  auto make_light(T& l) {
7480  return light<L>(l);
7481  }
7482 
7483  template <typename T>
7484  struct user : private detail::ebco<T> {
7485  private:
7487 
7488  public:
7489  using base_t::base_t;
7490 
7491  using base_t::value;
7492 
7493  operator std::add_pointer_t<std::remove_reference_t<T>>() {
7494  return std::addressof(this->base_t::value());
7495  }
7496 
7497  operator std::add_pointer_t<std::add_const_t<std::remove_reference_t<T>>>() const {
7498  return std::addressof(this->base_t::value());
7499  }
7500 
7501  operator std::add_lvalue_reference_t<T>() {
7502  return this->base_t::value();
7503  }
7504 
7505  operator std::add_const_t<std::add_lvalue_reference_t<T>>&() const {
7506  return this->base_t::value();
7507  }
7508  };
7509 
7510  template <typename T>
7511  auto make_user(T&& u) {
7513  return user<U>(std::forward<T>(u));
7514  }
7515 
7516  template <typename T>
7517  struct metatable_registry_key : private detail::ebco<T> {
7518  private:
7520 
7521  public:
7522  using base_t::base_t;
7523 
7524  using base_t::value;
7525  };
7526 
7527  template <typename T>
7528  auto meta_registry_key(T&& key) {
7529  typedef meta::unqualified_t<T> K;
7530  return metatable_registry_key<K>(std::forward<T>(key));
7531  }
7532 
7533  template <typename... Upvalues>
7534  struct closure {
7536  std::tuple<Upvalues...> upvalues;
7537  closure(lua_CFunction f, Upvalues... targetupvalues) : c_function(f), upvalues(std::forward<Upvalues>(targetupvalues)...) {
7538  }
7539  };
7540 
7541  template <>
7542  struct closure<> {
7545  closure(lua_CFunction f, int upvalue_count = 0) : c_function(f), upvalues(upvalue_count) {
7546  }
7547  };
7548 
7550 
7551  template <typename... Args>
7552  closure<Args...> make_closure(lua_CFunction f, Args&&... args) {
7553  return closure<Args...>(f, std::forward<Args>(args)...);
7554  }
7555 
7556  template <typename Sig, typename... Ps>
7558  std::tuple<Ps...> arguments;
7559  template <typename Arg, typename... Args, meta::disable<std::is_same<meta::unqualified_t<Arg>, function_arguments>> = meta::enabler>
7560  function_arguments(Arg&& arg, Args&&... args) : arguments(std::forward<Arg>(arg), std::forward<Args>(args)...) {
7561  }
7562  };
7563 
7564  template <typename Sig = function_sig<>, typename... Args>
7565  auto as_function(Args&&... args) {
7566  return function_arguments<Sig, std::decay_t<Args>...>(std::forward<Args>(args)...);
7567  }
7568 
7569  template <typename Sig = function_sig<>, typename... Args>
7570  auto as_function_reference(Args&&... args) {
7571  return function_arguments<Sig, Args...>(std::forward<Args>(args)...);
7572  }
7573 
7574  template <typename T>
7575  struct as_table_t : private detail::ebco<T> {
7576  private:
7578 
7579  public:
7580  as_table_t() = default;
7581  as_table_t(const as_table_t&) = default;
7582  as_table_t(as_table_t&&) = default;
7583  as_table_t& operator=(const as_table_t&) = default;
7584  as_table_t& operator=(as_table_t&&) = default;
7585  as_table_t(const meta::unqualified_t<T>& obj) noexcept(std::is_nothrow_constructible_v<base_t, const meta::unqualified_t<T>&>) : base_t(obj) {
7586  }
7587  as_table_t(meta::unqualified_t<T>&& obj) noexcept(std::is_nothrow_constructible_v<base_t, meta::unqualified_t<T>&&>) : base_t(std::move(obj)) {
7588  }
7589  template <typename Arg, typename... Args,
7591  !std::is_same_v<as_table_t, meta::unqualified_t<Arg>> && !std::is_same_v<meta::unqualified_t<T>, meta::unqualified_t<Arg>>>* = nullptr>
7592  as_table_t(Arg&& arg, Args&&... args) noexcept(std::is_nothrow_constructible_v<base_t, Arg, Args...>)
7593  : base_t(std::forward<Arg>(arg), std::forward<Args>(args)...) {
7594  }
7595 
7596  using base_t::value;
7597 
7598  operator std::add_lvalue_reference_t<T>() {
7599  return this->base_t::value();
7600  }
7601 
7602  operator std::add_const_t<std::add_lvalue_reference_t<T>>() const {
7603  return this->base_t::value();
7604  }
7605  };
7606 
7607  template <typename T>
7608  struct nested : private detail::ebco<T> {
7609  private:
7611 
7612  public:
7613  using nested_type = T;
7614 
7615  nested() = default;
7616  nested(const nested&) = default;
7617  nested(nested&&) = default;
7618  nested& operator=(const nested&) = default;
7619  nested& operator=(nested&&) = default;
7620  nested(const meta::unqualified_t<T>& obj) noexcept(std::is_nothrow_constructible_v<base_t, const meta::unqualified_t<T>&>) : base_t(obj) {
7621  }
7622  nested(meta::unqualified_t<T>&& obj) noexcept(std::is_nothrow_constructible_v<base_t, meta::unqualified_t<T>&&>) : base_t(std::move(obj)) {
7623  }
7624  template <typename Arg, typename... Args,
7626  !std::is_same_v<nested, meta::unqualified_t<Arg>> && !std::is_same_v<meta::unqualified_t<T>, meta::unqualified_t<Arg>>>* = nullptr>
7627  nested(Arg&& arg, Args&&... args) noexcept(std::is_nothrow_constructible_v<base_t, Arg, Args...>)
7628  : base_t(std::forward<Arg>(arg), std::forward<Args>(args)...) {
7629  }
7630 
7631  using base_t::value;
7632 
7633  operator std::add_lvalue_reference_t<T>() {
7634  return this->base_t::value();
7635  }
7636 
7637  operator std::add_const_t<std::add_lvalue_reference_t<T>>() const {
7638  return this->base_t::value();
7639  }
7640  };
7641 
7642  struct nested_tag_t { };
7643  constexpr inline nested_tag_t nested_tag {};
7644 
7645  template <typename T>
7646  as_table_t<T> as_table_ref(T&& container) {
7647  return as_table_t<T>(std::forward<T>(container));
7648  }
7649 
7650  template <typename T>
7652  return as_table_t<meta::unqualified_t<T>>(std::forward<T>(container));
7653  }
7654 
7655  template <typename T>
7656  nested<T> as_nested_ref(T&& container) {
7657  return nested<T>(std::forward<T>(container));
7658  }
7659 
7660  template <typename T>
7662  return nested<meta::unqualified_t<T>>(std::forward<T>(container));
7663  }
7664 
7665  template <typename T>
7666  struct as_container_t : private detail::ebco<T> {
7667  private:
7669 
7670  public:
7671  using type = T;
7672 
7673  as_container_t() = default;
7674  as_container_t(const as_container_t&) = default;
7675  as_container_t(as_container_t&&) = default;
7676  as_container_t& operator=(const as_container_t&) = default;
7677  as_container_t& operator=(as_container_t&&) = default;
7678 
7679  using base_t::base_t;
7680 
7681  using base_t::value;
7682 
7683  operator std::add_lvalue_reference_t<T>() {
7684  return value();
7685  }
7686  };
7687 
7688  template <typename T>
7689  auto as_container(T&& value) {
7690  return as_container_t<T>(std::forward<T>(value));
7691  }
7692 
7693  template <typename T>
7694  struct push_invoke_t : private detail::ebco<T> {
7695  private:
7697 
7698  public:
7699  push_invoke_t() = default;
7700  push_invoke_t(const push_invoke_t&) = default;
7701  push_invoke_t(push_invoke_t&&) = default;
7702  push_invoke_t& operator=(const push_invoke_t&) = default;
7703  push_invoke_t& operator=(push_invoke_t&&) = default;
7704 
7705  using base_t::base_t;
7706 
7707  using base_t::value;
7708  };
7709 
7710  template <typename Fx>
7711  auto push_invoke(Fx&& fx) {
7712  return push_invoke_t<Fx>(std::forward<Fx>(fx));
7713  }
7714 
7715  template <typename T>
7716  struct forward_as_value_t : private detail::ebco<T> {
7717  private:
7719 
7720  public:
7721  forward_as_value_t() = default;
7722  forward_as_value_t(const forward_as_value_t&) = default;
7724  forward_as_value_t& operator=(const forward_as_value_t&) = default;
7725  forward_as_value_t& operator=(forward_as_value_t&&) = default;
7726 
7727  using base_t::base_t;
7728 
7729  using base_t::value;
7730  };
7731 
7732  template <typename T>
7733  auto pass_as_value(T& value_ref_) {
7734  return forward_as_value_t<T>(value_ref_);
7735  }
7736 
7737  struct override_value_t { };
7739  struct update_if_empty_t { };
7741  struct create_if_nil_t { };
7743 
7744  namespace detail {
7745  enum insert_mode { none = 0x0, update_if_empty = 0x01, override_value = 0x02, create_if_nil = 0x04 };
7746 
7747  template <typename T, typename...>
7748  using is_insert_mode = std::integral_constant<bool,
7749  std::is_same_v<T, override_value_t> || std::is_same_v<T, update_if_empty_t> || std::is_same_v<T, create_if_nil_t>>;
7750 
7751  template <typename T, typename...>
7753  } // namespace detail
7754 
7755  struct this_state {
7757 
7758  this_state(lua_State* Ls) : L(Ls) {
7759  }
7760 
7761  operator lua_State*() const noexcept {
7762  return lua_state();
7763  }
7764 
7765  lua_State* operator->() const noexcept {
7766  return lua_state();
7767  }
7768 
7769  lua_State* lua_state() const noexcept {
7770  return L;
7771  }
7772  };
7773 
7776 
7778  }
7779 
7780  operator lua_State*() const noexcept {
7781  return lua_state();
7782  }
7783 
7784  lua_State* operator->() const noexcept {
7785  return lua_state();
7786  }
7787 
7788  lua_State* lua_state() const noexcept {
7789  return L;
7790  }
7791  };
7792 
7793  struct new_table {
7794  int sequence_hint = 0;
7795  int map_hint = 0;
7796 
7797  new_table() = default;
7798  new_table(const new_table&) = default;
7799  new_table(new_table&&) = default;
7800  new_table& operator=(const new_table&) = default;
7801  new_table& operator=(new_table&&) = default;
7802 
7803  new_table(int sequence_hint_, int map_hint_ = 0) noexcept : sequence_hint(sequence_hint_), map_hint(map_hint_) {
7804  }
7805  };
7806 
7807  const new_table create = {};
7808 
7809  enum class lib : unsigned char {
7810  // print, assert, and other base functions
7811  base,
7812  // require and other package functions
7813  package,
7814  // coroutine functions and utilities
7815  coroutine,
7816  // string library
7817  string,
7818  // functionality from the OS
7819  os,
7820  // all things math
7821  math,
7822  // the table manipulator and observer functions
7823  table,
7824  // the debug library
7825  debug,
7826  // the bit library: different based on which you're using
7827  bit32,
7828  // input/output library
7829  io,
7830  // LuaJIT only
7831  ffi,
7832  // LuaJIT only
7833  jit,
7834  // library for handling utf8: new to Lua
7835  utf8,
7836  // do not use
7837  count
7838  };
7839 
7840  enum class call_syntax { dot = 0, colon = 1 };
7841 
7842  enum class load_mode {
7843  any = 0,
7844  text = 1,
7845  binary = 2,
7846  };
7847 
7848  enum class call_status : int {
7849  ok = LUA_OK,
7850  yielded = LUA_YIELD,
7851  runtime = LUA_ERRRUN,
7852  memory = LUA_ERRMEM,
7853  handler = LUA_ERRERR,
7854  gc = LUA_ERRGCMM,
7856  file = LUA_ERRFILE,
7857  };
7858 
7859  enum class thread_status : int {
7860  ok = LUA_OK,
7861  yielded = LUA_YIELD,
7862  runtime = LUA_ERRRUN,
7863  memory = LUA_ERRMEM,
7864  gc = LUA_ERRGCMM,
7865  handler = LUA_ERRERR,
7866  dead = -1,
7867  };
7868 
7869  enum class load_status : int {
7870  ok = LUA_OK,
7872  memory = LUA_ERRMEM,
7873  gc = LUA_ERRGCMM,
7874  file = LUA_ERRFILE,
7875  };
7876 
7877  enum class gc_mode : int {
7878  incremental = 0,
7879  generational = 1,
7881  };
7882 
7883  enum class type : int {
7884  none = LUA_TNONE,
7885  lua_nil = LUA_TNIL,
7886 #if SOL_IS_ON(SOL_NIL)
7887  nil = lua_nil,
7888 #endif // Objective C/C++ Keyword that's found in OSX SDK and OBJC -- check for all forms to protect
7889  string = LUA_TSTRING,
7890  number = LUA_TNUMBER,
7891  thread = LUA_TTHREAD,
7892  boolean = LUA_TBOOLEAN,
7893  function = LUA_TFUNCTION,
7896  table = LUA_TTABLE,
7897  poly = -0xFFFF
7898  };
7899 
7900  inline const std::string& to_string(call_status c) {
7901  static const std::array<std::string, 10> names { { "ok",
7902  "yielded",
7903  "runtime",
7904  "memory",
7905  "handler",
7906  "gc",
7907  "syntax",
7908  "file",
7909  "CRITICAL_EXCEPTION_FAILURE",
7910  "CRITICAL_INDETERMINATE_STATE_FAILURE" } };
7911  switch (c) {
7912  case call_status::ok:
7913  return names[0];
7914  case call_status::yielded:
7915  return names[1];
7916  case call_status::runtime:
7917  return names[2];
7918  case call_status::memory:
7919  return names[3];
7920  case call_status::handler:
7921  return names[4];
7922  case call_status::gc:
7923  return names[5];
7924  case call_status::syntax:
7925  return names[6];
7926  case call_status::file:
7927  return names[7];
7928  }
7929  if (static_cast<std::ptrdiff_t>(c) == -1) {
7930  // One of the many cases where a critical exception error has occurred
7931  return names[8];
7932  }
7933  return names[9];
7934  }
7935 
7937  switch (c) {
7938  case call_status::ok:
7939  case call_status::yielded:
7940  case call_status::runtime:
7941  case call_status::memory:
7942  case call_status::handler:
7943  case call_status::gc:
7944  case call_status::syntax:
7945  case call_status::file:
7946  return false;
7947  }
7948  return true;
7949  }
7950 
7951  inline const std::string& to_string(load_status c) {
7952  static const std::array<std::string, 7> names {
7953  { "ok", "memory", "gc", "syntax", "file", "CRITICAL_EXCEPTION_FAILURE", "CRITICAL_INDETERMINATE_STATE_FAILURE" }
7954  };
7955  switch (c) {
7956  case load_status::ok:
7957  return names[0];
7958  case load_status::memory:
7959  return names[1];
7960  case load_status::gc:
7961  return names[2];
7962  case load_status::syntax:
7963  return names[3];
7964  case load_status::file:
7965  return names[4];
7966  }
7967  if (static_cast<int>(c) == -1) {
7968  // One of the many cases where a critical exception error has occurred
7969  return names[5];
7970  }
7971  return names[6];
7972  }
7973 
7974  inline const std::string& to_string(load_mode c) {
7975  static const std::array<std::string, 3> names { {
7976  "bt",
7977  "t",
7978  "b",
7979  } };
7980  return names[static_cast<std::size_t>(c)];
7981  }
7982 
7983  enum class meta_function : unsigned {
7984  construct,
7985  index,
7986  new_index,
7987  mode,
7988  call,
7989  call_function = call,
7990  metatable,
7991  to_string,
7992  length,
7993  unary_minus,
7994  addition,
7995  subtraction,
7997  division,
7998  modulus,
7999  power_of,
8000  involution = power_of,
8001  concatenation,
8002  equal_to,
8003  less_than,
8009  bitwise_not,
8010  bitwise_and,
8011  bitwise_or,
8012  bitwise_xor,
8013  pairs,
8014  ipairs,
8015  next,
8016  type,
8017  type_info,
8019  storage,
8020  gc_names,
8021  static_index,
8023  };
8024 
8026 
8027  inline const std::array<std::string, 37>& meta_function_names() {
8028  static const std::array<std::string, 37> names = { { "new",
8029  "__index",
8030  "__newindex",
8031  "__mode",
8032  "__call",
8033  "__metatable",
8034  "__tostring",
8035  "__len",
8036  "__unm",
8037  "__add",
8038  "__sub",
8039  "__mul",
8040  "__div",
8041  "__mod",
8042  "__pow",
8043  "__concat",
8044  "__eq",
8045  "__lt",
8046  "__le",
8047  "__gc",
8048 
8049  "__idiv",
8050  "__shl",
8051  "__shr",
8052  "__bnot",
8053  "__band",
8054  "__bor",
8055  "__bxor",
8056 
8057  "__pairs",
8058  "__ipairs",
8059  "next",
8060 
8061  "__type",
8062  "__typeinfo",
8063  "__sol.call_new",
8064  "__sol.storage",
8065  "__sol.gc_names",
8066  "__sol.static_index",
8067  "__sol.static_new_index" } };
8068  return names;
8069  }
8070 
8071  inline const std::string& to_string(meta_function mf) {
8072  return meta_function_names()[static_cast<std::size_t>(mf)];
8073  }
8074 
8075  inline type type_of(lua_State* L, int index) {
8076  return static_cast<type>(lua_type(L, index));
8077  }
8078 
8079  inline std::string type_name(lua_State* L, type t) {
8080  return lua_typename(L, static_cast<int>(t));
8081  }
8082 
8083  template <typename T>
8085  : std::integral_constant<bool,
8086  (std::is_base_of_v<stateless_stack_reference, T> || std::is_base_of_v<stateless_reference, T>)&&(
8087  !std::is_base_of_v<stack_reference, T> && !std::is_base_of_v<reference, T> && !std::is_base_of_v<main_reference, T>)> { };
8088 
8089  template <typename T>
8091 
8092  template <typename T>
8094  : std::integral_constant<bool,
8095  std::is_base_of_v<reference,
8096  T> || std::is_base_of_v<main_reference, T> || std::is_base_of_v<stack_reference, T> || std::is_base_of_v<stateless_stack_reference, T> || std::is_base_of_v<stateless_reference, T>> {
8097  };
8098 
8099  template <typename T>
8101 
8102  template <typename T>
8103  struct is_lua_reference_or_proxy : std::integral_constant<bool, is_lua_reference_v<T> || meta::is_specialization_of_v<T, table_proxy>> { };
8104 
8105  template <typename T>
8107 
8108  template <typename T>
8110  : std::integral_constant<bool,
8111  std::is_same_v<meta::unqualified_t<T>,
8112  this_state> || std::is_same_v<meta::unqualified_t<T>, this_main_state> || std::is_same_v<meta::unqualified_t<T>, this_environment> || std::is_same_v<meta::unqualified_t<T>, variadic_args>> {
8113  };
8114 
8115  template <typename T>
8117 
8118  template <typename T>
8119  struct is_variadic_arguments : meta::any<std::is_same<T, variadic_args>, meta::is_optional<T>> { };
8120 
8121  template <typename T>
8123  : std::integral_constant<bool,
8124  !std::is_same_v<state_view,
8125  T> && !std::is_same_v<state, T> && !meta::is_initializer_list_v<T> && !meta::is_string_like_v<T> && !meta::is_string_literal_array_v<T> && !is_transparent_argument_v<T> && !is_lua_reference_v<T> && (meta::has_begin_end_v<T> || std::is_array_v<T>)> {
8126  };
8127 
8128  template <typename T>
8129  constexpr inline bool is_container_v = is_container<T>::value;
8130 
8131  template <typename T>
8132  struct is_to_stringable : meta::any<meta::supports_to_string_member<meta::unqualified_t<T>>, meta::supports_adl_to_string<meta::unqualified_t<T>>,
8133  meta::supports_op_left_shift<std::ostream, meta::unqualified_t<T>>> { };
8134 
8135  template <typename T>
8137 
8138  template <typename T>
8140 
8141  template <typename T>
8142  inline constexpr bool is_callable_v = is_callable<T>::value;
8143 
8144  namespace detail {
8145  template <typename T, typename = void>
8146  struct lua_type_of : std::integral_constant<type, type::userdata> { };
8147 
8148  template <typename C, typename T, typename A>
8149  struct lua_type_of<std::basic_string<C, T, A>> : std::integral_constant<type, type::string> { };
8150 
8151  template <typename C, typename T>
8152  struct lua_type_of<basic_string_view<C, T>> : std::integral_constant<type, type::string> { };
8153 
8154  template <std::size_t N>
8155  struct lua_type_of<char[N]> : std::integral_constant<type, type::string> { };
8156 
8157  template <std::size_t N>
8158  struct lua_type_of<wchar_t[N]> : std::integral_constant<type, type::string> { };
8159 
8160 #if SOL_IS_ON(SOL_CHAR8_T)
8161  template <std::size_t N>
8162  struct lua_type_of<char8_t[N]> : std::integral_constant<type, type::string> { };
8163 #endif
8164 
8165  template <std::size_t N>
8166  struct lua_type_of<char16_t[N]> : std::integral_constant<type, type::string> { };
8167 
8168  template <std::size_t N>
8169  struct lua_type_of<char32_t[N]> : std::integral_constant<type, type::string> { };
8170 
8171  template <>
8172  struct lua_type_of<char> : std::integral_constant<type, type::string> { };
8173 
8174  template <>
8175  struct lua_type_of<wchar_t> : std::integral_constant<type, type::string> { };
8176 
8177 #if SOL_IS_ON(SOL_CHAR8_T)
8178  template <>
8179  struct lua_type_of<char8_t> : std::integral_constant<type, type::string> { };
8180 #endif
8181 
8182  template <>
8183  struct lua_type_of<char16_t> : std::integral_constant<type, type::string> { };
8184 
8185  template <>
8186  struct lua_type_of<char32_t> : std::integral_constant<type, type::string> { };
8187 
8188  template <>
8189  struct lua_type_of<const char*> : std::integral_constant<type, type::string> { };
8190 
8191  template <>
8192  struct lua_type_of<const wchar_t*> : std::integral_constant<type, type::string> { };
8193 
8194 #if SOL_IS_ON(SOL_CHAR8_T)
8195  template <>
8196  struct lua_type_of<const char8_t*> : std::integral_constant<type, type::string> { };
8197 #endif
8198 
8199  template <>
8200  struct lua_type_of<const char16_t*> : std::integral_constant<type, type::string> { };
8201 
8202  template <>
8203  struct lua_type_of<const char32_t*> : std::integral_constant<type, type::string> { };
8204 
8205  template <>
8206  struct lua_type_of<bool> : std::integral_constant<type, type::boolean> { };
8207 
8208  template <>
8209  struct lua_type_of<lua_nil_t> : std::integral_constant<type, type::lua_nil> { };
8210 
8211  template <>
8212  struct lua_type_of<nullopt_t> : std::integral_constant<type, type::lua_nil> { };
8213 
8214  template <>
8215  struct lua_type_of<lua_value> : std::integral_constant<type, type::poly> { };
8216 
8217  template <>
8218  struct lua_type_of<detail::non_lua_nil_t> : std::integral_constant<type, type::poly> { };
8219 
8220  template <>
8221  struct lua_type_of<std::nullptr_t> : std::integral_constant<type, type::lua_nil> { };
8222 
8223  template <>
8224  struct lua_type_of<error> : std::integral_constant<type, type::string> { };
8225 
8226  template <bool b, typename Base>
8227  struct lua_type_of<basic_table_core<b, Base>> : std::integral_constant<type, type::table> { };
8228 
8229  template <typename Base>
8230  struct lua_type_of<basic_lua_table<Base>> : std::integral_constant<type, type::table> { };
8231 
8232  template <typename Base>
8233  struct lua_type_of<basic_metatable<Base>> : std::integral_constant<type, type::table> { };
8234 
8235  template <typename T, typename Base>
8236  struct lua_type_of<basic_usertype<T, Base>> : std::integral_constant<type, type::table> { };
8237 
8238  template <>
8239  struct lua_type_of<metatable_key_t> : std::integral_constant<type, type::table> { };
8240 
8241  template <typename B>
8242  struct lua_type_of<basic_environment<B>> : std::integral_constant<type, type::poly> { };
8243 
8244  template <>
8245  struct lua_type_of<env_key_t> : std::integral_constant<type, type::poly> { };
8246 
8247  template <>
8248  struct lua_type_of<new_table> : std::integral_constant<type, type::table> { };
8249 
8250  template <typename T>
8251  struct lua_type_of<as_table_t<T>> : std::integral_constant<type, type::table> { };
8252 
8253  template <typename T>
8254  struct lua_type_of<std::initializer_list<T>> : std::integral_constant<type, type::table> { };
8255 
8256  template <bool b>
8257  struct lua_type_of<basic_reference<b>> : std::integral_constant<type, type::poly> { };
8258 
8259  template <>
8260  struct lua_type_of<stack_reference> : std::integral_constant<type, type::poly> { };
8261 
8262  template <typename Base>
8263  struct lua_type_of<basic_object<Base>> : std::integral_constant<type, type::poly> { };
8264 
8265  template <typename... Args>
8266  struct lua_type_of<std::tuple<Args...>> : std::integral_constant<type, type::poly> { };
8267 
8268  template <typename A, typename B>
8269  struct lua_type_of<std::pair<A, B>> : std::integral_constant<type, type::poly> { };
8270 
8271  template <>
8272  struct lua_type_of<void*> : std::integral_constant<type, type::lightuserdata> { };
8273 
8274  template <>
8275  struct lua_type_of<const void*> : std::integral_constant<type, type::lightuserdata> { };
8276 
8277  template <>
8278  struct lua_type_of<lightuserdata_value> : std::integral_constant<type, type::lightuserdata> { };
8279 
8280  template <>
8281  struct lua_type_of<userdata_value> : std::integral_constant<type, type::userdata> { };
8282 
8283  template <typename T>
8284  struct lua_type_of<light<T>> : std::integral_constant<type, type::lightuserdata> { };
8285 
8286  template <typename T>
8287  struct lua_type_of<user<T>> : std::integral_constant<type, type::userdata> { };
8288 
8289  template <typename Base>
8290  struct lua_type_of<basic_lightuserdata<Base>> : std::integral_constant<type, type::lightuserdata> { };
8291 
8292  template <typename Base>
8293  struct lua_type_of<basic_userdata<Base>> : std::integral_constant<type, type::userdata> { };
8294 
8295  template <>
8296  struct lua_type_of<lua_CFunction> : std::integral_constant<type, type::function> { };
8297 
8298  template <>
8299  struct lua_type_of<std::remove_pointer_t<lua_CFunction>> : std::integral_constant<type, type::function> { };
8300 
8301  template <typename Base, bool aligned>
8302  struct lua_type_of<basic_function<Base, aligned>> : std::integral_constant<type, type::function> { };
8303 
8304  template <typename Base, bool aligned, typename Handler>
8305  struct lua_type_of<basic_protected_function<Base, aligned, Handler>> : std::integral_constant<type, type::function> { };
8306 
8307  template <typename Base>
8308  struct lua_type_of<basic_coroutine<Base>> : std::integral_constant<type, type::function> { };
8309 
8310  template <typename Base>
8311  struct lua_type_of<basic_thread<Base>> : std::integral_constant<type, type::thread> { };
8312 
8313  template <typename Signature>
8314  struct lua_type_of<std::function<Signature>> : std::integral_constant<type, type::function> { };
8315 
8316  template <typename T>
8317  struct lua_type_of<optional<T>> : std::integral_constant<type, type::poly> { };
8318 
8319  template <typename T>
8320  struct lua_type_of<std::optional<T>> : std::integral_constant<type, type::poly> { };
8321 
8322  template <>
8323  struct lua_type_of<variadic_args> : std::integral_constant<type, type::poly> { };
8324 
8325  template <>
8326  struct lua_type_of<variadic_results> : std::integral_constant<type, type::poly> { };
8327 
8328  template <>
8329  struct lua_type_of<stack_count> : std::integral_constant<type, type::poly> { };
8330 
8331  template <>
8332  struct lua_type_of<this_state> : std::integral_constant<type, type::poly> { };
8333 
8334  template <>
8335  struct lua_type_of<this_main_state> : std::integral_constant<type, type::poly> { };
8336 
8337  template <>
8338  struct lua_type_of<this_environment> : std::integral_constant<type, type::poly> { };
8339 
8340  template <>
8341  struct lua_type_of<type> : std::integral_constant<type, type::poly> { };
8342 
8343 #if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE)
8344  template <typename T>
8345  struct lua_type_of<T*> : std::integral_constant<type, std::is_function_v<T> ? type::function : type::userdata> { };
8346 #else
8347  template <typename T>
8348  struct lua_type_of<T*> : std::integral_constant<type, type::userdata> { };
8349 #endif
8350 
8351  template <typename T>
8352  struct lua_type_of<T, std::enable_if_t<std::is_arithmetic_v<T> || std::is_same_v<T, lua_Number> || std::is_same_v<T, lua_Integer>>>
8353  : std::integral_constant<type, type::number> { };
8354 
8355  template <typename T>
8356  struct lua_type_of<T, std::enable_if_t<std::is_function_v<T>>> : std::integral_constant<type, type::function> { };
8357 
8358  template <typename T>
8359  struct lua_type_of<T, std::enable_if_t<std::is_enum_v<T>>> : std::integral_constant<type, type::number> { };
8360 
8361  template <>
8362  struct lua_type_of<meta_function> : std::integral_constant<type, type::string> { };
8363 
8364 #if SOL_IS_ON(SOL_STD_VARIANT)
8365  template <typename... Tn>
8366  struct lua_type_of<std::variant<Tn...>> : std::integral_constant<type, type::poly> { };
8367 #endif // std::variant deployment sucks on Clang
8368 
8369  template <typename T>
8370  struct lua_type_of<nested<T>> : meta::conditional_t<::sol::is_container_v<T>, std::integral_constant<type, type::table>, lua_type_of<T>> { };
8371 
8372  template <typename C, C v, template <typename...> class V, typename... Args>
8373  struct accumulate : std::integral_constant<C, v> { };
8374 
8375  template <typename C, C v, template <typename...> class V, typename T, typename... Args>
8376  struct accumulate<C, v, V, T, Args...> : accumulate<C, v + V<T>::value, V, Args...> { };
8377 
8378  template <typename C, C v, template <typename...> class V, typename List>
8380 
8381  template <typename C, C v, template <typename...> class V, typename... Args>
8382  struct accumulate_list<C, v, V, types<Args...>> : accumulate<C, v, V, Args...> { };
8383  } // namespace detail
8384 
8385  template <typename T>
8388  };
8389 
8390  template <typename T>
8392 
8393  template <typename T>
8394  struct lua_size : std::integral_constant<int, 1> {
8396  };
8397 
8398  template <typename A, typename B>
8399  struct lua_size<std::pair<A, B>> : std::integral_constant<int, lua_size<A>::value + lua_size<B>::value> { };
8400 
8401  template <typename... Args>
8402  struct lua_size<std::tuple<Args...>> : std::integral_constant<int, detail::accumulate<int, 0, lua_size, Args...>::value> { };
8403 
8404  template <typename T>
8405  inline constexpr int lua_size_v = lua_size<T>::value;
8406 
8407  namespace detail {
8408  // MSVC's decltype detection is broken, which breaks other
8409  // parts of the code. So we add more workarounds. The moment it's fixed,
8410  // we take it away and break everyone that doesn't upgrade.
8411  template <typename T>
8415 
8416  template <typename T>
8418  } // namespace detail
8419 
8420  template <typename T>
8422  : std::integral_constant<bool,
8423  type::userdata
8424  != lua_type_of_v<
8425  T> || ((type::userdata == lua_type_of_v<T>)&&meta::meta_detail::has_internal_marker_v<lua_type_of<T>> && !meta::meta_detail::has_internal_marker_v<lua_size<T>>)
8426  || is_lua_reference_or_proxy_v<T> || meta::is_specialization_of_v<T, std::tuple> || meta::is_specialization_of_v<T, std::pair>> { };
8427 
8428  template <typename T>
8430 
8431  template <typename T>
8433 #if SOL_IS_ON(SOL_FUNCTION_CALL_VALUE_SEMANTICS)
8434  : std::true_type {
8435  };
8436 #else
8437  : std::false_type {
8438  };
8439 #endif
8440 
8441  template <typename T>
8443 
8444  template <typename T>
8445  struct is_main_threaded : std::is_base_of<main_reference, T> { };
8446 
8447  template <typename T>
8449 
8450  template <typename T>
8451  struct is_stack_based : std::is_base_of<stack_reference, T> { };
8452  template <>
8454  template <>
8456  template <>
8458  template <>
8460  template <>
8462  template <>
8464 
8465  template <typename T>
8467 
8468  template <typename T>
8470  template <>
8472  template <>
8474  template <typename T>
8475  struct is_lua_primitive<std::reference_wrapper<T>> : std::true_type { };
8476  template <typename T>
8478  template <typename T>
8480  template <typename T>
8482  template <typename T>
8484  template <typename T>
8486  template <typename T>
8488  template <>
8490  template <>
8492  template <>
8494  template <>
8496  template <typename T>
8498 
8499  template <typename T>
8500  struct is_lua_index : std::is_integral<T> { };
8501  template <>
8503  template <>
8505  template <>
8507  template <>
8509 
8510  template <typename Signature>
8511  struct lua_bind_traits : meta::bind_traits<Signature> {
8512  private:
8514 
8515  public:
8516  typedef std::integral_constant<bool, meta::count_for<is_variadic_arguments, typename base_t::args_list>::value != 0> runtime_variadics_t;
8517  static const std::size_t true_arity = base_t::arity;
8520  static const std::size_t true_free_arity = base_t::free_arity;
8523  };
8524 
8525  template <typename T>
8527  template <bool x, typename T>
8529  template <typename T>
8531 
8532  template <typename T>
8533  inline constexpr bool is_table_v = is_table<T>::value;
8534 
8535  template <typename T>
8537  template <typename T>
8539 
8540  template <typename T>
8542 
8543  template <typename T>
8545  template <bool x, typename T>
8546  struct is_stack_table<basic_table_core<x, T>> : std::integral_constant<bool, std::is_base_of_v<stack_reference, T>> { };
8547  template <typename T>
8548  struct is_stack_table<basic_lua_table<T>> : std::integral_constant<bool, std::is_base_of_v<stack_reference, T>> { };
8549 
8550  template <typename T>
8552 
8553  template <typename T>
8555  template <typename T, bool aligned>
8556  struct is_function<basic_function<T, aligned>> : std::true_type { };
8557  template <typename T, bool aligned, typename Handler>
8558  struct is_function<basic_protected_function<T, aligned, Handler>> : std::true_type { };
8559 
8560  template <typename T>
8562 
8563  template <typename T>
8565 
8566  template <typename T>
8568 
8569  template <typename T>
8570  inline constexpr bool is_userdata_v = is_userdata<T>::value;
8571 
8572  template <typename T>
8573  using is_environment = std::integral_constant<bool, is_userdata_v<T> || is_table_v<T> || meta::is_specialization_of_v<T, basic_environment>>;
8574 
8575  template <typename T>
8577 
8578  template <typename T>
8579  using is_table_like = std::integral_constant<bool, is_table_v<T> || is_environment_v<T> || is_userdata_v<T>>;
8580 
8581  template <typename T>
8582  inline constexpr bool is_table_like_v = is_table_like<T>::value;
8583 
8584  template <typename T>
8586  : std::integral_constant<bool,
8587  (SOL_IS_ON(SOL_DEFAULT_AUTOMAGICAL_USERTYPES))
8588  || (std::is_array_v<
8589  meta::unqualified_t<T>> || (!std::is_same_v<meta::unqualified_t<T>, state> && !std::is_same_v<meta::unqualified_t<T>, state_view>))> {
8590  };
8591 
8592  template <typename T>
8593  inline type type_of() {
8594  return lua_type_of<meta::unqualified_t<T>>::value;
8595  }
8596 
8597  namespace detail {
8598  template <typename T>
8600 
8601  template <typename... Args>
8603 
8604  template <typename... Args>
8606 
8607  template <>
8609 
8610  template <typename T>
8612 
8613  template <typename T>
8615 
8616  template <typename... Args>
8618 
8619  template <typename T>
8620  struct is_constructor<protect_t<T>> : is_constructor<meta::unqualified_t<T>> { };
8621 
8622  template <typename F, typename... Policies>
8623  struct is_constructor<policy_wrapper<F, Policies...>> : is_constructor<meta::unqualified_t<F>> { };
8624 
8625  template <typename T>
8627 
8628  template <typename... Args>
8630 
8631  template <typename... Args>
8632  inline constexpr bool any_is_constructor_v = any_is_constructor<Args...>::value;
8633 
8634  template <typename T>
8636 
8637  template <typename Fx>
8639 
8640  template <typename... Args>
8642 
8643  template <typename... Args>
8644  inline constexpr bool any_is_destructor_v = any_is_destructor<Args...>::value;
8645  } // namespace detail
8646 
8647  template <typename T>
8648  using is_lua_c_function = meta::any<std::is_same<lua_CFunction, T>, std::is_same<detail::lua_CFunction_noexcept, T>, std::is_same<lua_CFunction_ref, T>>;
8649 
8650  template <typename T>
8652 
8653  enum class automagic_flags : unsigned {
8654  none = 0x000u,
8655  default_constructor = 0x001,
8656  destructor = 0x002u,
8657  pairs_operator = 0x004u,
8658  to_string_operator = 0x008u,
8659  call_operator = 0x010u,
8660  less_than_operator = 0x020u,
8662  length_operator = 0x080u,
8663  equal_to_operator = 0x100u,
8666  };
8667 
8669  return static_cast<automagic_flags>(
8670  static_cast<std::underlying_type_t<automagic_flags>>(left) | static_cast<std::underlying_type_t<automagic_flags>>(right));
8671  }
8672 
8674  return static_cast<automagic_flags>(
8675  static_cast<std::underlying_type_t<automagic_flags>>(left) & static_cast<std::underlying_type_t<automagic_flags>>(right));
8676  }
8677 
8679  left = left | right;
8680  return left;
8681  }
8682 
8684  left = left & right;
8685  return left;
8686  }
8687 
8688  template <typename Left, typename Right>
8689  constexpr bool has_flag(Left left, Right right) noexcept {
8690  return (left & right) == right;
8691  }
8692 
8693  template <typename Left, typename Right>
8694  constexpr bool has_any_flag(Left left, Right right) noexcept {
8695  return (left & right) != static_cast<Left>(static_cast<std::underlying_type_t<Left>>(0));
8696  }
8697 
8698  template <typename Left, typename Right>
8699  constexpr auto clear_flags(Left left, Right right) noexcept {
8700  return static_cast<Left>(static_cast<std::underlying_type_t<Left>>(left) & ~static_cast<std::underlying_type_t<Right>>(right));
8701  }
8702 
8704  bool default_constructor = true;
8705  bool destructor = true;
8706  bool pairs_operator = true;
8707  bool to_string_operator = true;
8708  bool call_operator = true;
8709  bool less_than_operator = true;
8711  bool length_operator = true;
8712  bool equal_to_operator = true;
8713  };
8714 
8715  template <automagic_flags compile_time_defaults = automagic_flags::all>
8717 
8718 } // namespace sol
8719 
8720 // end of sol/types.hpp
8721 
8722 #include <exception>
8723 #include <cstring>
8724 
8725 #if SOL_IS_ON(SOL_PRINT_ERRORS)
8726 #include <iostream>
8727 #endif
8728 
8729 namespace sol {
8730  // must push a single object to be the error object
8731  // NOTE: the VAST MAJORITY of all Lua libraries -- C or otherwise -- expect a string for the type of error
8732  // break this convention at your own risk
8734 
8735  namespace detail {
8736  inline const char (&default_exception_handler_name())[11] {
8737  static const char name[11] = "sol.\xE2\x98\xA2\xE2\x98\xA2";
8738  return name;
8739  }
8740 
8741  // must push at least 1 object on the stack
8743 #if SOL_IS_ON(SOL_PRINT_ERRORS)
8744  std::cerr << "[sol2] An exception occurred: ";
8745  std::cerr.write(what.data(), static_cast<std::streamsize>(what.size()));
8746  std::cerr << std::endl;
8747 #endif
8748  lua_pushlstring(L, what.data(), what.size());
8749  return 1;
8750  }
8751 
8754  type t = static_cast<type>(lua_type(L, -1));
8755  if (t != type::lightuserdata) {
8756  lua_pop(L, 1);
8757  return default_exception_handler(L, std::move(maybe_ex), std::move(what));
8758  }
8759  void* vfunc = lua_touserdata(L, -1);
8760  lua_pop(L, 1);
8761  if (vfunc == nullptr) {
8762  return default_exception_handler(L, std::move(maybe_ex), std::move(what));
8763  }
8764  exception_handler_function exfunc = reinterpret_cast<exception_handler_function>(vfunc);
8765  return exfunc(L, std::move(maybe_ex), std::move(what));
8766  }
8767 
8768 #if SOL_IS_OFF(SOL_EXCEPTIONS)
8769  template <lua_CFunction f>
8770  int static_trampoline(lua_State* L) noexcept {
8771  return f(L);
8772  }
8773 
8774 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE)
8775  template <lua_CFunction_noexcept f>
8776  int static_trampoline_noexcept(lua_State* L) noexcept {
8777  return f(L);
8778  }
8779 #else
8780  template <lua_CFunction f>
8781  int static_trampoline_noexcept(lua_State* L) noexcept {
8782  return f(L);
8783  }
8784 #endif
8785 
8786  template <typename Fx, typename... Args>
8787  int trampoline(lua_State* L, Fx&& f, Args&&... args) noexcept {
8788  return f(L, std::forward<Args>(args)...);
8789  }
8790 
8791  inline int c_trampoline(lua_State* L, lua_CFunction f) noexcept {
8792  return trampoline(L, f);
8793  }
8794 #else
8795 
8797 #if SOL_IS_ON(SOL_PROPAGATE_EXCEPTIONS)
8798  return f(L);
8799 #else
8800  try {
8801  return f(L);
8802  }
8803  catch (const char* cs) {
8805  }
8806  catch (const std::string& s) {
8808  }
8809  catch (const std::exception& e) {
8811  }
8812 #if SOL_IS_ON(SOL_EXCEPTIONS_CATCH_ALL)
8813  // LuaJIT cannot have the catchall when the safe propagation is on
8814  // but LuaJIT will swallow all C++ errors
8815  // if we don't at least catch std::exception ones
8816  catch (...) {
8817  call_exception_handler(L, optional<const std::exception&>(nullopt), "caught (...) exception");
8818  }
8819 #endif // LuaJIT cannot have the catchall, but we must catch std::exceps for it
8820  return lua_error(L);
8821 #endif // Safe exceptions
8822  }
8823 
8824  template <lua_CFunction f>
8826  return lua_cfunction_trampoline(L, f);
8827  }
8828 
8829 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE)
8830  template <lua_CFunction_noexcept f>
8832  return f(L);
8833  }
8834 #else
8835  template <lua_CFunction f>
8836  int static_trampoline_noexcept(lua_State* L) noexcept {
8837  return f(L);
8838  }
8839 #endif
8840 
8841  template <typename Fx, typename... Args>
8842  int trampoline(lua_State* L, Fx&& f, Args&&... args) {
8843  if constexpr (meta::bind_traits<meta::unqualified_t<Fx>>::is_noexcept) {
8844  return f(L, std::forward<Args>(args)...);
8845  }
8846  else {
8847 #if SOL_IS_ON(SOL_PROPAGATE_EXCEPTIONS)
8848  return f(L, std::forward<Args>(args)...);
8849 #else
8850  try {
8851  return f(L, std::forward<Args>(args)...);
8852  }
8853  catch (const char* cs) {
8855  }
8856  catch (const std::string& s) {
8858  }
8859  catch (const std::exception& e) {
8861  }
8862 #if SOL_IS_ON(SOL_EXCEPTIONS_CATCH_ALL)
8863  // LuaJIT cannot have the catchall when the safe propagation is on
8864  // but LuaJIT will swallow all C++ errors
8865  // if we don't at least catch std::exception ones
8866  catch (...) {
8867  call_exception_handler(L, optional<const std::exception&>(nullopt), "caught (...) exception");
8868  }
8869 #endif
8870  return lua_error(L);
8871 #endif
8872  }
8873  }
8874 
8876  return trampoline(L, f);
8877  }
8878 #endif // Exceptions vs. No Exceptions
8879 
8880  template <typename F, F fx>
8882 #if 0
8883  // TODO: you must evaluate the get/check_get of every
8884  // argument, to ensure it doesn't throw
8885  // (e.g., for the sol_lua_check_access extension point!)
8886  // This incluudes properly noexcept-ing all the above
8887  // trampolines / safety nets
8888  if constexpr (meta::bind_traits<F>::is_noexcept) {
8889  return static_trampoline_noexcept<fx>(L);
8890  }
8891  else
8892 #endif
8893  { return static_trampoline<fx>(L); }
8894  }
8895  } // namespace detail
8896 
8898  static_assert(sizeof(void*) >= sizeof(exception_handler_function),
8899  "void* storage is too small to transport the exception handler: please file a bug on the sol2 issue tracker to get this looked at!");
8900  void* storage;
8901  std::memcpy(&storage, &exf, sizeof(exception_handler_function));
8904  }
8905 } // namespace sol
8906 
8907 // end of sol/trampoline.hpp
8908 
8909 // beginning of sol/stack_core.hpp
8910 
8911 // beginning of sol/inheritance.hpp
8912 
8913 // beginning of sol/usertype_traits.hpp
8914 
8915 // beginning of sol/demangle.hpp
8916 
8917 #include <string>
8918 #include <array>
8919 #include <cctype>
8920 #if SOL_IS_ON(SOL_MINGW_CCTYPE_IS_POISONED)
8921 extern "C" {
8922 #include <ctype.h>
8923 }
8924 #endif // MinGW is on some stuff
8925 #include <locale>
8926 
8927 namespace sol { namespace detail {
8928  inline constexpr std::array<string_view, 9> removals { { "{anonymous}",
8929  "(anonymous namespace)",
8930  "public:",
8931  "private:",
8932  "protected:",
8933  "struct ",
8934  "class ",
8935  "`anonymous-namespace'",
8936  "`anonymous namespace'" } };
8937 
8938 #if SOL_IS_ON(SOL_COMPILER_GCC) || SOL_IS_ON(SOL_COMPILER_CLANG)
8939  inline std::string ctti_get_type_name_from_sig(std::string name) {
8940  // cardinal sins from MINGW
8941  using namespace std;
8942  std::size_t start = name.find_first_of('[');
8943  start = name.find_first_of('=', start);
8944  std::size_t end = name.find_last_of(']');
8945  if (end == std::string::npos)
8946  end = name.size();
8947  if (start == std::string::npos)
8948  start = 0;
8949  if (start < name.size() - 1)
8950  start += 1;
8951  name = name.substr(start, end - start);
8952  start = name.rfind("seperator_mark");
8953  if (start != std::string::npos) {
8954  name.erase(start - 2, name.length());
8955  }
8956  while (!name.empty() && isblank(name.front()))
8957  name.erase(name.begin());
8958  while (!name.empty() && isblank(name.back()))
8959  name.pop_back();
8960 
8961  for (std::size_t r = 0; r < removals.size(); ++r) {
8962  auto found = name.find(removals[r]);
8963  while (found != std::string::npos) {
8964  name.erase(found, removals[r].size());
8965  found = name.find(removals[r]);
8966  }
8967  }
8968 
8969  return name;
8970  }
8971 
8972  template <typename T, class seperator_mark = int>
8973  inline std::string ctti_get_type_name() {
8974  return ctti_get_type_name_from_sig(__PRETTY_FUNCTION__);
8975  }
8976 #elif SOL_IS_ON(SOL_COMPILER_VCXX)
8977  inline std::string ctti_get_type_name_from_sig(std::string name) {
8978  std::size_t start = name.find("get_type_name");
8979  if (start == std::string::npos)
8980  start = 0;
8981  else
8982  start += 13;
8983  if (start < name.size() - 1)
8984  start += 1;
8985  std::size_t end = name.find_last_of('>');
8986  if (end == std::string::npos)
8987  end = name.size();
8988  name = name.substr(start, end - start);
8989  if (name.find("struct", 0) == 0)
8990  name.replace(0, 6, "", 0);
8991  if (name.find("class", 0) == 0)
8992  name.replace(0, 5, "", 0);
8993  while (!name.empty() && isblank(name.front()))
8994  name.erase(name.begin());
8995  while (!name.empty() && isblank(name.back()))
8996  name.pop_back();
8997 
8998  for (std::size_t r = 0; r < removals.size(); ++r) {
8999  auto found = name.find(removals[r]);
9000  while (found != std::string::npos) {
9001  name.erase(found, removals[r].size());
9002  found = name.find(removals[r]);
9003  }
9004  }
9005 
9006  return name;
9007  }
9008 
9009  template <typename T>
9010  std::string ctti_get_type_name() {
9011  return ctti_get_type_name_from_sig(__FUNCSIG__);
9012  }
9013 #else
9014 #error Compiler not supported for demangling
9015 #endif // compilers
9016 
9017  template <typename T>
9018  std::string demangle_once() {
9019  std::string realname = ctti_get_type_name<T>();
9020  return realname;
9021  }
9022 
9023  inline std::string short_demangle_from_type_name(std::string realname) {
9024  // This isn't the most complete but it'll do for now...?
9025  static const std::array<std::string, 10> ops = {
9026  { "operator<", "operator<<", "operator<<=", "operator<=", "operator>", "operator>>", "operator>>=", "operator>=", "operator->", "operator->*" }
9027  };
9028  int level = 0;
9029  std::size_t idx = 0;
9030  for (idx = static_cast<std::size_t>(realname.empty() ? 0 : realname.size() - 1); idx > 0; --idx) {
9031  if (level == 0 && realname[idx] == ':') {
9032  break;
9033  }
9034  bool isleft = realname[idx] == '<';
9035  bool isright = realname[idx] == '>';
9036  if (!isleft && !isright)
9037  continue;
9038  bool earlybreak = false;
9039  for (const auto& op : ops) {
9040  std::size_t nisop = realname.rfind(op, idx);
9041  if (nisop == std::string::npos)
9042  continue;
9043  std::size_t nisopidx = idx - op.size() + 1;
9044  if (nisop == nisopidx) {
9045  idx = static_cast<std::size_t>(nisopidx);
9046  earlybreak = true;
9047  }
9048  break;
9049  }
9050  if (earlybreak) {
9051  continue;
9052  }
9053  level += isleft ? -1 : 1;
9054  }
9055  if (idx > 0) {
9056  realname.erase(0, realname.length() < static_cast<std::size_t>(idx) ? realname.length() : idx + 1);
9057  }
9058  return realname;
9059  }
9060 
9061  template <typename T>
9062  std::string short_demangle_once() {
9063  std::string realname = ctti_get_type_name<T>();
9064  return short_demangle_from_type_name(realname);
9065  }
9066 
9067  template <typename T>
9068  const std::string& demangle() {
9069  static const std::string d = demangle_once<T>();
9070  return d;
9071  }
9072 
9073  template <typename T>
9074  const std::string& short_demangle() {
9075  static const std::string d = short_demangle_once<T>();
9076  return d;
9077  }
9078 }} // namespace sol::detail
9079 
9080 // end of sol/demangle.hpp
9081 
9082 namespace sol {
9083 
9084  template <typename T>
9085  struct usertype_traits {
9086  static const std::string& name() {
9087  static const std::string& n = detail::short_demangle<T>();
9088  return n;
9089  }
9090  static const std::string& qualified_name() {
9091  static const std::string& q_n = detail::demangle<T>();
9092  return q_n;
9093  }
9094  static const std::string& metatable() {
9095  static const std::string m = std::string("sol.").append(detail::demangle<T>());
9096  return m;
9097  }
9098  static const std::string& user_metatable() {
9099  static const std::string u_m = std::string("sol.").append(detail::demangle<T>()).append(".user");
9100  return u_m;
9101  }
9102  static const std::string& user_gc_metatable() {
9103  static const std::string u_g_m = std::string("sol.").append(detail::demangle<T>()).append(".user\xE2\x99\xBB");
9104  return u_g_m;
9105  }
9106  static const std::string& gc_table() {
9107  static const std::string g_t = std::string("sol.").append(detail::demangle<T>()).append(".\xE2\x99\xBB");
9108  return g_t;
9109  }
9110  };
9111 
9112 } // namespace sol
9113 
9114 // end of sol/usertype_traits.hpp
9115 
9116 // beginning of sol/unique_usertype_traits.hpp
9117 
9118 #include <memory>
9119 
9120 namespace sol {
9121 
9122  namespace detail {
9123  template <typename T>
9126  };
9127 
9128  template <typename T>
9129  struct unique_fallback<std::shared_ptr<T>> {
9130  private:
9131  using pointer = typename std::pointer_traits<std::shared_ptr<T>>::element_type*;
9132 
9133  public:
9134  // rebind is non-void
9135  // if and only if unique usertype
9136  // is cast-capable
9137  template <typename X>
9138  using rebind_actual_type = std::shared_ptr<X>;
9139 
9140  static bool is_null(lua_State*, const std::shared_ptr<T>& p) noexcept {
9141  return p == nullptr;
9142  }
9143 
9144  static pointer get(lua_State*, const std::shared_ptr<T>& p) noexcept {
9145  return p.get();
9146  }
9147  };
9148 
9149  template <typename T, typename D>
9150  struct unique_fallback<std::unique_ptr<T, D>> {
9151  private:
9152  using pointer = typename std::unique_ptr<T, D>::pointer;
9153 
9154  public:
9155  static bool is_null(lua_State*, const std::unique_ptr<T, D>& p) noexcept {
9156  return p == nullptr;
9157  }
9158 
9159  static pointer get(lua_State*, const std::unique_ptr<T, D>& p) noexcept {
9160  return p.get();
9161  }
9162  };
9163  } // namespace detail
9164 
9165  namespace meta { namespace meta_detail {
9166  template <typename T, typename = void>
9168 
9169  template <typename T>
9170  struct unique_actual_type<T, meta::void_t<typename T::actual_type>> {
9171  using type = typename T::actual_type;
9172  };
9173 
9174  template <typename T, typename... Rest, template <typename...> class Templ>
9175  struct unique_actual_type<Templ<T, Rest...>> {
9176  using type = T;
9177  };
9178 
9179  }} // namespace meta::meta_detail
9180 
9181  template <typename T>
9183 
9184  namespace meta { namespace meta_detail {
9185  template <typename T>
9186  using value_test_t = decltype(T::value);
9187 
9188  template <typename T>
9189  using type_test_t = typename T::type;
9190 
9191  template <typename T>
9192  using type_element_type_t = typename T::element_type;
9193 
9194  template <typename T, typename = void>
9197  };
9198 
9199  template <typename T>
9200  struct unique_element_type<T, std::enable_if_t<meta::is_detected_v<type_element_type_t, T>>> {
9201  using type = typename T::element_type;
9202  };
9203 
9204  template <typename T>
9205  struct unique_element_type<T, std::enable_if_t<meta::is_detected_v<type_test_t, T>>> {
9206  using type = typename T::type;
9207  };
9208 
9209  template <typename T, typename = void>
9210  struct unique_valid : std::integral_constant<bool, !has_internal_marker_v<T>> { };
9211 
9212  template <typename T>
9213  struct unique_valid<T, meta::void_t<decltype(T::value)>> : std::integral_constant<bool, T::value> { };
9214  }} // namespace meta::meta_detail
9215 
9216  template <typename T>
9218 
9219  template <typename T, typename Element = void>
9220  using unique_usertype_rebind_actual_t = typename unique_usertype_traits<T>::template rebind_actual_type<Element>;
9221 
9222  template <typename T>
9223  struct unique_usertype_traits : public detail::unique_fallback<T> { };
9224 
9225  template <typename T>
9226  struct is_unique_usertype : std::integral_constant<bool, meta::meta_detail::unique_valid<unique_usertype_traits<T>>::value> { };
9227 
9228  template <typename T>
9230 
9231  namespace meta { namespace meta_detail {
9232  template <typename T>
9234  = decltype(sol_lua_check_access(types<T>(), static_cast<lua_State*>(nullptr), -1, std::declval<stack::record&>()));
9235 
9236  template <typename T>
9237  inline constexpr bool is_adl_sol_lua_check_access_v = meta::is_detected_v<adl_sol_lua_check_access_test_t, T>;
9238 
9239  template <typename T>
9241  = decltype(unique_usertype_traits<T>::get(static_cast<lua_State*>(nullptr), std::declval<unique_usertype_actual_t<T>>()));
9242 
9243  template <typename T>
9244  inline constexpr bool unique_usertype_get_with_state_v = meta::is_detected_v<unique_usertype_get_with_state_test_t, T>;
9245 
9246  template <typename T>
9248  = decltype(unique_usertype_traits<T>::is_null(static_cast<lua_State*>(nullptr), std::declval<unique_usertype_actual_t<T>>()));
9249 
9250  template <typename T>
9251  inline constexpr bool unique_usertype_is_null_with_state_v = meta::is_detected_v<unique_usertype_is_null_with_state_test_t, T>;
9252  }} // namespace meta::meta_detail
9253 
9254  namespace detail {
9255  template <typename T>
9256  constexpr bool unique_is_null_noexcept() noexcept {
9257  if constexpr (meta::meta_detail::unique_usertype_is_null_with_state_v<std::remove_cv_t<T>>) {
9258  return noexcept(
9259  unique_usertype_traits<T>::is_null(static_cast<lua_State*>(nullptr), std::declval<unique_usertype_actual_t<std::remove_cv_t<T>>>()));
9260  }
9261  else {
9262  return noexcept(unique_usertype_traits<T>::is_null(std::declval<unique_usertype_actual_t<std::remove_cv_t<T>>>()));
9263  }
9264  }
9265 
9266  template <typename T>
9267  bool unique_is_null(lua_State* L_, T& value_) noexcept(unique_is_null_noexcept<std::remove_cv_t<T>>()) {
9268  using Tu = std::remove_cv_t<T>;
9269  if constexpr (meta::meta_detail::unique_usertype_is_null_with_state_v<Tu>) {
9270  return unique_usertype_traits<Tu>::is_null(L_, value_);
9271  }
9272  else {
9273  return unique_usertype_traits<Tu>::is_null(value_);
9274  }
9275  }
9276 
9277  template <typename T>
9278  constexpr bool unique_get_noexcept() noexcept {
9279  if constexpr (meta::meta_detail::unique_usertype_get_with_state_v<std::remove_cv_t<T>>) {
9280  return noexcept(
9281  unique_usertype_traits<T>::get(static_cast<lua_State*>(nullptr), std::declval<unique_usertype_actual_t<std::remove_cv_t<T>>>()));
9282  }
9283  else {
9284  return noexcept(unique_usertype_traits<T>::get(std::declval<unique_usertype_actual_t<std::remove_cv_t<T>>>()));
9285  }
9286  }
9287 
9288  template <typename T>
9289  auto unique_get(lua_State* L_, T& value_) noexcept(unique_get_noexcept<std::remove_cv_t<T>>()) {
9290  using Tu = std::remove_cv_t<T>;
9291  if constexpr (meta::meta_detail::unique_usertype_get_with_state_v<Tu>) {
9292  return unique_usertype_traits<Tu>::get(L_, value_);
9293  }
9294  else {
9295  return unique_usertype_traits<Tu>::get(value_);
9296  }
9297  }
9298  } // namespace detail
9299 
9300  namespace meta { namespace meta_detail {
9301  template <typename T, typename Element = void>
9302  using is_rebind_actual_type_test_t = typename T::template rebind_actual_type<Element>;
9303 
9304  template <typename T, typename Element = void>
9306 
9307  template <typename T, typename Element = void>
9309 
9310  template <typename T, typename Element, bool = is_rebind_actual_type_v<T, Element>>
9312 
9313  template <typename T, typename Element>
9314  struct is_actual_type_rebindable_for_test<T, Element, true>
9315  : std::integral_constant<bool, !std::is_void_v<typename T::template rebind_actual_type<Element>>> { };
9316  }} // namespace meta::meta_detail
9317 
9318  template <typename T, typename Element = void>
9320 
9321  template <typename T, typename Element = void>
9323 
9324 } // namespace sol
9325 
9326 // end of sol/unique_usertype_traits.hpp
9327 
9328 namespace sol {
9329  template <typename... Args>
9330  struct base_list { };
9331  template <typename... Args>
9332  using bases = base_list<Args...>;
9333 
9336 
9337  template <typename... Args>
9339 
9340  namespace detail {
9341 
9342  inline decltype(auto) base_class_check_key() {
9343  static const auto& key = "class_check";
9344  return key;
9345  }
9346 
9347  inline decltype(auto) base_class_cast_key() {
9348  static const auto& key = "class_cast";
9349  return key;
9350  }
9351 
9352  inline decltype(auto) base_class_index_propogation_key() {
9353  static const auto& key = u8"\xF0\x9F\x8C\xB2.index";
9354  return key;
9355  }
9356 
9357  inline decltype(auto) base_class_new_index_propogation_key() {
9358  static const auto& key = u8"\xF0\x9F\x8C\xB2.new_index";
9359  return key;
9360  }
9361 
9362  template <typename T>
9363  struct inheritance {
9364  typedef typename base<T>::type bases_t;
9365 
9366  static bool type_check_bases(types<>, const string_view&) {
9367  return false;
9368  }
9369 
9370  template <typename Base, typename... Args>
9372  return ti == usertype_traits<Base>::qualified_name() || type_check_bases(types<Args...>(), ti);
9373  }
9374 
9375  static bool type_check(const string_view& ti) {
9376  return ti == usertype_traits<T>::qualified_name() || type_check_bases(bases_t(), ti);
9377  }
9378 
9379  template <typename... Bases>
9380  static bool type_check_with(const string_view& ti) {
9381  return ti == usertype_traits<T>::qualified_name() || type_check_bases(types<Bases...>(), ti);
9382  }
9383 
9384  static void* type_cast_bases(types<>, T*, const string_view&) {
9385  return nullptr;
9386  }
9387 
9388  template <typename Base, typename... Args>
9389  static void* type_cast_bases(types<Base, Args...>, T* data, const string_view& ti) {
9390  // Make sure to convert to T first, and then dynamic cast to the proper type
9391  return ti != usertype_traits<Base>::qualified_name() ? type_cast_bases(types<Args...>(), data, ti)
9392  : static_cast<void*>(static_cast<Base*>(data));
9393  }
9394 
9395  static void* type_cast(void* voiddata, const string_view& ti) {
9396  T* data = static_cast<T*>(voiddata);
9397  return static_cast<void*>(ti != usertype_traits<T>::qualified_name() ? type_cast_bases(bases_t(), data, ti) : data);
9398  }
9399 
9400  template <typename... Bases>
9401  static void* type_cast_with(void* voiddata, const string_view& ti) {
9402  T* data = static_cast<T*>(voiddata);
9403  return static_cast<void*>(ti != usertype_traits<T>::qualified_name() ? type_cast_bases(types<Bases...>(), data, ti) : data);
9404  }
9405 
9406  template <typename U>
9407  static bool type_unique_cast_bases(types<>, void*, void*, const string_view&) {
9408  return 0;
9409  }
9410 
9411  template <typename U, typename Base, typename... Args>
9412  static int type_unique_cast_bases(types<Base, Args...>, void* source_data, void* target_data, const string_view& ti) {
9413  using uu_traits = unique_usertype_traits<U>;
9414  using base_ptr = typename uu_traits::template rebind_actual_type<Base>;
9416  if (base_ti == ti) {
9417  if (target_data != nullptr) {
9418  U* source = static_cast<U*>(source_data);
9419  base_ptr* target = static_cast<base_ptr*>(target_data);
9420  // perform proper derived -> base conversion
9421  *target = *source;
9422  }
9423  return 2;
9424  }
9425  return type_unique_cast_bases<U>(types<Args...>(), source_data, target_data, ti);
9426  }
9427 
9428  template <typename U>
9429  static int type_unique_cast(void* source_data, void* target_data, const string_view& ti, const string_view& rebind_ti) {
9430  if constexpr (is_actual_type_rebindable_for_v<U>) {
9431  using rebound_actual_type = unique_usertype_rebind_actual_t<U>;
9434  if (rebind_ti != this_rebind_ti) {
9435  // this is not even of the same unique type
9436  return 0;
9437  }
9439  if (ti == this_ti) {
9440  // direct match, return 1
9441  return 1;
9442  }
9443  return type_unique_cast_bases<U>(maybe_bases_or_empty(), source_data, target_data, ti);
9444  }
9445  else {
9446  (void)rebind_ti;
9448  if (ti == this_ti) {
9449  // direct match, return 1
9450  return 1;
9451  }
9452  return type_unique_cast_bases<U>(types<>(), source_data, target_data, ti);
9453  }
9454  }
9455 
9456  template <typename U, typename... Bases>
9457  static int type_unique_cast_with(void* source_data, void* target_data, const string_view& ti, const string_view& rebind_ti) {
9458  using uc_bases_t = types<Bases...>;
9459  if constexpr (is_actual_type_rebindable_for_v<U>) {
9460  using rebound_actual_type = unique_usertype_rebind_actual_t<U>;
9461  using cond_bases_t = meta::conditional_t<std::is_void_v<rebound_actual_type>, types<>, uc_bases_t>;
9463  if (rebind_ti != this_rebind_ti) {
9464  // this is not even of the same unique type
9465  return 0;
9466  }
9468  if (ti == this_ti) {
9469  // direct match, return 1
9470  return 1;
9471  }
9472  return type_unique_cast_bases<U>(cond_bases_t(), source_data, target_data, ti);
9473  }
9474  else {
9475  (void)rebind_ti;
9477  if (ti == this_ti) {
9478  // direct match, return 1
9479  return 1;
9480  }
9481  return type_unique_cast_bases<U>(types<>(), source_data, target_data, ti);
9482  }
9483  }
9484  };
9485 
9489  } // namespace detail
9490 } // namespace sol
9491 
9492 // end of sol/inheritance.hpp
9493 
9494 // beginning of sol/error_handler.hpp
9495 
9496 #include <cstdio>
9497 
9498 namespace sol {
9499 
9500  namespace detail {
9501  constexpr const char* not_a_number = "not a numeric type";
9502  constexpr const char* not_a_number_or_number_string = "not a numeric type or numeric string";
9503  constexpr const char* not_a_number_integral = "not a numeric type that fits exactly an integer (number maybe has significant decimals)";
9504  constexpr const char* not_a_number_or_number_string_integral
9505  = "not a numeric type or a numeric string that fits exactly an integer (e.g. number maybe has significant decimals)";
9506 
9507  constexpr const char* not_enough_stack_space = "not enough space left on Lua stack";
9508  constexpr const char* not_enough_stack_space_floating = "not enough space left on Lua stack for a floating point number";
9509  constexpr const char* not_enough_stack_space_integral = "not enough space left on Lua stack for an integral number";
9510  constexpr const char* not_enough_stack_space_string = "not enough space left on Lua stack for a string";
9511  constexpr const char* not_enough_stack_space_meta_function_name = "not enough space left on Lua stack for the name of a meta_function";
9512  constexpr const char* not_enough_stack_space_userdata = "not enough space left on Lua stack to create a sol2 userdata";
9513  constexpr const char* not_enough_stack_space_generic = "not enough space left on Lua stack to push valuees";
9514  constexpr const char* not_enough_stack_space_environment = "not enough space left on Lua stack to retrieve environment";
9515  constexpr const char* protected_function_error = "caught (...) unknown error during protected_function call";
9516 
9517  inline void accumulate_and_mark(const std::string& n, std::string& aux_message, int& marker) {
9518  if (marker > 0) {
9519  aux_message += ", ";
9520  }
9521  aux_message += n;
9522  ++marker;
9523  }
9524  } // namespace detail
9525 
9526  inline std::string associated_type_name(lua_State* L, int index, type t) {
9527  switch (t) {
9528  case type::poly:
9529  return "anything";
9530  case type::userdata: {
9531 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
9532  luaL_checkstack(L, 2, "not enough space to push get the type name");
9533 #endif // make sure stack doesn't overflow
9534  if (lua_getmetatable(L, index) == 0) {
9535  break;
9536  }
9537  lua_pushlstring(L, "__name", 6);
9538  lua_rawget(L, -2);
9539  size_t sz;
9540  const char* name = lua_tolstring(L, -1, &sz);
9541  std::string tn(name, static_cast<std::string::size_type>(sz));
9542  lua_pop(L, 2);
9543  return tn;
9544  }
9545  default:
9546  break;
9547  }
9548  return lua_typename(L, static_cast<int>(t));
9549  }
9550 
9551  inline int push_type_panic_string(lua_State* L, int index, type expected, type actual, string_view message, string_view aux_message) noexcept {
9552  const char* err = message.size() == 0
9553  ? (aux_message.size() == 0 ? "stack index %d, expected %s, received %s" : "stack index %d, expected %s, received %s: %s")
9554  : "stack index %d, expected %s, received %s: %s %s";
9555  const char* type_name = expected == type::poly ? "anything" : lua_typename(L, static_cast<int>(expected));
9556  {
9557  std::string actual_name = associated_type_name(L, index, actual);
9558  lua_pushfstring(L, err, index, type_name, actual_name.c_str(), message.data(), aux_message.data());
9559  }
9560  return 1;
9561  }
9562 
9563  inline int type_panic_string(lua_State* L, int index, type expected, type actual, string_view message = "") noexcept(false) {
9564  push_type_panic_string(L, index, expected, actual, message, "");
9565  return lua_error(L);
9566  }
9567 
9568  inline int type_panic_c_str(lua_State* L, int index, type expected, type actual, const char* message = nullptr) noexcept(false) {
9569  push_type_panic_string(L, index, expected, actual, message == nullptr ? "" : message, "");
9570  return lua_error(L);
9571  }
9572 
9573  struct type_panic_t {
9574  int operator()(lua_State* L, int index, type expected, type actual) const noexcept(false) {
9575  return type_panic_c_str(L, index, expected, actual, nullptr);
9576  }
9577  int operator()(lua_State* L, int index, type expected, type actual, string_view message) const noexcept(false) {
9578  return type_panic_c_str(L, index, expected, actual, message.data());
9579  }
9580  };
9581 
9583 
9585  int operator()(lua_State* L, int index, type expected, type actual, string_view message) const noexcept(false) {
9586  push_type_panic_string(L, index, expected, actual, message, "(type check failed in constructor)");
9587  return lua_error(L);
9588  }
9589  };
9590 
9591  template <typename F = void>
9593  int operator()(lua_State* L, int index, type expected, type actual, string_view message) const noexcept(false) {
9594  push_type_panic_string(L, index, expected, actual, message, "(bad argument to variable or function call)");
9595  return lua_error(L);
9596  }
9597  };
9598 
9599  template <typename R, typename... Args>
9600  struct argument_handler<types<R, Args...>> {
9601  int operator()(lua_State* L, int index, type expected, type actual, string_view message) const noexcept(false) {
9602  {
9603  std::string aux_message = "(bad argument into '";
9604  aux_message += detail::demangle<R>();
9605  aux_message += "(";
9606  int marker = 0;
9607  (void)detail::swallow { int(), (detail::accumulate_and_mark(detail::demangle<Args>(), aux_message, marker), int())... };
9608  aux_message += ")')";
9609  push_type_panic_string(L, index, expected, actual, message, aux_message);
9610  }
9611  return lua_error(L);
9612  }
9613  };
9614 
9615  // Specify this function as the handler for lua::check if you know there's nothing wrong
9616  inline int no_panic(lua_State*, int, type, type, const char* = nullptr) noexcept {
9617  return 0;
9618  }
9619 
9620  inline void type_error(lua_State* L, int expected, int actual) noexcept(false) {
9621  luaL_error(L, "expected %s, received %s", lua_typename(L, expected), lua_typename(L, actual));
9622  }
9623 
9624  inline void type_error(lua_State* L, type expected, type actual) noexcept(false) {
9625  type_error(L, static_cast<int>(expected), static_cast<int>(actual));
9626  }
9627 
9628  inline void type_assert(lua_State* L, int index, type expected, type actual) noexcept(false) {
9629  if (expected != type::poly && expected != actual) {
9630  type_panic_c_str(L, index, expected, actual, nullptr);
9631  }
9632  }
9633 
9634  inline void type_assert(lua_State* L, int index, type expected) {
9635  type actual = type_of(L, index);
9636  type_assert(L, index, expected, actual);
9637  }
9638 
9639 } // namespace sol
9640 
9641 // end of sol/error_handler.hpp
9642 
9643 // beginning of sol/reference.hpp
9644 
9645 // beginning of sol/stack_reference.hpp
9646 
9647 namespace sol {
9648  namespace detail {
9649  inline bool xmovable(lua_State* leftL, lua_State* rightL) {
9650  if (rightL == nullptr || leftL == nullptr || leftL == rightL) {
9651  return false;
9652  }
9653  const void* leftregistry = lua_topointer(leftL, LUA_REGISTRYINDEX);
9654  const void* rightregistry = lua_topointer(rightL, LUA_REGISTRYINDEX);
9655  return leftregistry == rightregistry;
9656  }
9657  } // namespace detail
9658 
9660  private:
9661  friend class stack_reference;
9662 
9663  int m_index = 0;
9664 
9665  int registry_index() const noexcept {
9666  return LUA_NOREF;
9667  }
9668 
9669  public:
9670  stateless_stack_reference() noexcept = default;
9673  }
9675  }
9677  }
9678  stateless_stack_reference(absolute_index index_) noexcept : m_index(index_) {
9679  }
9680  stateless_stack_reference(raw_index index_) noexcept : m_index(index_) {
9681  }
9682  stateless_stack_reference(lua_State*, ref_index) noexcept = delete;
9683  stateless_stack_reference(ref_index) noexcept = delete;
9684  stateless_stack_reference(const reference&) noexcept = delete;
9685  stateless_stack_reference(const stateless_stack_reference&) noexcept = default;
9686  stateless_stack_reference(stateless_stack_reference&& o) noexcept = default;
9688  stateless_stack_reference& operator=(const stateless_stack_reference&) noexcept = default;
9689 
9690  int push(lua_State* L_) const noexcept {
9691 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
9692  luaL_checkstack(L_, 1, "not enough Lua stack space to push a single reference value");
9693 #endif // make sure stack doesn't overflow
9694  lua_pushvalue(L_, m_index);
9695  return 1;
9696  }
9697 
9698  void pop(lua_State* L_, int pop_count = 1) const noexcept {
9699  lua_pop(L_, pop_count);
9700  }
9701 
9702  int stack_index() const noexcept {
9703  return m_index;
9704  }
9705 
9706  const void* pointer(lua_State* L_) const noexcept {
9707  const void* pointer_id = lua_topointer(L_, stack_index());
9708  return pointer_id;
9709  }
9710 
9711  type get_type(lua_State* L_) const noexcept {
9712  int untyped_value = lua_type(L_, stack_index());
9713  return static_cast<type>(untyped_value);
9714  }
9715 
9716  bool valid(lua_State* L) const noexcept {
9717  type t = get_type(L);
9718  return t != type::lua_nil && t != type::none;
9719  }
9720 
9721  void reset(lua_State*) noexcept {
9722  m_index = 0;
9723  }
9724 
9725  void reset(lua_State* L_, int index_) noexcept {
9726  m_index = absolute_index(L_, index_);
9727  }
9728 
9729  void abandon(lua_State* = nullptr) noexcept {
9730  m_index = 0;
9731  }
9732 
9734  return stateless_stack_reference(L_, raw_index(m_index));
9735  }
9736 
9738  m_index = right.m_index;
9739  }
9740 
9741  bool equals(lua_State* L_, const stateless_stack_reference& r) const noexcept {
9742  return lua_compare(L_, this->stack_index(), r.stack_index(), LUA_OPEQ) == 1;
9743  }
9744 
9745  bool equals(lua_State* L_, lua_nil_t) const noexcept {
9746  return valid(L_);
9747  }
9748  };
9749 
9751  private:
9752  lua_State* luastate = nullptr;
9753 
9754  public:
9755  stack_reference() noexcept = default;
9757  stack_reference(lua_State* L, lua_nil_t) noexcept : stateless_stack_reference(L, 0), luastate(L) {
9758  }
9759  stack_reference(lua_State* L, int i) noexcept : stateless_stack_reference(L, i), luastate(L) {
9760  }
9762  }
9763  stack_reference(lua_State* L, raw_index i) noexcept : stateless_stack_reference(L, i), luastate(L) {
9764  }
9765  stack_reference(lua_State* L, ref_index i) noexcept = delete;
9766  stack_reference(lua_State* L, const reference& r) noexcept = delete;
9767  stack_reference(lua_State* L, const stack_reference& r) noexcept : luastate(L) {
9768  if (!r.valid()) {
9769  m_index = 0;
9770  return;
9771  }
9772  int i = r.stack_index();
9773  if (detail::xmovable(lua_state(), r.lua_state())) {
9774 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
9775  luaL_checkstack(L, 1, "not enough Lua stack space to push a single reference value");
9776 #endif // make sure stack doesn't overflow
9777  lua_pushvalue(r.lua_state(), r.stack_index());
9778  lua_xmove(r.lua_state(), luastate, 1);
9779  i = absolute_index(luastate, -1);
9780  }
9781  m_index = i;
9782  }
9783  stack_reference(stack_reference&& o) noexcept = default;
9784  stack_reference& operator=(stack_reference&&) noexcept = default;
9785  stack_reference(const stack_reference&) noexcept = default;
9786  stack_reference& operator=(const stack_reference&) noexcept = default;
9787 
9788  int push() const noexcept {
9789  return push(lua_state());
9790  }
9791 
9792  int push(lua_State* L_) const noexcept {
9794  }
9795 
9796  void pop() const noexcept {
9797  pop(lua_state());
9798  }
9799 
9800  void pop(lua_State* L_, int pop_count_ = 1) const noexcept {
9801  stateless_stack_reference::pop(L_, pop_count_);
9802  }
9803 
9804  const void* pointer() const noexcept {
9805  return stateless_stack_reference::pointer(lua_state());
9806  }
9807 
9808  type get_type() const noexcept {
9809  return stateless_stack_reference::get_type(lua_state());
9810  }
9811 
9812  lua_State* lua_state() const noexcept {
9813  return luastate;
9814  }
9815 
9816  bool valid() const noexcept {
9817  return stateless_stack_reference::valid(lua_state());
9818  }
9819 
9820  void abandon() {
9822  }
9823  };
9824 
9825  inline bool operator==(const stack_reference& l, const stack_reference& r) {
9826  return lua_compare(l.lua_state(), l.stack_index(), r.stack_index(), LUA_OPEQ) == 1;
9827  }
9828 
9829  inline bool operator!=(const stack_reference& l, const stack_reference& r) {
9830  return !operator==(l, r);
9831  }
9832 
9833  inline bool operator==(const stack_reference& lhs, const lua_nil_t&) {
9834  return !lhs.valid();
9835  }
9836 
9837  inline bool operator==(const lua_nil_t&, const stack_reference& rhs) {
9838  return !rhs.valid();
9839  }
9840 
9841  inline bool operator!=(const stack_reference& lhs, const lua_nil_t&) {
9842  return lhs.valid();
9843  }
9844 
9845  inline bool operator!=(const lua_nil_t&, const stack_reference& rhs) {
9846  return rhs.valid();
9847  }
9848 
9850  return l.stack_index() == r.stack_index();
9851  }
9852 
9854  return l.stack_index() != r.stack_index();
9855  }
9856 
9859 
9861  }
9862 
9863  lua_State* lua_state() const noexcept {
9864  return m_L;
9865  }
9866 
9868  return lhs.equals(lua_state(), rhs);
9869  }
9870 
9871  bool operator()(lua_nil_t lhs, const stateless_stack_reference& rhs) const {
9872  return rhs.equals(lua_state(), lhs);
9873  }
9874 
9875  bool operator()(const stateless_stack_reference& lhs, lua_nil_t rhs) const {
9876  return lhs.equals(lua_state(), rhs);
9877  }
9878 
9879  private:
9881  };
9882 
9885 
9886  bool operator()(const lua_nil_t& lhs, const stack_reference& rhs) const {
9887  return lhs == rhs;
9888  }
9889 
9890  bool operator()(const stack_reference& lhs, const lua_nil_t& rhs) const {
9891  return lhs == rhs;
9892  }
9893 
9894  bool operator()(const stack_reference& lhs, const stack_reference& rhs) const {
9895  return lhs == rhs;
9896  }
9897  };
9898 
9903 
9904  stateless_stack_reference_hash(lua_State* L_) noexcept : m_L(L_) {
9905  }
9906 
9907  lua_State* lua_state() const noexcept {
9908  return m_L;
9909  }
9910 
9911  result_type operator()(const argument_type& lhs) const noexcept {
9912  std::hash<const void*> h;
9913  return h(lhs.pointer(lua_state()));
9914  }
9915 
9916  private:
9918  };
9919 
9924 
9925  result_type operator()(const argument_type& lhs) const noexcept {
9926  std::hash<const void*> h;
9927  return h(lhs.pointer());
9928  }
9929  };
9930 } // namespace sol
9931 
9932 // end of sol/stack_reference.hpp
9933 
9934 #include <functional>
9935 
9936 namespace sol {
9937  namespace detail {
9938  inline const char (&default_main_thread_name())[9] {
9939  static const char name[9] = "sol.\xF0\x9F\x93\x8C";
9940  return name;
9941  }
9942  } // namespace detail
9943 
9944  namespace stack {
9945  inline void remove(lua_State* L_, int rawindex, int count) {
9946  if (count < 1)
9947  return;
9948  int top = lua_gettop(L_);
9949  if (top < 1) {
9950  return;
9951  }
9952  if (rawindex == -count || top == rawindex) {
9953  // Slice them right off the top
9954  lua_pop(L_, static_cast<int>(count));
9955  return;
9956  }
9957 
9958  // Remove each item one at a time using stack operations
9959  // Probably slower, maybe, haven't benchmarked,
9960  // but necessary
9961  int index = lua_absindex(L_, rawindex);
9962  if (index < 0) {
9963  index = lua_gettop(L_) + (index + 1);
9964  }
9965  int last = index + count;
9966  for (int i = index; i < last; ++i) {
9967  lua_remove(L_, index);
9968  }
9969  }
9970 
9973  int index;
9974  int count;
9975  push_popper_at(lua_State* L_, int index_ = -1, int count_ = 1) : L(L_), index(index_), count(count_) {
9976  }
9978  remove(L, index, count);
9979  }
9980  };
9981 
9982  template <bool top_level>
9983  struct push_popper_n {
9986  push_popper_n(lua_State* L_, int pop_count_) : L(L_), pop_count(pop_count_) {
9987  }
9988  push_popper_n(const push_popper_n&) = delete;
9989  push_popper_n(push_popper_n&&) = default;
9990  push_popper_n& operator=(const push_popper_n&) = delete;
9991  push_popper_n& operator=(push_popper_n&&) = default;
9993  lua_pop(L, pop_count);
9994  }
9995  };
9996 
9997  template <>
9998  struct push_popper_n<true> {
10000  }
10001  };
10002 
10003  template <bool, typename T, typename = void>
10004  struct push_popper {
10007  int m_index;
10008 
10009  push_popper(T object_) noexcept : m_object(object_), m_index(lua_absindex(m_object.lua_state(), -m_object.push())) {
10010  }
10011 
10012  int index_of(const Tu&) const noexcept {
10013  return m_index;
10014  }
10015 
10017  m_object.pop();
10018  }
10019  };
10020 
10021  template <typename T, typename C>
10022  struct push_popper<true, T, C> {
10024 
10025  push_popper(T) noexcept {
10026  }
10027 
10028  int index_of(const Tu&) const noexcept {
10029  return -1;
10030  }
10031 
10033  }
10034  };
10035 
10036  template <typename T>
10037  struct push_popper<false, T, std::enable_if_t<is_stack_based_v<meta::unqualified_t<T>>>> {
10039 
10040  push_popper(T) noexcept {
10041  }
10042 
10043  int index_of(const Tu& object_) const noexcept {
10044  return object_.stack_index();
10045  }
10046 
10048  }
10049  };
10050 
10051  template <bool, typename T, typename = void>
10056  int m_index;
10057 
10058  stateless_push_popper(lua_State* L_, T object_) noexcept : m_L(L_), m_object(object_), m_index(lua_absindex(m_L, -m_object.push(m_L))) {
10059  }
10060 
10061  int index_of(const Tu&) const noexcept {
10062  return m_index;
10063  }
10064 
10066  m_object.pop(m_L);
10067  }
10068  };
10069 
10070  template <typename T, typename C>
10071  struct stateless_push_popper<true, T, C> {
10073 
10075  }
10076 
10077  int index_of(lua_State*, const Tu&) const noexcept {
10078  return -1;
10079  }
10080 
10082  }
10083  };
10084 
10085  template <typename T>
10086  struct stateless_push_popper<false, T, std::enable_if_t<is_stack_based_v<meta::unqualified_t<T>>>> {
10089 
10090  stateless_push_popper(lua_State* L_, T) noexcept : m_L(L_) {
10091  }
10092 
10093  int index_of(const Tu& object_) const noexcept {
10094  return object_.stack_index();
10095  }
10096 
10098  }
10099  };
10100 
10101  template <bool top_level = false, typename T>
10103  return push_popper<top_level, T>(std::forward<T>(x));
10104  }
10105 
10106  template <bool top_level = false, typename T>
10108  return stateless_push_popper<top_level, T>(L_, std::forward<T>(object_));
10109  }
10110 
10111  template <typename T>
10113  int push_count = object_.push();
10114  lua_State* L = object_.lua_state();
10115  return push_popper_at(L, lua_absindex(L, -push_count), push_count);
10116  }
10117 
10118  template <bool top_level = false>
10120  return push_popper_n<top_level>(L_, pop_count_);
10121  }
10122  } // namespace stack
10123 
10124  inline lua_State* main_thread(lua_State* L_, lua_State* backup_if_unsupported_ = nullptr) {
10125 #if SOL_LUA_VERSION_I_ < 502
10126  if (L_ == nullptr)
10127  return backup_if_unsupported_;
10129  auto pp = stack::pop_n(L_, 1);
10130  if (type_of(L_, -1) == type::thread) {
10131  return lua_tothread(L_, -1);
10132  }
10133  return backup_if_unsupported_;
10134 #else
10135  if (L_ == nullptr)
10136  return backup_if_unsupported_;
10138  lua_State* Lmain = lua_tothread(L_, -1);
10139  lua_pop(L_, 1);
10140  return Lmain;
10141 #endif // Lua 5.2+ has the main thread unqualified_getter
10142  }
10143 
10144  namespace detail {
10145  struct no_safety_tag {
10146  } inline constexpr no_safety {};
10147 
10148  template <bool b>
10149  inline lua_State* pick_main_thread(lua_State* L_, lua_State* backup_if_unsupported = nullptr) {
10150  (void)L_;
10151  (void)backup_if_unsupported;
10152  if (b) {
10153  return main_thread(L_, backup_if_unsupported);
10154  }
10155  return L_;
10156  }
10157  } // namespace detail
10158 
10160  private:
10161  template <bool o_main_only>
10162  friend class basic_reference;
10163 
10164  int ref = LUA_NOREF;
10165 
10166  int copy_ref(lua_State* L_) const noexcept {
10167  if (ref == LUA_NOREF)
10168  return LUA_NOREF;
10169  push(L_);
10170  return luaL_ref(L_, LUA_REGISTRYINDEX);
10171  }
10172 
10174  if (valid(L_)) {
10175  deref(L_);
10176  }
10177  ref = r.copy_ref(L_);
10178  return rL;
10179  }
10180 
10182  if (valid(L_)) {
10183  deref(L_);
10184  }
10185  ref = r.ref;
10186  r.ref = LUA_NOREF;
10187  return rL;
10188  }
10189 
10190  protected:
10191  int stack_index() const noexcept {
10192  return -1;
10193  }
10194 
10196 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
10197  luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value");
10198 #endif // make sure stack doesn't overflow
10199  lua_pushglobaltable(L_);
10200  ref = luaL_ref(L_, LUA_REGISTRYINDEX);
10201  }
10202 
10203  stateless_reference(int raw_ref_index) noexcept : ref(raw_ref_index) {
10204  }
10205 
10206  public:
10207  stateless_reference() noexcept = default;
10209  }
10210  stateless_reference(const stack_reference& r) noexcept : stateless_reference(r.lua_state(), r.stack_index()) {
10211  }
10212  stateless_reference(stack_reference&& r) noexcept : stateless_reference(r.lua_state(), r.stack_index()) {
10213  }
10215  if (r.ref == LUA_REFNIL) {
10216  ref = LUA_REFNIL;
10217  return;
10218  }
10219  if (r.ref == LUA_NOREF || L_ == nullptr) {
10220  ref = LUA_NOREF;
10221  return;
10222  }
10223  ref = r.copy_ref(L_);
10224  }
10225 
10227  if (r.ref == LUA_REFNIL) {
10228  ref = LUA_REFNIL;
10229  return;
10230  }
10231  if (r.ref == LUA_NOREF || L_ == nullptr) {
10232  ref = LUA_NOREF;
10233  return;
10234  }
10235  ref = r.ref;
10236  r.ref = LUA_NOREF;
10237  }
10238 
10240  if (L_ == nullptr || r.lua_state() == nullptr || r.get_type() == type::none) {
10241  ref = LUA_NOREF;
10242  return;
10243  }
10244  if (r.get_type() == type::lua_nil) {
10245  ref = LUA_REFNIL;
10246  return;
10247  }
10248  if (L_ != r.lua_state() && !detail::xmovable(L_, r.lua_state())) {
10249  return;
10250  }
10251  r.push(L_);
10252  ref = luaL_ref(L_, LUA_REGISTRYINDEX);
10253  }
10254 
10255  stateless_reference(lua_State* L_, const stateless_stack_reference& r) noexcept : stateless_reference(L_, r.stack_index()) {
10256  }
10257 
10258  stateless_reference(lua_State* L_, int index = -1) noexcept {
10259 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
10260  luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value");
10261 #endif // make sure stack doesn't overflow
10262  lua_pushvalue(L_, index);
10263  ref = luaL_ref(L_, LUA_REGISTRYINDEX);
10264  }
10265  stateless_reference(lua_State* L_, absolute_index index_) noexcept : stateless_reference(L_, index_.index) {
10266  }
10267  stateless_reference(lua_State* L_, ref_index index_) noexcept {
10268  lua_rawgeti(L_, LUA_REGISTRYINDEX, index_.index);
10269  ref = luaL_ref(L_, LUA_REGISTRYINDEX);
10270  }
10272  }
10273 
10274  ~stateless_reference() noexcept = default;
10275 
10276  stateless_reference(const stateless_reference& o) noexcept = delete;
10277  stateless_reference& operator=(const stateless_reference& r) noexcept = delete;
10278 
10279  stateless_reference(stateless_reference&& o) noexcept : ref(o.ref) {
10280  o.ref = LUA_NOREF;
10281  }
10282 
10284  ref = o.ref;
10285  o.ref = LUA_NOREF;
10286  return *this;
10287  }
10288 
10289  int push(lua_State* L_) const noexcept {
10290 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
10291  luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value");
10292 #endif // make sure stack doesn't overflow
10293  lua_rawgeti(L_, LUA_REGISTRYINDEX, ref);
10294  return 1;
10295  }
10296 
10297  void pop(lua_State* L_, int n = 1) const noexcept {
10298  lua_pop(L_, n);
10299  }
10300 
10301  int registry_index() const noexcept {
10302  return ref;
10303  }
10304 
10305  void reset(lua_State* L_) noexcept {
10306  if (valid(L_)) {
10307  deref(L_);
10308  }
10309  ref = LUA_NOREF;
10310  }
10311 
10312  void reset(lua_State* L_, int index_) noexcept {
10313  reset(L_);
10314 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
10315  luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value");
10316 #endif // make sure stack doesn't overflow
10317  lua_pushvalue(L_, index_);
10318  ref = luaL_ref(L_, LUA_REGISTRYINDEX);
10319  }
10320 
10321  bool valid(lua_State*) const noexcept {
10322  return !(ref == LUA_NOREF || ref == LUA_REFNIL);
10323  }
10324 
10325  const void* pointer(lua_State* L_) const noexcept {
10326  int si = push(L_);
10327  const void* vp = lua_topointer(L_, -si);
10328  lua_pop(L_, si);
10329  return vp;
10330  }
10331 
10332  type get_type(lua_State* L_) const noexcept {
10333  int p = push(L_);
10334  int result = lua_type(L_, -1);
10335  pop(L_, p);
10336  return static_cast<type>(result);
10337  }
10338 
10339  void abandon(lua_State* = nullptr) {
10340  ref = LUA_NOREF;
10341  }
10342 
10343  void deref(lua_State* L_) const noexcept {
10344  luaL_unref(L_, LUA_REGISTRYINDEX, ref);
10345  }
10346 
10347  stateless_reference copy(lua_State* L_) const noexcept {
10348  if (!valid(L_)) {
10349  return {};
10350  }
10351  return stateless_reference(copy_ref(L_));
10352  }
10353 
10354  void copy_assign(lua_State* L_, const stateless_reference& right) noexcept {
10355  if (valid(L_)) {
10356  deref(L_);
10357  }
10358  if (!right.valid(L_)) {
10359  return;
10360  }
10361  ref = right.copy_ref(L_);
10362  }
10363 
10364  bool equals(lua_State* L_, const stateless_reference& r) const noexcept {
10365  auto ppl = stack::push_pop(L_, *this);
10366  auto ppr = stack::push_pop(L_, r);
10367  return lua_compare(L_, -1, -2, LUA_OPEQ) == 1;
10368  }
10369 
10370  bool equals(lua_State* L_, const stateless_stack_reference& r) const noexcept {
10371  auto ppl = stack::push_pop(L_, *this);
10372  return lua_compare(L_, -1, r.stack_index(), LUA_OPEQ) == 1;
10373  }
10374 
10375  bool equals(lua_State* L_, lua_nil_t) const noexcept {
10376  return valid(L_);
10377  }
10378  };
10379 
10380  template <bool main_only = false>
10381  class basic_reference : public stateless_reference {
10382  private:
10383  template <bool o_main_only>
10384  friend class basic_reference;
10385  lua_State* luastate = nullptr; // non-owning
10386 
10387  template <bool r_main_only>
10389  if (valid()) {
10390  deref();
10391  }
10392  if (r.ref == LUA_REFNIL) {
10393  luastate = detail::pick_main_thread < main_only && !r_main_only > (r.lua_state(), r.lua_state());
10394  ref = LUA_REFNIL;
10395  return;
10396  }
10397  if (r.ref == LUA_NOREF) {
10398  luastate = r.luastate;
10399  ref = LUA_NOREF;
10400  return;
10401  }
10402  if (detail::xmovable(lua_state(), r.lua_state())) {
10403  r.push(lua_state());
10404  ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
10405  return;
10406  }
10407  luastate = detail::pick_main_thread < main_only && !r_main_only > (r.lua_state(), r.lua_state());
10408  ref = r.copy_ref();
10409  }
10410 
10411  template <bool r_main_only>
10413  if (valid()) {
10414  deref();
10415  }
10416  if (r.ref == LUA_REFNIL) {
10417  luastate = detail::pick_main_thread < main_only && !r_main_only > (r.lua_state(), r.lua_state());
10418  ref = LUA_REFNIL;
10419  return;
10420  }
10421  if (r.ref == LUA_NOREF) {
10422  luastate = r.luastate;
10423  ref = LUA_NOREF;
10424  return;
10425  }
10426  if (detail::xmovable(lua_state(), r.lua_state())) {
10427  r.push(lua_state());
10428  ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
10429  return;
10430  }
10431 
10432  luastate = detail::pick_main_thread < main_only && !r_main_only > (r.lua_state(), r.lua_state());
10433  ref = r.ref;
10434  r.ref = LUA_NOREF;
10435  r.luastate = nullptr;
10436  }
10437 
10438  protected:
10439  basic_reference(lua_State* L_, global_tag_t) noexcept : basic_reference(detail::pick_main_thread<main_only>(L_, L_), global_tag, global_tag) {
10440  }
10441 
10443  }
10444 
10445  basic_reference(lua_State* oL, const basic_reference<!main_only>& o) noexcept : stateless_reference(oL, o), luastate(oL) {
10446  }
10447 
10448  void deref() const noexcept {
10449  return stateless_reference::deref(lua_state());
10450  }
10451 
10452  int copy_ref() const noexcept {
10453  return copy_ref(lua_state());
10454  }
10455 
10456  int copy_ref(lua_State* L_) const noexcept {
10457  return stateless_reference::copy_ref(L_);
10458  }
10459 
10460  public:
10461  basic_reference() noexcept = default;
10463  }
10464  basic_reference(const stack_reference& r) noexcept : basic_reference(r.lua_state(), r.stack_index()) {
10465  }
10466  basic_reference(stack_reference&& r) noexcept : basic_reference(r.lua_state(), r.stack_index()) {
10467  }
10468  template <bool r_main_only>
10469  basic_reference(lua_State* L_, const basic_reference<r_main_only>& r) noexcept : luastate(detail::pick_main_thread<main_only>(L_, L_)) {
10470  if (r.ref == LUA_REFNIL) {
10471  ref = LUA_REFNIL;
10472  return;
10473  }
10474  if (r.ref == LUA_NOREF || lua_state() == nullptr) {
10475  ref = LUA_NOREF;
10476  return;
10477  }
10478  if (detail::xmovable(lua_state(), r.lua_state())) {
10479  r.push(lua_state());
10480  ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
10481  return;
10482  }
10483  ref = r.copy_ref();
10484  }
10485 
10486  template <bool r_main_only>
10487  basic_reference(lua_State* L_, basic_reference<r_main_only>&& r) noexcept : luastate(detail::pick_main_thread<main_only>(L_, L_)) {
10488  if (r.ref == LUA_REFNIL) {
10489  ref = LUA_REFNIL;
10490  return;
10491  }
10492  if (r.ref == LUA_NOREF || lua_state() == nullptr) {
10493  ref = LUA_NOREF;
10494  return;
10495  }
10496  if (detail::xmovable(lua_state(), r.lua_state())) {
10497  r.push(lua_state());
10498  ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
10499  return;
10500  }
10501  ref = r.ref;
10502  r.ref = LUA_NOREF;
10503  r.luastate = nullptr;
10504  }
10505 
10506  basic_reference(lua_State* L_, const stack_reference& r) noexcept : luastate(detail::pick_main_thread<main_only>(L_, L_)) {
10507  if (lua_state() == nullptr || r.lua_state() == nullptr || r.get_type() == type::none) {
10508  ref = LUA_NOREF;
10509  return;
10510  }
10511  if (r.get_type() == type::lua_nil) {
10512  ref = LUA_REFNIL;
10513  return;
10514  }
10515  if (lua_state() != r.lua_state() && !detail::xmovable(lua_state(), r.lua_state())) {
10516  return;
10517  }
10518  r.push(lua_state());
10519  ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
10520  }
10521  basic_reference(lua_State* L_, int index = -1) noexcept : luastate(detail::pick_main_thread<main_only>(L_, L_)) {
10522  // use L_ to stick with that state's execution stack
10523 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
10524  luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value");
10525 #endif // make sure stack doesn't overflow
10526  lua_pushvalue(L_, index);
10527  ref = luaL_ref(L_, LUA_REGISTRYINDEX);
10528  }
10529  basic_reference(lua_State* L_, ref_index index) noexcept : luastate(detail::pick_main_thread<main_only>(L_, L_)) {
10530  lua_rawgeti(lua_state(), LUA_REGISTRYINDEX, index.index);
10531  ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
10532  }
10533  basic_reference(lua_State* L_, lua_nil_t) noexcept : luastate(detail::pick_main_thread<main_only>(L_, L_)) {
10534  }
10535 
10536  ~basic_reference() noexcept {
10537  if (lua_state() == nullptr || ref == LUA_NOREF)
10538  return;
10539  deref();
10540  }
10541 
10542  basic_reference(const basic_reference& o) noexcept : stateless_reference(o.copy_ref()), luastate(o.lua_state()) {
10543  }
10544 
10545  basic_reference(basic_reference&& o) noexcept : stateless_reference(std::move(o)), luastate(o.lua_state()) {
10546  o.luastate = nullptr;
10547  }
10548 
10550  : basic_reference(detail::pick_main_thread<main_only>(o.lua_state(), o.lua_state()), o) {
10551  }
10552 
10554  : stateless_reference(std::move(o)), luastate(detail::pick_main_thread<main_only>(o.lua_state(), o.lua_state())) {
10555  o.luastate = nullptr;
10556  o.ref = LUA_NOREF;
10557  }
10558 
10560  move_assign(std::move(r));
10561  return *this;
10562  }
10563 
10565  copy_assign_complex(r);
10566  return *this;
10567  }
10568 
10570  move_assign(std::move(r));
10571  return *this;
10572  }
10573 
10575  copy_assign_complex(r);
10576  return *this;
10577  }
10578 
10580  reset();
10581  return *this;
10582  }
10583 
10584  template <typename Super>
10585  basic_reference& operator=(proxy_base<Super>&& r);
10586 
10587  template <typename Super>
10588  basic_reference& operator=(const proxy_base<Super>& r);
10589 
10590  int push() const noexcept {
10591  return push(lua_state());
10592  }
10593 
10594  void reset() noexcept {
10595  stateless_reference::reset(luastate);
10596  luastate = nullptr;
10597  }
10598 
10599  int push(lua_State* L_) const noexcept {
10600 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
10601  luaL_checkstack(L_, 1, "not enough Lua stack space to push this reference value");
10602 #endif // make sure stack doesn't overflow
10603  if (lua_state() == nullptr) {
10604  lua_pushnil(L_);
10605  return 1;
10606  }
10607  lua_rawgeti(lua_state(), LUA_REGISTRYINDEX, ref);
10608  if (L_ != lua_state()) {
10609  lua_xmove(lua_state(), L_, 1);
10610  }
10611  return 1;
10612  }
10613 
10614  void pop() const noexcept {
10615  pop(lua_state());
10616  }
10617 
10618  void pop(lua_State* L_, int n = 1) const noexcept {
10619  stateless_reference::pop(L_, n);
10620  }
10621 
10622  int registry_index() const noexcept {
10624  }
10625 
10626  bool valid() const noexcept {
10627  return stateless_reference::valid(lua_state());
10628  }
10629 
10630  bool valid(lua_State* L_) const noexcept {
10631  return stateless_reference::valid(L_);
10632  }
10633 
10634  const void* pointer() const noexcept {
10635  return stateless_reference::pointer(lua_state());
10636  }
10637 
10638  explicit operator bool() const noexcept {
10639  return valid();
10640  }
10641 
10642  type get_type() const noexcept {
10643  return stateless_reference::get_type(lua_state());
10644  }
10645 
10646  lua_State* lua_state() const noexcept {
10647  return luastate;
10648  }
10649  };
10650 
10651  template <bool lb, bool rb>
10652  inline bool operator==(const basic_reference<lb>& l, const basic_reference<rb>& r) noexcept {
10653  auto ppl = stack::push_pop(l);
10654  auto ppr = stack::push_pop(r);
10655  return lua_compare(l.lua_state(), -1, -2, LUA_OPEQ) == 1;
10656  }
10657 
10658  template <bool lb, bool rb>
10659  inline bool operator!=(const basic_reference<lb>& l, const basic_reference<rb>& r) noexcept {
10660  return !operator==(l, r);
10661  }
10662 
10663  template <bool lb>
10664  inline bool operator==(const basic_reference<lb>& l, const stack_reference& r) noexcept {
10665  auto ppl = stack::push_pop(l);
10666  return lua_compare(l.lua_state(), -1, r.stack_index(), LUA_OPEQ) == 1;
10667  }
10668 
10669  template <bool lb>
10670  inline bool operator!=(const basic_reference<lb>& l, const stack_reference& r) noexcept {
10671  return !operator==(l, r);
10672  }
10673 
10674  template <bool rb>
10675  inline bool operator==(const stack_reference& l, const basic_reference<rb>& r) noexcept {
10676  auto ppr = stack::push_pop(r);
10677  return lua_compare(l.lua_state(), -1, r.stack_index(), LUA_OPEQ) == 1;
10678  }
10679 
10680  template <bool rb>
10681  inline bool operator!=(const stack_reference& l, const basic_reference<rb>& r) noexcept {
10682  return !operator==(l, r);
10683  }
10684 
10685  template <bool lb>
10686  inline bool operator==(const basic_reference<lb>& lhs, const lua_nil_t&) noexcept {
10687  return !lhs.valid();
10688  }
10689 
10690  template <bool rb>
10691  inline bool operator==(const lua_nil_t&, const basic_reference<rb>& rhs) noexcept {
10692  return !rhs.valid();
10693  }
10694 
10695  template <bool lb>
10696  inline bool operator!=(const basic_reference<lb>& lhs, const lua_nil_t&) noexcept {
10697  return lhs.valid();
10698  }
10699 
10700  template <bool rb>
10701  inline bool operator!=(const lua_nil_t&, const basic_reference<rb>& rhs) noexcept {
10702  return rhs.valid();
10703  }
10704 
10705  inline bool operator==(const stateless_reference& l, const stateless_reference& r) noexcept {
10706  return l.registry_index() == r.registry_index();
10707  }
10708 
10709  inline bool operator!=(const stateless_reference& l, const stateless_reference& r) noexcept {
10710  return l.registry_index() != r.registry_index();
10711  }
10712 
10713  inline bool operator==(const stateless_reference& lhs, const lua_nil_t&) noexcept {
10714  return lhs.registry_index() == LUA_REFNIL;
10715  }
10716 
10717  inline bool operator==(const lua_nil_t&, const stateless_reference& rhs) noexcept {
10718  return rhs.registry_index() == LUA_REFNIL;
10719  }
10720 
10721  inline bool operator!=(const stateless_reference& lhs, const lua_nil_t&) noexcept {
10722  return lhs.registry_index() != LUA_REFNIL;
10723  }
10724 
10725  inline bool operator!=(const lua_nil_t&, const stateless_reference& rhs) noexcept {
10726  return rhs.registry_index() != LUA_REFNIL;
10727  }
10728 
10731 
10733  }
10734 
10735  bool operator()(const lua_nil_t& lhs, const stateless_reference& rhs) const noexcept {
10736  return rhs.equals(lua_state(), lhs);
10737  }
10738 
10739  bool operator()(const stateless_reference& lhs, const lua_nil_t& rhs) const noexcept {
10740  return lhs.equals(lua_state(), rhs);
10741  }
10742 
10743  bool operator()(const stateless_reference& lhs, const stateless_reference& rhs) const noexcept {
10744  return lhs.equals(lua_state(), rhs);
10745  }
10746  };
10747 
10750 
10751  template <bool rb>
10752  bool operator()(const lua_nil_t& lhs, const basic_reference<rb>& rhs) const noexcept {
10753  return lhs == rhs;
10754  }
10755 
10756  template <bool lb>
10757  bool operator()(const basic_reference<lb>& lhs, const lua_nil_t& rhs) const noexcept {
10758  return lhs == rhs;
10759  }
10760 
10761  template <bool lb, bool rb>
10762  bool operator()(const basic_reference<lb>& lhs, const basic_reference<rb>& rhs) const noexcept {
10763  return lhs == rhs;
10764  }
10765 
10766  template <bool lb>
10767  bool operator()(const basic_reference<lb>& lhs, const stack_reference& rhs) const noexcept {
10768  return lhs == rhs;
10769  }
10770 
10771  template <bool rb>
10772  bool operator()(const stack_reference& lhs, const basic_reference<rb>& rhs) const noexcept {
10773  return lhs == rhs;
10774  }
10775  };
10776 
10781 
10783  }
10784 
10785  result_type operator()(const stateless_reference& lhs) const noexcept {
10786  std::hash<const void*> h;
10787  return h(lhs.pointer(lua_state()));
10788  }
10789  };
10790 
10795 
10796  template <bool lb>
10797  result_type operator()(const basic_reference<lb>& lhs) const noexcept {
10798  std::hash<const void*> h;
10799  return h(lhs.pointer());
10800  }
10801  };
10802 } // namespace sol
10803 
10804 // end of sol/reference.hpp
10805 
10806 // beginning of sol/tie.hpp
10807 
10808 namespace sol {
10809 
10810  namespace detail {
10811  template <typename T>
10813  } // namespace detail
10814 
10815  template <typename T>
10816  struct tie_size : std::tuple_size<T> { };
10817 
10818  template <typename T>
10819  struct is_tieable : std::integral_constant<bool, (::sol::tie_size<T>::value > 0)> { };
10820 
10821  template <typename... Tn>
10822  struct tie_t : public std::tuple<std::add_lvalue_reference_t<Tn>...> {
10823  private:
10824  typedef std::tuple<std::add_lvalue_reference_t<Tn>...> base_t;
10825 
10826  template <typename T>
10827  void set(std::false_type, T&& target) {
10828  std::get<0>(*this) = std::forward<T>(target);
10829  }
10830 
10831  template <typename T>
10832  void set(std::true_type, T&& target) {
10833  typedef tie_size<meta::unqualified_t<T>> value_size;
10834  typedef tie_size<std::tuple<Tn...>> tie_size;
10835  typedef meta::conditional_t<(value_size::value < tie_size::value), value_size, tie_size> indices_size;
10836  typedef std::make_index_sequence<indices_size::value> indices;
10837  set_extra(detail::is_speshul<meta::unqualified_t<T>>(), indices(), std::forward<T>(target));
10838  }
10839 
10840  template <std::size_t... I, typename T>
10841  void set_extra(std::true_type, std::index_sequence<I...>, T&& target) {
10842  using std::get;
10843  (void)detail::swallow { 0, (get<I>(static_cast<base_t&>(*this)) = get<I>(types<Tn...>(), target), 0)..., 0 };
10844  }
10845 
10846  template <std::size_t... I, typename T>
10847  void set_extra(std::false_type, std::index_sequence<I...>, T&& target) {
10848  using std::get;
10849  (void)detail::swallow { 0, (get<I>(static_cast<base_t&>(*this)) = get<I>(target), 0)..., 0 };
10850  }
10851 
10852  public:
10853  using base_t::base_t;
10854 
10855  template <typename T>
10856  tie_t& operator=(T&& value) {
10857  typedef is_tieable<meta::unqualified_t<T>> tieable;
10858  set(tieable(), std::forward<T>(value));
10859  return *this;
10860  }
10861  };
10862 
10863  template <typename... Tn>
10864  struct tie_size<tie_t<Tn...>> : std::tuple_size<std::tuple<Tn...>> { };
10865 
10866  namespace adl_barrier_detail {
10867  template <typename... Tn>
10868  inline tie_t<std::remove_reference_t<Tn>...> tie(Tn&&... argn) {
10869  return tie_t<std::remove_reference_t<Tn>...>(std::forward<Tn>(argn)...);
10870  }
10871  } // namespace adl_barrier_detail
10872 
10873  using namespace adl_barrier_detail;
10874 
10875 } // namespace sol
10876 
10877 // end of sol/tie.hpp
10878 
10879 // beginning of sol/stack_guard.hpp
10880 
10881 #include <functional>
10882 
10883 namespace sol {
10884  namespace detail {
10885  inline void stack_fail(int, int) {
10886 #if SOL_IS_ON(SOL_EXCEPTIONS)
10887  throw error(detail::direct_error, "imbalanced stack after operation finish");
10888 #else
10889  // Lol, what do you want, an error printout? :3c
10890  // There's no sane default here. The right way would be C-style abort(), and that's not acceptable, so
10891  // hopefully someone will register their own stack_fail thing for the `fx` parameter of stack_guard.
10892 #endif // No Exceptions
10893  }
10894  } // namespace detail
10895 
10896  struct stack_guard {
10898  int top;
10899  std::function<void(int, int)> on_mismatch;
10900 
10902  }
10903  stack_guard(lua_State* L, int top, std::function<void(int, int)> fx = detail::stack_fail) : L(L), top(top), on_mismatch(std::move(fx)) {
10904  }
10905  bool check_stack(int modification = 0) const {
10906  int bottom = lua_gettop(L) + modification;
10907  if (top == bottom) {
10908  return true;
10909  }
10910  on_mismatch(top, bottom);
10911  return false;
10912  }
10914  check_stack();
10915  }
10916  };
10917 } // namespace sol
10918 
10919 // end of sol/stack_guard.hpp
10920 
10921 #include <vector>
10922 #include <bitset>
10923 #include <forward_list>
10924 #include <string>
10925 #include <limits>
10926 #include <algorithm>
10927 #include <sstream>
10928 #include <optional>
10929 #include <type_traits>
10930 
10931 namespace sol {
10932  namespace detail {
10933  struct with_function_tag { };
10934  struct as_reference_tag { };
10935  template <typename T>
10936  struct as_pointer_tag { };
10937  template <typename T>
10938  struct as_value_tag { };
10939  template <typename T>
10940  struct as_unique_tag { };
10941  template <typename T>
10942  struct as_table_tag { };
10943 
10944  template <typename Tag>
10945  inline constexpr bool is_tagged_v
10947  detail::
10948  as_pointer_tag> || meta::is_specialization_of_v<Tag, as_value_tag> || meta::is_specialization_of_v<Tag, as_unique_tag> || meta::is_specialization_of_v<Tag, as_table_tag> || std::is_same_v<Tag, as_reference_tag> || std::is_same_v<Tag, with_function_tag>;
10949 
10951 
10952  using unique_destructor = void (*)(void*);
10954 
10955  inline void* alloc_newuserdata(lua_State* L, std::size_t bytesize) {
10956 #if SOL_LUA_VERSION_I_ >= 504
10957  return lua_newuserdatauv(L, bytesize, 1);
10958 #else
10959  return lua_newuserdata(L, bytesize);
10960 #endif
10961  }
10962 
10964  // this handles arbitrary alignments...
10965  // make this into a power-of-2-only?
10966  // actually can't: this is a C++14-compatible framework,
10967  // power of 2 alignment is C++17
10968  std::uintptr_t offby = static_cast<std::uintptr_t>(ptr % alignment);
10969  std::uintptr_t padding = (alignment - offby) % alignment;
10970  ptr += padding;
10971  space -= padding;
10972  return ptr;
10973  }
10974 
10975  inline void* align(std::size_t alignment, void* ptr, std::size_t& space) {
10976  return reinterpret_cast<void*>(align(alignment, reinterpret_cast<std::uintptr_t>(ptr), space));
10977  }
10978 
10980  std::size_t space = (std::numeric_limits<std::size_t>::max)();
10981  return align(alignment, ptr, space) + size;
10982  }
10983 
10984  template <typename... Args>
10986  std::uintptr_t end = ptr;
10987  ((end = align_one(alignof(Args), sizeof(Args), end)), ...);
10988  return static_cast<std::size_t>(end - ptr);
10989  }
10990 
10991  template <typename... Args>
10993  static_assert(sizeof...(Args) > 0);
10994 
10995  constexpr std::size_t max_arg_alignment = (std::max)({ alignof(Args)... });
10996  if constexpr (max_arg_alignment <= alignof(std::max_align_t)) {
10997  // If all types are `good enough`, simply calculate alignment in case of the worst allocator
10998  std::size_t worst_required_size = 0;
10999  for (std::size_t ptr = 0; ptr < max_arg_alignment; ptr++) {
11000  worst_required_size = (std::max)(worst_required_size, aligned_space_for<Args...>(ptr));
11001  }
11002  return worst_required_size;
11003  }
11004  else {
11005  // For over-aligned types let's assume that every Arg in Args starts at the worst aligned address
11006  return (aligned_space_for<Args>(0x1) + ...);
11007  }
11008  }
11009 
11010  inline void* align_usertype_pointer(void* ptr) {
11011  using use_align = std::integral_constant<bool,
11012 #if SOL_IS_OFF(SOL_ALIGN_MEMORY)
11013  false
11014 #else
11015  (std::alignment_of<void*>::value > 1)
11016 #endif
11017  >;
11018  if (!use_align::value) {
11019  return ptr;
11020  }
11021  std::size_t space = (std::numeric_limits<std::size_t>::max)();
11022  return align(std::alignment_of<void*>::value, ptr, space);
11023  }
11024 
11025  template <bool pre_aligned = false, bool pre_shifted = false>
11027  using use_align = std::integral_constant<bool,
11028 #if SOL_IS_OFF(SOL_ALIGN_MEMORY)
11029  false
11030 #else
11031  (std::alignment_of<unique_destructor>::value > 1)
11032 #endif
11033  >;
11034  if (!pre_aligned) {
11036  }
11037  if (!pre_shifted) {
11038  ptr = static_cast<void*>(static_cast<char*>(ptr) + sizeof(void*));
11039  }
11040  if (!use_align::value) {
11041  return static_cast<void*>(static_cast<void**>(ptr) + 1);
11042  }
11043  std::size_t space = (std::numeric_limits<std::size_t>::max)();
11044  return align(std::alignment_of<unique_destructor>::value, ptr, space);
11045  }
11046 
11047  template <bool pre_aligned = false, bool pre_shifted = false>
11049  using use_align = std::integral_constant<bool,
11050 #if SOL_IS_OFF(SOL_ALIGN_MEMORY)
11051  false
11052 #else
11053  (std::alignment_of<unique_tag>::value > 1)
11054 #endif
11055  >;
11056  if (!pre_aligned) {
11058  }
11059  if (!pre_shifted) {
11060  ptr = static_cast<void*>(static_cast<char*>(ptr) + sizeof(unique_destructor));
11061  }
11062  if (!use_align::value) {
11063  return ptr;
11064  }
11065  std::size_t space = (std::numeric_limits<std::size_t>::max)();
11066  return align(std::alignment_of<unique_tag>::value, ptr, space);
11067  }
11068 
11069  template <typename T, bool pre_aligned = false, bool pre_shifted = false>
11071  typedef std::integral_constant<bool,
11072 #if SOL_IS_OFF(SOL_ALIGN_MEMORY)
11073  false
11074 #else
11075  (std::alignment_of_v<T> > 1)
11076 #endif
11077  >
11078  use_align;
11079  if (!pre_aligned) {
11081  }
11082  if (!pre_shifted) {
11083  ptr = static_cast<void*>(static_cast<char*>(ptr) + sizeof(unique_tag));
11084  }
11085  if (!use_align::value) {
11086  return ptr;
11087  }
11088  std::size_t space = (std::numeric_limits<std::size_t>::max)();
11089  return align(std::alignment_of_v<T>, ptr, space);
11090  }
11091 
11092  template <typename T>
11093  void* align_user(void* ptr) {
11094  typedef std::integral_constant<bool,
11095 #if SOL_IS_OFF(SOL_ALIGN_MEMORY)
11096  false
11097 #else
11098  (std::alignment_of_v<T> > 1)
11099 #endif
11100  >
11101  use_align;
11102  if (!use_align::value) {
11103  return ptr;
11104  }
11105  std::size_t space = (std::numeric_limits<std::size_t>::max)();
11106  return align(std::alignment_of_v<T>, ptr, space);
11107  }
11108 
11109  template <typename T>
11111  typedef std::integral_constant<bool,
11112 #if SOL_IS_OFF(SOL_ALIGN_MEMORY)
11113  false
11114 #else
11115  (std::alignment_of<T*>::value > 1)
11116 #endif
11117  >
11118  use_align;
11119  if (!use_align::value) {
11120  T** pointerpointer = static_cast<T**>(alloc_newuserdata(L, sizeof(T*)));
11121  return pointerpointer;
11122  }
11123  constexpr std::size_t initial_size = aligned_space_for<T*>();
11124 
11125  std::size_t allocated_size = initial_size;
11126  void* unadjusted = alloc_newuserdata(L, initial_size);
11127  void* adjusted = align(std::alignment_of<T*>::value, unadjusted, allocated_size);
11128  if (adjusted == nullptr) {
11129  // trash allocator can burn in hell
11130  lua_pop(L, 1);
11131  // luaL_error(L, "if you are the one that wrote this allocator you should feel bad for doing a
11132  // worse job than malloc/realloc and should go read some books, yeah?");
11133  luaL_error(L, "cannot properly align memory for '%s'", detail::demangle<T*>().data());
11134  }
11135  return static_cast<T**>(adjusted);
11136  }
11137 
11138  inline bool attempt_alloc(lua_State* L, std::size_t ptr_align, std::size_t ptr_size, std::size_t value_align,
11139  std::size_t allocated_size, void*& pointer_adjusted, void*& data_adjusted) {
11140  void* adjusted = alloc_newuserdata(L, allocated_size);
11141  pointer_adjusted = align(ptr_align, adjusted, allocated_size);
11142  if (pointer_adjusted == nullptr) {
11143  lua_pop(L, 1);
11144  return false;
11145  }
11146  // subtract size of what we're going to allocate there
11147  allocated_size -= ptr_size;
11148  adjusted = static_cast<void*>(static_cast<char*>(pointer_adjusted) + ptr_size);
11149  data_adjusted = align(value_align, adjusted, allocated_size);
11150  if (data_adjusted == nullptr) {
11151  lua_pop(L, 1);
11152  return false;
11153  }
11154  return true;
11155  }
11156 
11157  inline bool attempt_alloc_unique(lua_State* L, std::size_t ptr_align, std::size_t ptr_size, std::size_t real_align,
11158  std::size_t allocated_size, void*& pointer_adjusted, void*& dx_adjusted, void*& id_adjusted, void*& data_adjusted) {
11159  void* adjusted = alloc_newuserdata(L, allocated_size);
11160  pointer_adjusted = align(ptr_align, adjusted, allocated_size);
11161  if (pointer_adjusted == nullptr) {
11162  lua_pop(L, 1);
11163  return false;
11164  }
11165  allocated_size -= ptr_size;
11166 
11167  adjusted = static_cast<void*>(static_cast<char*>(pointer_adjusted) + ptr_size);
11168  dx_adjusted = align(std::alignment_of_v<unique_destructor>, adjusted, allocated_size);
11169  if (dx_adjusted == nullptr) {
11170  lua_pop(L, 1);
11171  return false;
11172  }
11173  allocated_size -= sizeof(unique_destructor);
11174 
11175  adjusted = static_cast<void*>(static_cast<char*>(dx_adjusted) + sizeof(unique_destructor));
11176 
11177  id_adjusted = align(std::alignment_of_v<unique_tag>, adjusted, allocated_size);
11178  if (id_adjusted == nullptr) {
11179  lua_pop(L, 1);
11180  return false;
11181  }
11182  allocated_size -= sizeof(unique_tag);
11183 
11184  adjusted = static_cast<void*>(static_cast<char*>(id_adjusted) + sizeof(unique_tag));
11185  data_adjusted = align(real_align, adjusted, allocated_size);
11186  if (data_adjusted == nullptr) {
11187  lua_pop(L, 1);
11188  return false;
11189  }
11190  return true;
11191  }
11192 
11193  template <typename T>
11195  typedef std::integral_constant<bool,
11196 #if SOL_IS_OFF(SOL_ALIGN_MEMORY)
11197  false
11198 #else
11199  (std::alignment_of<T*>::value > 1 || std::alignment_of_v<T> > 1)
11200 #endif
11201  >
11202  use_align;
11203  if (!use_align::value) {
11204  T** pointerpointer = static_cast<T**>(alloc_newuserdata(L, sizeof(T*) + sizeof(T)));
11205  T*& pointerreference = *pointerpointer;
11206  T* allocationtarget = reinterpret_cast<T*>(pointerpointer + 1);
11207  pointerreference = allocationtarget;
11208  return allocationtarget;
11209  }
11210 
11211  constexpr std::size_t initial_size = aligned_space_for<T*, T>();
11212 
11213  void* pointer_adjusted;
11214  void* data_adjusted;
11215  bool result
11216  = attempt_alloc(L, std::alignment_of_v<T*>, sizeof(T*), std::alignment_of_v<T>, initial_size, pointer_adjusted, data_adjusted);
11217  if (!result) {
11218  if (pointer_adjusted == nullptr) {
11219  luaL_error(L, "aligned allocation of userdata block (pointer section) for '%s' failed", detail::demangle<T>().c_str());
11220  }
11221  else {
11222  luaL_error(L, "aligned allocation of userdata block (data section) for '%s' failed", detail::demangle<T>().c_str());
11223  }
11224  return nullptr;
11225  }
11226 
11227  T** pointerpointer = reinterpret_cast<T**>(pointer_adjusted);
11228  T*& pointerreference = *pointerpointer;
11229  T* allocationtarget = reinterpret_cast<T*>(data_adjusted);
11230  pointerreference = allocationtarget;
11231  return allocationtarget;
11232  }
11233 
11234  template <typename T, typename Real>
11236  typedef std::integral_constant<bool,
11237 #if SOL_IS_OFF(SOL_ALIGN_MEMORY)
11238  false
11239 #else
11240  (std::alignment_of<T*>::value > 1 || std::alignment_of<unique_tag>::value > 1 || std::alignment_of<unique_destructor>::value > 1
11241  || std::alignment_of<Real>::value > 1)
11242 #endif
11243  >
11244  use_align;
11245  if (!use_align::value) {
11246  pref = static_cast<T**>(alloc_newuserdata(L, sizeof(T*) + sizeof(detail::unique_destructor) + sizeof(unique_tag) + sizeof(Real)));
11247  dx = static_cast<detail::unique_destructor*>(static_cast<void*>(pref + 1));
11248  id = static_cast<unique_tag*>(static_cast<void*>(dx + 1));
11249  Real* mem = static_cast<Real*>(static_cast<void*>(id + 1));
11250  return mem;
11251  }
11252 
11253  constexpr std::size_t initial_size = aligned_space_for<T*, unique_destructor, unique_tag, Real>();
11254 
11255  void* pointer_adjusted;
11256  void* dx_adjusted;
11257  void* id_adjusted;
11258  void* data_adjusted;
11259  bool result = attempt_alloc_unique(L,
11260  std::alignment_of_v<T*>,
11261  sizeof(T*),
11262  std::alignment_of_v<Real>,
11263  initial_size,
11264  pointer_adjusted,
11265  dx_adjusted,
11266  id_adjusted,
11267  data_adjusted);
11268  if (!result) {
11269  if (pointer_adjusted == nullptr) {
11270  luaL_error(L, "aligned allocation of userdata block (pointer section) for '%s' failed", detail::demangle<T>().c_str());
11271  }
11272  else if (dx_adjusted == nullptr) {
11273  luaL_error(L, "aligned allocation of userdata block (deleter section) for '%s' failed", detail::demangle<T>().c_str());
11274  }
11275  else {
11276  luaL_error(L, "aligned allocation of userdata block (data section) for '%s' failed", detail::demangle<T>().c_str());
11277  }
11278  return nullptr;
11279  }
11280 
11281  pref = static_cast<T**>(pointer_adjusted);
11282  dx = static_cast<detail::unique_destructor*>(dx_adjusted);
11283  id = static_cast<unique_tag*>(id_adjusted);
11284  Real* mem = static_cast<Real*>(data_adjusted);
11285  return mem;
11286  }
11287 
11288  template <typename T>
11290  typedef std::integral_constant<bool,
11291 #if SOL_IS_OFF(SOL_ALIGN_MEMORY)
11292  false
11293 #else
11294  (std::alignment_of_v<T> > 1)
11295 #endif
11296  >
11297  use_align;
11298  if (!use_align::value) {
11299  T* pointer = static_cast<T*>(alloc_newuserdata(L, sizeof(T)));
11300  return pointer;
11301  }
11302 
11303  constexpr std::size_t initial_size = aligned_space_for<T>();
11304 
11305  std::size_t allocated_size = initial_size;
11306  void* unadjusted = alloc_newuserdata(L, allocated_size);
11307  void* adjusted = align(std::alignment_of_v<T>, unadjusted, allocated_size);
11308  if (adjusted == nullptr) {
11309  lua_pop(L, 1);
11310  luaL_error(L, "cannot properly align memory for '%s'", detail::demangle<T>().data());
11311  }
11312  return static_cast<T*>(adjusted);
11313  }
11314 
11315  template <typename T>
11317  void* memory = lua_touserdata(L, 1);
11319  T** pdata = static_cast<T**>(memory);
11320  T* data = *pdata;
11321  std::allocator<T> alloc {};
11322  std::allocator_traits<std::allocator<T>>::destroy(alloc, data);
11323  return 0;
11324  }
11325 
11326  template <typename T>
11327  int unique_destroy(lua_State* L) noexcept {
11328  void* memory = lua_touserdata(L, 1);
11330  unique_destructor& dx = *static_cast<unique_destructor*>(memory);
11331  memory = align_usertype_unique_tag<true>(memory);
11332  (dx)(memory);
11333  return 0;
11334  }
11335 
11336  template <typename T>
11337  int user_alloc_destroy(lua_State* L) noexcept {
11338  void* memory = lua_touserdata(L, 1);
11339  void* aligned_memory = align_user<T>(memory);
11340  T* typed_memory = static_cast<T*>(aligned_memory);
11341  std::allocator<T> alloc;
11342  std::allocator_traits<std::allocator<T>>::destroy(alloc, typed_memory);
11343  return 0;
11344  }
11345 
11346  template <typename T, typename Real>
11347  void usertype_unique_alloc_destroy(void* memory) {
11348  void* aligned_memory = align_usertype_unique<Real, true>(memory);
11349  Real* typed_memory = static_cast<Real*>(aligned_memory);
11350  std::allocator<Real> alloc;
11351  std::allocator_traits<std::allocator<Real>>::destroy(alloc, typed_memory);
11352  }
11353 
11354  template <typename T>
11356  return luaL_error(L,
11357  "cannot call the destructor for '%s': it is either hidden (protected/private) or removed with '= "
11358  "delete' and thusly this type is being destroyed without properly destroying, invoking undefined "
11359  "behavior: please bind a usertype and specify a custom destructor to define the behavior properly",
11360  detail::demangle<T>().data());
11361  }
11362 
11363  template <typename T>
11364  void reserve(T&, std::size_t) {
11365  }
11366 
11367  template <typename T, typename Al>
11368  void reserve(std::vector<T, Al>& vec, std::size_t hint) {
11369  vec.reserve(hint);
11370  }
11371 
11372  template <typename T, typename Tr, typename Al>
11373  void reserve(std::basic_string<T, Tr, Al>& str, std::size_t hint) {
11374  str.reserve(hint);
11375  }
11376 
11378  return true;
11379  }
11380 
11383  std::bitset<64>& properties;
11385 
11386  properties_enrollment_allowed(int& times_through_, std::bitset<64>& properties_, automagic_enrollments& enrollments_)
11387  : times_through(times_through_), properties(properties_), enrollments(enrollments_) {
11388  }
11389 
11390  bool operator()(meta_function mf) const {
11391  bool p = properties[static_cast<std::size_t>(mf)];
11392  if (times_through > 0) {
11393  return p;
11394  }
11395  switch (mf) {
11396  case meta_function::length:
11397  return enrollments.length_operator && !p;
11398  case meta_function::pairs:
11399  return enrollments.pairs_operator && !p;
11400  case meta_function::call:
11401  return enrollments.call_operator && !p;
11403  return enrollments.less_than_operator && !p;
11405  return enrollments.less_than_or_equal_to_operator && !p;
11407  return enrollments.equal_to_operator && !p;
11408  default:
11409  break;
11410  }
11411  return !p;
11412  }
11413  };
11414 
11417  int& index;
11418 
11419  indexed_insert(lua_reg_table& registration_table_, int& index_ref_) : registration_table(registration_table_), index(index_ref_) {
11420  }
11421  void operator()(meta_function meta_function_name_, lua_CFunction c_function_) {
11422  registration_table[index] = luaL_Reg { to_string(meta_function_name_).c_str(), c_function_ };
11423  ++index;
11424  }
11425  };
11426  } // namespace detail
11427 
11428  namespace stack {
11429 
11430  template <typename T, bool global = false, bool raw = false, typename = void>
11432  template <typename T, typename P, bool global = false, bool raw = false, typename = void>
11434 
11435  template <typename T, bool global = false, bool raw = false, typename = void>
11437 
11438  template <typename T, typename = void>
11440  template <typename T, typename = void>
11442 
11443  template <typename T, typename = void>
11445  template <typename T, typename = void>
11447 
11448  template <typename T, typename = void>
11449  struct popper;
11450 
11451  template <typename T, typename = void>
11453 
11454  template <typename T, type t, typename = void>
11456  template <typename T, type t, typename = void>
11458 
11459  template <typename T, typename = void>
11461  template <typename T, typename = void>
11463 
11464  struct probe {
11465  bool success;
11466  int levels;
11467 
11468  probe(bool s, int l) : success(s), levels(l) {
11469  }
11470 
11471  operator bool() const {
11472  return success;
11473  };
11474  };
11475 
11476  struct record {
11477  int last;
11478  int used;
11479 
11480  record() noexcept : last(), used() {
11481  }
11482  void use(int count) noexcept {
11483  last = count;
11484  used += count;
11485  }
11486  };
11487 
11488  namespace stack_detail {
11489  template <typename Function>
11490  Function* get_function_pointer(lua_State*, int, record&) noexcept;
11491  template <typename Function, typename Handler>
11492  bool check_function_pointer(lua_State* L, int index, Handler&& handler, record& tracking) noexcept;
11493  } // namespace stack_detail
11494 
11495  } // namespace stack
11496 
11497  namespace meta { namespace meta_detail {
11498  template <typename T>
11499  using adl_sol_lua_get_test_t = decltype(sol_lua_get(types<T>(), static_cast<lua_State*>(nullptr), -1, std::declval<stack::record&>()));
11500 
11501  template <typename T>
11503  = decltype(sol_lua_interop_get(types<T>(), static_cast<lua_State*>(nullptr), -1, static_cast<void*>(nullptr), std::declval<stack::record&>()));
11504 
11505  template <typename T>
11506  using adl_sol_lua_check_test_t = decltype(sol_lua_check(types<T>(), static_cast<lua_State*>(nullptr), -1, &no_panic, std::declval<stack::record&>()));
11507 
11508  template <typename T>
11510  = decltype(sol_lua_interop_check(types<T>(), static_cast<lua_State*>(nullptr), -1, type::none, &no_panic, std::declval<stack::record&>()));
11511 
11512  template <typename T>
11514  = decltype(sol_lua_check_get(types<T>(), static_cast<lua_State*>(nullptr), -1, &no_panic, std::declval<stack::record&>()));
11515 
11516  template <typename... Args>
11517  using adl_sol_lua_push_test_t = decltype(sol_lua_push(static_cast<lua_State*>(nullptr), std::declval<Args>()...));
11518 
11519  template <typename T, typename... Args>
11520  using adl_sol_lua_push_exact_test_t = decltype(sol_lua_push(types<T>(), static_cast<lua_State*>(nullptr), std::declval<Args>()...));
11521 
11522  template <typename T>
11523  inline constexpr bool is_adl_sol_lua_get_v = meta::is_detected_v<adl_sol_lua_get_test_t, T>;
11524 
11525  template <typename T>
11526  inline constexpr bool is_adl_sol_lua_interop_get_v = meta::is_detected_v<adl_sol_lua_interop_get_test_t, T>;
11527 
11528  template <typename T>
11529  inline constexpr bool is_adl_sol_lua_check_v = meta::is_detected_v<adl_sol_lua_check_test_t, T>;
11530 
11531  template <typename T>
11532  inline constexpr bool is_adl_sol_lua_interop_check_v = meta::is_detected_v<adl_sol_lua_interop_check_test_t, T>;
11533 
11534  template <typename T>
11535  inline constexpr bool is_adl_sol_lua_check_get_v = meta::is_detected_v<adl_sol_lua_check_get_test_t, T>;
11536 
11537  template <typename... Args>
11539 
11540  template <typename T, typename... Args>
11542  }} // namespace meta::meta_detail
11543 
11544  namespace stack {
11545  namespace stack_detail {
11546  constexpr const char* not_enough_stack_space = "not enough space left on Lua stack";
11547  constexpr const char* not_enough_stack_space_floating = "not enough space left on Lua stack for a floating point number";
11548  constexpr const char* not_enough_stack_space_integral = "not enough space left on Lua stack for an integral number";
11549  constexpr const char* not_enough_stack_space_string = "not enough space left on Lua stack for a string";
11550  constexpr const char* not_enough_stack_space_meta_function_name = "not enough space left on Lua stack for the name of a meta_function";
11551  constexpr const char* not_enough_stack_space_userdata = "not enough space left on Lua stack to create a sol2 userdata";
11552  constexpr const char* not_enough_stack_space_generic = "not enough space left on Lua stack to push valuees";
11553  constexpr const char* not_enough_stack_space_environment = "not enough space left on Lua stack to retrieve environment";
11554 
11555  template <typename T>
11556  struct strip {
11557  typedef T type;
11558  };
11559  template <typename T>
11560  struct strip<std::reference_wrapper<T>> {
11561  typedef T& type;
11562  };
11563  template <typename T>
11564  struct strip<user<T>> {
11565  typedef T& type;
11566  };
11567  template <typename T>
11568  struct strip<non_null<T>> {
11569  typedef T type;
11570  };
11571  template <typename T>
11572  using strip_t = typename strip<T>::type;
11573 
11574  template <typename C>
11575  static int get_size_hint(C& c) {
11576  return static_cast<int>(c.size());
11577  }
11578 
11579  template <typename V, typename Al>
11580  static int get_size_hint(const std::forward_list<V, Al>&) {
11581  // forward_list makes me sad
11582  return static_cast<int>(32);
11583  }
11584 
11585  template <typename T>
11586  decltype(auto) unchecked_unqualified_get(lua_State* L, int index, record& tracking) {
11587  using Tu = meta::unqualified_t<T>;
11588  if constexpr (meta::meta_detail::is_adl_sol_lua_get_v<Tu>) {
11589  return sol_lua_get(types<Tu>(), L, index, tracking);
11590  }
11591  else {
11593  return g.get(L, index, tracking);
11594  }
11595  }
11596 
11597  template <typename T>
11598  decltype(auto) unchecked_get(lua_State* L, int index, record& tracking) {
11599  if constexpr (meta::meta_detail::is_adl_sol_lua_get_v<T>) {
11600  return sol_lua_get(types<T>(), L, index, tracking);
11601  }
11602  else {
11603  qualified_getter<T> g {};
11604  return g.get(L, index, tracking);
11605  }
11606  }
11607 
11608  template <typename T>
11609  decltype(auto) unqualified_interop_get(lua_State* L, int index, void* unadjusted_pointer, record& tracking) {
11610  using Tu = meta::unqualified_t<T>;
11611  if constexpr (meta::meta_detail::is_adl_sol_lua_interop_get_v<Tu>) {
11612  return sol_lua_interop_get(types<Tu>(), L, index, unadjusted_pointer, tracking);
11613  }
11614  else {
11615  (void)L;
11616  (void)index;
11617  (void)unadjusted_pointer;
11618  (void)tracking;
11619  using Ti = stack_detail::strip_t<Tu>;
11620  return std::pair<bool, Ti*> { false, nullptr };
11621  }
11622  }
11623 
11624  template <typename T>
11625  decltype(auto) interop_get(lua_State* L, int index, void* unadjusted_pointer, record& tracking) {
11626  if constexpr (meta::meta_detail::is_adl_sol_lua_interop_get_v<T>) {
11627  return sol_lua_interop_get(types<T>(), L, index, unadjusted_pointer, tracking);
11628  }
11629  else {
11630  return unqualified_interop_get<T>(L, index, unadjusted_pointer, tracking);
11631  }
11632  }
11633 
11634  template <typename T, typename Handler>
11635  bool unqualified_interop_check(lua_State* L, int index, type index_type, Handler&& handler, record& tracking) {
11636  using Tu = meta::unqualified_t<T>;
11637  if constexpr (meta::meta_detail::is_adl_sol_lua_interop_check_v<Tu>) {
11638  return sol_lua_interop_check(types<Tu>(), L, index, index_type, std::forward<Handler>(handler), tracking);
11639  }
11640  else {
11641  (void)L;
11642  (void)index;
11643  (void)index_type;
11644  (void)handler;
11645  (void)tracking;
11646  return false;
11647  }
11648  }
11649 
11650  template <typename T, typename Handler>
11651  bool interop_check(lua_State* L, int index, type index_type, Handler&& handler, record& tracking) {
11652  if constexpr (meta::meta_detail::is_adl_sol_lua_interop_check_v<T>) {
11653  return sol_lua_interop_check(types<T>(), L, index, index_type, std::forward<Handler>(handler), tracking);
11654  }
11655  else {
11656  return unqualified_interop_check<T>(L, index, index_type, std::forward<Handler>(handler), tracking);
11657  }
11658  }
11659 
11661 
11664  const char* key;
11666 
11667  undefined_metatable(lua_State* l, const char* k, undefined_method_func umf) : L(l), key(k), on_new_table(umf) {
11668  }
11669 
11670  void operator()() const {
11671  if (luaL_newmetatable(L, key) == 1) {
11672  on_new_table(stack_reference(L, -1));
11673  }
11674  lua_setmetatable(L, -2);
11675  }
11676  };
11677  } // namespace stack_detail
11678 
11679  inline bool maybe_indexable(lua_State* L, int index = -1) {
11680  type t = type_of(L, index);
11681  return t == type::userdata || t == type::table;
11682  }
11683 
11684  inline int top(lua_State* L) {
11685  return lua_gettop(L);
11686  }
11687 
11688  inline bool is_main_thread(lua_State* L) {
11689  int ismainthread = lua_pushthread(L);
11690  lua_pop(L, 1);
11691  return ismainthread == 1;
11692  }
11693 
11695  if (is_main_thread(L)) {
11696  return;
11697  }
11698  int stacksize = lua_gettop(L);
11699  if (stacksize < 1) {
11700  return;
11701  }
11702  if (type_of(L, 1) != type::function) {
11703  return;
11704  }
11705  // well now we're screwed...
11706  // we can clean the stack and pray it doesn't destroy anything?
11707  lua_pop(L, stacksize);
11708  }
11709 
11710  inline void clear(lua_State* L, int table_index) {
11711  lua_pushnil(L);
11712  while (lua_next(L, table_index) != 0) {
11713  // remove value
11714  lua_pop(L, 1);
11715  // duplicate key to protect form rawset
11716  lua_pushvalue(L, -1);
11717  // push new value
11718  lua_pushnil(L);
11719  // table_index%[key] = nil
11720  lua_rawset(L, table_index);
11721  }
11722  }
11723 
11724  inline void clear(reference& r) {
11725  auto pp = push_pop<false>(r);
11726  int stack_index = pp.index_of(r);
11727  clear(r.lua_state(), stack_index);
11728  }
11729 
11730  inline void clear(stack_reference& r) {
11731  clear(r.lua_state(), r.stack_index());
11732  }
11733 
11734  inline void clear(lua_State* L_, stateless_reference& r) {
11735  r.push(L_);
11736  int stack_index = absolute_index(L_, -1);
11737  clear(L_, stack_index);
11738  r.pop(L_);
11739  }
11740 
11742  clear(L_, r.stack_index());
11743  }
11744 
11745  template <typename T, typename... Args>
11746  int push(lua_State* L, T&& t, Args&&... args) {
11747  using Tu = meta::unqualified_t<T>;
11748  if constexpr (meta::meta_detail::is_adl_sol_lua_push_exact_v<T, T, Args...>) {
11749  return sol_lua_push(types<T>(), L, std::forward<T>(t), std::forward<Args>(args)...);
11750  }
11751  else if constexpr (meta::meta_detail::is_adl_sol_lua_push_exact_v<Tu, T, Args...>) {
11752  return sol_lua_push(types<Tu>(), L, std::forward<T>(t), std::forward<Args>(args)...);
11753  }
11754  else if constexpr (meta::meta_detail::is_adl_sol_lua_push_v<T, Args...>) {
11755  return sol_lua_push(L, std::forward<T>(t), std::forward<Args>(args)...);
11756  }
11757  else {
11759  return p.push(L, std::forward<T>(t), std::forward<Args>(args)...);
11760  }
11761  }
11762 
11763  // overload allows to use a pusher of a specific type, but pass in any kind of args
11764  template <typename T, typename Arg, typename... Args, typename = std::enable_if_t<!std::is_same<T, Arg>::value>>
11765  int push(lua_State* L, Arg&& arg, Args&&... args) {
11766  using Tu = meta::unqualified_t<T>;
11767  if constexpr (meta::meta_detail::is_adl_sol_lua_push_exact_v<T, Arg, Args...>) {
11768  return sol_lua_push(types<T>(), L, std::forward<Arg>(arg), std::forward<Args>(args)...);
11769  }
11770  else if constexpr (meta::meta_detail::is_adl_sol_lua_push_exact_v<Tu, Arg, Args...>) {
11771  return sol_lua_push(types<Tu>(), L, std::forward<Arg>(arg), std::forward<Args>(args)...);
11772  }
11773  else if constexpr (meta::meta_detail::is_adl_sol_lua_push_v<Arg, Args...> && !detail::is_tagged_v<Tu>) {
11774  return sol_lua_push(L, std::forward<Arg>(arg), std::forward<Args>(args)...);
11775  }
11776  else {
11778  return p.push(L, std::forward<Arg>(arg), std::forward<Args>(args)...);
11779  }
11780  }
11781 
11782  template <typename T, typename... Args>
11783  int push_userdata(lua_State* L, T&& t, Args&&... args) {
11784  using U = meta::unqualified_t<T>;
11788  return stack::push<Tr>(L, std::forward<T>(t), std::forward<Args>(args)...);
11789  }
11790 
11791  template <typename T, typename Arg, typename... Args>
11792  int push_userdata(lua_State* L, Arg&& arg, Args&&... args) {
11793  using U = meta::unqualified_t<T>;
11797  return stack::push<Tr>(L, std::forward<Arg>(arg), std::forward<Args>(args)...);
11798  }
11799 
11800  namespace stack_detail {
11801 
11802  template <typename T, typename Arg, typename... Args>
11803  int push_reference(lua_State* L, Arg&& arg, Args&&... args) {
11804  // clang-format off
11805  using use_reference_tag =
11806  meta::all<
11808 #if SOL_IS_OFF(SOL_FUNCTION_CALL_VALUE_SEMANTICS)
11809  , std::is_lvalue_reference<T>,
11813 #endif
11814  >;
11815  // clang-format on
11817  return stack::push<Tr>(L, std::forward<Arg>(arg), std::forward<Args>(args)...);
11818  }
11819 
11820  } // namespace stack_detail
11821 
11822  template <typename T, typename... Args>
11823  int push_reference(lua_State* L, T&& t, Args&&... args) {
11824  return stack_detail::push_reference<T>(L, std::forward<T>(t), std::forward<Args>(args)...);
11825  }
11826 
11827  template <typename T, typename Arg, typename... Args>
11828  int push_reference(lua_State* L, Arg&& arg, Args&&... args) {
11829  return stack_detail::push_reference<T>(L, std::forward<Arg>(arg), std::forward<Args>(args)...);
11830  }
11831 
11832  inline int multi_push(lua_State*) {
11833  // do nothing
11834  return 0;
11835  }
11836 
11837  template <typename T, typename... Args>
11838  int multi_push(lua_State* L, T&& t, Args&&... args) {
11839  int pushcount = push(L, std::forward<T>(t));
11840  void(detail::swallow { (pushcount += stack::push(L, std::forward<Args>(args)), 0)... });
11841  return pushcount;
11842  }
11843 
11845  // do nothing
11846  return 0;
11847  }
11848 
11849  template <typename T, typename... Args>
11850  int multi_push_reference(lua_State* L, T&& t, Args&&... args) {
11851  int pushcount = stack::push_reference(L, std::forward<T>(t));
11852  void(detail::swallow { (pushcount += stack::push_reference(L, std::forward<Args>(args)), 0)... });
11853  return pushcount;
11854  }
11855 
11856  template <typename T, typename Handler>
11857  bool unqualified_check(lua_State* L, int index, Handler&& handler, record& tracking) {
11858  using Tu = meta::unqualified_t<T>;
11859  if constexpr (meta::meta_detail::is_adl_sol_lua_check_v<Tu>) {
11860  return sol_lua_check(types<Tu>(), L, index, std::forward<Handler>(handler), tracking);
11861  }
11862  else {
11864  return c.check(L, index, std::forward<Handler>(handler), tracking);
11865  }
11866  }
11867 
11868  template <typename T, typename Handler>
11869  bool unqualified_check(lua_State* L, int index, Handler&& handler) {
11870  record tracking {};
11871  return unqualified_check<T>(L, index, std::forward<Handler>(handler), tracking);
11872  }
11873 
11874  template <typename T>
11876  auto handler = &no_panic;
11877  return unqualified_check<T>(L, index, handler);
11878  }
11879 
11880  template <typename T, typename Handler>
11881  bool check(lua_State* L, int index, Handler&& handler, record& tracking) {
11882  if constexpr (meta::meta_detail::is_adl_sol_lua_check_v<T>) {
11883  return sol_lua_check(types<T>(), L, index, std::forward<Handler>(handler), tracking);
11884  }
11885  else {
11886  using Tu = meta::unqualified_t<T>;
11888  return c.check(L, index, std::forward<Handler>(handler), tracking);
11889  }
11890  }
11891 
11892  template <typename T, typename Handler>
11893  bool check(lua_State* L, int index, Handler&& handler) {
11894  record tracking {};
11895  return check<T>(L, index, std::forward<Handler>(handler), tracking);
11896  }
11897 
11898  template <typename T>
11899  bool check(lua_State* L, int index = -lua_size<meta::unqualified_t<T>>::value) {
11900  auto handler = &no_panic;
11901  return check<T>(L, index, handler);
11902  }
11903 
11904  template <typename T, typename Handler>
11905  bool check_usertype(lua_State* L, int index, type, Handler&& handler, record& tracking) {
11906  using Tu = meta::unqualified_t<T>;
11908  return check<detail_t>(L, index, std::forward<Handler>(handler), tracking);
11909  }
11910 
11911  template <typename T, typename Handler>
11912  bool check_usertype(lua_State* L, int index, Handler&& handler, record& tracking) {
11913  using Tu = meta::unqualified_t<T>;
11915  return check<detail_t>(L, index, std::forward<Handler>(handler), tracking);
11916  }
11917 
11918  template <typename T, typename Handler>
11919  bool check_usertype(lua_State* L, int index, Handler&& handler) {
11920  record tracking {};
11921  return check_usertype<T>(L, index, std::forward<Handler>(handler), tracking);
11922  }
11923 
11924  template <typename T>
11925  bool check_usertype(lua_State* L, int index = -lua_size<meta::unqualified_t<T>>::value) {
11926  auto handler = &no_panic;
11927  return check_usertype<T>(L, index, handler);
11928  }
11929 
11930  template <typename T, typename Handler>
11931  decltype(auto) unqualified_check_get(lua_State* L, int index, Handler&& handler, record& tracking) {
11932  using Tu = meta::unqualified_t<T>;
11933  if constexpr (meta::meta_detail::is_adl_sol_lua_check_get_v<T>) {
11934  return sol_lua_check_get(types<T>(), L, index, std::forward<Handler>(handler), tracking);
11935  }
11936  else if constexpr (meta::meta_detail::is_adl_sol_lua_check_get_v<Tu>) {
11937  return sol_lua_check_get(types<Tu>(), L, index, std::forward<Handler>(handler), tracking);
11938  }
11939  else {
11941  return cg.get(L, index, std::forward<Handler>(handler), tracking);
11942  }
11943  }
11944 
11945  template <typename T, typename Handler>
11946  decltype(auto) unqualified_check_get(lua_State* L, int index, Handler&& handler) {
11947  record tracking {};
11948  return unqualified_check_get<T>(L, index, handler, tracking);
11949  }
11950 
11951  template <typename T>
11952  decltype(auto) unqualified_check_get(lua_State* L, int index = -lua_size<meta::unqualified_t<T>>::value) {
11953  auto handler = &no_panic;
11954  return unqualified_check_get<T>(L, index, handler);
11955  }
11956 
11957  template <typename T, typename Handler>
11958  decltype(auto) check_get(lua_State* L, int index, Handler&& handler, record& tracking) {
11959  if constexpr (meta::meta_detail::is_adl_sol_lua_check_get_v<T>) {
11960  return sol_lua_check_get(types<T>(), L, index, std::forward<Handler>(handler), tracking);
11961  }
11962  else {
11964  return cg.get(L, index, std::forward<Handler>(handler), tracking);
11965  }
11966  }
11967 
11968  template <typename T, typename Handler>
11969  decltype(auto) check_get(lua_State* L, int index, Handler&& handler) {
11970  record tracking {};
11971  return check_get<T>(L, index, handler, tracking);
11972  }
11973 
11974  template <typename T>
11975  decltype(auto) check_get(lua_State* L, int index = -lua_size<meta::unqualified_t<T>>::value) {
11976  auto handler = &no_panic;
11977  return check_get<T>(L, index, handler);
11978  }
11979 
11980  namespace stack_detail {
11981 
11982  template <typename Handler>
11983  bool check_types(lua_State*, int, Handler&&, record&) {
11984  return true;
11985  }
11986 
11987  template <typename T, typename... Args, typename Handler>
11988  bool check_types(lua_State* L, int firstargument, Handler&& handler, record& tracking) {
11989  if (!stack::check<T>(L, firstargument + tracking.used, handler, tracking))
11990  return false;
11991  return check_types<Args...>(L, firstargument, std::forward<Handler>(handler), tracking);
11992  }
11993 
11994  template <typename... Args, typename Handler>
11995  bool check_types(types<Args...>, lua_State* L, int index, Handler&& handler, record& tracking) {
11996  return check_types<Args...>(L, index, std::forward<Handler>(handler), tracking);
11997  }
11998 
11999  } // namespace stack_detail
12000 
12001  template <typename... Args, typename Handler>
12002  bool multi_check(lua_State* L, int index, Handler&& handler, record& tracking) {
12003  return stack_detail::check_types<Args...>(L, index, std::forward<Handler>(handler), tracking);
12004  }
12005 
12006  template <typename... Args, typename Handler>
12007  bool multi_check(lua_State* L, int index, Handler&& handler) {
12008  record tracking {};
12009  return multi_check<Args...>(L, index, std::forward<Handler>(handler), tracking);
12010  }
12011 
12012  template <typename... Args>
12013  bool multi_check(lua_State* L, int index) {
12014  return multi_check<Args...>(L, index);
12015  }
12016 
12017  template <typename T>
12018  auto unqualified_get(lua_State* L, int index, record& tracking) -> decltype(stack_detail::unchecked_unqualified_get<T>(L, index, tracking)) {
12019 #if SOL_IS_ON(SOL_SAFE_GETTER)
12020  static constexpr bool is_op = meta::is_optional_v<T>;
12021  if constexpr (is_op) {
12022  return stack_detail::unchecked_unqualified_get<T>(L, index, tracking);
12023  }
12024  else {
12026  return stack_detail::unchecked_unqualified_get<T>(L, index, tracking);
12027  }
12028  auto op = unqualified_check_get<T>(L, index, type_panic_c_str, tracking);
12029  return *std::move(op);
12030  }
12031 #else
12032  return stack_detail::unchecked_unqualified_get<T>(L, index, tracking);
12033 #endif
12034  }
12035 
12036  template <typename T>
12037  decltype(auto) unqualified_get(lua_State* L, int index = -lua_size<meta::unqualified_t<T>>::value) {
12038  record tracking {};
12039  return unqualified_get<T>(L, index, tracking);
12040  }
12041 
12042  template <typename T>
12043  auto get(lua_State* L, int index, record& tracking) -> decltype(stack_detail::unchecked_get<T>(L, index, tracking)) {
12044 #if SOL_IS_ON(SOL_SAFE_GETTER)
12045  static constexpr bool is_op = meta::is_optional_v<T>;
12046  if constexpr (is_op) {
12047  return stack_detail::unchecked_get<T>(L, index, tracking);
12048  }
12049  else {
12051  return stack_detail::unchecked_get<T>(L, index, tracking);
12052  }
12053  auto op = check_get<T>(L, index, type_panic_c_str, tracking);
12054  return *std::move(op);
12055  }
12056 #else
12057  return stack_detail::unchecked_get<T>(L, index, tracking);
12058 #endif
12059  }
12060 
12061  template <typename T>
12062  decltype(auto) get(lua_State* L, int index = -lua_size<meta::unqualified_t<T>>::value) {
12063  record tracking {};
12064  return get<T>(L, index, tracking);
12065  }
12066 
12067  template <typename T>
12068  decltype(auto) get_usertype(lua_State* L, int index, record& tracking) {
12070  return get<UT>(L, index, tracking);
12071  }
12072 
12073  template <typename T>
12074  decltype(auto) get_usertype(lua_State* L, int index = -lua_size_v<meta::unqualified_t<T>>) {
12075  record tracking {};
12076  return get_usertype<T>(L, index, tracking);
12077  }
12078 
12079  template <typename T>
12080  decltype(auto) pop(lua_State* L) {
12081  return popper<T> {}.pop(L);
12082  }
12083 
12084  template <bool global = false, bool raw = false, typename Key>
12085  void get_field(lua_State* L, Key&& key) {
12086  field_getter<meta::unqualified_t<Key>, global, raw> {}.get(L, std::forward<Key>(key));
12087  }
12088 
12089  template <bool global = false, bool raw = false, typename Key>
12090  void get_field(lua_State* L, Key&& key, int tableindex) {
12091  field_getter<meta::unqualified_t<Key>, global, raw> {}.get(L, std::forward<Key>(key), tableindex);
12092  }
12093 
12094  template <bool global = false, typename Key>
12095  void raw_get_field(lua_State* L, Key&& key) {
12096  get_field<global, true>(L, std::forward<Key>(key));
12097  }
12098 
12099  template <bool global = false, typename Key>
12100  void raw_get_field(lua_State* L, Key&& key, int tableindex) {
12101  get_field<global, true>(L, std::forward<Key>(key), tableindex);
12102  }
12103 
12104  template <bool global = false, bool raw = false, typename C = detail::non_lua_nil_t, typename Key>
12106  return probe_field_getter<meta::unqualified_t<Key>, C, global, raw> {}.get(L, std::forward<Key>(key));
12107  }
12108 
12109  template <bool global = false, bool raw = false, typename C = detail::non_lua_nil_t, typename Key>
12110  probe probe_get_field(lua_State* L, Key&& key, int tableindex) {
12111  return probe_field_getter<meta::unqualified_t<Key>, C, global, raw> {}.get(L, std::forward<Key>(key), tableindex);
12112  }
12113 
12114  template <bool global = false, typename C = detail::non_lua_nil_t, typename Key>
12116  return probe_get_field<global, true, C>(L, std::forward<Key>(key));
12117  }
12118 
12119  template <bool global = false, typename C = detail::non_lua_nil_t, typename Key>
12120  probe probe_raw_get_field(lua_State* L, Key&& key, int tableindex) {
12121  return probe_get_field<global, true, C>(L, std::forward<Key>(key), tableindex);
12122  }
12123 
12124  template <bool global = false, bool raw = false, typename Key, typename Value>
12125  void set_field(lua_State* L, Key&& key, Value&& value) {
12126  field_setter<meta::unqualified_t<Key>, global, raw> {}.set(L, std::forward<Key>(key), std::forward<Value>(value));
12127  }
12128 
12129  template <bool global = false, bool raw = false, typename Key, typename Value>
12130  void set_field(lua_State* L, Key&& key, Value&& value, int tableindex) {
12131  field_setter<meta::unqualified_t<Key>, global, raw> {}.set(L, std::forward<Key>(key), std::forward<Value>(value), tableindex);
12132  }
12133 
12134  template <bool global = false, typename Key, typename Value>
12135  void raw_set_field(lua_State* L, Key&& key, Value&& value) {
12136  set_field<global, true>(L, std::forward<Key>(key), std::forward<Value>(value));
12137  }
12138 
12139  template <bool global = false, typename Key, typename Value>
12140  void raw_set_field(lua_State* L, Key&& key, Value&& value, int tableindex) {
12141  set_field<global, true>(L, std::forward<Key>(key), std::forward<Value>(value), tableindex);
12142  }
12143 
12144  template <typename T, typename F>
12145  void modify_unique_usertype_as(const stack_reference& obj, F&& f) {
12146  void* raw = lua_touserdata(obj.lua_state(), obj.stack_index());
12147  void* ptr_memory = detail::align_usertype_pointer(raw);
12148  void* uu_memory = detail::align_usertype_unique<T>(raw);
12149  T& uu = *static_cast<T*>(uu_memory);
12150  f(uu);
12151  *static_cast<void**>(ptr_memory) = static_cast<void*>(detail::unique_get(obj.lua_state(), uu));
12152  }
12153 
12154  template <typename F>
12155  void modify_unique_usertype(const stack_reference& obj, F&& f) {
12157  using T = typename bt::template arg_at<0>;
12158  using Tu = meta::unqualified_t<T>;
12159  modify_unique_usertype_as<Tu>(obj, std::forward<F>(f));
12160  }
12161 
12162  namespace stack_detail {
12163  template <typename T, typename Handler>
12164  decltype(auto) check_get_arg(lua_State* L_, int index_, Handler&& handler_, record& tracking_) {
12165  if constexpr (meta::meta_detail::is_adl_sol_lua_check_access_v<T>) {
12166  sol_lua_check_access(types<meta::unqualified_t<T>>(), L_, index_, tracking_);
12167  }
12168  return check_get<T>(L_, index_, std::forward<Handler>(handler_), tracking_);
12169  }
12170 
12171  template <typename T>
12172  decltype(auto) unchecked_get_arg(lua_State* L_, int index_, record& tracking_) {
12173  if constexpr (meta::meta_detail::is_adl_sol_lua_check_access_v<T>) {
12174  sol_lua_check_access(types<meta::unqualified_t<T>>(), L_, index_, tracking_);
12175  }
12176  return unchecked_get<T>(L_, index_, tracking_);
12177  }
12178  } // namespace stack_detail
12179 
12180  } // namespace stack
12181 
12182  namespace detail {
12183 
12184  template <typename T>
12186  if constexpr (is_unique_usertype_v<T>) {
12187  return &unique_destroy<T>;
12188  }
12189  else if constexpr (!std::is_pointer_v<T>) {
12190  return &usertype_alloc_destroy<T>;
12191  }
12192  else {
12193  return &cannot_destroy<T>;
12194  }
12195  }
12196 
12197  template <typename T>
12199  return &cannot_destroy<T>;
12200  }
12201 
12202  template <typename T>
12204  return make_destructor<T>(std::is_destructible<T>());
12205  }
12206 
12207  struct no_comp {
12208  template <typename A, typename B>
12209  bool operator()(A&&, B&&) const {
12210  return false;
12211  }
12212  };
12213 
12214  template <typename T>
12216  return stack::push(L, stack::check<T>(L, 1, &no_panic));
12217  }
12218 
12219  template <typename T>
12221  decltype(auto) ts = stack::get<T>(L, 1).to_string();
12222  return stack::push(L, std::forward<decltype(ts)>(ts));
12223  }
12224 
12225  template <typename T>
12227  return luaL_error(L,
12228  "cannot perform to_string on '%s': no 'to_string' overload in namespace, 'to_string' member "
12229  "function, or operator<<(ostream&, ...) present",
12230  detail::demangle<T>().data());
12231  }
12232 
12233  template <typename T>
12235  using namespace std;
12236  decltype(auto) ts = to_string(stack::get<T>(L, 1));
12237  return stack::push(L, std::forward<decltype(ts)>(ts));
12238  }
12239 
12240  template <typename T>
12242  return member_default_to_string<T>(meta::supports_to_string_member<T>(), L);
12243  }
12244 
12245  template <typename T>
12247  std::ostringstream oss;
12248  oss << stack::unqualified_get<T>(L, 1);
12249  return stack::push(L, oss.str());
12250  }
12251 
12252  template <typename T>
12254  return adl_default_to_string<T>(meta::supports_adl_to_string<T>(), L);
12255  }
12256 
12257  template <typename T>
12259  return oss_default_to_string<T>(meta::supports_op_left_shift<std::ostream, T>(), L);
12260  }
12261 
12262  template <typename T>
12264  decltype(auto) self = stack::unqualified_get<T>(L, 1);
12265  return stack::push(L, self.size());
12266  }
12267 
12268  template <typename T, typename Op>
12270  if constexpr (std::is_void_v<T>) {
12271  return stack::push(L, false);
12272  }
12273  else {
12274  auto maybel = stack::unqualified_check_get<T>(L, 1);
12275  if (!maybel) {
12276  return stack::push(L, false);
12277  }
12278  auto mayber = stack::unqualified_check_get<T>(L, 2);
12279  if (!mayber) {
12280  return stack::push(L, false);
12281  }
12282  decltype(auto) l = *maybel;
12283  decltype(auto) r = *mayber;
12284  if constexpr (std::is_same_v<no_comp, Op>) {
12285  std::equal_to<> op;
12286  return stack::push(L, op(detail::ptr(l), detail::ptr(r)));
12287  }
12288  else {
12289  if constexpr (std::is_same_v<std::equal_to<>, Op> // clang-format hack
12290  || std::is_same_v<std::less_equal<>, Op> //
12291  || std::is_same_v<std::less_equal<>, Op>) { //
12292  if (detail::ptr(l) == detail::ptr(r)) {
12293  return stack::push(L, true);
12294  }
12295  }
12296  Op op;
12297  return stack::push(L, op(detail::deref(l), detail::deref(r)));
12298  }
12299  }
12300  }
12301 
12302  template <typename T, typename IFx, typename Fx>
12303  void insert_default_registrations(IFx&& ifx, Fx&& fx);
12304 
12305  template <typename T, bool, bool>
12307 
12308  template <typename T>
12309  struct get_is_primitive<T, true, false>
12310  : meta::neg<std::is_reference<decltype(sol_lua_get(types<T>(), nullptr, -1, std::declval<stack::record&>()))>> { };
12311 
12312  template <typename T>
12313  struct get_is_primitive<T, false, true>
12314  : meta::neg<std::is_reference<decltype(sol_lua_get(types<meta::unqualified_t<T>>(), nullptr, -1, std::declval<stack::record&>()))>> { };
12315 
12316  template <typename T>
12317  struct get_is_primitive<T, true, true> : get_is_primitive<T, true, false> { };
12318 
12319  } // namespace detail
12320 
12321  template <typename T>
12323  : detail::get_is_primitive<T, meta::meta_detail::is_adl_sol_lua_get_v<T>, meta::meta_detail::is_adl_sol_lua_get_v<meta::unqualified_t<T>>> { };
12324 
12325 } // namespace sol
12326 
12327 // end of sol/stack_core.hpp
12328 
12329 // beginning of sol/stack_check.hpp
12330 
12331 // beginning of sol/stack_check_unqualified.hpp
12332 
12333 #include <memory>
12334 #include <functional>
12335 #include <utility>
12336 #include <cmath>
12337 #include <optional>
12338 #if SOL_IS_ON(SOL_STD_VARIANT)
12339 #include <variant>
12340 #endif // variant shenanigans
12341 
12342 namespace sol { namespace stack {
12343  template <typename Handler>
12344  bool loose_table_check(lua_State* L_, int index, Handler&& handler, record& tracking) {
12345  tracking.use(1);
12346  type t = type_of(L_, index);
12347  if (t == type::table) {
12348  return true;
12349  }
12350  if (t != type::userdata) {
12351  handler(L_, index, type::table, t, "value is not a table or a userdata that can behave like one");
12352  return false;
12353  }
12354  return true;
12355  }
12356 
12357  namespace stack_detail {
12358  inline bool impl_check_metatable(lua_State* L_, int index, const std::string& metakey, bool poptable) {
12359  luaL_getmetatable(L_, &metakey[0]);
12360  const type expectedmetatabletype = static_cast<type>(lua_type(L_, -1));
12361  if (expectedmetatabletype != type::lua_nil) {
12362  if (lua_rawequal(L_, -1, index) == 1) {
12363  lua_pop(L_, 1 + static_cast<int>(poptable));
12364  return true;
12365  }
12366  }
12367  lua_pop(L_, 1);
12368  return false;
12369  }
12370 
12371  template <typename T, bool poptable = true>
12372  inline bool check_metatable(lua_State* L_, int index = -2) {
12373  return impl_check_metatable(L_, index, usertype_traits<T>::metatable(), poptable);
12374  }
12375 
12376  template <type expected, int (*check_func)(lua_State*, int)>
12377  struct basic_check {
12378  template <typename Handler>
12379  static bool check(lua_State* L_, int index, Handler&& handler, record& tracking) {
12380  tracking.use(1);
12381  bool success = check_func(L_, index) == 1;
12382  if (!success) {
12383  // expected type, actual type
12384  handler(L_, index, expected, type_of(L_, index), "");
12385  }
12386  return success;
12387  }
12388  };
12389  } // namespace stack_detail
12390 
12391  template <typename T, typename>
12393  template <typename Handler>
12394  static bool check(lua_State*, int, type, Handler&&, record&) {
12395  return false;
12396  }
12397  };
12398 
12399  template <typename T, typename>
12401  template <typename Handler>
12402  static bool check(lua_State* L_, int index, type index_type, Handler&& handler, record& tracking) {
12403  return stack_detail::unqualified_interop_check<T>(L_, index, index_type, std::forward<Handler>(handler), tracking);
12404  }
12405  };
12406 
12407  template <typename T, type expected, typename>
12408  struct unqualified_checker {
12409  template <typename Handler>
12410  static bool check(lua_State* L_, int index, Handler&& handler, record& tracking) {
12411  if constexpr (std::is_same_v<T, bool>) {
12412  tracking.use(1);
12413  bool success = lua_isboolean(L_, index) == 1;
12414  if (!success) {
12415  // expected type, actual type
12416  handler(L_, index, expected, type_of(L_, index), "");
12417  }
12418  return success;
12419  }
12420  else if constexpr (meta::any_same_v<T,
12421  char
12422 #if SOL_IS_ON(SOL_CHAR8_T)
12423  ,
12424  char8_t
12425 #endif
12426  ,
12427  char16_t,
12428  char32_t>) {
12429  return stack::check<std::basic_string<T>>(L_, index, std::forward<Handler>(handler), tracking);
12430  }
12431  else if constexpr (std::is_integral_v<T> || std::is_same_v<T, lua_Integer>) {
12432  tracking.use(1);
12433 #if SOL_LUA_VERSION_I_ >= 503
12434  // Lua 5.3 and greater checks for numeric precision
12435 #if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS)
12436  // imprecise, sloppy conversions
12437  int isnum = 0;
12438  lua_tointegerx(L_, index, &isnum);
12439  const bool success = isnum != 0;
12440  if (!success) {
12441  // expected type, actual type
12443  }
12444 #elif SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS)
12445  // this check is precise, do not convert
12446  if (lua_isinteger(L_, index) == 1) {
12447  return true;
12448  }
12449  const bool success = false;
12450  if (!success) {
12451  // expected type, actual type
12453  }
12454 #else
12455  // Numerics are neither safe nor string-convertible
12456  type t = type_of(L_, index);
12457  const bool success = t == type::number;
12458 #endif
12459  if (!success) {
12460  // expected type, actual type
12462  }
12463  return success;
12464 #else
12465  // Lua 5.2 and below checks
12466 #if SOL_IS_OFF(SOL_STRINGS_ARE_NUMBERS)
12467  // must pre-check, because it will convert
12468  type t = type_of(L_, index);
12469  if (t != type::number) {
12470  // expected type, actual type
12472  return false;
12473  }
12474 #endif // Do not allow strings to be numbers
12475 
12476 #if SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS)
12477  int isnum = 0;
12478  const lua_Number v = lua_tonumberx(L_, index, &isnum);
12479  const bool success = isnum != 0 && static_cast<lua_Number>(llround(v)) == v;
12480 #else
12481  const bool success = true;
12482 #endif // Safe numerics and number precision checking
12483  if (!success) {
12484  // Use defines to provide a better error message!
12485 #if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS)
12487 #elif SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS)
12489 #else
12491 #endif
12492  }
12493  return success;
12494 #endif
12495  }
12496  else if constexpr (std::is_floating_point_v<T> || std::is_same_v<T, lua_Number>) {
12497  tracking.use(1);
12498 #if SOL_IS_ON(SOL_STRINGS_ARE_NUMBERS)
12499  bool success = lua_isnumber(L_, index) == 1;
12500  if (!success) {
12501  // expected type, actual type
12503  }
12504  return success;
12505 #else
12506  type t = type_of(L_, index);
12507  bool success = t == type::number;
12508  if (!success) {
12509  // expected type, actual type
12511  }
12512  return success;
12513 #endif // Strings are Numbers
12514  }
12515  else if constexpr (meta::any_same_v<T, type, this_state, this_main_state, this_environment, variadic_args>) {
12516  (void)L_;
12517  (void)index;
12518  (void)handler;
12519  tracking.use(0);
12520  return true;
12521  }
12522  else if constexpr (is_unique_usertype_v<T>) {
12523  using element = unique_usertype_element_t<T>;
12524  using actual = unique_usertype_actual_t<T>;
12525  const type indextype = type_of(L_, index);
12526  tracking.use(1);
12527  if (indextype != type::userdata) {
12528  handler(L_, index, type::userdata, indextype, "value is not a userdata");
12529  return false;
12530  }
12531  if (lua_getmetatable(L_, index) == 0) {
12532  return true;
12533  }
12534  int metatableindex = lua_gettop(L_);
12535  if (stack_detail::check_metatable<d::u<element>>(L_, metatableindex)) {
12536  void* memory = lua_touserdata(L_, index);
12539  bool success = &detail::usertype_unique_alloc_destroy<element, actual> == pdx;
12540  if (!success) {
12541  memory = detail::align_usertype_unique_tag<true>(memory);
12542 #if 0
12543  // New version, one day
12544 #else
12545  const char*& name_tag = *static_cast<const char**>(memory);
12546  success = usertype_traits<T>::qualified_name() == name_tag;
12547 #endif
12548  if (!success) {
12549  handler(L_, index, type::userdata, indextype, "value is a userdata but is not the correct unique usertype");
12550  }
12551  }
12552  return success;
12553  }
12554  lua_pop(L_, 1);
12555  handler(L_, index, type::userdata, indextype, "unrecognized userdata (not pushed by sol?)");
12556  return false;
12557  }
12558  else if constexpr (meta::any_same_v<T, lua_nil_t, std::nullopt_t, nullopt_t>) {
12559  bool success = lua_isnil(L_, index);
12560  if (success) {
12561  tracking.use(1);
12562  return success;
12563  }
12564  tracking.use(0);
12565  success = lua_isnone(L_, index);
12566  if (!success) {
12567  // expected type, actual type
12568  handler(L_, index, expected, type_of(L_, index), "");
12569  }
12570  return success;
12571  }
12572  else if constexpr (std::is_same_v<T, env_key_t>) {
12573  tracking.use(1);
12574  type t = type_of(L_, index);
12575  if (t == type::table || t == type::none || t == type::lua_nil || t == type::userdata) {
12576  return true;
12577  }
12578  handler(L_, index, type::table, t, "value cannot not have a valid environment");
12579  return true;
12580  }
12581  else if constexpr (std::is_same_v<T, detail::non_lua_nil_t>) {
12582  return !stack::unqualified_check<lua_nil_t>(L_, index, std::forward<Handler>(handler), tracking);
12583  }
12584  else if constexpr (meta::is_specialization_of_v<T, basic_lua_table>) {
12585  tracking.use(1);
12586  type t = type_of(L_, index);
12587  if (t != type::table) {
12588  handler(L_, index, type::table, t, "value is not a table");
12589  return false;
12590  }
12591  return true;
12592  }
12593  else if constexpr (meta::is_specialization_of_v<T, basic_bytecode>) {
12594  tracking.use(1);
12595  type t = type_of(L_, index);
12596  if (t != type::function) {
12597  handler(L_, index, type::function, t, "value is not a function that can be dumped");
12598  return false;
12599  }
12600  return true;
12601  }
12602  else if constexpr (meta::is_specialization_of_v<T, basic_environment>) {
12603  tracking.use(1);
12604  if (lua_getmetatable(L_, index) == 0) {
12605  return true;
12606  }
12607  type t = type_of(L_, -1);
12608  if (t == type::table || t == type::none || t == type::lua_nil) {
12609  lua_pop(L_, 1);
12610  return true;
12611  }
12612  if (t != type::userdata) {
12613  lua_pop(L_, 1);
12614  handler(L_, index, type::table, t, "value does not have a valid metatable");
12615  return false;
12616  }
12617  return true;
12618  }
12619  else if constexpr (std::is_same_v<T, metatable_key_t>) {
12620  tracking.use(1);
12621  if (lua_getmetatable(L_, index) == 0) {
12622  return true;
12623  }
12624  type t = type_of(L_, -1);
12625  if (t == type::table || t == type::none || t == type::lua_nil) {
12626  lua_pop(L_, 1);
12627  return true;
12628  }
12629  if (t != type::userdata) {
12630  lua_pop(L_, 1);
12631  handler(L_, index, expected, t, "value does not have a valid metatable");
12632  return false;
12633  }
12634  return true;
12635  }
12636  else if constexpr (std::is_same_v<T, luaL_Stream*> || std::is_same_v<T, luaL_Stream>) {
12637  if (lua_getmetatable(L_, index) == 0) {
12638  type t = type_of(L_, index);
12639  handler(L_, index, expected, t, "value is not a valid luaL_Stream (has no metatable/is not a valid value)");
12640  return false;
12641  }
12643  if (type_of(L_, index) != type::table) {
12644  type t = type_of(L_, index);
12645  lua_pop(L_, 1);
12646  handler(L_,
12647  index,
12648  expected,
12649  t,
12650  "value is not a valid luaL_Stream (there is no metatable for luaL_Stream -- did you forget to "
12651  "my_lua_state.open_libraries(sol::lib::state) or equivalent?)");
12652  return false;
12653  }
12654  int is_stream_table = lua_compare(L_, -1, -2, LUA_OPEQ);
12655  lua_pop(L_, 2);
12656  if (is_stream_table == 0) {
12657  type t = type_of(L_, index);
12658  handler(L_, index, expected, t, "value is not a valid luaL_Stream (incorrect metatable)");
12659  return false;
12660  }
12661  return true;
12662  }
12663  else if constexpr (meta::is_optional_v<T>) {
12664  using ValueType = typename T::value_type;
12665  (void)handler;
12666  type t = type_of(L_, index);
12667  if (t == type::none) {
12668  tracking.use(0);
12669  return true;
12670  }
12671  if (t == type::lua_nil) {
12672  tracking.use(1);
12673  return true;
12674  }
12675  return stack::unqualified_check<ValueType>(L_, index, &no_panic, tracking);
12676  }
12677 #if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE)
12678  else if constexpr (std::is_function_v<T> || (std::is_pointer_v<T> && std::is_function_v<std::remove_pointer_t<T>>)) {
12679  return stack_detail::check_function_pointer<std::remove_pointer_t<T>>(L_, index, std::forward<Handler>(handler), tracking);
12680  }
12681 #endif
12682  else if constexpr (expected == type::userdata) {
12683  if constexpr (meta::any_same_v<T, userdata_value> || meta::is_specialization_of_v<T, basic_userdata>) {
12684  tracking.use(1);
12685  type t = type_of(L_, index);
12686  bool success = t == type::userdata;
12687  if (!success) {
12688  // expected type, actual type
12689  handler(L_, index, type::userdata, t, "");
12690  }
12691  return success;
12692  }
12693  else if constexpr (meta::is_specialization_of_v<T, user>) {
12695  (void)c;
12696  return c.check(L_, index, std::forward<Handler>(handler), tracking);
12697  }
12698  else {
12699  if constexpr (std::is_pointer_v<T>) {
12700  return check_usertype<T>(L_, index, std::forward<Handler>(handler), tracking);
12701  }
12702  else if constexpr (meta::is_specialization_of_v<T, std::reference_wrapper>) {
12703  using T_internal = typename T::type;
12704  return stack::check<T_internal>(L_, index, std::forward<Handler>(handler), tracking);
12705  }
12706  else {
12707  return check_usertype<T>(L_, index, std::forward<Handler>(handler), tracking);
12708  }
12709  }
12710  }
12711  else if constexpr (expected == type::poly) {
12712  tracking.use(1);
12713  bool success = is_lua_reference_v<T> || !lua_isnone(L_, index);
12714  if (!success) {
12715  // expected type, actual type
12716  handler(L_, index, type::poly, type_of(L_, index), "");
12717  }
12718  return success;
12719  }
12720  else if constexpr (expected == type::lightuserdata) {
12721  tracking.use(1);
12722  type t = type_of(L_, index);
12723  bool success = t == type::userdata || t == type::lightuserdata;
12724  if (!success) {
12725  // expected type, actual type
12726  handler(L_, index, type::lightuserdata, t, "");
12727  }
12728  return success;
12729  }
12730  else if constexpr (expected == type::function) {
12731  if constexpr (meta::any_same_v<T, lua_CFunction, std::remove_pointer_t<lua_CFunction>, c_closure>) {
12732  tracking.use(1);
12733  bool success = lua_iscfunction(L_, index) == 1;
12734  if (!success) {
12735  // expected type, actual type
12736  handler(L_, index, expected, type_of(L_, index), "");
12737  }
12738  return success;
12739  }
12740  else {
12741  tracking.use(1);
12742  type t = type_of(L_, index);
12743  if (t == type::lua_nil || t == type::none || t == type::function) {
12744  // allow for lua_nil to be returned
12745  return true;
12746  }
12747  if (t != type::userdata && t != type::table) {
12748  handler(L_, index, type::function, t, "must be a function or table or a userdata");
12749  return false;
12750  }
12751  // Do advanced check for call-style userdata?
12752  static const auto& callkey = to_string(meta_function::call);
12753  if (lua_getmetatable(L_, index) == 0) {
12754  // No metatable, no __call key possible
12755  handler(L_, index, type::function, t, "value is not a function and does not have overriden metatable");
12756  return false;
12757  }
12758  if (lua_isnoneornil(L_, -1)) {
12759  lua_pop(L_, 1);
12760  handler(L_, index, type::function, t, "value is not a function and does not have valid metatable");
12761  return false;
12762  }
12763  lua_getfield(L_, -1, &callkey[0]);
12764  if (lua_isnoneornil(L_, -1)) {
12765  lua_pop(L_, 2);
12766  handler(L_, index, type::function, t, "value's metatable does not have __call overridden in metatable, cannot call this type");
12767  return false;
12768  }
12769  // has call, is definitely a function
12770  lua_pop(L_, 2);
12771  return true;
12772  }
12773  }
12774  else if constexpr (expected == type::table) {
12775  return stack::loose_table_check(L_, index, std::forward<Handler>(handler), tracking);
12776  }
12777  else {
12778  tracking.use(1);
12779  const type indextype = type_of(L_, index);
12780  bool success = expected == indextype;
12781  if (!success) {
12782  // expected type, actual type, message
12783  handler(L_, index, expected, indextype, "");
12784  }
12785  return success;
12786  }
12787  }
12788  };
12789 
12790  template <typename T>
12791  struct unqualified_checker<non_null<T>, type::userdata> : unqualified_checker<T, lua_type_of_v<T>> { };
12792 
12793  template <typename T>
12794  struct unqualified_checker<detail::as_value_tag<T>, type::userdata> {
12795  template <typename Handler>
12796  static bool check(lua_State* L_, int index, Handler&& handler, record& tracking) {
12797  const type indextype = type_of(L_, index);
12798  return check(types<T>(), L_, index, indextype, std::forward<Handler>(handler), tracking);
12799  }
12800 
12801  template <typename U, typename Handler>
12802  static bool check(types<U>, lua_State* L_, int index, type indextype, Handler&& handler, record& tracking) {
12803  if constexpr (
12804  std::is_same_v<T,
12805  lightuserdata_value> || std::is_same_v<T, userdata_value> || std::is_same_v<T, userdata> || std::is_same_v<T, lightuserdata>) {
12806  tracking.use(1);
12807  if (indextype != type::userdata) {
12808  handler(L_, index, type::userdata, indextype, "value is not a valid userdata");
12809  return false;
12810  }
12811  return true;
12812  }
12813  else {
12814 #if SOL_IS_ON(SOL_USE_INTEROP)
12815  if (stack_detail::interop_check<U>(L_, index, indextype, handler, tracking)) {
12816  return true;
12817  }
12818 #endif // interop extensibility
12819  tracking.use(1);
12820 #if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE)
12821  if (lua_iscfunction(L_, index) != 0) {
12822  // a potential match...
12823  return true;
12824  }
12825 #endif
12826  if (indextype != type::userdata) {
12827  handler(L_, index, type::userdata, indextype, "value is not a valid userdata");
12828  return false;
12829  }
12830  if (lua_getmetatable(L_, index) == 0) {
12831  return true;
12832  }
12833  int metatableindex = lua_gettop(L_);
12834  if (stack_detail::check_metatable<U>(L_, metatableindex))
12835  return true;
12836  if (stack_detail::check_metatable<U*>(L_, metatableindex))
12837  return true;
12838  if (stack_detail::check_metatable<d::u<U>>(L_, metatableindex))
12839  return true;
12840  if (stack_detail::check_metatable<as_container_t<U>>(L_, metatableindex))
12841  return true;
12842  bool success = false;
12843  bool has_derived = derive<T>::value || weak_derive<T>::value;
12844  if (has_derived) {
12845 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
12847 #endif // make sure stack doesn't overflow
12848  auto pn = stack::pop_n(L_, 1);
12850  lua_rawget(L_, metatableindex);
12851  if (type_of(L_, -1) != type::lua_nil) {
12852  void* basecastdata = lua_touserdata(L_, -1);
12853  detail::inheritance_check_function ic = reinterpret_cast<detail::inheritance_check_function>(basecastdata);
12854  success = ic(usertype_traits<T>::qualified_name());
12855  }
12856  }
12857  lua_pop(L_, 1);
12858  if (!success) {
12859  handler(L_, index, type::userdata, indextype, "value at this index does not properly reflect the desired type");
12860  return false;
12861  }
12862  return true;
12863  }
12864  }
12865  };
12866 
12867  template <typename T>
12868  struct unqualified_checker<detail::as_pointer_tag<T>, type::userdata> {
12869  template <typename Handler>
12870  static bool check(lua_State* L_, int index, type indextype, Handler&& handler, record& tracking) {
12871  if (indextype == type::lua_nil) {
12872  tracking.use(1);
12873  return true;
12874  }
12875  return check_usertype<std::remove_pointer_t<T>>(L_, index, std::forward<Handler>(handler), tracking);
12876  }
12877 
12878  template <typename Handler>
12879  static bool check(lua_State* L_, int index, Handler&& handler, record& tracking) {
12880  const type indextype = type_of(L_, index);
12881  return check(L_, index, indextype, std::forward<Handler>(handler), tracking);
12882  }
12883  };
12884 
12885  template <typename... Args>
12886  struct unqualified_checker<std::tuple<Args...>, type::poly> {
12887  template <typename Handler>
12888  static bool check(lua_State* L_, int index, Handler&& handler, record& tracking) {
12889  return stack::multi_check<Args...>(L_, index, std::forward<Handler>(handler), tracking);
12890  }
12891  };
12892 
12893  template <typename A, typename B>
12894  struct unqualified_checker<std::pair<A, B>, type::poly> {
12895  template <typename Handler>
12896  static bool check(lua_State* L_, int index, Handler&& handler, record& tracking) {
12897  return stack::multi_check<A, B>(L_, index, std::forward<Handler>(handler), tracking);
12898  }
12899  };
12900 
12901 #if SOL_IS_ON(SOL_STD_VARIANT)
12902 
12903  template <typename... Tn>
12904  struct unqualified_checker<std::variant<Tn...>, type::poly> {
12905  typedef std::variant<Tn...> V;
12906  typedef std::variant_size<V> V_size;
12907  typedef std::integral_constant<bool, V_size::value == 0> V_is_empty;
12908 
12909  template <typename Handler>
12910  static bool is_one(std::integral_constant<std::size_t, 0>, lua_State* L_, int index, Handler&& handler, record& tracking) {
12911  if constexpr (V_is_empty::value) {
12912  if (lua_isnone(L_, index)) {
12913  return true;
12914  }
12915  }
12916  tracking.use(1);
12917  handler(L_, index, type::poly, type_of(L_, index), "value does not fit any type present in the variant");
12918  return false;
12919  }
12920 
12921  template <std::size_t I, typename Handler>
12922  static bool is_one(std::integral_constant<std::size_t, I>, lua_State* L_, int index, Handler&& handler, record& tracking) {
12923  typedef std::variant_alternative_t<I - 1, V> T;
12924  record temp_tracking = tracking;
12925  if (stack::check<T>(L_, index, &no_panic, temp_tracking)) {
12926  tracking = temp_tracking;
12927  return true;
12928  }
12929  return is_one(std::integral_constant<std::size_t, I - 1>(), L_, index, std::forward<Handler>(handler), tracking);
12930  }
12931 
12932  template <typename Handler>
12933  static bool check(lua_State* L_, int index, Handler&& handler, record& tracking) {
12934  return is_one(std::integral_constant<std::size_t, V_size::value>(), L_, index, std::forward<Handler>(handler), tracking);
12935  }
12936  };
12937 
12938 #endif // variant shenanigans
12939 
12940 }} // namespace sol::stack
12941 
12942 // end of sol/stack_check_unqualified.hpp
12943 
12944 // beginning of sol/stack_check_qualified.hpp
12945 
12946 namespace sol { namespace stack {
12947 
12948  template <typename X, type expected, typename>
12949  struct qualified_checker {
12950  template <typename Handler>
12951  static bool check(lua_State* L, int index, Handler&& handler, record& tracking) {
12952  using no_cv_X = meta::unqualified_t<X>;
12953  if constexpr (!std::is_reference_v<X> && is_unique_usertype_v<no_cv_X>) {
12954  using element = unique_usertype_element_t<no_cv_X>;
12955  if constexpr (is_actual_type_rebindable_for_v<no_cv_X>) {
12956  using rebound_actual_type = unique_usertype_rebind_actual_t<no_cv_X>;
12957  // we have a unique pointer type that can be
12958  // rebound to a base/derived type
12959  const type indextype = type_of(L, index);
12960  tracking.use(1);
12961  if (indextype != type::userdata) {
12962  handler(L, index, type::userdata, indextype, "value is not a userdata");
12963  return false;
12964  }
12965  void* memory = lua_touserdata(L, index);
12968  if (&detail::usertype_unique_alloc_destroy<element, no_cv_X> == pdx) {
12969  return true;
12970  }
12971  if constexpr (derive<element>::value) {
12972  memory = detail::align_usertype_unique_tag<true, false>(memory);
12973  detail::unique_tag& ic = *reinterpret_cast<detail::unique_tag*>(memory);
12976  if (ic(nullptr, nullptr, ti, rebind_ti) != 0) {
12977  return true;
12978  }
12979  }
12980  handler(L, index, type::userdata, indextype, "value is a userdata but is not the correct unique usertype");
12981  return false;
12982  }
12983  else {
12984  return stack::unqualified_check<X>(L, index, std::forward<Handler>(handler), tracking);
12985  }
12986  }
12987  else if constexpr (!std::is_reference_v<X> && is_container_v<no_cv_X>) {
12988  if (type_of(L, index) == type::userdata) {
12989  return stack::unqualified_check<X>(L, index, std::forward<Handler>(handler), tracking);
12990  }
12991  else {
12992  return stack::unqualified_check<nested<X>>(L, index, std::forward<Handler>(handler), tracking);
12993  }
12994  }
12995  else if constexpr (!std::is_reference_v<X> && meta::is_specialization_of_v<X, nested>) {
12996  using NestedX = typename meta::unqualified_t<X>::nested_type;
12997  return stack::check<NestedX>(L, index, ::std::forward<Handler>(handler), tracking);
12998  }
12999  else {
13000  return stack::unqualified_check<X>(L, index, std::forward<Handler>(handler), tracking);
13001  }
13002  }
13003  };
13004 }} // namespace sol::stack
13005 
13006 // end of sol/stack_check_qualified.hpp
13007 
13008 // end of sol/stack_check.hpp
13009 
13010 // beginning of sol/stack_get.hpp
13011 
13012 // beginning of sol/stack_get_unqualified.hpp
13013 
13014 // beginning of sol/overload.hpp
13015 
13016 #include <utility>
13017 
13018 namespace sol {
13019  template <typename... Functions>
13020  struct overload_set {
13021  std::tuple<Functions...> functions;
13022  template <typename Arg, typename... Args, meta::disable<std::is_same<overload_set, meta::unqualified_t<Arg>>> = meta::enabler>
13023  overload_set(Arg&& arg, Args&&... args) : functions(std::forward<Arg>(arg), std::forward<Args>(args)...) {
13024  }
13025  overload_set(const overload_set&) = default;
13026  overload_set(overload_set&&) = default;
13027  overload_set& operator=(const overload_set&) = default;
13028  overload_set& operator=(overload_set&&) = default;
13029  };
13030 
13031  template <typename... Args>
13032  decltype(auto) overload(Args&&... args) {
13033  return overload_set<std::decay_t<Args>...>(std::forward<Args>(args)...);
13034  }
13035 } // namespace sol
13036 
13037 // end of sol/overload.hpp
13038 
13039 // beginning of sol/unicode.hpp
13040 
13041 #include <array>
13042 #include <cstring>
13043 
13044 namespace sol {
13045  // Everything here was lifted pretty much straight out of
13046  // ogonek, because fuck figuring it out=
13047  namespace unicode {
13048  enum class error_code {
13049  ok = 0,
13050  invalid_code_point,
13056  };
13057 
13058  inline const string_view& to_string(error_code ec) {
13059  static const string_view storage[7] = { "ok",
13060  "invalid code points",
13061  "invalid code unit",
13062  "invalid leading surrogate",
13063  "invalid trailing surrogate",
13064  "sequence too short",
13065  "overlong sequence" };
13066  return storage[static_cast<std::size_t>(ec)];
13067  }
13068 
13069  template <typename It>
13072  char32_t codepoint;
13073  It next;
13074  };
13075 
13076  template <typename C>
13080  std::array<C, 4> code_units;
13081  };
13082 
13084  // codepoint related
13085  static constexpr char32_t last_code_point = 0x10FFFF;
13086 
13087  static constexpr char32_t first_lead_surrogate = 0xD800;
13088  static constexpr char32_t last_lead_surrogate = 0xDBFF;
13089 
13090  static constexpr char32_t first_trail_surrogate = 0xDC00;
13091  static constexpr char32_t last_trail_surrogate = 0xDFFF;
13092 
13093  static constexpr char32_t first_surrogate = first_lead_surrogate;
13094  static constexpr char32_t last_surrogate = last_trail_surrogate;
13095 
13096  static constexpr bool is_lead_surrogate(char32_t u) {
13097  return u >= first_lead_surrogate && u <= last_lead_surrogate;
13098  }
13099  static constexpr bool is_trail_surrogate(char32_t u) {
13100  return u >= first_trail_surrogate && u <= last_trail_surrogate;
13101  }
13102  static constexpr bool is_surrogate(char32_t u) {
13103  return u >= first_surrogate && u <= last_surrogate;
13104  }
13105 
13106  // utf8 related
13107  static constexpr auto last_1byte_value = 0x7Fu;
13108  static constexpr auto last_2byte_value = 0x7FFu;
13109  static constexpr auto last_3byte_value = 0xFFFFu;
13110 
13111  static constexpr auto start_2byte_mask = 0x80u;
13112  static constexpr auto start_3byte_mask = 0xE0u;
13113  static constexpr auto start_4byte_mask = 0xF0u;
13114 
13115  static constexpr auto continuation_mask = 0xC0u;
13116  static constexpr auto continuation_signature = 0x80u;
13117 
13118  static constexpr bool is_invalid(unsigned char b) {
13119  return b == 0xC0 || b == 0xC1 || b > 0xF4;
13120  }
13121 
13122  static constexpr bool is_continuation(unsigned char b) {
13123  return (b & unicode_detail::continuation_mask) == unicode_detail::continuation_signature;
13124  }
13125 
13126  static constexpr bool is_overlong(char32_t u, std::size_t bytes) {
13127  return u <= unicode_detail::last_1byte_value || (u <= unicode_detail::last_2byte_value && bytes > 2)
13128  || (u <= unicode_detail::last_3byte_value && bytes > 3);
13129  }
13130 
13131  static constexpr int sequence_length(unsigned char b) {
13132  return (b & start_2byte_mask) == 0 ? 1
13133  : (b & start_3byte_mask) != start_3byte_mask ? 2
13134  : (b & start_4byte_mask) != start_4byte_mask ? 3
13135  : 4;
13136  }
13137 
13138  static constexpr char32_t decode(unsigned char b0, unsigned char b1) {
13139  return (static_cast<char32_t>((b0 & 0x1Fu) << 6u) | static_cast<char32_t>(b1 & 0x3Fu));
13140  }
13141  static constexpr char32_t decode(unsigned char b0, unsigned char b1, unsigned char b2) {
13142  return static_cast<char32_t>((b0 & 0x0Fu) << 12u) | static_cast<char32_t>((b1 & 0x3Fu) << 6u) | static_cast<char32_t>(b2 & 0x3Fu);
13143  }
13144  static constexpr char32_t decode(unsigned char b0, unsigned char b1, unsigned char b2, unsigned char b3) {
13145  return static_cast<char32_t>(static_cast<char32_t>((b0 & 0x07u) << 18u) | static_cast<char32_t>((b1 & 0x3F) << 12)
13146  | static_cast<char32_t>((b2 & 0x3Fu) << 6u) | static_cast<char32_t>(b3 & 0x3Fu));
13147  }
13148 
13149  // utf16 related
13150  static constexpr char32_t last_bmp_value = 0xFFFF;
13151  static constexpr char32_t normalizing_value = 0x10000;
13152  static constexpr int lead_surrogate_bitmask = 0xFFC00;
13153  static constexpr int trail_surrogate_bitmask = 0x3FF;
13154  static constexpr int lead_shifted_bits = 10;
13155  static constexpr char32_t replacement = 0xFFFD;
13156 
13157  static char32_t combine_surrogates(char16_t lead, char16_t trail) {
13158  auto hi = lead - first_lead_surrogate;
13159  auto lo = trail - first_trail_surrogate;
13160  return normalizing_value + ((hi << lead_shifted_bits) | lo);
13161  }
13162  };
13163 
13166  er.error = error_code::ok;
13167  if (codepoint <= unicode_detail::last_1byte_value) {
13168  er.code_units_size = 1;
13169  er.code_units = std::array<char, 4> { { static_cast<char>(codepoint) } };
13170  }
13171  else if (codepoint <= unicode_detail::last_2byte_value) {
13172  er.code_units_size = 2;
13173  er.code_units = std::array<char, 4> { {
13174  static_cast<char>(0xC0 | ((codepoint & 0x7C0) >> 6)),
13175  static_cast<char>(0x80 | (codepoint & 0x3F)),
13176  } };
13177  }
13178  else if (codepoint <= unicode_detail::last_3byte_value) {
13179  er.code_units_size = 3;
13180  er.code_units = std::array<char, 4> { {
13181  static_cast<char>(0xE0 | ((codepoint & 0xF000) >> 12)),
13182  static_cast<char>(0x80 | ((codepoint & 0xFC0) >> 6)),
13183  static_cast<char>(0x80 | (codepoint & 0x3F)),
13184  } };
13185  }
13186  else {
13187  er.code_units_size = 4;
13188  er.code_units = std::array<char, 4> { {
13189  static_cast<char>(0xF0 | ((codepoint & 0x1C0000) >> 18)),
13190  static_cast<char>(0x80 | ((codepoint & 0x3F000) >> 12)),
13191  static_cast<char>(0x80 | ((codepoint & 0xFC0) >> 6)),
13192  static_cast<char>(0x80 | (codepoint & 0x3F)),
13193  } };
13194  }
13195  return er;
13196  }
13197 
13200 
13201  if (codepoint <= unicode_detail::last_bmp_value) {
13202  er.code_units_size = 1;
13203  er.code_units = std::array<char16_t, 4> { { static_cast<char16_t>(codepoint) } };
13204  er.error = error_code::ok;
13205  }
13206  else {
13207  auto normal = codepoint - unicode_detail::normalizing_value;
13208  auto lead = unicode_detail::first_lead_surrogate + ((normal & unicode_detail::lead_surrogate_bitmask) >> unicode_detail::lead_shifted_bits);
13209  auto trail = unicode_detail::first_trail_surrogate + (normal & unicode_detail::trail_surrogate_bitmask);
13210  er.code_units = std::array<char16_t, 4> { { static_cast<char16_t>(lead), static_cast<char16_t>(trail) } };
13211  er.code_units_size = 2;
13212  er.error = error_code::ok;
13213  }
13214  return er;
13215  }
13216 
13219  er.code_units_size = 1;
13220  er.code_units[0] = codepoint;
13221  er.error = error_code::ok;
13222  return er;
13223  }
13224 
13225  template <typename It>
13226  inline decoded_result<It> utf8_to_code_point(It it, It last) {
13227  decoded_result<It> dr;
13228  if (it == last) {
13229  dr.next = it;
13230  dr.error = error_code::sequence_too_short;
13231  return dr;
13232  }
13233 
13234  unsigned char b0 = static_cast<unsigned char>(*it);
13235  std::size_t length = static_cast<std::size_t>(unicode_detail::sequence_length(b0));
13236 
13237  if (length == 1) {
13238  dr.codepoint = static_cast<char32_t>(b0);
13239  dr.error = error_code::ok;
13240  ++it;
13241  dr.next = it;
13242  return dr;
13243  }
13244 
13245  if (unicode_detail::is_invalid(b0) || unicode_detail::is_continuation(b0)) {
13246  dr.error = error_code::invalid_code_unit;
13247  dr.next = it;
13248  return dr;
13249  }
13250 
13251  ++it;
13252  std::array<unsigned char, 4> b;
13253  b[0] = b0;
13254  for (std::size_t i = 1; i < length; ++i) {
13255  b[i] = static_cast<unsigned char>(*it);
13256  if (!unicode_detail::is_continuation(b[i])) {
13257  dr.error = error_code::invalid_code_unit;
13258  dr.next = it;
13259  return dr;
13260  }
13261  ++it;
13262  }
13263 
13264  char32_t decoded;
13265  switch (length) {
13266  case 2:
13267  decoded = unicode_detail::decode(b[0], b[1]);
13268  break;
13269  case 3:
13270  decoded = unicode_detail::decode(b[0], b[1], b[2]);
13271  break;
13272  default:
13273  decoded = unicode_detail::decode(b[0], b[1], b[2], b[3]);
13274  break;
13275  }
13276 
13277  if (unicode_detail::is_overlong(decoded, length)) {
13278  dr.error = error_code::overlong_sequence;
13279  return dr;
13280  }
13281  if (unicode_detail::is_surrogate(decoded) || decoded > unicode_detail::last_code_point) {
13283  return dr;
13284  }
13285 
13286  // then everything is fine
13287  dr.codepoint = decoded;
13288  dr.error = error_code::ok;
13289  dr.next = it;
13290  return dr;
13291  }
13292 
13293  template <typename It>
13294  inline decoded_result<It> utf16_to_code_point(It it, It last) {
13295  decoded_result<It> dr;
13296  if (it == last) {
13297  dr.next = it;
13298  dr.error = error_code::sequence_too_short;
13299  return dr;
13300  }
13301 
13302  char16_t lead = static_cast<char16_t>(*it);
13303 
13304  if (!unicode_detail::is_surrogate(lead)) {
13305  ++it;
13306  dr.codepoint = static_cast<char32_t>(lead);
13307  dr.next = it;
13308  dr.error = error_code::ok;
13309  return dr;
13310  }
13311  if (!unicode_detail::is_lead_surrogate(lead)) {
13312  dr.error = error_code::invalid_leading_surrogate;
13313  dr.next = it;
13314  return dr;
13315  }
13316 
13317  ++it;
13318  auto trail = *it;
13319  if (!unicode_detail::is_trail_surrogate(trail)) {
13320  dr.error = error_code::invalid_trailing_surrogate;
13321  dr.next = it;
13322  return dr;
13323  }
13324 
13325  dr.codepoint = unicode_detail::combine_surrogates(lead, trail);
13326  dr.next = ++it;
13327  dr.error = error_code::ok;
13328  return dr;
13329  }
13330 
13331  template <typename It>
13332  inline decoded_result<It> utf32_to_code_point(It it, It last) {
13333  decoded_result<It> dr;
13334  if (it == last) {
13335  dr.next = it;
13336  dr.error = error_code::sequence_too_short;
13337  return dr;
13338  }
13339  dr.codepoint = static_cast<char32_t>(*it);
13340  dr.next = ++it;
13341  dr.error = error_code::ok;
13342  return dr;
13343  }
13344  } // namespace unicode
13345 } // namespace sol
13346 // end of sol/unicode.hpp
13347 
13348 #include <memory>
13349 #include <functional>
13350 #include <utility>
13351 #include <cstdlib>
13352 #include <cmath>
13353 #include <string_view>
13354 #if SOL_IS_ON(SOL_STD_VARIANT)
13355 #include <variant>
13356 #endif // Apple clang screwed up
13357 
13358 namespace sol { namespace stack {
13359 
13360  namespace stack_detail {
13361  template <typename Ch>
13364 
13365  count_code_units_utf() : needed_size(0) {
13366  }
13367 
13369  needed_size += er.code_units_size;
13370  }
13371  };
13372 
13373  template <typename Ch, typename ErCh>
13375  Ch* target_;
13376 
13377  copy_code_units_utf(Ch* target) : target_(target) {
13378  }
13379 
13381  std::memcpy(target_, er.code_units.data(), er.code_units_size * sizeof(ErCh));
13382  target_ += er.code_units_size;
13383  }
13384  };
13385 
13386  template <typename Ch, typename F>
13387  inline void convert(const char* strb, const char* stre, F&& f) {
13388  char32_t cp = 0;
13389  for (const char* strtarget = strb; strtarget < stre;) {
13390  auto dr = unicode::utf8_to_code_point(strtarget, stre);
13391  if (dr.error != unicode::error_code::ok) {
13393  ++strtarget;
13394  }
13395  else {
13396  cp = dr.codepoint;
13397  strtarget = dr.next;
13398  }
13399  if constexpr (std::is_same_v<Ch, char32_t>) {
13400  auto er = unicode::code_point_to_utf32(cp);
13401  f(er);
13402  }
13403  else {
13404  auto er = unicode::code_point_to_utf16(cp);
13405  f(er);
13406  }
13407  }
13408  }
13409 
13410  template <typename BaseCh, typename S>
13411  inline S get_into(lua_State* L, int index, record& tracking) {
13412  using Ch = typename S::value_type;
13413  tracking.use(1);
13414  size_t len;
13415  auto utf8p = lua_tolstring(L, index, &len);
13416  if (len < 1)
13417  return S();
13418  const char* strb = utf8p;
13419  const char* stre = utf8p + len;
13421  convert<BaseCh>(strb, stre, count_units);
13422  S r(count_units.needed_size, static_cast<Ch>(0));
13423  r.resize(count_units.needed_size);
13424  Ch* target = &r[0];
13426  convert<BaseCh>(strb, stre, copy_units);
13427  return r;
13428  }
13429  } // namespace stack_detail
13430 
13431  template <typename T, typename>
13432  struct unqualified_getter {
13433  static decltype(auto) get(lua_State* L, int index, record& tracking) {
13434  if constexpr (std::is_same_v<T, bool>) {
13435  tracking.use(1);
13436  return lua_toboolean(L, index) != 0;
13437  }
13438  else if constexpr (std::is_enum_v<T>) {
13439  tracking.use(1);
13440  return static_cast<T>(lua_tointegerx(L, index, nullptr));
13441  }
13442  else if constexpr (std::is_integral_v<T> || std::is_same_v<T, lua_Integer>) {
13443  tracking.use(1);
13444 #if SOL_LUA_VERSION_I_ >= 503
13445  if (lua_isinteger(L, index) != 0) {
13446  return static_cast<T>(lua_tointeger(L, index));
13447  }
13448 #endif
13449  return static_cast<T>(llround(lua_tonumber(L, index)));
13450  }
13451  else if constexpr (std::is_floating_point_v<T> || std::is_same_v<T, lua_Number>) {
13452  tracking.use(1);
13453  return static_cast<T>(lua_tonumber(L, index));
13454  }
13455  else if constexpr (is_lua_reference_v<T>) {
13456  if constexpr (is_global_table_v<T>) {
13457  tracking.use(1);
13458  return T(L, global_tag);
13459  }
13460  else {
13461  tracking.use(1);
13462  return T(L, index);
13463  }
13464  }
13465  else if constexpr (is_unique_usertype_v<T>) {
13466  using actual = unique_usertype_actual_t<T>;
13467 
13468  tracking.use(1);
13469  void* memory = lua_touserdata(L, index);
13470  void* aligned_memory = detail::align_usertype_unique<actual>(memory);
13471  actual* typed_memory = static_cast<actual*>(aligned_memory);
13472  return *typed_memory;
13473  }
13474  else if constexpr (meta::is_optional_v<T>) {
13475  using ValueType = typename T::value_type;
13476  return unqualified_check_getter<ValueType>::template get_using<T>(L, index, &no_panic, tracking);
13477  }
13478  else if constexpr (std::is_same_v<T, luaL_Stream*>) {
13479  luaL_Stream* pstream = static_cast<luaL_Stream*>(lua_touserdata(L, index));
13480  return pstream;
13481  }
13482  else if constexpr (std::is_same_v<T, luaL_Stream>) {
13483  luaL_Stream* pstream = static_cast<luaL_Stream*>(lua_touserdata(L, index));
13484  return *pstream;
13485  }
13486 #if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE)
13487  else if constexpr (std::is_function_v<T> || (std::is_pointer_v<T> && std::is_function_v<std::remove_pointer_t<T>>)) {
13488  return stack_detail::get_function_pointer<std::remove_pointer_t<T>>(L, index, tracking);
13489  }
13490 #endif
13491  else {
13492  return stack_detail::unchecked_unqualified_get<detail::as_value_tag<T>>(L, index, tracking);
13493  }
13494  }
13495  };
13496 
13497  template <typename X, typename>
13498  struct qualified_getter {
13499  static decltype(auto) get(lua_State* L, int index, record& tracking) {
13500  using Tu = meta::unqualified_t<X>;
13501  static constexpr bool is_userdata_of_some_kind
13502  = !std::is_reference_v<
13503  X> && is_container_v<Tu> && std::is_default_constructible_v<Tu> && !is_lua_primitive_v<Tu> && !is_transparent_argument_v<Tu>;
13504  if constexpr (is_userdata_of_some_kind) {
13505  if (type_of(L, index) == type::userdata) {
13506  return static_cast<Tu>(stack_detail::unchecked_unqualified_get<Tu>(L, index, tracking));
13507  }
13508  else {
13509  return stack_detail::unchecked_unqualified_get<sol::nested<Tu>>(L, index, tracking);
13510  }
13511  }
13512  else if constexpr (!std::is_reference_v<X> && is_unique_usertype_v<Tu> && !is_actual_type_rebindable_for_v<Tu>) {
13513  using element = unique_usertype_element_t<Tu>;
13514  using actual = unique_usertype_actual_t<Tu>;
13515  tracking.use(1);
13516  void* memory = lua_touserdata(L, index);
13519  if (&detail::usertype_unique_alloc_destroy<element, Tu> == pdx) {
13520  memory = detail::align_usertype_unique_tag<true, false>(memory);
13521  memory = detail::align_usertype_unique<actual, true, false>(memory);
13522  actual* mem = static_cast<actual*>(memory);
13523  return static_cast<actual>(*mem);
13524  }
13525  actual r {};
13526  if constexpr (!derive<element>::value) {
13527 #if SOL_IS_ON(SOL_DEBUG_BUILD)
13528  // In debug mode we would rather abort you for this grave failure rather
13529  // than let you deref a null pointer and fuck everything over
13530  std::abort();
13531 #endif
13532  return static_cast<actual>(std::move(r));
13533  }
13534  else {
13535  memory = detail::align_usertype_unique_tag<true, false>(memory);
13536  detail::unique_tag& ic = *reinterpret_cast<detail::unique_tag*>(memory);
13537  memory = detail::align_usertype_unique<actual, true, false>(memory);
13539  int cast_operation;
13540  if constexpr (is_actual_type_rebindable_for_v<Tu>) {
13541  using rebound_actual_type = unique_usertype_rebind_actual_t<Tu, void>;
13543  cast_operation = ic(memory, &r, ti, rebind_ti);
13544  }
13545  else {
13546  string_view rebind_ti("");
13547  cast_operation = ic(memory, &r, ti, rebind_ti);
13548  }
13549  switch (cast_operation) {
13550  case 1: {
13551  // it's a perfect match,
13552  // alias memory directly
13553  actual* mem = static_cast<actual*>(memory);
13554  return static_cast<actual>(*mem);
13555  }
13556  case 2:
13557  // it's a base match, return the
13558  // aliased creation
13559  return static_cast<actual>(std::move(r));
13560  default:
13561  // uh oh..
13562  break;
13563  }
13564 #if SOL_IS_ON(SOL_DEBUG_BUILD)
13565  // In debug mode we would rather abort you for this grave failure rather
13566  // than let you deref a null pointer and fuck everything over
13567  std::abort();
13568 #endif
13569  return static_cast<actual>(r);
13570  }
13571  }
13572  else {
13573  return stack_detail::unchecked_unqualified_get<Tu>(L, index, tracking);
13574  }
13575  }
13576  };
13577 
13578  template <typename T>
13581 
13582  template <typename V>
13584  cont.push_back(stack::get<V>(L, -lua_size<V>::value));
13585  }
13586 
13587  template <typename V>
13588  static void push_back_at_end(std::false_type, types<V> t, lua_State* L, T& cont, std::size_t idx) {
13589  insert_at_end(meta::has_insert<Tu>(), t, L, cont, idx);
13590  }
13591 
13592  template <typename V>
13594  using std::cend;
13595  cont.insert(cend(cont), stack::get<V>(L, -lua_size<V>::value));
13596  }
13597 
13598  template <typename V>
13599  static void insert_at_end(std::false_type, types<V>, lua_State* L, T& cont, std::size_t idx) {
13600  cont[idx] = stack::get<V>(L, -lua_size<V>::value);
13601  }
13602 
13604  return false;
13605  }
13606 
13607  static bool max_size_check(std::true_type, T& cont, std::size_t idx) {
13608  return idx >= cont.max_size();
13609  }
13610 
13611  static T get(lua_State* L, int relindex, record& tracking) {
13612  return get(meta::is_associative<Tu>(), L, relindex, tracking);
13613  }
13614 
13615  static T get(std::false_type, lua_State* L, int relindex, record& tracking) {
13616  typedef typename Tu::value_type V;
13617  return get(types<V>(), L, relindex, tracking);
13618  }
13619 
13620  template <typename V>
13621  static T get(types<V> t, lua_State* L, int relindex, record& tracking) {
13622  tracking.use(1);
13623 
13624  // the W4 flag is really great,
13625  // so great that it can tell my for loops (twice nested)
13626  // below never actually terminate
13627  // without hitting where the gotos have infested
13628 
13629  // so now I would get the error W4XXX unreachable
13630  // me that the return cont at the end of this function
13631  // which is fair until other compilers complain
13632  // that there isn't a return and that based on
13633  // SOME MAGICAL FORCE
13634  // control flow falls off the end of a non-void function
13635  // so it needs to be there for the compilers that are
13636  // too flimsy to analyze the basic blocks...
13637  // (I'm sure I should file a bug but those compilers are already
13638  // in the wild; it doesn't matter if I fix them,
13639  // someone else is still going to get some old-ass compiler
13640  // and then bother me about the unclean build for the 30th
13641  // time)
13642 
13643  // "Why not an IIFE?"
13644  // Because additional lambdas / functions which serve as
13645  // capture-all-and-then-invoke bloat binary sizes
13646  // by an actually detectable amount
13647  // (one user uses sol2 pretty heavily and 22 MB of binary size
13648  // was saved by reducing reliance on lambdas in templates)
13649 
13650  // This would really be solved by having break N;
13651  // be a real, proper thing...
13652  // but instead, we have to use labels and gotos
13653  // and earn the universal vitriol of the dogmatic
13654  // programming community
13655 
13656  // all in all: W4 is great!~
13657 
13658  int index = lua_absindex(L, relindex);
13659  T cont;
13660  std::size_t idx = 0;
13661 #if SOL_LUA_VERSION_I_ >= 503
13662  // This method is HIGHLY performant over regular table iteration
13663  // thanks to the Lua API changes in 5.3
13664  // Questionable in 5.4
13665  for (lua_Integer i = 0;; i += lua_size<V>::value) {
13666  if (max_size_check(meta::has_max_size<Tu>(), cont, idx)) {
13667  // see above comment
13668  goto done;
13669  }
13670  bool isnil = false;
13671  for (int vi = 0; vi < lua_size<V>::value; ++vi) {
13672 #if SOL_IS_ON(SOL_LUA_NIL_IN_TABLES) && SOL_LUA_VERSION_I_ >= 600
13673 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
13675 #endif // make sure stack doesn't overflow
13676  lua_pushinteger(L, static_cast<lua_Integer>(i + vi));
13677  if (lua_keyin(L, index) == 0) {
13678  // it's time to stop
13679  isnil = true;
13680  }
13681  else {
13682  // we have a key, have to get the value
13683  lua_geti(L, index, i + vi);
13684  }
13685 #else
13686  type vt = static_cast<type>(lua_geti(L, index, i + vi));
13687  isnil = vt == type::none || vt == type::lua_nil;
13688 #endif
13689  if (isnil) {
13690  if (i == 0) {
13691  break;
13692  }
13693 #if SOL_IS_ON(SOL_LUA_NIL_IN_TABLES) && SOL_LUA_VERSION_I_ >= 600
13694  lua_pop(L, vi);
13695 #else
13696  lua_pop(L, (vi + 1));
13697 #endif
13698  // see above comment
13699  goto done;
13700  }
13701  }
13702  if (isnil) {
13703 #if SOL_IS_ON(SOL_LUA_NIL_IN_TABLES) && SOL_LUA_VERSION_I_ >= 600
13704 #else
13706 #endif
13707  continue;
13708  }
13709 
13710  push_back_at_end(meta::has_push_back<Tu>(), t, L, cont, idx);
13711  ++idx;
13713  }
13714 #else
13715  // Zzzz slower but necessary thanks to the lower version API and missing functions qq
13716  for (lua_Integer i = 0;; i += lua_size<V>::value, lua_pop(L, lua_size<V>::value)) {
13717  if (idx >= cont.max_size()) {
13718  // see above comment
13719  goto done;
13720  }
13721 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
13723 #endif // make sure stack doesn't overflow
13724  bool isnil = false;
13725  for (int vi = 0; vi < lua_size<V>::value; ++vi) {
13726  lua_pushinteger(L, i);
13727  lua_gettable(L, index);
13728  type vt = type_of(L, -1);
13729  isnil = vt == type::lua_nil;
13730  if (isnil) {
13731  if (i == 0) {
13732  break;
13733  }
13734  lua_pop(L, (vi + 1));
13735  // see above comment
13736  goto done;
13737  }
13738  }
13739  if (isnil)
13740  continue;
13741  push_back_at_end(meta::has_push_back<Tu>(), t, L, cont, idx);
13742  ++idx;
13743  }
13744 #endif
13745  done:
13746  return cont;
13747  }
13748 
13749  static T get(std::true_type, lua_State* L, int index, record& tracking) {
13750  typedef typename Tu::value_type P;
13751  typedef typename P::first_type K;
13752  typedef typename P::second_type V;
13753  return get(types<K, V>(), L, index, tracking);
13754  }
13755 
13756  template <typename K, typename V>
13757  static T get(types<K, V>, lua_State* L, int relindex, record& tracking) {
13758  tracking.use(1);
13759 
13760 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
13762 #endif // make sure stack doesn't overflow
13763 
13764  T associative;
13765  int index = lua_absindex(L, relindex);
13766  lua_pushnil(L);
13767  while (lua_next(L, index) != 0) {
13768  decltype(auto) key = stack::check_get<K>(L, -2);
13769  if (!key) {
13770  lua_pop(L, 1);
13771  continue;
13772  }
13773  associative.emplace(std::forward<decltype(*key)>(*key), stack::get<V>(L, -1));
13774  lua_pop(L, 1);
13775  }
13776  return associative;
13777  }
13778  };
13779 
13780  template <typename T, typename Al>
13781  struct unqualified_getter<as_table_t<std::forward_list<T, Al>>> {
13782  typedef std::forward_list<T, Al> C;
13783 
13784  static C get(lua_State* L, int relindex, record& tracking) {
13785  return get(meta::has_key_value_pair<C>(), L, relindex, tracking);
13786  }
13787 
13788  static C get(std::true_type, lua_State* L, int index, record& tracking) {
13789  typedef typename T::value_type P;
13790  typedef typename P::first_type K;
13791  typedef typename P::second_type V;
13792  return get(types<K, V>(), L, index, tracking);
13793  }
13794 
13795  static C get(std::false_type, lua_State* L, int relindex, record& tracking) {
13796  typedef typename C::value_type V;
13797  return get(types<V>(), L, relindex, tracking);
13798  }
13799 
13800  template <typename V>
13801  static C get(types<V>, lua_State* L, int relindex, record& tracking) {
13802  tracking.use(1);
13803 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
13805 #endif // make sure stack doesn't overflow
13806 
13807  int index = lua_absindex(L, relindex);
13808  C cont;
13809  auto at = cont.cbefore_begin();
13810  std::size_t idx = 0;
13811 #if SOL_LUA_VERSION_I_ >= 503
13812  // This method is HIGHLY performant over regular table iteration thanks to the Lua API changes in 5.3
13813  for (lua_Integer i = 0;; i += lua_size<V>::value, lua_pop(L, lua_size<V>::value)) {
13814  if (idx >= cont.max_size()) {
13815  goto done;
13816  }
13817  bool isnil = false;
13818  for (int vi = 0; vi < lua_size<V>::value; ++vi) {
13819  type t = static_cast<type>(lua_geti(L, index, i + vi));
13820  isnil = t == type::lua_nil;
13821  if (isnil) {
13822  if (i == 0) {
13823  break;
13824  }
13825  lua_pop(L, (vi + 1));
13826  goto done;
13827  }
13828  }
13829  if (isnil)
13830  continue;
13831  at = cont.insert_after(at, stack::get<V>(L, -lua_size<V>::value));
13832  ++idx;
13833  }
13834 #else
13835  // Zzzz slower but necessary thanks to the lower version API and missing functions qq
13836  for (lua_Integer i = 0;; i += lua_size<V>::value, lua_pop(L, lua_size<V>::value)) {
13837  if (idx >= cont.max_size()) {
13838  goto done;
13839  }
13840  bool isnil = false;
13841  for (int vi = 0; vi < lua_size<V>::value; ++vi) {
13842  lua_pushinteger(L, i);
13843  lua_gettable(L, index);
13844  type t = type_of(L, -1);
13845  isnil = t == type::lua_nil;
13846  if (isnil) {
13847  if (i == 0) {
13848  break;
13849  }
13850  lua_pop(L, (vi + 1));
13851  goto done;
13852  }
13853  }
13854  if (isnil)
13855  continue;
13856  at = cont.insert_after(at, stack::get<V>(L, -lua_size<V>::value));
13857  ++idx;
13858  }
13859 #endif
13860  done:
13861  return cont;
13862  }
13863 
13864  template <typename K, typename V>
13865  static C get(types<K, V>, lua_State* L, int relindex, record& tracking) {
13866  tracking.use(1);
13867 
13868 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
13870 #endif // make sure stack doesn't overflow
13871 
13872  C associative;
13873  auto at = associative.cbefore_begin();
13874  int index = lua_absindex(L, relindex);
13875  lua_pushnil(L);
13876  while (lua_next(L, index) != 0) {
13877  decltype(auto) key = stack::check_get<K>(L, -2);
13878  if (!key) {
13879  lua_pop(L, 1);
13880  continue;
13881  }
13882  at = associative.emplace_after(at, std::forward<decltype(*key)>(*key), stack::get<V>(L, -1));
13883  lua_pop(L, 1);
13884  }
13885  return associative;
13886  }
13887  };
13888 
13889  template <typename T>
13891  static T get(lua_State* L, int index, record& tracking) {
13892  using Tu = meta::unqualified_t<T>;
13893  if constexpr (is_container_v<Tu>) {
13894  if constexpr (meta::is_associative<Tu>::value) {
13895  typedef typename T::value_type P;
13896  typedef typename P::first_type K;
13897  typedef typename P::second_type V;
13899  return g.get(types<K, nested<V>>(), L, index, tracking);
13900  }
13901  else {
13902  typedef typename T::value_type V;
13904  return g.get(types<nested<V>>(), L, index, tracking);
13905  }
13906  }
13907  else {
13909  return g.get(L, index, tracking);
13910  }
13911  }
13912  };
13913 
13914  template <typename T>
13916  static decltype(auto) get(lua_State* L, int index, record& tracking) {
13917  return stack::unqualified_get<T>(L, index, tracking);
13918  }
13919  };
13920 
13921  template <typename T>
13923  static decltype(auto) get(lua_State* L, int index, record& tracking) {
13924  return stack::unqualified_get<T*>(L, index, tracking);
13925  }
13926  };
13927 
13928  template <>
13930  static userdata_value get(lua_State* L, int index, record& tracking) {
13931  tracking.use(1);
13932  return userdata_value(lua_touserdata(L, index));
13933  }
13934  };
13935 
13936  template <>
13938  static lightuserdata_value get(lua_State* L, int index, record& tracking) {
13939  tracking.use(1);
13941  }
13942  };
13943 
13944  template <typename T>
13946  static light<T> get(lua_State* L, int index, record& tracking) {
13947  tracking.use(1);
13948  void* memory = lua_touserdata(L, index);
13949  return light<T>(static_cast<T*>(memory));
13950  }
13951  };
13952 
13953  template <typename T>
13955  static std::add_lvalue_reference_t<T> get(lua_State* L, int index, record& tracking) {
13956  tracking.use(1);
13957  void* memory = lua_touserdata(L, index);
13958  memory = detail::align_user<T>(memory);
13959  return *static_cast<std::remove_reference_t<T>*>(memory);
13960  }
13961  };
13962 
13963  template <typename T>
13964  struct unqualified_getter<user<T*>> {
13965  static T* get(lua_State* L, int index, record& tracking) {
13966  tracking.use(1);
13967  void* memory = lua_touserdata(L, index);
13968  memory = detail::align_user<T*>(memory);
13969  return static_cast<T*>(memory);
13970  }
13971  };
13972 
13973  template <>
13975  static type get(lua_State* L, int index, record& tracking) {
13976  tracking.use(1);
13977  return static_cast<type>(lua_type(L, index));
13978  }
13979  };
13980 
13981  template <>
13983  static std::string get(lua_State* L, int index, record& tracking) {
13984  tracking.use(1);
13985  std::size_t len;
13986  auto str = lua_tolstring(L, index, &len);
13987  return std::string(str, len);
13988  }
13989  };
13990 
13991  template <>
13992  struct unqualified_getter<const char*> {
13993  static const char* get(lua_State* L, int index, record& tracking) {
13994  tracking.use(1);
13995  size_t sz;
13996  return lua_tolstring(L, index, &sz);
13997  }
13998  };
13999 
14000  template <>
14001  struct unqualified_getter<char> {
14002  static char get(lua_State* L, int index, record& tracking) {
14003  tracking.use(1);
14004  size_t len;
14005  auto str = lua_tolstring(L, index, &len);
14006  return len > 0 ? str[0] : '\0';
14007  }
14008  };
14009 
14010  template <typename Traits>
14011  struct unqualified_getter<basic_string_view<char, Traits>> {
14012  static string_view get(lua_State* L, int index, record& tracking) {
14013  tracking.use(1);
14014  size_t sz;
14015  const char* str = lua_tolstring(L, index, &sz);
14016  return basic_string_view<char, Traits>(str, sz);
14017  }
14018  };
14019 
14020  template <typename Traits, typename Al>
14021  struct unqualified_getter<std::basic_string<wchar_t, Traits, Al>> {
14022  using S = std::basic_string<wchar_t, Traits, Al>;
14023  static S get(lua_State* L, int index, record& tracking) {
14024  using Ch = meta::conditional_t<sizeof(wchar_t) == 2, char16_t, char32_t>;
14025  return stack_detail::get_into<Ch, S>(L, index, tracking);
14026  }
14027  };
14028 
14029  template <typename Traits, typename Al>
14030  struct unqualified_getter<std::basic_string<char16_t, Traits, Al>> {
14031  static std::basic_string<char16_t, Traits, Al> get(lua_State* L, int index, record& tracking) {
14032  return stack_detail::get_into<char16_t, std::basic_string<char16_t, Traits, Al>>(L, index, tracking);
14033  }
14034  };
14035 
14036  template <typename Traits, typename Al>
14037  struct unqualified_getter<std::basic_string<char32_t, Traits, Al>> {
14038  static std::basic_string<char32_t, Traits, Al> get(lua_State* L, int index, record& tracking) {
14039  return stack_detail::get_into<char32_t, std::basic_string<char32_t, Traits, Al>>(L, index, tracking);
14040  }
14041  };
14042 
14043  template <>
14044  struct unqualified_getter<char16_t> {
14045  static char16_t get(lua_State* L, int index, record& tracking) {
14046  string_view utf8 = stack::get<string_view>(L, index, tracking);
14047  const char* strb = utf8.data();
14048  const char* stre = utf8.data() + utf8.size();
14049  char32_t cp = 0;
14050  auto dr = unicode::utf8_to_code_point(strb, stre);
14051  if (dr.error != unicode::error_code::ok) {
14053  }
14054  else {
14055  cp = dr.codepoint;
14056  }
14057  auto er = unicode::code_point_to_utf16(cp);
14058  return er.code_units[0];
14059  }
14060  };
14061 
14062  template <>
14063  struct unqualified_getter<char32_t> {
14064  static char32_t get(lua_State* L, int index, record& tracking) {
14065  string_view utf8 = stack::get<string_view>(L, index, tracking);
14066  const char* strb = utf8.data();
14067  const char* stre = utf8.data() + utf8.size();
14068  char32_t cp = 0;
14069  auto dr = unicode::utf8_to_code_point(strb, stre);
14070  if (dr.error != unicode::error_code::ok) {
14072  }
14073  else {
14074  cp = dr.codepoint;
14075  }
14076  auto er = unicode::code_point_to_utf32(cp);
14077  return er.code_units[0];
14078  }
14079  };
14080 
14081  template <>
14082  struct unqualified_getter<wchar_t> {
14083  static wchar_t get(lua_State* L, int index, record& tracking) {
14084  typedef meta::conditional_t<sizeof(wchar_t) == 2, char16_t, char32_t> Ch;
14086  (void)g;
14087  auto c = g.get(L, index, tracking);
14088  return static_cast<wchar_t>(c);
14089  }
14090  };
14091 
14092  template <>
14094  static meta_function get(lua_State* L, int index, record& tracking) {
14095  tracking.use(1);
14096  const char* name = unqualified_getter<const char*> {}.get(L, index, tracking);
14097  const auto& mfnames = meta_function_names();
14098  for (std::size_t i = 0; i < mfnames.size(); ++i)
14099  if (mfnames[i] == name)
14100  return static_cast<meta_function>(i);
14101  return meta_function::construct;
14102  }
14103  };
14104 
14105  template <>
14107  static lua_nil_t get(lua_State*, int, record& tracking) {
14108  tracking.use(1);
14109  return lua_nil;
14110  }
14111  };
14112 
14113  template <>
14114  struct unqualified_getter<std::nullptr_t> {
14115  static std::nullptr_t get(lua_State*, int, record& tracking) {
14116  tracking.use(1);
14117  return nullptr;
14118  }
14119  };
14120 
14121  template <>
14123  static nullopt_t get(lua_State*, int, record& tracking) {
14124  tracking.use(1);
14125  return nullopt;
14126  }
14127  };
14128 
14129  template <>
14131  static this_state get(lua_State* L, int, record& tracking) {
14132  tracking.use(0);
14133  return this_state(L);
14134  }
14135  };
14136 
14137  template <>
14139  static this_main_state get(lua_State* L, int, record& tracking) {
14140  tracking.use(0);
14141  return this_main_state(main_thread(L, L));
14142  }
14143  };
14144 
14145  template <>
14147  static lua_CFunction get(lua_State* L, int index, record& tracking) {
14148  tracking.use(1);
14149  return lua_tocfunction(L, index);
14150  }
14151  };
14152 
14153  template <>
14155  static c_closure get(lua_State* L, int index, record& tracking) {
14156  tracking.use(1);
14157  return c_closure(lua_tocfunction(L, index), -1);
14158  }
14159  };
14160 
14161  template <>
14163  static error get(lua_State* L, int index, record& tracking) {
14164  tracking.use(1);
14165  size_t sz = 0;
14166  const char* err = lua_tolstring(L, index, &sz);
14167  if (err == nullptr) {
14168  return error(detail::direct_error, "");
14169  }
14170  return error(detail::direct_error, std::string(err, sz));
14171  }
14172  };
14173 
14174  template <>
14176  static void* get(lua_State* L, int index, record& tracking) {
14177  tracking.use(1);
14178  return lua_touserdata(L, index);
14179  }
14180  };
14181 
14182  template <>
14183  struct unqualified_getter<const void*> {
14184  static const void* get(lua_State* L, int index, record& tracking) {
14185  tracking.use(1);
14186  return lua_touserdata(L, index);
14187  }
14188  };
14189 
14190  template <typename T>
14191  struct unqualified_getter<detail::as_value_tag<T>> {
14192  static T* get_no_lua_nil(lua_State* L, int index, record& tracking) {
14193  void* memory = lua_touserdata(L, index);
14194 #if SOL_IS_ON(SOL_USE_INTEROP)
14195  auto ugr = stack_detail::interop_get<T>(L, index, memory, tracking);
14196  if (ugr.first) {
14197  return ugr.second;
14198  }
14199 #endif // interop extensibility
14200  tracking.use(1);
14201  void* rawdata = detail::align_usertype_pointer(memory);
14202  void** pudata = static_cast<void**>(rawdata);
14203  void* udata = *pudata;
14204  return get_no_lua_nil_from(L, udata, index, tracking);
14205  }
14206 
14207  static T* get_no_lua_nil_from(lua_State* L, void* udata, int index, record&) {
14208  bool has_derived = derive<T>::value || weak_derive<T>::value;
14209  if (has_derived) {
14210  if (lua_getmetatable(L, index) == 1) {
14212  if (type_of(L, -1) != type::lua_nil) {
14213  void* basecastdata = lua_touserdata(L, -1);
14214  detail::inheritance_cast_function ic = reinterpret_cast<detail::inheritance_cast_function>(basecastdata);
14215  // use the casting function to properly adjust the pointer for the desired T
14216  udata = ic(udata, usertype_traits<T>::qualified_name());
14217  }
14218  lua_pop(L, 2);
14219  }
14220  }
14221  if constexpr (std::is_function_v<T>) {
14222  T* func = reinterpret_cast<T*>(udata);
14223  return func;
14224  }
14225  else {
14226  T* obj = static_cast<T*>(udata);
14227  return obj;
14228  }
14229  }
14230 
14231  static T& get(lua_State* L, int index, record& tracking) {
14232  return *get_no_lua_nil(L, index, tracking);
14233  }
14234  };
14235 
14236  template <typename T>
14237  struct unqualified_getter<detail::as_pointer_tag<T>> {
14238  static T* get(lua_State* L, int index, record& tracking) {
14239  type t = type_of(L, index);
14240  if (t == type::lua_nil) {
14241  tracking.use(1);
14242  return nullptr;
14243  }
14245  return g.get_no_lua_nil(L, index, tracking);
14246  }
14247  };
14248 
14249  template <typename T>
14251  static T* get(lua_State* L, int index, record& tracking) {
14253  return g.get_no_lua_nil(L, index, tracking);
14254  }
14255  };
14256 
14257  template <typename T>
14258  struct unqualified_getter<T&> {
14259  static T& get(lua_State* L, int index, record& tracking) {
14261  return g.get(L, index, tracking);
14262  }
14263  };
14264 
14265  template <typename T>
14266  struct unqualified_getter<std::reference_wrapper<T>> {
14267  static T& get(lua_State* L, int index, record& tracking) {
14269  return g.get(L, index, tracking);
14270  }
14271  };
14272 
14273  template <typename T>
14274  struct unqualified_getter<T*> {
14275  static T* get(lua_State* L, int index, record& tracking) {
14276 #if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE)
14277  if constexpr (std::is_function_v<T>) {
14278  return stack_detail::get_function_pointer<T>(L, index, tracking);
14279  }
14280  else {
14282  return g.get(L, index, tracking);
14283  }
14284 #else
14286  return g.get(L, index, tracking);
14287 #endif
14288  }
14289  };
14290 
14291  template <typename... Tn>
14292  struct unqualified_getter<std::tuple<Tn...>> {
14293  typedef std::tuple<decltype(stack::get<Tn>(nullptr, 0))...> R;
14294 
14295  template <typename... Args>
14296  static R apply(std::index_sequence<>, lua_State*, int, record&, Args&&... args) {
14297  // Fuck you too, VC++
14298  return R { std::forward<Args>(args)... };
14299  }
14300 
14301  template <std::size_t I, std::size_t... Ix, typename... Args>
14302  static R apply(std::index_sequence<I, Ix...>, lua_State* L, int index, record& tracking, Args&&... args) {
14303  // Fuck you too, VC++
14304  typedef std::tuple_element_t<I, std::tuple<Tn...>> T;
14305  return apply(std::index_sequence<Ix...>(), L, index, tracking, std::forward<Args>(args)..., stack::get<T>(L, index + tracking.used, tracking));
14306  }
14307 
14308  static R get(lua_State* L, int index, record& tracking) {
14309  return apply(std::make_index_sequence<sizeof...(Tn)>(), L, index, tracking);
14310  }
14311  };
14312 
14313  template <typename A, typename B>
14314  struct unqualified_getter<std::pair<A, B>> {
14315  static decltype(auto) get(lua_State* L, int index, record& tracking) {
14316  return std::pair<decltype(stack::get<A>(L, index)), decltype(stack::get<B>(L, index))> { stack::get<A>(L, index, tracking),
14317  stack::get<B>(L, index + tracking.used, tracking) };
14318  }
14319  };
14320 
14321 #if SOL_IS_ON(SOL_STD_VARIANT)
14322 
14323  template <typename... Tn>
14324  struct unqualified_getter<std::variant<Tn...>> {
14325  using V = std::variant<Tn...>;
14326 
14327  static V get_one(std::integral_constant<std::size_t, std::variant_size_v<V>>, lua_State* L, int index, record& tracking) {
14328  (void)L;
14329  (void)index;
14330  (void)tracking;
14331  if constexpr (std::variant_size_v<V> == 0) {
14332  return V();
14333  }
14334  else {
14335  // using T = std::variant_alternative_t<0, V>;
14336  std::abort();
14337  // return V(std::in_place_index<0>, stack::get<T>(L, index, tracking));
14338  }
14339  }
14340 
14341  template <std::size_t I>
14342  static V get_one(std::integral_constant<std::size_t, I>, lua_State* L, int index, record& tracking) {
14343  typedef std::variant_alternative_t<I, V> T;
14344  record temp_tracking = tracking;
14345  if (stack::check<T>(L, index, &no_panic, temp_tracking)) {
14346  tracking = temp_tracking;
14347  return V(std::in_place_index<I>, stack::get<T>(L, index));
14348  }
14349  return get_one(std::integral_constant<std::size_t, I + 1>(), L, index, tracking);
14350  }
14351 
14352  static V get(lua_State* L, int index, record& tracking) {
14353  return get_one(std::integral_constant<std::size_t, 0>(), L, index, tracking);
14354  }
14355  };
14356 #endif // variant
14357 
14358 }} // namespace sol::stack
14359 
14360 // end of sol/stack_get_unqualified.hpp
14361 
14362 // beginning of sol/stack_get_qualified.hpp
14363 
14364 namespace sol { namespace stack {
14365 
14366  // There are no more enable_ifs that can be used here,
14367  // so this is just for posterity, I guess?
14368  // maybe I'll fill this file in later.
14369 
14370 }} // namespace sol::stack
14371 
14372 // end of sol/stack_get_qualified.hpp
14373 
14374 // end of sol/stack_get.hpp
14375 
14376 // beginning of sol/stack_check_get.hpp
14377 
14378 // beginning of sol/stack_check_get_unqualified.hpp
14379 
14380 #include <cstdlib>
14381 #include <cmath>
14382 #include <optional>
14383 #if SOL_IS_ON(SOL_STD_VARIANT)
14384 #include <variant>
14385 #endif // variant shenanigans (thanks, Mac OSX)
14386 
14387 namespace sol { namespace stack {
14388  template <typename T, typename>
14389  struct unqualified_check_getter {
14390  typedef decltype(stack_detail::unchecked_unqualified_get<T>(nullptr, -1, std::declval<record&>())) R;
14391 
14392  template <typename Optional, typename Handler>
14393  static Optional get_using(lua_State* L, int index, Handler&& handler, record& tracking) {
14394  if constexpr (!meta::meta_detail::is_adl_sol_lua_check_v<T> && !meta::meta_detail::is_adl_sol_lua_get_v<T>) {
14395  if constexpr (is_lua_reference_v<T>) {
14396  if constexpr (is_global_table_v<T>) {
14397  (void)L;
14398  (void)index;
14399  (void)handler;
14400  tracking.use(1);
14401  return true;
14402  }
14403  else {
14404  // actually check if it's none here, otherwise
14405  // we'll have a none object inside an optional!
14406  bool success = lua_isnoneornil(L, index) == 0 && stack::check<T>(L, index, &no_panic);
14407  if (!success) {
14408  // expected type, actual type
14409  tracking.use(static_cast<int>(success));
14410  handler(L, index, type::poly, type_of(L, index), "");
14411  return detail::associated_nullopt_v<Optional>;
14412  }
14413  return stack_detail::unchecked_get<T>(L, index, tracking);
14414  }
14415  }
14416  else if constexpr ((std::is_integral_v<T> || std::is_same_v<T, lua_Integer>)&&!std::is_same_v<T, bool>) {
14417 #if SOL_LUA_VERSION_I_ >= 503
14418  if (lua_isinteger(L, index) != 0) {
14419  tracking.use(1);
14420  return static_cast<T>(lua_tointeger(L, index));
14421  }
14422 #endif
14423  int isnum = 0;
14424  const lua_Number value = lua_tonumberx(L, index, &isnum);
14425  if (isnum != 0) {
14426 #if SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS)
14427  const auto integer_value = llround(value);
14428  if (static_cast<lua_Number>(integer_value) == value) {
14429  tracking.use(1);
14430  return static_cast<T>(integer_value);
14431  }
14432 #else
14433  tracking.use(1);
14434  return static_cast<T>(value);
14435 #endif
14436  }
14437  const type t = type_of(L, index);
14438  tracking.use(static_cast<int>(t != type::none));
14439  handler(L, index, type::number, t, "not an integer");
14440  return detail::associated_nullopt_v<Optional>;
14441  }
14442  else if constexpr (std::is_floating_point_v<T> || std::is_same_v<T, lua_Number>) {
14443  int isnum = 0;
14444  lua_Number value = lua_tonumberx(L, index, &isnum);
14445  if (isnum == 0) {
14446  type t = type_of(L, index);
14447  tracking.use(static_cast<int>(t != type::none));
14448  handler(L, index, type::number, t, "not a valid floating point number");
14449  return detail::associated_nullopt_v<Optional>;
14450  }
14451  tracking.use(1);
14452  return static_cast<T>(value);
14453  }
14454  else if constexpr (std::is_enum_v<T> && !meta::any_same_v<T, meta_function, type>) {
14455  int isnum = 0;
14456  lua_Integer value = lua_tointegerx(L, index, &isnum);
14457  if (isnum == 0) {
14458  type t = type_of(L, index);
14459  tracking.use(static_cast<int>(t != type::none));
14460  handler(L, index, type::number, t, "not a valid enumeration value");
14461  return detail::associated_nullopt_v<Optional>;
14462  }
14463  tracking.use(1);
14464  return static_cast<T>(value);
14465  }
14466  else {
14467  if (!unqualified_check<T>(L, index, std::forward<Handler>(handler))) {
14468  tracking.use(static_cast<int>(!lua_isnone(L, index)));
14469  return detail::associated_nullopt_v<Optional>;
14470  }
14471  return stack_detail::unchecked_unqualified_get<T>(L, index, tracking);
14472  }
14473  }
14474  else {
14475  if (!unqualified_check<T>(L, index, std::forward<Handler>(handler))) {
14476  tracking.use(static_cast<int>(!lua_isnone(L, index)));
14477  return detail::associated_nullopt_v<Optional>;
14478  }
14479  return stack_detail::unchecked_unqualified_get<T>(L, index, tracking);
14480  }
14481  }
14482 
14483  template <typename Handler>
14484  static optional<R> get(lua_State* L, int index, Handler&& handler, record& tracking) {
14485  return get_using<optional<R>>(L, index, std::forward<Handler>(handler), tracking);
14486  }
14487  };
14488 
14489 #if SOL_IS_ON(SOL_STD_VARIANT)
14490  template <typename... Tn, typename C>
14491  struct unqualified_check_getter<std::variant<Tn...>, C> {
14492  typedef std::variant<Tn...> V;
14493  typedef std::variant_size<V> V_size;
14494  typedef std::integral_constant<bool, V_size::value == 0> V_is_empty;
14495 
14496  template <typename Handler>
14497  static optional<V> get_empty(std::true_type, lua_State*, int, Handler&&, record&) {
14498  return nullopt;
14499  }
14500 
14501  template <typename Handler>
14502  static optional<V> get_empty(std::false_type, lua_State* L, int index, Handler&& handler, record&) {
14503  // This should never be reached...
14504  // please check your code and understand what you did to bring yourself here
14505  // maybe file a bug report, or 5
14506  handler(
14507  L, index, type::poly, type_of(L, index), "this variant code should never be reached: if it has, you have done something so terribly wrong");
14508  return nullopt;
14509  }
14510 
14511  template <typename Handler>
14512  static optional<V> get_one(std::integral_constant<std::size_t, 0>, lua_State* L, int index, Handler&& handler, record& tracking) {
14513  return get_empty(V_is_empty(), L, index, std::forward<Handler>(handler), tracking);
14514  }
14515 
14516  template <std::size_t I, typename Handler>
14517  static optional<V> get_one(std::integral_constant<std::size_t, I>, lua_State* L, int index, Handler&& handler, record& tracking) {
14518  typedef std::variant_alternative_t<I - 1, V> T;
14519  if (stack::check<T>(L, index, &no_panic, tracking)) {
14520  return V(std::in_place_index<I - 1>, stack::get<T>(L, index));
14521  }
14522  return get_one(std::integral_constant<std::size_t, I - 1>(), L, index, std::forward<Handler>(handler), tracking);
14523  }
14524 
14525  template <typename Handler>
14526  static optional<V> get(lua_State* L, int index, Handler&& handler, record& tracking) {
14527  return get_one(std::integral_constant<std::size_t, V_size::value>(), L, index, std::forward<Handler>(handler), tracking);
14528  }
14529  };
14530 #endif // standard variant
14531 }} // namespace sol::stack
14532 
14533 // end of sol/stack_check_get_unqualified.hpp
14534 
14535 // beginning of sol/stack_check_get_qualified.hpp
14536 
14537 namespace sol { namespace stack {
14538 
14539 #if SOL_IS_ON(SOL_COMPILER_GCC)
14540 #pragma GCC diagnostic push
14541 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
14542 #endif
14543 
14544  namespace stack_detail {
14545  template <typename OptionalType, typename T, typename Handler>
14546  OptionalType get_optional(lua_State* L, int index, Handler&& handler, record& tracking) {
14547  using Tu = meta::unqualified_t<T>;
14548 
14549  if constexpr (is_lua_reference_v<T>) {
14550  if constexpr (is_global_table_v<Tu>) {
14551  (void)L;
14552  (void)index;
14553  (void)handler;
14554  tracking.use(1);
14555  return true;
14556  }
14557  else {
14558  // actually check if it's none here, otherwise
14559  // we'll have a none object inside an optional!
14560  bool success = lua_isnoneornil(L, index) == 0 && stack::check<T>(L, index, &no_panic);
14561  if (!success) {
14562  // expected type, actual type
14563  tracking.use(static_cast<int>(success));
14564  handler(L, index, type::poly, type_of(L, index), "");
14565  return {};
14566  }
14567  return OptionalType(stack_detail::unchecked_get<T>(L, index, tracking));
14568  }
14569  }
14570  else if constexpr (!std::is_reference_v<T> && is_unique_usertype_v<Tu> && !is_actual_type_rebindable_for_v<Tu>) {
14571  // we can take shortcuts here to save on separate checking, and just return nullopt!
14572  using element = unique_usertype_element_t<Tu>;
14573  using actual = unique_usertype_actual_t<Tu>;
14574  tracking.use(1);
14575  void* memory = lua_touserdata(L, index);
14578  if (&detail::usertype_unique_alloc_destroy<element, Tu> == pdx) {
14579  memory = detail::align_usertype_unique_tag<true, false>(memory);
14580  memory = detail::align_usertype_unique<actual, true, false>(memory);
14581  actual* mem = static_cast<actual*>(memory);
14582  return static_cast<actual>(*mem);
14583  }
14584  if constexpr (!derive<element>::value) {
14585  return OptionalType();
14586  }
14587  else {
14588  memory = detail::align_usertype_unique_tag<true, false>(memory);
14589  detail::unique_tag& ic = *reinterpret_cast<detail::unique_tag*>(memory);
14590  memory = detail::align_usertype_unique<actual, true, false>(memory);
14592  int cast_operation;
14593  actual r {};
14594  if constexpr (is_actual_type_rebindable_for_v<Tu>) {
14595  using rebound_actual_type = unique_usertype_rebind_actual_t<Tu, void>;
14597  cast_operation = ic(memory, &r, ti, rebind_ti);
14598  }
14599  else {
14600  string_view rebind_ti("");
14601  cast_operation = ic(memory, &r, ti, rebind_ti);
14602  }
14603  switch (cast_operation) {
14604  case 1: {
14605  // it's a perfect match,
14606  // alias memory directly
14607  actual* mem = static_cast<actual*>(memory);
14608  return OptionalType(*mem);
14609  }
14610  case 2:
14611  // it's a base match, return the
14612  // aliased creation
14613  return OptionalType(std::move(r));
14614  default:
14615  break;
14616  }
14617  return OptionalType();
14618  }
14619  }
14620  else {
14621  if (!check<T>(L, index, std::forward<Handler>(handler))) {
14622  tracking.use(static_cast<int>(!lua_isnone(L, index)));
14623  return OptionalType();
14624  }
14625  return OptionalType(stack_detail::unchecked_get<T>(L, index, tracking));
14626  }
14627  }
14628  } // namespace stack_detail
14629 
14630 #if SOL_IS_ON(SOL_COMPILER_GCC)
14631 #pragma GCC diagnostic pop
14632 #endif
14633 
14634  template <typename T, typename>
14635  struct qualified_check_getter {
14636  typedef decltype(stack_detail::unchecked_get<T>(nullptr, -1, std::declval<record&>())) R;
14637 
14638  template <typename Handler>
14639  optional<R> get(lua_State* L, int index, Handler&& handler, record& tracking) {
14640  return stack_detail::get_optional<optional<R>, T>(L, index, std::forward<Handler>(handler), tracking);
14641  }
14642  };
14643 
14644  template <typename Optional>
14645  struct qualified_getter<Optional, std::enable_if_t<meta::is_optional_v<Optional>>> {
14646  static Optional get(lua_State* L, int index, record& tracking) {
14647  using T = typename meta::unqualified_t<Optional>::value_type;
14648  return stack_detail::get_optional<Optional, T>(L, index, &no_panic, tracking);
14649  }
14650  };
14651 
14652 }} // namespace sol::stack
14653 
14654 // end of sol/stack_check_get_qualified.hpp
14655 
14656 // end of sol/stack_check_get.hpp
14657 
14658 // beginning of sol/stack_push.hpp
14659 
14660 #include <memory>
14661 #include <type_traits>
14662 #include <cassert>
14663 #include <limits>
14664 #include <cmath>
14665 #include <string_view>
14666 #if SOL_IS_ON(SOL_STD_VARIANT)
14667 #include <variant>
14668 #endif // Can use variant
14669 
14670 // beginning of sol/debug.hpp
14671 
14672 #include <iostream>
14673 
14674 namespace sol { namespace detail { namespace debug {
14675  inline std::string dump_types(lua_State* L) {
14676  std::string visual;
14677  std::size_t size = lua_gettop(L) + 1;
14678  for (std::size_t i = 1; i < size; ++i) {
14679  if (i != 1) {
14680  visual += " | ";
14681  }
14682  visual += type_name(L, stack::get<type>(L, static_cast<int>(i)));
14683  }
14684  return visual;
14685  }
14686 
14687  inline void print_stack(lua_State* L) {
14688  std::cout << dump_types(L) << std::endl;
14689  }
14690 
14691  inline void print_section(const std::string& message, lua_State* L) {
14692  std::cout << "-- " << message << " -- [ " << dump_types(L) << " ]" << std::endl;
14693  }
14694 }}} // namespace sol::detail::debug
14695 
14696 // end of sol/debug.hpp
14697 
14698 namespace sol { namespace stack {
14699  namespace stack_detail {
14700  template <typename T>
14701  inline bool integer_value_fits(const T& value) {
14702  // We check if we can rely on casts or a lack of padding bits to satisfy
14703  // the requirements here
14704  // If it lacks padding bits, we can jump back and forth between lua_Integer and whatever type without
14705  // loss of information
14706  constexpr bool is_same_signedness
14707  = (std::is_signed_v<T> && std::is_signed_v<lua_Integer>) || (std::is_unsigned_v<T> && std::is_unsigned_v<lua_Integer>);
14708  constexpr bool probaby_fits_within_lua_Integer = sizeof(T) == sizeof(lua_Integer)
14709 #if SOL_IS_ON(SOL_ALL_INTEGER_VALUES_FIT)
14710  && ((std::has_unique_object_representations_v<T> && std::has_unique_object_representations_v<lua_Integer>) ? true : is_same_signedness)
14711 #else
14712  && is_same_signedness
14713 #endif
14714  ;
14715  if constexpr (sizeof(T) < sizeof(lua_Integer) || probaby_fits_within_lua_Integer) {
14716  (void)value;
14717  return true;
14718  }
14719  else {
14720  auto u_min = static_cast<std::intmax_t>((std::numeric_limits<lua_Integer>::min)());
14721  auto u_max = static_cast<std::uintmax_t>((std::numeric_limits<lua_Integer>::max)());
14722  auto t_min = static_cast<std::intmax_t>((std::numeric_limits<T>::min)());
14723  auto t_max = static_cast<std::uintmax_t>((std::numeric_limits<T>::max)());
14724  return (u_min <= t_min || value >= static_cast<T>(u_min)) && (u_max >= t_max || value <= static_cast<T>(u_max));
14725  }
14726  }
14727 
14728  template <typename T>
14730  if constexpr (meta::any_same_v<std::underlying_type_t<T>,
14731  char
14732 #if SOL_IS_ON(SOL_CHAR8_T)
14733  ,
14734  char8_t
14735 #endif
14736  ,
14737  char16_t,
14738  char32_t>) {
14739  if constexpr (std::is_signed_v<T>) {
14740  return stack::push(L, static_cast<std::int_least32_t>(value));
14741  }
14742  else {
14743  return stack::push(L, static_cast<std::uint_least32_t>(value));
14744  }
14745  }
14746  else {
14747  return stack::push(L, static_cast<std::underlying_type_t<T>>(value));
14748  }
14749  }
14750 
14751  template <typename T>
14753  return 0;
14754  }
14755  } // namespace stack_detail
14756 
14757  inline int push_environment_of(lua_State* L, int target_index = -1) {
14758 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
14760 #endif // make sure stack doesn't overflow
14761 #if SOL_LUA_VERSION_I_ < 502
14762  // Use lua_getfenv
14763  lua_getfenv(L, target_index);
14764 #else
14765 
14766  if (lua_iscfunction(L, target_index) != 0) {
14767  const char* maybe_upvalue_name = lua_getupvalue(L, target_index, 1);
14768  if (maybe_upvalue_name != nullptr) {
14769  // it worked, take this one
14770  return 1;
14771  }
14772  }
14773  // Nominally, we search for the `"_ENV"` value.
14774  // If we don't find it.... uh, well. We've got a problem?
14775  for (int upvalue_index = 1;; ++upvalue_index) {
14776  const char* maybe_upvalue_name = lua_getupvalue(L, target_index, upvalue_index);
14777  if (maybe_upvalue_name == nullptr) {
14778  push(L, lua_nil);
14779  break;
14780  }
14781 
14782  string_view upvalue_name(maybe_upvalue_name);
14783  if (upvalue_name == "_ENV") {
14784  // Keep this one!
14785  break;
14786  }
14787  // Discard what we received, loop back around
14788  lua_pop(L, 1);
14789  }
14790 #endif
14791  return 1;
14792  }
14793 
14794  template <typename T>
14795  int push_environment_of(const T& target) {
14796  lua_State* target_L = target.lua_state();
14797  int target_index = absolute_index(target_L, -target.push());
14798  int env_count = push_environment_of(target_L, target_index);
14799  sol_c_assert(env_count == 1);
14800  lua_rotate(target_L, target_index, 1);
14801  lua_pop(target_L, 1);
14802  return env_count;
14803  }
14804 
14805  template <typename T>
14806  struct unqualified_pusher<detail::as_value_tag<T>> {
14807  template <typename F, typename... Args>
14808  static int push_fx(lua_State* L, F&& f, Args&&... args) {
14809 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
14811 #endif // make sure stack doesn't overflow
14812  // Basically, we store all user-data like this:
14813  // If it's a movable/copyable value (no std::ref(x)), then we store the pointer to the new
14814  // data in the first sizeof(T*) bytes, and then however many bytes it takes to
14815  // do the actual object. Things that are std::ref or plain T* are stored as
14816  // just the sizeof(T*), and nothing else.
14817  T* obj = detail::usertype_allocate<T>(L);
14818  f();
14819  std::allocator<T> alloc {};
14820  std::allocator_traits<std::allocator<T>>::construct(alloc, obj, std::forward<Args>(args)...);
14821  return 1;
14822  }
14823 
14824  template <typename K, typename... Args>
14825  static int push_keyed(lua_State* L, K&& k, Args&&... args) {
14826  stack_detail::undefined_metatable fx(L, &k[0], &stack::stack_detail::set_undefined_methods_on<T>);
14827  return push_fx(L, fx, std::forward<Args>(args)...);
14828  }
14829 
14830  template <typename Arg, typename... Args>
14831  static int push(lua_State* L, Arg&& arg, Args&&... args) {
14832  if constexpr (std::is_same_v<meta::unqualified_t<Arg>, detail::with_function_tag>) {
14833  (void)arg;
14834  return push_fx(L, std::forward<Args>(args)...);
14835  }
14836  else {
14837  return push_keyed(L, usertype_traits<T>::metatable(), std::forward<Arg>(arg), std::forward<Args>(args)...);
14838  }
14839  }
14840 
14841  static int push(lua_State* L) {
14842  return push_keyed(L, usertype_traits<T>::metatable());
14843  }
14844  };
14845 
14846  template <typename T>
14847  struct unqualified_pusher<detail::as_pointer_tag<T>> {
14849 
14850  template <typename F>
14851  static int push_fx(lua_State* L, F&& f, T* obj) {
14852  if (obj == nullptr)
14853  return stack::push(L, lua_nil);
14854 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
14856 #endif // make sure stack doesn't overflow
14857  T** pref = detail::usertype_allocate_pointer<T>(L);
14858  f();
14859  *pref = obj;
14860  return 1;
14861  }
14862 
14863  template <typename K>
14864  static int push_keyed(lua_State* L, K&& k, T* obj) {
14865  stack_detail::undefined_metatable fx(L, &k[0], &stack::stack_detail::set_undefined_methods_on<U*>);
14866  return push_fx(L, fx, obj);
14867  }
14868 
14869  template <typename Arg, typename... Args>
14870  static int push(lua_State* L, Arg&& arg, Args&&... args) {
14871  if constexpr (std::is_same_v<meta::unqualified_t<Arg>, detail::with_function_tag>) {
14872  (void)arg;
14873  return push_fx(L, std::forward<Args>(args)...);
14874  }
14875  else {
14876  return push_keyed(L, usertype_traits<U*>::metatable(), std::forward<Arg>(arg), std::forward<Args>(args)...);
14877  }
14878  }
14879  };
14880 
14881  template <>
14882  struct unqualified_pusher<detail::as_reference_tag> {
14883  template <typename T>
14884  static int push(lua_State* L, T&& obj) {
14885  return stack::push(L, detail::ptr(obj));
14886  }
14887  };
14888 
14889  namespace stack_detail {
14890  template <typename T>
14891  struct uu_pusher {
14894 
14895  template <typename Arg, typename... Args>
14896  static int push(lua_State* L, Arg&& arg, Args&&... args) {
14897  if constexpr (std::is_base_of_v<actual, meta::unqualified_t<Arg>>) {
14898  if (detail::unique_is_null(L, arg)) {
14899  return stack::push(L, lua_nil);
14900  }
14901  return push_deep(L, std::forward<Arg>(arg), std::forward<Args>(args)...);
14902  }
14903  else {
14904  return push_deep(L, std::forward<Arg>(arg), std::forward<Args>(args)...);
14905  }
14906  }
14907 
14908  template <typename... Args>
14909  static int push_deep(lua_State* L, Args&&... args) {
14910 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
14912 #endif // make sure stack doesn't overflow
14913  element** pointer_to_memory = nullptr;
14914  detail::unique_destructor* fx = nullptr;
14915  detail::unique_tag* id = nullptr;
14916  actual* typed_memory = detail::usertype_unique_allocate<element, actual>(L, pointer_to_memory, fx, id);
14917  if (luaL_newmetatable(L, &usertype_traits<d::u<std::remove_cv_t<element>>>::metatable()[0]) == 1) {
14918  detail::lua_reg_table registration_table {};
14919  int index = 0;
14920  detail::indexed_insert insert_callable(registration_table, index);
14921  detail::insert_default_registrations<element>(insert_callable, detail::property_always_true);
14922  registration_table[index] = { to_string(meta_function::garbage_collect).c_str(), detail::make_destructor<T>() };
14923  luaL_setfuncs(L, registration_table, 0);
14924  }
14925  lua_setmetatable(L, -2);
14926  *fx = detail::usertype_unique_alloc_destroy<element, actual>;
14927  *id = &detail::inheritance<element>::template type_unique_cast<actual>;
14928  detail::default_construct::construct(typed_memory, std::forward<Args>(args)...);
14929  *pointer_to_memory = detail::unique_get<T>(L, *typed_memory);
14930  return 1;
14931  }
14932  };
14933  } // namespace stack_detail
14934 
14935  template <typename T>
14936  struct unqualified_pusher<detail::as_unique_tag<T>> {
14937  template <typename... Args>
14938  static int push(lua_State* L, Args&&... args) {
14940  (void)p;
14941  return p.push(L, std::forward<Args>(args)...);
14942  }
14943  };
14944 
14945  template <typename T, typename>
14946  struct unqualified_pusher {
14947  template <typename... Args>
14948  static int push(lua_State* L, Args&&... args) {
14949  using Tu = meta::unqualified_t<T>;
14950  if constexpr (is_lua_reference_v<Tu>) {
14951  using int_arr = int[];
14952  int_arr p { (std::forward<Args>(args).push(L))... };
14953  return p[0];
14954  }
14955  else if constexpr (std::is_same_v<Tu, bool>) {
14956 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
14958 #endif // make sure stack doesn't overflow
14959  lua_pushboolean(L, std::forward<Args>(args)...);
14960  return 1;
14961  }
14962  else if constexpr (std::is_integral_v<Tu> || std::is_same_v<Tu, lua_Integer>) {
14963  const Tu& value(std::forward<Args>(args)...);
14964 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
14966 #endif // make sure stack doesn't overflow
14967 #if SOL_LUA_VERSION_I_ >= 503
14968  if (stack_detail::integer_value_fits<Tu>(value)) {
14969  lua_pushinteger(L, static_cast<lua_Integer>(value));
14970  return 1;
14971  }
14972 #endif // Lua 5.3 and above
14973 #if SOL_IS_ON(SOL_NUMBER_PRECISION_CHECKS)
14974  if (static_cast<T>(llround(static_cast<lua_Number>(value))) != value) {
14975 #if SOL_IS_OFF(SOL_EXCEPTIONS)
14976  // Is this really worth it?
14977  sol_m_assert(false, "integer value will be misrepresented in lua");
14978  lua_pushinteger(L, static_cast<lua_Integer>(value));
14979  return 1;
14980 #else
14981  throw error(detail::direct_error, "integer value will be misrepresented in lua");
14982 #endif // No Exceptions
14983  }
14984 #endif // Safe Numerics and Number Precision Check
14985  lua_pushnumber(L, static_cast<lua_Number>(value));
14986  return 1;
14987  }
14988  else if constexpr (std::is_floating_point_v<Tu> || std::is_same_v<Tu, lua_Number>) {
14989 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
14991 #endif // make sure stack doesn't overflow
14992  lua_pushnumber(L, std::forward<Args>(args)...);
14993  return 1;
14994  }
14995  else if constexpr (std::is_same_v<Tu, luaL_Stream*>) {
14996  luaL_Stream* source { std::forward<Args>(args)... };
14997  luaL_Stream* stream = static_cast<luaL_Stream*>(detail::alloc_newuserdata(L, sizeof(luaL_Stream)));
14998  stream->f = source->f;
14999 #if SOL_IS_ON(SOL_LUAL_STREAM_USE_CLOSE_FUNCTION)
15000  stream->closef = source->closef;
15001 #endif // LuaJIT and Lua 5.1 and below do not have
15002  return 1;
15003  }
15004  else if constexpr (std::is_same_v<Tu, luaL_Stream>) {
15005  luaL_Stream& source(std::forward<Args>(args)...);
15006  luaL_Stream* stream = static_cast<luaL_Stream*>(detail::alloc_newuserdata(L, sizeof(luaL_Stream)));
15007  stream->f = source.f;
15008 #if SOL_IS_ON(SOL_LUAL_STREAM_USE_CLOSE_FUNCTION)
15009  stream->closef = source.closef;
15010 #endif // LuaJIT and Lua 5.1 and below do not have
15011  return 1;
15012  }
15013  else if constexpr (std::is_enum_v<Tu>) {
15014  return stack_detail::msvc_is_ass_with_if_constexpr_push_enum(std::true_type(), L, std::forward<Args>(args)...);
15015  }
15016  else if constexpr (std::is_pointer_v<Tu>) {
15017  return stack::push<detail::as_pointer_tag<std::remove_pointer_t<T>>>(L, std::forward<Args>(args)...);
15018  }
15019  else if constexpr (is_unique_usertype_v<Tu>) {
15020  return stack::push<detail::as_unique_tag<T>>(L, std::forward<Args>(args)...);
15021  }
15022  else {
15023  return stack::push<detail::as_value_tag<T>>(L, std::forward<Args>(args)...);
15024  }
15025  }
15026  };
15027 
15028  template <typename T>
15029  struct unqualified_pusher<std::reference_wrapper<T>> {
15030  static int push(lua_State* L, const std::reference_wrapper<T>& t) {
15031  return stack::push(L, std::addressof(detail::deref(t.get())));
15032  }
15033  };
15034 
15035  template <typename T>
15036  struct unqualified_pusher<detail::as_table_tag<T>> {
15038 
15039  static int push(lua_State* L, const T& tablecont) {
15040  return push(has_kvp(), std::false_type(), L, tablecont);
15041  }
15042 
15043  static int push(lua_State* L, const T& tablecont, nested_tag_t) {
15044  return push(has_kvp(), std::true_type(), L, tablecont);
15045  }
15046 
15047  static int push(std::true_type, lua_State* L, const T& tablecont) {
15048  return push(has_kvp(), std::true_type(), L, tablecont);
15049  }
15050 
15051  static int push(std::false_type, lua_State* L, const T& tablecont) {
15052  return push(has_kvp(), std::false_type(), L, tablecont);
15053  }
15054 
15055  template <bool is_nested>
15056  static int push(std::true_type, std::integral_constant<bool, is_nested>, lua_State* L, const T& tablecont) {
15057  auto& cont = detail::deref(detail::unwrap(tablecont));
15058  lua_createtable(L, static_cast<int>(cont.size()), 0);
15059  int tableindex = lua_gettop(L);
15060  for (const auto& pair : cont) {
15061  if (is_nested) {
15062  set_field(L, pair.first, as_nested_ref(pair.second), tableindex);
15063  }
15064  else {
15065  set_field(L, pair.first, pair.second, tableindex);
15066  }
15067  }
15068  return 1;
15069  }
15070 
15071  template <bool is_nested>
15072  static int push(std::false_type, std::integral_constant<bool, is_nested>, lua_State* L, const T& tablecont) {
15073  auto& cont = detail::deref(detail::unwrap(tablecont));
15075  int tableindex = lua_gettop(L);
15076  std::size_t index = 1;
15077  for (const auto& i : cont) {
15078 #if SOL_LUA_VERSION_I_ >= 503
15079  int p = is_nested ? stack::push(L, as_nested_ref(i)) : stack::push(L, i);
15080  for (int pi = 0; pi < p; ++pi) {
15081  lua_seti(L, tableindex, static_cast<lua_Integer>(index++));
15082  }
15083 #else
15084 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15086 #endif // make sure stack doesn't overflow
15087  lua_pushinteger(L, static_cast<lua_Integer>(index));
15088  int p = is_nested ? stack::push(L, as_nested_ref(i)) : stack::push(L, i);
15089  if (p == 1) {
15090  ++index;
15091  lua_settable(L, tableindex);
15092  }
15093  else {
15094  int firstindex = tableindex + 1 + 1;
15095  for (int pi = 0; pi < p; ++pi) {
15096  stack::push(L, index);
15097 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15099 #endif // make sure stack doesn't overflow
15100  lua_pushvalue(L, firstindex);
15101  lua_settable(L, tableindex);
15102  ++index;
15103  ++firstindex;
15104  }
15105  lua_pop(L, 1 + p);
15106  }
15107 #endif // Lua Version 5.3 and others
15108  }
15109  // TODO: figure out a better way to do this...?
15110  // set_field(L, -1, cont.size());
15111  return 1;
15112  }
15113  };
15114 
15115  template <typename T>
15117  static int push(lua_State* L, const as_table_t<T>& value_) {
15118  using inner_t = std::remove_pointer_t<meta::unwrap_unqualified_t<T>>;
15119  if constexpr (is_container_v<inner_t>) {
15120  return stack::push<detail::as_table_tag<T>>(L, value_.value());
15121  }
15122  else {
15123  return stack::push(L, value_.value());
15124  }
15125  }
15126 
15127  static int push(lua_State* L, const T& value_) {
15128  using inner_t = std::remove_pointer_t<meta::unwrap_unqualified_t<T>>;
15129  if constexpr (is_container_v<inner_t>) {
15130  return stack::push<detail::as_table_tag<T>>(L, value_);
15131  }
15132  else {
15133  return stack::push(L, value_);
15134  }
15135  }
15136  };
15137 
15138  template <typename T>
15140  static int push(lua_State* L, const T& nested_value) noexcept {
15141  using Tu = meta::unwrap_unqualified_t<T>;
15142  using inner_t = std::remove_pointer_t<Tu>;
15143  if constexpr (is_container_v<inner_t>) {
15144  return stack::push<detail::as_table_tag<T>>(L, nested_value, nested_tag);
15145  }
15146  else {
15147  return stack::push<Tu>(L, nested_value);
15148  }
15149  }
15150 
15151  static int push(lua_State* L, const nested<T>& nested_wrapper_) noexcept {
15152  using Tu = meta::unwrap_unqualified_t<T>;
15153  using inner_t = std::remove_pointer_t<Tu>;
15154  if constexpr (is_container_v<inner_t>) {
15155  return stack::push<detail::as_table_tag<T>>(L, nested_wrapper_.value(), nested_tag);
15156  }
15157  else {
15158  return stack::push<Tu>(L, nested_wrapper_.value());
15159  }
15160  }
15161  };
15162 
15163  template <typename T>
15164  struct unqualified_pusher<std::initializer_list<T>> {
15165  static int push(lua_State* L, const std::initializer_list<T>& il) noexcept {
15167  return p.push(L, il);
15168  }
15169  };
15170 
15171  template <>
15173  static int push(lua_State* L, lua_nil_t) noexcept {
15174 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15176 #endif // make sure stack doesn't overflow
15177  lua_pushnil(L);
15178  return 1;
15179  }
15180  };
15181 
15182  template <>
15184  static int push(lua_State*, stack_count st) noexcept {
15185  return st.count;
15186  }
15187  };
15188 
15189  template <>
15191  static int push(lua_State* L, metatable_key_t) {
15192 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15194 #endif // make sure stack doesn't overflow
15195  lua_pushlstring(L, to_string(meta_function::metatable).c_str(), 4);
15196  return 1;
15197  }
15198  };
15199 
15200  template <>
15201  struct unqualified_pusher<std::remove_pointer_t<lua_CFunction>> {
15202  static int push(lua_State* L, lua_CFunction func, int n = 0) noexcept {
15203 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15205 #endif // make sure stack doesn't overflow
15206  lua_pushcclosure(L, func, n);
15207  return 1;
15208  }
15209  };
15210 
15211  template <>
15213  static int push(lua_State* L, lua_CFunction func, int n = 0) {
15214 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15216 #endif // make sure stack doesn't overflow
15217  lua_pushcclosure(L, func, n);
15218  return 1;
15219  }
15220  };
15221 
15222 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE)
15223  template <>
15224  struct unqualified_pusher<std::remove_pointer_t<detail::lua_CFunction_noexcept>> {
15225  static int push(lua_State* L, detail::lua_CFunction_noexcept func, int n = 0) {
15226 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15228 #endif // make sure stack doesn't overflow
15229  lua_pushcclosure(L, func, n);
15230  return 1;
15231  }
15232  };
15233 
15234  template <>
15236  static int push(lua_State* L, detail::lua_CFunction_noexcept func, int n = 0) {
15237 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15239 #endif // make sure stack doesn't overflow
15240  lua_pushcclosure(L, func, n);
15241  return 1;
15242  }
15243  };
15244 #endif // noexcept function type
15245 
15246  template <>
15248  static int push(lua_State* L, c_closure cc) {
15249 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15251 #endif // make sure stack doesn't overflow
15253  return 1;
15254  }
15255  };
15256 
15257  template <typename Arg, typename... Args>
15258  struct unqualified_pusher<closure<Arg, Args...>> {
15259  template <std::size_t... I, typename T>
15260  static int push(std::index_sequence<I...>, lua_State* L, T&& c) {
15261  using f_tuple = decltype(std::forward<T>(c).upvalues);
15262  int pushcount = multi_push(L, std::get<I>(std::forward<f_tuple>(std::forward<T>(c).upvalues))...);
15263  return stack::push(L, c_closure(c.c_function, pushcount));
15264  }
15265 
15266  template <typename T>
15267  static int push(lua_State* L, T&& c) {
15268  return push(std::make_index_sequence<1 + sizeof...(Args)>(), L, std::forward<T>(c));
15269  }
15270  };
15271 
15272  template <>
15274  static int push(lua_State* L, void* userdata) noexcept {
15275 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15277 #endif // make sure stack doesn't overflow
15279  return 1;
15280  }
15281  };
15282 
15283  template <>
15284  struct unqualified_pusher<const void*> {
15285  static int push(lua_State* L, const void* userdata) noexcept {
15286 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15288 #endif // make sure stack doesn't overflow
15289  lua_pushlightuserdata(L, const_cast<void*>(userdata));
15290  return 1;
15291  }
15292  };
15293 
15294  template <>
15296  static int push(lua_State* L, lightuserdata_value userdata) noexcept {
15297 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15299 #endif // make sure stack doesn't overflow
15301  return 1;
15302  }
15303  };
15304 
15305  template <typename T>
15307  static int push(lua_State* L, light<T> l) noexcept {
15308 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15310 #endif // make sure stack doesn't overflow
15311  lua_pushlightuserdata(L, static_cast<void*>(l.value()));
15312  return 1;
15313  }
15314  };
15315 
15316  template <typename T>
15318  template <bool with_meta = true, typename Key, typename... Args>
15319  static int push_with(lua_State* L, Key&& name, Args&&... args) {
15320 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15322 #endif // make sure stack doesn't overflow
15323  // A dumb pusher
15324  T* data = detail::user_allocate<T>(L);
15325  if (with_meta) {
15326  // Make sure we have a plain GC set for this data
15327 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15329 #endif // make sure stack doesn't overflow
15330  if (luaL_newmetatable(L, name) != 0) {
15331  lua_CFunction cdel = detail::user_alloc_destroy<T>;
15332  lua_pushcclosure(L, cdel, 0);
15333  lua_setfield(L, -2, "__gc");
15334  }
15335  lua_setmetatable(L, -2);
15336  }
15337  std::allocator<T> alloc {};
15338  std::allocator_traits<std::allocator<T>>::construct(alloc, data, std::forward<Args>(args)...);
15339  return 1;
15340  }
15341 
15342  template <typename Arg, typename... Args>
15343  static int push(lua_State* L, Arg&& arg, Args&&... args) {
15344  if constexpr (std::is_same_v<meta::unqualified_t<Arg>, metatable_key_t>) {
15345  const auto name = &arg[0];
15346  return push_with<true>(L, name, std::forward<Args>(args)...);
15347  }
15348  else if constexpr (std::is_same_v<meta::unqualified_t<Arg>, no_metatable_t>) {
15349  (void)arg;
15350  const auto name = &usertype_traits<meta::unqualified_t<T>>::user_gc_metatable()[0];
15351  return push_with<false>(L, name, std::forward<Args>(args)...);
15352  }
15353  else {
15354  const auto name = &usertype_traits<meta::unqualified_t<T>>::user_gc_metatable()[0];
15355  return push_with(L, name, std::forward<Arg>(arg), std::forward<Args>(args)...);
15356  }
15357  }
15358 
15359  static int push(lua_State* L, const user<T>& u) {
15360  const auto name = &usertype_traits<meta::unqualified_t<T>>::user_gc_metatable()[0];
15361  return push_with(L, name, u.value);
15362  }
15363 
15364  static int push(lua_State* L, user<T>&& u) {
15365  const auto name = &usertype_traits<meta::unqualified_t<T>>::user_gc_metatable()[0];
15366  return push_with(L, name, std::move(u.value()));
15367  }
15368 
15369  static int push(lua_State* L, no_metatable_t, const user<T>& u) {
15370  const auto name = &usertype_traits<meta::unqualified_t<T>>::user_gc_metatable()[0];
15371  return push_with<false>(L, name, u.value());
15372  }
15373 
15374  static int push(lua_State* L, no_metatable_t, user<T>&& u) {
15375  const auto name = &usertype_traits<meta::unqualified_t<T>>::user_gc_metatable()[0];
15376  return push_with<false>(L, name, std::move(u.value()));
15377  }
15378  };
15379 
15380  template <>
15382  static int push(lua_State* L, userdata_value data) {
15383 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15385 #endif // make sure stack doesn't overflow
15386  void** ud = detail::usertype_allocate_pointer<void>(L);
15387  *ud = data.value();
15388  return 1;
15389  }
15390  };
15391 
15392  template <>
15393  struct unqualified_pusher<const char*> {
15394  static int push_sized(lua_State* L, const char* str, std::size_t len) {
15395 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15397 #endif // make sure stack doesn't overflow
15398  lua_pushlstring(L, str, len);
15399  return 1;
15400  }
15401 
15402  static int push(lua_State* L, const char* str) {
15403  if (str == nullptr)
15404  return stack::push(L, lua_nil);
15405  return push_sized(L, str, std::char_traits<char>::length(str));
15406  }
15407 
15408  static int push(lua_State* L, const char* strb, const char* stre) {
15409  return push_sized(L, strb, static_cast<std::size_t>(stre - strb));
15410  }
15411 
15412  static int push(lua_State* L, const char* str, std::size_t len) {
15413  return push_sized(L, str, len);
15414  }
15415  };
15416 
15417  template <>
15418  struct unqualified_pusher<char*> {
15419  static int push_sized(lua_State* L, const char* str, std::size_t len) {
15421  (void)p;
15422  return p.push_sized(L, str, len);
15423  }
15424 
15425  static int push(lua_State* L, const char* str) {
15427  (void)p;
15428  return p.push(L, str);
15429  }
15430 
15431  static int push(lua_State* L, const char* strb, const char* stre) {
15433  (void)p;
15434  return p.push(L, strb, stre);
15435  }
15436 
15437  static int push(lua_State* L, const char* str, std::size_t len) {
15439  (void)p;
15440  return p.push(L, str, len);
15441  }
15442  };
15443 
15444  template <size_t N>
15445  struct unqualified_pusher<char[N]> {
15446  static int push(lua_State* L, const char (&str)[N]) {
15447 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15449 #endif // make sure stack doesn't overflow
15450  lua_pushlstring(L, str, std::char_traits<char>::length(str));
15451  return 1;
15452  }
15453 
15454  static int push(lua_State* L, const char (&str)[N], std::size_t sz) {
15455 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15457 #endif // make sure stack doesn't overflow
15458  lua_pushlstring(L, str, sz);
15459  return 1;
15460  }
15461  };
15462 
15463  template <>
15464  struct unqualified_pusher<char> {
15465  static int push(lua_State* L, char c) {
15466  const char str[2] = { c, '\0' };
15467  return stack::push(L, static_cast<const char*>(str), 1u);
15468  }
15469  };
15470 
15471 #if SOL_IS_ON(SOL_CHAR8_T)
15472  template <>
15473  struct unqualified_pusher<const char8_t*> {
15474  static int push_sized(lua_State* L, const char8_t* str, std::size_t len) {
15475 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15477 #endif // make sure stack doesn't overflow
15478  lua_pushlstring(L, reinterpret_cast<const char*>(str), len);
15479  return 1;
15480  }
15481 
15482  static int push(lua_State* L, const char8_t* str) {
15483  if (str == nullptr)
15484  return stack::push(L, lua_nil);
15485  return push_sized(L, str, std::char_traits<char>::length(reinterpret_cast<const char*>(str)));
15486  }
15487 
15488  static int push(lua_State* L, const char8_t* strb, const char8_t* stre) {
15489  return push_sized(L, strb, static_cast<std::size_t>(stre - strb));
15490  }
15491 
15492  static int push(lua_State* L, const char8_t* str, std::size_t len) {
15493  return push_sized(L, str, len);
15494  }
15495  };
15496 
15497  template <>
15498  struct unqualified_pusher<char8_t*> {
15499  static int push_sized(lua_State* L, const char8_t* str, std::size_t len) {
15500  unqualified_pusher<const char8_t*> p {};
15501  (void)p;
15502  return p.push_sized(L, str, len);
15503  }
15504 
15505  static int push(lua_State* L, const char8_t* str) {
15506  unqualified_pusher<const char8_t*> p {};
15507  (void)p;
15508  return p.push(L, str);
15509  }
15510 
15511  static int push(lua_State* L, const char8_t* strb, const char8_t* stre) {
15512  unqualified_pusher<const char8_t*> p {};
15513  (void)p;
15514  return p.push(L, strb, stre);
15515  }
15516 
15517  static int push(lua_State* L, const char8_t* str, std::size_t len) {
15518  unqualified_pusher<const char8_t*> p {};
15519  (void)p;
15520  return p.push(L, str, len);
15521  }
15522  };
15523 
15524  template <size_t N>
15525  struct unqualified_pusher<char8_t[N]> {
15526  static int push(lua_State* L, const char8_t (&str)[N]) {
15527 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15529 #endif // make sure stack doesn't overflow
15530  const char* str_as_char = reinterpret_cast<const char*>(static_cast<const char8_t*>(str));
15531  lua_pushlstring(L, str_as_char, std::char_traits<char>::length(str_as_char));
15532  return 1;
15533  }
15534 
15535  static int push(lua_State* L, const char8_t (&str)[N], std::size_t sz) {
15536 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15538 #endif // make sure stack doesn't overflow
15539  lua_pushlstring(L, str, sz);
15540  return 1;
15541  }
15542  };
15543 
15544  template <>
15545  struct unqualified_pusher<char8_t> {
15546  static int push(lua_State* L, char8_t c) {
15547  const char8_t str[2] = { c, '\0' };
15548  return stack::push(L, static_cast<const char8_t*>(str), 1u);
15549  }
15550  };
15551 #endif // char8_t
15552 
15553  template <typename Ch, typename Traits, typename Al>
15554  struct unqualified_pusher<std::basic_string<Ch, Traits, Al>> {
15555  static int push(lua_State* L, const std::basic_string<Ch, Traits, Al>& str) {
15556  if constexpr (!std::is_same_v<Ch, char>) {
15557  return stack::push(L, str.data(), str.size());
15558  }
15559  else {
15560 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15562 #endif // make sure stack doesn't overflow
15563  lua_pushlstring(L, str.c_str(), str.size());
15564  return 1;
15565  }
15566  }
15567 
15568  static int push(lua_State* L, const std::basic_string<Ch, Traits, Al>& str, std::size_t sz) {
15569  if constexpr (!std::is_same_v<Ch, char>) {
15570  return stack::push(L, str.data(), sz);
15571  }
15572  else {
15573 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15575 #endif // make sure stack doesn't overflow
15576  lua_pushlstring(L, str.c_str(), sz);
15577  return 1;
15578  }
15579  }
15580  };
15581 
15582  template <typename Ch, typename Traits>
15584  static int push(lua_State* L, const basic_string_view<Ch, Traits>& sv) {
15585  return stack::push(L, sv.data(), sv.length());
15586  }
15587 
15589  return stack::push(L, sv.data(), n);
15590  }
15591  };
15592 
15593  template <>
15595  static int push(lua_State* L, meta_function m) {
15596 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15598 #endif // make sure stack doesn't overflow
15599  const std::string& str = to_string(m);
15600  lua_pushlstring(L, str.c_str(), str.size());
15601  return 1;
15602  }
15603  };
15604 
15605  template <>
15607  static int push(lua_State* L, absolute_index ai) {
15608 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15610 #endif // make sure stack doesn't overflow
15611  lua_pushvalue(L, ai);
15612  return 1;
15613  }
15614  };
15615 
15616  template <>
15618  static int push(lua_State* L, raw_index ri) {
15619 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15621 #endif // make sure stack doesn't overflow
15622  lua_pushvalue(L, ri);
15623  return 1;
15624  }
15625  };
15626 
15627  template <>
15629  static int push(lua_State* L, ref_index ri) {
15630 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15632 #endif // make sure stack doesn't overflow
15634  return 1;
15635  }
15636  };
15637 
15638  template <>
15639  struct unqualified_pusher<const wchar_t*> {
15640  static int push(lua_State* L, const wchar_t* wstr) {
15641  return push(L, wstr, std::char_traits<wchar_t>::length(wstr));
15642  }
15643 
15644  static int push(lua_State* L, const wchar_t* wstr, std::size_t sz) {
15645  return push(L, wstr, wstr + sz);
15646  }
15647 
15648  static int push(lua_State* L, const wchar_t* strb, const wchar_t* stre) {
15649  if constexpr (sizeof(wchar_t) == 2) {
15650  const char16_t* sb = reinterpret_cast<const char16_t*>(strb);
15651  const char16_t* se = reinterpret_cast<const char16_t*>(stre);
15652  return stack::push(L, sb, se);
15653  }
15654  else {
15655  const char32_t* sb = reinterpret_cast<const char32_t*>(strb);
15656  const char32_t* se = reinterpret_cast<const char32_t*>(stre);
15657  return stack::push(L, sb, se);
15658  }
15659  }
15660  };
15661 
15662  template <>
15663  struct unqualified_pusher<wchar_t*> {
15664  static int push(lua_State* L, const wchar_t* str) {
15666  (void)p;
15667  return p.push(L, str);
15668  }
15669 
15670  static int push(lua_State* L, const wchar_t* strb, const wchar_t* stre) {
15672  (void)p;
15673  return p.push(L, strb, stre);
15674  }
15675 
15676  static int push(lua_State* L, const wchar_t* str, std::size_t len) {
15678  (void)p;
15679  return p.push(L, str, len);
15680  }
15681  };
15682 
15683  template <>
15684  struct unqualified_pusher<const char16_t*> {
15685  static int convert_into(lua_State* L, char* start, std::size_t, const char16_t* strb, const char16_t* stre) {
15686  char* target = start;
15687  char32_t cp = 0;
15688  for (const char16_t* strtarget = strb; strtarget < stre;) {
15689  auto dr = unicode::utf16_to_code_point(strtarget, stre);
15690  if (dr.error != unicode::error_code::ok) {
15692  }
15693  else {
15694  cp = dr.codepoint;
15695  }
15696  auto er = unicode::code_point_to_utf8(cp);
15697  const char* utf8data = er.code_units.data();
15698  std::memcpy(target, utf8data, er.code_units_size);
15699  target += er.code_units_size;
15700  strtarget = dr.next;
15701  }
15702 
15703  return stack::push(L, start, target);
15704  }
15705 
15706  static int push(lua_State* L, const char16_t* u16str) {
15707  return push(L, u16str, std::char_traits<char16_t>::length(u16str));
15708  }
15709 
15710  static int push(lua_State* L, const char16_t* u16str, std::size_t sz) {
15711  return push(L, u16str, u16str + sz);
15712  }
15713 
15714  static int push(lua_State* L, const char16_t* strb, const char16_t* stre) {
15716  // if our max string space is small enough, use SBO
15717  // right off the bat
15718  std::size_t max_possible_code_units = static_cast<std::size_t>(static_cast<std::size_t>(stre - strb) * static_cast<std::size_t>(4));
15719  if (max_possible_code_units <= SOL_OPTIMIZATION_STRING_CONVERSION_STACK_SIZE_I_) {
15720  return convert_into(L, sbo, max_possible_code_units, strb, stre);
15721  }
15722  // otherwise, we must manually count/check size
15723  std::size_t needed_size = 0;
15724  for (const char16_t* strtarget = strb; strtarget < stre;) {
15725  auto dr = unicode::utf16_to_code_point(strtarget, stre);
15726  auto er = unicode::code_point_to_utf8(dr.codepoint);
15727  needed_size += er.code_units_size;
15728  strtarget = dr.next;
15729  }
15731  return convert_into(L, sbo, needed_size, strb, stre);
15732  }
15733  std::string u8str("", 0);
15734  u8str.resize(needed_size);
15735  char* target = const_cast<char*>(u8str.data());
15736  return convert_into(L, target, needed_size, strb, stre);
15737  }
15738  };
15739 
15740  template <>
15741  struct unqualified_pusher<char16_t*> {
15742  static int push(lua_State* L, const char16_t* str) {
15744  (void)p;
15745  return p.push(L, str);
15746  }
15747 
15748  static int push(lua_State* L, const char16_t* strb, const char16_t* stre) {
15750  (void)p;
15751  return p.push(L, strb, stre);
15752  }
15753 
15754  static int push(lua_State* L, const char16_t* str, std::size_t len) {
15756  (void)p;
15757  return p.push(L, str, len);
15758  }
15759  };
15760 
15761  template <>
15762  struct unqualified_pusher<const char32_t*> {
15763  static int convert_into(lua_State* L, char* start, std::size_t, const char32_t* strb, const char32_t* stre) {
15764  char* target = start;
15765  char32_t cp = 0;
15766  for (const char32_t* strtarget = strb; strtarget < stre;) {
15767  auto dr = unicode::utf32_to_code_point(strtarget, stre);
15768  if (dr.error != unicode::error_code::ok) {
15770  }
15771  else {
15772  cp = dr.codepoint;
15773  }
15774  auto er = unicode::code_point_to_utf8(cp);
15775  const char* data = er.code_units.data();
15776  std::memcpy(target, data, er.code_units_size);
15777  target += er.code_units_size;
15778  strtarget = dr.next;
15779  }
15780  return stack::push(L, start, target);
15781  }
15782 
15783  static int push(lua_State* L, const char32_t* u32str) {
15784  return push(L, u32str, u32str + std::char_traits<char32_t>::length(u32str));
15785  }
15786 
15787  static int push(lua_State* L, const char32_t* u32str, std::size_t sz) {
15788  return push(L, u32str, u32str + sz);
15789  }
15790 
15791  static int push(lua_State* L, const char32_t* strb, const char32_t* stre) {
15793  // if our max string space is small enough, use SBO
15794  // right off the bat
15795  std::size_t max_possible_code_units = static_cast<std::size_t>(static_cast<std::size_t>(stre - strb) * static_cast<std::size_t>(4));
15796  if (max_possible_code_units <= SOL_OPTIMIZATION_STRING_CONVERSION_STACK_SIZE_I_) {
15797  return convert_into(L, sbo, max_possible_code_units, strb, stre);
15798  }
15799  // otherwise, we must manually count/check size
15800  std::size_t needed_size = 0;
15801  for (const char32_t* strtarget = strb; strtarget < stre;) {
15802  auto dr = unicode::utf32_to_code_point(strtarget, stre);
15803  auto er = unicode::code_point_to_utf8(dr.codepoint);
15804  needed_size += er.code_units_size;
15805  strtarget = dr.next;
15806  }
15808  return convert_into(L, sbo, needed_size, strb, stre);
15809  }
15810  std::string u8str("", 0);
15811  u8str.resize(needed_size);
15812  char* target = const_cast<char*>(u8str.data());
15813  return convert_into(L, target, needed_size, strb, stre);
15814  }
15815  };
15816 
15817  template <>
15818  struct unqualified_pusher<char32_t*> {
15819  static int push(lua_State* L, const char32_t* str) {
15821  (void)p;
15822  return p.push(L, str);
15823  }
15824 
15825  static int push(lua_State* L, const char32_t* strb, const char32_t* stre) {
15827  (void)p;
15828  return p.push(L, strb, stre);
15829  }
15830 
15831  static int push(lua_State* L, const char32_t* str, std::size_t len) {
15833  (void)p;
15834  return p.push(L, str, len);
15835  }
15836  };
15837 
15838  template <size_t N>
15839  struct unqualified_pusher<wchar_t[N]> {
15840  static int push(lua_State* L, const wchar_t (&str)[N]) {
15841  return push(L, str, std::char_traits<wchar_t>::length(str));
15842  }
15843 
15844  static int push(lua_State* L, const wchar_t (&str)[N], std::size_t sz) {
15845  const wchar_t* str_ptr = static_cast<const wchar_t*>(str);
15846  return stack::push<const wchar_t*>(L, str_ptr, str_ptr + sz);
15847  }
15848  };
15849 
15850  template <size_t N>
15851  struct unqualified_pusher<char16_t[N]> {
15852  static int push(lua_State* L, const char16_t (&str)[N]) {
15853  return push(L, str, std::char_traits<char16_t>::length(str));
15854  }
15855 
15856  static int push(lua_State* L, const char16_t (&str)[N], std::size_t sz) {
15857  const char16_t* str_ptr = static_cast<const char16_t*>(str);
15858  return stack::push<const char16_t*>(L, str_ptr, str_ptr + sz);
15859  }
15860  };
15861 
15862  template <size_t N>
15863  struct unqualified_pusher<char32_t[N]> {
15864  static int push(lua_State* L, const char32_t (&str)[N]) {
15865  return push(L, str, std::char_traits<char32_t>::length(str));
15866  }
15867 
15868  static int push(lua_State* L, const char32_t (&str)[N], std::size_t sz) {
15869  const char32_t* str_ptr = static_cast<const char32_t*>(str);
15870  return stack::push<const char32_t*>(L, str_ptr, str_ptr + sz);
15871  }
15872  };
15873 
15874  template <>
15875  struct unqualified_pusher<wchar_t> {
15876  static int push(lua_State* L, wchar_t c) {
15877  const wchar_t str[2] = { c, '\0' };
15878  return stack::push(L, static_cast<const wchar_t*>(str), 1u);
15879  }
15880  };
15881 
15882  template <>
15883  struct unqualified_pusher<char16_t> {
15884  static int push(lua_State* L, char16_t c) {
15885  const char16_t str[2] = { c, '\0' };
15886  return stack::push(L, static_cast<const char16_t*>(str), 1u);
15887  }
15888  };
15889 
15890  template <>
15891  struct unqualified_pusher<char32_t> {
15892  static int push(lua_State* L, char32_t c) {
15893  const char32_t str[2] = { c, '\0' };
15894  return stack::push(L, static_cast<const char32_t*>(str), 1u);
15895  }
15896  };
15897 
15898  template <typename... Args>
15899  struct unqualified_pusher<std::tuple<Args...>> {
15900  template <std::size_t... I, typename T>
15901  static int push(std::index_sequence<I...>, lua_State* L, T&& t) {
15902 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
15903  luaL_checkstack(L, static_cast<int>(sizeof...(I)), detail::not_enough_stack_space_generic);
15904 #endif // make sure stack doesn't overflow
15905  int pushcount = 0;
15906  (void)detail::swallow { 0, (pushcount += stack::push(L, std::get<I>(std::forward<T>(t))), 0)... };
15907  return pushcount;
15908  }
15909 
15910  template <typename T>
15911  static int push(lua_State* L, T&& t) {
15912  return push(std::index_sequence_for<Args...>(), L, std::forward<T>(t));
15913  }
15914  };
15915 
15916  template <typename A, typename B>
15917  struct unqualified_pusher<std::pair<A, B>> {
15918  template <typename T>
15919  static int push(lua_State* L, T&& t) {
15920  int pushcount = stack::push(L, std::get<0>(std::forward<T>(t)));
15921  pushcount += stack::push(L, std::get<1>(std::forward<T>(t)));
15922  return pushcount;
15923  }
15924  };
15925 
15926  template <typename T>
15927  struct unqualified_pusher<T, std::enable_if_t<meta::is_optional_v<T>>> {
15929 
15930  template <typename Optional>
15931  static int push(lua_State* L, Optional&& op) {
15933  if (!op) {
15934  return stack::push(L, nullopt);
15935  }
15936  return stack::push(L, static_cast<QualifiedValueType>(op.value()));
15937  }
15938  };
15939 
15940  template <typename T>
15942  static int push(lua_State* L, const forward_as_value_t<T>& value_) {
15943  return stack::push<T>(L, value_.value());
15944  }
15945 
15946  static int push(lua_State* L, forward_as_value_t<T>&& value_) {
15947  return stack::push<T>(L, std::move(value_).value());
15948  }
15949  };
15950 
15951  template <>
15953  static int push(lua_State* L, nullopt_t) noexcept {
15954  return stack::push(L, lua_nil);
15955  }
15956  };
15957 
15958  template <>
15959  struct unqualified_pusher<std::nullptr_t> {
15960  static int push(lua_State* L, std::nullptr_t) noexcept {
15961  return stack::push(L, lua_nil);
15962  }
15963  };
15964 
15965  template <>
15967  static int push(lua_State*, const this_state&) noexcept {
15968  return 0;
15969  }
15970  };
15971 
15972  template <>
15974  static int push(lua_State*, const this_main_state&) noexcept {
15975  return 0;
15976  }
15977  };
15978 
15979  template <>
15981  static int push(lua_State* L, const new_table& nt) {
15983  return 1;
15984  }
15985  };
15986 
15987  template <typename Allocator>
15988  struct unqualified_pusher<basic_bytecode<Allocator>> {
15989  template <typename T>
15990  static int push(lua_State* L, T&& bc, const char* bytecode_name) {
15991  const auto first = bc.data();
15992  const auto bcsize = bc.size();
15993  // pushes either the function, or an error
15994  // if it errors, shit goes south, and people can test that upstream
15996  L, reinterpret_cast<const char*>(first), static_cast<std::size_t>(bcsize * (sizeof(*first) / sizeof(const char))), bytecode_name);
15997  return 1;
15998  }
15999 
16000  template <typename T>
16001  static int push(lua_State* L, T&& bc) {
16002  return push(L, std::forward<bc>(bc), "bytecode");
16003  }
16004  };
16005 
16006 #if SOL_IS_ON(SOL_STD_VARIANT)
16007  namespace stack_detail {
16008 
16009  struct push_function {
16011 
16012  push_function(lua_State* L_) noexcept : L(L_) {
16013  }
16014 
16015  template <typename T>
16016  int operator()(T&& value) const {
16017  return stack::push<T>(L, std::forward<T>(value));
16018  }
16019  };
16020 
16021  } // namespace stack_detail
16022 
16023  template <typename... Tn>
16024  struct unqualified_pusher<std::variant<Tn...>> {
16025  static int push(lua_State* L, const std::variant<Tn...>& v) {
16026  return std::visit(stack_detail::push_function(L), v);
16027  }
16028 
16029  static int push(lua_State* L, std::variant<Tn...>&& v) {
16030  return std::visit(stack_detail::push_function(L), std::move(v));
16031  }
16032  };
16033 #endif // Variant because Clang is terrible
16034 
16035 }} // namespace sol::stack
16036 
16037 // end of sol/stack_push.hpp
16038 
16039 // beginning of sol/stack_pop.hpp
16040 
16041 #include <utility>
16042 #include <tuple>
16043 
16044 namespace sol { namespace stack {
16045  template <typename T, typename>
16046  struct popper {
16047  inline static decltype(auto) pop(lua_State* L) {
16048  if constexpr (is_stack_based_v<meta::unqualified_t<T>>) {
16049  static_assert(!is_stack_based_v<meta::unqualified_t<T>>,
16050  "You cannot pop something that lives solely on the stack: it will not remain on the stack when popped and thusly will go out of "
16051  "scope!");
16052  }
16053  else {
16054  record tracking {};
16055  decltype(auto) r = get<T>(L, -lua_size<T>::value, tracking);
16056  lua_pop(L, tracking.used);
16057  return r;
16058  }
16059  }
16060  };
16061 }} // namespace sol::stack
16062 
16063 // end of sol/stack_pop.hpp
16064 
16065 // beginning of sol/stack_field.hpp
16066 
16067 namespace sol { namespace stack {
16068 
16069  namespace stack_detail {
16070  template <typename T, bool global, bool raw>
16071  inline constexpr bool is_get_direct_tableless_v = (global && !raw && meta::is_c_str_or_string_v<T>);
16072 
16073  template <typename T, bool global, bool raw>
16074  inline constexpr bool is_get_direct_v = (is_get_direct_tableless_v<T, global, raw>) // cf-hack
16075  || (!global && !raw && (meta::is_c_str_or_string_v<T> || meta::is_string_of_v<T, char>)) // cf-hack
16076  || (!global && raw && (std::is_integral_v<T> && !std::is_same_v<T, bool>))
16077 #if SOL_LUA_VERSION_I_ >= 503
16078  || (!global && !raw && (std::is_integral_v<T> && !std::is_same_v<T, bool>))
16079 #endif // integer keys 5.3 or better
16080 #if SOL_LUA_VERSION_I_ >= 502
16081  || (!global && raw && std::is_pointer_v<T> && std::is_void_v<std::remove_pointer_t<T>>)
16082 #endif // void pointer keys 5.2 or better
16083  ;
16084 
16085  template <typename T, bool global, bool raw>
16086  inline constexpr bool is_set_direct_tableless_v = (global && !raw && meta::is_c_str_or_string_v<T>);
16087 
16088  template <typename T, bool global, bool raw>
16089  inline constexpr bool is_set_direct_v = (is_set_direct_tableless_v<T, global, raw>) // cf-hack
16090  || (!global && !raw && (meta::is_c_str_or_string_v<T> || meta::is_string_of_v<T, char>)) // cf-hack
16091  || (!global && raw && (std::is_integral_v<T> && !std::is_same_v<T, bool>)) // cf-hack
16092 #if SOL_LUA_VERSION_I_ >= 503
16093  || (!global && !raw && (std::is_integral_v<T> && !std::is_same_v<T, bool>))
16094 #endif // integer keys 5.3 or better
16095 #if SOL_LUA_VERSION_I_ >= 502
16096  || (!global && raw && (std::is_pointer_v<T> && std::is_void_v<std::remove_pointer_t<T>>))
16097 #endif // void pointer keys 5.2 or better
16098  ;
16099  } // namespace stack_detail
16100 
16101  template <typename T, bool global, bool raw, typename>
16102  struct field_getter {
16103  static inline constexpr int default_table_index
16104  = meta::conditional_t<stack_detail::is_get_direct_v<T, global, raw>, std::integral_constant<int, -1>, std::integral_constant<int, -2>>::value;
16105 
16106  template <typename Key>
16107  void get(lua_State* L, Key&& key, int tableindex = default_table_index) {
16108  if constexpr (std::is_same_v<T, update_if_empty_t> || std::is_same_v<T, override_value_t> || std::is_same_v<T, create_if_nil_t>) {
16109  (void)L;
16110  (void)key;
16111  (void)tableindex;
16112  }
16113  else if constexpr (std::is_same_v<T, env_key_t>) {
16114  (void)key;
16115 #if SOL_LUA_VERSION_I_ < 502
16116  // Use lua_setfenv
16117  lua_getfenv(L, tableindex);
16118 #else
16119  // Use upvalues as explained in Lua 5.2 and beyond's manual
16120  if (lua_getupvalue(L, tableindex, 1) == nullptr) {
16121  push(L, lua_nil);
16122  }
16123 #endif
16124  }
16125  else if constexpr (std::is_same_v<T, metatable_key_t>) {
16126  (void)key;
16127  if (lua_getmetatable(L, tableindex) == 0)
16128  push(L, lua_nil);
16129  }
16130  else if constexpr (raw) {
16131  if constexpr (std::is_integral_v<T> && !std::is_same_v<bool, T>) {
16132  lua_rawgeti(L, tableindex, static_cast<lua_Integer>(key));
16133  }
16134 #if SOL_LUA_VERSION_I_ >= 502
16135  else if constexpr (std::is_pointer_v<T> && std::is_void_v<std::remove_pointer_t<T>>) {
16136  lua_rawgetp(L, tableindex, key);
16137  }
16138 #endif // Lua 5.2.x+
16139  else {
16140  push(L, std::forward<Key>(key));
16141  lua_rawget(L, tableindex);
16142  }
16143  }
16144  else {
16145  if constexpr (meta::is_c_str_or_string_v<T>) {
16146  if constexpr (global) {
16147  (void)tableindex;
16148  lua_getglobal(L, &key[0]);
16149  }
16150  else {
16151  lua_getfield(L, tableindex, &key[0]);
16152  }
16153  }
16154  else if constexpr (std::is_same_v<T, meta_function>) {
16155  const auto& real_key = to_string(key);
16156  lua_getfield(L, tableindex, &real_key[0]);
16157  }
16158 #if SOL_LUA_VERSION_I_ >= 503
16159  else if constexpr (std::is_integral_v<T> && !std::is_same_v<bool, T>) {
16160  lua_geti(L, tableindex, static_cast<lua_Integer>(key));
16161  }
16162 #endif // Lua 5.3.x+
16163  else {
16164  push(L, std::forward<Key>(key));
16165  lua_gettable(L, tableindex);
16166  }
16167  }
16168  }
16169  };
16170 
16171  template <typename... Args, bool b, bool raw, typename C>
16172  struct field_getter<std::tuple<Args...>, b, raw, C> {
16173  template <std::size_t... I, typename Keys>
16174  void apply(std::index_sequence<0, I...>, lua_State* L, Keys&& keys, int tableindex) {
16175  get_field<b, raw>(L, std::get<0>(std::forward<Keys>(keys)), tableindex);
16176  void(detail::swallow { (get_field<false, raw>(L, std::get<I>(std::forward<Keys>(keys))), 0)... });
16177  reference saved(L, -1);
16178  lua_pop(L, static_cast<int>(sizeof...(I)));
16179  saved.push();
16180  }
16181 
16182  template <typename Keys>
16183  void get(lua_State* L, Keys&& keys) {
16184  apply(std::make_index_sequence<sizeof...(Args)>(), L, std::forward<Keys>(keys), lua_absindex(L, -1));
16185  }
16186 
16187  template <typename Keys>
16188  void get(lua_State* L, Keys&& keys, int tableindex) {
16189  apply(std::make_index_sequence<sizeof...(Args)>(), L, std::forward<Keys>(keys), tableindex);
16190  }
16191  };
16192 
16193  template <typename A, typename B, bool b, bool raw, typename C>
16194  struct field_getter<std::pair<A, B>, b, raw, C> {
16195  template <typename Keys>
16196  void get(lua_State* L, Keys&& keys, int tableindex) {
16197  get_field<b, raw>(L, std::get<0>(std::forward<Keys>(keys)), tableindex);
16198  get_field<false, raw>(L, std::get<1>(std::forward<Keys>(keys)));
16199  reference saved(L, -1);
16200  lua_pop(L, static_cast<int>(2));
16201  saved.push();
16202  }
16203 
16204  template <typename Keys>
16205  void get(lua_State* L, Keys&& keys) {
16206  get_field<b, raw>(L, std::get<0>(std::forward<Keys>(keys)));
16207  get_field<false, raw>(L, std::get<1>(std::forward<Keys>(keys)));
16208  reference saved(L, -1);
16209  lua_pop(L, static_cast<int>(2));
16210  saved.push();
16211  }
16212  };
16213 
16214  template <typename T, bool global, bool raw, typename>
16215  struct field_setter {
16216  static constexpr int default_table_index
16217  = meta::conditional_t<stack_detail::is_set_direct_v<T, global, raw>, std::integral_constant<int, -2>, std::integral_constant<int, -3>>::value;
16218 
16219  template <typename Key, typename Value>
16220  void set(lua_State* L, Key&& key, Value&& value, int tableindex = default_table_index) {
16221  if constexpr (std::is_same_v<T, update_if_empty_t> || std::is_same_v<T, override_value_t>) {
16222  (void)L;
16223  (void)key;
16224  (void)value;
16225  (void)tableindex;
16226  }
16227  else if constexpr (std::is_same_v<T, metatable_key_t>) {
16228  (void)key;
16229  push(L, std::forward<Value>(value));
16230  lua_setmetatable(L, tableindex);
16231  }
16232  else if constexpr (raw) {
16233  if constexpr (std::is_integral_v<T> && !std::is_same_v<bool, T>) {
16234  push(L, std::forward<Value>(value));
16235  lua_rawseti(L, tableindex, static_cast<lua_Integer>(key));
16236  }
16237 #if SOL_LUA_VERSION_I_ >= 502
16238  else if constexpr (std::is_pointer_v<T> && std::is_void_v<std::remove_pointer_t<T>>) {
16239  push(L, std::forward<Value>(value));
16240  lua_rawsetp(L, tableindex, std::forward<Key>(key));
16241  }
16242 #endif // Lua 5.2.x
16243  else {
16244  push(L, std::forward<Key>(key));
16245  push(L, std::forward<Value>(value));
16246  lua_rawset(L, tableindex);
16247  }
16248  }
16249  else {
16250  if constexpr (meta::is_c_str_or_string_v<T>) {
16251  if constexpr (global) {
16252  push(L, std::forward<Value>(value));
16253  lua_setglobal(L, &key[0]);
16254  (void)tableindex;
16255  }
16256  else {
16257  push(L, std::forward<Value>(value));
16258  lua_setfield(L, tableindex, &key[0]);
16259  }
16260  }
16261 #if SOL_LUA_VERSION_I_ >= 503
16262  else if constexpr (std::is_integral_v<T> && !std::is_same_v<bool, T>) {
16263  push(L, std::forward<Value>(value));
16264  lua_seti(L, tableindex, static_cast<lua_Integer>(key));
16265  }
16266 #endif // Lua 5.3.x
16267  else {
16268  push(L, std::forward<Key>(key));
16269  push(L, std::forward<Value>(value));
16270  lua_settable(L, tableindex);
16271  }
16272  }
16273  }
16274  };
16275 
16276  template <typename... Args, bool b, bool raw, typename C>
16277  struct field_setter<std::tuple<Args...>, b, raw, C> {
16278  template <bool g, std::size_t I, typename Keys, typename Value>
16279  void apply(std::index_sequence<I>, lua_State* L, Keys&& keys, Value&& value, int tableindex) {
16280  I < 1 ? set_field<g, raw>(L, std::get<I>(std::forward<Keys>(keys)), std::forward<Value>(value), tableindex)
16281  : set_field<g, raw>(L, std::get<I>(std::forward<Keys>(keys)), std::forward<Value>(value));
16282  }
16283 
16284  template <bool g, std::size_t I0, std::size_t I1, std::size_t... I, typename Keys, typename Value>
16285  void apply(std::index_sequence<I0, I1, I...>, lua_State* L, Keys&& keys, Value&& value, int tableindex) {
16286  I0 < 1 ? get_field<g, raw>(L, std::get<I0>(std::forward<Keys>(keys)), tableindex)
16287  : get_field<g, raw>(L, std::get<I0>(std::forward<Keys>(keys)), -1);
16288  apply<false>(std::index_sequence<I1, I...>(), L, std::forward<Keys>(keys), std::forward<Value>(value), -1);
16289  }
16290 
16291  template <bool g, std::size_t I0, std::size_t... I, typename Keys, typename Value>
16292  void top_apply(std::index_sequence<I0, I...>, lua_State* L, Keys&& keys, Value&& value, int tableindex) {
16293  apply<g>(std::index_sequence<I0, I...>(), L, std::forward<Keys>(keys), std::forward<Value>(value), tableindex);
16294  lua_pop(L, static_cast<int>(sizeof...(I)));
16295  }
16296 
16297  template <typename Keys, typename Value>
16298  void set(lua_State* L, Keys&& keys, Value&& value, int tableindex = -3) {
16299  top_apply<b>(std::make_index_sequence<sizeof...(Args)>(), L, std::forward<Keys>(keys), std::forward<Value>(value), tableindex);
16300  }
16301  };
16302 
16303  template <typename A, typename B, bool b, bool raw, typename C>
16304  struct field_setter<std::pair<A, B>, b, raw, C> {
16305  template <typename Keys, typename Value>
16306  void set(lua_State* L, Keys&& keys, Value&& value, int tableindex = -1) {
16307  get_field<b, raw>(L, std::get<0>(std::forward<Keys>(keys)), tableindex);
16308  set_field<false, raw>(L, std::get<1>(std::forward<Keys>(keys)), std::forward<Value>(value), lua_gettop(L));
16309  lua_pop(L, 1);
16310  }
16311  };
16312 }} // namespace sol::stack
16313 
16314 // end of sol/stack_field.hpp
16315 
16316 // beginning of sol/stack_probe.hpp
16317 
16318 namespace sol { namespace stack {
16319  template <typename T, typename P, bool b, bool raw, typename>
16320  struct probe_field_getter {
16321  template <typename Key>
16322  probe get(lua_State* L, Key&& key, int tableindex = -2) {
16323  if constexpr (!b) {
16324  if (!maybe_indexable(L, tableindex)) {
16325  return probe(false, 0);
16326  }
16327  }
16328  get_field<b, raw>(L, std::forward<Key>(key), tableindex);
16329  return probe(check<P>(L), 1);
16330  }
16331  };
16332 
16333  template <typename A, typename B, typename P, bool b, bool raw, typename C>
16334  struct probe_field_getter<std::pair<A, B>, P, b, raw, C> {
16335  template <typename Keys>
16336  probe get(lua_State* L, Keys&& keys, int tableindex = -2) {
16337  if (!b && !maybe_indexable(L, tableindex)) {
16338  return probe(false, 0);
16339  }
16340  get_field<b, raw>(L, std::get<0>(keys), tableindex);
16341  if (!maybe_indexable(L)) {
16342  return probe(false, 1);
16343  }
16344  get_field<false, raw>(L, std::get<1>(keys), tableindex);
16345  return probe(check<P>(L), 2);
16346  }
16347  };
16348 
16349  template <typename... Args, typename P, bool b, bool raw, typename C>
16350  struct probe_field_getter<std::tuple<Args...>, P, b, raw, C> {
16351  template <std::size_t I, typename Keys>
16352  probe apply(std::index_sequence<I>, int sofar, lua_State* L, Keys&& keys, int tableindex) {
16353  get_field<(I < 1) && b, raw>(L, std::get<I>(keys), tableindex);
16354  return probe(check<P>(L), sofar);
16355  }
16356 
16357  template <std::size_t I, std::size_t I1, std::size_t... In, typename Keys>
16358  probe apply(std::index_sequence<I, I1, In...>, int sofar, lua_State* L, Keys&& keys, int tableindex) {
16359  get_field < I<1 && b, raw>(L, std::get<I>(keys), tableindex);
16360  if (!maybe_indexable(L)) {
16361  return probe(false, sofar);
16362  }
16363  return apply(std::index_sequence<I1, In...>(), sofar + 1, L, std::forward<Keys>(keys), -1);
16364  }
16365 
16366  template <typename Keys>
16367  probe get(lua_State* L, Keys&& keys, int tableindex = -2) {
16368  if constexpr (!b) {
16369  if (!maybe_indexable(L, tableindex)) {
16370  return probe(false, 0);
16371  }
16372  return apply(std::index_sequence_for<Args...>(), 1, L, std::forward<Keys>(keys), tableindex);
16373  }
16374  else {
16375  return apply(std::index_sequence_for<Args...>(), 1, L, std::forward<Keys>(keys), tableindex);
16376  }
16377  }
16378  };
16379 }} // namespace sol::stack
16380 
16381 // end of sol/stack_probe.hpp
16382 
16383 #include <cstring>
16384 #include <array>
16385 
16386 namespace sol {
16387  namespace detail {
16390 
16391  inline const std::string& default_chunk_name() {
16392  static const std::string name = "";
16393  return name;
16394  }
16395 
16396  template <std::size_t N>
16397  const char* make_chunk_name(const string_view& code, const std::string& chunkname, char (&basechunkname)[N]) {
16398  if (chunkname.empty()) {
16399  auto it = code.cbegin();
16400  auto e = code.cend();
16401  std::size_t i = 0;
16402  static const std::size_t n = N - 4;
16403  for (i = 0; i < n && it != e; ++i, ++it) {
16404  basechunkname[i] = *it;
16405  }
16406  if (it != e) {
16407  for (std::size_t c = 0; c < 3; ++i, ++c) {
16408  basechunkname[i] = '.';
16409  }
16410  }
16411  basechunkname[i] = '\0';
16412  return &basechunkname[0];
16413  }
16414  else {
16415  return chunkname.c_str();
16416  }
16417  }
16418 
16421  while (lua_next(r.lua_state(), -2)) {
16422  absolute_index key(r.lua_state(), -2);
16423  auto pn = stack::pop_n(r.lua_state(), 1);
16424  stack::set_field<false, true>(r.lua_state(), key, lua_nil, r.stack_index());
16425  }
16426  }
16427 
16428  inline void clear_entries(const reference& registry_reference) {
16429  auto pp = stack::push_pop(registry_reference);
16430  stack_reference ref(registry_reference.lua_state(), -1);
16431  clear_entries(ref);
16432  }
16433  } // namespace detail
16434 
16435  namespace stack {
16436  namespace stack_detail {
16437  template <typename T>
16438  inline int push_as_upvalues(lua_State* L, T& item) {
16439  typedef std::decay_t<T> TValue;
16440  static const std::size_t itemsize = sizeof(TValue);
16441  static const std::size_t voidsize = sizeof(void*);
16442  static const std::size_t voidsizem1 = voidsize - 1;
16443  static const std::size_t data_t_count = (sizeof(TValue) + voidsizem1) / voidsize;
16444  typedef std::array<void*, data_t_count> data_t;
16445 
16446  data_t data { {} };
16447  std::memcpy(&data[0], std::addressof(item), itemsize);
16448  int pushcount = 0;
16449  for (const auto& v : data) {
16450  lua_pushlightuserdata(L, v);
16451  pushcount += 1;
16452  }
16453  return pushcount;
16454  }
16455 
16456  template <typename T>
16457  inline std::pair<T, int> get_as_upvalues(lua_State* L, int index = 2) {
16458  static const std::size_t data_t_count = (sizeof(T) + (sizeof(void*) - 1)) / sizeof(void*);
16459  typedef std::array<void*, data_t_count> data_t;
16460  data_t voiddata { {} };
16461  for (std::size_t i = 0, d = 0; d < sizeof(T); ++i, d += sizeof(void*)) {
16462  voiddata[i] = lua_touserdata(L, upvalue_index(index++));
16463  }
16464  return std::pair<T, int>(*reinterpret_cast<T*>(static_cast<void*>(voiddata.data())), index);
16465  }
16466 
16467  template <typename T>
16468  inline std::pair<T, int> get_as_upvalues_using_function(lua_State* L, int function_index = -1) {
16469  static const std::size_t data_t_count = (sizeof(T) + (sizeof(void*) - 1)) / sizeof(void*);
16470  typedef std::array<void*, data_t_count> data_t;
16471  function_index = lua_absindex(L, function_index);
16472  int index = 0;
16473  data_t voiddata { {} };
16474  for (std::size_t d = 0; d < sizeof(T); d += sizeof(void*)) {
16475  // first upvalue is nullptr to respect environment shenanigans
16476  // So +2 instead of +1
16477  const char* upvalue_name = lua_getupvalue(L, function_index, index + 2);
16478  if (upvalue_name == nullptr) {
16479  // We should freak out here...
16480  break;
16481  }
16482  voiddata[index] = lua_touserdata(L, -1);
16483  ++index;
16484  }
16485  lua_pop(L, index);
16486  return std::pair<T, int>(*reinterpret_cast<T*>(static_cast<void*>(voiddata.data())), index);
16487  }
16488 
16489  template <bool checked, typename Handler, typename Fx, typename... Args>
16490  static decltype(auto) eval(types<>, std::index_sequence<>, lua_State*, int, Handler&&, record&, Fx&& fx, Args&&... args) {
16491  return std::forward<Fx>(fx)(std::forward<Args>(args)...);
16492  }
16493 
16494  template <bool checked, typename Arg, typename... Args, std::size_t I, std::size_t... Is, typename Handler, typename Fx, typename... FxArgs>
16495  static decltype(auto) eval(types<Arg, Args...>, std::index_sequence<I, Is...>, lua_State* L_, int start_index_, Handler&& handler_,
16496  record& tracking_, Fx&& fx_, FxArgs&&... fxargs_) {
16497 #if SOL_IS_ON(SOL_PROPAGATE_EXCEPTIONS)
16498  // We can save performance/time by letting errors unwind produced arguments
16499  // rather than checking everything once, and then potentially re-doing work
16500  if constexpr (checked) {
16501  return eval<checked>(types<Args...>(),
16502  std::index_sequence<Is...>(),
16503  L_,
16504  start_index_,
16505  std::forward<Handler>(handler_),
16506  tracking_,
16507  std::forward<Fx>(fx_),
16508  std::forward<FxArgs>(fxargs_)...,
16509  *stack_detail::check_get_arg<Arg>(L_, start_index_ + tracking_.used, handler_, tracking_));
16510  }
16511  else
16512 #endif
16513  {
16514  return eval<checked>(types<Args...>(),
16515  std::index_sequence<Is...>(),
16516  L_,
16517  start_index_,
16518  std::forward<Handler>(handler_),
16519  tracking_,
16520  std::forward<Fx>(fx_),
16521  std::forward<FxArgs>(fxargs_)...,
16522  stack_detail::unchecked_get_arg<Arg>(L_, start_index_ + tracking_.used, tracking_));
16523  }
16524  }
16525 
16526  template <bool checkargs = detail::default_safe_function_calls, std::size_t... I, typename R, typename... Args, typename Fx, typename... FxArgs>
16527  inline decltype(auto) call(types<R>, types<Args...> argument_types_, std::index_sequence<I...> argument_indices_, lua_State* L_,
16528  int start_index_, Fx&& fx_, FxArgs&&... args_) {
16529  static_assert(meta::all_v<meta::is_not_move_only<Args>...>,
16530  "One of the arguments being bound is a move-only type, and it is not being taken by reference: this will break your code. Please take "
16531  "a reference and std::move it manually if this was your intention.");
16532  argument_handler<types<R, Args...>> handler {};
16533  record tracking {};
16534 #if SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS)
16535  if constexpr (checkargs) {
16536  multi_check<Args...>(L_, start_index_, handler);
16537  }
16538 #endif
16539  if constexpr (std::is_void_v<R>) {
16540  eval<checkargs>(
16541  argument_types_, argument_indices_, L_, start_index_, handler, tracking, std::forward<Fx>(fx_), std::forward<FxArgs>(args_)...);
16542  }
16543  else {
16544  return eval<checkargs>(
16545  argument_types_, argument_indices_, L_, start_index_, handler, tracking, std::forward<Fx>(fx_), std::forward<FxArgs>(args_)...);
16546  }
16547  }
16548 
16549  template <typename T>
16550  void raw_table_set(lua_State* L, T&& arg, int tableindex = -2) {
16551  int push_count = push(L, std::forward<T>(arg));
16552  sol_c_assert(push_count == 1);
16553  std::size_t unique_index = static_cast<std::size_t>(luaL_len(L, tableindex) + 1u);
16554  lua_rawseti(L, tableindex, unique_index);
16555  }
16556 
16557  } // namespace stack_detail
16558 
16559  template <typename T>
16560  int set_ref(lua_State* L, T&& arg, int tableindex = -2) {
16561  int push_count = push(L, std::forward<T>(arg));
16562  sol_c_assert(push_count == 1);
16563  return luaL_ref(L, tableindex);
16564  }
16565 
16566  template <bool check_args = detail::default_safe_function_calls, typename R, typename... Args, typename Fx, typename... FxArgs>
16567  inline decltype(auto) call(types<R> tr, types<Args...> ta, lua_State* L, int start, Fx&& fx, FxArgs&&... args) {
16568  using args_indices = std::make_index_sequence<sizeof...(Args)>;
16569  if constexpr (std::is_void_v<R>) {
16570  stack_detail::call<check_args>(tr, ta, args_indices(), L, start, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
16571  }
16572  else {
16573  return stack_detail::call<check_args>(tr, ta, args_indices(), L, start, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
16574  }
16575  }
16576 
16577  template <bool check_args = detail::default_safe_function_calls, typename R, typename... Args, typename Fx, typename... FxArgs>
16578  inline decltype(auto) call(types<R> tr, types<Args...> ta, lua_State* L, Fx&& fx, FxArgs&&... args) {
16579  if constexpr (std::is_void_v<R>) {
16580  call<check_args>(tr, ta, L, 1, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
16581  }
16582  else {
16583  return call<check_args>(tr, ta, L, 1, std::forward<Fx>(fx), std::forward<FxArgs>(args)...);
16584  }
16585  }
16586 
16587  template <bool check_args = detail::default_safe_function_calls, typename R, typename... Args, typename Fx, typename... FxArgs>
16588  inline decltype(auto) call_from_top(types<R> tr, types<Args...> ta, lua_State* L, Fx&& fx, FxArgs&&... args) {
16589  using expected_count_t = meta::count_for_pack<lua_size, Args...>;
16590  if constexpr (std::is_void_v<R>) {
16591  call<check_args>(tr,
16592  ta,
16593  L,
16594  (std::max)(static_cast<int>(lua_gettop(L) - expected_count_t::value), static_cast<int>(0)),
16595  std::forward<Fx>(fx),
16596  std::forward<FxArgs>(args)...);
16597  }
16598  else {
16599  return call<check_args>(tr,
16600  ta,
16601  L,
16602  (std::max)(static_cast<int>(lua_gettop(L) - expected_count_t::value), static_cast<int>(0)),
16603  std::forward<Fx>(fx),
16604  std::forward<FxArgs>(args)...);
16605  }
16606  }
16607 
16608  template <bool check_args = detail::default_safe_function_calls, bool clean_stack = true, typename Ret0, typename... Ret, typename... Args,
16609  typename Fx, typename... FxArgs>
16610  inline int call_into_lua(types<Ret0, Ret...> tr, types<Args...> ta, lua_State* L, int start, Fx&& fx, FxArgs&&... fxargs) {
16611  if constexpr (std::is_void_v<Ret0>) {
16612  call<check_args>(tr, ta, L, start, std::forward<Fx>(fx), std::forward<FxArgs>(fxargs)...);
16613  if constexpr (clean_stack) {
16614  lua_settop(L, 0);
16615  }
16616  return 0;
16617  }
16618  else {
16619  (void)tr;
16620  decltype(auto) r
16621  = call<check_args>(types<meta::return_type_t<Ret0, Ret...>>(), ta, L, start, std::forward<Fx>(fx), std::forward<FxArgs>(fxargs)...);
16622  using R = meta::unqualified_t<decltype(r)>;
16623  using is_stack = meta::any<is_stack_based<R>, std::is_same<R, absolute_index>, std::is_same<R, ref_index>, std::is_same<R, raw_index>>;
16624  if constexpr (clean_stack && !is_stack::value) {
16625  lua_settop(L, 0);
16626  }
16627  return push_reference(L, std::forward<decltype(r)>(r));
16628  }
16629  }
16630 
16631  template <bool check_args = detail::default_safe_function_calls, bool clean_stack = true, typename Fx, typename... FxArgs>
16632  inline int call_lua(lua_State* L, int start, Fx&& fx, FxArgs&&... fxargs) {
16633  using traits_type = lua_bind_traits<meta::unqualified_t<Fx>>;
16634  using args_list = typename traits_type::args_list;
16635  using returns_list = typename traits_type::returns_list;
16636  return call_into_lua<check_args, clean_stack>(returns_list(), args_list(), L, start, std::forward<Fx>(fx), std::forward<FxArgs>(fxargs)...);
16637  }
16638 
16639  inline call_syntax get_call_syntax(lua_State* L, const string_view& key, int index) {
16640  if (lua_gettop(L) < 1) {
16641  return call_syntax::dot;
16642  }
16643  luaL_getmetatable(L, key.data());
16644  auto pn = pop_n(L, 1);
16645  if (lua_compare(L, -1, index, LUA_OPEQ) != 1) {
16646  return call_syntax::dot;
16647  }
16648  return call_syntax::colon;
16649  }
16650 
16651  inline void script(
16652  lua_State* L, lua_Reader reader, void* data, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
16653  detail::typical_chunk_name_t basechunkname = {};
16654  const char* chunknametarget = detail::make_chunk_name("lua_Reader", chunkname, basechunkname);
16655  if (lua_load(L, reader, data, chunknametarget, to_string(mode).c_str()) || lua_pcall(L, 0, LUA_MULTRET, 0)) {
16656  lua_error(L);
16657  }
16658  }
16659 
16660  inline void script(
16661  lua_State* L, const string_view& code, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
16662 
16663  detail::typical_chunk_name_t basechunkname = {};
16664  const char* chunknametarget = detail::make_chunk_name(code, chunkname, basechunkname);
16665  if (luaL_loadbufferx(L, code.data(), code.size(), chunknametarget, to_string(mode).c_str()) || lua_pcall(L, 0, LUA_MULTRET, 0)) {
16666  lua_error(L);
16667  }
16668  }
16669 
16670  inline void script_file(lua_State* L, const std::string& filename, load_mode mode = load_mode::any) {
16671  if (luaL_loadfilex(L, filename.c_str(), to_string(mode).c_str()) || lua_pcall(L, 0, LUA_MULTRET, 0)) {
16672  lua_error(L);
16673  }
16674  }
16675 
16677 #if SOL_IS_ON(SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE)
16678  if (L == nullptr) {
16679  return;
16680  }
16681 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
16683 #endif // make sure stack doesn't overflow
16684  lua_pushlightuserdata(L, (void*)handler);
16685  auto pn = pop_n(L, 1);
16686  luaJIT_setmode(L, -1, LUAJIT_MODE_WRAPCFUNC | LUAJIT_MODE_ON);
16687 #else
16688  (void)L;
16689  (void)handler;
16690 #endif
16691  }
16692 
16694 #if SOL_IS_ON(SOL_USE_LUAJIT_EXCEPTION_TRAMPOLINE)
16695  if (L == nullptr) {
16696  return;
16697  }
16698  luaJIT_setmode(L, -1, LUAJIT_MODE_WRAPCFUNC | LUAJIT_MODE_OFF);
16699 #else
16700  (void)L;
16701 #endif
16702  }
16703  } // namespace stack
16704 } // namespace sol
16705 
16706 // end of sol/stack.hpp
16707 
16708 // beginning of sol/object.hpp
16709 
16710 // beginning of sol/make_reference.hpp
16711 
16712 namespace sol {
16713 
16714  template <typename R = reference, bool should_pop = !is_stack_based_v<R>, typename T>
16715  R make_reference(lua_State* L, T&& value) {
16716  int backpedal = stack::push(L, std::forward<T>(value));
16717  R r = stack::get<R>(L, -backpedal);
16718  if (should_pop) {
16719  lua_pop(L, backpedal);
16720  }
16721  return r;
16722  }
16723 
16724  template <typename T, typename R = reference, bool should_pop = !is_stack_based_v<R>, typename... Args>
16725  R make_reference(lua_State* L, Args&&... args) {
16726  int backpedal = stack::push<T>(L, std::forward<Args>(args)...);
16727  R r = stack::get<R>(L, -backpedal);
16728  if (should_pop) {
16729  lua_pop(L, backpedal);
16730  }
16731  return r;
16732  }
16733 
16734  template <typename R = reference, bool should_pop = !is_stack_based_v<R>, typename T>
16736  int backpedal = stack::push_userdata(L, std::forward<T>(value));
16737  R r = stack::get<R>(L, -backpedal);
16738  if (should_pop) {
16739  lua_pop(L, backpedal);
16740  }
16741  return r;
16742  }
16743 
16744  template <typename T, typename R = reference, bool should_pop = !is_stack_based_v<R>, typename... Args>
16746  int backpedal = stack::push_userdata<T>(L, std::forward<Args>(args)...);
16747  R r = stack::get<R>(L, -backpedal);
16748  if (should_pop) {
16749  lua_pop(L, backpedal);
16750  }
16751  return r;
16752  }
16753 
16754 } // namespace sol
16755 
16756 // end of sol/make_reference.hpp
16757 
16758 // beginning of sol/object_base.hpp
16759 
16760 namespace sol {
16761 
16762  template <typename ref_t>
16763  class basic_object_base : public ref_t {
16764  private:
16765  using base_t = ref_t;
16766 
16767  template <typename T>
16768  decltype(auto) as_stack(std::true_type) const {
16769  return stack::get<T>(base_t::lua_state(), base_t::stack_index());
16770  }
16771 
16772  template <typename T>
16773  decltype(auto) as_stack(std::false_type) const {
16774  base_t::push();
16775  return stack::pop<T>(base_t::lua_state());
16776  }
16777 
16778  template <typename T>
16779  bool is_stack(std::true_type) const {
16780  return stack::check<T>(base_t::lua_state(), base_t::stack_index(), &no_panic);
16781  }
16782 
16783  template <typename T>
16785  int r = base_t::registry_index();
16786  if (r == LUA_REFNIL)
16787  return meta::any_same<meta::unqualified_t<T>, lua_nil_t, nullopt_t, std::nullptr_t>::value ? true : false;
16788  if (r == LUA_NOREF)
16789  return false;
16790  auto pp = stack::push_pop(*this);
16791  return stack::check<T>(base_t::lua_state(), -1, &no_panic);
16792  }
16793 
16794  public:
16795  basic_object_base() noexcept = default;
16798  basic_object_base& operator=(const basic_object_base&) = default;
16800  template <typename T, typename... Args, meta::enable<meta::neg<std::is_same<meta::unqualified_t<T>, basic_object_base>>> = meta::enabler>
16801  basic_object_base(T&& arg, Args&&... args) : base_t(std::forward<T>(arg), std::forward<Args>(args)...) {
16802  }
16803 
16804  template <typename T>
16805  decltype(auto) as() const {
16806  return as_stack<T>(is_stack_based<base_t>());
16807  }
16808 
16809  template <typename T>
16810  bool is() const {
16811  return is_stack<T>(is_stack_based<base_t>());
16812  }
16813  };
16814 } // namespace sol
16815 
16816 // end of sol/object_base.hpp
16817 
16818 namespace sol {
16819 
16820  template <typename base_type>
16821  class basic_object : public basic_object_base<base_type> {
16822  private:
16824 
16825  template <bool invert_and_pop = false>
16826  basic_object(std::integral_constant<bool, invert_and_pop>, lua_State* L_, int index_ = -1) noexcept : base_t(L_, index_) {
16827  if (invert_and_pop) {
16828  lua_pop(L_, -index_);
16829  }
16830  }
16831 
16832  protected:
16834  }
16835  basic_object(detail::no_safety_tag, lua_State* L_, int index_) : base_t(L_, index_) {
16836  }
16838  }
16839  template <typename T,
16842  basic_object(detail::no_safety_tag, T&& r) noexcept : base_t(std::forward<T>(r)) {
16843  }
16844 
16845  template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
16846  basic_object(detail::no_safety_tag, lua_State* L_, T&& r) noexcept : base_t(L_, std::forward<T>(r)) {
16847  }
16848 
16849  public:
16850  basic_object() noexcept = default;
16851  template <typename T,
16852  meta::enable<meta::neg<std::is_same<meta::unqualified_t<T>, basic_object>>, meta::neg<std::is_same<base_type, stack_reference>>,
16853  is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
16854  basic_object(T&& r) : base_t(std::forward<T>(r)) {
16855  }
16856  template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
16857  basic_object(lua_State* L_, T&& r) : base_t(L_, std::forward<T>(r)) {
16858  }
16860  }
16862  }
16863  basic_object(const basic_object&) = default;
16864  basic_object(basic_object&&) = default;
16865  basic_object(const stack_reference& r) noexcept : basic_object(r.lua_state(), r.stack_index()) {
16866  }
16867  basic_object(stack_reference&& r) noexcept : basic_object(r.lua_state(), r.stack_index()) {
16868  }
16869  template <typename Super>
16870  basic_object(const proxy_base<Super>& r) noexcept : basic_object(r.operator basic_object()) {
16871  }
16872  template <typename Super>
16874  }
16875  basic_object(lua_State* L_, lua_nil_t r) noexcept : base_t(L_, r) {
16876  }
16877  basic_object(lua_State* L_, int index_ = -1) noexcept : base_t(L_, index_) {
16878  }
16879  basic_object(lua_State* L_, absolute_index index_) noexcept : base_t(L_, index_) {
16880  }
16881  basic_object(lua_State* L_, raw_index index_) noexcept : base_t(L_, index_) {
16882  }
16883  basic_object(lua_State* L_, ref_index index_) noexcept : base_t(L_, index_) {
16884  }
16885  template <typename T, typename... Args>
16886  basic_object(lua_State* L_, in_place_type_t<T>, Args&&... args) noexcept
16887  : basic_object(std::integral_constant<bool, !is_stack_based<base_t>::value>(), L_, -stack::push<T>(L_, std::forward<Args>(args)...)) {
16888  }
16889  template <typename T, typename... Args>
16890  basic_object(lua_State* L_, in_place_t, T&& arg, Args&&... args) noexcept
16891  : basic_object(L_, in_place_type<T>, std::forward<T>(arg), std::forward<Args>(args)...) {
16892  }
16893  basic_object& operator=(const basic_object&) = default;
16894  basic_object& operator=(basic_object&&) = default;
16895  basic_object& operator=(const base_type& b) {
16896  base_t::operator=(b);
16897  return *this;
16898  }
16899  basic_object& operator=(base_type&& b) {
16900  base_t::operator=(std::move(b));
16901  return *this;
16902  }
16903  template <typename Super>
16905  this->operator=(r.operator basic_object());
16906  return *this;
16907  }
16908  template <typename Super>
16910  this->operator=(r.operator basic_object());
16911  return *this;
16912  }
16913  };
16914 
16915  template <typename T>
16916  object make_object(lua_State* L_, T&& value) {
16917  return make_reference<object, true>(L_, std::forward<T>(value));
16918  }
16919 
16920  template <typename T, typename... Args>
16921  object make_object(lua_State* L_, Args&&... args) {
16922  return make_reference<T, object, true>(L_, std::forward<Args>(args)...);
16923  }
16924 
16925  template <typename T>
16926  object make_object_userdata(lua_State* L_, T&& value) {
16927  return make_reference_userdata<object, true>(L_, std::forward<T>(value));
16928  }
16929 
16930  template <typename T, typename... Args>
16931  object make_object_userdata(lua_State* L_, Args&&... args) {
16932  return make_reference_userdata<T, object, true>(L_, std::forward<Args>(args)...);
16933  }
16934 } // namespace sol
16935 
16936 // end of sol/object.hpp
16937 
16938 // beginning of sol/function.hpp
16939 
16940 // beginning of sol/unsafe_function.hpp
16941 
16942 // beginning of sol/function_result.hpp
16943 
16944 // beginning of sol/protected_function_result.hpp
16945 
16946 // beginning of sol/proxy_base.hpp
16947 
16948 namespace sol {
16949  struct proxy_base_tag { };
16950 
16951  namespace detail {
16952  template <typename T>
16954  std::tuple<meta::conditional_t<std::is_array_v<meta::unqualified_t<T>>, std::remove_reference_t<T>&, meta::unqualified_t<T>>>>;
16955  }
16956 
16957  template <typename Super>
16958  struct proxy_base : public proxy_base_tag {
16960  const Super& super = *static_cast<const Super*>(static_cast<const void*>(this));
16961  return super.lua_state();
16962  }
16963 
16964  operator std::string() const {
16965  const Super& super = *static_cast<const Super*>(static_cast<const void*>(this));
16966  return super.template get<std::string>();
16967  }
16968 
16969  template <typename T, meta::enable<meta::neg<meta::is_string_constructible<T>>, is_proxy_primitive<meta::unqualified_t<T>>> = meta::enabler>
16970  operator T() const {
16971  const Super& super = *static_cast<const Super*>(static_cast<const void*>(this));
16972  return super.template get<T>();
16973  }
16974 
16975  template <typename T,
16977  operator T&() const {
16978  const Super& super = *static_cast<const Super*>(static_cast<const void*>(this));
16979  return super.template get<T&>();
16980  }
16981  };
16982 
16983 } // namespace sol
16984 
16985 // end of sol/proxy_base.hpp
16986 
16987 // beginning of sol/stack_iterator.hpp
16988 
16989 #include <limits>
16990 #include <iterator>
16991 
16992 namespace sol {
16993  template <typename proxy_t, bool is_const>
16997  typedef proxy_t value_type;
16998  typedef std::ptrdiff_t difference_type;
16999  typedef std::random_access_iterator_tag iterator_category;
17001  int index;
17003  proxy_t sp;
17004 
17005  stack_iterator() : L(nullptr), index((std::numeric_limits<int>::max)()), stacktop((std::numeric_limits<int>::max)()), sp() {
17006  }
17007  stack_iterator(const stack_iterator<proxy_t, true>& r) : L(r.L), index(r.index), stacktop(r.stacktop), sp(r.sp) {
17008  }
17009  stack_iterator(lua_State* luastate, int idx, int topidx) : L(luastate), index(idx), stacktop(topidx), sp(luastate, idx) {
17010  }
17011 
17013  return proxy_t(L, index);
17014  }
17015 
17017  return proxy_t(L, index);
17018  }
17019 
17021  sp = proxy_t(L, index);
17022  return &sp;
17023  }
17024 
17026  const_cast<proxy_t&>(sp) = proxy_t(L, index);
17027  return &sp;
17028  }
17029 
17031  ++index;
17032  return *this;
17033  }
17034 
17036  auto r = *this;
17037  this->operator++();
17038  return r;
17039  }
17040 
17042  --index;
17043  return *this;
17044  }
17045 
17047  auto r = *this;
17048  this->operator--();
17049  return r;
17050  }
17051 
17053  index += static_cast<int>(idx);
17054  return *this;
17055  }
17056 
17058  index -= static_cast<int>(idx);
17059  return *this;
17060  }
17061 
17063  return index - r.index;
17064  }
17065 
17067  stack_iterator r = *this;
17068  r += idx;
17069  return r;
17070  }
17071 
17073  return proxy_t(L, index + static_cast<int>(idx));
17074  }
17075 
17076  bool operator==(const stack_iterator& r) const {
17077  if (stacktop == (std::numeric_limits<int>::max)()) {
17078  return r.index == r.stacktop;
17079  }
17080  else if (r.stacktop == (std::numeric_limits<int>::max)()) {
17081  return index == stacktop;
17082  }
17083  return index == r.index;
17084  }
17085 
17086  bool operator!=(const stack_iterator& r) const {
17087  return !(this->operator==(r));
17088  }
17089 
17090  bool operator<(const stack_iterator& r) const {
17091  return index < r.index;
17092  }
17093 
17094  bool operator>(const stack_iterator& r) const {
17095  return index > r.index;
17096  }
17097 
17098  bool operator<=(const stack_iterator& r) const {
17099  return index <= r.index;
17100  }
17101 
17102  bool operator>=(const stack_iterator& r) const {
17103  return index >= r.index;
17104  }
17105  };
17106 
17107  template <typename proxy_t, bool is_const>
17110  return r + n;
17111  }
17112 } // namespace sol
17113 
17114 // end of sol/stack_iterator.hpp
17115 
17116 // beginning of sol/stack_proxy.hpp
17117 
17118 // beginning of sol/stack_proxy_base.hpp
17119 
17120 namespace sol {
17121  struct stack_proxy_base : public proxy_base<stack_proxy_base> {
17122  private:
17124  int m_index;
17125 
17126  public:
17127  stack_proxy_base() : m_L(nullptr), m_index(0) {
17128  }
17129  stack_proxy_base(lua_State* L_, int index_) : m_L(L_), m_index(index_) {
17130  }
17131 
17132  template <typename T>
17133  decltype(auto) get() const {
17134  return stack::get<T>(m_L, stack_index());
17135  }
17136 
17137  template <typename T>
17138  bool is() const {
17139  return stack::check<T>(m_L, stack_index());
17140  }
17141 
17142  template <typename T>
17143  decltype(auto) as() const {
17144  return get<T>();
17145  }
17146 
17147  type get_type() const noexcept {
17148  return type_of(lua_state(), stack_index());
17149  }
17150 
17151  int push() const {
17152  return push(m_L);
17153  }
17154 
17155  int push(lua_State* L_) const {
17156  lua_pushvalue(L_, m_index);
17157  return 1;
17158  }
17159 
17161  return m_L;
17162  }
17163  int stack_index() const {
17164  return m_index;
17165  }
17166  };
17167 
17168  namespace stack {
17169  template <>
17171  static stack_proxy_base get(lua_State* L_, int index_ = -1) {
17172  return stack_proxy_base(L_, index_);
17173  }
17174  };
17175 
17176  template <>
17178  static int push(lua_State*, const stack_proxy_base& proxy_reference) {
17179  return proxy_reference.push();
17180  }
17181  };
17182  } // namespace stack
17183 
17184 } // namespace sol
17185 
17186 // end of sol/stack_proxy_base.hpp
17187 
17188 namespace sol {
17189  struct stack_proxy : public stack_proxy_base {
17190  public:
17192  }
17194  }
17195 
17196  template <typename... Ret, typename... Args>
17197  decltype(auto) call(Args&&... args);
17198 
17199  template <typename... Args>
17200  decltype(auto) operator()(Args&&... args) {
17201  return call<>(std::forward<Args>(args)...);
17202  }
17203  };
17204 
17205  namespace stack {
17206  template <>
17208  static stack_proxy get(lua_State* L, int index, record& tracking) {
17209  tracking.use(0);
17210  return stack_proxy(L, index);
17211  }
17212  };
17213 
17214  template <>
17216  static int push(lua_State*, const stack_proxy& ref) {
17217  return ref.push();
17218  }
17219  };
17220  } // namespace stack
17221 } // namespace sol
17222 
17223 // end of sol/stack_proxy.hpp
17224 
17225 #include <cstdint>
17226 
17227 namespace sol {
17228  struct protected_function_result : public proxy_base<protected_function_result> {
17229  private:
17231  int index;
17235 
17236  public:
17240  typedef std::ptrdiff_t difference_type;
17244  typedef std::reverse_iterator<iterator> reverse_iterator;
17245  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
17246 
17248  protected_function_result(lua_State* Ls, int idx = -1, int retnum = 0, int popped = 0, call_status pferr = call_status::ok) noexcept
17249  : L(Ls), index(idx), returncount(retnum), popcount(popped), err(pferr) {
17250  }
17251 
17252  // We do not want anyone to copy these around willy-nilly
17253  // Will likely break people, but also will probably get rid of quiet bugs that have
17254  // been lurking. (E.g., Vanilla Lua will just quietly discard over-pops and under-pops:
17255  // LuaJIT and other Lua engines will implode and segfault at random later times.)
17257  protected_function_result& operator=(const protected_function_result&) = delete;
17258 
17260  : L(o.L), index(o.index), returncount(o.returncount), popcount(o.popcount), err(o.err) {
17261  // Must be manual, otherwise destructor will screw us
17262  // return count being 0 is enough to keep things clean
17263  // but we will be thorough
17264  o.abandon();
17265  }
17267  L = o.L;
17268  index = o.index;
17269  returncount = o.returncount;
17270  popcount = o.popcount;
17271  err = o.err;
17272  // Must be manual, otherwise destructor will screw us
17273  // return count being 0 is enough to keep things clean
17274  // but we will be thorough
17275  o.abandon();
17276  return *this;
17277  }
17278 
17280  protected_function_result& operator=(const unsafe_function_result& o) = delete;
17282  protected_function_result& operator=(unsafe_function_result&& o) noexcept;
17283 
17284  call_status status() const noexcept {
17285  return err;
17286  }
17287 
17288  bool valid() const noexcept {
17289  return status() == call_status::ok || status() == call_status::yielded;
17290  }
17291 
17292 #if SOL_IS_ON(SOL_COMPILER_GCC)
17293 #pragma GCC diagnostic push
17294 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
17295 #endif
17296 
17297  template <typename T>
17298  decltype(auto) get(int index_offset = 0) const {
17299  using UT = meta::unqualified_t<T>;
17300  int target = index + index_offset;
17301  if constexpr (meta::is_optional_v<UT>) {
17302  using ValueType = typename UT::value_type;
17303  if constexpr (std::is_same_v<ValueType, error>) {
17304  if (valid()) {
17305  return UT();
17306  }
17307  return UT(error(detail::direct_error, stack::get<std::string>(L, target)));
17308  }
17309  else {
17310  if (!valid()) {
17311  return UT();
17312  }
17313  return stack::get<UT>(L, target);
17314  }
17315  }
17316  else {
17317  if constexpr (std::is_same_v<T, error>) {
17318 #if SOL_IS_ON(SOL_SAFE_PROXIES)
17319  if (valid()) {
17320  type t = type_of(L, target);
17321  type_panic_c_str(L, target, t, type::none, "bad get from protected_function_result (is an error)");
17322  }
17323 #endif // Check Argument Safety
17324  return error(detail::direct_error, stack::get<std::string>(L, target));
17325  }
17326  else {
17327 #if SOL_IS_ON(SOL_SAFE_PROXIES)
17328  if (!valid()) {
17329  type t = type_of(L, target);
17330  type_panic_c_str(L, target, t, type::none, "bad get from protected_function_result (is not an error)");
17331  }
17332 #endif // Check Argument Safety
17333  return stack::get<T>(L, target);
17334  }
17335  }
17336  }
17337 
17338 #if SOL_IS_ON(SOL_COMPILER_GCC)
17339 #pragma GCC diagnostic pop
17340 #endif
17341 
17342  type get_type(int index_offset = 0) const noexcept {
17343  return type_of(L, index + static_cast<int>(index_offset));
17344  }
17345 
17347  return stack_proxy(L, index + static_cast<int>(index_offset));
17348  }
17349 
17351  return iterator(L, index, stack_index() + return_count());
17352  }
17354  return iterator(L, stack_index() + return_count(), stack_index() + return_count());
17355  }
17357  return const_iterator(L, index, stack_index() + return_count());
17358  }
17360  return const_iterator(L, stack_index() + return_count(), stack_index() + return_count());
17361  }
17363  return begin();
17364  }
17366  return end();
17367  }
17368 
17370  return std::reverse_iterator<iterator>(begin());
17371  }
17373  return std::reverse_iterator<iterator>(end());
17374  }
17376  return std::reverse_iterator<const_iterator>(begin());
17377  }
17379  return std::reverse_iterator<const_iterator>(end());
17380  }
17382  return std::reverse_iterator<const_iterator>(cbegin());
17383  }
17385  return std::reverse_iterator<const_iterator>(cend());
17386  }
17387 
17388  lua_State* lua_state() const noexcept {
17389  return L;
17390  };
17391  int stack_index() const noexcept {
17392  return index;
17393  };
17394  int return_count() const noexcept {
17395  return returncount;
17396  };
17397  int pop_count() const noexcept {
17398  return popcount;
17399  };
17400  void abandon() noexcept {
17401  // L = nullptr;
17402  index = 0;
17403  returncount = 0;
17404  popcount = 0;
17405  err = call_status::runtime;
17406  }
17408  if (L == nullptr)
17409  return;
17410  stack::remove(L, index, popcount);
17411  }
17412  };
17413 
17414  namespace stack {
17415  template <>
17417  static int push(lua_State* L, const protected_function_result& pfr) {
17418 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
17420 #endif // make sure stack doesn't overflow
17421  int p = 0;
17422  for (int i = 0; i < pfr.pop_count(); ++i) {
17423  lua_pushvalue(L, i + pfr.stack_index());
17424  ++p;
17425  }
17426  return p;
17427  }
17428  };
17429  } // namespace stack
17430 } // namespace sol
17431 
17432 // end of sol/protected_function_result.hpp
17433 
17434 // beginning of sol/unsafe_function_result.hpp
17435 
17436 #include <cstdint>
17437 
17438 namespace sol {
17439  struct unsafe_function_result : public proxy_base<unsafe_function_result> {
17440  private:
17442  int index;
17444 
17445  public:
17449  typedef std::ptrdiff_t difference_type;
17453  typedef std::reverse_iterator<iterator> reverse_iterator;
17454  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
17455 
17457  unsafe_function_result(lua_State* Ls, int idx = -1, int retnum = 0) noexcept : L(Ls), index(idx), returncount(retnum) {
17458  }
17459 
17460  // We do not want anyone to copy these around willy-nilly
17461  // Will likely break people, but also will probably get rid of quiet bugs that have
17462  // been lurking. (E.g., Vanilla Lua will just quietly discard over-pops and under-pops:
17463  // LuaJIT and other Lua engines will implode and segfault at random later times.)
17465  unsafe_function_result& operator=(const unsafe_function_result&) = delete;
17466 
17467  unsafe_function_result(unsafe_function_result&& o) noexcept : L(o.L), index(o.index), returncount(o.returncount) {
17468  // Must be manual, otherwise destructor will screw us
17469  // return count being 0 is enough to keep things clean
17470  // but will be thorough
17471  o.abandon();
17472  }
17474  L = o.L;
17475  index = o.index;
17476  returncount = o.returncount;
17477  // Must be manual, otherwise destructor will screw us
17478  // return count being 0 is enough to keep things clean
17479  // but will be thorough
17480  o.abandon();
17481  return *this;
17482  }
17483 
17485  unsafe_function_result& operator=(const protected_function_result& o) = delete;
17487  unsafe_function_result& operator=(protected_function_result&& o) noexcept;
17488 
17489  template <typename T>
17490  decltype(auto) get(difference_type index_offset = 0) const {
17491  return stack::get<T>(L, index + static_cast<int>(index_offset));
17492  }
17493 
17494  type get_type(difference_type index_offset = 0) const noexcept {
17495  return type_of(L, index + static_cast<int>(index_offset));
17496  }
17497 
17499  return stack_proxy(L, index + static_cast<int>(index_offset));
17500  }
17501 
17503  return iterator(L, index, stack_index() + return_count());
17504  }
17506  return iterator(L, stack_index() + return_count(), stack_index() + return_count());
17507  }
17509  return const_iterator(L, index, stack_index() + return_count());
17510  }
17512  return const_iterator(L, stack_index() + return_count(), stack_index() + return_count());
17513  }
17515  return begin();
17516  }
17518  return end();
17519  }
17520 
17522  return std::reverse_iterator<iterator>(begin());
17523  }
17525  return std::reverse_iterator<iterator>(end());
17526  }
17528  return std::reverse_iterator<const_iterator>(begin());
17529  }
17531  return std::reverse_iterator<const_iterator>(end());
17532  }
17534  return std::reverse_iterator<const_iterator>(cbegin());
17535  }
17537  return std::reverse_iterator<const_iterator>(cend());
17538  }
17539 
17540  call_status status() const noexcept {
17541  return call_status::ok;
17542  }
17543 
17544  bool valid() const noexcept {
17545  return status() == call_status::ok || status() == call_status::yielded;
17546  }
17547 
17549  return L;
17550  };
17551  int stack_index() const {
17552  return index;
17553  };
17554  int return_count() const {
17555  return returncount;
17556  };
17557  void abandon() noexcept {
17558  // L = nullptr;
17559  index = 0;
17560  returncount = 0;
17561  }
17563  if (L != nullptr) {
17564  lua_pop(L, returncount);
17565  }
17566  }
17567  };
17568 
17569  namespace stack {
17570  template <>
17572  static int push(lua_State* L, const unsafe_function_result& fr) {
17573  int p = 0;
17574  for (int i = 0; i < fr.return_count(); ++i) {
17575  lua_pushvalue(L, i + fr.stack_index());
17576  ++p;
17577  }
17578  return p;
17579  }
17580  };
17581  } // namespace stack
17582 } // namespace sol
17583 
17584 // end of sol/unsafe_function_result.hpp
17585 
17586 #include <cstdint>
17587 
17588 namespace sol {
17589 
17590  namespace detail {
17591  template <>
17593  template <>
17595 
17596  template <std::size_t I, typename... Args, typename T>
17598  return stack_proxy(fr.lua_state(), fr.stack_index() + static_cast<int>(I));
17599  }
17600 
17601  template <std::size_t I, std::size_t N, typename Arg, typename... Args, typename T, meta::enable<meta::boolean<(N > 0)>> = meta::enabler>
17604  }
17605  } // namespace detail
17606 
17607  template <>
17608  struct tie_size<unsafe_function_result> : std::integral_constant<std::size_t, SIZE_MAX> { };
17609 
17610  template <>
17611  struct tie_size<protected_function_result> : std::integral_constant<std::size_t, SIZE_MAX> { };
17612 
17613  template <std::size_t I>
17615  return stack_proxy(fr.lua_state(), fr.stack_index() + static_cast<int>(I));
17616  }
17617 
17618  template <std::size_t I, typename... Args>
17621  }
17622 
17623  template <std::size_t I>
17625  return stack_proxy(fr.lua_state(), fr.stack_index() + static_cast<int>(I));
17626  }
17627 
17628  template <std::size_t I, typename... Args>
17631  }
17632 } // namespace sol
17633 
17634 // end of sol/function_result.hpp
17635 
17636 // beginning of sol/function_types.hpp
17637 
17638 // beginning of sol/function_types_core.hpp
17639 
17640 // beginning of sol/wrapper.hpp
17641 
17642 namespace sol {
17643 
17644  namespace detail {
17645  template <typename T>
17646  using array_return_type = meta::conditional_t<std::is_array<T>::value, std::add_lvalue_reference_t<T>, T>;
17647  }
17648 
17649  template <typename F, typename = void>
17650  struct wrapper {
17655 
17656  template <typename... Args>
17657  static decltype(auto) call(F& f, Args&&... args) {
17658  return f(std::forward<Args>(args)...);
17659  }
17660 
17661  struct caller {
17662  template <typename... Args>
17663  decltype(auto) operator()(F& fx, Args&&... args) const {
17664  return call(fx, std::forward<Args>(args)...);
17665  }
17666  };
17667  };
17668 
17669  template <typename F>
17670  struct wrapper<F, std::enable_if_t<std::is_function<std::remove_pointer_t<meta::unqualified_t<F>>>::value>> {
17675 
17676  template <F fx, typename... Args>
17677  static decltype(auto) invoke(Args&&... args) {
17678  return fx(std::forward<Args>(args)...);
17679  }
17680 
17681  template <typename... Args>
17682  static decltype(auto) call(F& fx, Args&&... args) {
17683  return fx(std::forward<Args>(args)...);
17684  }
17685 
17686  struct caller {
17687  template <typename... Args>
17688  decltype(auto) operator()(F& fx, Args&&... args) const {
17689  return call(fx, std::forward<Args>(args)...);
17690  }
17691  };
17692 
17693  template <F fx>
17694  struct invoker {
17695  template <typename... Args>
17696  decltype(auto) operator()(Args&&... args) const {
17697  return invoke<fx>(std::forward<Args>(args)...);
17698  }
17699  };
17700  };
17701 
17702  template <typename F>
17703  struct wrapper<F, std::enable_if_t<std::is_member_object_pointer<meta::unqualified_t<F>>::value>> {
17710 
17711  template <F fx>
17712  static auto call(object_type& mem) -> detail::array_return_type<decltype(mem.*fx)> {
17713  return mem.*fx;
17714  }
17715 
17716  template <F fx, typename Arg, typename... Args>
17717  static decltype(auto) invoke(object_type& mem, Arg&& arg, Args&&...) {
17718  return mem.*fx = std::forward<Arg>(arg);
17719  }
17720 
17721  template <typename Fx>
17722  static auto call(Fx&& fx, object_type& mem) -> detail::array_return_type<decltype(mem.*fx)> {
17723  return mem.*fx;
17724  }
17725 
17726  template <typename Fx, typename Arg, typename... Args>
17727  static void call(Fx&& fx, object_type& mem, Arg&& arg, Args&&...) {
17728  using actual_type = meta::unqualified_t<detail::array_return_type<decltype(mem.*fx)>>;
17729  if constexpr (std::is_array_v<actual_type>) {
17730  using std::cbegin;
17731  using std::cend;
17732  auto first = cbegin(arg);
17733  auto last = cend(arg);
17734  for (std::size_t i = 0; first != last; ++i, ++first) {
17735  (mem.*fx)[i] = *first;
17736  }
17737  }
17738  else {
17739  (mem.*fx) = std::forward<Arg>(arg);
17740  }
17741  }
17742 
17743  struct caller {
17744  template <typename Fx, typename... Args>
17745  decltype(auto) operator()(Fx&& fx, object_type& mem, Args&&... args) const {
17746  return call(std::forward<Fx>(fx), mem, std::forward<Args>(args)...);
17747  }
17748  };
17749 
17750  template <F fx>
17751  struct invoker {
17752  template <typename... Args>
17753  decltype(auto) operator()(Args&&... args) const {
17754  return invoke<fx>(std::forward<Args>(args)...);
17755  }
17756  };
17757  };
17758 
17759  template <typename F, typename R, typename O, typename... FArgs>
17761  typedef O object_type;
17764  typedef types<object_type&, FArgs...> free_args_list;
17766 
17767  template <F fx, typename... Args>
17768  static R invoke(O& mem, Args&&... args) {
17769  return (mem.*fx)(std::forward<Args>(args)...);
17770  }
17771 
17772  template <typename Fx, typename... Args>
17773  static R call(Fx&& fx, O& mem, Args&&... args) {
17774  return (mem.*fx)(std::forward<Args>(args)...);
17775  }
17776 
17777  struct caller {
17778  template <typename Fx, typename... Args>
17779  decltype(auto) operator()(Fx&& fx, O& mem, Args&&... args) const {
17780  return call(std::forward<Fx>(fx), mem, std::forward<Args>(args)...);
17781  }
17782  };
17783 
17784  template <F fx>
17785  struct invoker {
17786  template <typename... Args>
17787  decltype(auto) operator()(O& mem, Args&&... args) const {
17788  return invoke<fx>(mem, std::forward<Args>(args)...);
17789  }
17790  };
17791  };
17792 
17793  template <typename R, typename O, typename... Args>
17794  struct wrapper<R (O::*)(Args...)> : public member_function_wrapper<R (O::*)(Args...), R, O, Args...> { };
17795 
17796  template <typename R, typename O, typename... Args>
17797  struct wrapper<R (O::*)(Args...) const> : public member_function_wrapper<R (O::*)(Args...) const, R, O, Args...> { };
17798 
17799  template <typename R, typename O, typename... Args>
17800  struct wrapper<R (O::*)(Args...) const volatile> : public member_function_wrapper<R (O::*)(Args...) const volatile, R, O, Args...> { };
17801 
17802  template <typename R, typename O, typename... Args>
17803  struct wrapper<R (O::*)(Args...)&> : public member_function_wrapper<R (O::*)(Args...)&, R, O, Args...> { };
17804 
17805  template <typename R, typename O, typename... Args>
17806  struct wrapper<R (O::*)(Args...) const&> : public member_function_wrapper<R (O::*)(Args...) const&, R, O, Args...> { };
17807 
17808  template <typename R, typename O, typename... Args>
17809  struct wrapper<R (O::*)(Args...) const volatile&> : public member_function_wrapper<R (O::*)(Args...) const volatile&, R, O, Args...> { };
17810 
17811  template <typename R, typename O, typename... Args>
17812  struct wrapper<R (O::*)(Args..., ...)&> : public member_function_wrapper<R (O::*)(Args..., ...)&, R, O, Args...> { };
17813 
17814  template <typename R, typename O, typename... Args>
17815  struct wrapper<R (O::*)(Args..., ...) const&> : public member_function_wrapper<R (O::*)(Args..., ...) const&, R, O, Args...> { };
17816 
17817  template <typename R, typename O, typename... Args>
17818  struct wrapper<R (O::*)(Args..., ...) const volatile&> : public member_function_wrapper<R (O::*)(Args..., ...) const volatile&, R, O, Args...> { };
17819 
17820  template <typename R, typename O, typename... Args>
17821  struct wrapper<R (O::*)(Args...) &&> : public member_function_wrapper<R (O::*)(Args...)&, R, O, Args...> { };
17822 
17823  template <typename R, typename O, typename... Args>
17824  struct wrapper<R (O::*)(Args...) const&&> : public member_function_wrapper<R (O::*)(Args...) const&, R, O, Args...> { };
17825 
17826  template <typename R, typename O, typename... Args>
17827  struct wrapper<R (O::*)(Args...) const volatile&&> : public member_function_wrapper<R (O::*)(Args...) const volatile&, R, O, Args...> { };
17828 
17829  template <typename R, typename O, typename... Args>
17830  struct wrapper<R (O::*)(Args..., ...) &&> : public member_function_wrapper<R (O::*)(Args..., ...)&, R, O, Args...> { };
17831 
17832  template <typename R, typename O, typename... Args>
17833  struct wrapper<R (O::*)(Args..., ...) const&&> : public member_function_wrapper<R (O::*)(Args..., ...) const&, R, O, Args...> { };
17834 
17835  template <typename R, typename O, typename... Args>
17836  struct wrapper<R (O::*)(Args..., ...) const volatile&&> : public member_function_wrapper<R (O::*)(Args..., ...) const volatile&, R, O, Args...> { };
17837 
17838 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE)
17839  // noexcept has become a part of a function's type
17840 
17841  template <typename R, typename O, typename... Args>
17842  struct wrapper<R (O::*)(Args...) noexcept> : public member_function_wrapper<R (O::*)(Args...) noexcept, R, O, Args...> { };
17843 
17844  template <typename R, typename O, typename... Args>
17845  struct wrapper<R (O::*)(Args...) const noexcept> : public member_function_wrapper<R (O::*)(Args...) const noexcept, R, O, Args...> { };
17846 
17847  template <typename R, typename O, typename... Args>
17848  struct wrapper<R (O::*)(Args...) const volatile noexcept> : public member_function_wrapper<R (O::*)(Args...) const volatile noexcept, R, O, Args...> { };
17849 
17850  template <typename R, typename O, typename... Args>
17851  struct wrapper<R (O::*)(Args...)& noexcept> : public member_function_wrapper<R (O::*)(Args...)& noexcept, R, O, Args...> { };
17852 
17853  template <typename R, typename O, typename... Args>
17854  struct wrapper<R (O::*)(Args...) const& noexcept> : public member_function_wrapper<R (O::*)(Args...) const& noexcept, R, O, Args...> { };
17855 
17856  template <typename R, typename O, typename... Args>
17857  struct wrapper<R (O::*)(Args...) const volatile& noexcept> : public member_function_wrapper<R (O::*)(Args...) const volatile& noexcept, R, O, Args...> { };
17858 
17859  template <typename R, typename O, typename... Args>
17860  struct wrapper<R (O::*)(Args..., ...)& noexcept> : public member_function_wrapper<R (O::*)(Args..., ...)& noexcept, R, O, Args...> { };
17861 
17862  template <typename R, typename O, typename... Args>
17863  struct wrapper<R (O::*)(Args..., ...) const& noexcept> : public member_function_wrapper<R (O::*)(Args..., ...) const& noexcept, R, O, Args...> { };
17864 
17865  template <typename R, typename O, typename... Args>
17866  struct wrapper<R (O::*)(Args..., ...) const volatile& noexcept>
17867  : public member_function_wrapper<R (O::*)(Args..., ...) const volatile& noexcept, R, O, Args...> { };
17868 
17869  template <typename R, typename O, typename... Args>
17870  struct wrapper<R (O::*)(Args...)&& noexcept> : public member_function_wrapper<R (O::*)(Args...)& noexcept, R, O, Args...> { };
17871 
17872  template <typename R, typename O, typename... Args>
17873  struct wrapper<R (O::*)(Args...) const&& noexcept> : public member_function_wrapper<R (O::*)(Args...) const& noexcept, R, O, Args...> { };
17874 
17875  template <typename R, typename O, typename... Args>
17876  struct wrapper<R (O::*)(Args...) const volatile&& noexcept> : public member_function_wrapper<R (O::*)(Args...) const volatile& noexcept, R, O, Args...> {
17877  };
17878 
17879  template <typename R, typename O, typename... Args>
17880  struct wrapper<R (O::*)(Args..., ...)&& noexcept> : public member_function_wrapper<R (O::*)(Args..., ...)& noexcept, R, O, Args...> { };
17881 
17882  template <typename R, typename O, typename... Args>
17883  struct wrapper<R (O::*)(Args..., ...) const&& noexcept> : public member_function_wrapper<R (O::*)(Args..., ...) const& noexcept, R, O, Args...> { };
17884 
17885  template <typename R, typename O, typename... Args>
17886  struct wrapper<R (O::*)(Args..., ...) const volatile&& noexcept>
17887  : public member_function_wrapper<R (O::*)(Args..., ...) const volatile& noexcept, R, O, Args...> { };
17888 
17889 #endif // noexcept is part of a function's type
17890 
17891 } // namespace sol
17892 
17893 // end of sol/wrapper.hpp
17894 
17895 #include <memory>
17896 
17897 namespace sol { namespace function_detail {
17898  template <typename Fx, int start = 1, bool is_yielding = false>
17899  int call(lua_State* L) {
17900  Fx& fx = stack::get<user<Fx>>(L, upvalue_index(start));
17901  int nr = fx(L);
17902  if (is_yielding) {
17903  return lua_yield(L, nr);
17904  }
17905  else {
17906  return nr;
17907  }
17908  }
17909 }} // namespace sol::function_detail
17910 
17911 // end of sol/function_types_core.hpp
17912 
17913 // beginning of sol/function_types_templated.hpp
17914 
17915 // beginning of sol/call.hpp
17916 
17917 // beginning of sol/property.hpp
17918 
17919 #include <type_traits>
17920 #include <utility>
17921 
17922 namespace sol {
17923  namespace detail {
17924  struct no_prop { };
17925  } // namespace detail
17926 
17927  template <typename R, typename W>
17929  private:
17932 
17933  public:
17934  template <typename Rx, typename Wx>
17935  property_wrapper(Rx&& r, Wx&& w) : read_base_t(std::forward<Rx>(r)), write_base_t(std::forward<Wx>(w)) {
17936  }
17937 
17938  W& write() {
17939  return write_base_t::value();
17940  }
17941 
17942  const W& write() const {
17943  return write_base_t::value();
17944  }
17945 
17946  R& read() {
17947  return read_base_t::value();
17948  }
17949 
17950  const R& read() const {
17951  return read_base_t::value();
17952  }
17953  };
17954 
17955  template <typename F, typename G>
17956  inline decltype(auto) property(F&& f, G&& g) {
17957  typedef lua_bind_traits<meta::unqualified_t<F>> left_traits;
17958  typedef lua_bind_traits<meta::unqualified_t<G>> right_traits;
17959  if constexpr (left_traits::free_arity < right_traits::free_arity) {
17960  return property_wrapper<std::decay_t<F>, std::decay_t<G>>(std::forward<F>(f), std::forward<G>(g));
17961  }
17962  else {
17963  return property_wrapper<std::decay_t<G>, std::decay_t<F>>(std::forward<G>(g), std::forward<F>(f));
17964  }
17965  }
17966 
17967  template <typename F>
17968  inline decltype(auto) property(F&& f) {
17969  typedef lua_bind_traits<meta::unqualified_t<F>> left_traits;
17970  if constexpr (left_traits::free_arity < 2) {
17971  return property_wrapper<std::decay_t<F>, detail::no_prop>(std::forward<F>(f), detail::no_prop());
17972  }
17973  else {
17975  }
17976  }
17977 
17978  template <typename F>
17979  inline decltype(auto) readonly_property(F&& f) {
17980  return property_wrapper<std::decay_t<F>, detail::no_prop>(std::forward<F>(f), detail::no_prop());
17981  }
17982 
17983  template <typename F>
17984  inline decltype(auto) writeonly_property(F&& f) {
17986  }
17987 
17988  template <typename T>
17990  private:
17992 
17993  public:
17994  using base_t::base_t;
17995 
17996  operator T&() {
17997  return base_t::value();
17998  }
17999  operator const T&() const {
18000  return base_t::value();
18001  }
18002  };
18003 
18004  // Allow someone to make a member variable readonly (const)
18005  template <typename R, typename T>
18006  inline auto readonly(R T::*v) {
18007  return readonly_wrapper<meta::unqualified_t<decltype(v)>>(v);
18008  }
18009 
18010  template <typename T>
18012  private:
18014 
18015  public:
18016  using base_t::base_t;
18017  };
18018 
18019  template <typename V>
18020  inline auto var(V&& v) {
18021  typedef std::decay_t<V> T;
18022  return var_wrapper<T>(std::forward<V>(v));
18023  }
18024 
18025  namespace meta {
18026  template <typename T>
18027  using is_member_object = std::integral_constant<bool, std::is_member_object_pointer_v<T> || is_specialization_of_v<T, readonly_wrapper>>;
18028 
18029  template <typename T>
18031 
18032  template <typename T>
18033  using is_member_object_or_function = std::integral_constant<bool, is_member_object_v<T> || std::is_member_pointer_v<T>>;
18034 
18035  template <typename T>
18037  } // namespace meta
18038 
18039 } // namespace sol
18040 
18041 // end of sol/property.hpp
18042 
18043 // beginning of sol/protect.hpp
18044 
18045 #include <utility>
18046 
18047 namespace sol {
18048 
18049  template <typename T>
18050  struct protect_t {
18052 
18053  template <typename Arg, typename... Args, meta::disable<std::is_same<protect_t, meta::unqualified_t<Arg>>> = meta::enabler>
18054  protect_t(Arg&& arg, Args&&... args) : value(std::forward<Arg>(arg), std::forward<Args>(args)...) {
18055  }
18056 
18057  protect_t(const protect_t&) = default;
18058  protect_t(protect_t&&) = default;
18059  protect_t& operator=(const protect_t&) = default;
18060  protect_t& operator=(protect_t&&) = default;
18061  };
18062 
18063  template <typename T>
18064  auto protect(T&& value) {
18065  return protect_t<std::decay_t<T>>(std::forward<T>(value));
18066  }
18067 
18068 } // namespace sol
18069 
18070 // end of sol/protect.hpp
18071 
18072 namespace sol {
18073  namespace u_detail {
18074 
18075  } // namespace u_detail
18076 
18077  namespace policy_detail {
18078  template <int I, int... In>
18080  if constexpr (sizeof...(In) == 0) {
18081  (void)L;
18082  return;
18083  }
18084  else {
18085  absolute_index ai(L, I);
18086  if (type_of(L, ai) != type::userdata) {
18087  return;
18088  }
18089  lua_createtable(L, static_cast<int>(sizeof...(In)), 0);
18090  stack_reference deps(L, -1);
18091  auto per_dep = [&L, &deps](int i) {
18092 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
18094 #endif // make sure stack doesn't overflow
18095  lua_pushvalue(L, i);
18096  luaL_ref(L, deps.stack_index());
18097  };
18098  (void)per_dep;
18099  (void)detail::swallow { int(), (per_dep(In), int())... };
18100  lua_setuservalue(L, ai);
18101  }
18102  }
18103 
18104  template <int... In>
18105  inline void handle_policy(returns_self_with<In...>, lua_State* L, int& pushed) {
18106  pushed = stack::push(L, raw_index(1));
18108  }
18109 
18110  inline void handle_policy(const stack_dependencies& sdeps, lua_State* L, int&) {
18111  absolute_index ai(L, sdeps.target);
18112  if (type_of(L, ai) != type::userdata) {
18113  return;
18114  }
18115  lua_createtable(L, static_cast<int>(sdeps.size()), 0);
18116  stack_reference deps(L, -1);
18117 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
18118  luaL_checkstack(L, static_cast<int>(sdeps.size()), detail::not_enough_stack_space_generic);
18119 #endif // make sure stack doesn't overflow
18120  for (std::size_t i = 0; i < sdeps.size(); ++i) {
18121  lua_pushvalue(L, sdeps.stack_indices[i]);
18122  luaL_ref(L, deps.stack_index());
18123  }
18124  lua_setuservalue(L, ai);
18125  }
18126 
18127  template <typename P, meta::disable<std::is_base_of<detail::policy_base_tag, meta::unqualified_t<P>>> = meta::enabler>
18128  inline void handle_policy(P&& p, lua_State* L, int& pushed) {
18129  pushed = std::forward<P>(p)(L, pushed);
18130  }
18131  } // namespace policy_detail
18132 
18133  namespace function_detail {
18135  return luaL_error(L, "sol: cannot call this constructor (tagged as non-constructible)");
18136  }
18137  } // namespace function_detail
18138 
18139  namespace call_detail {
18140 
18141  template <typename R, typename W>
18143  return f.read();
18144  }
18145 
18146  template <typename R, typename W>
18148  return f.write();
18149  }
18150 
18151  template <typename T, typename List>
18152  struct void_call : void_call<T, meta::function_args_t<List>> { };
18153 
18154  template <typename T, typename... Args>
18155  struct void_call<T, types<Args...>> {
18156  static void call(Args...) {
18157  }
18158  };
18159 
18160  template <typename T, bool checked, bool clean_stack>
18162  T* obj_;
18165 
18167  : obj_(obj_ptr), obj_lua_ref_(&obj_lua_ref), p_umf_(&umf) {
18168  }
18169 
18170  template <typename Fx, std::size_t I, typename... R, typename... Args>
18172  detail::default_construct func {};
18173  int result = stack::call_into_lua<checked, clean_stack>(r, a, L, start, func, this->obj_);
18174  // construct userdata table
18175  // SPECIFICALLY, after we've created it successfully.
18176  // If the constructor exits for any reason we have to break things down...
18177  if constexpr (clean_stack) {
18178  obj_lua_ref_->push();
18179  (*this->p_umf_)();
18180  obj_lua_ref_->pop();
18181  }
18182  else {
18183  (*this->p_umf_)();
18184  }
18185  return result;
18186  }
18187  };
18188 
18189  namespace overload_detail {
18190  template <std::size_t... M, typename Match, typename... Args>
18191  inline int overload_match_arity(types<>, std::index_sequence<>, std::index_sequence<M...>, Match&&, lua_State* L, int, int, Args&&...) {
18192  return luaL_error(L, "sol: no matching function call takes this number of arguments and the specified types");
18193  }
18194 
18195  template <typename Fx, typename... Fxs, std::size_t I, std::size_t... In, std::size_t... M, typename Match, typename... Args>
18196  inline int overload_match_arity(types<Fx, Fxs...>, std::index_sequence<I, In...>, std::index_sequence<M...>, Match&& matchfx, lua_State* L,
18197  int fxarity, int start, Args&&... args) {
18200  typedef typename traits::free_args_list args_list;
18201  // compile-time eliminate any functions that we know ahead of time are of improper arity
18202  if constexpr (!traits::runtime_variadics_t::value
18205  std::index_sequence<In...>(),
18206  std::index_sequence<M...>(),
18207  std::forward<Match>(matchfx),
18208  L,
18209  fxarity,
18210  start,
18211  std::forward<Args>(args)...);
18212  }
18213  else {
18214  if constexpr (!traits::runtime_variadics_t::value) {
18215  if (traits::free_arity != fxarity) {
18217  std::index_sequence<In...>(),
18218  std::index_sequence<traits::free_arity, M...>(),
18219  std::forward<Match>(matchfx),
18220  L,
18221  fxarity,
18222  start,
18223  std::forward<Args>(args)...);
18224  }
18225  }
18226  stack::record tracking {};
18227  if (!stack::stack_detail::check_types(args_list(), L, start, &no_panic, tracking)) {
18229  std::index_sequence<In...>(),
18230  std::index_sequence<M...>(),
18231  std::forward<Match>(matchfx),
18232  L,
18233  fxarity,
18234  start,
18235  std::forward<Args>(args)...);
18236  }
18237  return matchfx(types<Fx>(), meta::index_value<I>(), return_types(), args_list(), L, fxarity, start, std::forward<Args>(args)...);
18238  }
18239  }
18240 
18241  template <std::size_t... M, typename Match, typename... Args>
18243  types<>, std::index_sequence<>, std::index_sequence<M...>, Match&& matchfx, lua_State* L, int fxarity, int start, Args&&... args) {
18244  return overload_match_arity(types<>(),
18245  std::index_sequence<>(),
18246  std::index_sequence<M...>(),
18247  std::forward<Match>(matchfx),
18248  L,
18249  fxarity,
18250  start,
18251  std::forward<Args>(args)...);
18252  }
18253 
18254  template <typename Fx, std::size_t I, std::size_t... M, typename Match, typename... Args>
18256  types<Fx>, std::index_sequence<I>, std::index_sequence<M...>, Match&& matchfx, lua_State* L, int fxarity, int start, Args&&... args) {
18259  typedef typename traits::free_args_list args_list;
18260  // compile-time eliminate any functions that we know ahead of time are of improper arity
18261  if constexpr (!traits::runtime_variadics_t::value
18263  return overload_match_arity(types<>(),
18264  std::index_sequence<>(),
18265  std::index_sequence<M...>(),
18266  std::forward<Match>(matchfx),
18267  L,
18268  fxarity,
18269  start,
18270  std::forward<Args>(args)...);
18271  }
18272  if constexpr (!traits::runtime_variadics_t::value) {
18273  if (traits::free_arity != fxarity) {
18274  return overload_match_arity(types<>(),
18275  std::index_sequence<>(),
18276  std::index_sequence<traits::free_arity, M...>(),
18277  std::forward<Match>(matchfx),
18278  L,
18279  fxarity,
18280  start,
18281  std::forward<Args>(args)...);
18282  }
18283  }
18284  return matchfx(types<Fx>(), meta::index_value<I>(), return_types(), args_list(), L, fxarity, start, std::forward<Args>(args)...);
18285  }
18286 
18287  template <typename Fx, typename Fx1, typename... Fxs, std::size_t I, std::size_t I1, std::size_t... In, std::size_t... M, typename Match,
18288  typename... Args>
18289  inline int overload_match_arity_single(types<Fx, Fx1, Fxs...>, std::index_sequence<I, I1, In...>, std::index_sequence<M...>, Match&& matchfx,
18290  lua_State* L, int fxarity, int start, Args&&... args) {
18293  typedef typename traits::free_args_list args_list;
18294  // compile-time eliminate any functions that we know ahead of time are of improper arity
18295  if constexpr (!traits::runtime_variadics_t::value
18298  std::index_sequence<I1, In...>(),
18299  std::index_sequence<M...>(),
18300  std::forward<Match>(matchfx),
18301  L,
18302  fxarity,
18303  start,
18304  std::forward<Args>(args)...);
18305  }
18306  else {
18307  if constexpr (!traits::runtime_variadics_t::value) {
18308  if (traits::free_arity != fxarity) {
18310  std::index_sequence<I1, In...>(),
18311  std::index_sequence<traits::free_arity, M...>(),
18312  std::forward<Match>(matchfx),
18313  L,
18314  fxarity,
18315  start,
18316  std::forward<Args>(args)...);
18317  }
18318  }
18319  stack::record tracking {};
18320  if (!stack::stack_detail::check_types(args_list(), L, start, &no_panic, tracking)) {
18322  std::index_sequence<I1, In...>(),
18323  std::index_sequence<M...>(),
18324  std::forward<Match>(matchfx),
18325  L,
18326  fxarity,
18327  start,
18328  std::forward<Args>(args)...);
18329  }
18330  return matchfx(types<Fx>(), meta::index_value<I>(), return_types(), args_list(), L, fxarity, start, std::forward<Args>(args)...);
18331  }
18332  }
18333  } // namespace overload_detail
18334 
18335  template <typename... Functions, typename Match, typename... Args>
18336  inline int overload_match_arity(Match&& matchfx, lua_State* L, int fxarity, int start, Args&&... args) {
18338  std::make_index_sequence<sizeof...(Functions)>(),
18339  std::index_sequence<>(),
18340  std::forward<Match>(matchfx),
18341  L,
18342  fxarity,
18343  start,
18344  std::forward<Args>(args)...);
18345  }
18346 
18347  template <typename... Functions, typename Match, typename... Args>
18348  inline int overload_match(Match&& matchfx, lua_State* L, int start, Args&&... args) {
18349  int fxarity = lua_gettop(L) - (start - 1);
18350  return overload_match_arity<Functions...>(std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
18351  }
18352 
18353  template <typename T, typename... TypeLists, typename Match, typename... Args>
18354  inline int construct_match(Match&& matchfx, lua_State* L, int fxarity, int start, Args&&... args) {
18355  // use same overload resolution matching as all other parts of the framework
18357  std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
18358  }
18359 
18360  template <typename T, bool checked, bool clean_stack, typename... TypeLists>
18362  static const auto& meta = usertype_traits<T>::metatable();
18363  int argcount = lua_gettop(L);
18365  argcount -= static_cast<int>(syntax);
18366 
18367  T* obj = detail::usertype_allocate<T>(L);
18368  reference userdataref(L, -1);
18369  stack::stack_detail::undefined_metatable umf(L, &meta[0], &stack::stack_detail::set_undefined_methods_on<T>);
18370 
18371  // put userdata at the first index
18372  lua_insert(L, 1);
18373  construct_match<T, TypeLists...>(constructor_match<T, checked, clean_stack>(obj, userdataref, umf), L, argcount, 1 + static_cast<int>(syntax));
18374 
18375  userdataref.push();
18376  return 1;
18377  }
18378 
18379  template <typename T, bool checked, bool clean_stack, typename... TypeLists>
18380  inline int construct(lua_State* L) {
18381  return detail::static_trampoline<&construct_trampolined<T, checked, clean_stack, TypeLists...>>(L);
18382  }
18383 
18384  template <typename F, bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename = void>
18386  template <typename Fx, typename... Args>
18387  static int call(lua_State* L, Fx&& f, Args&&... args) {
18388  using uFx = meta::unqualified_t<Fx>;
18389  static constexpr bool is_ref = is_lua_reference_v<uFx>;
18390  if constexpr (is_ref) {
18391  if constexpr (is_index) {
18392  return stack::push(L, std::forward<Fx>(f), std::forward<Args>(args)...);
18393  }
18394  else {
18395  std::forward<Fx>(f) = stack::unqualified_get<F>(L, boost + (is_variable ? 3 : 1));
18396  return 0;
18397  }
18398  }
18399  else {
18400  using wrap = wrapper<uFx>;
18401  using traits_type = typename wrap::traits_type;
18402  using fp_t = typename traits_type::function_pointer_type;
18403  constexpr bool is_function_pointer_convertible = std::is_class_v<uFx> && std::is_convertible_v<std::decay_t<Fx>, fp_t>;
18404  if constexpr (is_function_pointer_convertible) {
18405  fp_t fx = f;
18407  L, fx, std::forward<Args>(args)...);
18408  }
18409  else {
18410  using returns_list = typename wrap::returns_list;
18411  using args_list = typename wrap::free_args_list;
18412  using caller = typename wrap::caller;
18413  return stack::call_into_lua<checked, clean_stack>(
18414  returns_list(), args_list(), L, boost + 1, caller(), std::forward<Fx>(f), std::forward<Args>(args)...);
18415  }
18416  }
18417  }
18418  };
18419 
18420  template <typename T, bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
18421  struct agnostic_lua_call_wrapper<var_wrapper<T>, is_index, is_variable, checked, boost, clean_stack, C> {
18422  template <typename F>
18423  static int call(lua_State* L, F&& f) {
18424  if constexpr (is_index) {
18425  constexpr bool is_stack = is_stack_based_v<meta::unqualified_t<decltype(detail::unwrap(f.value()))>>;
18426  if constexpr (clean_stack && !is_stack) {
18427  lua_settop(L, 0);
18428  }
18429  return stack::push_reference(L, detail::unwrap(f.value()));
18430  }
18431  else {
18432  if constexpr (std::is_const_v<meta::unwrapped_t<T>>) {
18433  (void)f;
18434  return luaL_error(L, "sol: cannot write to a readonly (const) variable");
18435  }
18436  else {
18437  using R = meta::unwrapped_t<T>;
18438  if constexpr (std::is_assignable_v<std::add_lvalue_reference_t<meta::unqualified_t<R>>, R>) {
18439  detail::unwrap(f.value()) = stack::unqualified_get<meta::unwrapped_t<T>>(L, boost + (is_variable ? 3 : 1));
18440  if (clean_stack) {
18441  lua_settop(L, 0);
18442  }
18443  return 0;
18444  }
18445  else {
18446  return luaL_error(L, "sol: cannot write to this variable: copy assignment/constructor not available");
18447  }
18448  }
18449  }
18450  }
18451  };
18452 
18453  template <bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
18454  struct agnostic_lua_call_wrapper<lua_CFunction_ref, is_index, is_variable, checked, boost, clean_stack, C> {
18455  static int call(lua_State* L, lua_CFunction_ref f) {
18456  return f(L);
18457  }
18458  };
18459 
18460  template <bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
18461  struct agnostic_lua_call_wrapper<lua_CFunction, is_index, is_variable, checked, boost, clean_stack, C> {
18462  static int call(lua_State* L, lua_CFunction f) {
18463  return f(L);
18464  }
18465  };
18466 
18467 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE)
18468  template <bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
18469  struct agnostic_lua_call_wrapper<detail::lua_CFunction_noexcept, is_index, is_variable, checked, boost, clean_stack, C> {
18471  return f(L);
18472  }
18473  };
18474 #endif // noexcept function types
18475 
18476  template <bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
18477  struct agnostic_lua_call_wrapper<detail::no_prop, is_index, is_variable, checked, boost, clean_stack, C> {
18478  static int call(lua_State* L, const detail::no_prop&) {
18479  return luaL_error(L, is_index ? "sol: cannot read from a writeonly property" : "sol: cannot write to a readonly property");
18480  }
18481  };
18482 
18483  template <bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
18484  struct agnostic_lua_call_wrapper<no_construction, is_index, is_variable, checked, boost, clean_stack, C> {
18485  static int call(lua_State* L, const no_construction&) {
18487  }
18488  };
18489 
18490  template <typename... Args, bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
18491  struct agnostic_lua_call_wrapper<bases<Args...>, is_index, is_variable, checked, boost, clean_stack, C> {
18492  static int call(lua_State*, const bases<Args...>&) {
18493  // Uh. How did you even call this, lul
18494  return 0;
18495  }
18496  };
18497 
18498  template <typename T, bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
18499  struct agnostic_lua_call_wrapper<std::reference_wrapper<T>, is_index, is_variable, checked, boost, clean_stack, C> {
18500  static int call(lua_State* L, std::reference_wrapper<T> f) {
18502  return alcw.call(L, f.get());
18503  }
18504  };
18505 
18506  template <typename T, typename F, bool is_index, bool is_variable, bool checked = detail::default_safe_function_calls, int boost = 0,
18507  bool clean_stack = true, typename = void>
18509  template <typename Fx, typename... Args>
18510  static int call(lua_State* L, Fx&& fx, Args&&... args) {
18511  if constexpr (std::is_member_function_pointer_v<F>) {
18512  using wrap = wrapper<F>;
18513  using object_type = typename wrap::object_type;
18514  if constexpr (sizeof...(Args) < 1) {
18515  using Ta = meta::conditional_t<std::is_void_v<T>, object_type, T>;
18516  static_assert(std::is_base_of_v<object_type, Ta>,
18517  "It seems like you might have accidentally bound a class type with a member function method that does not correspond to the "
18518  "class. For example, there could be a small type in your new_usertype<T>(...) binding, where you specify one class \"T\" "
18519  "but then bind member methods from a complete unrelated class. Check things over!");
18520 #if SOL_IS_ON(SOL_SAFE_USERTYPE)
18521  auto maybeo = stack::check_get<Ta*>(L, 1);
18522  if (!maybeo || maybeo.value() == nullptr) {
18523  return luaL_error(L,
18524  "sol: received nil for 'self' argument (use ':' for accessing member functions, make sure member variables are "
18525  "preceeded by the "
18526  "actual object with '.' syntax)");
18527  }
18528  object_type* o = static_cast<object_type*>(maybeo.value());
18529  return call(L, std::forward<Fx>(fx), *o);
18530 #else
18531  object_type& o = static_cast<object_type&>(*stack::unqualified_get<non_null<Ta*>>(L, 1));
18532  return call(L, std::forward<Fx>(fx), o);
18533 #endif // Safety
18534  }
18535  else {
18536  using returns_list = typename wrap::returns_list;
18537  using args_list = typename wrap::args_list;
18538  using caller = typename wrap::caller;
18539  return stack::call_into_lua<checked, clean_stack>(
18540  returns_list(), args_list(), L, boost + (is_variable ? 3 : 2), caller(), std::forward<Fx>(fx), std::forward<Args>(args)...);
18541  }
18542  }
18543  else if constexpr (std::is_member_object_pointer_v<F>) {
18544  using wrap = wrapper<F>;
18545  using object_type = typename wrap::object_type;
18546  if constexpr (is_index) {
18547  if constexpr (sizeof...(Args) < 1) {
18548  using Ta = meta::conditional_t<std::is_void_v<T>, object_type, T>;
18549  static_assert(std::is_base_of_v<object_type, Ta>,
18550  "It seems like you might have accidentally bound a class type with a member function method that does not correspond "
18551  "to the class. For example, there could be a small type in your new_usertype<T>(...) binding, where you specify one "
18552  "class \"T\" but then bind member methods from a complete unrelated class. Check things over!");
18553 #if SOL_IS_ON(SOL_SAFE_USERTYPE)
18554  auto maybeo = stack::check_get<Ta*>(L, 1);
18555  if (!maybeo || maybeo.value() == nullptr) {
18556  if (is_variable) {
18557  return luaL_error(L, "sol: 'self' argument is lua_nil (bad '.' access?)");
18558  }
18559  return luaL_error(L, "sol: 'self' argument is lua_nil (pass 'self' as first argument)");
18560  }
18561  object_type* o = static_cast<object_type*>(maybeo.value());
18562  return call(L, std::forward<Fx>(fx), *o);
18563 #else
18564  object_type& o = static_cast<object_type&>(*stack::get<non_null<Ta*>>(L, 1));
18565  return call(L, std::forward<Fx>(fx), o);
18566 #endif // Safety
18567  }
18568  else {
18569  using returns_list = typename wrap::returns_list;
18570  using caller = typename wrap::caller;
18571  return stack::call_into_lua<checked, clean_stack>(returns_list(),
18572  types<>(),
18573  L,
18574  boost + (is_variable ? 3 : 2),
18575  caller(),
18576  std::forward<Fx>(fx),
18577  std::forward<Args>(args)...);
18578  }
18579  }
18580  else {
18581  using traits_type = lua_bind_traits<F>;
18582  using return_type = typename traits_type::return_type;
18583  constexpr bool ret_is_const = std::is_const_v<std::remove_reference_t<return_type>>;
18584  if constexpr (ret_is_const) {
18585  (void)fx;
18586  (void)detail::swallow { 0, (static_cast<void>(args), 0)... };
18587  return luaL_error(L, "sol: cannot write to a readonly (const) variable");
18588  }
18589  else {
18590  using u_return_type = meta::unqualified_t<return_type>;
18591  constexpr bool is_assignable = std::is_copy_assignable_v<u_return_type> || std::is_array_v<u_return_type>;
18592  if constexpr (!is_assignable) {
18593  (void)fx;
18594  (void)detail::swallow { 0, ((void)args, 0)... };
18595  return luaL_error(L, "sol: cannot write to this variable: copy assignment/constructor not available");
18596  }
18597  else {
18598  using args_list = typename wrap::args_list;
18599  using caller = typename wrap::caller;
18600  if constexpr (sizeof...(Args) > 0) {
18601  return stack::call_into_lua<checked, clean_stack>(types<void>(),
18602  args_list(),
18603  L,
18604  boost + (is_variable ? 3 : 2),
18605  caller(),
18606  std::forward<Fx>(fx),
18607  std::forward<Args>(args)...);
18608  }
18609  else {
18610  using Ta = meta::conditional_t<std::is_void_v<T>, object_type, T>;
18611 #if SOL_IS_ON(SOL_SAFE_USERTYPE)
18612  auto maybeo = stack::check_get<Ta*>(L, 1);
18613  if (!maybeo || maybeo.value() == nullptr) {
18614  if (is_variable) {
18615  return luaL_error(L, "sol: received nil for 'self' argument (bad '.' access?)");
18616  }
18617  return luaL_error(L, "sol: received nil for 'self' argument (pass 'self' as first argument)");
18618  }
18619  object_type* po = static_cast<object_type*>(maybeo.value());
18620  object_type& o = *po;
18621 #else
18622  object_type& o = static_cast<object_type&>(*stack::get<non_null<Ta*>>(L, 1));
18623 #endif // Safety
18624 
18625  return stack::call_into_lua<checked, clean_stack>(
18626  types<void>(), args_list(), L, boost + (is_variable ? 3 : 2), caller(), std::forward<Fx>(fx), o);
18627  }
18628  }
18629  }
18630  }
18631  }
18632  else {
18634  return alcw.call(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
18635  }
18636  }
18637  };
18638 
18639  template <typename T, typename F, bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
18640  struct lua_call_wrapper<T, readonly_wrapper<F>, is_index, is_variable, checked, boost, clean_stack, C> {
18642  using wrap = wrapper<F>;
18643  using object_type = typename wrap::object_type;
18644 
18645  static int call(lua_State* L, readonly_wrapper<F>&& rw) {
18646  if constexpr (!is_index) {
18647  (void)rw;
18648  return luaL_error(L, "sol: cannot write to a sol::readonly variable");
18649  }
18650  else {
18652  return lcw.call(L, std::move(rw.value()));
18653  }
18654  }
18655 
18656  static int call(lua_State* L, readonly_wrapper<F>&& rw, object_type& o) {
18657  if constexpr (!is_index) {
18658  (void)o;
18659  return call(L, std::move(rw));
18660  }
18661  else {
18663  return lcw.call(L, rw.value(), o);
18664  }
18665  }
18666 
18667  static int call(lua_State* L, const readonly_wrapper<F>& rw) {
18668  if constexpr (!is_index) {
18669  (void)rw;
18670  return luaL_error(L, "sol: cannot write to a sol::readonly variable");
18671  }
18672  else {
18674  return lcw.call(L, rw.value());
18675  }
18676  }
18677 
18678  static int call(lua_State* L, const readonly_wrapper<F>& rw, object_type& o) {
18679  if constexpr (!is_index) {
18680  (void)o;
18681  return call(L, rw);
18682  }
18683  else {
18685  return lcw.call(L, rw.value(), o);
18686  }
18687  }
18688  };
18689 
18690  template <typename T, typename... Args, bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
18691  struct lua_call_wrapper<T, constructor_list<Args...>, is_index, is_variable, checked, boost, clean_stack, C> {
18692  typedef constructor_list<Args...> F;
18693 
18694  static int call(lua_State* L, F&) {
18695  const auto& meta = usertype_traits<T>::metatable();
18696  int argcount = lua_gettop(L);
18698  argcount -= static_cast<int>(syntax);
18699 
18700  T* obj = detail::usertype_allocate<T>(L);
18701  reference userdataref(L, -1);
18702  stack::stack_detail::undefined_metatable umf(L, &meta[0], &stack::stack_detail::set_undefined_methods_on<T>);
18703 
18704  // put userdata at the first index
18705  lua_insert(L, 1);
18706  // Because of the way constructors work,
18707  // we have to kill the data, but only if the cosntructor is successfulyl invoked...
18708  // if it's not successfully invoked and we panic,
18709  // we cannot actually deallcoate/delete the data.
18710  construct_match<T, Args...>(
18711  constructor_match<T, checked, clean_stack>(obj, userdataref, umf), L, argcount, boost + 1 + 1 + static_cast<int>(syntax));
18712 
18713  userdataref.push();
18714  return 1;
18715  }
18716  };
18717 
18718  template <typename T, typename... Cxs, bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
18719  struct lua_call_wrapper<T, constructor_wrapper<Cxs...>, is_index, is_variable, checked, boost, clean_stack, C> {
18720  typedef constructor_wrapper<Cxs...> F;
18721 
18722  struct onmatch {
18723  template <typename Fx, std::size_t I, typename... R, typename... Args>
18725  const auto& meta = usertype_traits<T>::metatable();
18726  T* obj = detail::usertype_allocate<T>(L);
18727  reference userdataref(L, -1);
18728  stack::stack_detail::undefined_metatable umf(L, &meta[0], &stack::stack_detail::set_undefined_methods_on<T>);
18729  umf();
18730 
18731  auto& func = std::get<I>(f.functions);
18732  // put userdata at the first index
18733  lua_insert(L, 1);
18734  stack::call_into_lua<checked, clean_stack>(r, a, L, boost + 1 + start, func, detail::implicit_wrapper<T>(obj));
18735 
18736  userdataref.push();
18737  return 1;
18738  }
18739  };
18740 
18741  static int call(lua_State* L, F& f) {
18743  int syntaxval = static_cast<int>(syntax);
18744  int argcount = lua_gettop(L) - syntaxval;
18745  return construct_match<T, meta::pop_front_type_t<meta::function_args_t<Cxs>>...>(onmatch(), L, argcount, 1 + syntaxval, f);
18746  }
18747  };
18748 
18749  template <typename T, typename Fx, bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
18750  struct lua_call_wrapper<T, destructor_wrapper<Fx>, is_index, is_variable, checked, boost, clean_stack, C> {
18751 
18752  template <typename F>
18753  static int call(lua_State* L, F&& f) {
18754  if constexpr (std::is_void_v<Fx>) {
18755  return detail::usertype_alloc_destroy<T>(L);
18756  }
18757  else {
18758  using uFx = meta::unqualified_t<Fx>;
18760  return lcw.call(L, std::forward<F>(f).fx);
18761  }
18762  }
18763  };
18764 
18765  template <typename T, typename... Fs, bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
18766  struct lua_call_wrapper<T, overload_set<Fs...>, is_index, is_variable, checked, boost, clean_stack, C> {
18767  typedef overload_set<Fs...> F;
18768 
18769  struct on_match {
18770  template <typename Fx, std::size_t I, typename... R, typename... Args>
18772  auto& f = std::get<I>(fx.functions);
18774  }
18775  };
18776 
18777  static int call(lua_State* L, F& fx) {
18778  return overload_match_arity<Fs...>(on_match(), L, lua_gettop(L), 1, fx);
18779  }
18780  };
18781 
18782  template <typename T, typename... Fs, bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
18783  struct lua_call_wrapper<T, factory_wrapper<Fs...>, is_index, is_variable, checked, boost, clean_stack, C> {
18784  typedef factory_wrapper<Fs...> F;
18785 
18786  struct on_match {
18787  template <typename Fx, std::size_t I, typename... R, typename... Args>
18789  auto& f = std::get<I>(fx.functions);
18791  }
18792  };
18793 
18794  static int call(lua_State* L, F& fx) {
18795  return overload_match_arity<Fs...>(on_match(), L, lua_gettop(L) - boost, 1 + boost, fx);
18796  }
18797  };
18798 
18799  template <typename T, typename R, typename W, bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
18800  struct lua_call_wrapper<T, property_wrapper<R, W>, is_index, is_variable, checked, boost, clean_stack, C> {
18803  typedef wrapper<U> wrap;
18806 
18807  template <typename F, typename... Args>
18808  static int call(lua_State* L, F&& f, Args&&... args) {
18809  constexpr bool is_specialized = meta::any<std::is_same<U, detail::no_prop>,
18813  std::is_member_pointer<U>>::value;
18814  if constexpr (is_specialized) {
18815  if constexpr (is_index) {
18816  decltype(auto) p = f.read();
18817  lua_call_wrapper<T, meta::unqualified_t<decltype(p)>, is_index, is_variable, checked, boost, clean_stack> lcw {};
18818  return lcw.call(L, p, std::forward<Args>(args)...);
18819  }
18820  else {
18821  decltype(auto) p = f.write();
18822  lua_call_wrapper<T, meta::unqualified_t<decltype(p)>, is_index, is_variable, checked, boost, clean_stack> lcw {};
18823  return lcw.call(L, p, std::forward<Args>(args)...);
18824  }
18825  }
18826  else {
18827  constexpr bool non_class_object_type = meta::any<std::is_void<object_type>,
18829  if constexpr (non_class_object_type) {
18830  // The type being void means we don't have any arguments, so it might be a free functions?
18831  using args_list = typename traits_type::free_args_list;
18832  using returns_list = typename wrap::returns_list;
18833  using caller = typename wrap::caller;
18834  if constexpr (is_index) {
18835  decltype(auto) pf = f.read();
18836  return stack::call_into_lua<checked, clean_stack>(
18837  returns_list(), args_list(), L, boost + (is_variable ? 3 : 2), caller(), pf);
18838  }
18839  else {
18840  decltype(auto) pf = f.write();
18841  return stack::call_into_lua<checked, clean_stack>(
18842  returns_list(), args_list(), L, boost + (is_variable ? 3 : 2), caller(), pf);
18843  }
18844  }
18845  else {
18847  using Ta = T;
18848  using Oa = std::remove_pointer_t<object_type>;
18849 #if SOL_IS_ON(SOL_SAFE_USERTYPE)
18850  auto maybeo = stack::check_get<Ta*>(L, 1);
18851  if (!maybeo || maybeo.value() == nullptr) {
18852  if (is_variable) {
18853  return luaL_error(L, "sol: 'self' argument is lua_nil (bad '.' access?)");
18854  }
18855  return luaL_error(L, "sol: 'self' argument is lua_nil (pass 'self' as first argument)");
18856  }
18857  Oa* o = static_cast<Oa*>(maybeo.value());
18858 #else
18859  Oa* o = static_cast<Oa*>(stack::get<non_null<Ta*>>(L, 1));
18860 #endif // Safety
18861  using returns_list = typename wrap::returns_list;
18862  using caller = typename wrap::caller;
18863  if constexpr (is_index) {
18864  decltype(auto) pf = f.read();
18865  return stack::call_into_lua<checked, clean_stack>(
18866  returns_list(), args_list(), L, boost + (is_variable ? 3 : 2), caller(), pf, detail::implicit_wrapper<Oa>(*o));
18867  }
18868  else {
18869  decltype(auto) pf = f.write();
18870  return stack::call_into_lua<checked, clean_stack>(
18871  returns_list(), args_list(), L, boost + (is_variable ? 3 : 2), caller(), pf, detail::implicit_wrapper<Oa>(*o));
18872  }
18873  }
18874  }
18875  }
18876  };
18877 
18878  template <typename T, typename V, bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
18879  struct lua_call_wrapper<T, protect_t<V>, is_index, is_variable, checked, boost, clean_stack, C> {
18880  typedef protect_t<V> F;
18881 
18882  template <typename... Args>
18883  static int call(lua_State* L, F& fx, Args&&... args) {
18885  }
18886  };
18887 
18888  template <typename T, typename F, typename... Policies, bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
18889  struct lua_call_wrapper<T, policy_wrapper<F, Policies...>, is_index, is_variable, checked, boost, clean_stack, C> {
18890  typedef policy_wrapper<F, Policies...> P;
18891 
18892  template <std::size_t... In>
18893  static int call(std::index_sequence<In...>, lua_State* L, P& fx) {
18895  (void)detail::swallow { int(), (policy_detail::handle_policy(std::get<In>(fx.policies), L, pushed), int())... };
18896  return pushed;
18897  }
18898 
18899  static int call(lua_State* L, P& fx) {
18900  typedef typename P::indices indices;
18901  return call(indices(), L, fx);
18902  }
18903  };
18904 
18905  template <typename T, typename Y, bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
18906  struct lua_call_wrapper<T, yielding_t<Y>, is_index, is_variable, checked, boost, clean_stack, C> {
18907  template <typename F>
18908  static int call(lua_State* L, F&& f) {
18909  return lua_call_wrapper<T, meta::unqualified_t<Y>, is_index, is_variable, checked, boost, clean_stack> {}.call(L, f.func);
18910  }
18911  };
18912 
18913  template <typename T, typename Sig, typename P, bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
18914  struct lua_call_wrapper<T, function_arguments<Sig, P>, is_index, is_variable, checked, boost, clean_stack, C> {
18915  static int call(lua_State* L, const function_arguments<Sig, P>& f) {
18916  lua_call_wrapper<T, meta::unqualified_t<P>, is_index, is_variable, checked, boost, clean_stack> lcw {};
18917  return lcw.call(L, std::get<0>(f.arguments));
18918  }
18919 
18921  lua_call_wrapper<T, meta::unqualified_t<P>, is_index, is_variable, checked, boost, clean_stack> lcw {};
18922  return lcw.call(L, std::get<0>(f.arguments));
18923  }
18924 
18926  lua_call_wrapper<T, meta::unqualified_t<P>, is_index, is_variable, checked, boost, clean_stack> lcw {};
18927  return lcw.call(L, std::get<0>(std::move(f.arguments)));
18928  }
18929  };
18930 
18931  template <typename T, bool is_index, bool is_variable, int boost = 0, bool checked = detail::default_safe_function_calls, bool clean_stack = true,
18932  typename Fx, typename... Args>
18933  inline int call_wrapped(lua_State* L, Fx&& fx, Args&&... args) {
18934  using uFx = meta::unqualified_t<Fx>;
18935  if constexpr (meta::is_specialization_of_v<uFx, yielding_t>) {
18936  using real_fx = meta::unqualified_t<decltype(std::forward<Fx>(fx).func)>;
18938  return lcw.call(L, std::forward<Fx>(fx).func, std::forward<Args>(args)...);
18939  }
18940  else {
18942  return lcw.call(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
18943  }
18944  }
18945 
18946  template <typename T, bool is_index, bool is_variable, typename F, int start = 1, bool checked = detail::default_safe_function_calls,
18947  bool clean_stack = true>
18948  inline int call_user(lua_State* L) {
18949  auto& fx = stack::unqualified_get<user<F>>(L, upvalue_index(start));
18950  using uFx = meta::unqualified_t<F>;
18951  int nr = call_wrapped<T, is_index, is_variable, 0, checked, clean_stack>(L, fx);
18952  if constexpr (meta::is_specialization_of_v<uFx, yielding_t>) {
18953  return lua_yield(L, nr);
18954  }
18955  else {
18956  return nr;
18957  }
18958  }
18959 
18960  template <typename T, typename = void>
18962 
18963  template <typename T>
18964  struct is_var_bind<T, std::enable_if_t<std::is_member_object_pointer<T>::value>> : std::true_type { };
18965 
18966  template <typename T>
18967  struct is_var_bind<T, std::enable_if_t<is_lua_reference_or_proxy<T>::value>> : std::true_type { };
18968 
18969  template <>
18970  struct is_var_bind<detail::no_prop> : std::true_type { };
18971 
18972  template <typename R, typename W>
18974 
18975  template <typename T>
18977 
18978  template <typename T>
18979  struct is_var_bind<readonly_wrapper<T>> : is_var_bind<meta::unqualified_t<T>> { };
18980 
18981  template <typename F, typename... Policies>
18982  struct is_var_bind<policy_wrapper<F, Policies...>> : is_var_bind<meta::unqualified_t<F>> { };
18983  } // namespace call_detail
18984 
18985  template <typename T>
18986  struct is_variable_binding : call_detail::is_var_bind<meta::unqualified_t<T>> { };
18987 
18988  template <typename T>
18990 
18991  template <typename T>
18992  struct is_function_binding : meta::neg<is_variable_binding<T>> { };
18993 
18994 } // namespace sol
18995 
18996 // end of sol/call.hpp
18997 
18998 namespace sol {
18999  namespace function_detail {
19000  template <typename F, F fx>
19002  typedef meta::bind_traits<meta::unqualified_t<F>> traits_type;
19003  typedef typename traits_type::args_list args_list;
19005  return stack::call_into_lua(return_type(), args_list(), L, 1, fx);
19006  }
19007 
19008  template <typename R, typename V, V, typename T>
19010  return luaL_error(L, "cannot write to this type: copy assignment/constructor not available");
19011  }
19012 
19013  template <typename R, typename V, V variable, typename T>
19014  inline int call_set_assignable(std::true_type, lua_State* L, T&& mem) {
19015  (mem.*variable) = stack::get<R>(L, 2);
19016  return 0;
19017  }
19018 
19019  template <typename R, typename V, V, typename T>
19021  return luaL_error(L, "cannot write to a const variable");
19022  }
19023 
19024  template <typename R, typename V, V variable, typename T>
19025  inline int call_set_variable(std::true_type, lua_State* L, T&& mem) {
19026  return call_set_assignable<R, V, variable>(std::is_assignable<std::add_lvalue_reference_t<R>, R>(), L, std::forward<T>(mem));
19027  }
19028 
19029  template <typename V, V variable>
19031  typedef meta::bind_traits<meta::unqualified_t<V>> traits_type;
19032  typedef typename traits_type::object_type T;
19033  typedef typename traits_type::return_type R;
19034  auto& mem = stack::get<T>(L, 1);
19035  switch (lua_gettop(L)) {
19036  case 1: {
19037  decltype(auto) r = (mem.*variable);
19038  stack::push_reference(L, std::forward<decltype(r)>(r));
19039  return 1;
19040  }
19041  case 2:
19042  return call_set_variable<R, V, variable>(meta::neg<std::is_const<R>>(), L, mem);
19043  default:
19044  return luaL_error(L, "incorrect number of arguments to member variable function call");
19045  }
19046  }
19047 
19048  template <typename F, F fx>
19050  return call_wrapper_variable<F, fx>(std::is_member_object_pointer<F>(), L);
19051  }
19052 
19053  template <typename F, F fx>
19055  return call_detail::call_wrapped<void, false, false>(L, fx);
19056  }
19057 
19058  template <typename F, F fx>
19060  return call_wrapper_function<F, fx>(std::is_member_function_pointer<meta::unqualified_t<F>>(), L);
19061  }
19062 
19063  template <typename... Fxs>
19065  template <typename Fx, std::size_t I, typename R, typename... Args>
19067  typedef meta::at_in_pack_t<I, Fxs...> target;
19068  return target::call(L);
19069  }
19070  };
19071 
19072  template <typename F, F fx>
19074  return fx(L);
19075  }
19076 
19077  template <typename F, F fx>
19079 #ifdef __clang__
19080  return detail::trampoline(L, function_detail::call_wrapper_entry<F, fx>);
19081 #else
19082  return detail::typed_static_trampoline<decltype(&function_detail::call_wrapper_entry<F, fx>), (&function_detail::call_wrapper_entry<F, fx>)>(L);
19083 #endif // fuck you clang :c
19084  }
19085 
19086  } // namespace function_detail
19087 
19088  template <typename F, F fx>
19089  inline int c_call(lua_State* L) {
19090  typedef meta::unqualified_t<F> Fu;
19091  typedef std::integral_constant<bool,
19092  std::is_same<Fu, lua_CFunction>::value
19093 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE)
19094  || std::is_same<Fu, detail::lua_CFunction_noexcept>::value
19095 #endif
19096  >
19097  is_raw;
19098  return function_detail::c_call_raw<F, fx>(is_raw(), L);
19099  }
19100 
19101  template <typename F, F f>
19102  struct wrap {
19103  typedef F type;
19104 
19105  static int call(lua_State* L) noexcept(noexcept(c_call<type, f>(L))) {
19106  return c_call<type, f>(L);
19107  }
19108  };
19109 
19110  template <typename... Fxs>
19111  inline int c_call(lua_State* L) {
19112  if constexpr (sizeof...(Fxs) < 2) {
19113  using target = meta::at_in_pack_t<0, Fxs...>;
19114  return target::call(L);
19115  }
19116  else {
19118  }
19119  }
19120 
19121 } // namespace sol
19122 
19123 // end of sol/function_types_templated.hpp
19124 
19125 // beginning of sol/function_types_stateless.hpp
19126 
19127 namespace sol { namespace function_detail {
19128  template <typename Function>
19130  using function_type = std::remove_pointer_t<std::decay_t<Function>>;
19132 
19133  static int real_call(lua_State* L)
19134 #if SOL_IS_ON(SOL_COMPILER_VCXX)
19135  // MSVC is broken, what a surprise...
19136 #else
19137  noexcept(traits_type::is_noexcept)
19138 #endif
19139  {
19140  auto udata = stack::stack_detail::get_as_upvalues<function_type*>(L);
19141  function_type* fx = udata.first;
19142  return call_detail::call_wrapped<void, true, false>(L, fx);
19143  }
19144 
19145  template <bool is_yielding, bool no_trampoline>
19146  static int call(lua_State* L) {
19147  int nr;
19148  if constexpr (no_trampoline) {
19149  nr = real_call(L);
19150  }
19151  else {
19152  nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
19153  }
19154  if (is_yielding) {
19155  return lua_yield(L, nr);
19156  }
19157  else {
19158  return nr;
19159  }
19160  }
19161  };
19162 
19163  template <typename T, typename Function>
19165  typedef std::remove_pointer_t<std::decay_t<Function>> function_type;
19167 
19168  static int real_call(lua_State* L)
19169 #if SOL_IS_ON(SOL_COMPILER_VCXX)
19170  // MSVC is broken, what a surprise...
19171 #else
19172  noexcept(traits_type::is_noexcept)
19173 #endif
19174  {
19175  // Layout:
19176  // idx 1...n: verbatim data of member function pointer
19177  // idx n + 1: is the object's void pointer
19178  // We don't need to store the size, because the other side is templated
19179  // with the same member function pointer type
19180  function_type& memfx = stack::get<user<function_type>>(L, upvalue_index(2));
19181  auto& item = *static_cast<T*>(stack::get<void*>(L, upvalue_index(3)));
19182  return call_detail::call_wrapped<T, true, false, -1>(L, memfx, item);
19183  }
19184 
19185  template <bool is_yielding, bool no_trampoline>
19186  static int call(lua_State* L)
19187 #if SOL_IS_ON(SOL_COMPILER_VCXX)
19188  // MSVC is broken, what a surprise...
19189 #else
19190  noexcept(traits_type::is_noexcept)
19191 #endif
19192  {
19193  int nr;
19194  if constexpr (no_trampoline) {
19195  nr = real_call(L);
19196  }
19197  else {
19198  nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
19199  }
19200  if (is_yielding) {
19201  return lua_yield(L, nr);
19202  }
19203  else {
19204  return nr;
19205  }
19206  }
19207 
19209 #if SOL_IS_ON(SOL_COMPILER_VCXX)
19210  // MSVC is broken, what a surprise...
19211 #else
19212  noexcept(traits_type::is_noexcept)
19213 #endif
19214  {
19215  return call(L);
19216  }
19217  };
19218 
19219  template <typename T, typename Function>
19221  typedef std::remove_pointer_t<std::decay_t<Function>> function_type;
19223 
19224  static int real_call(lua_State* L)
19225 #if SOL_IS_ON(SOL_COMPILER_VCXX)
19226  // MSVC is broken, what a surprise...
19227 #else
19228  noexcept(traits_type::is_noexcept)
19229 #endif
19230  {
19231  // Layout:
19232  // idx 1...n: verbatim data of member variable pointer
19233  // idx n + 1: is the object's void pointer
19234  // We don't need to store the size, because the other side is templated
19235  // with the same member function pointer type
19236  auto memberdata = stack::stack_detail::get_as_upvalues<function_type>(L);
19237  auto objdata = stack::stack_detail::get_as_upvalues<T*>(L, memberdata.second);
19238  auto& mem = *objdata.first;
19239  function_type& var = memberdata.first;
19240  switch (lua_gettop(L)) {
19241  case 0:
19242  return call_detail::call_wrapped<T, true, false, -1>(L, var, mem);
19243  case 1:
19244  return call_detail::call_wrapped<T, false, false, -1>(L, var, mem);
19245  default:
19246  return luaL_error(L, "sol: incorrect number of arguments to member variable function");
19247  }
19248  }
19249 
19250  template <bool is_yielding, bool no_trampoline>
19251  static int call(lua_State* L)
19252 #if SOL_IS_ON(SOL_COMPILER_VCXX)
19253  // MSVC is broken, what a surprise...
19254 #else
19255  noexcept(traits_type::is_noexcept)
19256 #endif
19257  {
19258  int nr;
19259  if constexpr (no_trampoline) {
19260  nr = real_call(L);
19261  }
19262  else {
19263  nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
19264  }
19265  if (is_yielding) {
19266  return lua_yield(L, nr);
19267  }
19268  else {
19269  return nr;
19270  }
19271  }
19272 
19274 #if SOL_IS_ON(SOL_COMPILER_VCXX)
19275  // MSVC is broken, what a surprise...
19276 #else
19277  noexcept(traits_type::is_noexcept)
19278 #endif
19279  {
19280  return call(L);
19281  }
19282  };
19283 
19284  template <typename T, typename Function>
19286  typedef std::remove_pointer_t<std::decay_t<Function>> function_type;
19288 
19289  static int real_call(lua_State* L)
19290 #if SOL_IS_ON(SOL_COMPILER_VCXX)
19291  // MSVC is broken, what a surprise...
19292 #else
19293  noexcept(traits_type::is_noexcept)
19294 #endif
19295  {
19296  // Layout:
19297  // idx 1...n: verbatim data of member variable pointer
19298  // idx n + 1: is the object's void pointer
19299  // We don't need to store the size, because the other side is templated
19300  // with the same member function pointer type
19301  auto memberdata = stack::stack_detail::get_as_upvalues<function_type>(L);
19302  auto objdata = stack::stack_detail::get_as_upvalues<T*>(L, memberdata.second);
19303  auto& mem = *objdata.first;
19304  function_type& var = memberdata.first;
19305  switch (lua_gettop(L)) {
19306  case 0:
19307  return call_detail::call_wrapped<T, true, false, -1>(L, var, mem);
19308  default:
19309  return luaL_error(L, "sol: incorrect number of arguments to member variable function");
19310  }
19311  }
19312 
19313  template <bool is_yielding, bool no_trampoline>
19314  static int call(lua_State* L)
19315 #if SOL_IS_ON(SOL_COMPILER_VCXX)
19316  // MSVC is broken, what a surprise...
19317 #else
19318  noexcept(traits_type::is_noexcept)
19319 #endif
19320  {
19321  int nr;
19322  if constexpr (no_trampoline) {
19323  nr = real_call(L);
19324  }
19325  else {
19326  nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
19327  }
19328  if (is_yielding) {
19329  return lua_yield(L, nr);
19330  }
19331  else {
19332  return nr;
19333  }
19334  }
19335 
19337 #if SOL_IS_ON(SOL_COMPILER_VCXX)
19338  // MSVC is broken, what a surprise...
19339 #else
19340  noexcept(traits_type::is_noexcept)
19341 #endif
19342  {
19343  return call(L);
19344  }
19345  };
19346 
19347  template <typename T, typename Function>
19349  typedef std::remove_pointer_t<std::decay_t<Function>> function_type;
19351 
19352  static int real_call(lua_State* L)
19353 #if SOL_IS_ON(SOL_COMPILER_VCXX)
19354  // MSVC is broken, what a surprise...
19355 #else
19356  noexcept(traits_type::is_noexcept)
19357 #endif
19358  {
19359  // Layout:
19360  // idx 1...n: verbatim data of member variable pointer
19361  function_type& memfx = stack::get<user<function_type>>(L, upvalue_index(2));
19362  return call_detail::call_wrapped<T, false, false>(L, memfx);
19363  }
19364 
19365  template <bool is_yielding, bool no_trampoline>
19366  static int call(lua_State* L)
19367 #if SOL_IS_ON(SOL_COMPILER_VCXX)
19368  // MSVC is broken, what a surprise...
19369 #else
19370  noexcept(traits_type::is_noexcept)
19371 #endif
19372  {
19373  int nr;
19374  if constexpr (no_trampoline) {
19375  nr = real_call(L);
19376  }
19377  else {
19378  nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
19379  }
19380  if (is_yielding) {
19381  return lua_yield(L, nr);
19382  }
19383  else {
19384  return nr;
19385  }
19386  }
19387 
19389 #if SOL_IS_ON(SOL_COMPILER_VCXX)
19390  // MSVC is broken, what a surprise...
19391 #else
19392  noexcept(traits_type::is_noexcept)
19393 #endif
19394  {
19395  return call(L);
19396  }
19397  };
19398 
19399  template <typename T, typename Function>
19401  typedef std::remove_pointer_t<std::decay_t<Function>> function_type;
19402 
19403  static int real_call(lua_State* L) noexcept(std::is_nothrow_copy_assignable_v<T>) {
19404  // Layout:
19405  // idx 1...n: verbatim data of member variable pointer
19406  auto memberdata = stack::stack_detail::get_as_upvalues<function_type>(L);
19407  function_type& var = memberdata.first;
19408  switch (lua_gettop(L)) {
19409  case 1:
19410  return call_detail::call_wrapped<T, true, false>(L, var);
19411  case 2:
19412  return call_detail::call_wrapped<T, false, false>(L, var);
19413  default:
19414  return luaL_error(L, "sol: incorrect number of arguments to member variable function");
19415  }
19416  }
19417 
19418  template <bool is_yielding, bool no_trampoline>
19419  static int call(lua_State* L) noexcept(std::is_nothrow_copy_assignable_v<T>) {
19420  int nr;
19421  if constexpr (no_trampoline) {
19422  nr = real_call(L);
19423  }
19424  else {
19425  nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
19426  }
19427  if (is_yielding) {
19428  return lua_yield(L, nr);
19429  }
19430  else {
19431  return nr;
19432  }
19433  }
19434 
19435  int operator()(lua_State* L) noexcept(std::is_nothrow_copy_assignable_v<T>) {
19436  return call(L);
19437  }
19438  };
19439 
19440  template <typename T, typename Function>
19442  typedef std::remove_pointer_t<std::decay_t<Function>> function_type;
19444 
19445  static int real_call(lua_State* L) noexcept(std::is_nothrow_copy_assignable_v<T>) {
19446  // Layout:
19447  // idx 1...n: verbatim data of member variable pointer
19448  auto memberdata = stack::stack_detail::get_as_upvalues<function_type>(L);
19449  function_type& var = memberdata.first;
19450  switch (lua_gettop(L)) {
19451  case 1:
19452  return call_detail::call_wrapped<T, true, false>(L, var);
19453  default:
19454  return luaL_error(L, "sol: incorrect number of arguments to member variable function");
19455  }
19456  }
19457 
19458  template <bool is_yielding, bool no_trampoline>
19459  static int call(lua_State* L) noexcept(std::is_nothrow_copy_assignable_v<T>) {
19460  int nr;
19461  if constexpr (no_trampoline) {
19462  nr = real_call(L);
19463  }
19464  else {
19465  nr = detail::typed_static_trampoline<decltype(&real_call), (&real_call)>(L);
19466  }
19467  if (is_yielding) {
19468  return lua_yield(L, nr);
19469  }
19470  else {
19471  return nr;
19472  }
19473  }
19474 
19475  int operator()(lua_State* L) noexcept(std::is_nothrow_copy_assignable_v<T>) {
19476  return call(L);
19477  }
19478  };
19479 }} // namespace sol::function_detail
19480 
19481 // end of sol/function_types_stateless.hpp
19482 
19483 // beginning of sol/function_types_stateful.hpp
19484 
19485 namespace sol { namespace function_detail {
19486  template <typename Func, bool is_yielding, bool no_trampoline>
19488  typedef std::decay_t<meta::unwrap_unqualified_t<Func>> function_type;
19490 
19491  template <typename... Args>
19492  functor_function(function_type f, Args&&... args) noexcept(std::is_nothrow_constructible_v<function_type, function_type, Args...>)
19493  : invocation(std::move(f), std::forward<Args>(args)...) {
19494  }
19495 
19496  static int call(lua_State* L, functor_function& self) noexcept(noexcept(call_detail::call_wrapped<void, true, false>(L, self.invocation))) {
19497  int nr = call_detail::call_wrapped<void, true, false>(L, self.invocation);
19498  if (is_yielding) {
19499  return lua_yield(L, nr);
19500  }
19501  else {
19502  return nr;
19503  }
19504  }
19505 
19506  int operator()(lua_State* L) noexcept(noexcept(call_detail::call_wrapped<void, true, false>(L, invocation))) {
19507  if constexpr (no_trampoline) {
19508  return call(L, *this);
19509  }
19510  else {
19511  return detail::trampoline(L, &call, *this);
19512  }
19513  }
19514  };
19515 
19516  template <typename T, typename Function, bool is_yielding, bool no_trampoline>
19518  typedef std::remove_pointer_t<std::decay_t<Function>> function_type;
19524 
19525  template <typename... Args>
19526  member_function(function_type f, Args&&... args) noexcept(
19527  std::is_nothrow_constructible_v<function_type, function_type>&& std::is_nothrow_constructible_v<T, Args...>)
19528  : invocation(std::move(f)), member(std::forward<Args>(args)...) {
19529  }
19530 
19531  static int call(lua_State* L, member_function& self)
19532 #if SOL_IS_ON(SOL_COMPILER_VCXX)
19533  // MSVC is broken, what a surprise...
19534 #else
19535  noexcept(traits_type::is_noexcept)
19536 #endif
19537  {
19538  int nr = call_detail::call_wrapped<T, true, false, -1>(L, self.invocation, detail::unwrap(detail::deref(self.member)));
19539  if (is_yielding) {
19540  return lua_yield(L, nr);
19541  }
19542  else {
19543  return nr;
19544  }
19545  }
19546 
19548 #if SOL_IS_ON(SOL_COMPILER_VCXX)
19549  // MSVC is broken, what a surprise...
19550 #else
19551  noexcept(traits_type::is_noexcept)
19552 #endif
19553  {
19554  if constexpr (no_trampoline) {
19555  return call(L, *this);
19556  }
19557  else {
19558  return detail::trampoline(L, &call, *this);
19559  }
19560  }
19561  };
19562 
19563  template <typename T, typename Function, bool is_yielding, bool no_trampoline>
19565  typedef std::remove_pointer_t<std::decay_t<Function>> function_type;
19570  typedef std::add_lvalue_reference_t<meta::unwrapped_t<std::remove_reference_t<decltype(detail::deref(member))>>> M;
19571 
19572  template <typename... Args>
19573  member_variable(function_type v, Args&&... args) noexcept(
19574  std::is_nothrow_constructible_v<function_type, function_type>&& std::is_nothrow_constructible_v<T, Args...>)
19575  : var(std::move(v)), member(std::forward<Args>(args)...) {
19576  }
19577 
19578  static int call(lua_State* L, member_variable& self) noexcept(std::is_nothrow_copy_assignable_v<T>) {
19579  int nr;
19580  {
19581  M mem = detail::unwrap(detail::deref(self.member));
19582  switch (lua_gettop(L)) {
19583  case 0:
19584  nr = call_detail::call_wrapped<T, true, false, -1>(L, self.var, mem);
19585  break;
19586  case 1:
19587  nr = call_detail::call_wrapped<T, false, false, -1>(L, self.var, mem);
19588  break;
19589  default:
19590  nr = luaL_error(L, "sol: incorrect number of arguments to member variable function");
19591  break;
19592  }
19593  }
19594  if (is_yielding) {
19595  return lua_yield(L, nr);
19596  }
19597  else {
19598  return nr;
19599  }
19600  }
19601 
19602  int operator()(lua_State* L) noexcept(std::is_nothrow_copy_assignable_v<T>) {
19603  if constexpr (no_trampoline) {
19604  return call(L, *this);
19605  }
19606  else {
19607  return detail::trampoline(L, &call, *this);
19608  }
19609  }
19610  };
19611 }} // namespace sol::function_detail
19612 
19613 // end of sol/function_types_stateful.hpp
19614 
19615 // beginning of sol/function_types_overloaded.hpp
19616 
19617 namespace sol { namespace function_detail {
19618  template <int start_skew, typename... Functions>
19620  typedef std::tuple<Functions...> overload_list;
19621  typedef std::make_index_sequence<sizeof...(Functions)> indices;
19623 
19625  }
19626 
19627  overloaded_function(Functions... fxs) : overloads(fxs...) {
19628  }
19629 
19630  template <typename Fx, std::size_t I, typename... R, typename... Args>
19632  auto& func = std::get<I>(ol);
19633  int nr = call_detail::call_wrapped<void, true, false, start_skew>(L, func);
19634  return nr;
19635  }
19636 
19637  struct on_success {
19638  template <typename... Args>
19639  int operator()(Args&&... args) const {
19640  return call(std::forward<Args>(args)...);
19641  }
19642  };
19643 
19645  on_success call_obj {};
19646  return call_detail::overload_match<Functions...>(call_obj, L, 1 + start_skew, overloads);
19647  }
19648  };
19649 }} // namespace sol::function_detail
19650 
19651 // end of sol/function_types_overloaded.hpp
19652 
19653 // beginning of sol/resolve.hpp
19654 
19655 namespace sol {
19656 
19657 #ifndef __clang__
19658  // constexpr is fine for not-clang
19659 
19660  namespace detail {
19661  template <typename R, typename... Args, typename F, typename = std::invoke_result_t<meta::unqualified_t<F>, Args...>>
19662  inline constexpr auto resolve_i(types<R(Args...)>, F&&) -> R (meta::unqualified_t<F>::*)(Args...) {
19663  using Sig = R(Args...);
19664  typedef meta::unqualified_t<F> Fu;
19665  return static_cast<Sig Fu::*>(&Fu::operator());
19666  }
19667 
19668  template <typename F, typename U = meta::unqualified_t<F>>
19669  inline constexpr auto resolve_f(std::true_type, F&& f)
19670  -> decltype(resolve_i(types<meta::function_signature_t<decltype(&U::operator())>>(), std::forward<F>(f))) {
19671  return resolve_i(types<meta::function_signature_t<decltype(&U::operator())>>(), std::forward<F>(f));
19672  }
19673 
19674  template <typename F>
19675  inline constexpr void resolve_f(std::false_type, F&&) {
19676  static_assert(meta::call_operator_deducible_v<F>, "Cannot use no-template-parameter call with an overloaded functor: specify the signature");
19677  }
19678 
19679  template <typename F, typename U = meta::unqualified_t<F>>
19680  inline constexpr auto resolve_i(types<>, F&& f) -> decltype(resolve_f(meta::call_operator_deducible<U>(), std::forward<F>(f))) {
19681  return resolve_f(meta::call_operator_deducible<U> {}, std::forward<F>(f));
19682  }
19683 
19684  template <typename... Args, typename F, typename R = std::invoke_result_t<F&, Args...>>
19685  inline constexpr auto resolve_i(types<Args...>, F&& f) -> decltype(resolve_i(types<R(Args...)>(), std::forward<F>(f))) {
19686  return resolve_i(types<R(Args...)>(), std::forward<F>(f));
19687  }
19688 
19689  template <typename Sig, typename C>
19690  inline constexpr Sig C::*resolve_v(std::false_type, Sig C::*mem_func_ptr) {
19691  return mem_func_ptr;
19692  }
19693 
19694  template <typename Sig, typename C>
19695  inline constexpr Sig C::*resolve_v(std::true_type, Sig C::*mem_variable_ptr) {
19696  return mem_variable_ptr;
19697  }
19698  } // namespace detail
19699 
19700  template <typename... Args, typename R>
19701  inline constexpr auto resolve(R fun_ptr(Args...)) -> R (*)(Args...) {
19702  return fun_ptr;
19703  }
19704 
19705  template <typename Sig>
19706  inline constexpr Sig* resolve(Sig* fun_ptr) {
19707  return fun_ptr;
19708  }
19709 
19710  template <typename... Args, typename R, typename C>
19711  inline constexpr auto resolve(R (C::*mem_ptr)(Args...)) -> R (C::*)(Args...) {
19712  return mem_ptr;
19713  }
19714 
19715  template <typename Sig, typename C>
19716  inline constexpr Sig C::*resolve(Sig C::*mem_ptr) {
19717  return detail::resolve_v(std::is_member_object_pointer<Sig C::*>(), mem_ptr);
19718  }
19719 
19720  template <typename... Sig, typename F, meta::disable<std::is_function<meta::unqualified_t<F>>> = meta::enabler>
19721  inline constexpr auto resolve(F&& f) -> decltype(detail::resolve_i(types<Sig...>(), std::forward<F>(f))) {
19722  return detail::resolve_i(types<Sig...>(), std::forward<F>(f));
19723  }
19724 #else
19725 
19726  // Clang has distinct problems with constexpr arguments,
19727  // so don't use the constexpr versions inside of clang.
19728 
19729  namespace detail {
19730  template <typename R, typename... Args, typename F, typename = std::invoke_result_t<meta::unqualified_t<F>, Args...>>
19731  inline auto resolve_i(types<R(Args...)>, F&&) -> R (meta::unqualified_t<F>::*)(Args...) {
19732  using Sig = R(Args...);
19733  typedef meta::unqualified_t<F> Fu;
19734  return static_cast<Sig Fu::*>(&Fu::operator());
19735  }
19736 
19737  template <typename F, typename U = meta::unqualified_t<F>>
19738  inline auto resolve_f(std::true_type, F&& f)
19739  -> decltype(resolve_i(types<meta::function_signature_t<decltype(&U::operator())>>(), std::forward<F>(f))) {
19740  return resolve_i(types<meta::function_signature_t<decltype(&U::operator())>>(), std::forward<F>(f));
19741  }
19742 
19743  template <typename F>
19744  inline void resolve_f(std::false_type, F&&) {
19745  static_assert(meta::call_operator_deducible_v<F>, "Cannot use no-template-parameter call with an overloaded functor: specify the signature");
19746  }
19747 
19748  template <typename F, typename U = meta::unqualified_t<F>>
19749  inline auto resolve_i(types<>, F&& f) -> decltype(resolve_f(meta::call_operator_deducible<U>(), std::forward<F>(f))) {
19750  return resolve_f(meta::call_operator_deducible<U> {}, std::forward<F>(f));
19751  }
19752 
19753  template <typename... Args, typename F, typename R = std::invoke_result_t<F&, Args...>>
19754  inline auto resolve_i(types<Args...>, F&& f) -> decltype(resolve_i(types<R(Args...)>(), std::forward<F>(f))) {
19755  return resolve_i(types<R(Args...)>(), std::forward<F>(f));
19756  }
19757 
19758  template <typename Sig, typename C>
19759  inline Sig C::*resolve_v(std::false_type, Sig C::*mem_func_ptr) {
19760  return mem_func_ptr;
19761  }
19762 
19763  template <typename Sig, typename C>
19764  inline Sig C::*resolve_v(std::true_type, Sig C::*mem_variable_ptr) {
19765  return mem_variable_ptr;
19766  }
19767  } // namespace detail
19768 
19769  template <typename... Args, typename R>
19770  inline auto resolve(R fun_ptr(Args...)) -> R (*)(Args...) {
19771  return fun_ptr;
19772  }
19773 
19774  template <typename Sig>
19775  inline Sig* resolve(Sig* fun_ptr) {
19776  return fun_ptr;
19777  }
19778 
19779  template <typename... Args, typename R, typename C>
19780  inline auto resolve(R (C::*mem_ptr)(Args...)) -> R (C::*)(Args...) {
19781  return mem_ptr;
19782  }
19783 
19784  template <typename Sig, typename C>
19785  inline Sig C::*resolve(Sig C::*mem_ptr) {
19786  return detail::resolve_v(std::is_member_object_pointer<Sig C::*>(), mem_ptr);
19787  }
19788 
19789  template <typename... Sig, typename F>
19790  inline auto resolve(F&& f) -> decltype(detail::resolve_i(types<Sig...>(), std::forward<F>(f))) {
19791  return detail::resolve_i(types<Sig...>(), std::forward<F>(f));
19792  }
19793 
19794 #endif
19795 
19796 } // namespace sol
19797 
19798 // end of sol/resolve.hpp
19799 
19800 namespace sol {
19801  namespace function_detail {
19802  template <typename T>
19804  using type = T;
19805  };
19806 
19807  struct call_indicator { };
19808 
19809  template <bool yielding>
19812  int nr = cf(L);
19813  if constexpr (yielding) {
19814  return lua_yield(L, nr);
19815  }
19816  else {
19817  return nr;
19818  }
19819  }
19820 
19821  template <bool yielding>
19824  int nr = cf(L);
19825  if constexpr (yielding) {
19826  return lua_yield(L, nr);
19827  }
19828  else {
19829  return nr;
19830  }
19831  }
19832 
19834 
19835  template <bool is_yielding, bool no_trampoline, typename Fx, typename... Args>
19836  void select(lua_State* L, Fx&& fx, Args&&... args);
19837 
19838  template <bool is_yielding, bool no_trampoline, typename Fx, typename... Args>
19839  void select_set_fx(lua_State* L, Args&&... args) {
19840  lua_CFunction freefunc = no_trampoline ? function_detail::call<meta::unqualified_t<Fx>, 2, is_yielding>
19841  : detail::static_trampoline<function_detail::call<meta::unqualified_t<Fx>, 2, is_yielding>>;
19842 
19843  int upvalues = 0;
19844  upvalues += stack::push(L, nullptr);
19845  upvalues += stack::push<user<Fx>>(L, std::forward<Args>(args)...);
19846  stack::push(L, c_closure(freefunc, upvalues));
19847  }
19848 
19849  template <bool is_yielding, bool no_trampoline, typename R, typename... A, typename Fx, typename... Args>
19850  void select_convertible(types<R(A...)>, lua_State* L, Fx&& fx, Args&&... args) {
19851  using dFx = std::decay_t<meta::unwrap_unqualified_t<Fx>>;
19852  using fx_ptr_t = R (*)(A...);
19853  constexpr bool is_convertible = std::is_convertible_v<dFx, fx_ptr_t>;
19854  if constexpr (is_convertible) {
19855  fx_ptr_t fxptr = detail::unwrap(std::forward<Fx>(fx));
19856  select<is_yielding, no_trampoline>(L, std::move(fxptr), std::forward<Args>(args)...);
19857  }
19858  else {
19860  select_set_fx<is_yielding, no_trampoline, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
19861  }
19862  }
19863 
19864  template <bool is_yielding, bool no_trampoline, typename Fx, typename... Args>
19865  void select_convertible(types<>, lua_State* L, Fx&& fx, Args&&... args) {
19867  select_convertible<is_yielding, no_trampoline>(types<Sig>(), L, std::forward<Fx>(fx), std::forward<Args>(args)...);
19868  }
19869 
19870  template <bool is_yielding, bool no_trampoline, typename Fx, typename... Args>
19871  void select_member_variable(lua_State* L, Fx&& fx, Args&&... args) {
19872  using uFx = meta::unqualified_t<Fx>;
19873  if constexpr (sizeof...(Args) < 1) {
19874  using C = typename meta::bind_traits<uFx>::object_type;
19875  lua_CFunction freefunc = &function_detail::upvalue_this_member_variable<C, Fx>::template call<is_yielding, no_trampoline>;
19876 
19877  int upvalues = 0;
19878  upvalues += stack::push(L, nullptr);
19879  upvalues += stack::stack_detail::push_as_upvalues(L, fx);
19880  stack::push(L, c_closure(freefunc, upvalues));
19881  }
19882  else if constexpr (sizeof...(Args) < 2) {
19883  using Tu = typename meta::meta_detail::unqualified_non_alias<Args...>::type;
19884  constexpr bool is_reference = meta::is_specialization_of_v<Tu, std::reference_wrapper> || std::is_pointer_v<Tu>;
19885  if constexpr (meta::is_specialization_of_v<Tu, function_detail::class_indicator>) {
19886  lua_CFunction freefunc
19888 
19889  int upvalues = 0;
19890  upvalues += stack::push(L, nullptr);
19891  upvalues += stack::stack_detail::push_as_upvalues(L, fx);
19892  stack::push(L, c_closure(freefunc, upvalues));
19893  }
19894  else if constexpr (is_reference) {
19895  typedef std::decay_t<Fx> dFx;
19896  dFx memfxptr(std::forward<Fx>(fx));
19897  auto userptr = detail::ptr(std::forward<Args>(args)...);
19899  meta::unqualified_t<Fx>>::template call<is_yielding, no_trampoline>;
19900 
19901  int upvalues = 0;
19902  upvalues += stack::push(L, nullptr);
19903  upvalues += stack::stack_detail::push_as_upvalues(L, memfxptr);
19904  upvalues += stack::push(L, static_cast<void const*>(userptr));
19905  stack::push(L, c_closure(freefunc, upvalues));
19906  }
19907  else {
19908  using clean_fx = std::remove_pointer_t<std::decay_t<Fx>>;
19910  select_set_fx<is_yielding, no_trampoline, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
19911  }
19912  }
19913  else {
19914  using C = typename meta::bind_traits<uFx>::object_type;
19915  using clean_fx = std::remove_pointer_t<std::decay_t<Fx>>;
19917  select_set_fx<is_yielding, no_trampoline, F>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
19918  }
19919  }
19920 
19921  template <bool is_yielding, bool no_trampoline, typename Fx, typename T, typename... Args>
19922  void select_member_function_with(lua_State* L, Fx&& fx, T&& obj, Args&&... args) {
19923  using dFx = std::decay_t<Fx>;
19924  using Tu = meta::unqualified_t<T>;
19925  if constexpr (meta::is_specialization_of_v<Tu, function_detail::class_indicator>) {
19926  (void)obj;
19927  using C = typename Tu::type;
19928  lua_CFunction freefunc = &function_detail::upvalue_this_member_function<C, dFx>::template call<is_yielding, no_trampoline>;
19929 
19930  int upvalues = 0;
19931  upvalues += stack::push(L, nullptr);
19932  upvalues += stack::push<user<dFx>>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
19933  stack::push(L, c_closure(freefunc, upvalues));
19934  }
19935  else {
19936  constexpr bool is_reference = meta::is_specialization_of_v<Tu, std::reference_wrapper> || std::is_pointer_v<Tu>;
19937  if constexpr (is_reference) {
19938  auto userptr = detail::ptr(std::forward<T>(obj));
19939  lua_CFunction freefunc
19940  = &function_detail::upvalue_member_function<std::decay_t<decltype(*userptr)>, dFx>::template call<is_yielding, no_trampoline>;
19941 
19942  int upvalues = 0;
19943  upvalues += stack::push(L, nullptr);
19944  upvalues += stack::push<user<dFx>>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
19945  upvalues += stack::push(L, lightuserdata_value(static_cast<void*>(userptr)));
19946  stack::push(L, c_closure(freefunc, upvalues));
19947  }
19948  else {
19950  select_set_fx<is_yielding, no_trampoline, F>(L, std::forward<Fx>(fx), std::forward<T>(obj), std::forward<Args>(args)...);
19951  }
19952  }
19953  }
19954 
19955  template <bool is_yielding, bool no_trampoline, typename Fx, typename... Args>
19956  void select_member_function(lua_State* L, Fx&& fx, Args&&... args) {
19957  using dFx = std::decay_t<Fx>;
19958  if constexpr (sizeof...(Args) < 1) {
19959  using C = typename meta::bind_traits<meta::unqualified_t<Fx>>::object_type;
19960  lua_CFunction freefunc = &function_detail::upvalue_this_member_function<C, dFx>::template call<is_yielding, no_trampoline>;
19961 
19962  int upvalues = 0;
19963  upvalues += stack::push(L, nullptr);
19964  upvalues += stack::push<user<dFx>>(L, std::forward<Fx>(fx));
19965  stack::push(L, c_closure(freefunc, upvalues));
19966  }
19967  else {
19968  select_member_function_with<is_yielding, no_trampoline>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
19969  }
19970  }
19971 
19972  template <bool is_yielding, bool no_trampoline, typename Fx, typename... Args>
19973  void select(lua_State* L, Fx&& fx, Args&&... args) {
19974  using uFx = meta::unqualified_t<Fx>;
19975  if constexpr (is_lua_reference_v<uFx>) {
19976  // TODO: hoist into lambda in this case for yielding???
19977  stack::push(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
19978  }
19979  else if constexpr (is_lua_c_function_v<uFx>) {
19980  if constexpr (no_trampoline) {
19981  if (is_yielding) {
19982  int upvalues = 0;
19983  upvalues += stack::push(L, nullptr);
19984  upvalues += stack::push(L, std::forward<Fx>(fx));
19985 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE)
19986  if constexpr (std::is_nothrow_invocable_r_v<int, uFx, lua_State*>) {
19987  detail::lua_CFunction_noexcept cf = &lua_c_noexcept_wrapper<true>;
19988  lua_pushcclosure(L, reinterpret_cast<lua_CFunction>(cf), upvalues);
19989  }
19990  else
19991 #endif
19992  {
19993  lua_CFunction cf = &function_detail::lua_c_wrapper<true>;
19994  lua_pushcclosure(L, cf, upvalues);
19995  }
19996  }
19997  else {
19998  lua_pushcclosure(L, std::forward<Fx>(fx), 0);
19999  }
20000  }
20001  else {
20002  int upvalues = 0;
20003  upvalues += stack::push(L, nullptr);
20004  upvalues += stack::push(L, std::forward<Fx>(fx));
20005 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE)
20006  if constexpr (std::is_nothrow_invocable_r_v<int, uFx, lua_State*>) {
20007  detail::lua_CFunction_noexcept cf = &lua_c_noexcept_wrapper<is_yielding>;
20008  lua_pushcclosure(L, reinterpret_cast<lua_CFunction>(cf), upvalues);
20009  }
20010  else {
20011  lua_CFunction cf = &function_detail::lua_c_wrapper<is_yielding>;
20012  lua_pushcclosure(L, cf, upvalues);
20013  }
20014 #else
20015  lua_CFunction cf = &function_detail::lua_c_wrapper<is_yielding>;
20016  lua_pushcclosure(L, cf, upvalues);
20017 #endif
20018  }
20019  }
20020  else if constexpr (std::is_function_v<std::remove_pointer_t<uFx>>) {
20021  std::decay_t<Fx> target(std::forward<Fx>(fx), std::forward<Args>(args)...);
20022  lua_CFunction freefunc = &function_detail::upvalue_free_function<Fx>::template call<is_yielding, no_trampoline>;
20023 
20024  int upvalues = 0;
20025  upvalues += stack::push(L, nullptr);
20026  upvalues += stack::stack_detail::push_as_upvalues(L, target);
20027  stack::push(L, c_closure(freefunc, upvalues));
20028  }
20029  else if constexpr (std::is_member_function_pointer_v<uFx>) {
20030  select_member_function<is_yielding, no_trampoline>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
20031  }
20032  else if constexpr (meta::is_member_object_v<uFx>) {
20033  select_member_variable<is_yielding, no_trampoline>(L, std::forward<Fx>(fx), std::forward<Args>(args)...);
20034  }
20035  else {
20036  select_convertible<is_yielding, no_trampoline>(types<>(), L, std::forward<Fx>(fx), std::forward<Args>(args)...);
20037  }
20038  }
20039  } // namespace function_detail
20040 
20041  namespace stack {
20042  template <typename... Sigs>
20044  template <bool is_yielding, typename Arg0, typename... Args>
20045  static int push_yielding(lua_State* L, Arg0&& arg0, Args&&... args) {
20046  if constexpr (meta::is_specialization_of_v<meta::unqualified_t<Arg0>, std::function>) {
20047  if constexpr (is_yielding) {
20048  return stack::push<meta::unqualified_t<Arg0>>(L, detail::yield_tag, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
20049  }
20050  else {
20051  return stack::push(L, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
20052  }
20053  }
20054  else {
20055  function_detail::select<is_yielding, false>(L, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
20056  return 1;
20057  }
20058  }
20059 
20060  template <typename Arg0, typename... Args>
20061  static int push(lua_State* L, Arg0&& arg0, Args&&... args) {
20062  if constexpr (std::is_same_v<meta::unqualified_t<Arg0>, detail::yield_tag_t>) {
20063  push_yielding<true>(L, std::forward<Args>(args)...);
20064  }
20066  push_yielding<true>(L, std::forward<Arg0>(arg0).func, std::forward<Args>(args)...);
20067  }
20068  else {
20069  push_yielding<false>(L, std::forward<Arg0>(arg0), std::forward<Args>(args)...);
20070  }
20071  return 1;
20072  }
20073  };
20074 
20075  template <typename T>
20077  template <typename... Args>
20078  static int push(lua_State* L, const yielding_t<T>& f, Args&&... args) {
20079  if constexpr (meta::is_specialization_of_v<meta::unqualified_t<T>, std::function>) {
20080  return stack::push<T>(L, detail::yield_tag, f.func, std::forward<Args>(args)...);
20081  }
20082  else {
20083  function_detail::select<true, false>(L, f.func, std::forward<Args>(args)...);
20084  return 1;
20085  }
20086  }
20087 
20088  template <typename... Args>
20089  static int push(lua_State* L, yielding_t<T>&& f, Args&&... args) {
20090  if constexpr (meta::is_specialization_of_v<meta::unqualified_t<T>, std::function>) {
20091  return stack::push<T>(L, detail::yield_tag, std::move(f.func), std::forward<Args>(args)...);
20092  }
20093  else {
20094  function_detail::select<true, false>(L, std::move(f.func), std::forward<Args>(args)...);
20095  return 1;
20096  }
20097  }
20098  };
20099 
20100  template <typename T, typename... Args>
20102  template <std::size_t... I, typename FP>
20103  static int push_func(std::index_sequence<I...>, lua_State* L, FP&& fp) {
20104  return stack::push<T>(L, std::get<I>(std::forward<FP>(fp).arguments)...);
20105  }
20106 
20108  return push_func(std::make_index_sequence<sizeof...(Args)>(), L, fp);
20109  }
20110 
20112  return push_func(std::make_index_sequence<sizeof...(Args)>(), L, std::move(fp));
20113  }
20114  };
20115 
20116  template <typename Signature>
20117  struct unqualified_pusher<std::function<Signature>> {
20119 
20120  static int push(lua_State* L, detail::yield_tag_t, const std::function<Signature>& fx) {
20121  if (fx) {
20122  function_detail::select_set_fx<true, false, TargetFunctor>(L, fx);
20123  return 1;
20124  }
20125  return stack::push(L, lua_nil);
20126  }
20127 
20128  static int push(lua_State* L, detail::yield_tag_t, std::function<Signature>&& fx) {
20129  if (fx) {
20130  function_detail::select_set_fx<true, false, TargetFunctor>(L, std::move(fx));
20131  return 1;
20132  }
20133  return stack::push(L, lua_nil);
20134  }
20135 
20136  static int push(lua_State* L, const std::function<Signature>& fx) {
20137  if (fx) {
20138  function_detail::select_set_fx<false, false, TargetFunctor>(L, fx);
20139  return 1;
20140  }
20141  return stack::push(L, lua_nil);
20142  }
20143 
20144  static int push(lua_State* L, std::function<Signature>&& fx) {
20145  if (fx) {
20146  function_detail::select_set_fx<false, false, TargetFunctor>(L, std::move(fx));
20147  return 1;
20148  }
20149  return stack::push(L, lua_nil);
20150  }
20151  };
20152 
20153  template <typename Signature>
20154  struct unqualified_pusher<Signature, std::enable_if_t<meta::is_member_object_or_function_v<Signature>>> {
20155  template <typename... Args>
20156  static int push(lua_State* L, Args&&... args) {
20157  function_detail::select<false, false>(L, std::forward<Args>(args)...);
20158  return 1;
20159  }
20160  };
20161 
20162  template <typename Signature>
20163  struct unqualified_pusher<Signature,
20164  std::enable_if_t<meta::all<std::is_function<std::remove_pointer_t<Signature>>, meta::neg<std::is_same<Signature, lua_CFunction>>,
20165  meta::neg<std::is_same<Signature, std::remove_pointer_t<lua_CFunction>>>
20166 #if SOL_IS_ON(SOL_USE_NOEXCEPT_FUNCTION_TYPE)
20167  ,
20168  meta::neg<std::is_same<Signature, detail::lua_CFunction_noexcept>>,
20169  meta::neg<std::is_same<Signature, std::remove_pointer_t<detail::lua_CFunction_noexcept>>>
20170 #endif // noexcept function types
20171  >::value>> {
20172  template <typename F>
20173  static int push(lua_State* L, F&& f) {
20174  function_detail::select<false, true>(L, std::forward<F>(f));
20175  return 1;
20176  }
20177  };
20178 
20179  template <typename... Functions>
20180  struct unqualified_pusher<overload_set<Functions...>> {
20182  using F = function_detail::overloaded_function<0, Functions...>;
20183  function_detail::select_set_fx<false, false, F>(L, std::move(set.functions));
20184  return 1;
20185  }
20186 
20187  static int push(lua_State* L, const overload_set<Functions...>& set) {
20188  using F = function_detail::overloaded_function<0, Functions...>;
20189  function_detail::select_set_fx<false, false, F>(L, set.functions);
20190  return 1;
20191  }
20192  };
20193 
20194  template <typename T>
20196  static int push(lua_State* L, protect_t<T>&& pw) {
20197  lua_CFunction cf = call_detail::call_user<void, false, false, protect_t<T>, 2>;
20198  int upvalues = 0;
20199  upvalues += stack::push(L, nullptr);
20200  upvalues += stack::push<user<protect_t<T>>>(L, std::move(pw.value));
20201  return stack::push(L, c_closure(cf, upvalues));
20202  }
20203 
20204  static int push(lua_State* L, const protect_t<T>& pw) {
20205  lua_CFunction cf = call_detail::call_user<void, false, false, protect_t<T>, 2>;
20206  int upvalues = 0;
20207  upvalues += stack::push(L, nullptr);
20208  upvalues += stack::push<user<protect_t<T>>>(L, pw.value);
20209  return stack::push(L, c_closure(cf, upvalues));
20210  }
20211  };
20212 
20213  template <typename F, typename G>
20215  static int push(lua_State* L, property_wrapper<F, G>&& pw) {
20216  if constexpr (std::is_void_v<F>) {
20217  return stack::push(L, std::move(pw.write()));
20218  }
20219  else if constexpr (std::is_void_v<G>) {
20220  return stack::push(L, std::move(pw.read()));
20221  }
20222  else {
20223  return stack::push(L, overload(std::move(pw.read()), std::move(pw.write())));
20224  }
20225  }
20226 
20227  static int push(lua_State* L, const property_wrapper<F, G>& pw) {
20228  if constexpr (std::is_void_v<F>) {
20229  return stack::push(L, pw.write);
20230  }
20231  else if constexpr (std::is_void_v<G>) {
20232  return stack::push(L, pw.read);
20233  }
20234  else {
20235  return stack::push(L, overload(pw.read, pw.write));
20236  }
20237  }
20238  };
20239 
20240  template <typename T>
20242  static int push(lua_State* L, var_wrapper<T>&& vw) {
20243  return stack::push(L, std::move(vw.value()));
20244  }
20245  static int push(lua_State* L, const var_wrapper<T>& vw) {
20246  return stack::push(L, vw.value());
20247  }
20248  };
20249 
20250  template <typename... Functions>
20251  struct unqualified_pusher<factory_wrapper<Functions...>> {
20252  static int push(lua_State* L, const factory_wrapper<Functions...>& fw) {
20253  using F = function_detail::overloaded_function<0, Functions...>;
20254  function_detail::select_set_fx<false, false, F>(L, fw.functions);
20255  return 1;
20256  }
20257 
20259  using F = function_detail::overloaded_function<0, Functions...>;
20260  function_detail::select_set_fx<false, false, F>(L, std::move(fw.functions));
20261  return 1;
20262  }
20263 
20265  using F = function_detail::overloaded_function<1, Functions...>;
20266  function_detail::select_set_fx<false, false, F>(L, fw.functions);
20267  return 1;
20268  }
20269 
20271  using F = function_detail::overloaded_function<1, Functions...>;
20272  function_detail::select_set_fx<false, false, F>(L, std::move(fw.functions));
20273  return 1;
20274  }
20275  };
20276 
20277  template <>
20279  static int push(lua_State* L, no_construction) {
20281  return stack::push(L, cf);
20282  }
20283 
20285  return push(L, c);
20286  }
20287  };
20288 
20289  template <typename T>
20290  struct unqualified_pusher<detail::tagged<T, no_construction>> {
20293  return stack::push(L, cf);
20294  }
20295 
20298  return stack::push(L, cf);
20299  }
20300  };
20301 
20302  template <typename T, typename... Lists>
20303  struct unqualified_pusher<detail::tagged<T, constructor_list<Lists...>>> {
20306  return stack::push(L, cf);
20307  }
20308 
20311  return stack::push(L, cf);
20312  }
20313  };
20314 
20315  template <typename L0, typename... Lists>
20316  struct unqualified_pusher<constructor_list<L0, Lists...>> {
20317  typedef constructor_list<L0, Lists...> cl_t;
20318  static int push(lua_State* L, cl_t cl) {
20319  typedef typename meta::bind_traits<L0>::return_type T;
20320  return stack::push<detail::tagged<T, cl_t>>(L, cl);
20321  }
20322  };
20323 
20324  template <typename T, typename... Fxs>
20325  struct unqualified_pusher<detail::tagged<T, constructor_wrapper<Fxs...>>> {
20327  return push(L, std::move(c.value()));
20328  }
20329 
20330  static int push(lua_State* L, const detail::tagged<T, const constructor_wrapper<Fxs...>>& c) {
20331  return push(L, c.value());
20332  }
20333 
20335  lua_CFunction cf = call_detail::call_user<T, false, false, constructor_wrapper<Fxs...>, 2>;
20336  int upvalues = 0;
20337  upvalues += stack::push(L, nullptr);
20338  upvalues += stack::push<user<constructor_wrapper<Fxs...>>>(L, std::move(c));
20339  return stack::push(L, c_closure(cf, upvalues));
20340  }
20341 
20342  static int push(lua_State* L, const constructor_wrapper<Fxs...>& c) {
20343  lua_CFunction cf = call_detail::call_user<T, false, false, constructor_wrapper<Fxs...>, 2>;
20344  int upvalues = 0;
20345  upvalues += stack::push(L, nullptr);
20346  upvalues += stack::push<user<constructor_wrapper<Fxs...>>>(L, c);
20347  return stack::push(L, c_closure(cf, upvalues));
20348  }
20349  };
20350 
20351  template <typename F, typename... Fxs>
20353  static int push(lua_State* L, const constructor_wrapper<F, Fxs...>& c) {
20354  typedef typename meta::bind_traits<F>::template arg_at<0> arg0;
20356  return stack::push<detail::tagged<T, constructor_wrapper<F, Fxs...>>>(L, c);
20357  }
20358 
20360  typedef typename meta::bind_traits<F>::template arg_at<0> arg0;
20362  return stack::push<detail::tagged<T, constructor_wrapper<F, Fxs...>>>(L, std::move(c));
20363  }
20364  };
20365 
20366  template <typename T>
20367  struct unqualified_pusher<detail::tagged<T, destructor_wrapper<void>>> {
20369  lua_CFunction cf = detail::usertype_alloc_destroy<T>;
20370  return stack::push(L, cf);
20371  }
20372  };
20373 
20374  template <typename T, typename Fx>
20375  struct unqualified_pusher<detail::tagged<T, destructor_wrapper<Fx>>> {
20376  static int push(lua_State* L, destructor_wrapper<Fx>&& c) {
20377  lua_CFunction cf = call_detail::call_user<T, false, false, destructor_wrapper<Fx>, 2>;
20378  int upvalues = 0;
20379  upvalues += stack::push(L, nullptr);
20380  upvalues += stack::push<user<destructor_wrapper<Fx>>>(L, std::move(c));
20381  return stack::push(L, c_closure(cf, upvalues));
20382  }
20383 
20384  static int push(lua_State* L, const destructor_wrapper<Fx>& c) {
20385  lua_CFunction cf = call_detail::call_user<T, false, false, destructor_wrapper<Fx>, 2>;
20386  int upvalues = 0;
20387  upvalues += stack::push(L, nullptr);
20388  upvalues += stack::push<user<destructor_wrapper<Fx>>>(L, c);
20389  return stack::push(L, c_closure(cf, upvalues));
20390  }
20391  };
20392 
20393  template <typename Fx>
20395  static int push(lua_State* L, destructor_wrapper<Fx>&& c) {
20396  lua_CFunction cf = call_detail::call_user<void, false, false, destructor_wrapper<Fx>, 2>;
20397  int upvalues = 0;
20398  upvalues += stack::push(L, nullptr);
20399  upvalues += stack::push<user<destructor_wrapper<Fx>>>(L, std::move(c));
20400  return stack::push(L, c_closure(cf, upvalues));
20401  }
20402 
20403  static int push(lua_State* L, const destructor_wrapper<Fx>& c) {
20404  lua_CFunction cf = call_detail::call_user<void, false, false, destructor_wrapper<Fx>, 2>;
20405  int upvalues = 0;
20406  upvalues += stack::push(L, nullptr);
20407  upvalues += stack::push<user<destructor_wrapper<Fx>>>(L, c);
20408  return stack::push(L, c_closure(cf, upvalues));
20409  }
20410  };
20411 
20412  template <typename F, typename... Policies>
20413  struct unqualified_pusher<policy_wrapper<F, Policies...>> {
20414  using P = policy_wrapper<F, Policies...>;
20415 
20416  static int push(lua_State* L, const P& p) {
20417  lua_CFunction cf = call_detail::call_user<void, false, false, P, 2>;
20418  int upvalues = 0;
20419  upvalues += stack::push(L, nullptr);
20420  upvalues += stack::push<user<P>>(L, p);
20421  return stack::push(L, c_closure(cf, upvalues));
20422  }
20423 
20424  static int push(lua_State* L, P&& p) {
20425  lua_CFunction cf = call_detail::call_user<void, false, false, P, 2>;
20426  int upvalues = 0;
20427  upvalues += stack::push(L, nullptr);
20428  upvalues += stack::push<user<P>>(L, std::move(p));
20429  return stack::push(L, c_closure(cf, upvalues));
20430  }
20431  };
20432 
20433  template <typename T, typename F, typename... Policies>
20434  struct unqualified_pusher<detail::tagged<T, policy_wrapper<F, Policies...>>> {
20435  using P = policy_wrapper<F, Policies...>;
20437 
20438  static int push(lua_State* L, const Tagged& p) {
20439  lua_CFunction cf = call_detail::call_user<T, false, false, P, 2>;
20440  int upvalues = 0;
20441  upvalues += stack::push(L, nullptr);
20442  upvalues += stack::push<user<P>>(L, p.value());
20443  return stack::push(L, c_closure(cf, upvalues));
20444  }
20445 
20446  static int push(lua_State* L, Tagged&& p) {
20447  lua_CFunction cf = call_detail::call_user<T, false, false, P, 2>;
20448  int upvalues = 0;
20449  upvalues += stack::push(L, nullptr);
20450  upvalues += stack::push<user<P>>(L, std::move(p.value()));
20451  return stack::push(L, c_closure(cf, upvalues));
20452  }
20453  };
20454 
20455  template <typename T>
20457  static int push(lua_State* L, push_invoke_t<T>&& pi) {
20458  if constexpr (std::is_invocable_v<std::add_rvalue_reference_t<T>, lua_State*>) {
20459  return stack::push(L, std::move(pi.value())(L));
20460  }
20461  else {
20462  return stack::push(L, std::move(pi.value())());
20463  }
20464  }
20465 
20466  static int push(lua_State* L, const push_invoke_t<T>& pi) {
20467  if constexpr (std::is_invocable_v<const T, lua_State*>) {
20468  return stack::push(L, pi.value()(L));
20469  }
20470  else {
20471  return stack::push(L, pi.value()());
20472  }
20473  }
20474  };
20475 
20476  namespace stack_detail {
20477  template <typename Function, typename Handler>
20478  bool check_function_pointer(lua_State* L, int index, Handler&& handler, record& tracking) noexcept {
20479 #if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE)
20480  tracking.use(1);
20481  bool success = lua_iscfunction(L, index) == 1;
20482  if (success) {
20483  // there must be at LEAST 2 upvalues; otherwise, we didn't serialize it.
20484  const char* upvalue_name = lua_getupvalue(L, index, 2);
20485  lua_pop(L, 1);
20486  success = upvalue_name != nullptr;
20487  }
20488  if (!success) {
20489  // expected type, actual type
20490  handler(
20491  L, index, type::function, type_of(L, index), "type must be a Lua C Function gotten from a function pointer serialized by sol2");
20492  }
20493  return success;
20494 #else
20495  (void)L;
20496  (void)index;
20497  (void)handler;
20498  (void)tracking;
20499  return false;
20500 #endif
20501  }
20502 
20503  template <typename Function>
20504  Function* get_function_pointer(lua_State* L, int index, record& tracking) noexcept {
20505 #if SOL_IS_ON(SOL_GET_FUNCTION_POINTER_UNSAFE)
20506  tracking.use(1);
20507  auto udata = stack::stack_detail::get_as_upvalues_using_function<Function*>(L, index);
20508  Function* fx = udata.first;
20509  return fx;
20510 #else
20511  (void)L;
20512  (void)index;
20513  (void)tracking;
20515 #if SOL_IS_DEFAULT_OFF(SOL_GET_FUNCTION_POINTER_UNSAFE)
20516  "You are attempting to retrieve a function pointer type. "
20517  "This is inherently unsafe in sol2. In order to do this, you must turn on the "
20518  "SOL_GET_FUNCTION_POINTER_UNSAFE configuration macro, as detailed in the documentation. "
20519  "Please be careful!"
20520 #else
20521  "You are attempting to retrieve a function pointer type. "
20522  "You explicitly turned off the ability to do this by defining "
20523  "SOL_GET_FUNCTION_POINTER_UNSAFE or similar to be off. "
20524  "Please reconsider this!"
20525 #endif
20526  );
20527  return nullptr;
20528 #endif
20529  }
20530  } // namespace stack_detail
20531  } // namespace stack
20532 } // namespace sol
20533 
20534 // end of sol/function_types.hpp
20535 
20536 // beginning of sol/dump_handler.hpp
20537 
20538 #include <cstdint>
20539 #include <exception>
20540 
20541 namespace sol {
20542 
20543  class dump_error : public error {
20544  private:
20545  int m_ec;
20546 
20547  public:
20548  dump_error(int error_code_) : error("dump returned non-zero error of " + std::to_string(error_code_)), m_ec(error_code_) {
20549  }
20550 
20551  int error_code() const {
20552  return m_ec;
20553  }
20554  };
20555 
20556  inline int dump_pass_on_error(lua_State* L_, int result_code, lua_Writer writer_function, void* userdata_pointer_, bool strip) {
20557  (void)L_;
20558  (void)writer_function;
20559  (void)userdata_pointer_;
20560  (void)strip;
20561  return result_code;
20562  }
20563 
20564  inline int dump_panic_on_error(lua_State* L_, int result_code, lua_Writer writer_function, void* userdata_pointer_, bool strip) {
20565  (void)L_;
20566  (void)writer_function;
20567  (void)userdata_pointer_;
20568  (void)strip;
20569  return luaL_error(L_, "a non-zero error code (%d) was returned by the lua_Writer for the dump function", result_code);
20570  }
20571 
20572  inline int dump_throw_on_error(lua_State* L_, int result_code, lua_Writer writer_function, void* userdata_pointer_, bool strip) {
20573 #if SOL_IS_OFF(SOL_EXCEPTIONS)
20574  return dump_panic_on_error(L_, result_code, writer_function, userdata_pointer_, strip);
20575 #else
20576  (void)L_;
20577  (void)writer_function;
20578  (void)userdata_pointer_;
20579  (void)strip;
20580  throw dump_error(result_code);
20581 #endif // no exceptions stuff
20582  }
20583 
20584 } // namespace sol
20585 
20586 // end of sol/dump_handler.hpp
20587 
20588 #include <cstdint>
20589 
20590 namespace sol {
20591  template <typename ref_t, bool aligned = false>
20592  class basic_function : public basic_object<ref_t> {
20593  private:
20595 
20596  void luacall(std::ptrdiff_t argcount, std::ptrdiff_t resultcount) const {
20597  lua_call(lua_state(), static_cast<int>(argcount), static_cast<int>(resultcount));
20598  }
20599 
20600  template <std::size_t... I, typename... Ret>
20601  auto invoke(types<Ret...>, std::index_sequence<I...>, std::ptrdiff_t n) const {
20602  luacall(n, lua_size<std::tuple<Ret...>>::value);
20603  return stack::pop<std::tuple<Ret...>>(lua_state());
20604  }
20605 
20606  template <std::size_t I, typename Ret, meta::enable<meta::neg<std::is_void<Ret>>> = meta::enabler>
20607  Ret invoke(types<Ret>, std::index_sequence<I>, std::ptrdiff_t n) const {
20608  luacall(n, lua_size<Ret>::value);
20609  return stack::pop<Ret>(lua_state());
20610  }
20611 
20612  template <std::size_t I>
20613  void invoke(types<void>, std::index_sequence<I>, std::ptrdiff_t n) const {
20614  luacall(n, 0);
20615  }
20616 
20617  unsafe_function_result invoke(types<>, std::index_sequence<>, std::ptrdiff_t n) const {
20618  int stacksize = lua_gettop(lua_state());
20619  int firstreturn = (std::max)(1, stacksize - static_cast<int>(n));
20620  luacall(n, LUA_MULTRET);
20621  int poststacksize = lua_gettop(lua_state());
20622  int returncount = poststacksize - (firstreturn - 1);
20623  return unsafe_function_result(lua_state(), firstreturn, returncount);
20624  }
20625 
20626  public:
20627  using base_t::lua_state;
20628 
20629  basic_function() = default;
20630  template <typename T,
20633  basic_function(T&& r) noexcept : base_t(std::forward<T>(r)) {
20634 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
20635  if (!is_function<meta::unqualified_t<T>>::value) {
20636  auto pp = stack::push_pop(*this);
20638  stack::check<basic_function>(lua_state(), -1, handler);
20639  }
20640 #endif // Safety
20641  }
20642  basic_function(const basic_function&) = default;
20643  basic_function& operator=(const basic_function&) = default;
20644  basic_function(basic_function&&) = default;
20645  basic_function& operator=(basic_function&&) = default;
20646  basic_function(const stack_reference& r) : basic_function(r.lua_state(), r.stack_index()) {
20647  }
20648  basic_function(stack_reference&& r) : basic_function(r.lua_state(), r.stack_index()) {
20649  }
20651  }
20652  template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
20653  basic_function(lua_State* L, T&& r) : base_t(L, std::forward<T>(r)) {
20654 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
20655  auto pp = stack::push_pop(*this);
20657  stack::check<basic_function>(lua_state(), -1, handler);
20658 #endif // Safety
20659  }
20660  basic_function(lua_State* L, int index = -1) : base_t(L, index) {
20661 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
20663  stack::check<basic_function>(L, index, handler);
20664 #endif // Safety
20665  }
20667 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
20668  auto pp = stack::push_pop(*this);
20670  stack::check<basic_function>(lua_state(), -1, handler);
20671 #endif // Safety
20672  }
20673 
20674  template <typename Fx>
20675  int dump(lua_Writer writer, void* userdata, bool strip, Fx&& on_error) const {
20676  this->push();
20677  auto ppn = stack::push_popper_n<false>(this->lua_state(), 1);
20678  int r = lua_dump(this->lua_state(), writer, userdata, strip ? 1 : 0);
20679  if (r != 0) {
20680  return on_error(this->lua_state(), r, writer, userdata, strip);
20681  }
20682  return r;
20683  }
20684 
20685  int dump(lua_Writer writer, void* userdata, bool strip = false) const {
20686  return dump(writer, userdata, strip, &dump_throw_on_error);
20687  }
20688 
20689  template <typename Container = bytecode>
20690  Container dump() const {
20691  Container bc;
20692  (void)dump(static_cast<lua_Writer>(&basic_insert_dump_writer<Container>), static_cast<void*>(&bc), false, &dump_panic_on_error);
20693  return bc;
20694  }
20695 
20696  template <typename Container = bytecode, typename Fx>
20697  Container dump(Fx&& on_error) const {
20698  Container bc;
20699  (void)dump(static_cast<lua_Writer>(&basic_insert_dump_writer<Container>), static_cast<void*>(&bc), false, std::forward<Fx>(on_error));
20700  return bc;
20701  }
20702 
20703  template <typename... Args>
20705  return call<>(std::forward<Args>(args)...);
20706  }
20707 
20708  template <typename... Ret, typename... Args>
20709  decltype(auto) operator()(types<Ret...>, Args&&... args) const {
20710  return call<Ret...>(std::forward<Args>(args)...);
20711  }
20712 
20713  template <typename... Ret, typename... Args>
20714  decltype(auto) call(Args&&... args) const {
20715  if (!aligned) {
20716  base_t::push();
20717  }
20718  int pushcount = stack::multi_push_reference(lua_state(), std::forward<Args>(args)...);
20719  return invoke(types<Ret...>(), std::make_index_sequence<sizeof...(Ret)>(), static_cast<std::ptrdiff_t>(pushcount));
20720  }
20721  };
20722 } // namespace sol
20723 
20724 // end of sol/unsafe_function.hpp
20725 
20726 // beginning of sol/protected_function.hpp
20727 
20728 // beginning of sol/protected_handler.hpp
20729 
20730 #include <cstdint>
20731 
20732 namespace sol { namespace detail {
20733  inline const char (&default_handler_name())[9] {
20734  static const char name[9] = "sol.\xF0\x9F\x94\xA9";
20735  return name;
20736  }
20737 
20738  template <bool ShouldPush, typename Target = reference>
20741  const Target& target;
20743 
20744  protected_handler(std::false_type, lua_State* L_, const Target& target_) : m_L(L_), target(target_), stack_index(0) {
20745  if (ShouldPush) {
20746  stack_index = lua_gettop(L_) + 1;
20747  target.push(L_);
20748  }
20749  }
20750 
20751  protected_handler(std::true_type, lua_State* L_, const Target& target_) : m_L(L_), target(target_), stack_index(0) {
20752  if (ShouldPush) {
20753  stack_index = target.stack_index();
20754  }
20755  }
20756 
20757  protected_handler(lua_State* L_, const Target& target_) : protected_handler(meta::boolean<is_stack_based_v<Target>>(), L_, target_) {
20758  }
20759 
20760  bool valid() const noexcept {
20761  return ShouldPush;
20762  }
20763 
20765  if constexpr (!is_stack_based_v<Target>) {
20766  if (stack_index != 0) {
20767  lua_remove(m_L, stack_index);
20768  }
20769  }
20770  }
20771  };
20772 
20773  template <typename Base, typename T>
20775  return p;
20776  }
20777 
20778  template <typename Reference, bool IsMainReference = false>
20779  inline Reference get_default_handler(lua_State* L_) {
20780  if (is_stack_based_v<Reference> || L_ == nullptr)
20781  return Reference(L_, lua_nil);
20782  L_ = IsMainReference ? main_thread(L_, L_) : L_;
20784  auto pp = stack::pop_n(L_, 1);
20785  return Reference(L_, -1);
20786  }
20787 
20788  template <typename T>
20789  inline void set_default_handler(lua_State* L, const T& ref) {
20790  if (L == nullptr) {
20791  return;
20792  }
20793  if (!ref.valid()) {
20794 #if SOL_IS_ON(SOL_SAFE_STACK_CHECK)
20796 #endif // make sure stack doesn't overflow
20797  lua_pushnil(L);
20799  }
20800  else {
20801  ref.push(L);
20803  }
20804  }
20805 }} // namespace sol::detail
20806 
20807 // end of sol/protected_handler.hpp
20808 
20809 #include <cstdint>
20810 #include <algorithm>
20811 
20812 namespace sol {
20813 
20814  namespace detail {
20815  template <bool ShouldPush_, typename Handler_>
20818  handler_.stack_index = 0;
20819  if (ShouldPush_) {
20820  handler_.target.push(L_);
20821  detail::call_exception_handler(L_, maybe_ex, error);
20822  lua_call(L_, 1, 1);
20823  }
20824  else {
20825  detail::call_exception_handler(L_, maybe_ex, error);
20826  }
20827  }
20828  } // namespace detail
20829 
20830  template <typename Reference, bool Aligned = false, typename Handler = reference>
20831  class basic_protected_function : public basic_object<Reference> {
20832  private:
20834  using handler_t = Handler;
20835  inline static constexpr bool is_stack_handler_v = is_stack_based_v<handler_t>;
20836 
20838  : base_t(other_), m_error_handler(other_.m_error_handler.copy(lua_state())) {
20839  }
20840 
20841  basic_protected_function(std::false_type, const basic_protected_function& other_) noexcept : base_t(other_), m_error_handler(other_.m_error_handler) {
20842  }
20843 
20844  public:
20845  basic_protected_function() = default;
20846  template <typename T,
20850  basic_protected_function(T&& r) noexcept : base_t(std::forward<T>(r)), m_error_handler(get_default_handler(r.lua_state())) {
20851 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
20852  if (!is_function<meta::unqualified_t<T>>::value) {
20853  auto pp = stack::push_pop(*this);
20855  stack::check<basic_protected_function>(lua_state(), -1, handler);
20856  }
20857 #endif // Safety
20858  }
20860  : basic_protected_function(meta::boolean<is_stateless_lua_reference_v<Handler>>(), other_) {
20861  }
20863  base_t::operator=(other_);
20864  if constexpr (is_stateless_lua_reference_v<Handler>) {
20865  m_error_handler.copy_assign(lua_state(), other_.m_error_handler);
20866  }
20867  else {
20868  m_error_handler = other_.m_error_handler;
20869  }
20870  return *this;
20871  }
20873  basic_protected_function& operator=(basic_protected_function&&) = default;
20875  }
20877  }
20878  basic_protected_function(const basic_function<base_t>& b, handler_t eh) : base_t(b), m_error_handler(std::move(eh)) {
20879  }
20881  }
20882  basic_protected_function(const stack_reference& r) : basic_protected_function(r.lua_state(), r.stack_index(), get_default_handler(r.lua_state())) {
20883  }
20884  basic_protected_function(stack_reference&& r) : basic_protected_function(r.lua_state(), r.stack_index(), get_default_handler(r.lua_state())) {
20885  }
20886  basic_protected_function(const stack_reference& r, handler_t eh) : basic_protected_function(r.lua_state(), r.stack_index(), std::move(eh)) {
20887  }
20888  basic_protected_function(stack_reference&& r, handler_t eh) : basic_protected_function(r.lua_state(), r.stack_index(), std::move(eh)) {
20889  }
20890 
20891  template <typename Super>
20893  }
20894  template <typename Super>
20896  }
20897  template <typename Proxy, typename HandlerReference,
20900  basic_protected_function(Proxy&& p, HandlerReference&& eh)
20901  : basic_protected_function(detail::force_cast<base_t>(p), make_reference<handler_t>(p.lua_state(), std::forward<HandlerReference>(eh))) {
20902  }
20903 
20904  template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
20906  }
20907  template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
20908  basic_protected_function(lua_State* L_, T&& r, handler_t eh) : base_t(L_, std::forward<T>(r)), m_error_handler(std::move(eh)) {
20909 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
20910  auto pp = stack::push_pop(*this);
20912  stack::check<basic_protected_function>(lua_state(), -1, handler);
20913 #endif // Safety
20914  }
20915 
20916  basic_protected_function(lua_nil_t n) : base_t(n), m_error_handler(n) {
20917  }
20918 
20920  }
20921  basic_protected_function(lua_State* L_, int index_, handler_t eh) : base_t(L_, index_), m_error_handler(std::move(eh)) {
20922 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
20924  stack::check<basic_protected_function>(L_, index_, handler);
20925 #endif // Safety
20926  }
20928  }
20929  basic_protected_function(lua_State* L_, absolute_index index_, handler_t eh) : base_t(L_, index_), m_error_handler(std::move(eh)) {
20930 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
20932  stack::check<basic_protected_function>(L_, index_, handler);
20933 #endif // Safety
20934  }
20936  }
20937  basic_protected_function(lua_State* L_, raw_index index_, handler_t eh) : base_t(L_, index_), m_error_handler(std::move(eh)) {
20938 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
20940  stack::check<basic_protected_function>(L_, index_, handler);
20941 #endif // Safety
20942  }
20944  }
20945  basic_protected_function(lua_State* L_, ref_index index_, handler_t eh) : base_t(L_, index_), m_error_handler(std::move(eh)) {
20946 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
20947  auto pp = stack::push_pop(*this);
20949  stack::check<basic_protected_function>(lua_state(), -1, handler);
20950 #endif // Safety
20951  }
20952 
20953  using base_t::lua_state;
20954 
20955  template <typename Fx>
20956  int dump(lua_Writer writer, void* userdata_pointer_, bool strip, Fx&& on_error) const {
20957  this->push();
20958  auto ppn = stack::push_popper_n<false>(this->lua_state(), 1);
20959  int r = lua_dump(this->lua_state(), writer, userdata_pointer_, strip ? 1 : 0);
20960  if (r != 0) {
20961  return on_error(this->lua_state(), r, writer, userdata_pointer_, strip);
20962  }
20963  return r;
20964  }
20965 
20966  int dump(lua_Writer writer, void* userdata_pointer_, bool strip = false) const {
20967  return dump(writer, userdata_pointer_, strip, &dump_pass_on_error);
20968  }
20969 
20970  template <typename Container = bytecode>
20971  Container dump() const {
20972  Container bc;
20973  (void)dump(static_cast<lua_Writer>(&basic_insert_dump_writer<Container>), static_cast<void*>(&bc), false, &dump_throw_on_error);
20974  return bc;
20975  }
20976 
20977  template <typename Container = bytecode, typename Fx>
20978  Container dump(Fx&& on_error) const {
20979  Container bc;
20980  (void)dump(static_cast<lua_Writer>(&basic_insert_dump_writer<Container>), static_cast<void*>(&bc), false, std::forward<Fx>(on_error));
20981  return bc;
20982  }
20983 
20984  template <typename... Args>
20986  return call<>(std::forward<Args>(args)...);
20987  }
20988 
20989  template <typename... Ret, typename... Args>
20990  decltype(auto) operator()(types<Ret...>, Args&&... args) const {
20991  return call<Ret...>(std::forward<Args>(args)...);
20992  }
20993 
20994  template <typename... Ret, typename... Args>
20995  decltype(auto) call(Args&&... args) const {
20996  if constexpr (!Aligned) {
20997  // we do not expect the function to already be on the stack: push it
20998  if (m_error_handler.valid(lua_state())) {
20999  detail::protected_handler<true, handler_t> h(lua_state(), m_error_handler);
21000  base_t::push();
21001  int pushcount = stack::multi_push_reference(lua_state(), std::forward<Args>(args)...);
21002  return invoke(types<Ret...>(), std::make_index_sequence<sizeof...(Ret)>(), pushcount, h);
21003  }
21004  else {
21005  detail::protected_handler<false, handler_t> h(lua_state(), m_error_handler);
21006  base_t::push();
21007  int pushcount = stack::multi_push_reference(lua_state(), std::forward<Args>(args)...);
21008  return invoke(types<Ret...>(), std::make_index_sequence<sizeof...(Ret)>(), pushcount, h);
21009  }
21010  }
21011  else {
21012  // the function is already on the stack at the right location
21013  if (m_error_handler.valid()) {
21014  // the handler will be pushed onto the stack manually,
21015  // since it's not already on the stack this means we need to push our own
21016  // function on the stack too and swap things to be in-place
21017  if constexpr (!is_stack_handler_v) {
21018  // so, we need to remove the function at the top and then dump the handler out ourselves
21019  base_t::push();
21020  }
21021  detail::protected_handler<true, handler_t> h(lua_state(), m_error_handler);
21022  if constexpr (!is_stack_handler_v) {
21023  lua_replace(lua_state(), -3);
21024  h.stack_index = lua_absindex(lua_state(), -2);
21025  }
21026  int pushcount = stack::multi_push_reference(lua_state(), std::forward<Args>(args)...);
21027  return invoke(types<Ret...>(), std::make_index_sequence<sizeof...(Ret)>(), pushcount, h);
21028  }
21029  else {
21030  detail::protected_handler<false, handler_t> h(lua_state(), m_error_handler);
21031  int pushcount = stack::multi_push_reference(lua_state(), std::forward<Args>(args)...);
21032  return invoke(types<Ret...>(), std::make_index_sequence<sizeof...(Ret)>(), pushcount, h);
21033  }
21034  }
21035  }
21036 
21038  if constexpr (is_stateless_lua_reference_v<handler_t>) {
21039  this->m_error_handler.reset(lua_state());
21040  }
21041  }
21042 
21044  return detail::get_default_handler<handler_t, is_main_threaded_v<base_t>>(L_);
21045  }
21046 
21047  template <typename T>
21048  static void set_default_handler(const T& ref) {
21049  detail::set_default_handler(ref.lua_state(), ref);
21050  }
21051 
21052  auto get_error_handler() const noexcept {
21053  if constexpr (is_stateless_lua_reference_v<handler_t>) {
21054  if constexpr (is_stack_based_v<handler_t>) {
21055  return stack_reference(lua_state(), m_error_handler.stack_index());
21056  }
21057  else {
21058  return basic_reference<is_main_threaded_v<base_t>>(lua_state(), ref_index(m_error_handler.registry_index()));
21059  }
21060  }
21061  else {
21062  return m_error_handler;
21063  }
21064  }
21065 
21066  template <typename ErrorHandler_>
21067  void set_error_handler(ErrorHandler_&& error_handler_) noexcept {
21068  static_assert(!is_stack_based_v<handler_t> || is_stack_based_v<ErrorHandler_>,
21069  "A stack-based error handler can only be set from a parameter that is also stack-based.");
21070  if constexpr (std::is_rvalue_reference_v<ErrorHandler_>) {
21071  m_error_handler = std::forward<ErrorHandler_>(error_handler_);
21072  }
21073  else {
21074  m_error_handler.copy_assign(lua_state(), std::forward<ErrorHandler_>(error_handler_));
21075  }
21076  }
21077 
21078  void abandon () noexcept {
21079  this->m_error_handler.abandon();
21080  base_t::abandon();
21081  }
21082 
21083  private:
21085 
21086  template <bool b>
21087  call_status luacall(std::ptrdiff_t argcount, std::ptrdiff_t result_count_, detail::protected_handler<b, handler_t>& h) const {
21088  return static_cast<call_status>(lua_pcall(lua_state(), static_cast<int>(argcount), static_cast<int>(result_count_), h.stack_index));
21089  }
21090 
21091  template <std::size_t... I, bool b, typename... Ret>
21092  auto invoke(types<Ret...>, std::index_sequence<I...>, std::ptrdiff_t n, detail::protected_handler<b, handler_t>& h) const {
21093  luacall(n, sizeof...(Ret), h);
21094  return stack::pop<std::tuple<Ret...>>(lua_state());
21095  }
21096 
21097  template <std::size_t I, bool b, typename Ret>
21098  Ret invoke(types<Ret>, std::index_sequence<I>, std::ptrdiff_t n, detail::protected_handler<b, handler_t>& h) const {
21099  luacall(n, 1, h);
21100  return stack::pop<Ret>(lua_state());
21101  }
21102 
21103  template <std::size_t I, bool b>
21104  void invoke(types<void>, std::index_sequence<I>, std::ptrdiff_t n, detail::protected_handler<b, handler_t>& h) const {
21105  luacall(n, 0, h);
21106  }
21107 
21108  template <bool b>
21109  protected_function_result invoke(types<>, std::index_sequence<>, std::ptrdiff_t n, detail::protected_handler<b, handler_t>& h) const {
21110  int stacksize = lua_gettop(lua_state());
21111  int poststacksize = stacksize;
21112  int firstreturn = 1;
21113  int returncount = 0;
21115 #if SOL_IS_ON(SOL_EXCEPTIONS) && SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS)
21116  try {
21117 #endif // No Exceptions
21118  firstreturn = (std::max)(1, static_cast<int>(stacksize - n - static_cast<int>(h.valid() && !is_stack_handler_v)));
21119  code = luacall(n, LUA_MULTRET, h);
21120  poststacksize = lua_gettop(lua_state()) - static_cast<int>(h.valid() && !is_stack_handler_v);
21121  returncount = poststacksize - (firstreturn - 1);
21122 #if SOL_IS_ON(SOL_EXCEPTIONS) && SOL_IS_OFF(SOL_PROPAGATE_EXCEPTIONS)
21123  }
21124  // Handle C++ errors thrown from C++ functions bound inside of lua
21125  catch (const char* error) {
21127  firstreturn = lua_gettop(lua_state());
21128  return protected_function_result(lua_state(), firstreturn, 0, 1, call_status::runtime);
21129  }
21130  catch (const std::string& error) {
21132  firstreturn = lua_gettop(lua_state());
21133  return protected_function_result(lua_state(), firstreturn, 0, 1, call_status::runtime);
21134  }
21135  catch (const std::exception& error) {
21137  firstreturn = lua_gettop(lua_state());
21138  return protected_function_result(lua_state(), firstreturn, 0, 1, call_status::runtime);
21139  }
21140 #if SOL_IS_ON(SOL_EXCEPTIONS_CATCH_ALL)
21141  // LuaJIT cannot have the catchall when the safe propagation is on
21142  // but LuaJIT will swallow all C++ errors
21143  // if we don't at least catch std::exception ones
21144  catch (...) {
21146  firstreturn = lua_gettop(lua_state());
21147  return protected_function_result(lua_state(), firstreturn, 0, 1, call_status::runtime);
21148  }
21149 #endif // Always catch edge case
21150 #else
21151  // do not handle exceptions: they can be propogated into C++ and keep all type information / rich information
21152 #endif // Exceptions vs. No Exceptions
21153  return protected_function_result(lua_state(), firstreturn, returncount, returncount, code);
21154  }
21155  };
21156 } // namespace sol
21157 
21158 // end of sol/protected_function.hpp
21159 
21160 #include <functional>
21161 
21162 namespace sol {
21163  template <typename... Ret, typename... Args>
21164  decltype(auto) stack_proxy::call(Args&&... args) {
21165  stack_function sf(this->lua_state(), this->stack_index());
21166  return sf.template call<Ret...>(std::forward<Args>(args)...);
21167  }
21168 
21170  : L(o.lua_state()), index(o.stack_index()), returncount(o.return_count()), popcount(o.return_count()), err(o.status()) {
21171  // Must be manual, otherwise destructor will screw us
21172  // return count being 0 is enough to keep things clean
21173  // but we will be thorough
21174  o.abandon();
21175  }
21176 
21178  L = o.lua_state();
21179  index = o.stack_index();
21180  returncount = o.return_count();
21181  popcount = o.return_count();
21182  err = o.status();
21183  // Must be manual, otherwise destructor will screw us
21184  // return count being 0 is enough to keep things clean
21185  // but we will be thorough
21186  o.abandon();
21187  return *this;
21188  }
21189 
21191  : L(o.lua_state()), index(o.stack_index()), returncount(o.return_count()) {
21192  // Must be manual, otherwise destructor will screw us
21193  // return count being 0 is enough to keep things clean
21194  // but we will be thorough
21195  o.abandon();
21196  }
21198  L = o.lua_state();
21199  index = o.stack_index();
21200  returncount = o.return_count();
21201  // Must be manual, otherwise destructor will screw us
21202  // return count being 0 is enough to keep things clean
21203  // but we will be thorough
21204  o.abandon();
21205  return *this;
21206  }
21207 
21208  namespace detail {
21209  template <typename... R>
21210  struct std_shim {
21212 
21213  std_shim(unsafe_function lua_func) : lua_func_(std::move(lua_func)) {
21214  }
21215 
21216  template <typename... Args>
21218  return lua_func_.call<R...>(std::forward<Args>(args)...);
21219  }
21220  };
21221 
21222  template <>
21223  struct std_shim<void> {
21225 
21226  std_shim(unsafe_function lua_func) : lua_func_(std::move(lua_func)) {
21227  }
21228 
21229  template <typename... Args>
21230  void operator()(Args&&... args) {
21231  lua_func_.call<void>(std::forward<Args>(args)...);
21232  }
21233  };
21234  } // namespace detail
21235 
21236  namespace stack {
21237  template <typename Signature>
21238  struct unqualified_getter<std::function<Signature>> {
21240  typedef typename fx_t::args_list args_lists;
21242 
21243  template <typename... R>
21244  static std::function<Signature> get_std_func(types<R...>, lua_State* L, int index) {
21245  detail::std_shim<R...> fx(unsafe_function(L, index));
21246  return fx;
21247  }
21248 
21249  static std::function<Signature> get(lua_State* L, int index, record& tracking) {
21250  tracking.use(1);
21251  type t = type_of(L, index);
21252  if (t == type::none || t == type::lua_nil) {
21253  return nullptr;
21254  }
21255  return get_std_func(return_types(), L, index);
21256  }
21257  };
21258 
21259  template <typename Allocator>
21260  struct unqualified_getter<basic_bytecode<Allocator>> {
21261  static basic_bytecode<Allocator> get(lua_State* L, int index, record& tracking) {
21262  tracking.use(1);
21263  stack_function sf(L, index);
21264  return sf.dump(&dump_panic_on_error);
21265  }
21266  };
21267  } // namespace stack
21268 
21269 } // namespace sol
21270 
21271 // end of sol/function.hpp
21272 
21273 // beginning of sol/usertype.hpp
21274 
21275 // beginning of sol/usertype_core.hpp
21276 
21277 // beginning of sol/deprecate.hpp
21278 
21279 #ifndef SOL_DEPRECATED
21280 #ifdef _MSC_VER
21281 #define SOL_DEPRECATED __declspec(deprecated)
21282 #elif __GNUC__
21283 #define SOL_DEPRECATED __attribute__((deprecated))
21284 #else
21285 #define SOL_DEPRECATED [[deprecated]]
21286 #endif // compilers
21287 #endif // SOL_DEPRECATED
21288 
21289 namespace sol { namespace detail {
21290  template <typename T>
21292  using type = T;
21293  };
21294 }} // namespace sol::detail
21295 
21296 // end of sol/deprecate.hpp
21297 
21298 // beginning of sol/usertype_container_launch.hpp
21299 
21300 // beginning of sol/usertype_container.hpp
21301 
21302 namespace sol {
21303 
21304  template <typename T>
21306 
21307  namespace container_detail {
21308 
21309  template <typename T>
21311  private:
21312  template <typename C>
21313  static meta::sfinae_yes_t test(decltype(&C::clear));
21314  template <typename C>
21315  static meta::sfinae_no_t test(...);
21316 
21317  public:
21318  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), meta::sfinae_yes_t>;
21319  };
21320 
21321  template <typename T>
21323  private:
21324  template <typename C>
21325  static meta::sfinae_yes_t test(decltype(&C::empty));
21326  template <typename C>
21327  static meta::sfinae_no_t test(...);
21328 
21329  public:
21330  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), meta::sfinae_yes_t>;
21331  };
21332 
21333  template <typename T>
21335  private:
21336  template <typename C>
21337  static meta::sfinae_yes_t test(
21338  decltype(std::declval<C>().erase_after(std::declval<std::add_rvalue_reference_t<typename C::const_iterator>>()))*);
21339  template <typename C>
21340  static meta::sfinae_no_t test(...);
21341 
21342  public:
21343  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), meta::sfinae_yes_t>;
21344  };
21345 
21346  template <typename T, typename = void>
21347  struct has_find_test {
21348  private:
21349  template <typename C>
21350  static meta::sfinae_yes_t test(decltype(std::declval<C>().find(std::declval<std::add_rvalue_reference_t<typename C::value_type>>()))*);
21351  template <typename C>
21352  static meta::sfinae_no_t test(...);
21353 
21354  public:
21355  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), meta::sfinae_yes_t>;
21356  };
21357 
21358  template <typename T>
21359  struct has_find_test<T, std::enable_if_t<meta::is_lookup<T>::value>> {
21360  private:
21361  template <typename C>
21362  static meta::sfinae_yes_t test(decltype(std::declval<C>().find(std::declval<std::add_rvalue_reference_t<typename C::key_type>>()))*);
21363  template <typename C>
21364  static meta::sfinae_no_t test(...);
21365 
21366  public:
21367  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), meta::sfinae_yes_t>;
21368  };
21369 
21370  template <typename T>
21372  private:
21373  template <typename C>
21374  static meta::sfinae_yes_t test(decltype(std::declval<C>().erase(std::declval<typename C::iterator>()))*);
21375  template <typename C>
21376  static meta::sfinae_no_t test(...);
21377 
21378  public:
21379  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), meta::sfinae_yes_t>;
21380  };
21381 
21382  template <typename T>
21384  private:
21385  template <typename C>
21386  static meta::sfinae_yes_t test(decltype(std::declval<C>().erase(std::declval<typename C::key_type>()))*);
21387  template <typename C>
21388  static meta::sfinae_no_t test(...);
21389 
21390  public:
21391  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), meta::sfinae_yes_t>;
21392  };
21393 
21394  template <typename T>
21396  private:
21397  template <typename C>
21398  static meta::sfinae_yes_t test(decltype(&C::find));
21399  template <typename C>
21400  static meta::sfinae_no_t test(...);
21401 
21402  public:
21403  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), meta::sfinae_yes_t>;
21404  };
21405 
21406  template <typename T>
21408  private:
21409  template <typename C>
21410  static meta::sfinae_yes_t test(decltype(&C::index_of));
21411  template <typename C>
21412  static meta::sfinae_no_t test(...);
21413 
21414  public:
21415  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), meta::sfinae_yes_t>;
21416  };
21417 
21418  template <typename T>
21420  private:
21421  template <typename C>
21422  static meta::sfinae_yes_t test(decltype(&C::insert));
21423  template <typename C>
21424  static meta::sfinae_no_t test(...);
21425 
21426  public:
21427  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), meta::sfinae_yes_t>;
21428  };
21429 
21430  template <typename T>
21432  private:
21433  template <typename C>
21434  static meta::sfinae_yes_t test(decltype(&C::erase));
21435  template <typename C>
21436  static meta::sfinae_no_t test(...);
21437 
21438  public:
21439  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), meta::sfinae_yes_t>;
21440  };
21441 
21442  template <typename T>
21444  private:
21445  template <typename C>
21446  static meta::sfinae_yes_t test(decltype(&C::index_set));
21447  template <typename C>
21448  static meta::sfinae_no_t test(...);
21449 
21450  public:
21451  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), meta::sfinae_yes_t>;
21452  };
21453 
21454  template <typename T>
21456  private:
21457  template <typename C>
21458  static meta::sfinae_yes_t test(decltype(&C::index_get));
21459  template <typename C>
21460  static meta::sfinae_no_t test(...);
21461 
21462  public:
21463  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), meta::sfinae_yes_t>;
21464  };
21465 
21466  template <typename T>
21468  private:
21469  template <typename C>
21470  static meta::sfinae_yes_t test(decltype(&C::set));
21471  template <typename C>
21472  static meta::sfinae_no_t test(...);
21473 
21474  public:
21475  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), meta::sfinae_yes_t>;
21476  };
21477 
21478  template <typename T>
21480  private:
21481  template <typename C>
21482  static meta::sfinae_yes_t test(decltype(&C::get));
21483  template <typename C>
21484  static meta::sfinae_no_t test(...);
21485 
21486  public:
21487  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), meta::sfinae_yes_t>;
21488  };
21489 
21490  template <typename T>
21492  private:
21493  template <typename C>
21494  static meta::sfinae_yes_t test(decltype(&C::at));
21495  template <typename C>
21496  static meta::sfinae_no_t test(...);
21497 
21498  public:
21499  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), meta::sfinae_yes_t>;
21500  };
21501 
21502  template <typename T>
21504  private:
21505  template <typename C>
21506  static meta::sfinae_yes_t test(decltype(&C::pairs));
21507  template <typename C>
21508  static meta::sfinae_no_t test(...);
21509 
21510  public:
21511  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), meta::sfinae_yes_t>;
21512  };
21513 
21514  template <typename T>
21516  private:
21517  template <typename C>
21518  static meta::sfinae_yes_t test(decltype(&C::ipairs));
21519  template <typename C>
21520  static meta::sfinae_no_t test(...);
21521 
21522  public:
21523  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), meta::sfinae_yes_t>;
21524  };
21525 
21526  template <typename T>
21528  private:
21529  template <typename C>
21530  static meta::sfinae_yes_t test(decltype(&C::next));
21531  template <typename C>
21532  static meta::sfinae_no_t test(...);
21533 
21534  public:
21535  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), meta::sfinae_yes_t>;
21536  };
21537 
21538  template <typename T>
21540  private:
21541  template <typename C>
21542  static meta::sfinae_yes_t test(decltype(&C::add));
21543  template <typename C>
21544  static meta::sfinae_no_t test(...);
21545 
21546  public:
21547  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), meta::sfinae_yes_t>;
21548  };
21549 
21550  template <typename T>
21552  private:
21553  template <typename C>
21554  static meta::sfinae_yes_t test(decltype(&C::size));
21555  template <typename C>
21556  static meta::sfinae_no_t test(...);
21557 
21558  public:
21559  static constexpr bool value = std::is_same_v<decltype(test<T>(0)), meta::sfinae_yes_t>;
21560  };
21561 
21562  template <typename T>
21564 
21565  template <typename T>
21567 
21568  template <typename T>
21570 
21571  template <typename T>
21573 
21574  template <typename T>
21576 
21577  template <typename T>
21579 
21580  template <typename T>
21582 
21583  template <typename T>
21585 
21586  template <typename T>
21588 
21589  template <typename T>
21591 
21592  template <typename T>
21594 
21595  template <typename T>
21597 
21598  template <typename T>
21600 
21601  template <typename T>
21603 
21604  template <typename T>
21606 
21607  template <typename T>
21609 
21610  template <typename T>
21612 
21613  template <typename T>
21615 
21616  template <typename T>
21618 
21619  template <typename T>
21621 
21622  template <typename T>
21624 
21625  template <typename T>
21627 
21628  template <typename T>
21630 
21631  template <typename T>
21633 
21634  template <typename T>
21636  typedef T type;
21637  };
21638 
21639  template <typename T>
21641  typedef T type;
21642  };
21643 
21644  template <typename T>
21646 
21647  template <typename T>
21648  decltype(auto) get_key(std::false_type, T&& t) {
21649  return std::forward<T>(t);
21650  }
21651 
21652  template <typename T>
21653  decltype(auto) get_key(std::true_type, T&& t) {
21654  return t.first;
21655  }
21656 
21657  template <typename T>
21658  decltype(auto) get_value(std::false_type, T&& t) {
21659  return std::forward<T>(t);
21660  }
21661 
21662  template <typename T>
21663  decltype(auto) get_value(std::true_type, T&& t) {
21664  return t.second;
21665  }
21666 
21667  template <typename X, typename = void>
21669  private:
21670  typedef std::remove_pointer_t<meta::unwrap_unqualified_t<X>> T;
21671 
21672  public:
21675 
21676  static int at(lua_State* L_) {
21677  return luaL_error(L_, "sol: cannot call 'at(index)' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
21678  }
21679 
21680  static int get(lua_State* L_) {
21681  return luaL_error(L_, "sol: cannot call 'get(key)' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
21682  }
21683 
21684  static int index_get(lua_State* L_) {
21685  return luaL_error(L_, "sol: cannot call 'container[key]' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
21686  }
21687 
21688  static int set(lua_State* L_) {
21689  return luaL_error(L_, "sol: cannot call 'set(key, value)' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
21690  }
21691 
21692  static int index_set(lua_State* L_) {
21693  return luaL_error(
21694  L_, "sol: cannot call 'container[key] = value' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
21695  }
21696 
21697  static int add(lua_State* L_) {
21698  return luaL_error(L_, "sol: cannot call 'add' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
21699  }
21700 
21701  static int insert(lua_State* L_) {
21702  return luaL_error(L_, "sol: cannot call 'insert' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
21703  }
21704 
21705  static int find(lua_State* L_) {
21706  return luaL_error(L_, "sol: cannot call 'find' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
21707  }
21708 
21709  static int index_of(lua_State* L_) {
21710  return luaL_error(L_, "sol: cannot call 'index_of' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
21711  }
21712 
21713  static int size(lua_State* L_) {
21714  return luaL_error(L_, "sol: cannot call 'end' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
21715  }
21716 
21717  static int clear(lua_State* L_) {
21718  return luaL_error(L_, "sol: cannot call 'clear' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
21719  }
21720 
21721  static int empty(lua_State* L_) {
21722  return luaL_error(L_, "sol: cannot call 'empty' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
21723  }
21724 
21725  static int erase(lua_State* L_) {
21726  return luaL_error(L_, "sol: cannot call 'erase' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
21727  }
21728 
21729  static int next(lua_State* L_) {
21730  return luaL_error(L_, "sol: cannot call 'next' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
21731  }
21732 
21733  static int pairs(lua_State* L_) {
21734  return luaL_error(L_, "sol: cannot call '__pairs/pairs' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
21735  }
21736 
21737  static int ipairs(lua_State* L_) {
21738  return luaL_error(L_, "sol: cannot call '__ipairs' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
21739  }
21740 
21741  static iterator begin(lua_State* L_, T&) {
21742  luaL_error(L_, "sol: cannot call 'being' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
21743  return lua_nil;
21744  }
21745 
21746  static iterator end(lua_State* L_, T&) {
21747  luaL_error(L_, "sol: cannot call 'end' on type '%s': it is not recognized as a container", detail::demangle<T>().c_str());
21748  return lua_nil;
21749  }
21750  };
21751 
21752  template <typename X>
21754  std::enable_if_t<meta::all<is_forced_container<meta::unqualified_t<X>>, meta::has_value_type<meta::unqualified_t<container_decay_t<X>>>,
21755  meta::has_iterator<meta::unqualified_t<container_decay_t<X>>>>::value>> {
21756  private:
21757  using T = std::remove_pointer_t<meta::unwrap_unqualified_t<container_decay_t<X>>>;
21758 
21759  private:
21765  using iterator = typename T::iterator;
21766  using value_type = typename T::value_type;
21770  typedef typename KV::first_type K;
21771  typedef typename KV::second_type V;
21773  typedef decltype(*std::declval<iterator&>()) iterator_return;
21774  typedef meta::conditional_t<is_associative::value || is_matched_lookup::value, std::add_lvalue_reference_t<V>,
21775  meta::conditional_t<is_lookup::value, V, iterator_return>>
21777  typedef typename meta::iterator_tag<iterator>::type iterator_category;
21778  typedef std::is_same<iterator_category, std::input_iterator_tag> is_input_iterator;
21779  typedef meta::conditional_t<is_input_iterator::value, V, decltype(detail::deref_move_only(std::declval<captured_type>()))> push_type;
21780  typedef std::is_copy_assignable<V> is_copyable;
21781  typedef meta::neg<meta::any<std::is_const<V>, std::is_const<std::remove_reference_t<iterator_return>>, meta::neg<is_copyable>>> is_writable;
21782  typedef meta::unqualified_t<decltype(get_key(is_associative(), std::declval<std::add_lvalue_reference_t<value_type>>()))> key_type;
21783  typedef meta::all<std::is_integral<K>, meta::neg<meta::any<is_associative, is_lookup>>> is_linear_integral;
21784 
21785  struct iter {
21790 
21791  iter(lua_State* L_, int stack_index, T& source_, iterator it_) : keep_alive(sol::main_thread(L_, L_), stack_index), source(source_), it(std::move(it_)), index(0) {
21792  }
21793 
21794  ~iter() {
21795  }
21796  };
21797 
21798  static auto& get_src(lua_State* L_) {
21799 #if SOL_IS_ON(SOL_SAFE_USERTYPE)
21800  auto p = stack::unqualified_check_get<T*>(L_, 1);
21801  if (!p) {
21802  luaL_error(L_,
21803  "sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)",
21804  detail::demangle<T>().c_str());
21805  }
21806  if (p.value() == nullptr) {
21807  luaL_error(
21808  L_, "sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle<T>().c_str());
21809  }
21810  return *p.value();
21811 #else
21812  return stack::unqualified_get<T>(L_, 1);
21813 #endif // Safe getting with error
21814  }
21815 
21816  static detail::error_result at_category(std::input_iterator_tag, lua_State* L_, T& self, std::ptrdiff_t pos) {
21817  pos += deferred_uc::index_adjustment(L_, self);
21818  if (pos < 0) {
21819  return stack::push(L_, lua_nil);
21820  }
21821  auto it = deferred_uc::begin(L_, self);
21822  auto e = deferred_uc::end(L_, self);
21823  if (it == e) {
21824  return stack::push(L_, lua_nil);
21825  }
21826  while (pos > 0) {
21827  --pos;
21828  ++it;
21829  if (it == e) {
21830  return stack::push(L_, lua_nil);
21831  }
21832  }
21833  return get_associative(is_associative(), L_, it);
21834  }
21835 
21836  static detail::error_result at_category(std::random_access_iterator_tag, lua_State* L_, T& self, std::ptrdiff_t pos) {
21837  std::ptrdiff_t len = static_cast<std::ptrdiff_t>(size_start(L_, self));
21838  pos += deferred_uc::index_adjustment(L_, self);
21839  if (pos < 0 || pos >= len) {
21840  return stack::push(L_, lua_nil);
21841  }
21842  auto it = std::next(deferred_uc::begin(L_, self), pos);
21843  return get_associative(is_associative(), L_, it);
21844  }
21845 
21846  static detail::error_result at_start(lua_State* L_, T& self, std::ptrdiff_t pos) {
21847  return at_category(iterator_category(), L_, self, pos);
21848  }
21849 
21850  template <typename Iter>
21852  decltype(auto) v = *it;
21853  return stack::stack_detail::push_reference<push_type>(L_, detail::deref_move_only(v.second));
21854  }
21855 
21856  template <typename Iter>
21858  return stack::stack_detail::push_reference<push_type>(L_, detail::deref_move_only(*it));
21859  }
21860 
21861  static detail::error_result get_category(std::input_iterator_tag, lua_State* L_, T& self, K& key) {
21862  key = static_cast<K>(key + deferred_uc::index_adjustment(L_, self));
21863  if (key < 0) {
21864  return stack::push(L_, lua_nil);
21865  }
21866  auto it = deferred_uc::begin(L_, self);
21867  auto e = deferred_uc::end(L_, self);
21868  if (it == e) {
21869  return stack::push(L_, lua_nil);
21870  }
21871  while (key > 0) {
21872  --key;
21873  ++it;
21874  if (it == e) {
21875  return stack::push(L_, lua_nil);
21876  }
21877  }
21878  return get_associative(is_associative(), L_, it);
21879  }
21880 
21881  static detail::error_result get_category(std::random_access_iterator_tag, lua_State* L_, T& self, K& key) {
21882  std::ptrdiff_t len = static_cast<std::ptrdiff_t>(size_start(L_, self));
21883  key = static_cast<K>(static_cast<std::ptrdiff_t>(key) + deferred_uc::index_adjustment(L_, self));
21884  if (key < 0 || key >= len) {
21885  return stack::push(L_, lua_nil);
21886  }
21887  auto it = std::next(deferred_uc::begin(L_, self), key);
21888  return get_associative(is_associative(), L_, it);
21889  }
21890 
21892  return get_category(iterator_category(), L_, self, key);
21893  }
21894 
21896  auto fx = [&](const value_type& r) -> bool { return key == get_key(is_associative(), r); };
21897  auto e = deferred_uc::end(L_, self);
21898  auto it = std::find_if(deferred_uc::begin(L_, self), e, std::ref(fx));
21899  if (it == e) {
21900  return stack::push(L_, lua_nil);
21901  }
21902  return get_associative(is_associative(), L_, it);
21903  }
21904 
21906  return detail::error_result("cannot get this key on '%s': no suitable way to increment iterator and compare to key value '%s'",
21907  detail::demangle<T>().data(),
21908  detail::demangle<K>().data());
21909  }
21910 
21912  return get_comparative(meta::supports_op_equal<K, key_type>(), L_, self, key);
21913  }
21914 
21916  decltype(auto) v = *it;
21917  v.second = value.as<V>();
21918  return {};
21919  }
21920 
21922  decltype(auto) v = *it;
21923  v = value.as<V>();
21924  return {};
21925  }
21926 
21928  return set_associative(is_associative(), it, std::move(value));
21929  }
21930 
21932  return detail::error_result(
21933  "cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle<T>().data());
21934  }
21935 
21936  static detail::error_result set_category(std::input_iterator_tag, lua_State* L_, T& self, stack_object okey, stack_object value) {
21937  decltype(auto) key = okey.as<K>();
21938  key = static_cast<K>(static_cast<std::ptrdiff_t>(key) + deferred_uc::index_adjustment(L_, self));
21939  auto e = deferred_uc::end(L_, self);
21940  auto it = deferred_uc::begin(L_, self);
21941  auto backit = it;
21942  for (; key > 0 && it != e; --key, ++it) {
21943  backit = it;
21944  }
21945  if (it == e) {
21946  if (key == 0) {
21947  return add_copyable(is_copyable(), L_, self, std::move(value), meta::has_insert_after<T>::value ? backit : it);
21948  }
21949  return detail::error_result("out of bounds (too big) for set on '%s'", detail::demangle<T>().c_str());
21950  }
21951  return set_writable(is_writable(), L_, self, it, std::move(value));
21952  }
21953 
21954  static detail::error_result set_category(std::random_access_iterator_tag, lua_State* L_, T& self, stack_object okey, stack_object value) {
21955  decltype(auto) key = okey.as<K>();
21956  key = static_cast<K>(static_cast<std::ptrdiff_t>(key) + deferred_uc::index_adjustment(L_, self));
21957  if (key < 0) {
21958  return detail::error_result("sol: out of bounds (too small) for set on '%s'", detail::demangle<T>().c_str());
21959  }
21960  std::ptrdiff_t len = static_cast<std::ptrdiff_t>(size_start(L_, self));
21961  if (key == len) {
21962  return add_copyable(is_copyable(), L_, self, std::move(value));
21963  }
21964  else if (key >= len) {
21965  return detail::error_result("sol: out of bounds (too big) for set on '%s'", detail::demangle<T>().c_str());
21966  }
21967  auto it = std::next(deferred_uc::begin(L_, self), key);
21968  return set_writable(is_writable(), L_, self, it, std::move(value));
21969  }
21970 
21972  decltype(auto) key = okey.as<K>();
21973  if (!is_writable::value) {
21974  return detail::error_result(
21975  "cannot perform a 'set': '%s's iterator reference is not writable (non-copy-assignable or const)", detail::demangle<T>().data());
21976  }
21977  auto fx = [&](const value_type& r) -> bool { return key == get_key(is_associative(), r); };
21978  auto e = deferred_uc::end(L_, self);
21979  auto it = std::find_if(deferred_uc::begin(L_, self), e, std::ref(fx));
21980  if (it == e) {
21981  return {};
21982  }
21983  return set_writable(is_writable(), L_, self, it, std::move(value));
21984  }
21985 
21987  return detail::error_result("cannot set this value on '%s': no suitable way to increment iterator or compare to '%s' key",
21988  detail::demangle<T>().data(),
21989  detail::demangle<K>().data());
21990  }
21991 
21992  template <typename Iter>
21995  self.insert(it, value_type(key, value.as<V>()));
21996  return {};
21997  }
21998  else if constexpr (meta::has_insert<T>::value) {
21999  self.insert(value_type(key, value.as<V>()));
22000  return {};
22001  }
22002  else {
22003  (void)self;
22004  (void)it;
22005  (void)key;
22006  return detail::error_result(
22007  "cannot call 'set' on '%s': there is no 'insert' function on this associative type", detail::demangle<T>().c_str());
22008  }
22009  }
22010 
22011  template <typename Iter>
22014  self.insert(it, key);
22015  return {};
22016  }
22017  else if constexpr (meta::has_insert<T>::value) {
22018  self.insert(key);
22019  return {};
22020  }
22021  else {
22022  (void)self;
22023  (void)it;
22024  (void)key;
22025  return detail::error_result(
22026  "cannot call 'set' on '%s': there is no 'insert' function on this non-associative type", detail::demangle<T>().c_str());
22027  }
22028  }
22029 
22031  decltype(auto) key = okey.as<K>();
22032  auto it = self.find(key);
22033  if (it == deferred_uc::end(L_, self)) {
22034  return set_associative_insert(is_associative(), L_, self, it, key, std::move(value));
22035  }
22036  return set_writable(is_writable(), L_, self, it, std::move(value));
22037  }
22038 
22040  return set_comparative(meta::supports_op_equal<K, key_type>(), L_, self, std::move(key), std::move(value));
22041  }
22042 
22044  return set_category(iterator_category(), L_, self, std::move(key), std::move(value));
22045  }
22046 
22048  return set_associative_find(meta::all<has_find<T>, meta::any<is_associative, is_lookup>>(), L_, self, std::move(key), std::move(value));
22049  }
22050 
22051  template <bool idx_of = false>
22053  if constexpr (!is_ordered::value && idx_of) {
22054  (void)L_;
22055  (void)self;
22056  return detail::error_result("cannot perform an 'index_of': '%s's is not an ordered container", detail::demangle<T>().data());
22057  }
22058  else {
22059  decltype(auto) key = stack::unqualified_get<K>(L_, 2);
22060  auto it = self.find(key);
22061  if (it == deferred_uc::end(L_, self)) {
22062  return stack::push(L_, lua_nil);
22063  }
22064  if constexpr (idx_of) {
22065  auto dist = std::distance(deferred_uc::begin(L_, self), it);
22066  dist -= deferred_uc::index_adjustment(L_, self);
22067  return stack::push(L_, dist);
22068  }
22069  else {
22070  return get_associative(is_associative(), L_, it);
22071  }
22072  }
22073  }
22074 
22075  template <bool idx_of = false>
22077  if constexpr (!is_ordered::value && idx_of) {
22078  (void)L_;
22079  (void)self;
22080  return detail::error_result("cannot perform an 'index_of': '%s's is not an ordered container", detail::demangle<T>().data());
22081  }
22082  else {
22083  decltype(auto) value = stack::unqualified_get<V>(L_, 2);
22084  auto it = self.find(value);
22085  if (it == deferred_uc::end(L_, self)) {
22086  return stack::push(L_, lua_nil);
22087  }
22088  if constexpr (idx_of) {
22089  auto dist = std::distance(deferred_uc::begin(L_, self), it);
22090  dist -= deferred_uc::index_adjustment(L_, self);
22091  return stack::push(L_, dist);
22092  }
22093  else {
22094  return get_associative(is_associative(), L_, it);
22095  }
22096  }
22097  }
22098 
22099  template <bool idx_of = false>
22101  return find_has_associative_lookup<idx_of>(meta::any<is_lookup, is_associative>(), L_, self);
22102  }
22103 
22104  template <typename Iter>
22106  return get_associative(is_associative(), L_, it);
22107  }
22108 
22109  template <typename Iter>
22111  idx = static_cast<std::size_t>(static_cast<std::ptrdiff_t>(idx) - deferred_uc::index_adjustment(L_, self));
22112  return stack::push(L_, idx);
22113  }
22114 
22115  template <bool = false>
22117  return detail::error_result("cannot call 'find' on '%s': there is no 'find' function and the value_type is not equality comparable",
22118  detail::demangle<T>().c_str());
22119  }
22120 
22121  template <bool idx_of = false>
22123  decltype(auto) value = stack::unqualified_get<V>(L_, 2);
22124  auto it = deferred_uc::begin(L_, self);
22125  auto e = deferred_uc::end(L_, self);
22126  std::size_t idx = 0;
22127  for (;; ++it, ++idx) {
22128  if (it == e) {
22129  return stack::push(L_, lua_nil);
22130  }
22131  if (value == get_value(is_associative(), *it)) {
22132  break;
22133  }
22134  }
22135  return find_associative_lookup(meta::all<meta::boolean<!idx_of>, meta::any<is_lookup, is_associative>>(), L_, self, it, idx);
22136  }
22137 
22138  template <bool idx_of = false>
22140  return find_comparative<idx_of>(meta::supports_op_equal<V>(), L_, self);
22141  }
22142 
22143  template <typename Iter>
22145  return add_insert_after(std::false_type(), L_, self, value);
22146  }
22147 
22149  return detail::error_result("cannot call 'add' on type '%s': no suitable insert/push_back C++ functions", detail::demangle<T>().data());
22150  }
22151 
22152  template <typename Iter>
22154  self.insert_after(pos, value.as<V>());
22155  return {};
22156  }
22157 
22159  auto backit = self.before_begin();
22160  {
22161  auto e = deferred_uc::end(L_, self);
22162  for (auto it = deferred_uc::begin(L_, self); it != e; ++backit, ++it) { }
22163  }
22164  return add_insert_after(std::true_type(), L_, self, value, backit);
22165  }
22166 
22167  template <typename Iter>
22169  self.insert(pos, value.as<V>());
22170  return {};
22171  }
22172 
22174  auto pos = deferred_uc::end(L_, self);
22175  return add_insert(std::true_type(), L_, self, value, pos);
22176  }
22177 
22178  template <typename Iter>
22179  static detail::error_result add_insert(std::false_type, lua_State* L_, T& self, stack_object value, Iter& pos) {
22180  return add_insert_after(meta::has_insert_after<T>(), L_, self, std::move(value), pos);
22181  }
22182 
22184  return add_insert_after(meta::has_insert_after<T>(), L_, self, std::move(value));
22185  }
22186 
22187  template <typename Iter>
22189  self.push_back(value.as<V>());
22190  return {};
22191  }
22192 
22194  self.push_back(value.as<V>());
22195  return {};
22196  }
22197 
22198  template <typename Iter>
22200  return add_insert(
22201  std::integral_constant < bool, meta::has_insert<T>::value || meta::has_insert_with_iterator<T>::value > (), L_, self, value, pos);
22202  }
22203 
22205  return add_insert(
22206  std::integral_constant < bool, meta::has_insert<T>::value || meta::has_insert_with_iterator<T>::value > (), L_, self, value);
22207  }
22208 
22209  template <typename Iter>
22212  self.insert(pos, value_type(key.as<K>(), stack::unqualified_get<V>(L_, 3)));
22213  return {};
22214  }
22215  else if constexpr (meta::has_insert<T>::value) {
22216  self.insert(value_type(key.as<K>(), stack::unqualified_get<V>(L_, 3)));
22217  return {};
22218  }
22219  else {
22220  (void)L_;
22221  (void)self;
22222  (void)key;
22223  (void)pos;
22224  return detail::error_result(
22225  "cannot call 'insert' on '%s': there is no 'insert' function on this associative type", detail::demangle<T>().c_str());
22226  }
22227  }
22228 
22230  auto pos = deferred_uc::end(L_, self);
22231  return add_associative(std::true_type(), L_, self, std::move(key), pos);
22232  }
22233 
22234  template <typename Iter>
22236  return add_push_back(meta::has_push_back<T>(), L_, self, value, pos);
22237  }
22238 
22240  return add_push_back(meta::has_push_back<T>(), L_, self, value);
22241  }
22242 
22243  template <typename Iter>
22245  return add_associative(is_associative(), L_, self, std::move(value), pos);
22246  }
22247 
22249  return add_associative(is_associative(), L_, self, value);
22250  }
22251 
22252  template <typename Iter>
22254  return add_copyable(std::false_type(), L_, self, std::move(value));
22255  }
22256 
22258  return detail::error_result("cannot call 'add' on '%s': value_type is non-copyable", detail::demangle<T>().data());
22259  }
22260 
22262  // TODO: should we warn or error about someone calling insert on an ordered / lookup container with no associativity?
22263  return add_copyable(std::true_type(), L_, self, std::move(value));
22264  }
22265 
22267  auto it = deferred_uc::begin(L_, self);
22268  auto key = where.as<K>();
22269  key = static_cast<K>(static_cast<std::ptrdiff_t>(key) + deferred_uc::index_adjustment(L_, self));
22270  std::advance(it, key);
22271  self.insert(it, value.as<V>());
22272  return {};
22273  }
22274 
22276  auto key = where.as<K>();
22277  auto backit = self.before_begin();
22278  {
22279  key = static_cast<K>(static_cast<std::ptrdiff_t>(key) + deferred_uc::index_adjustment(L_, self));
22280  auto e = deferred_uc::end(L_, self);
22281  for (auto it = deferred_uc::begin(L_, self); key > 0; ++backit, ++it, --key) {
22282  if (backit == e) {
22283  return detail::error_result("sol: out of bounds (too big) for set on '%s'", detail::demangle<T>().c_str());
22284  }
22285  }
22286  }
22287  self.insert_after(backit, value.as<V>());
22288  return {};
22289  }
22290 
22292  return detail::error_result(
22293  "cannot call 'insert' on '%s': no suitable or similar functionality detected on this container", detail::demangle<T>().data());
22294  }
22295 
22297  return insert_lookup(meta::any<is_associative, is_lookup>(), L_, self, std::move(key), std::move(value));
22298  }
22299 
22301  return insert_after_has(meta::has_insert_after<T>(), L_, self, where, value);
22302  }
22303 
22305  return insert_has(std::integral_constant < bool,
22307  L_,
22308  self,
22309  std::move(key),
22310  std::move(value));
22311  }
22312 
22314  return detail::error_result("cannot call 'insert' on '%s': value_type is non-copyable", detail::demangle<T>().data());
22315  }
22316 
22318  auto it = deferred_uc::begin(L_, self);
22319  key = (static_cast<std::ptrdiff_t>(key) + deferred_uc::index_adjustment(L_, self));
22320  std::advance(it, key);
22321  self.erase(it);
22322 
22323  return {};
22324  }
22325 
22327  auto fx = [&](const value_type& r) -> bool { return key == r; };
22328  auto e = deferred_uc::end(L_, self);
22329  auto it = std::find_if(deferred_uc::begin(L_, self), e, std::ref(fx));
22330  if (it == e) {
22331  return {};
22332  }
22333  self.erase(it);
22334 
22335  return {};
22336  }
22337 
22339  self.erase(key);
22340  return {};
22341  }
22342 
22344  return erase_integral(std::is_integral<K>(), L_, self, key);
22345  }
22346 
22348  auto backit = self.before_begin();
22349  {
22350  key = static_cast<K>(static_cast<std::ptrdiff_t>(key) + deferred_uc::index_adjustment(L_, self));
22351  auto e = deferred_uc::end(L_, self);
22352  for (auto it = deferred_uc::begin(L_, self); key > 0; ++backit, ++it, --key) {
22353  if (backit == e) {
22354  return detail::error_result("sol: out of bounds for erase on '%s'", detail::demangle<T>().c_str());
22355  }
22356  }
22357  }
22358  self.erase_after(backit);
22359  return {};
22360  }
22361 
22363  return detail::error_result("sol: cannot call erase on '%s'", detail::demangle<T>().c_str());
22364  }
22365 
22367  return erase_associative_lookup(meta::any<is_associative, is_lookup>(), L_, self, key);
22368  }
22369 
22371  return erase_after_has(has_erase_after<T>(), L_, self, key);
22372  }
22373 
22375  return erase_associative_lookup(meta::any<is_associative, is_lookup>(), L_, self, key);
22376  }
22377 
22379  return erase_key_has(has_erase_key<T>(), L_, self, key);
22380  }
22381 
22382  static auto size_has(std::false_type, lua_State* L_, T& self) {
22383  return std::distance(deferred_uc::begin(L_, self), deferred_uc::end(L_, self));
22384  }
22385 
22386  static auto size_has(std::true_type, lua_State*, T& self) {
22387  return self.size();
22388  }
22389 
22390  static void clear_has(std::true_type, lua_State*, T& self) {
22391  self.clear();
22392  }
22393 
22394  static void clear_has(std::false_type, lua_State* L_, T&) {
22395  luaL_error(L_, "sol: cannot call clear on '%s'", detail::demangle<T>().c_str());
22396  }
22397 
22398  static bool empty_has(std::true_type, lua_State*, T& self) {
22399  return self.empty();
22400  }
22401 
22402  static bool empty_has(std::false_type, lua_State* L_, T& self) {
22403  return deferred_uc::begin(L_, self) == deferred_uc::end(L_, self);
22404  }
22405 
22407  auto it = self.find(key);
22408  if (it == deferred_uc::end(L_, self)) {
22409  stack::push(L_, lua_nil);
22410  return {};
22411  }
22412  return get_associative(std::true_type(), L_, it);
22413  }
22414 
22416  return get_it(is_linear_integral(), L_, self, key);
22417  }
22418 
22419  static detail::error_result get_start(lua_State* L_, T& self, K& key) {
22420  return get_associative_find(std::integral_constant < bool, is_associative::value&& has_find<T>::value > (), L_, self, key);
22421  }
22422 
22424  return set_it(is_linear_integral(), L_, self, std::move(key), std::move(value));
22425  }
22426 
22427  static std::size_t size_start(lua_State* L_, T& self) {
22428  return static_cast<std::size_t>(size_has(meta::has_size<T>(), L_, self));
22429  }
22430 
22431  static void clear_start(lua_State* L_, T& self) {
22432  clear_has(has_clear<T>(), L_, self);
22433  }
22434 
22435  static bool empty_start(lua_State* L_, T& self) {
22436  return empty_has(has_empty<T>(), L_, self);
22437  }
22438 
22439  static detail::error_result erase_start(lua_State* L_, T& self, K& key) {
22440  return erase_has(has_erase<T>(), L_, self, key);
22441  }
22442 
22443  template <bool ip>
22445  iter& i = stack::unqualified_get<user<iter>>(L_, 1);
22446  auto& source = i.source;
22447  auto& it = i.it;
22448  if (it == deferred_uc::end(L_, source)) {
22449  return stack::push(L_, lua_nil);
22450  }
22451  int p;
22452  if constexpr (ip) {
22453  ++i.index;
22454  p = stack::push_reference(L_, i.index);
22455  }
22456  else {
22457  p = stack::push_reference(L_, it->first);
22458  }
22459  p += stack::stack_detail::push_reference<push_type>(L_, detail::deref_move_only(it->second));
22460  std::advance(it, 1);
22461  return p;
22462  }
22463 
22464  template <bool>
22466  iter& i = stack::unqualified_get<user<iter>>(L_, 1);
22467  auto& source = i.source;
22468  auto& it = i.it;
22469  next_K k = stack::unqualified_get<next_K>(L_, 2);
22470  if (it == deferred_uc::end(L_, source)) {
22471  return stack::push(L_, lua_nil);
22472  }
22473  int p;
22474  if constexpr (std::is_integral_v<next_K>) {
22475  p = stack::push_reference(L_, k + 1);
22476  }
22477  else {
22478  p = stack::stack_detail::push_reference(L_, k + 1);
22479  }
22480  p += stack::stack_detail::push_reference<push_type>(L_, detail::deref_move_only(*it));
22481  std::advance(it, 1);
22482  return p;
22483  }
22484 
22485  template <bool ip>
22486  static int next_iter(lua_State* L_) {
22488  return next_associative<ip>(is_assoc(), L_);
22489  }
22490 
22491  template <bool ip>
22493  auto& src = get_src(L_);
22494  stack::push(L_, next_iter<ip>);
22495  stack::push<user<iter>>(L_, L_, 1, src, deferred_uc::begin(L_, src));
22496  stack::push(L_, lua_nil);
22497  return 3;
22498  }
22499 
22500  template <bool ip>
22502  auto& src = get_src(L_);
22503  stack::push(L_, next_iter<ip>);
22504  stack::push<user<iter>>(L_, L_, 1, src, deferred_uc::begin(L_, src));
22505  stack::push(L_, 0);
22506  return 3;
22507  }
22508 
22509  public:
22510  static int at(lua_State* L_) {
22511  auto& self = get_src(L_);
22513  {
22514  std::ptrdiff_t pos = stack::unqualified_get<std::ptrdiff_t>(L_, 2);
22515  er = at_start(L_, self, pos);
22516  }
22517  return handle_errors(L_, er);
22518  }
22519 
22520  static int get(lua_State* L_) {
22521  auto& self = get_src(L_);
22523  {
22524  decltype(auto) key = stack::unqualified_get<K>(L_);
22525  er = get_start(L_, self, key);
22526  }
22527  return handle_errors(L_, er);
22528  }
22529 
22530  static int index_get(lua_State* L_) {
22531  return get(L_);
22532  }
22533 
22534  static int set(lua_State* L_) {
22535  stack_object value = stack_object(L_, raw_index(3));
22536  if constexpr (is_linear_integral::value) {
22537  // for non-associative containers,
22538  // erasure only happens if it is the
22539  // last index in the container
22540  auto key = stack::get<K>(L_, 2);
22541  auto self_size = deferred_uc::size(L_);
22542  if (key == static_cast<K>(self_size)) {
22543  if (type_of(L_, 3) == type::lua_nil) {
22544  return erase(L_);
22545  }
22546  }
22547  }
22548  else {
22549  if (type_of(L_, 3) == type::lua_nil) {
22550  return erase(L_);
22551  }
22552  }
22553  auto& self = get_src(L_);
22554  detail::error_result er = set_start(L_, self, stack_object(L_, raw_index(2)), std::move(value));
22555  return handle_errors(L_, er);
22556  }
22557 
22558  static int index_set(lua_State* L_) {
22559  return set(L_);
22560  }
22561 
22562  static int add(lua_State* L_) {
22563  auto& self = get_src(L_);
22564  detail::error_result er = add_copyable(is_copyable(), L_, self, stack_object(L_, raw_index(2)));
22565  return handle_errors(L_, er);
22566  }
22567 
22568  static int insert(lua_State* L_) {
22569  auto& self = get_src(L_);
22570  detail::error_result er = insert_copyable(is_copyable(), L_, self, stack_object(L_, raw_index(2)), stack_object(L_, raw_index(3)));
22571  return handle_errors(L_, er);
22572  }
22573 
22574  static int find(lua_State* L_) {
22575  auto& self = get_src(L_);
22576  detail::error_result er = find_has(has_find<T>(), L_, self);
22577  return handle_errors(L_, er);
22578  }
22579 
22580  static int index_of(lua_State* L_) {
22581  auto& self = get_src(L_);
22582  detail::error_result er = find_has<true>(has_find<T>(), L_, self);
22583  return handle_errors(L_, er);
22584  }
22585 
22586  static iterator begin(lua_State*, T& self) {
22587  if constexpr (meta::has_begin_end_v<T>) {
22588  return self.begin();
22589  }
22590  else {
22591  using std::begin;
22592  return begin(self);
22593  }
22594  }
22595 
22596  static iterator end(lua_State*, T& self) {
22597  if constexpr (meta::has_begin_end_v<T>) {
22598  return self.end();
22599  }
22600  else {
22601  using std::end;
22602  return end(self);
22603  }
22604  }
22605 
22606  static int size(lua_State* L_) {
22607  auto& self = get_src(L_);
22608  std::size_t r = size_start(L_, self);
22609  return stack::push(L_, r);
22610  }
22611 
22612  static int clear(lua_State* L_) {
22613  auto& self = get_src(L_);
22614  clear_start(L_, self);
22615  return 0;
22616  }
22617 
22618  static int erase(lua_State* L_) {
22619  auto& self = get_src(L_);
22621  {
22622  decltype(auto) key = stack::unqualified_get<K>(L_, 2);
22623  er = erase_start(L_, self, key);
22624  }
22625  return handle_errors(L_, er);
22626  }
22627 
22628  static int empty(lua_State* L_) {
22629  auto& self = get_src(L_);
22630  return stack::push(L_, empty_start(L_, self));
22631  }
22632 
22633  static std::ptrdiff_t index_adjustment(lua_State*, T&) {
22634  return static_cast<std::ptrdiff_t>((SOL_CONTAINER_START_INDEX_I_) == 0 ? 0 : -(SOL_CONTAINER_START_INDEX_I_));
22635  }
22636 
22637  static int pairs(lua_State* L_) {
22639  return pairs_associative<false>(is_assoc(), L_);
22640  }
22641 
22642  static int ipairs(lua_State* L_) {
22644  return pairs_associative<true>(is_assoc(), L_);
22645  }
22646 
22647  static int next(lua_State* L_) {
22648  return stack::push(L_, next_iter<false>);
22649  }
22650  };
22651 
22652  template <typename X>
22653  struct usertype_container_default<X, std::enable_if_t<std::is_array<std::remove_pointer_t<meta::unwrap_unqualified_t<X>>>::value>> {
22654  private:
22655  typedef std::remove_pointer_t<meta::unwrap_unqualified_t<X>> T;
22657 
22658  public:
22659  typedef std::remove_extent_t<T> value_type;
22661 
22662  private:
22663  struct iter {
22667 
22668  iter(lua_State* L_, int stack_index, T& source, iterator it) noexcept
22669  : keep_alive(sol::main_thread(L_, L_), stack_index), source(source), it(std::move(it)) {
22670  }
22671 
22672  ~iter() {
22673 
22674  }
22675  };
22676 
22677  static auto& get_src(lua_State* L_) {
22678  auto p = stack::unqualified_check_get<T*>(L_, 1);
22679 #if SOL_IS_ON(SOL_SAFE_USERTYPE)
22680  if (!p) {
22681  luaL_error(L_,
22682  "sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)",
22683  detail::demangle<T>().c_str());
22684  }
22685  if (p.value() == nullptr) {
22686  luaL_error(
22687  L_, "sol: 'self' argument is nil (pass 'self' as first argument with ':' or call on a '%s' type)", detail::demangle<T>().c_str());
22688  }
22689 #endif // Safe getting with error
22690  return *p.value();
22691  }
22692 
22693  static int find(std::true_type, lua_State* L_) {
22694  T& self = get_src(L_);
22695  decltype(auto) value = stack::unqualified_get<value_type>(L_, 2);
22696  std::size_t N = std::extent<T>::value;
22697  for (std::size_t idx = 0; idx < N; ++idx) {
22698  using v_t = std::add_const_t<decltype(self[idx])>;
22699  v_t v = self[idx];
22700  if (v == value) {
22701  idx = static_cast<std::size_t>(static_cast<std::ptrdiff_t>(idx) - deferred_uc::index_adjustment(L_, self));
22702  return stack::push(L_, idx);
22703  }
22704  }
22705  return stack::push(L_, lua_nil);
22706  }
22707 
22708  static int find(std::false_type, lua_State* L_) {
22709  return luaL_error(L_, "sol: cannot call 'find' on '%s': no supported comparison operator for the value type", detail::demangle<T>().c_str());
22710  }
22711 
22712  static int next_iter(lua_State* L_) {
22713  iter& i = stack::unqualified_get<user<iter>>(L_, 1);
22714  auto& source = i.source;
22715  auto& it = i.it;
22716  std::size_t k = stack::unqualified_get<std::size_t>(L_, 2);
22717  if (it == deferred_uc::end(L_, source)) {
22718  return 0;
22719  }
22720  int p;
22721  p = stack::push(L_, k + 1);
22723  std::advance(it, 1);
22724  return p;
22725  }
22726 
22727  public:
22728  static int clear(lua_State* L_) {
22729  return luaL_error(L_, "sol: cannot call 'clear' on type '%s': cannot remove all items from a fixed array", detail::demangle<T>().c_str());
22730  }
22731 
22732  static int erase(lua_State* L_) {
22733  return luaL_error(L_, "sol: cannot call 'erase' on type '%s': cannot remove an item from fixed arrays", detail::demangle<T>().c_str());
22734  }
22735 
22736  static int add(lua_State* L_) {
22737  return luaL_error(L_, "sol: cannot call 'add' on type '%s': cannot add to fixed arrays", detail::demangle<T>().c_str());
22738  }
22739 
22740  static int insert(lua_State* L_) {
22741  return luaL_error(L_, "sol: cannot call 'insert' on type '%s': cannot insert new entries into fixed arrays", detail::demangle<T>().c_str());
22742  }
22743 
22744  static int at(lua_State* L_) {
22745  return get(L_);
22746  }
22747 
22748  static int get(lua_State* L_) {
22749  T& self = get_src(L_);
22750  std::ptrdiff_t idx = stack::unqualified_get<std::ptrdiff_t>(L_, 2);
22751  idx += deferred_uc::index_adjustment(L_, self);
22752  if (idx >= static_cast<std::ptrdiff_t>(std::extent<T>::value) || idx < 0) {
22753  return stack::push(L_, lua_nil);
22754  }
22755  return stack::push_reference(L_, detail::deref_move_only(self[idx]));
22756  }
22757 
22758  static int index_get(lua_State* L_) {
22759  return get(L_);
22760  }
22761 
22762  static int set(lua_State* L_) {
22763  T& self = get_src(L_);
22764  std::ptrdiff_t idx = stack::unqualified_get<std::ptrdiff_t>(L_, 2);
22765  idx += deferred_uc::index_adjustment(L_, self);
22766  if (idx >= static_cast<std::ptrdiff_t>(std::extent<T>::value)) {
22767  return luaL_error(L_, "sol: index out of bounds (too big) for set on '%s'", detail::demangle<T>().c_str());
22768  }
22769  if (idx < 0) {
22770  return luaL_error(L_, "sol: index out of bounds (too small) for set on '%s'", detail::demangle<T>().c_str());
22771  }
22772  self[idx] = stack::unqualified_get<value_type>(L_, 3);
22773  return 0;
22774  }
22775 
22776  static int index_set(lua_State* L_) {
22777  return set(L_);
22778  }
22779 
22780  static int index_of(lua_State* L_) {
22781  return find(L_);
22782  }
22783 
22784  static int find(lua_State* L_) {
22786  }
22787 
22788  static int size(lua_State* L_) {
22789  return stack::push(L_, std::extent<T>::value);
22790  }
22791 
22792  static int empty(lua_State* L_) {
22793  return stack::push(L_, std::extent<T>::value > 0);
22794  }
22795 
22796  static int pairs(lua_State* L_) {
22797  auto& src = get_src(L_);
22798  stack::push(L_, next_iter);
22799  stack::push<user<iter>>(L_, L_, 1, src, deferred_uc::begin(L_, src));
22800  stack::push(L_, 0);
22801  return 3;
22802  }
22803 
22804  static int ipairs(lua_State* L_) {
22805  return pairs(L_);
22806  }
22807 
22808  static int next(lua_State* L_) {
22809  return stack::push(L_, next_iter);
22810  }
22811 
22812  static std::ptrdiff_t index_adjustment(lua_State*, T&) {
22814  }
22815 
22816  static iterator begin(lua_State*, T& self) {
22817  return std::addressof(self[0]);
22818  }
22819 
22820  static iterator end(lua_State*, T& self) {
22821  return std::addressof(self[0]) + std::extent<T>::value;
22822  }
22823  };
22824 
22825  template <typename X>
22827  } // namespace container_detail
22828 
22829  template <typename T>
22831 
22832 } // namespace sol
22833 
22834 // end of sol/usertype_container.hpp
22835 
22836 #include <unordered_map>
22837 
22838 namespace sol {
22839 
22840  namespace container_detail {
22841  template <typename X>
22842  struct u_c_launch {
22843  using T = std::remove_pointer_t<meta::unqualified_t<X>>;
22846 
22848  return uc::index_get(L);
22849  }
22850 
22852  return default_uc::index_get(L);
22853  }
22854 
22855  static inline int real_index_call(lua_State* L) {
22856  static const std::unordered_map<string_view, lua_CFunction> calls {
22857  { "at", &real_at_call },
22858  { "get", &real_get_call },
22859  { "set", &real_set_call },
22860  { "size", &real_length_call },
22861  { "add", &real_add_call },
22862  { "empty", &real_empty_call },
22863  { "insert", &real_insert_call },
22864  { "clear", &real_clear_call },
22865  { "find", &real_find_call },
22866  { "index_of", &real_index_of_call },
22867  { "erase", &real_erase_call },
22868  { "pairs", &pairs_call },
22869  { "next", &next_call },
22870  };
22871  auto maybenameview = stack::unqualified_check_get<string_view>(L, 2);
22872  if (maybenameview) {
22873  const string_view& name = *maybenameview;
22874  auto it = calls.find(name);
22875  if (it != calls.cend()) {
22876  return stack::push(L, it->second);
22877  }
22878  }
22879  return real_index_get_traits(container_detail::has_traits_index_get<uc>(), L);
22880  }
22881 
22882  static inline int real_at_traits(std::true_type, lua_State* L) {
22883  return uc::at(L);
22884  }
22885 
22886  static inline int real_at_traits(std::false_type, lua_State* L) {
22887  return default_uc::at(L);
22888  }
22889 
22890  static inline int real_at_call(lua_State* L) {
22891  return real_at_traits(container_detail::has_traits_at<uc>(), L);
22892  }
22893 
22894  static inline int real_get_traits(std::true_type, lua_State* L) {
22895  return uc::get(L);
22896  }
22897 
22898  static inline int real_get_traits(std::false_type, lua_State* L) {
22899  return default_uc::get(L);
22900  }
22901 
22902  static inline int real_get_call(lua_State* L) {
22903  return real_get_traits(container_detail::has_traits_get<uc>(), L);
22904  }
22905 
22906  static inline int real_set_traits(std::true_type, lua_State* L) {
22907  return uc::set(L);
22908  }
22909 
22910  static inline int real_set_traits(std::false_type, lua_State* L) {
22911  return default_uc::set(L);
22912  }
22913 
22914  static inline int real_set_call(lua_State* L) {
22915  return real_set_traits(container_detail::has_traits_set<uc>(), L);
22916  }
22917 
22919  return uc::index_set(L);
22920  }
22921 
22923  return default_uc::index_set(L);
22924  }
22925 
22926  static inline int real_new_index_call(lua_State* L) {
22927  return real_index_set_traits(container_detail::has_traits_index_set<uc>(), L);
22928  }
22929 
22930  static inline int real_pairs_traits(std::true_type, lua_State* L) {
22931  return uc::pairs(L);
22932  }
22933 
22935  return default_uc::pairs(L);
22936  }
22937 
22938  static inline int real_pairs_call(lua_State* L) {
22939  return real_pairs_traits(container_detail::has_traits_pairs<uc>(), L);
22940  }
22941 
22943  return uc::ipairs(L);
22944  }
22945 
22947  return default_uc::ipairs(L);
22948  }
22949 
22950  static inline int real_ipairs_call(lua_State* L) {
22951  return real_ipairs_traits(container_detail::has_traits_ipairs<uc>(), L);
22952  }
22953 
22954  static inline int real_next_traits(std::true_type, lua_State* L) {
22955  return uc::next(L);
22956  }
22957 
22958  static inline int real_next_traits(std::false_type, lua_State* L) {
22959  return default_uc::next(L);
22960  }
22961 
22962  static inline int real_next_call(lua_State* L) {
22963  return real_next_traits(container_detail::has_traits_next<uc>(), L);
22964  }
22965 
22966  static inline int real_size_traits(std::true_type, lua_State* L) {
22967  return uc::size(L);
22968  }
22969 
22970  static inline int real_size_traits(std::false_type, lua_State* L) {
22971  return default_uc::size(L);
22972  }
22973 
22974  static inline int real_length_call(lua_State* L) {
22975  return real_size_traits(container_detail::has_traits_size<uc>(), L);
22976  }
22977 
22978  static inline int real_add_traits(std::true_type, lua_State* L) {
22979  return uc::add(L);
22980  }
22981 
22982  static inline int real_add_traits(std::false_type, lua_State* L) {
22983  return default_uc::add(L);
22984  }
22985 
22986  static inline int real_add_call(lua_State* L) {
22987  return real_add_traits(container_detail::has_traits_add<uc>(), L);
22988  }
22989 
22991  return uc::insert(L);
22992  }
22993 
22995  return default_uc::insert(L);
22996  }
22997 
22998  static inline int real_insert_call(lua_State* L) {
22999  return real_insert_traits(container_detail::has_traits_insert<uc>(), L);
23000  }
23001 
23002  static inline int real_clear_traits(std::true_type, lua_State* L) {
23003  return uc::clear(L);
23004  }
23005 
23007  return default_uc::clear(L);
23008  }
23009 
23010  static inline int real_clear_call(lua_State* L) {
23011  return real_clear_traits(container_detail::has_traits_clear<uc>(), L);
23012  }
23013 
23014  static inline int real_empty_traits(std::true_type, lua_State* L) {
23015  return uc::empty(L);
23016  }
23017 
23019  return default_uc::empty(L);
23020  }
23021 
23022  static inline int real_empty_call(lua_State* L) {
23023  return real_empty_traits(container_detail::has_traits_empty<uc>(), L);
23024  }
23025 
23026  static inline int real_erase_traits(std::true_type, lua_State* L) {
23027  return uc::erase(L);
23028  }
23029 
23031  return default_uc::erase(L);
23032  }
23033 
23034  static inline int real_erase_call(lua_State* L) {
23035  return real_erase_traits(container_detail::has_traits_erase<uc>(), L);
23036  }
23037 
23038  static inline int real_find_traits(std::true_type, lua_State* L) {
23039  return uc::find(L);
23040  }
23041 
23042  static inline int real_find_traits(std::false_type, lua_State* L) {
23043  return default_uc::find(L);
23044  }
23045 
23046  static inline int real_find_call(lua_State* L) {
23047  return real_find_traits(container_detail::has_traits_find<uc>(), L);
23048  }
23049 
23050  static inline int real_index_of_call(lua_State* L) {
23052  return uc::index_of(L);
23053  }
23054  else {
23055  return default_uc::index_of(L);
23056  }
23057  }
23058 
23059  static inline int add_call(lua_State* L) {
23060  return detail::typed_static_trampoline<decltype(&real_add_call), (&real_add_call)>(L);
23061  }
23062 
23063  static inline int erase_call(lua_State* L) {
23064  return detail::typed_static_trampoline<decltype(&real_erase_call), (&real_erase_call)>(L);
23065  }
23066 
23067  static inline int insert_call(lua_State* L) {
23068  return detail::typed_static_trampoline<decltype(&real_insert_call), (&real_insert_call)>(L);
23069  }
23070 
23071  static inline int clear_call(lua_State* L) {
23072  return detail::typed_static_trampoline<decltype(&real_clear_call), (&real_clear_call)>(L);
23073  }
23074 
23075  static inline int empty_call(lua_State* L) {
23076  return detail::typed_static_trampoline<decltype(&real_empty_call), (&real_empty_call)>(L);
23077  }
23078 
23079  static inline int find_call(lua_State* L) {
23080  return detail::typed_static_trampoline<decltype(&real_find_call), (&real_find_call)>(L);
23081  }
23082 
23083  static inline int index_of_call(lua_State* L) {
23084  return detail::typed_static_trampoline<decltype(&real_index_of_call), (&real_index_of_call)>(L);
23085  }
23086 
23087  static inline int length_call(lua_State* L) {
23088  return detail::typed_static_trampoline<decltype(&real_length_call), (&real_length_call)>(L);
23089  }
23090 
23091  static inline int pairs_call(lua_State* L) {
23092  return detail::typed_static_trampoline<decltype(&real_pairs_call), (&real_pairs_call)>(L);
23093  }
23094 
23095  static inline int ipairs_call(lua_State* L) {
23096  return detail::typed_static_trampoline<decltype(&real_ipairs_call), (&real_ipairs_call)>(L);
23097  }
23098 
23099  static inline int next_call(lua_State* L) {
23100  return detail::typed_static_trampoline<decltype(&real_next_call), (&real_next_call)>(L);
23101  }
23102 
23103  static inline int at_call(lua_State* L) {
23104  return detail::typed_static_trampoline<decltype(&real_at_call), (&real_at_call)>(L);
23105  }
23106 
23107  static inline int get_call(lua_State* L) {
23108  return detail::typed_static_trampoline<decltype(&real_get_call), (&real_get_call)>(L);
23109  }
23110 
23111  static inline int set_call(lua_State* L) {
23112  return detail::typed_static_trampoline<decltype(&real_set_call), (&real_set_call)>(L);
23113  }
23114 
23115  static inline int index_call(lua_State* L) {
23116  return detail::typed_static_trampoline<decltype(&real_index_call), (&real_index_call)>(L);
23117  }
23118 
23119  static inline int new_index_call(lua_State* L) {
23120  return detail::typed_static_trampoline<decltype(&real_new_index_call), (&real_new_index_call)>(L);
23121  }
23122  };
23123  } // namespace container_detail
23124 
23125  namespace stack {
23126  namespace stack_detail {
23127  template <typename T, bool is_shim = false>
23130 
23132  }
23133 
23134  void operator()() {
23135  using meta_usertype_container
23137  static const char* metakey
23139  static const std::array<luaL_Reg, 20> reg = { {
23140  // clang-format off
23141  { "__pairs", &meta_usertype_container::pairs_call },
23142  { "__ipairs", &meta_usertype_container::ipairs_call },
23143  { "__len", &meta_usertype_container::length_call },
23144  { "__index", &meta_usertype_container::index_call },
23145  { "__newindex", &meta_usertype_container::new_index_call },
23146  { "pairs", &meta_usertype_container::pairs_call },
23147  { "next", &meta_usertype_container::next_call },
23148  { "at", &meta_usertype_container::at_call },
23149  { "get", &meta_usertype_container::get_call },
23150  { "set", &meta_usertype_container::set_call },
23151  { "size", &meta_usertype_container::length_call },
23152  { "empty", &meta_usertype_container::empty_call },
23153  { "clear", &meta_usertype_container::clear_call },
23154  { "insert", &meta_usertype_container::insert_call },
23155  { "add", &meta_usertype_container::add_call },
23156  { "find", &meta_usertype_container::find_call },
23157  { "index_of", &meta_usertype_container::index_of_call },
23158  { "erase", &meta_usertype_container::erase_call },
23159  std::is_pointer<T>::value ? luaL_Reg{ nullptr, nullptr } : luaL_Reg{ "__gc", &detail::usertype_alloc_destroy<T> },
23160  { nullptr, nullptr }
23161  // clang-format on
23162  } };
23163 
23164  if (luaL_newmetatable(L, metakey) == 1) {
23165  luaL_setfuncs(L, reg.data(), 0);
23166  }
23167  lua_setmetatable(L, -2);
23168  }
23169  };
23170  } // namespace stack_detail
23171 
23172  template <typename T>
23175 
23176  static int push_lvalue(std::true_type, lua_State* L, const C& cont) {
23178  return stack::push<detail::as_pointer_tag<const C>>(L, detail::with_function_tag(), fx, detail::ptr(cont));
23179  }
23180 
23181  static int push_lvalue(std::false_type, lua_State* L, const C& cont) {
23183  return stack::push<detail::as_value_tag<C>>(L, detail::with_function_tag(), fx, cont);
23184  }
23185 
23186  static int push_rvalue(std::true_type, lua_State* L, C&& cont) {
23188  return stack::push<detail::as_value_tag<C>>(L, detail::with_function_tag(), fx, std::move(cont));
23189  }
23190 
23191  static int push_rvalue(std::false_type, lua_State* L, const C& cont) {
23192  return push_lvalue(std::is_lvalue_reference<T>(), L, cont);
23193  }
23194 
23195  static int push(lua_State* L, const as_container_t<T>& as_cont) {
23196  return push_lvalue(std::is_lvalue_reference<T>(), L, as_cont.value());
23197  }
23198 
23199  static int push(lua_State* L, as_container_t<T>&& as_cont) {
23200  return push_rvalue(meta::all<std::is_rvalue_reference<T>, meta::neg<std::is_lvalue_reference<T>>>(), L, std::forward<T>(as_cont.value()));
23201  }
23202  };
23203 
23204  template <typename T>
23206  using C = std::add_pointer_t<meta::unqualified_t<std::remove_pointer_t<T>>>;
23207 
23208  static int push(lua_State* L, T* cont) {
23210  return stack::push<detail::as_pointer_tag<T>>(L, detail::with_function_tag(), fx, cont);
23211  }
23212  };
23213 
23214  template <typename T>
23215  struct unqualified_pusher<T, std::enable_if_t<is_container_v<T>>> {
23216  using C = T;
23217 
23218  template <typename... Args>
23219  static int push(lua_State* L, Args&&... args) {
23221  return stack::push<detail::as_value_tag<T>>(L, detail::with_function_tag(), fx, std::forward<Args>(args)...);
23222  }
23223  };
23224 
23225  template <typename T>
23226  struct unqualified_pusher<T*, std::enable_if_t<is_container_v<T>>> {
23227  using C = std::add_pointer_t<meta::unqualified_t<std::remove_pointer_t<T>>>;
23228 
23229  static int push(lua_State* L, T* cont) {
23231  return stack::push<detail::as_pointer_tag<T>>(L, detail::with_function_tag(), fx, cont);
23232  }
23233  };
23234  } // namespace stack
23235 
23236 } // namespace sol
23237 
23238 // end of sol/usertype_container_launch.hpp
23239 
23240 #include <sstream>
23241 #include <type_traits>
23242 
23243 namespace sol {
23244  namespace u_detail {
23245  constexpr const lua_Integer toplevel_magic = static_cast<lua_Integer>(0xCCC2CCC1);
23246 
23247  constexpr const int environment_index = 1;
23248  constexpr const int usertype_storage_index = 2;
23249  constexpr const int usertype_storage_base_index = 3;
23250  constexpr const int exact_function_index = 4;
23251  constexpr const int magic_index = 5;
23252 
23253  constexpr const int simple_usertype_storage_index = 2;
23254  constexpr const int index_function_index = 3;
23255  constexpr const int new_index_function_index = 4;
23256 
23257  constexpr const int base_walking_failed_index = -32467;
23258  constexpr const int lookup_failed_index = -42469;
23259 
23260  enum class submetatable_type {
23261  // must be sequential
23262  value,
23263  reference,
23264  unique,
23266  const_value,
23267  // must be LAST!
23268  named
23269  };
23270 
23272  return s;
23273  }
23274 
23275 #if SOL_IS_ON(SOL_CHAR8_T)
23276  inline auto make_string_view(const char8_t* s) {
23277  return string_view(reinterpret_cast<const char*>(s));
23278  }
23279 #endif
23280 
23282  return string_view(to_string(meta_function::call_function));
23283  }
23284 
23286  return string_view(to_string(mf));
23287  }
23288 
23291  }
23292 
23293  template <typename Arg>
23294  inline std::string make_string(Arg&& arg) {
23296  return std::string(s.data(), s.size());
23297  }
23298 
23299  inline int is_indexer(string_view s) {
23300  if (s == to_string(meta_function::index)) {
23301  return 1;
23302  }
23303  else if (s == to_string(meta_function::new_index)) {
23304  return 2;
23305  }
23306  return 0;
23307  }
23308 
23309  inline int is_indexer(meta_function mf) {
23310  if (mf == meta_function::index) {
23311  return 1;
23312  }
23313  else if (mf == meta_function::new_index) {
23314  return 2;
23315  }
23316  return 0;
23317  }
23318 
23320  return 0;
23321  }
23322  } // namespace u_detail
23323 
23324  namespace detail {
23325 
23326  template <typename T, typename IFx, typename Fx>
23327  inline void insert_default_registrations(IFx&& ifx, Fx&& fx) {
23328  (void)ifx;
23329  (void)fx;
23330  if constexpr (is_automagical<T>::value) {
23331  if (fx(meta_function::less_than)) {
23332  if constexpr (meta::supports_op_less<T>::value) {
23333  lua_CFunction f = &comparsion_operator_wrap<T, std::less<>>;
23335  }
23336  }
23339  lua_CFunction f = &comparsion_operator_wrap<T, std::less_equal<>>;
23341  }
23342  }
23343  if (fx(meta_function::equal_to)) {
23344  if constexpr (meta::supports_op_equal<T>::value) {
23345  lua_CFunction f = &comparsion_operator_wrap<T, std::equal_to<>>;
23346  ifx(meta_function::equal_to, f);
23347  }
23348  else {
23349  lua_CFunction f = &comparsion_operator_wrap<T, no_comp>;
23350  ifx(meta_function::equal_to, f);
23351  }
23352  }
23353  if (fx(meta_function::pairs)) {
23355  }
23356  if (fx(meta_function::length)) {
23358  auto f = &default_size<T>;
23359  ifx(meta_function::length, f);
23360  }
23361  }
23362  if (fx(meta_function::to_string)) {
23363  if constexpr (is_to_stringable_v<T>) {
23364  if constexpr (!meta::is_probably_stateless_lambda_v<T> && !std::is_member_pointer_v<T>) {
23365  auto f = &detail::static_trampoline<&default_to_string<T>>;
23367  }
23368  }
23369  }
23370  if (fx(meta_function::call_function)) {
23371  if constexpr (is_callable_v<T>) {
23372  if constexpr (meta::call_operator_deducible_v<T>) {
23373  auto f = &c_call<decltype(&T::operator()), &T::operator()>;
23375  }
23376  }
23377  }
23378  }
23379  }
23380  } // namespace detail
23381 
23382  namespace stack { namespace stack_detail {
23383  template <typename X>
23385  using T = std::remove_pointer_t<X>;
23386 
23387  lua_State* L = t.lua_state();
23388 
23389  t.push();
23390 
23391  detail::lua_reg_table l {};
23392  int index = 0;
23393  detail::indexed_insert insert_fx(l, index);
23394  detail::insert_default_registrations<T>(insert_fx, detail::property_always_true);
23395  if constexpr (!std::is_pointer_v<X>) {
23396  l[index] = luaL_Reg { to_string(meta_function::garbage_collect).c_str(), detail::make_destructor<T>() };
23397  }
23398  luaL_setfuncs(L, l, 0);
23399 
23400  // __type table
23401  lua_createtable(L, 0, 2);
23402  const std::string& name = detail::demangle<T>();
23403  lua_pushlstring(L, name.c_str(), name.size());
23404  lua_setfield(L, -2, "name");
23405  lua_CFunction is_func = &detail::is_check<T>;
23406  lua_pushcclosure(L, is_func, 0);
23407  lua_setfield(L, -2, "is");
23408  lua_setfield(L, t.stack_index(), to_string(meta_function::type).c_str());
23409 
23410  t.pop();
23411  }
23412  }} // namespace stack::stack_detail
23413 } // namespace sol
23414 
23415 // end of sol/usertype_core.hpp
23416 
23417 // beginning of sol/usertype_storage.hpp
23418 
23419 #include <bitset>
23420 #include <unordered_map>
23421 #include <memory>
23422 
23423 namespace sol { namespace u_detail {
23424 
23425  struct usertype_storage_base;
23426  template <typename T>
23428 
23430  usertype_storage_base& get_usertype_storage_base(lua_State* L_, const char* gcmetakey);
23431  template <typename T>
23433  template <typename T>
23435 
23439 
23444  };
23445 
23448  };
23449 
23450  struct binding_base {
23451  virtual void* data() = 0;
23452  virtual ~binding_base() {
23453  }
23454  };
23455 
23456  template <typename K, typename Fq, typename T = void>
23460 #if SOL_IS_ON(SOL_CHAR8_T)
23461  || meta::is_c_str_of_v<uF, char8_t>
23462 #endif
23463  || meta::is_c_str_of_v<uF, char16_t> || meta::is_c_str_of_v<uF, char32_t> || meta::is_c_str_of_v<uF, wchar_t>,
23464  std::add_pointer_t<std::add_const_t<std::remove_all_extents_t<Fq>>>, std::decay_t<Fq>>;
23466 
23467  template <typename... Args>
23468  binding(Args&&... args) : data_(std::forward<Args>(args)...) {
23469  }
23470 
23471  virtual void* data() override {
23472  return static_cast<void*>(std::addressof(data_));
23473  }
23474 
23475  template <bool is_index = true, bool is_variable = false>
23476  static inline int call_with_(lua_State* L_, void* target) {
23477  constexpr int boost = !detail::is_non_factory_constructor<F>::value && std::is_same<K, call_construction>::value ? 1 : 0;
23478  auto& f = *static_cast<F*>(target);
23479  return call_detail::call_wrapped<T, is_index, is_variable, boost>(L_, f);
23480  }
23481 
23482  template <bool is_index = true, bool is_variable = false>
23483  static inline int call_(lua_State* L_) {
23484  void* f = stack::get<void*>(L_, upvalue_index(usertype_storage_index));
23485  return call_with_<is_index, is_variable>(L_, f);
23486  }
23487 
23488  template <bool is_index = true, bool is_variable = false>
23489  static inline int call(lua_State* L_) {
23490  int r = detail::typed_static_trampoline<decltype(&call_<is_index, is_variable>), (&call_<is_index, is_variable>)>(L_);
23491  if constexpr (meta::is_specialization_of_v<uF, yielding_t>) {
23492  return lua_yield(L_, r);
23493  }
23494  else {
23495  return r;
23496  }
23497  }
23498 
23499  template <bool is_index = true, bool is_variable = false>
23500  static inline int index_call_with_(lua_State* L_, void* target) {
23501  if constexpr (!is_variable) {
23502  if constexpr (is_lua_c_function_v<std::decay_t<F>>) {
23503  auto& f = *static_cast<std::decay_t<F>*>(target);
23504  return stack::push(L_, f);
23505  }
23506  else {
23507  // set up upvalues
23508  // for a chained call
23509  int upvalues = 0;
23510  upvalues += stack::push(L_, nullptr);
23511  upvalues += stack::push(L_, target);
23512  auto cfunc = &call<is_index, is_variable>;
23513  return stack::push(L_, c_closure(cfunc, upvalues));
23514  }
23515  }
23516  else {
23517  constexpr int boost = !detail::is_non_factory_constructor<F>::value && std::is_same<K, call_construction>::value ? 1 : 0;
23518  auto& f = *static_cast<F*>(target);
23519  return call_detail::call_wrapped<T, is_index, is_variable, boost>(L_, f);
23520  }
23521  }
23522 
23523  template <bool is_index = true, bool is_variable = false>
23524  static inline int index_call_(lua_State* L_) {
23525  void* f = stack::get<void*>(L_, upvalue_index(usertype_storage_index));
23526  return index_call_with_<is_index, is_variable>(L_, f);
23527  }
23528 
23529  template <bool is_index = true, bool is_variable = false>
23530  static inline int index_call(lua_State* L_) {
23531  int r = detail::typed_static_trampoline<decltype(&index_call_<is_index, is_variable>), (&index_call_<is_index, is_variable>)>(L_);
23532  if constexpr (meta::is_specialization_of_v<uF, yielding_t>) {
23533  return lua_yield(L_, r);
23534  }
23535  else {
23536  return r;
23537  }
23538  }
23539  };
23540 
23541  inline int index_fail(lua_State* L_) {
23542  if (lua_getmetatable(L_, 1) == 1) {
23543  int metatarget = lua_gettop(L_);
23544  stack::get_field<false, true>(L_, stack_reference(L_, raw_index(2)), metatarget);
23545  return 1;
23546  }
23547  // With runtime extensibility, we can't
23548  // hard-error things. They have to
23549  // return nil, like regular table types
23550  return stack::push(L_, lua_nil);
23551  }
23552 
23553  inline int index_target_fail(lua_State* L_, void*) {
23554  return index_fail(L_);
23555  }
23556 
23557  inline int new_index_fail(lua_State* L_) {
23558  return luaL_error(L_, "sol: cannot set (new_index) into this object: no defined new_index operation on usertype");
23559  }
23560 
23561  inline int new_index_target_fail(lua_State* L_, void*) {
23562  return new_index_fail(L_);
23563  }
23564 
23566  bool is_destruction = false;
23567  bool is_index = false;
23568  bool is_new_index = false;
23569  bool is_static_index = false;
23570  bool is_static_new_index = false;
23571  bool poison_indexing = false;
23572  bool is_unqualified_lua_CFunction = false;
23573  bool is_unqualified_lua_reference = false;
23574  std::string* p_key = nullptr;
23575  reference* p_binding_ref = nullptr;
23576  lua_CFunction call_func = nullptr;
23577  index_call_storage* p_ics = nullptr;
23578  usertype_storage_base* p_usb = nullptr;
23579  void* p_derived_usb = nullptr;
23580  lua_CFunction idx_call = nullptr, new_idx_call = nullptr, meta_idx_call = nullptr, meta_new_idx_call = nullptr;
23582 
23583  void operator()(lua_State* L_, submetatable_type smt_, stateless_reference& fast_index_table_) {
23584  std::string& key = *p_key;
23585  usertype_storage_base& usb = *p_usb;
23586  index_call_storage& ics = *p_ics;
23587 
23588  if (smt_ == submetatable_type::named) {
23589  // do not override __call or
23590  // other specific meta functions on named metatable:
23591  // we need that for call construction
23592  // and other amenities
23593  return;
23594  }
23595  int fast_index_table_push = fast_index_table_.push(L_);
23596  stateless_stack_reference t(L_, -fast_index_table_push);
23597  if (poison_indexing) {
23598  (usb.*change_indexing)(L_, smt_, p_derived_usb, t, idx_call, new_idx_call, meta_idx_call, meta_new_idx_call);
23599  }
23600  if (is_destruction
23601  && (smt_ == submetatable_type::reference || smt_ == submetatable_type::const_reference || smt_ == submetatable_type::named
23602  || smt_ == submetatable_type::unique)) {
23603  // gc does not apply to us here
23604  // for reference types (raw T*, std::ref)
23605  // for the named metatable itself,
23606  // or for unique_usertypes, which do their own custom destroyion
23607  t.pop(L_);
23608  return;
23609  }
23610  if (is_index || is_new_index || is_static_index || is_static_new_index) {
23611  // do not serialize the new_index and index functions here directly
23612  // we control those...
23613  t.pop(L_);
23614  return;
23615  }
23616  if (is_unqualified_lua_CFunction) {
23617  stack::set_field<false, true>(L_, key, call_func, t.stack_index());
23618  }
23619  else if (is_unqualified_lua_reference) {
23620  reference& binding_ref = *p_binding_ref;
23621  stack::set_field<false, true>(L_, key, binding_ref, t.stack_index());
23622  }
23623  else {
23624  stack::set_field<false, true>(L_, key, make_closure(call_func, nullptr, ics.binding_data), t.stack_index());
23625  }
23626  t.pop(L_);
23627  }
23628  };
23629 
23633 
23634  void operator()(lua_State* L_, submetatable_type smt_, stateless_reference& fast_index_table_) {
23635  if (smt_ == submetatable_type::named) {
23636  return;
23637  }
23638  int fast_index_table_push = fast_index_table_.push(L_);
23639  stateless_stack_reference t(L_, -fast_index_table_push);
23640  stack::set_field<false, true>(L_, key, value, t.stack_index());
23641  t.pop(L_);
23642  }
23643  };
23644 
23648  lua_CFunction idx_call, new_idx_call, meta_idx_call, meta_new_idx_call;
23652 
23653  void operator()(lua_State* L_, submetatable_type smt_, stateless_reference& fast_index_table_) {
23654  int fast_index_table_push = fast_index_table_.push(L_);
23655  stateless_stack_reference t(L_, -fast_index_table_push);
23656  stack::set_field(L_, detail::base_class_check_key(), reinterpret_cast<void*>(base_class_check_func), t.stack_index());
23657  stack::set_field(L_, detail::base_class_cast_key(), reinterpret_cast<void*>(base_class_cast_func), t.stack_index());
23658  // change indexing, forcefully
23659  (p_usb->*change_indexing)(L_, smt_, p_derived_usb, t, idx_call, new_idx_call, meta_idx_call, meta_new_idx_call);
23660  t.pop(L_);
23661  }
23662  };
23663 
23666 
23667  binding_data_equals(void* b) : binding_data(b) {
23668  }
23669 
23670  bool operator()(const std::unique_ptr<binding_base>& ptr) const {
23671  return binding_data == ptr->data();
23672  }
23673  };
23674 
23676  public:
23678  std::vector<std::unique_ptr<binding_base>> storage;
23679  std::vector<std::unique_ptr<char[]>> string_keys_storage;
23680  std::unordered_map<string_view, index_call_storage> string_keys;
23681  std::unordered_map<stateless_reference, stateless_reference, stateless_reference_hash, stateless_reference_equals> auxiliary_keys;
23695  std::bitset<64> properties;
23696 
23698  : m_L(L_)
23699  , storage()
23700  , string_keys_storage()
23701  , string_keys()
23702  , auxiliary_keys(0, stateless_reference_hash(L_), stateless_reference_equals(L_))
23703  , value_index_table()
23704  , reference_index_table()
23705  , unique_index_table()
23706  , const_reference_index_table()
23707  , const_value_index_table()
23708  , named_index_table()
23709  , type_table(make_reference<stateless_reference>(L_, create))
23710  , gc_names_table(make_reference<stateless_reference>(L_, create))
23711  , named_metatable(make_reference<stateless_reference>(L_, create))
23712  , base_index()
23713  , static_base_index()
23714  , is_using_index(false)
23715  , is_using_new_index(false)
23716  , properties() {
23717  base_index.binding_data = nullptr;
23718  base_index.index = index_target_fail;
23719  base_index.new_index = new_index_target_fail;
23720  base_index.new_binding_data = nullptr;
23721  static_base_index.binding_data = nullptr;
23722  static_base_index.index = index_target_fail;
23723  static_base_index.new_binding_data = this;
23724  static_base_index.new_index = new_index_target_set;
23725  }
23726 
23727  template <typename Fx>
23728  void for_each_table(lua_State* L_, Fx&& fx) {
23729  for (int i = 0; i < 6; ++i) {
23730  submetatable_type smt = static_cast<submetatable_type>(i);
23731  stateless_reference* p_fast_index_table = nullptr;
23732  switch (smt) {
23733  case submetatable_type::const_value:
23734  p_fast_index_table = &this->const_value_index_table;
23735  break;
23737  p_fast_index_table = &this->reference_index_table;
23738  break;
23739  case submetatable_type::unique:
23740  p_fast_index_table = &this->unique_index_table;
23741  break;
23742  case submetatable_type::const_reference:
23743  p_fast_index_table = &this->const_reference_index_table;
23744  break;
23745  case submetatable_type::named:
23746  p_fast_index_table = &this->named_index_table;
23747  break;
23748  case submetatable_type::value:
23749  default:
23750  p_fast_index_table = &this->value_index_table;
23751  break;
23752  }
23753  fx(L_, smt, *p_fast_index_table);
23754  }
23755  }
23756 
23758  string_keys_storage.emplace_back(new char[sv.size()]);
23759  std::unique_ptr<char[]>& sv_storage = string_keys_storage.back();
23760  std::memcpy(sv_storage.get(), sv.data(), sv.size());
23761  string_view stored_sv(sv_storage.get(), sv.size());
23762  string_keys.insert_or_assign(std::move(stored_sv), std::move(ics));
23763  }
23764 
23765  template <typename T, typename... Bases>
23767  static_assert(sizeof(void*) <= sizeof(detail::inheritance_check_function),
23768  "The size of this data pointer is too small to fit the inheritance checking function: Please file "
23769  "a bug report.");
23770  static_assert(sizeof(void*) <= sizeof(detail::inheritance_cast_function),
23771  "The size of this data pointer is too small to fit the inheritance checking function: Please file "
23772  "a bug report.");
23773  static_assert(!meta::any_same<T, Bases...>::value, "base classes cannot list the original class as part of the bases");
23774  if constexpr (sizeof...(Bases) > 0) {
23775  (void)detail::swallow { 0, ((weak_derive<Bases>::value = true), 0)... };
23776 
23777  void* derived_this = static_cast<void*>(static_cast<usertype_storage<T>*>(this));
23778 
23779  update_bases_func for_each_fx;
23780  for_each_fx.base_class_check_func = &detail::inheritance<T>::template type_check_with<Bases...>;
23781  for_each_fx.base_class_cast_func = &detail::inheritance<T>::template type_cast_with<Bases...>;
23782  for_each_fx.idx_call = &usertype_storage<T>::template index_call_with_bases<false, Bases...>;
23783  for_each_fx.new_idx_call = &usertype_storage<T>::template index_call_with_bases<true, Bases...>;
23784  for_each_fx.meta_idx_call = &usertype_storage<T>::template meta_index_call_with_bases<false, Bases...>;
23785  for_each_fx.meta_new_idx_call = &usertype_storage<T>::template meta_index_call_with_bases<true, Bases...>;
23786  for_each_fx.p_usb = this;
23787  for_each_fx.p_derived_usb = derived_this;
23788  for_each_fx.change_indexing = &usertype_storage_base::change_indexing;
23789  for_each_fx.p_derived_usb = derived_this;
23790  this->for_each_table(L_, for_each_fx);
23791  }
23792  else {
23793  (void)L_;
23794  }
23795  }
23796 
23797  void clear() {
23798  if (value_index_table.valid(m_L)) {
23799  stack::clear(m_L, value_index_table);
23800  }
23801  if (reference_index_table.valid(m_L)) {
23802  stack::clear(m_L, reference_index_table);
23803  }
23804  if (unique_index_table.valid(m_L)) {
23805  stack::clear(m_L, unique_index_table);
23806  }
23807  if (const_reference_index_table.valid(m_L)) {
23808  stack::clear(m_L, const_reference_index_table);
23809  }
23810  if (const_value_index_table.valid(m_L)) {
23811  stack::clear(m_L, const_value_index_table);
23812  }
23813  if (named_index_table.valid(m_L)) {
23814  stack::clear(m_L, named_index_table);
23815  }
23816  if (type_table.valid(m_L)) {
23817  stack::clear(m_L, type_table);
23818  }
23819  if (gc_names_table.valid(m_L)) {
23820  stack::clear(m_L, gc_names_table);
23821  }
23822  if (named_metatable.valid(m_L)) {
23823  auto pp = stack::push_pop(m_L, named_metatable);
23824  int named_metatable_index = pp.index_of(named_metatable);
23825  if (lua_getmetatable(m_L, named_metatable_index) == 1) {
23826  stack::clear(m_L, absolute_index(m_L, -1));
23827  }
23828  stack::clear(m_L, named_metatable);
23829  }
23830 
23831  value_index_table.reset(m_L);
23832  reference_index_table.reset(m_L);
23833  unique_index_table.reset(m_L);
23834  const_reference_index_table.reset(m_L);
23835  const_value_index_table.reset(m_L);
23836  named_index_table.reset(m_L);
23837  type_table.reset(m_L);
23838  gc_names_table.reset(m_L);
23839  named_metatable.reset(m_L);
23840 
23841  storage.clear();
23842  string_keys.clear();
23843  auxiliary_keys.clear();
23844  string_keys_storage.clear();
23845  }
23846 
23847  template <bool is_new_index, typename Base>
23848  static void base_walk_index(lua_State* L_, usertype_storage_base& self, bool& keep_going, int& base_result) {
23849  using bases = typename base<Base>::type;
23850  if (!keep_going) {
23851  return;
23852  }
23853  (void)L_;
23854  (void)self;
23855 #if SOL_IS_ON(SOL_USE_UNSAFE_BASE_LOOKUP)
23856  usertype_storage_base& base_storage = get_usertype_storage<Base>(L_);
23857  base_result = self_index_call<is_new_index, true>(bases(), L_, base_storage);
23858 #else
23859  optional<usertype_storage<Base>&> maybe_base_storage = maybe_get_usertype_storage<Base>(L_);
23860  if (static_cast<bool>(maybe_base_storage)) {
23861  base_result = self_index_call<is_new_index, true>(bases(), L_, *maybe_base_storage);
23862  keep_going = base_result == base_walking_failed_index;
23863  }
23864 #endif // Fast versus slow, safe base lookup
23865  }
23866 
23867  template <bool is_new_index = false, bool base_walking = false, bool from_named_metatable = false, typename... Bases>
23869  if constexpr (!from_named_metatable || !is_new_index) {
23870  type k_type = stack::get<type>(L, 2);
23871  if (k_type == type::string) {
23872  index_call_storage* target = nullptr;
23873  string_view k = stack::get<string_view>(L, 2);
23874  {
23875  auto it = self.string_keys.find(k);
23876  if (it != self.string_keys.cend()) {
23877  target = &it->second;
23878  }
23879  }
23880  if (target != nullptr) {
23881  // let the target decide what to do, unless it's named...
23882  if constexpr (is_new_index) {
23883  return (target->new_index)(L, target->binding_data);
23884  }
23885  else {
23886  return (target->index)(L, target->binding_data);
23887  }
23888  }
23889  }
23890  else if (k_type != type::lua_nil && k_type != type::none) {
23891  stateless_reference* target = nullptr;
23892  {
23893  stack_reference k = stack::get<stack_reference>(L, 2);
23894  auto it = self.auxiliary_keys.find(k);
23895  if (it != self.auxiliary_keys.cend()) {
23896  target = &it->second;
23897  }
23898  }
23899  if (target != nullptr) {
23900  if constexpr (is_new_index) {
23901  // set value and return
23902  target->reset(L, 3);
23903  return 0;
23904  }
23905  else {
23906  // push target to return
23907  // what we found
23908  return stack::push(L, *target);
23909  }
23910  }
23911  }
23912  }
23913 
23914  // retrieve bases and walk through them.
23915  bool keep_going = true;
23916  int base_result;
23917  (void)keep_going;
23918  (void)base_result;
23919  (void)detail::swallow { 1, (base_walk_index<is_new_index, Bases>(L, self, keep_going, base_result), 1)... };
23920  if constexpr (sizeof...(Bases) > 0) {
23921  if (!keep_going) {
23922  return base_result;
23923  }
23924  }
23925  if constexpr (base_walking) {
23926  // if we're JUST base-walking then don't index-fail, just
23927  // return the false bits
23929  }
23930  else if constexpr (from_named_metatable) {
23931  if constexpr (is_new_index) {
23932  return self.static_base_index.new_index(L, self.static_base_index.new_binding_data);
23933  }
23934  else {
23935  return self.static_base_index.index(L, self.static_base_index.binding_data);
23936  }
23937  }
23938  else {
23939  if constexpr (is_new_index) {
23940  return self.base_index.new_index(L, self.base_index.new_binding_data);
23941  }
23942  else {
23943  return self.base_index.index(L, self.base_index.binding_data);
23944  }
23945  }
23946  }
23947 
23948  void change_indexing(lua_State* L_, submetatable_type submetatable_, void* derived_this_, stateless_stack_reference& t_, lua_CFunction index_,
23949  lua_CFunction new_index_, lua_CFunction meta_index_, lua_CFunction meta_new_index_) {
23950  usertype_storage_base& this_base = *this;
23951  void* base_this = static_cast<void*>(&this_base);
23952 
23953  this->is_using_index |= true;
23954  this->is_using_new_index |= true;
23955  if (submetatable_ == submetatable_type::named) {
23956  stack::set_field(L_, metatable_key, named_index_table, t_.stack_index());
23957  stateless_stack_reference stack_metametatable(L_, -named_metatable.push(L_));
23958  stack::set_field<false, true>(L_,
23960  make_closure(meta_index_, nullptr, derived_this_, base_this, nullptr, toplevel_magic),
23961  stack_metametatable.stack_index());
23962  stack::set_field<false, true>(L_,
23964  make_closure(meta_new_index_, nullptr, derived_this_, base_this, nullptr, toplevel_magic),
23965  stack_metametatable.stack_index());
23966  stack_metametatable.pop(L_);
23967  }
23968  else {
23969  stack::set_field<false, true>(
23970  L_, meta_function::index, make_closure(index_, nullptr, derived_this_, base_this, nullptr, toplevel_magic), t_.stack_index());
23971  stack::set_field<false, true>(
23972  L_, meta_function::new_index, make_closure(new_index_, nullptr, derived_this_, base_this, nullptr, toplevel_magic), t_.stack_index());
23973  }
23974  }
23975 
23976  template <typename T = void, typename Key, typename Value>
23977  void set(lua_State* L, Key&& key, Value&& value);
23978 
23979  static int new_index_target_set(lua_State* L, void* target) {
23980  usertype_storage_base& self = *static_cast<usertype_storage_base*>(target);
23981  self.set(L, reference(L, raw_index(2)), reference(L, raw_index(3)));
23982  return 0;
23983  }
23984 
23986  value_index_table.reset(m_L);
23987  reference_index_table.reset(m_L);
23988  unique_index_table.reset(m_L);
23989  const_reference_index_table.reset(m_L);
23990  const_value_index_table.reset(m_L);
23991  named_index_table.reset(m_L);
23992  type_table.reset(m_L);
23993  gc_names_table.reset(m_L);
23994  named_metatable.reset(m_L);
23995 
23996  auto auxiliary_first = auxiliary_keys.cbegin();
23997  auto auxiliary_last = auxiliary_keys.cend();
23998  while (auxiliary_first != auxiliary_last) {
23999  // save a copy to what we're going to destroy
24000  auto auxiliary_target = auxiliary_first;
24001  // move the iterator up by 1
24002  ++auxiliary_first;
24003  // extract the node and destroy the key
24004  auto extracted_node = auxiliary_keys.extract(auxiliary_target);
24005  extracted_node.key().reset(m_L);
24006  extracted_node.mapped().reset(m_L);
24007  // continue if auxiliary_first hasn't been exhausted
24008  }
24009  }
24010  };
24011 
24012  template <typename T>
24013  struct usertype_storage : usertype_storage_base {
24014 
24015  using usertype_storage_base::usertype_storage_base;
24016 
24017  template <bool is_new_index, bool from_named_metatable>
24018  static inline int index_call_(lua_State* L) {
24019  using bases = typename base<T>::type;
24020  usertype_storage_base& self = stack::get<light<usertype_storage_base>>(L, upvalue_index(usertype_storage_index));
24021  return self_index_call<is_new_index, false, from_named_metatable>(bases(), L, self);
24022  }
24023 
24024  template <bool is_new_index, bool from_named_metatable, typename... Bases>
24025  static inline int index_call_with_bases_(lua_State* L) {
24026  using bases = types<Bases...>;
24027  usertype_storage_base& self = stack::get<light<usertype_storage_base>>(L, upvalue_index(usertype_storage_index));
24028  return self_index_call<is_new_index, false, from_named_metatable>(bases(), L, self);
24029  }
24030 
24031  template <bool is_new_index>
24032  static inline int index_call(lua_State* L) {
24033  return detail::static_trampoline<&index_call_<is_new_index, false>>(L);
24034  }
24035 
24036  template <bool is_new_index, typename... Bases>
24037  static inline int index_call_with_bases(lua_State* L) {
24038  return detail::static_trampoline<&index_call_with_bases_<is_new_index, false, Bases...>>(L);
24039  }
24040 
24041  template <bool is_new_index>
24042  static inline int meta_index_call(lua_State* L) {
24043  return detail::static_trampoline<&index_call_<is_new_index, true>>(L);
24044  }
24045 
24046  template <bool is_new_index, typename... Bases>
24047  static inline int meta_index_call_with_bases(lua_State* L) {
24048  return detail::static_trampoline<&index_call_with_bases_<is_new_index, true, Bases...>>(L);
24049  }
24050 
24051  template <typename Key, typename Value>
24052  inline void set(lua_State* L, Key&& key, Value&& value);
24053  };
24054 
24055  template <typename T, typename Key, typename Value>
24056  void usertype_storage_base::set(lua_State* L, Key&& key, Value&& value) {
24057  using ValueU = meta::unwrap_unqualified_t<Value>;
24058  using KeyU = meta::unwrap_unqualified_t<Key>;
24059  using Binding = binding<KeyU, ValueU, T>;
24060  using is_var_bind = is_variable_binding<ValueU>;
24061  if constexpr (std::is_same_v<KeyU, call_construction>) {
24062  (void)key;
24063  std::unique_ptr<Binding> p_binding = std::make_unique<Binding>(std::forward<Value>(value));
24064  Binding& b = *p_binding;
24065  this->storage.push_back(std::move(p_binding));
24066 
24067  this->named_index_table.push(L);
24068  absolute_index metametatable_index(L, -1);
24069  std::string_view call_metamethod_name = to_string(meta_function::call);
24070  lua_pushlstring(L, call_metamethod_name.data(), call_metamethod_name.size());
24071  stack::push(L, nullptr);
24072  stack::push(L, b.data());
24073  lua_CFunction target_func = &b.template call<false, false>;
24074  lua_pushcclosure(L, target_func, 2);
24075  lua_rawset(L, metametatable_index);
24076  this->named_index_table.pop(L);
24077  }
24078  else if constexpr (std::is_same_v<KeyU, base_classes_tag>) {
24079  (void)key;
24080  this->update_bases<T>(L, std::forward<Value>(value));
24081  }
24082  else if constexpr ((meta::is_string_like_or_constructible<KeyU>::value || std::is_same_v<KeyU, meta_function>)) {
24083  std::string s = u_detail::make_string(std::forward<Key>(key));
24084  auto storage_it = this->storage.end();
24085  auto string_it = this->string_keys.find(s);
24086  if (string_it != this->string_keys.cend()) {
24087  const auto& binding_data = string_it->second.binding_data;
24088  storage_it = std::find_if(this->storage.begin(), this->storage.end(), binding_data_equals(binding_data));
24089  this->string_keys.erase(string_it);
24090  }
24091 
24092  std::unique_ptr<Binding> p_binding = std::make_unique<Binding>(std::forward<Value>(value));
24093  Binding& b = *p_binding;
24094  if (storage_it != this->storage.cend()) {
24095  *storage_it = std::move(p_binding);
24096  }
24097  else {
24098  this->storage.push_back(std::move(p_binding));
24099  }
24100 
24101  bool is_index = (s == to_string(meta_function::index));
24102  bool is_new_index = (s == to_string(meta_function::new_index));
24103  bool is_static_index = (s == to_string(meta_function::static_index));
24104  bool is_static_new_index = (s == to_string(meta_function::static_new_index));
24105  bool is_destruction = s == to_string(meta_function::garbage_collect);
24106  bool poison_indexing = (!is_using_index || !is_using_new_index) && (is_var_bind::value || is_index || is_new_index);
24107  void* derived_this = static_cast<void*>(static_cast<usertype_storage<T>*>(this));
24108  index_call_storage ics;
24109  ics.binding_data = b.data();
24110  ics.index = is_index || is_static_index ? &Binding::template call_with_<true, is_var_bind::value>
24111  : &Binding::template index_call_with_<true, is_var_bind::value>;
24112  ics.new_index = is_new_index || is_static_new_index ? &Binding::template call_with_<false, is_var_bind::value>
24113  : &Binding::template index_call_with_<false, is_var_bind::value>;
24114 
24115  string_for_each_metatable_func for_each_fx;
24116  for_each_fx.is_destruction = is_destruction;
24117  for_each_fx.is_index = is_index;
24118  for_each_fx.is_new_index = is_new_index;
24119  for_each_fx.is_static_index = is_static_index;
24120  for_each_fx.is_static_new_index = is_static_new_index;
24121  for_each_fx.poison_indexing = poison_indexing;
24122  for_each_fx.p_key = &s;
24123  for_each_fx.p_ics = &ics;
24124  if constexpr (is_lua_c_function_v<ValueU>) {
24125  for_each_fx.is_unqualified_lua_CFunction = true;
24126  for_each_fx.call_func = *static_cast<lua_CFunction*>(ics.binding_data);
24127  }
24128  else if constexpr (is_lua_reference_or_proxy_v<ValueU>) {
24129  for_each_fx.is_unqualified_lua_reference = true;
24130  for_each_fx.p_binding_ref = static_cast<reference*>(ics.binding_data);
24131  }
24132  else {
24133  for_each_fx.call_func = &b.template call<false, is_var_bind::value>;
24134  }
24135  for_each_fx.p_usb = this;
24136  for_each_fx.p_derived_usb = derived_this;
24137  for_each_fx.idx_call = &usertype_storage<T>::template index_call<false>;
24138  for_each_fx.new_idx_call = &usertype_storage<T>::template index_call<true>;
24139  for_each_fx.meta_idx_call = &usertype_storage<T>::template meta_index_call<false>;
24140  for_each_fx.meta_new_idx_call = &usertype_storage<T>::template meta_index_call<true>;
24141  for_each_fx.change_indexing = &usertype_storage_base::change_indexing;
24142  // set base index and base new_index
24143  // functions here
24144  if (is_index) {
24145  this->base_index.index = ics.index;
24146  this->base_index.binding_data = ics.binding_data;
24147  }
24148  if (is_new_index) {
24149  this->base_index.new_index = ics.new_index;
24150  this->base_index.new_binding_data = ics.binding_data;
24151  }
24152  if (is_static_index) {
24153  this->static_base_index.index = ics.index;
24154  this->static_base_index.binding_data = ics.binding_data;
24155  }
24156  if (is_static_new_index) {
24157  this->static_base_index.new_index = ics.new_index;
24158  this->static_base_index.new_binding_data = ics.binding_data;
24159  }
24160  this->for_each_table(L, for_each_fx);
24161  this->add_entry(s, std::move(ics));
24162  }
24163  else {
24164  // the reference-based implementation might compare poorly and hash
24165  // poorly in some cases...
24166  if constexpr (is_lua_reference_v<KeyU> && is_lua_reference_v<ValueU>) {
24167  if (key.get_type() == type::string) {
24168  stack::push(L, key);
24169  std::string string_key = stack::pop<std::string>(L);
24170  this->set<T>(L, string_key, std::forward<Value>(value));
24171  }
24172  else {
24173  lua_reference_func ref_additions_fx { key, value };
24174 
24175  this->for_each_table(L, ref_additions_fx);
24176  this->auxiliary_keys.insert_or_assign(std::forward<Key>(key), std::forward<Value>(value));
24177  }
24178  }
24179  else {
24180  reference ref_key = make_reference(L, std::forward<Key>(key));
24181  reference ref_value = make_reference(L, std::forward<Value>(value));
24182  lua_reference_func ref_additions_fx { ref_key, ref_value };
24183 
24184  this->for_each_table(L, ref_additions_fx);
24185  this->auxiliary_keys.insert_or_assign(std::move(ref_key), std::move(ref_value));
24186  }
24187  }
24188  }
24189 
24190  template <typename T>
24191  template <typename Key, typename Value>
24192  void usertype_storage<T>::set(lua_State* L, Key&& key, Value&& value) {
24193  static_cast<usertype_storage_base&>(*this).set<T>(L, std::forward<Key>(key), std::forward<Value>(value));
24194  }
24195 
24196  template <typename T>
24198  using u_traits = usertype_traits<T>;
24199  using u_const_traits = usertype_traits<const T>;
24200  using u_unique_traits = usertype_traits<d::u<T>>;
24201  using u_ref_traits = usertype_traits<T*>;
24202  using u_const_ref_traits = usertype_traits<T const*>;
24203 
24205  registry.push();
24206  // eliminate all named entries for this usertype
24207  // in the registry (luaL_newmetatable does
24208  // [name] = new table
24209  // in registry upon creation
24215  registry.pop();
24216  }
24217 
24218  template <typename T>
24219  inline int destroy_usertype_storage(lua_State* L) noexcept {
24220  clear_usertype_registry_names<T>(L);
24221  return detail::user_alloc_destroy<usertype_storage<T>>(L);
24222  }
24223 
24224  template <typename T>
24226  const char* gcmetakey = &usertype_traits<T>::gc_table()[0];
24227 
24228  // Make sure userdata's memory is properly in lua first,
24229  // otherwise all the light userdata we make later will become invalid
24230  int usertype_storage_push_count = stack::push<user<usertype_storage<T>>>(L, no_metatable, L);
24231  stack_reference usertype_storage_ref(L, -usertype_storage_push_count);
24232 
24233  // create and push onto the stack a table to use as metatable for this GC
24234  // we create a metatable to attach to the regular gc_table
24235  // so that the destructor is called for the usertype storage
24236  int usertype_storage_metatabe_count = stack::push(L, new_table(0, 1));
24237  stack_reference usertype_storage_metatable(L, -usertype_storage_metatabe_count);
24238  // set the destroyion routine on the metatable
24239  stack::set_field(L, meta_function::garbage_collect, &destroy_usertype_storage<T>, usertype_storage_metatable.stack_index());
24240  // set the metatable on the usertype storage userdata
24241  stack::set_field(L, metatable_key, usertype_storage_metatable, usertype_storage_ref.stack_index());
24242  usertype_storage_metatable.pop();
24243 
24244  // set the usertype storage and its metatable
24245  // into the global table...
24246  stack::set_field<true>(L, gcmetakey, usertype_storage_ref);
24247  usertype_storage_ref.pop();
24248 
24249  // then retrieve the lua-stored version so we have a well-pinned
24250  // reference that does not die
24251  stack::get_field<true>(L, gcmetakey);
24252  usertype_storage<T>& target_umt = stack::pop<user<usertype_storage<T>>>(L);
24253  return target_umt;
24254  }
24255 
24257  if (type_of(L, index) != type::lightuserdata) {
24258  return nullopt;
24259  }
24260  usertype_storage_base& base_storage = *static_cast<usertype_storage_base*>(stack::get<void*>(L, index));
24261  return base_storage;
24262  }
24263 
24265  // okay, maybe we're looking at a table that is nested?
24266  if (type_of(L, index) != type::table) {
24267  return nullopt;
24268  }
24270  auto maybe_storage_base = maybe_as_usertype_storage_base(L, -1);
24271  lua_pop(L, 1);
24272  return maybe_storage_base;
24273  }
24274 
24276  // If we can get the index directly as this type, go for it
24277  auto maybe_already_is_usertype_storage_base = maybe_as_usertype_storage_base(L, index);
24278  if (maybe_already_is_usertype_storage_base) {
24279  return maybe_already_is_usertype_storage_base;
24280  }
24282  }
24283 
24285  stack::get_field<true>(L, gcmetakey);
24286  auto maybe_storage = maybe_as_usertype_storage_base(L, lua_gettop(L));
24287  lua_pop(L, 1);
24288  return maybe_storage;
24289  }
24290 
24291  inline usertype_storage_base& get_usertype_storage_base(lua_State* L, const char* gcmetakey) {
24292  stack::get_field<true>(L, gcmetakey);
24293  stack::record tracking;
24294  usertype_storage_base& target_umt = stack::stack_detail::unchecked_unqualified_get<user<usertype_storage_base>>(L, -1, tracking);
24295  lua_pop(L, 1);
24296  return target_umt;
24297  }
24298 
24299  template <typename T>
24301  const char* gcmetakey = &usertype_traits<T>::gc_table()[0];
24302  stack::get_field<true>(L, gcmetakey);
24303  int target = lua_gettop(L);
24304  if (!stack::check<user<usertype_storage<T>>>(L, target)) {
24305  return nullopt;
24306  }
24307  usertype_storage<T>& target_umt = stack::pop<user<usertype_storage<T>>>(L);
24308  return target_umt;
24309  }
24310 
24311  template <typename T>
24313  const char* gcmetakey = &usertype_traits<T>::gc_table()[0];
24314  stack::get_field<true>(L, gcmetakey);
24315  usertype_storage<T>& target_umt = stack::pop<user<usertype_storage<T>>>(L);
24316  return target_umt;
24317  }
24318 
24319  template <typename T>
24321  using u_traits = usertype_traits<T>;
24322 
24323  const char* gcmetakey = &u_traits::gc_table()[0];
24324  stack::get_field<true>(L, gcmetakey);
24326  lua_pop(L, 1);
24327  return;
24328  }
24329  usertype_storage<T>& target_umt = stack::pop<user<usertype_storage<T>>>(L);
24330  target_umt.clear();
24331 
24332  clear_usertype_registry_names<T>(L);
24333 
24334  stack::set_field<true>(L, gcmetakey, lua_nil);
24335  }
24336 
24337  template <typename T, automagic_flags enrollment_flags>
24338  inline int register_usertype(lua_State* L_, automagic_enrollments enrollments_ = {}) {
24339  using u_traits = usertype_traits<T>;
24340  using u_const_traits = usertype_traits<const T>;
24341  using u_unique_traits = usertype_traits<d::u<T>>;
24342  using u_ref_traits = usertype_traits<T*>;
24343  using u_const_ref_traits = usertype_traits<T const*>;
24344  using uts = usertype_storage<T>;
24345 
24346  // always have __new_index point to usertype_storage method
24347  // have __index always point to regular fast-lookup
24348  // meta_method table
24349  // if __new_index is invoked, runtime-swap
24350  // to slow __index if necessary
24351  // (no speed penalty because function calls
24352  // are all read-only -- only depend on __index
24353  // to retrieve function and then call happens VIA Lua)
24354 
24355  // __type entry:
24356  // table contains key -> value lookup,
24357  // where key is entry in metatable
24358  // and value is type information as a string as
24359  // best as we can give it
24360 
24361  // name entry:
24362  // string that contains raw class name,
24363  // as defined from C++
24364 
24365  // is entry:
24366  // checks if argument supplied is of type T
24367 
24368  // __storage entry:
24369  // a light userdata pointing to the storage
24370  // mostly to enable this new abstraction
24371  // to not require the type name `T`
24372  // to get at the C++ usertype storage within
24373 
24374  // we then let typical definitions potentially override these intrinsics
24375  // it's the user's fault if they override things or screw them up:
24376  // these names have been reserved and documented since sol2
24377 
24378  // STEP 0: tell the old usertype (if it exists)
24379  // to fuck off
24380  clear_usertype_storage<T>(L_);
24381 
24382  // STEP 1: Create backing store for usertype storage
24383  // Pretty much the most important step.
24384  // STEP 2: Create Lua tables used for fast method indexing.
24385  // This is done inside of the storage table's constructor
24386  usertype_storage<T>& storage = create_usertype_storage<T>(L_);
24387  usertype_storage_base& base_storage = storage;
24388  void* light_storage = static_cast<void*>(&storage);
24389  void* light_base_storage = static_cast<void*>(&base_storage);
24390 
24391  // STEP 3: set up GC escape hatch table entirely
24392  storage.gc_names_table.push(L_);
24393  stateless_stack_reference gnt(L_, -1);
24394  stack::set_field(L_, submetatable_type::named, &u_traits::gc_table()[0], gnt.stack_index());
24395  stack::set_field(L_, submetatable_type::const_value, &u_const_traits::metatable()[0], gnt.stack_index());
24396  stack::set_field(L_, submetatable_type::const_reference, &u_const_ref_traits::metatable()[0], gnt.stack_index());
24398  stack::set_field(L_, submetatable_type::unique, &u_unique_traits::metatable()[0], gnt.stack_index());
24399  stack::set_field(L_, submetatable_type::value, &u_traits::metatable()[0], gnt.stack_index());
24400  gnt.pop(L_);
24401 
24402  // STEP 4: add some useful information to the type table
24403  stateless_stack_reference stacked_type_table(L_, -storage.type_table.push(L_));
24404  stack::set_field(L_, "name", detail::demangle<T>(), stacked_type_table.stack_index());
24405  stack::set_field(L_, "is", &detail::is_check<T>, stacked_type_table.stack_index());
24406  stacked_type_table.pop(L_);
24407 
24408  // STEP 5: create and hook up metatable,
24409  // add intrinsics
24410  // this one is the actual meta-handling table,
24411  // the next one will be the one for
24412  int for_each_backing_metatable_calls = 0;
24413  auto for_each_backing_metatable = [&](lua_State* L_, submetatable_type smt_, stateless_reference& fast_index_table_) {
24414  // Pointer types, AKA "references" from C++
24415  const char* metakey = nullptr;
24416  switch (smt_) {
24417  case submetatable_type::const_value:
24418  metakey = &u_const_traits::metatable()[0];
24419  break;
24421  metakey = &u_ref_traits::metatable()[0];
24422  break;
24423  case submetatable_type::unique:
24424  metakey = &u_unique_traits::metatable()[0];
24425  break;
24426  case submetatable_type::const_reference:
24427  metakey = &u_const_ref_traits::metatable()[0];
24428  break;
24429  case submetatable_type::named:
24430  metakey = &u_traits::user_metatable()[0];
24431  break;
24432  case submetatable_type::value:
24433  default:
24434  metakey = &u_traits::metatable()[0];
24435  break;
24436  }
24437 
24438  luaL_newmetatable(L_, metakey);
24439  if (smt_ == submetatable_type::named) {
24440  // the named table itself
24441  // gets the associated name value
24442  storage.named_metatable.reset(L_, -1);
24443  lua_pop(L_, 1);
24444  // but the thing we perform the methods on
24445  // is still the metatable of the named
24446  // table
24447  lua_createtable(L_, 0, 6);
24448  }
24449  stateless_stack_reference t(L_, -1);
24450  fast_index_table_.reset(L_, t.stack_index());
24451  stack::set_field<false, true>(L_, meta_function::type, storage.type_table, t.stack_index());
24452  // destructible? serialize default destructor here
24453  // otherwise, not destructible: serialize a "hey you messed up"
24454  switch (smt_) {
24455  case submetatable_type::const_reference:
24457  case submetatable_type::named:
24458  break;
24459  case submetatable_type::unique:
24460  if constexpr (std::is_destructible_v<T>) {
24461  stack::set_field<false, true>(L_, meta_function::garbage_collect, &detail::unique_destroy<T>, t.stack_index());
24462  }
24463  else {
24464  stack::set_field<false, true>(L_, meta_function::garbage_collect, &detail::cannot_destroy<T>, t.stack_index());
24465  }
24466  break;
24467  case submetatable_type::value:
24468  case submetatable_type::const_value:
24469  default:
24470  if constexpr (std::is_destructible_v<T>) {
24471  stack::set_field<false, true>(L_, meta_function::garbage_collect, detail::make_destructor<T>(), t.stack_index());
24472  }
24473  else {
24474  stack::set_field<false, true>(L_, meta_function::garbage_collect, &detail::cannot_destroy<T>, t.stack_index());
24475  }
24476  break;
24477  }
24478 
24479  static_assert(sizeof(void*) <= sizeof(detail::inheritance_check_function),
24480  "The size of this data pointer is too small to fit the inheritance checking function: file a bug "
24481  "report.");
24482  static_assert(sizeof(void*) <= sizeof(detail::inheritance_cast_function),
24483  "The size of this data pointer is too small to fit the inheritance checking function: file a bug "
24484  "report.");
24485  stack::set_field<false, true>(L_, detail::base_class_check_key(), reinterpret_cast<void*>(&detail::inheritance<T>::type_check), t.stack_index());
24486  stack::set_field<false, true>(L_, detail::base_class_cast_key(), reinterpret_cast<void*>(&detail::inheritance<T>::type_cast), t.stack_index());
24487 
24488  auto prop_fx = detail::properties_enrollment_allowed(for_each_backing_metatable_calls, storage.properties, enrollments_);
24489  auto insert_fx = [&L_, &t, &storage](meta_function mf, lua_CFunction reg) {
24490  stack::set_field<false, true>(L_, mf, reg, t.stack_index());
24491  storage.properties[static_cast<std::size_t>(mf)] = true;
24492  };
24493  detail::insert_default_registrations<T>(insert_fx, prop_fx);
24494 
24495  // There are no variables, so serialize the fast function stuff
24496  // be sure to reset the index stuff to the non-fast version
24497  // if the user ever adds something later!
24498  if (smt_ == submetatable_type::named) {
24499  // add escape hatch storage pointer and gc names
24500  stack::set_field<false, true>(L_, meta_function::storage, light_base_storage, t.stack_index());
24501  stack::set_field<false, true>(L_, meta_function::gc_names, storage.gc_names_table, t.stack_index());
24502 
24503  // fancy new_indexing when using the named table
24504  {
24505  absolute_index named_metatable_index(L_, -storage.named_metatable.push(L_));
24506  stack::set_field<false, true>(L_, metatable_key, t, named_metatable_index);
24507  storage.named_metatable.pop(L_);
24508  }
24509  stack_reference stack_metametatable(L_, -storage.named_index_table.push(L_));
24510  stack::set_field<false, true>(L_,
24512  make_closure(uts::template meta_index_call<false>, nullptr, light_storage, light_base_storage, nullptr, toplevel_magic),
24513  stack_metametatable.stack_index());
24514  stack::set_field<false, true>(L_,
24516  make_closure(uts::template meta_index_call<true>, nullptr, light_storage, light_base_storage, nullptr, toplevel_magic),
24517  stack_metametatable.stack_index());
24518  stack_metametatable.pop();
24519  }
24520  else {
24521  // otherwise just plain for index,
24522  // and elaborated for new_index
24523  stack::set_field<false, true>(L_, meta_function::index, t, t.stack_index());
24524  stack::set_field<false, true>(L_,
24526  make_closure(uts::template index_call<true>, nullptr, light_storage, light_base_storage, nullptr, toplevel_magic),
24527  t.stack_index());
24528  storage.is_using_new_index = true;
24529  }
24530 
24531  ++for_each_backing_metatable_calls;
24532  fast_index_table_.reset(L_, t.stack_index());
24533  t.pop(L_);
24534  };
24535 
24536  storage.for_each_table(L_, for_each_backing_metatable);
24537 
24538  // can only use set AFTER we initialize all the metatables
24539  if constexpr (std::is_default_constructible_v<T> && has_flag(enrollment_flags, automagic_flags::default_constructor)) {
24540  if (enrollments_.default_constructor) {
24542  }
24543  }
24544 
24545  // return the named metatable we want names linked into
24546  storage.named_metatable.push(L_);
24547  return 1;
24548  }
24549 }} // namespace sol::u_detail
24550 
24551 // end of sol/usertype_storage.hpp
24552 
24553 // beginning of sol/usertype_proxy.hpp
24554 
24555 namespace sol {
24556  template <typename Table, typename Key>
24557  struct usertype_proxy : public proxy_base<usertype_proxy<Table, Key>> {
24558  private:
24560 
24561  template <typename T, std::size_t... I>
24562  decltype(auto) tuple_get(std::index_sequence<I...>) const& {
24563  return tbl.template traverse_get<T>(std::get<I>(key)...);
24564  }
24565 
24566  template <typename T, std::size_t... I>
24567  decltype(auto) tuple_get(std::index_sequence<I...>) && {
24568  return tbl.template traverse_get<T>(std::get<I>(std::move(key))...);
24569  }
24570 
24571  template <std::size_t... I, typename T>
24572  void tuple_set(std::index_sequence<I...>, T&& value) & {
24573  if constexpr (sizeof...(I) > 1) {
24574  tbl.traverse_set(std::get<I>(key)..., std::forward<T>(value));
24575  }
24576  else {
24577  tbl.set(std::get<I>(key)..., std::forward<T>(value));
24578  }
24579  }
24580 
24581  template <std::size_t... I, typename T>
24582  void tuple_set(std::index_sequence<I...>, T&& value) && {
24583  if constexpr (sizeof...(I) > 1) {
24584  tbl.traverse_set(std::get<I>(std::move(key))..., std::forward<T>(value));
24585  }
24586  else {
24587  tbl.set(std::get<I>(std::move(key))..., std::forward<T>(value));
24588  }
24589  }
24590 
24591  public:
24594 
24595  template <typename T>
24596  usertype_proxy(Table table, T&& k) : tbl(table), key(std::forward<T>(k)) {
24597  }
24598 
24599  template <typename T>
24600  usertype_proxy& set(T&& item) & {
24601  using idx_seq = std::make_index_sequence<std::tuple_size_v<meta::unqualified_t<key_type>>>;
24602  tuple_set(idx_seq(), std::forward<T>(item));
24603  return *this;
24604  }
24605 
24606  template <typename T>
24607  usertype_proxy&& set(T&& item) && {
24608  using idx_seq = std::make_index_sequence<std::tuple_size_v<meta::unqualified_t<key_type>>>;
24609  std::move(*this).tuple_set(idx_seq(), std::forward<T>(item));
24610  return std::move(*this);
24611  }
24612 
24613  template <typename T>
24614  usertype_proxy& operator=(T&& other) & {
24615  return set(std::forward<T>(other));
24616  }
24617 
24618  template <typename T>
24619  usertype_proxy&& operator=(T&& other) && {
24620  return std::move(*this).set(std::forward<T>(other));
24621  }
24622 
24623  template <typename T>
24624  usertype_proxy& operator=(std::initializer_list<T> other) & {
24625  return set(std::move(other));
24626  }
24627 
24628  template <typename T>
24629  usertype_proxy&& operator=(std::initializer_list<T> other) && {
24630  return std::move(*this).set(std::move(other));
24631  }
24632 
24633  template <typename T>
24634  decltype(auto) get() const& {
24635  using idx_seq = std::make_index_sequence<std::tuple_size_v<meta::unqualified_t<key_type>>>;
24636  return tuple_get<T>(idx_seq());
24637  }
24638 
24639  template <typename T>
24640  decltype(auto) get() && {
24641  using idx_seq = std::make_index_sequence<std::tuple_size_v<meta::unqualified_t<key_type>>>;
24642  return std::move(*this).template tuple_get<T>(idx_seq());
24643  }
24644 
24645  template <typename K>
24646  decltype(auto) operator[](K&& k) const& {
24647  auto keys = meta::tuplefy(key, std::forward<K>(k));
24649  }
24650 
24651  template <typename K>
24652  decltype(auto) operator[](K&& k) & {
24653  auto keys = meta::tuplefy(key, std::forward<K>(k));
24655  }
24656 
24657  template <typename K>
24658  decltype(auto) operator[](K&& k) && {
24659  auto keys = meta::tuplefy(std::move(key), std::forward<K>(k));
24661  }
24662 
24663  template <typename... Ret, typename... Args>
24664  decltype(auto) call(Args&&... args) {
24665 #if !defined(__clang__) && defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 191200000
24666  // MSVC is ass sometimes
24667  return get<function>().call<Ret...>(std::forward<Args>(args)...);
24668 #else
24669  return get<function>().template call<Ret...>(std::forward<Args>(args)...);
24670 #endif
24671  }
24672 
24673  template <typename... Args>
24674  decltype(auto) operator()(Args&&... args) {
24675  return call<>(std::forward<Args>(args)...);
24676  }
24677 
24678  bool valid() const {
24679  auto pp = stack::push_pop(tbl);
24680  auto p = stack::probe_get_field<std::is_same<meta::unqualified_t<Table>, global_table>::value>(lua_state(), key, lua_gettop(lua_state()));
24681  lua_pop(lua_state(), p.levels);
24682  return p;
24683  }
24684 
24685  int push() const noexcept {
24686  return push(this->lua_state());
24687  }
24688 
24689  int push(lua_State* L) const noexcept {
24690  return get<reference>().push(L);
24691  }
24692 
24693  type get_type() const {
24694  type t = type::none;
24695  auto pp = stack::push_pop(tbl);
24696  auto p = stack::probe_get_field<std::is_same<meta::unqualified_t<Table>, global_table>::value>(lua_state(), key, lua_gettop(lua_state()));
24697  if (p) {
24698  t = type_of(lua_state(), -1);
24699  }
24700  lua_pop(lua_state(), p.levels);
24701  return t;
24702  }
24703 
24705  return tbl.lua_state();
24706  }
24707  };
24708 } // namespace sol
24709 
24710 // end of sol/usertype_proxy.hpp
24711 
24712 // beginning of sol/metatable.hpp
24713 
24714 // beginning of sol/table_core.hpp
24715 
24716 // beginning of sol/table_proxy.hpp
24717 
24718 namespace sol {
24719 
24720  template <typename Table, typename Key>
24721  struct table_proxy : public proxy_base<table_proxy<Table, Key>> {
24722  private:
24724 
24725  template <typename T, std::size_t... I>
24726  decltype(auto) tuple_get(std::index_sequence<I...>) const& {
24727  return tbl.template traverse_get<T>(std::get<I>(key)...);
24728  }
24729 
24730  template <typename T, std::size_t... I>
24731  decltype(auto) tuple_get(std::index_sequence<I...>) && {
24732  return tbl.template traverse_get<T>(std::get<I>(std::move(key))...);
24733  }
24734 
24735  template <std::size_t... I, typename T>
24736  void tuple_set(std::index_sequence<I...>, T&& value) & {
24737  tbl.traverse_set(std::get<I>(key)..., std::forward<T>(value));
24738  }
24739 
24740  template <std::size_t... I, typename T>
24741  void tuple_set(std::index_sequence<I...>, T&& value) && {
24742  tbl.traverse_set(std::get<I>(std::move(key))..., std::forward<T>(value));
24743  }
24744 
24746  auto p = stack::probe_get_field<std::is_same_v<meta::unqualified_t<Table>, global_table>>(lua_state(), key, tbl.stack_index());
24747  lua_pop(lua_state(), p.levels);
24748  return p;
24749  }
24750 
24752  auto pp = stack::push_pop(tbl);
24753  auto p = stack::probe_get_field<std::is_same_v<meta::unqualified_t<Table>, global_table>>(lua_state(), key, lua_gettop(lua_state()));
24754  lua_pop(lua_state(), p.levels);
24755  return p;
24756  }
24757 
24758  public:
24761 
24762  template <typename T>
24763  table_proxy(Table table, T&& k) : tbl(table), key(std::forward<T>(k)) {
24764  }
24765 
24766  template <typename T>
24767  table_proxy& set(T&& item) & {
24768  tuple_set(std::make_index_sequence<std::tuple_size_v<meta::unqualified_t<key_type>>>(), std::forward<T>(item));
24769  return *this;
24770  }
24771 
24772  template <typename T>
24773  table_proxy&& set(T&& item) && {
24774  std::move(*this).tuple_set(std::make_index_sequence<std::tuple_size_v<meta::unqualified_t<key_type>>>(), std::forward<T>(item));
24775  return std::move(*this);
24776  }
24777 
24778  template <typename... Args>
24780  tbl.set_function(key, std::forward<Args>(args)...);
24781  return *this;
24782  }
24783 
24784  template <typename... Args>
24785  table_proxy&& set_function(Args&&... args) && {
24786  tbl.set_function(std::move(key), std::forward<Args>(args)...);
24787  return std::move(*this);
24788  }
24789 
24790  template <typename T>
24791  table_proxy& operator=(T&& other) & {
24792  using Tu = meta::unwrap_unqualified_t<T>;
24793  if constexpr (!is_lua_reference_or_proxy_v<Tu> && meta::is_invocable_v<Tu>) {
24794  return set_function(std::forward<T>(other));
24795  }
24796  else {
24797  return set(std::forward<T>(other));
24798  }
24799  }
24800 
24801  template <typename T>
24802  table_proxy&& operator=(T&& other) && {
24803  using Tu = meta::unwrap_unqualified_t<T>;
24804  if constexpr (!is_lua_reference_or_proxy_v<Tu> && meta::is_invocable_v<Tu> && !detail::is_msvc_callable_rigged_v<T>) {
24805  return std::move(*this).set_function(std::forward<T>(other));
24806  }
24807  else {
24808  return std::move(*this).set(std::forward<T>(other));
24809  }
24810  }
24811 
24812  template <typename T>
24813  table_proxy& operator=(std::initializer_list<T> other) & {
24814  return set(std::move(other));
24815  }
24816 
24817  template <typename T>
24818  table_proxy&& operator=(std::initializer_list<T> other) && {
24819  return std::move(*this).set(std::move(other));
24820  }
24821 
24822  template <typename T>
24823  bool is() const {
24824  typedef decltype(get<T>()) U;
24825  optional<U> option = this->get<optional<U>>();
24826  return option.has_value();
24827  }
24828 
24829  template <typename T>
24830  decltype(auto) get() const& {
24831  using idx_seq = std::make_index_sequence<std::tuple_size_v<meta::unqualified_t<key_type>>>;
24832  return tuple_get<T>(idx_seq());
24833  }
24834 
24835  template <typename T>
24836  decltype(auto) get() && {
24837  using idx_seq = std::make_index_sequence<std::tuple_size_v<meta::unqualified_t<key_type>>>;
24838  return std::move(*this).template tuple_get<T>(idx_seq());
24839  }
24840 
24841  template <typename T>
24842  decltype(auto) get_or(T&& otherwise) const {
24843  typedef decltype(get<T>()) U;
24844  optional<U> option = get<optional<U>>();
24845  if (option) {
24846  return static_cast<U>(option.value());
24847  }
24848  return static_cast<U>(std::forward<T>(otherwise));
24849  }
24850 
24851  template <typename T, typename D>
24852  decltype(auto) get_or(D&& otherwise) const {
24853  optional<T> option = get<optional<T>>();
24854  if (option) {
24855  return static_cast<T>(option.value());
24856  }
24857  return static_cast<T>(std::forward<D>(otherwise));
24858  }
24859 
24860  template <typename T>
24861  decltype(auto) get_or_create() {
24862  return get_or_create<T>(new_table());
24863  }
24864 
24865  template <typename T, typename Otherwise>
24866  decltype(auto) get_or_create(Otherwise&& other) {
24867  if (!this->valid()) {
24868  this->set(std::forward<Otherwise>(other));
24869  }
24870  return get<T>();
24871  }
24872 
24873  template <typename K>
24874  decltype(auto) operator[](K&& k) const& {
24875  auto keys = meta::tuplefy(key, std::forward<K>(k));
24876  return table_proxy<Table, decltype(keys)>(tbl, std::move(keys));
24877  }
24878 
24879  template <typename K>
24880  decltype(auto) operator[](K&& k) & {
24881  auto keys = meta::tuplefy(key, std::forward<K>(k));
24882  return table_proxy<Table, decltype(keys)>(tbl, std::move(keys));
24883  }
24884 
24885  template <typename K>
24886  decltype(auto) operator[](K&& k) && {
24887  auto keys = meta::tuplefy(std::move(key), std::forward<K>(k));
24888  return table_proxy<Table, decltype(keys)>(tbl, std::move(keys));
24889  }
24890 
24891  template <typename... Ret, typename... Args>
24892  decltype(auto) call(Args&&... args) {
24893  lua_State* L = this->lua_state();
24894  push(L);
24895  int idx = lua_gettop(L);
24896  stack_aligned_function func(L, idx);
24897  return func.call<Ret...>(std::forward<Args>(args)...);
24898  }
24899 
24900  template <typename... Args>
24901  decltype(auto) operator()(Args&&... args) {
24902  return call<>(std::forward<Args>(args)...);
24903  }
24904 
24905  bool valid() const {
24906  auto pp = stack::push_pop(tbl);
24907  auto p = stack::probe_get_field<std::is_same<meta::unqualified_t<Table>, global_table>::value>(lua_state(), key, lua_gettop(lua_state()));
24908  lua_pop(lua_state(), p.levels);
24909  return p;
24910  }
24911 
24912  int push() const noexcept {
24913  return push(this->lua_state());
24914  }
24915 
24916  int push(lua_State* L) const noexcept {
24918  auto pp = stack::push_pop<true>(tbl);
24919  int tableindex = pp.index_of(tbl);
24920  int top_index = lua_gettop(L);
24921  stack::get_field<true>(lua_state(), key, tableindex);
24922  lua_replace(L, top_index + 1);
24923  lua_settop(L, top_index + 1);
24924  }
24925  else {
24926  auto pp = stack::push_pop<false>(tbl);
24927  int tableindex = pp.index_of(tbl);
24928  int aftertableindex = lua_gettop(L);
24929  stack::get_field<false>(lua_state(), key, tableindex);
24930  lua_replace(L, tableindex);
24931  lua_settop(L, aftertableindex + 1);
24932  }
24933  return 1;
24934  }
24935 
24936  type get_type() const {
24937  type t = type::none;
24938  auto pp = stack::push_pop(tbl);
24939  auto p = stack::probe_get_field<std::is_same<meta::unqualified_t<Table>, global_table>::value>(lua_state(), key, lua_gettop(lua_state()));
24940  if (p) {
24941  t = type_of(lua_state(), -1);
24942  }
24943  lua_pop(lua_state(), p.levels);
24944  return t;
24945  }
24946 
24948  return tbl.lua_state();
24949  }
24950 
24952  if (!this->valid()) {
24953  this->set(new_table());
24954  }
24955  return *this;
24956  }
24957  };
24958 
24959  template <typename Table, typename Key, typename T>
24960  inline bool operator==(T&& left, const table_proxy<Table, Key>& right) {
24961  using G = decltype(stack::get<T>(nullptr, 0));
24962  return right.template get<optional<G>>() == left;
24963  }
24964 
24965  template <typename Table, typename Key, typename T>
24966  inline bool operator==(const table_proxy<Table, Key>& right, T&& left) {
24967  using G = decltype(stack::get<T>(nullptr, 0));
24968  return right.template get<optional<G>>() == left;
24969  }
24970 
24971  template <typename Table, typename Key, typename T>
24972  inline bool operator!=(T&& left, const table_proxy<Table, Key>& right) {
24973  using G = decltype(stack::get<T>(nullptr, 0));
24974  return right.template get<optional<G>>() != left;
24975  }
24976 
24977  template <typename Table, typename Key, typename T>
24978  inline bool operator!=(const table_proxy<Table, Key>& right, T&& left) {
24979  using G = decltype(stack::get<T>(nullptr, 0));
24980  return right.template get<optional<G>>() != left;
24981  }
24982 
24983  template <typename Table, typename Key>
24985  return !right.valid();
24986  }
24987 
24988  template <typename Table, typename Key>
24990  return !right.valid();
24991  }
24992 
24993  template <typename Table, typename Key>
24995  return right.valid();
24996  }
24997 
24998  template <typename Table, typename Key>
25000  return right.valid();
25001  }
25002 
25003  template <bool b>
25004  template <typename Super>
25006  basic_reference<b> v = r;
25007  this->operator=(std::move(v));
25008  return *this;
25009  }
25010 
25011  template <bool b>
25012  template <typename Super>
25014  basic_reference<b> v = r;
25015  this->operator=(std::move(v));
25016  return *this;
25017  }
25018 
25019  namespace stack {
25020  template <typename Table, typename Key>
25022  static int push(lua_State* L, const table_proxy<Table, Key>& p) {
25023  return p.push(L);
25024  }
25025  };
25026  } // namespace stack
25027 } // namespace sol
25028 
25029 // end of sol/table_proxy.hpp
25030 
25031 // beginning of sol/table_iterator.hpp
25032 
25033 #include <iterator>
25034 
25035 namespace sol {
25036 
25037  template <typename reference_type>
25039  public:
25040  typedef object key_type;
25041  typedef object mapped_type;
25042  typedef std::pair<object, object> value_type;
25043  typedef std::input_iterator_tag iterator_category;
25044  typedef std::ptrdiff_t difference_type;
25047  typedef const value_type& const_reference;
25048 
25049  private:
25050  std::pair<object, object> kvp;
25051  reference_type ref;
25052  int tableidx = 0;
25053  int keyidx = 0;
25054  std::ptrdiff_t idx = 0;
25055 
25056  public:
25057  basic_table_iterator() noexcept : keyidx(-1), idx(-1) {
25058  }
25059 
25060  basic_table_iterator(reference_type x) noexcept : ref(std::move(x)) {
25061  ref.push();
25062  tableidx = lua_gettop(ref.lua_state());
25063  stack::push(ref.lua_state(), lua_nil);
25064  this->operator++();
25065  if (idx == -1) {
25066  return;
25067  }
25068  --idx;
25069  }
25070 
25072  if (idx == -1)
25073  return *this;
25074 
25075  if (lua_next(ref.lua_state(), tableidx) == 0) {
25076  idx = -1;
25077  keyidx = -1;
25078  return *this;
25079  }
25080  ++idx;
25081  kvp.first = object(ref.lua_state(), -2);
25082  kvp.second = object(ref.lua_state(), -1);
25083  lua_pop(ref.lua_state(), 1);
25084  // leave key on the stack
25085  keyidx = lua_gettop(ref.lua_state());
25086  return *this;
25087  }
25088 
25090  auto saved = *this;
25091  this->operator++();
25092  return saved;
25093  }
25094 
25095  reference operator*() const noexcept {
25096  return const_cast<reference>(kvp);
25097  }
25098 
25099  bool operator==(const basic_table_iterator& right) const noexcept {
25100  return idx == right.idx;
25101  }
25102 
25103  bool operator!=(const basic_table_iterator& right) const noexcept {
25104  return idx != right.idx;
25105  }
25106 
25108  if (keyidx != -1) {
25109  stack::remove(ref.lua_state(), keyidx, 1);
25110  }
25111  if (ref.lua_state() != nullptr && ref.valid()) {
25112  stack::remove(ref.lua_state(), tableidx, 1);
25113  }
25114  }
25115  };
25116 
25117 } // namespace sol
25118 
25119 // end of sol/table_iterator.hpp
25120 
25121 // beginning of sol/pairs_iterator.hpp
25122 
25123 // beginning of sol/stack/detail/pairs.hpp
25124 
25125 #include <optional>
25126 
25127 namespace sol { namespace stack { namespace stack_detail {
25128 
25130  stack::get_field<true, false>(L_, "next");
25131  bool is_next = stack::check<protected_function>(L_);
25132  if (is_next) {
25133  return true;
25134  }
25135  stack::get_field<true, false>(L_, "table");
25136  stack::record tracking{};
25137  if (!stack::loose_table_check(L_, -1, &no_panic, tracking)) {
25138  return false;
25139  }
25140  lua_getfield(L_, -1, "next");
25141  bool is_table_next_func = stack::check<protected_function>(L_, -1);
25142  if (is_table_next_func) {
25143  return true;
25144  }
25145  lua_pop(L_, 1);
25146  return false;
25147  }
25148 
25149  inline std::optional<protected_function> find_lua_next_function(lua_State* L_) {
25150  if (maybe_push_lua_next_function(L_)) {
25151  return stack::pop<protected_function>(L_);
25152  }
25153  return std::nullopt;
25154  }
25155 
25156  inline int c_lua_next(lua_State* L_) noexcept {
25157  stack_reference table_stack_ref(L_, raw_index(1));
25158  stateless_stack_reference key_stack_ref(L_, raw_index(2));
25159  int result = lua_next(table_stack_ref.lua_state(), table_stack_ref.stack_index());
25160  if (result == 0) {
25161  stack::push(L_, lua_nil);
25162  return 1;
25163  }
25164  return 2;
25165  }
25166 
25167  inline int readonly_pairs(lua_State* L_) noexcept {
25168  int pushed = 0;
25169  if (!maybe_push_lua_next_function(L_)) {
25170  // we do not have the "next" function in the global namespace
25171  // from the "table" global entiry, use our own
25172  pushed += stack::push(L_, &c_lua_next);
25173  }
25174  else {
25175  pushed += 1;
25176  }
25177  int metatable_exists = lua_getmetatable(L_, 1);
25178  sol_c_assert(metatable_exists == 1);
25179  const auto& index_key = to_string(sol::meta_function::index);
25180  lua_getfield(L_, lua_gettop(L_), index_key.c_str());
25181  lua_remove(L_, -2);
25182  pushed += 1;
25183  pushed += stack::push(L_, lua_nil);
25184  return pushed;
25185  }
25186 
25187 }}} // sol::stack::stack_detail
25188 
25189 // end of sol/stack/detail/pairs.hpp
25190 
25191 namespace sol {
25192 
25193  struct pairs_sentinel { };
25194 
25196  private:
25197  inline static constexpr int empty_key_index = -1;
25198 
25199  public:
25200  using key_type = object;
25202  using value_type = std::pair<object, object>;
25203  using iterator_category = std::input_iterator_tag;
25204  using difference_type = std::ptrdiff_t;
25206  using const_pointer = value_type const*;
25208  using const_reference = const value_type&;
25209 
25210  pairs_iterator() noexcept
25211  : m_L(nullptr)
25212  , m_next_function_ref(lua_nil)
25213  , m_table_ref(lua_nil)
25214  , m_cached_key_value_pair({ lua_nil, lua_nil })
25215  , m_key_index(empty_key_index)
25216  , m_iteration_index(0) {
25217  }
25218 
25219  pairs_iterator(const pairs_iterator&) = delete;
25220  pairs_iterator& operator=(const pairs_iterator&) = delete;
25221 
25223  : m_L(right.m_L)
25224  , m_next_function_ref(std::move(right.m_next_function_ref))
25225  , m_table_ref(std::move(right.m_table_ref))
25226  , m_cached_key_value_pair(std::move(right.m_cached_key_value_pair))
25227  , m_key_index(right.m_key_index)
25228  , m_iteration_index(right.m_iteration_index) {
25229  right.m_key_index = empty_key_index;
25230  }
25231 
25233  m_L = right.m_L;
25234  m_next_function_ref = std::move(right.m_next_function_ref);
25235  m_table_ref = std::move(right.m_table_ref);
25236  m_cached_key_value_pair = std::move(right.m_cached_key_value_pair);
25237  m_key_index = right.m_key_index;
25238  m_iteration_index = right.m_iteration_index;
25239  right.m_key_index = empty_key_index;
25240  return *this;
25241  }
25242 
25243  template <typename Source>
25244  pairs_iterator(const Source& source_) noexcept : m_L(source_.lua_state()), m_key_index(empty_key_index), m_iteration_index(0) {
25245  if (m_L == nullptr || !source_.valid()) {
25246  m_key_index = empty_key_index;
25247  return;
25248  }
25249  int source_index = -source_.push(m_L);
25250  int abs_source_index = lua_absindex(m_L, source_index);
25251  int metatable_exists = lua_getmetatable(m_L, abs_source_index);
25252  lua_remove(m_L, abs_source_index);
25253  if (metatable_exists == 1) {
25254  // just has a metatable, but does it have __pairs ?
25255  stack_reference metatable(m_L, raw_index(abs_source_index));
25256  stack::get_field<is_global_table_v<Source>, true>(m_L, meta_function::pairs, metatable.stack_index());
25257  optional<protected_function> maybe_pairs_function = stack::pop<optional<protected_function>>(m_L);
25258  if (maybe_pairs_function.has_value()) {
25259  protected_function& pairs_function = *maybe_pairs_function;
25260  protected_function_result next_fn_and_table_and_first_key = pairs_function(source_);
25261  if (next_fn_and_table_and_first_key.valid()) {
25262  m_next_function_ref = next_fn_and_table_and_first_key.get<protected_function>(0);
25263  m_table_ref = next_fn_and_table_and_first_key.get<sol::reference>(1);
25264  m_key_index = next_fn_and_table_and_first_key.stack_index() - 1;
25265  // remove next function and table
25266  lua_remove(m_L, m_key_index);
25267  lua_remove(m_L, m_key_index);
25268  next_fn_and_table_and_first_key.abandon();
25269  lua_remove(m_L, abs_source_index);
25270  this->operator++();
25271  m_iteration_index = 0;
25272  return;
25273  }
25274  }
25275  }
25276 
25277  {
25278  auto maybe_next = stack::stack_detail::find_lua_next_function(m_L);
25279  if (maybe_next.has_value()) {
25280  m_next_function_ref = std::move(*maybe_next);
25281  m_table_ref = source_;
25282 
25283  stack::push(m_L, lua_nil);
25284  m_key_index = lua_gettop(m_L);
25285  this->operator++();
25286  m_iteration_index = 0;
25287  return;
25288  }
25289  }
25290 
25291  // okay, so none of the above worked and now we need to create
25292  // a shim / polyfill instead
25294  m_next_function_ref = stack::pop<protected_function>(m_L);
25295  m_table_ref = source_;
25296  stack::push(m_L, lua_nil);
25297  m_key_index = lua_gettop(m_L);
25298  this->operator++();
25299  m_iteration_index = 0;
25300  }
25301 
25303  if (m_key_index == empty_key_index) {
25304  return *this;
25305  }
25306  {
25307  sol::protected_function_result next_results = m_next_function_ref(m_table_ref, stack_reference(m_L, m_key_index));
25308  if (!next_results.valid()) {
25309  // TODO: abort, or throw an error?
25310  m_clear();
25311  m_key_index = empty_key_index;
25312  return *this;
25313  }
25314  int next_results_count = next_results.return_count();
25315  if (next_results_count < 2) {
25316  // iteration is over!
25317  next_results.abandon();
25318  lua_settop(m_L, m_key_index - 1);
25319  m_key_index = empty_key_index;
25320  ++m_iteration_index;
25321  return *this;
25322  }
25323  else {
25324  lua_remove(m_L, m_key_index);
25325  m_key_index = next_results.stack_index() - 1;
25326  m_cached_key_value_pair.first = stack::get<object>(m_L, m_key_index);
25327  m_cached_key_value_pair.second = stack::get<object>(m_L, m_key_index + 1);
25328  lua_settop(m_L, m_key_index);
25329  next_results.abandon();
25330  }
25331  }
25332  ++m_iteration_index;
25333  return *this;
25334  }
25335 
25336  std::ptrdiff_t index() const {
25337  return static_cast<std::ptrdiff_t>(m_iteration_index);
25338  }
25339 
25340  const_reference operator*() const noexcept {
25341  return m_cached_key_value_pair;
25342  }
25343 
25344  reference operator*() noexcept {
25345  return m_cached_key_value_pair;
25346  }
25347 
25348  friend bool operator==(const pairs_iterator& left, const pairs_iterator& right) noexcept {
25349  return left.m_table_ref == right.m_table_ref && left.m_iteration_index == right.m_iteration_index;
25350  }
25351 
25352  friend bool operator!=(const pairs_iterator& left, const pairs_iterator& right) noexcept {
25353  return left.m_table_ref != right.m_table_ref || left.m_iteration_index != right.m_iteration_index;
25354  }
25355 
25356  friend bool operator==(const pairs_iterator& left, const pairs_sentinel&) noexcept {
25357  return left.m_key_index == empty_key_index;
25358  }
25359 
25360  friend bool operator!=(const pairs_iterator& left, const pairs_sentinel&) noexcept {
25361  return left.m_key_index != empty_key_index;
25362  }
25363 
25364  friend bool operator==(const pairs_sentinel&, const pairs_iterator& left) noexcept {
25365  return left.m_key_index == empty_key_index;
25366  }
25367 
25368  friend bool operator!=(const pairs_sentinel&, const pairs_iterator& left) noexcept {
25369  return left.m_key_index != empty_key_index;
25370  }
25371 
25373  if (m_key_index != empty_key_index) {
25374  m_clear();
25375  }
25376  }
25377 
25378  private:
25379  void m_clear() noexcept {
25380  lua_remove(m_L, m_key_index);
25381  }
25382 
25386  std::pair<object, object> m_cached_key_value_pair;
25389  };
25390 
25391  template <typename Source>
25393  private:
25394  using source_t = std::add_lvalue_reference_t<Source>;
25396 
25397  public:
25400 
25401  basic_pairs_range(source_t source_) noexcept : m_source(source_) {
25402  }
25403 
25404  iterator begin() noexcept {
25405  return iterator(m_source);
25406  }
25407 
25408  iterator begin() const noexcept {
25409  return iterator(m_source);
25410  }
25411 
25412  const_iterator cbegin() const noexcept {
25413  return const_iterator(m_source);
25414  }
25415 
25416  pairs_sentinel end() noexcept {
25417  return {};
25418  }
25419 
25420  pairs_sentinel end() const noexcept {
25421  return {};
25422  }
25423 
25424  pairs_sentinel cend() const noexcept {
25425  return {};
25426  }
25427  };
25428 } // namespace sol
25429 
25430 // end of sol/pairs_iterator.hpp
25431 
25432 namespace sol {
25433  namespace detail {
25434  template <std::size_t n>
25435  struct clean {
25437  clean(lua_State* luastate) : L(luastate) {
25438  }
25440  lua_pop(L, static_cast<int>(n));
25441  }
25442  };
25443 
25444  struct ref_clean {
25447 
25448  ref_clean(lua_State* L_, int& pop_count_) noexcept : L(L_), pop_count(pop_count_) {
25449  }
25451  lua_pop(L, static_cast<int>(pop_count));
25452  }
25453  };
25454 
25455  inline int fail_on_newindex(lua_State* L_) {
25456  return luaL_error(L_, "sol: cannot modify the elements of an enumeration table");
25457  }
25458 
25459  } // namespace detail
25460 
25461  template <bool top_level, typename ref_t>
25462  class basic_table_core : public basic_object<ref_t> {
25463  private:
25465 
25466  friend class state;
25467  friend class state_view;
25468  template <typename, typename>
25469  friend class basic_usertype;
25470  template <typename>
25471  friend class basic_metatable;
25472 
25473  template <typename T>
25475 
25476  template <typename T>
25478 
25479  template <typename T>
25481 
25482  template <typename T>
25484 
25485  template <bool raw, typename... Ret, typename... Keys>
25486  decltype(auto) tuple_get(int table_index, Keys&&... keys) const {
25487  if constexpr (sizeof...(Ret) < 2) {
25488  return traverse_get_single_maybe_tuple<raw, Ret...>(table_index, std::forward<Keys>(keys)...);
25489  }
25490  else {
25491  using multi_ret = decltype(stack::pop<std::tuple<Ret...>>(nullptr));
25492  return multi_ret(traverse_get_single_maybe_tuple<raw, Ret>(table_index, std::forward<Keys>(keys))...);
25493  }
25494  }
25495 
25496  template <bool raw, typename Ret, size_t... I, typename Key>
25497  decltype(auto) traverse_get_single_tuple(int table_index, std::index_sequence<I...>, Key&& key) const {
25498  return traverse_get_single<raw, Ret>(table_index, std::get<I>(std::forward<Key>(key))...);
25499  }
25500 
25501  template <bool raw, typename Ret, typename Key>
25502  decltype(auto) traverse_get_single_maybe_tuple(int table_index, Key&& key) const {
25503  if constexpr (meta::is_tuple_v<meta::unqualified_t<Key>>) {
25504  return traverse_get_single_tuple<raw, Ret>(
25505  table_index, std::make_index_sequence<std::tuple_size_v<meta::unqualified_t<Key>>>(), std::forward<Key>(key));
25506  }
25507  else {
25508  return traverse_get_single<raw, Ret>(table_index, std::forward<Key>(key));
25509  }
25510  }
25511 
25512  template <bool raw, typename Ret, typename... Keys>
25513  decltype(auto) traverse_get_single(int table_index, Keys&&... keys) const {
25514  constexpr static bool global = (meta::count_for_to_pack_v < 1, is_get_direct_tableless, meta::unqualified_t<Keys>... >> 0);
25516  int popcount = 0;
25517  detail::ref_clean c(base_t::lua_state(), popcount);
25518  return traverse_get_deep_optional<global, raw, detail::insert_mode::none, Ret>(popcount, table_index, std::forward<Keys>(keys)...);
25519  }
25520  else {
25521  detail::clean<sizeof...(Keys) - meta::count_for_pack_v<detail::is_insert_mode, meta::unqualified_t<Keys>...>> c(base_t::lua_state());
25522  return traverse_get_deep<global, raw, detail::insert_mode::none, Ret>(table_index, std::forward<Keys>(keys)...);
25523  }
25524  }
25525 
25526  template <bool raw, typename Pairs, std::size_t... I>
25527  void tuple_set(std::index_sequence<I...>, Pairs&& pairs) {
25528  constexpr static bool global = (meta::count_even_for_pack_v < is_set_direct_tableless,
25529  meta::unqualified_t<decltype(std::get<I * 2>(std::forward<Pairs>(pairs)))>... >> 0);
25530  auto pp = stack::push_pop<global>(*this);
25531  int table_index = pp.index_of(*this);
25532  lua_State* L = base_t::lua_state();
25533  (void)table_index;
25534  (void)L;
25535  void(detail::swallow { (stack::set_field<(top_level), raw>(
25536  L, std::get<I * 2>(std::forward<Pairs>(pairs)), std::get<I * 2 + 1>(std::forward<Pairs>(pairs)), table_index),
25537  0)... });
25538  }
25539 
25540  template <bool global, bool raw, detail::insert_mode mode, typename T, typename Key, typename... Keys>
25541  decltype(auto) traverse_get_deep(int table_index, Key&& key, Keys&&... keys) const {
25542  if constexpr (std::is_same_v<meta::unqualified_t<Key>, create_if_nil_t>) {
25543  (void)key;
25544  return traverse_get_deep<false, raw, static_cast<detail::insert_mode>(mode | detail::insert_mode::create_if_nil), T>(
25545  table_index, std::forward<Keys>(keys)...);
25546  }
25547  else {
25548  lua_State* L = base_t::lua_state();
25549  stack::get_field<global, raw>(L, std::forward<Key>(key), table_index);
25550  if constexpr (sizeof...(Keys) > 0) {
25552  type t = type_of(L, -1);
25553  if (t == type::lua_nil || t == type::none) {
25554  lua_pop(L, 1);
25555  stack::push(L, new_table(0, 0));
25556  }
25557  }
25558  return traverse_get_deep<false, raw, mode, T>(lua_gettop(L), std::forward<Keys>(keys)...);
25559  }
25560  else {
25562  type t = type_of(L, -1);
25563  if ((t == type::lua_nil || t == type::none) && (is_table_like_v<T>)) {
25564  lua_pop(L, 1);
25565  stack::push(L, new_table(0, 0));
25566  }
25567  }
25568  return stack::get<T>(L);
25569  }
25570  }
25571  }
25572 
25573  template <bool global, bool raw, detail::insert_mode mode, typename T, typename Key, typename... Keys>
25574  decltype(auto) traverse_get_deep_optional(int& popcount, int table_index, Key&& key, Keys&&... keys) const {
25575  if constexpr (std::is_same_v<meta::unqualified_t<Key>, create_if_nil_t>) {
25577  (void)key;
25578  return traverse_get_deep_optional<global, raw, new_mode, T>(popcount, table_index, std::forward<Keys>(keys)...);
25579  }
25580  else if constexpr (std::is_same_v<meta::unqualified_t<Key>, update_if_empty_t>) {
25582  (void)key;
25583  return traverse_get_deep_optional<global, raw, new_mode, T>(popcount, table_index, std::forward<Keys>(keys)...);
25584  }
25585  else if constexpr (std::is_same_v<meta::unqualified_t<Key>, override_value_t>) {
25587  (void)key;
25588  return traverse_get_deep_optional<global, raw, new_mode, T>(popcount, table_index, std::forward<Keys>(keys)...);
25589  }
25590  else {
25591  if constexpr (sizeof...(Keys) > 0) {
25592  lua_State* L = base_t::lua_state();
25593  auto p = stack::probe_get_field<global, raw>(L, std::forward<Key>(key), table_index);
25594  popcount += p.levels;
25595  if (!p.success) {
25597  lua_pop(L, 1);
25598  constexpr bool is_seq = meta::count_for_to_pack_v < 1, std::is_integral, Keys... >> 0;
25599  stack::push(L, new_table(static_cast<int>(is_seq), static_cast<int>(!is_seq)));
25600  stack::set_field<global, raw>(L, std::forward<Key>(key), stack_reference(L, -1), table_index);
25601  }
25602  else {
25603  return T(nullopt);
25604  }
25605  }
25606  return traverse_get_deep_optional<false, raw, mode, T>(popcount, lua_gettop(L), std::forward<Keys>(keys)...);
25607  }
25608  else {
25609  using R = decltype(stack::get<T>(nullptr));
25610  using value_type = typename meta::unqualified_t<R>::value_type;
25611  lua_State* L = base_t::lua_state();
25612  auto p = stack::probe_get_field<global, raw, value_type>(L, key, table_index);
25613  popcount += p.levels;
25614  if (!p.success) {
25616  lua_pop(L, 1);
25617  stack::push(L, new_table(0, 0));
25618  stack::set_field<global, raw>(L, std::forward<Key>(key), stack_reference(L, -1), table_index);
25619  if (stack::check<value_type>(L, lua_gettop(L), &no_panic)) {
25620  return stack::get<T>(L);
25621  }
25622  }
25623  return R(nullopt);
25624  }
25625  return stack::get<T>(L);
25626  }
25627  }
25628  }
25629 
25630  template <bool global, bool raw, detail::insert_mode mode, typename Key, typename... Keys>
25631  void traverse_set_deep(int table_index, Key&& key, Keys&&... keys) const {
25632  using KeyU = meta::unqualified_t<Key>;
25633  if constexpr (std::is_same_v<KeyU, update_if_empty_t>) {
25634  (void)key;
25635  traverse_set_deep<global, raw, static_cast<detail::insert_mode>(mode | detail::insert_mode::update_if_empty)>(
25636  table_index, std::forward<Keys>(keys)...);
25637  }
25638  else if constexpr (std::is_same_v<KeyU, create_if_nil_t>) {
25639  (void)key;
25640  traverse_set_deep<global, raw, static_cast<detail::insert_mode>(mode | detail::insert_mode::create_if_nil)>(
25641  table_index, std::forward<Keys>(keys)...);
25642  }
25643  else if constexpr (std::is_same_v<KeyU, override_value_t>) {
25644  (void)key;
25645  traverse_set_deep<global, raw, static_cast<detail::insert_mode>(mode | detail::insert_mode::override_value)>(
25646  table_index, std::forward<Keys>(keys)...);
25647  }
25648  else {
25649  lua_State* L = base_t::lua_state();
25650  if constexpr (sizeof...(Keys) == 1) {
25652  auto p = stack::probe_get_field<global, raw>(L, key, table_index);
25653  lua_pop(L, p.levels);
25654  if (!p.success) {
25655  stack::set_field<global, raw>(L, std::forward<Key>(key), std::forward<Keys>(keys)..., table_index);
25656  }
25657  }
25658  else {
25659  stack::set_field<global, raw>(L, std::forward<Key>(key), std::forward<Keys>(keys)..., table_index);
25660  }
25661  }
25662  else {
25663  if constexpr (mode != detail::insert_mode::none) {
25664  stack::get_field<global, raw>(L, key, table_index);
25665  type vt = type_of(L, -1);
25668  if (vt == type::lua_nil || vt == type::none) {
25669  constexpr bool is_seq = meta::count_for_to_pack_v < 1, std::is_integral, Keys... >> 0;
25670  lua_pop(L, 1);
25671  stack::push(L, new_table(static_cast<int>(is_seq), static_cast<int>(!is_seq)));
25672  stack::set_field<global, raw>(L, std::forward<Key>(key), stack_reference(L, -1), table_index);
25673  }
25674  }
25675  else {
25676  if (vt != type::table) {
25677  constexpr bool is_seq = meta::count_for_to_pack_v < 1, std::is_integral, Keys... >> 0;
25678  lua_pop(L, 1);
25679  stack::push(L, new_table(static_cast<int>(is_seq), static_cast<int>(!is_seq)));
25680  stack::set_field<global, raw>(L, std::forward<Key>(key), stack_reference(L, -1), table_index);
25681  }
25682  }
25683  }
25684  else {
25685  stack::get_field<global, raw>(L, std::forward<Key>(key), table_index);
25686  }
25687  traverse_set_deep<false, raw, mode>(lua_gettop(L), std::forward<Keys>(keys)...);
25688  }
25689  }
25690  }
25691 
25692  protected:
25694  }
25696  }
25698  }
25699  template <typename T,
25702  basic_table_core(detail::no_safety_tag, T&& r) noexcept : base_t(std::forward<T>(r)) {
25703  }
25704  template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
25705  basic_table_core(detail::no_safety_tag, lua_State* L, T&& r) noexcept : base_t(L, std::forward<T>(r)) {
25706  }
25707 
25708  public:
25711 
25712  using base_t::lua_state;
25713 
25714  basic_table_core() noexcept = default;
25717  basic_table_core& operator=(const basic_table_core&) = default;
25718  basic_table_core& operator=(basic_table_core&&) = default;
25719 
25720  basic_table_core(const stack_reference& r) : basic_table_core(r.lua_state(), r.stack_index()) {
25721  }
25722 
25723  basic_table_core(stack_reference&& r) : basic_table_core(r.lua_state(), r.stack_index()) {
25724  }
25725 
25726  template <typename T, meta::enable_any<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
25727  basic_table_core(lua_State* L, T&& r) : base_t(L, std::forward<T>(r)) {
25728 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
25729  auto pp = stack::push_pop(*this);
25730  int table_index = pp.index_of(*this);
25732  stack::check<basic_table_core>(lua_state(), table_index, handler);
25733 #endif // Safety
25734  }
25735 
25736  basic_table_core(lua_State* L, const new_table& nt) : base_t(L, -stack::push(L, nt)) {
25738  lua_pop(L, 1);
25739  }
25740  }
25741 
25743 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
25745  stack::check<basic_table_core>(L, index, handler);
25746 #endif // Safety
25747  }
25748 
25750 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
25751  auto pp = stack::push_pop(*this);
25752  int table_index = pp.index_of(*this);
25754  stack::check<basic_table_core>(lua_state(), table_index, handler);
25755 #endif // Safety
25756  }
25757 
25758  template <typename T,
25761  basic_table_core(T&& r) noexcept : basic_table_core(detail::no_safety, std::forward<T>(r)) {
25762 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
25763  if (!is_table<meta::unqualified_t<T>>::value) {
25764  auto pp = stack::push_pop(*this);
25765  int table_index = pp.index_of(*this);
25767  stack::check<basic_table_core>(lua_state(), table_index, handler);
25768  }
25769 #endif // Safety
25770  }
25771 
25773  }
25774 
25775  basic_table_core(lua_State* L, global_tag_t t) noexcept : base_t(L, t) {
25776  }
25777 
25778  iterator begin() const {
25779  if (this->get_type() == type::table) {
25780  return iterator(*this);
25781  }
25782  return iterator();
25783  }
25784 
25785  iterator end() const {
25786  return iterator();
25787  }
25788 
25790  return begin();
25791  }
25792 
25794  return end();
25795  }
25796 
25799  }
25800 
25803  }
25804 
25805  void clear() {
25806  auto pp = stack::push_pop<false>(*this);
25807  int table_index = pp.index_of(*this);
25808  stack::clear(lua_state(), table_index);
25809  }
25810 
25811  template <typename... Ret, typename... Keys>
25812  decltype(auto) get(Keys&&... keys) const {
25813  static_assert(sizeof...(Keys) == sizeof...(Ret), "number of keys and number of return types do not match");
25815  auto pp = stack::push_pop<global>(*this);
25816  int table_index = pp.index_of(*this);
25817  return tuple_get<false, Ret...>(table_index, std::forward<Keys>(keys)...);
25818  }
25819 
25820  template <typename T, typename Key>
25821  decltype(auto) get_or(Key&& key, T&& otherwise) const {
25822  typedef decltype(get<T>("")) U;
25823  optional<U> option = get<optional<U>>(std::forward<Key>(key));
25824  if (option) {
25825  return static_cast<U>(option.value());
25826  }
25827  return static_cast<U>(std::forward<T>(otherwise));
25828  }
25829 
25830  template <typename T, typename Key, typename D>
25831  decltype(auto) get_or(Key&& key, D&& otherwise) const {
25832  optional<T> option = get<optional<T>>(std::forward<Key>(key));
25833  if (option) {
25834  return static_cast<T>(option.value());
25835  }
25836  return static_cast<T>(std::forward<D>(otherwise));
25837  }
25838 
25839  template <typename T, typename... Keys>
25840  decltype(auto) traverse_get(Keys&&... keys) const {
25841  static_assert(sizeof...(Keys) > 0, "must pass at least 1 key to get");
25842  constexpr static bool global = (meta::count_for_to_pack_v < 1, is_get_direct_tableless, meta::unqualified_t<Keys>... >> 0);
25843  auto pp = stack::push_pop<global>(*this);
25844  int table_index = pp.index_of(*this);
25845  return traverse_get_single<false, T>(table_index, std::forward<Keys>(keys)...);
25846  }
25847 
25848  template <typename... Keys>
25849  basic_table_core& traverse_set(Keys&&... keys) {
25850  static_assert(sizeof...(Keys) > 1, "must pass at least 1 key and 1 value to set");
25851  constexpr static bool global
25852  = (meta::count_when_for_to_pack_v < detail::is_not_insert_mode, 1, is_set_direct_tableless, meta::unqualified_t<Keys>... >> 0);
25853  auto pp = stack::push_pop<global>(*this);
25854  int table_index = pp.index_of(*this);
25855  lua_State* L = base_t::lua_state();
25856  auto pn = stack::pop_n(L, static_cast<int>(sizeof...(Keys) - 2 - meta::count_for_pack_v<detail::is_insert_mode, meta::unqualified_t<Keys>...>));
25857  traverse_set_deep<top_level, false, detail::insert_mode::none>(table_index, std::forward<Keys>(keys)...);
25858  return *this;
25859  }
25860 
25861  template <typename... Args>
25862  basic_table_core& set(Args&&... args) {
25863  if constexpr (sizeof...(Args) == 2) {
25864  traverse_set(std::forward<Args>(args)...);
25865  }
25866  else {
25867  tuple_set<false>(std::make_index_sequence<sizeof...(Args) / 2>(), std::forward_as_tuple(std::forward<Args>(args)...));
25868  }
25869  return *this;
25870  }
25871 
25872  template <typename... Ret, typename... Keys>
25873  decltype(auto) raw_get(Keys&&... keys) const {
25874  static_assert(sizeof...(Keys) == sizeof...(Ret), "number of keys and number of return types do not match");
25875  constexpr static bool global = (meta::count_for_to_pack_v < 1, is_raw_get_direct_tableless, meta::unqualified_t<Keys>... >> 0);
25876  auto pp = stack::push_pop<global>(*this);
25877  int table_index = pp.index_of(*this);
25878  return tuple_get<true, Ret...>(table_index, std::forward<Keys>(keys)...);
25879  }
25880 
25881  template <typename T, typename Key>
25882  decltype(auto) raw_get_or(Key&& key, T&& otherwise) const {
25883  typedef decltype(raw_get<T>("")) U;
25884  optional<U> option = raw_get<optional<U>>(std::forward<Key>(key));
25885  if (option) {
25886  return static_cast<U>(option.value());
25887  }
25888  return static_cast<U>(std::forward<T>(otherwise));
25889  }
25890 
25891  template <typename T, typename Key, typename D>
25892  decltype(auto) raw_get_or(Key&& key, D&& otherwise) const {
25893  optional<T> option = raw_get<optional<T>>(std::forward<Key>(key));
25894  if (option) {
25895  return static_cast<T>(option.value());
25896  }
25897  return static_cast<T>(std::forward<D>(otherwise));
25898  }
25899 
25900  template <typename T, typename... Keys>
25901  decltype(auto) traverse_raw_get(Keys&&... keys) const {
25902  constexpr static bool global = (meta::count_for_to_pack_v < 1, is_raw_get_direct_tableless, meta::unqualified_t<Keys>... >> 0);
25903  auto pp = stack::push_pop<global>(*this);
25904  int table_index = pp.index_of(*this);
25905  return traverse_get_single<true, T>(table_index, std::forward<Keys>(keys)...);
25906  }
25907 
25908  template <typename... Keys>
25910  constexpr static bool global = (meta::count_for_to_pack_v < 1, is_raw_set_direct_tableless, meta::unqualified_t<Keys>... >> 0);
25911  auto pp = stack::push_pop<global>(*this);
25912  lua_State* L = base_t::lua_state();
25913  auto pn = stack::pop_n(L, static_cast<int>(sizeof...(Keys) - 2 - meta::count_for_pack_v<detail::is_insert_mode, meta::unqualified_t<Keys>...>));
25914  traverse_set_deep<top_level, true, false>(std::forward<Keys>(keys)...);
25915  return *this;
25916  }
25917 
25918  template <typename... Args>
25920  tuple_set<true>(std::make_index_sequence<sizeof...(Args) / 2>(), std::forward_as_tuple(std::forward<Args>(args)...));
25921  return *this;
25922  }
25923 
25924  template <typename Class, typename Key>
25925  usertype<Class> new_usertype(Key&& key);
25926 
25927  template <typename Class, typename Key, automagic_flags enrollment_flags>
25928  usertype<Class> new_usertype(Key&& key, constant_automagic_enrollments<enrollment_flags> enrollment);
25929 
25930  template <typename Class, typename Key>
25931  usertype<Class> new_usertype(Key&& key, automagic_enrollments enrollment);
25932 
25933  template <typename Class, typename Key, typename Arg, typename... Args,
25934  typename = std::enable_if_t<!std::is_base_of_v<automagic_enrollments, meta::unqualified_t<Arg>>>>
25935  usertype<Class> new_usertype(Key&& key, Arg&& arg, Args&&... args);
25936 
25937  template <bool read_only = true, typename... Args>
25938  table new_enum(const string_view& name, Args&&... args) {
25939  table target = create_with(std::forward<Args>(args)...);
25940  if constexpr (read_only) {
25941  // Need to create a special iterator to handle this
25942  table x
25944  table shim = create_named(name, metatable_key, x);
25945  return shim;
25946  }
25947  else {
25948  set(name, target);
25949  return target;
25950  }
25951  }
25952 
25953  template <typename T, bool read_only = true>
25954  table new_enum(const string_view& name, std::initializer_list<std::pair<string_view, T>> items) {
25955  table target = create(static_cast<int>(items.size()), static_cast<int>(0));
25956  for (const auto& kvp : items) {
25957  target.set(kvp.first, kvp.second);
25958  }
25959  if constexpr (read_only) {
25961  table shim = create_named(name, metatable_key, x);
25962  return shim;
25963  }
25964  else {
25965  set(name, target);
25966  return target;
25967  }
25968  }
25969 
25970  template <typename Key = object, typename Value = object, typename Fx>
25971  void for_each(Fx&& fx) const {
25972  lua_State* L = base_t::lua_state();
25973  if constexpr (std::is_invocable_v<Fx, Key, Value>) {
25974  auto pp = stack::push_pop(*this);
25975  int table_index = pp.index_of(*this);
25976  stack::push(L, lua_nil);
25977  while (lua_next(L, table_index)) {
25978  Key key(L, -2);
25979  Value value(L, -1);
25980  auto pn = stack::pop_n(L, 1);
25981  fx(key, value);
25982  }
25983  }
25984  else {
25985  auto pp = stack::push_pop(*this);
25986  int table_index = pp.index_of(*this);
25987  stack::push(L, lua_nil);
25988  while (lua_next(L, table_index)) {
25989  Key key(L, -2);
25990  Value value(L, -1);
25991  auto pn = stack::pop_n(L, 1);
25992  std::pair<Key&, Value&> keyvalue(key, value);
25993  fx(keyvalue);
25994  }
25995  }
25996  }
25997 
25998  size_t size() const {
25999  auto pp = stack::push_pop(*this);
26000  int table_index = pp.index_of(*this);
26001  lua_State* L = base_t::lua_state();
26002  lua_len(L, table_index);
26003  return stack::pop<size_t>(L);
26004  }
26005 
26006  bool empty() const {
26007  return cbegin() == cend();
26008  }
26009 
26010  template <typename T>
26011  auto operator[](T&& key) & {
26012  return table_proxy<basic_table_core&, detail::proxy_key_t<T>>(*this, std::forward<T>(key));
26013  }
26014 
26015  template <typename T>
26016  auto operator[](T&& key) const& {
26017  return table_proxy<const basic_table_core&, detail::proxy_key_t<T>>(*this, std::forward<T>(key));
26018  }
26019 
26020  template <typename T>
26021  auto operator[](T&& key) && {
26022  return table_proxy<basic_table_core, detail::proxy_key_t<T>>(std::move(*this), std::forward<T>(key));
26023  }
26024 
26025  template <typename Sig, typename Key, typename... Args>
26026  basic_table_core& set_function(Key&& key, Args&&... args) {
26027  set_fx(types<Sig>(), std::forward<Key>(key), std::forward<Args>(args)...);
26028  return *this;
26029  }
26030 
26031  template <typename Key, typename... Args>
26032  basic_table_core& set_function(Key&& key, Args&&... args) {
26033  set_fx(types<>(), std::forward<Key>(key), std::forward<Args>(args)...);
26034  return *this;
26035  }
26036 
26037  template <typename... Args>
26038  basic_table_core& add(Args&&... args) {
26039  auto pp = stack::push_pop(*this);
26040  int table_index = pp.index_of(*this);
26041  lua_State* L = base_t::lua_state();
26042  (void)detail::swallow { 0, (stack::stack_detail::raw_table_set(L, std::forward<Args>(args), table_index), 0)... };
26043  return *this;
26044  }
26045 
26046  private:
26047  template <typename R, typename... Args, typename Fx, typename Key, typename = std::invoke_result_t<Fx, Args...>>
26048  void set_fx(types<R(Args...)>, Key&& key, Fx&& fx) {
26049  set_resolved_function<R(Args...)>(std::forward<Key>(key), std::forward<Fx>(fx));
26050  }
26051 
26052  template <typename Fx, typename Key, meta::enable<meta::is_specialization_of<meta::unqualified_t<Fx>, overload_set>> = meta::enabler>
26053  void set_fx(types<>, Key&& key, Fx&& fx) {
26054  set(std::forward<Key>(key), std::forward<Fx>(fx));
26055  }
26056 
26057  template <typename Fx, typename Key, typename... Args,
26059  void set_fx(types<>, Key&& key, Fx&& fx, Args&&... args) {
26060  set(std::forward<Key>(key), as_function_reference(std::forward<Fx>(fx), std::forward<Args>(args)...));
26061  }
26062 
26063  template <typename... Sig, typename... Args, typename Key>
26064  void set_resolved_function(Key&& key, Args&&... args) {
26065  set(std::forward<Key>(key), as_function_reference<function_sig<Sig...>>(std::forward<Args>(args)...));
26066  }
26067 
26068  public:
26069  static inline table create(lua_State* L, int narr = 0, int nrec = 0) {
26070  lua_createtable(L, narr, nrec);
26071  table result(L);
26072  lua_pop(L, 1);
26073  return result;
26074  }
26075 
26076  template <typename Key, typename Value, typename... Args>
26077  static inline table create(lua_State* L, int narr, int nrec, Key&& key, Value&& value, Args&&... args) {
26078  lua_createtable(L, narr, nrec);
26079  table result(L);
26080  result.set(std::forward<Key>(key), std::forward<Value>(value), std::forward<Args>(args)...);
26081  lua_pop(L, 1);
26082  return result;
26083  }
26084 
26085  template <typename... Args>
26086  static inline table create_with(lua_State* L, Args&&... args) {
26087  static_assert(sizeof...(Args) % 2 == 0, "You must have an even number of arguments for a key, value ... list.");
26088  constexpr int narr = static_cast<int>(meta::count_odd_for_pack_v<std::is_integral, Args...>);
26089  return create(L, narr, static_cast<int>((sizeof...(Args) / 2) - narr), std::forward<Args>(args)...);
26090  }
26091 
26092  table create(int narr = 0, int nrec = 0) {
26093  return create(base_t::lua_state(), narr, nrec);
26094  }
26095 
26096  template <typename Key, typename Value, typename... Args>
26097  table create(int narr, int nrec, Key&& key, Value&& value, Args&&... args) {
26098  return create(base_t::lua_state(), narr, nrec, std::forward<Key>(key), std::forward<Value>(value), std::forward<Args>(args)...);
26099  }
26100 
26101  template <typename Name>
26102  table create(Name&& name, int narr = 0, int nrec = 0) {
26103  table x = create(base_t::lua_state(), narr, nrec);
26104  this->set(std::forward<Name>(name), x);
26105  return x;
26106  }
26107 
26108  template <typename Name, typename Key, typename Value, typename... Args>
26109  table create(Name&& name, int narr, int nrec, Key&& key, Value&& value, Args&&... args) {
26110  table x = create(base_t::lua_state(), narr, nrec, std::forward<Key>(key), std::forward<Value>(value), std::forward<Args>(args)...);
26111  this->set(std::forward<Name>(name), x);
26112  return x;
26113  }
26114 
26115  template <typename... Args>
26116  table create_with(Args&&... args) {
26117  return create_with(base_t::lua_state(), std::forward<Args>(args)...);
26118  }
26119 
26120  template <typename Name, typename... Args>
26121  table create_named(Name&& name, Args&&... args) {
26122  static const int narr = static_cast<int>(meta::count_even_for_pack_v<std::is_integral, Args...>);
26123  return create(std::forward<Name>(name), narr, (sizeof...(Args) / 2) - narr, std::forward<Args>(args)...);
26124  }
26125  };
26126 } // namespace sol
26127 
26128 // end of sol/table_core.hpp
26129 
26130 namespace sol {
26131 
26132  template <typename base_type>
26133  class basic_metatable : public basic_table<base_type> {
26135  friend class state;
26136  friend class state_view;
26137 
26138  protected:
26140  }
26142  }
26144  }
26145  template <typename T,
26148  basic_metatable(detail::no_safety_tag, T&& r) noexcept : base_t(std::forward<T>(r)) {
26149  }
26150  template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
26151  basic_metatable(detail::no_safety_tag, lua_State* L, T&& r) noexcept : base_t(L, std::forward<T>(r)) {
26152  }
26153 
26154  template <typename R, typename... Args, typename Fx, typename Key, typename = std::invoke_result_t<Fx, Args...>>
26155  void set_fx(types<R(Args...)>, Key&& key, Fx&& fx) {
26156  set_resolved_function<R(Args...)>(std::forward<Key>(key), std::forward<Fx>(fx));
26157  }
26158 
26159  template <typename Fx, typename Key, meta::enable<meta::is_specialization_of<meta::unqualified_t<Fx>, overload_set>> = meta::enabler>
26160  void set_fx(types<>, Key&& key, Fx&& fx) {
26161  set(std::forward<Key>(key), std::forward<Fx>(fx));
26162  }
26163 
26164  template <typename Fx, typename Key, typename... Args,
26166  void set_fx(types<>, Key&& key, Fx&& fx, Args&&... args) {
26167  set(std::forward<Key>(key), as_function_reference(std::forward<Fx>(fx), std::forward<Args>(args)...));
26168  }
26169 
26170  template <typename... Sig, typename... Args, typename Key>
26171  void set_resolved_function(Key&& key, Args&&... args) {
26172  set(std::forward<Key>(key), as_function_reference<function_sig<Sig...>>(std::forward<Args>(args)...));
26173  }
26174 
26175  public:
26176  using base_t::lua_state;
26177 
26178  basic_metatable() noexcept = default;
26181  basic_metatable& operator=(const basic_metatable&) = default;
26182  basic_metatable& operator=(basic_metatable&&) = default;
26183  basic_metatable(const stack_reference& r) : basic_metatable(r.lua_state(), r.stack_index()) {
26184  }
26185  basic_metatable(stack_reference&& r) : basic_metatable(r.lua_state(), r.stack_index()) {
26186  }
26187  template <typename T, meta::enable_any<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
26188  basic_metatable(lua_State* L, T&& r) : base_t(L, std::forward<T>(r)) {
26189 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
26190  auto pp = stack::push_pop(*this);
26192  stack::check<basic_metatable>(lua_state(), -1, handler);
26193 #endif // Safety
26194  }
26196 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
26198  stack::check<basic_metatable>(L, index, handler);
26199 #endif // Safety
26200  }
26202 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
26203  auto pp = stack::push_pop(*this);
26205  stack::check<basic_metatable>(lua_state(), -1, handler);
26206 #endif // Safety
26207  }
26208  template <typename T,
26211  basic_metatable(T&& r) noexcept : basic_metatable(detail::no_safety, std::forward<T>(r)) {
26212 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
26213  if (!is_table<meta::unqualified_t<T>>::value) {
26214  auto pp = stack::push_pop(*this);
26216  stack::check<basic_metatable>(base_t::lua_state(), -1, handler);
26217  }
26218 #endif // Safety
26219  }
26221  }
26222 
26223  template <typename Key, typename Value>
26224  basic_metatable<base_type>& set(Key&& key, Value&& value);
26225 
26226  template <typename Sig, typename Key, typename... Args>
26227  basic_metatable& set_function(Key&& key, Args&&... args) {
26228  set_fx(types<Sig>(), std::forward<Key>(key), std::forward<Args>(args)...);
26229  return *this;
26230  }
26231 
26232  template <typename Key, typename... Args>
26233  basic_metatable& set_function(Key&& key, Args&&... args) {
26234  set_fx(types<>(), std::forward<Key>(key), std::forward<Args>(args)...);
26235  return *this;
26236  }
26237 
26238  void unregister() {
26239  using ustorage_base = u_detail::usertype_storage_base;
26240 
26241  lua_State* L = this->lua_state();
26242 
26243  auto pp = stack::push_pop(*this);
26244  int top = lua_gettop(L);
26245 
26246  stack_reference mt(L, -1);
26248  if (type_of(L, -1) != type::table) {
26249  lua_settop(L, top);
26250  return;
26251  }
26252  stack_reference gc_names_table(L, -1);
26254  if (type_of(L, -1) != type::lightuserdata) {
26255  lua_settop(L, top);
26256  return;
26257  }
26258  ustorage_base& base_storage = *static_cast<ustorage_base*>(stack::get<void*>(L, -1));
26259  std::array<string_view, 6> registry_traits;
26260  for (std::size_t i = 0; i < registry_traits.size(); ++i) {
26262  stack::get_field<false, true>(L, smt, gc_names_table.stack_index());
26263  registry_traits[i] = stack::get<string_view>(L, -1);
26264  }
26265 
26266  // get the registry
26268  registry.push();
26269  // eliminate all named entries for this usertype
26270  // in the registry (luaL_newmetatable does
26271  // [name] = new table
26272  // in registry upon creation)
26273  for (std::size_t i = 0; i < registry_traits.size(); ++i) {
26275  const string_view& gcmetakey = registry_traits[i];
26277  // use .data() to make it treat it like a c string,
26278  // which it is...
26279  stack::set_field<true>(L, gcmetakey.data(), lua_nil);
26280  }
26281  else {
26282  // do not change the values in the registry: they need to be present
26283  // no matter what, for safety's sake
26284  // stack::set_field(L, gcmetakey, lua_nil, registry.stack_index());
26285  }
26286  }
26287 
26288  // destroy all storage and tables
26289  base_storage.clear();
26290 
26291  // 6 strings from gc_names table,
26292  // + 1 registry,
26293  // + 1 gc_names table
26294  // + 1 light userdata of storage
26295  // + 1 registry
26296  // 10 total, 4 left since popping off 6 gc_names tables
26297  lua_settop(L, top);
26298  }
26299  };
26300 
26301 } // namespace sol
26302 
26303 // end of sol/metatable.hpp
26304 
26305 namespace sol {
26306 
26307  template <typename T, typename base_type>
26308  class basic_usertype : private basic_metatable<base_type> {
26309  private:
26312 
26313  template <typename>
26314  friend class basic_metatable;
26315 
26316  template <bool, typename>
26317  friend class basic_table_core;
26318 
26319  template <std::size_t... I, typename... Args>
26320  void tuple_set(std::index_sequence<I...>, std::tuple<Args...>&& args) {
26321  (void)args;
26322  (void)detail::swallow { 0, (this->set(std::get<I * 2>(std::move(args)), std::get<I * 2 + 1>(std::move(args))), 0)... };
26323  }
26324 
26325  template <typename R, typename... Args, typename Fx, typename Key, typename = std::invoke_result_t<Fx, Args...>>
26326  void set_fx(types<R(Args...)>, Key&& key, Fx&& fx) {
26327  set_resolved_function<R(Args...)>(std::forward<Key>(key), std::forward<Fx>(fx));
26328  }
26329 
26330  template <typename Fx, typename Key, meta::enable<meta::is_specialization_of<meta::unqualified_t<Fx>, overload_set>> = meta::enabler>
26331  void set_fx(types<>, Key&& key, Fx&& fx) {
26332  set(std::forward<Key>(key), std::forward<Fx>(fx));
26333  }
26334 
26335  template <typename Fx, typename Key, typename... Args,
26337  void set_fx(types<>, Key&& key, Fx&& fx, Args&&... args) {
26338  set(std::forward<Key>(key), as_function_reference(std::forward<Fx>(fx), std::forward<Args>(args)...));
26339  }
26340 
26341  template <typename... Sig, typename... Args, typename Key>
26342  void set_resolved_function(Key&& key, Args&&... args) {
26343  set(std::forward<Key>(key), as_function_reference<function_sig<Sig...>>(std::forward<Args>(args)...));
26344  }
26345 
26346  public:
26347  using base_t::base_t;
26348 
26349  using base_t::get;
26350  using base_t::lua_state;
26351  using base_t::pop;
26352  using base_t::push;
26353  using base_t::traverse_get;
26354  using base_t::traverse_set;
26355  using base_t::unregister;
26356 
26357  template <typename Key, typename Value>
26358  basic_usertype& set(Key&& key, Value&& value) {
26359  optional<u_detail::usertype_storage<T>&> maybe_uts = u_detail::maybe_get_usertype_storage<T>(this->lua_state());
26360  if (maybe_uts) {
26361  u_detail::usertype_storage<T>& uts = *maybe_uts;
26362  uts.set(this->lua_state(), std::forward<Key>(key), std::forward<Value>(value));
26363  }
26364  else {
26365  using ValueU = meta::unqualified_t<Value>;
26366  // cannot get metatable: try regular table set?
26367  if constexpr (detail::is_non_factory_constructor_v<ValueU> || detail::is_policy_v<ValueU>) {
26368  // tag constructors so we don't get destroyed by lack of info
26369  table_base_t::set(std::forward<Key>(key), detail::tagged<T, Value>(std::forward<Value>(value)));
26370  }
26371  else {
26372  table_base_t::set(std::forward<Key>(key), std::forward<Value>(value));
26373  }
26374  }
26375  return *this;
26376  }
26377 
26378  template <typename Sig, typename Key, typename... Args>
26379  basic_usertype& set_function(Key&& key, Args&&... args) {
26380  set_fx(types<Sig>(), std::forward<Key>(key), std::forward<Args>(args)...);
26381  return *this;
26382  }
26383 
26384  template <typename Key, typename... Args>
26385  basic_usertype& set_function(Key&& key, Args&&... args) {
26386  set_fx(types<>(), std::forward<Key>(key), std::forward<Args>(args)...);
26387  return *this;
26388  }
26389 
26390  template <typename Key>
26392  return usertype_proxy<basic_usertype&, std::decay_t<Key>>(*this, std::forward<Key>(key));
26393  }
26394 
26395  template <typename Key>
26397  return usertype_proxy<const basic_usertype&, std::decay_t<Key>>(*this, std::forward<Key>(key));
26398  }
26399  };
26400 
26401 } // namespace sol
26402 
26403 // end of sol/usertype.hpp
26404 
26405 // beginning of sol/table.hpp
26406 
26407 // beginning of sol/lua_table.hpp
26408 
26409 namespace sol {
26410 
26411  template <typename ref_t>
26412  struct basic_lua_table : basic_table_core<false, ref_t> {
26413  private:
26415 
26416  friend class state;
26417  friend class state_view;
26418 
26419  public:
26420  using base_t::lua_state;
26421 
26422  basic_lua_table() noexcept = default;
26425  basic_lua_table& operator=(const basic_lua_table&) = default;
26426  basic_lua_table& operator=(basic_lua_table&&) = default;
26427  basic_lua_table(const stack_reference& r) : basic_lua_table(r.lua_state(), r.stack_index()) {
26428  }
26429  basic_lua_table(stack_reference&& r) : basic_lua_table(r.lua_state(), r.stack_index()) {
26430  }
26431  template <typename T, meta::enable_any<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
26432  basic_lua_table(lua_State* L, T&& r) : base_t(L, std::forward<T>(r)) {
26433 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
26434  auto pp = stack::push_pop(*this);
26436  stack::check<basic_lua_table>(lua_state(), -1, handler);
26437 #endif // Safety
26438  }
26439  basic_lua_table(lua_State* L, const new_table& nt) : base_t(L, nt) {
26441  lua_pop(L, 1);
26442  }
26443  }
26444  basic_lua_table(lua_State* L, int index = -1) : base_t(detail::no_safety, L, index) {
26445 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
26447  stack::check<basic_lua_table>(L, index, handler);
26448 #endif // Safety
26449  }
26451 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
26452  auto pp = stack::push_pop(*this);
26454  stack::check<basic_lua_table>(lua_state(), -1, handler);
26455 #endif // Safety
26456  }
26457  template <typename T,
26460  basic_lua_table(T&& r) noexcept : basic_lua_table(detail::no_safety, std::forward<T>(r)) {
26461 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
26462  if (!is_table<meta::unqualified_t<T>>::value) {
26463  auto pp = stack::push_pop(*this);
26465  stack::check<basic_lua_table>(lua_state(), -1, handler);
26466  }
26467 #endif // Safety
26468  }
26470  }
26471  };
26472 
26473 } // namespace sol
26474 
26475 // end of sol/lua_table.hpp
26476 
26477 namespace sol {
26478  typedef table_core<false> table;
26479 
26480  template <bool is_global, typename base_type>
26481  template <typename Class, typename Key>
26483  constant_automagic_enrollments<> enrollments {};
26484  return this->new_usertype<Class>(std::forward<Key>(key), std::move(enrollments));
26485  }
26486 
26487  template <bool is_global, typename base_type>
26488  template <typename Class, typename Key, automagic_flags enrollment_flags>
26490  int mt_index = u_detail::register_usertype<Class, enrollment_flags>(this->lua_state(), std::move(enrollments));
26491  usertype<Class> mt(this->lua_state(), -mt_index);
26492  lua_pop(this->lua_state(), 1);
26493  set(std::forward<Key>(key), mt);
26494  return mt;
26495  }
26496 
26497  template <bool is_global, typename base_type>
26498  template <typename Class, typename Key>
26500  int mt_index = u_detail::register_usertype<Class, automagic_flags::all>(this->lua_state(), std::move(enrollments));
26501  usertype<Class> mt(this->lua_state(), -mt_index);
26502  lua_pop(this->lua_state(), 1);
26503  set(std::forward<Key>(key), mt);
26504  return mt;
26505  }
26506 
26507  template <bool is_global, typename base_type>
26508  template <typename Class, typename Key, typename Arg, typename... Args, typename>
26510  constexpr automagic_flags enrollment_flags = meta::any_same_v<no_construction, meta::unqualified_t<Arg>, meta::unqualified_t<Args>...>
26514  enrollments.default_constructor = !detail::any_is_constructor_v<Arg, Args...>;
26515  enrollments.destructor = !detail::any_is_destructor_v<Arg, Args...>;
26516  usertype<Class> ut = this->new_usertype<Class>(std::forward<Key>(key), std::move(enrollments));
26517  static_assert(sizeof...(Args) % 2 == static_cast<std::size_t>(!detail::any_is_constructor_v<Arg>),
26518  "you must pass an even number of arguments to new_usertype after first passing a constructor");
26519  if constexpr (detail::any_is_constructor_v<Arg>) {
26520  ut.set(meta_function::construct, std::forward<Arg>(arg));
26521  ut.tuple_set(std::make_index_sequence<(sizeof...(Args)) / 2>(), std::forward_as_tuple(std::forward<Args>(args)...));
26522  }
26523  else {
26524  ut.tuple_set(std::make_index_sequence<(sizeof...(Args) + 1) / 2>(), std::forward_as_tuple(std::forward<Arg>(arg), std::forward<Args>(args)...));
26525  }
26526  return ut;
26527  }
26528 
26529  template <typename base_type>
26530  template <typename Key, typename Value>
26532  this->push();
26533  lua_State* L = this->lua_state();
26534  int target = lua_gettop(L);
26536  maybe_uts = u_detail::maybe_get_usertype_storage_base(L, target);
26537  if (maybe_uts) {
26538  u_detail::usertype_storage_base& uts = *maybe_uts;
26539  uts.set(L, std::forward<Key>(key), std::forward<Value>(value));
26540  return *this;
26541  }
26542  else {
26543  base_t::set(std::forward<Key>(key), std::forward<Value>(value));
26544  }
26545  this->pop();
26546  return *this;
26547  }
26548 
26549  namespace stack {
26550  template <>
26552  static metatable get(lua_State* L, int index = -1) {
26553  if (lua_getmetatable(L, index) == 0) {
26554  return metatable(L, ref_index(LUA_REFNIL));
26555  }
26556  return metatable(L, -1);
26557  }
26558  };
26559  } // namespace stack
26560 } // namespace sol
26561 
26562 // end of sol/table.hpp
26563 
26564 // beginning of sol/state.hpp
26565 
26566 // beginning of sol/state_view.hpp
26567 
26568 // beginning of sol/environment.hpp
26569 
26570 namespace sol {
26571 
26572  template <typename base_type>
26573  struct basic_environment : basic_table<base_type> {
26574  private:
26576 
26577  public:
26578  using base_t::lua_state;
26579 
26580  basic_environment() noexcept = default;
26583  basic_environment& operator=(const basic_environment&) = default;
26585  basic_environment(const stack_reference& r) : basic_environment(r.lua_state(), r.stack_index()) {
26586  }
26587  basic_environment(stack_reference&& r) : basic_environment(r.lua_state(), r.stack_index()) {
26588  }
26589 
26591  }
26592  template <bool b>
26594  stack_table mt(L, new_table(0, 1));
26595  mt.set(meta_function::index, fallback);
26596  this->set(metatable_key, mt);
26597  mt.pop();
26598  }
26599 
26600  basic_environment(env_key_t, const stack_reference& extraction_target)
26601  : base_t(detail::no_safety, extraction_target.lua_state(), (stack::push_environment_of(extraction_target), -1)) {
26602 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
26604  stack::check<env_key_t>(this->lua_state(), -1, handler);
26605 #endif // Safety
26606  lua_pop(this->lua_state(), 1);
26607  }
26608  template <bool b>
26610  : base_t(detail::no_safety, extraction_target.lua_state(), (stack::push_environment_of(extraction_target), -1)) {
26611 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
26613  stack::check<env_key_t>(this->lua_state(), -1, handler);
26614 #endif // Safety
26615  lua_pop(this->lua_state(), 1);
26616  }
26617  basic_environment(lua_State* L, int index = -1) : base_t(detail::no_safety, L, index) {
26618 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
26620  stack::check<basic_environment>(L, index, handler);
26621 #endif // Safety
26622  }
26624 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
26625  auto pp = stack::push_pop(*this);
26627  stack::check<basic_environment>(L, -1, handler);
26628 #endif // Safety
26629  }
26630  template <typename T,
26633  basic_environment(T&& r) noexcept : base_t(detail::no_safety, std::forward<T>(r)) {
26634 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
26635  if (!is_environment<meta::unqualified_t<T>>::value) {
26636  auto pp = stack::push_pop(*this);
26638  stack::check<basic_environment>(lua_state(), -1, handler);
26639  }
26640 #endif // Safety
26641  }
26643  }
26644 
26645  template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
26646  basic_environment(lua_State* L, T&& r) noexcept : base_t(detail::no_safety, L, std::forward<T>(r)) {
26647 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
26648  if (!is_environment<meta::unqualified_t<T>>::value) {
26649  auto pp = stack::push_pop(*this);
26651  stack::check<basic_environment>(lua_state(), -1, handler);
26652  }
26653 #endif // Safety
26654  }
26655 
26656  template <typename T>
26657  bool set_on(const T& target) const {
26658  lua_State* L = target.lua_state();
26659  auto pp = stack::push_pop(target);
26660  int target_index = pp.index_of(target);
26661 #if SOL_LUA_VERSION_I_ < 502
26662  // Use lua_setfenv
26663  this->push();
26664  int success_result = lua_setfenv(L, target_index);
26665  return success_result != 0;
26666 #else
26667  // If this is a C function, the environment is always placed in
26668  // the first value, as is expected of sol2 (all upvalues have an empty name, "")
26669  if (lua_iscfunction(L, target_index) != 0) {
26670  const char* maybe_upvalue_name = lua_getupvalue(L, target_index, 1);
26671  if (maybe_upvalue_name == nullptr) {
26672  return false;
26673  }
26674  string_view upvalue_name(maybe_upvalue_name);
26675  if (upvalue_name == "") {
26676  this->push();
26677  const char* success = lua_setupvalue(L, target_index, 1);
26678  if (success == nullptr) {
26679  // left things alone on the stack, pop them off
26680  lua_pop(L, 2);
26681  return false;
26682  }
26683  lua_pop(L, 1);
26684  return true;
26685  }
26686  lua_pop(L, 1);
26687  return false;
26688  }
26689  else {
26690  // Must search for the right upvalue target on index
26691  for (int upvalue_index = 1;; ++upvalue_index) {
26692  const char* maybe_upvalue_name = lua_getupvalue(L, target_index, upvalue_index);
26693  if (maybe_upvalue_name == nullptr) {
26694  break;
26695  }
26696  string_view upvalue_name(maybe_upvalue_name);
26697  if (upvalue_name == "_ENV") {
26698  lua_pop(L, 1);
26699  this->push();
26700  const char* success = lua_setupvalue(L, target_index, upvalue_index);
26701  if (success == nullptr) {
26702  // left things alone on the stack, pop them off
26703  lua_pop(L, 1);
26704  break;
26705  }
26706  // whether or not we succeeded, we found _ENV
26707  // so we need to break
26708  return true;
26709  }
26710  lua_pop(L, 1);
26711  }
26712  // if we get here,
26713  // we did not find an _ENV here...
26714  return false;
26715  }
26716 #endif
26717  }
26718  };
26719 
26720  template <typename T, typename E>
26721  bool set_environment(const basic_environment<E>& env, const T& target) {
26722  return env.set_on(target);
26723  }
26724 
26725  template <typename E = reference, typename T>
26727  lua_State* L = target.lua_state();
26728  auto pp = stack::pop_n(L, stack::push_environment_of(target));
26729  return basic_environment<E>(L, -1);
26730  }
26731 
26734 
26736  }
26738  }
26739  this_environment(const this_environment&) = default;
26740  this_environment(this_environment&&) = default;
26741  this_environment& operator=(const this_environment&) = default;
26742  this_environment& operator=(this_environment&&) = default;
26743 
26744  explicit operator bool() const {
26745  return static_cast<bool>(env);
26746  }
26747 
26749  return env;
26750  }
26751 
26752  operator const optional<environment>&() const {
26753  return env;
26754  }
26755 
26756  operator environment&() {
26757  return env.value();
26758  }
26759 
26760  operator const environment&() const {
26761  return env.value();
26762  }
26763  };
26764 
26765  namespace stack {
26766  template <>
26768  static environment get(lua_State* L, int index, record& tracking) {
26769  tracking.use(1);
26771  }
26772  };
26773 
26774  template <>
26776  static this_environment get(lua_State* L, int, record& tracking) {
26777  tracking.use(0);
26778  lua_Debug info;
26779  // Level 0 means current function (this C function, which may or may not be useful for us?)
26780  // Level 1 means next call frame up the stack. (Can be nothing if function called directly from C++ with lua_p/call)
26781  int pre_stack_size = lua_gettop(L);
26782  if (lua_getstack(L, 1, &info) != 1) {
26783  if (lua_getstack(L, 0, &info) != 1) {
26784  lua_settop(L, pre_stack_size);
26785  return this_environment();
26786  }
26787  }
26788  if (lua_getinfo(L, "f", &info) == 0) {
26789  lua_settop(L, pre_stack_size);
26790  return this_environment();
26791  }
26792 
26793  stack_reference f(L, -1);
26794  environment env(env_key, f);
26795  if (!env.valid()) {
26796  lua_settop(L, pre_stack_size);
26797  return this_environment();
26798  }
26799  return this_environment(std::move(env));
26800  }
26801  };
26802  } // namespace stack
26803 } // namespace sol
26804 
26805 // end of sol/environment.hpp
26806 
26807 // beginning of sol/load_result.hpp
26808 
26809 #include <cstdint>
26810 
26811 namespace sol {
26812  struct load_result : public proxy_base<load_result> {
26813  private:
26815  int index;
26819 
26820  public:
26821  load_result() noexcept : load_result(nullptr) {}
26822  load_result(lua_State* Ls, int stackindex = -1, int retnum = 0, int popnum = 0, load_status lerr = load_status::ok) noexcept
26823  : L(Ls), index(stackindex), returncount(retnum), popcount(popnum), err(lerr) {
26824  }
26825 
26826  // We do not want anyone to copy these around willy-nilly
26827  // Will likely break people, but also will probably get rid of quiet bugs that have
26828  // been lurking. (E.g., Vanilla Lua will just quietly discard over-pops and under-pops:
26829  // LuaJIT and other Lua engines will implode and segfault at random later times.)
26830  load_result(const load_result&) = delete;
26831  load_result& operator=(const load_result&) = delete;
26832 
26833  load_result(load_result&& o) noexcept : L(o.L), index(o.index), returncount(o.returncount), popcount(o.popcount), err(o.err) {
26834  // Must be manual, otherwise destructor will screw us
26835  // return count being 0 is enough to keep things clean
26836  // but we will be thorough
26837  o.L = nullptr;
26838  o.index = 0;
26839  o.returncount = 0;
26840  o.popcount = 0;
26841  o.err = load_status::syntax;
26842  }
26844  L = o.L;
26845  index = o.index;
26846  returncount = o.returncount;
26847  popcount = o.popcount;
26848  err = o.err;
26849  // Must be manual, otherwise destructor will screw us
26850  // return count being 0 is enough to keep things clean
26851  // but we will be thorough
26852  o.L = nullptr;
26853  o.index = 0;
26854  o.returncount = 0;
26855  o.popcount = 0;
26856  o.err = load_status::syntax;
26857  return *this;
26858  }
26859 
26860  load_status status() const noexcept {
26861  return err;
26862  }
26863 
26864  bool valid() const noexcept {
26865  return status() == load_status::ok;
26866  }
26867 
26868  template <typename T>
26869  T get() const {
26870  using UT = meta::unqualified_t<T>;
26871  if constexpr (meta::is_optional_v<UT>) {
26872  using ValueType = typename UT::value_type;
26873  if constexpr (std::is_same_v<ValueType, error>) {
26874  if (valid()) {
26875  return UT(nullopt);
26876  }
26877  return error(detail::direct_error, stack::get<std::string>(L, index));
26878  }
26879  else {
26880  if (!valid()) {
26881  return UT(nullopt);
26882  }
26883  return stack::get<UT>(L, index);
26884  }
26885  }
26886  else {
26887  if constexpr (std::is_same_v<T, error>) {
26888 #if SOL_IS_ON(SOL_SAFE_PROXIES)
26889  if (valid()) {
26890  type_panic_c_str(L, index, type_of(L, index), type::none, "expecting an error type (a string, from Lua)");
26891  }
26892 #endif // Check proxy type's safety
26893  return error(detail::direct_error, stack::get<std::string>(L, index));
26894  }
26895  else {
26896 #if SOL_IS_ON(SOL_SAFE_PROXIES)
26897  if (!valid()) {
26899  }
26900 #endif // Check proxy type's safety
26901  return stack::get<T>(L, index);
26902  }
26903  }
26904  }
26905 
26906  template <typename... Ret, typename... Args>
26907  decltype(auto) call(Args&&... args) {
26908  return get<protected_function>().template call<Ret...>(std::forward<Args>(args)...);
26909  }
26910 
26911  template <typename... Args>
26912  decltype(auto) operator()(Args&&... args) {
26913  return call<>(std::forward<Args>(args)...);
26914  }
26915 
26916  lua_State* lua_state() const noexcept {
26917  return L;
26918  };
26919  int stack_index() const noexcept {
26920  return index;
26921  };
26922 
26924  if (L != nullptr) {
26925  stack::remove(L, index, popcount);
26926  }
26927  }
26928  };
26929 } // namespace sol
26930 
26931 // end of sol/load_result.hpp
26932 
26933 // beginning of sol/state_handling.hpp
26934 
26935 // beginning of sol/lua_value.hpp
26936 
26937 namespace sol {
26938  struct lua_value {
26939  public:
26940  struct arr : detail::ebco<std::initializer_list<lua_value>> {
26941  private:
26943 
26944  public:
26945  using base_t::base_t;
26946  };
26947 
26948  private:
26949  template <typename T>
26951  = meta::any<meta::is_specialization_of<T, std::initializer_list>, std::is_same<T, reference>, std::is_same<T, arr>>;
26952 
26953  template <typename T>
26955 
26957 #if SOL_IS_ON(SOL_USE_THREAD_LOCAL)
26958  static thread_local lua_State* L = nullptr;
26959 #else
26960  static lua_State* L = nullptr;
26961 #endif
26962  return L;
26963  }
26964 
26966 
26967  public:
26968  static void set_lua_state(lua_State* L) {
26969  thread_local_lua_state() = L;
26970  }
26971 
26972  template <typename T, meta::disable<is_reference_or_lua_value_init_list<meta::unqualified_t<T>>> = meta::enabler>
26973  lua_value(lua_State* L_, T&& value) : lua_value(((set_lua_state(L_)), std::forward<T>(value))) {
26974  }
26975 
26976  template <typename T, meta::disable<is_lua_value_single_constructible<meta::unqualified_t<T>>> = meta::enabler>
26977  lua_value(T&& value) : ref_value(make_reference(thread_local_lua_state(), std::forward<T>(value))) {
26978  }
26979 
26980  lua_value(lua_State* L_, std::initializer_list<std::pair<lua_value, lua_value>> il)
26981  : lua_value([&L_, &il]() {
26982  set_lua_state(L_);
26983  return std::move(il);
26984  }()) {
26985  }
26986 
26987  lua_value(std::initializer_list<std::pair<lua_value, lua_value>> il) : ref_value(make_reference(thread_local_lua_state(), std::move(il))) {
26988  }
26989 
26991  : lua_value([&L_, &il]() {
26992  set_lua_state(L_);
26993  return std::move(il);
26994  }()) {
26995  }
26996 
26997  lua_value(arr il) : ref_value(make_reference(thread_local_lua_state(), std::move(il.value()))) {
26998  }
26999 
27001  : lua_value([&L_, &r]() {
27002  set_lua_state(L_);
27003  return std::move(r);
27004  }()) {
27005  }
27006 
27007  lua_value(reference r) : ref_value(std::move(r)) {
27008  }
27009 
27010  lua_value(const lua_value&) noexcept = default;
27011  lua_value(lua_value&&) = default;
27012  lua_value& operator=(const lua_value&) = default;
27013  lua_value& operator=(lua_value&&) = default;
27014 
27015  const reference& value() const& {
27016  return ref_value;
27017  }
27018 
27020  return ref_value;
27021  }
27022 
27023  reference&& value() && {
27024  return std::move(ref_value);
27025  }
27026 
27027  template <typename T>
27028  decltype(auto) as() const {
27029  ref_value.push();
27030  return stack::pop<T>(ref_value.lua_state());
27031  }
27032 
27033  template <typename T>
27034  bool is() const {
27035  int r = ref_value.registry_index();
27036  if (r == LUA_REFNIL)
27037  return meta::any_same<meta::unqualified_t<T>, lua_nil_t, nullopt_t, std::nullptr_t>::value ? true : false;
27038  if (r == LUA_NOREF)
27039  return false;
27040  auto pp = stack::push_pop(ref_value);
27041  return stack::check<T>(ref_value.lua_state(), -1, &no_panic);
27042  }
27043  };
27044 
27045  using array_value = typename lua_value::arr;
27046 
27047  namespace stack {
27048  template <>
27050  static int push(lua_State* L, const lua_value& lv) {
27051  return stack::push(L, lv.value());
27052  }
27053 
27054  static int push(lua_State* L, lua_value&& lv) {
27055  return stack::push(L, std::move(lv).value());
27056  }
27057  };
27058 
27059  template <>
27061  static lua_value get(lua_State* L, int index, record& tracking) {
27062  return lua_value(L, stack::get<reference>(L, index, tracking));
27063  }
27064  };
27065  } // namespace stack
27066 } // namespace sol
27067 
27068 // end of sol/lua_value.hpp
27069 
27070 #if SOL_IS_ON(SOL_PRINT_ERRORS)
27071 #include <iostream>
27072 #endif
27073 
27074 namespace sol {
27076 #if SOL_LUA_VERSION_I_ < 502
27077  if (L == nullptr) {
27078  lua_pushnil(L);
27080  return;
27081  }
27082  lua_pushthread(L);
27084 #else
27085  (void)L;
27086 #endif
27087  }
27088 
27089  inline int default_at_panic(lua_State* L) {
27090 #if SOL_IS_OFF(SOL_EXCEPTIONS)
27091  (void)L;
27092  return -1;
27093 #else
27094  size_t messagesize;
27095  const char* message = lua_tolstring(L, -1, &messagesize);
27096  if (message) {
27097  std::string err(message, messagesize);
27098  lua_settop(L, 0);
27099 #if SOL_IS_ON(SOL_PRINT_ERRORS)
27100  std::cerr << "[sol2] An error occurred and panic has been invoked: ";
27101  std::cerr << err;
27102  std::cerr << std::endl;
27103 #endif
27104  throw error(err);
27105  }
27106  lua_settop(L, 0);
27107  throw error(std::string("An unexpected error occurred and panic has been invoked"));
27108 #endif // Printing Errors
27109  }
27110 
27112  std::string msg = "An unknown error has triggered the default error handler";
27113  optional<string_view> maybetopmsg = stack::unqualified_check_get<string_view>(L, 1, &no_panic);
27114  if (maybetopmsg) {
27115  const string_view& topmsg = maybetopmsg.value();
27116  msg.assign(topmsg.data(), topmsg.size());
27117  }
27118  luaL_traceback(L, L, msg.c_str(), 1);
27119  optional<string_view> maybetraceback = stack::unqualified_check_get<string_view>(L, -1, &no_panic);
27120  if (maybetraceback) {
27121  const string_view& traceback = maybetraceback.value();
27122  msg.assign(traceback.data(), traceback.size());
27123  }
27124 #if SOL_IS_ON(SOL_PRINT_ERRORS)
27125  // std::cerr << "[sol2] An error occurred and was caught in traceback: ";
27126  // std::cerr << msg;
27127  // std::cerr << std::endl;
27128 #endif // Printing
27129  return stack::push(L, msg);
27130  }
27131 
27132  inline void set_default_state(lua_State* L, lua_CFunction panic_function = &default_at_panic,
27135  lua_atpanic(L, panic_function);
27136  protected_function::set_default_handler(object(L, in_place, traceback_function));
27141  }
27142 
27144  std::size_t kb = static_cast<std::size_t>(lua_gc(L, LUA_GCCOUNT, 0));
27145  kb *= 1024;
27146  kb += static_cast<std::size_t>(lua_gc(L, LUA_GCCOUNTB, 0));
27147  return kb;
27148  }
27149 
27151  return result;
27152  }
27153 
27155  type t = type_of(L, result.stack_index());
27156  std::string err = "sol: ";
27157  err += to_string(result.status());
27158  err += " error";
27159 #if SOL_IS_ON(SOL_EXCEPTIONS)
27160  std::exception_ptr eptr = std::current_exception();
27161  if (eptr) {
27162  err += " with a ";
27163  try {
27164  std::rethrow_exception(eptr);
27165  }
27166  catch (const std::exception& ex) {
27167  err += "std::exception -- ";
27168  err.append(ex.what());
27169  }
27170  catch (const std::string& message) {
27171  err += "thrown message -- ";
27172  err.append(message);
27173  }
27174  catch (const char* message) {
27175  err += "thrown message -- ";
27176  err.append(message);
27177  }
27178  catch (...) {
27179  err.append("thrown but unknown type, cannot serialize into error message");
27180  }
27181  }
27182 #endif // serialize exception information if possible
27183  if (t == type::string) {
27184  err += ": ";
27185  string_view serr = stack::unqualified_get<string_view>(L, result.stack_index());
27186  err.append(serr.data(), serr.size());
27187  }
27188 #if SOL_IS_ON(SOL_PRINT_ERRORS)
27189  std::cerr << "[sol2] An error occurred and has been passed to an error handler: ";
27190  std::cerr << err;
27191  std::cerr << std::endl;
27192 #endif
27193  // replacing information of stack error into pfr
27194  int target = result.stack_index();
27195  if (result.pop_count() > 0) {
27196  stack::remove(L, target, result.pop_count());
27197  }
27198  stack::push(L, err);
27199  int top = lua_gettop(L);
27200  int towards = top - target;
27201  if (towards != 0) {
27202  lua_rotate(L, top, towards);
27203  }
27204 #if SOL_IS_OFF(SOL_EXCEPTIONS)
27205  return result;
27206 #else
27207  // just throw our error
27208  throw error(detail::direct_error, err);
27209 #endif // If exceptions are allowed
27210  }
27211 
27213 #if SOL_IS_ON(SOL_DEFAULT_PASS_ON_ERROR)
27214  return script_pass_on_error(L, std::move(pfr));
27215 #else
27216  return script_throw_on_error(L, std::move(pfr));
27217 #endif
27218  }
27219 
27220  namespace stack {
27223  sol::error err = stack::get<sol::error>(L, -p);
27224  lua_pop(L, p);
27225  return err;
27226  }
27227  } // namespace stack
27228 } // namespace sol
27229 
27230 // end of sol/state_handling.hpp
27231 
27232 #include <memory>
27233 #include <cstddef>
27234 
27235 namespace sol {
27236 
27237  class state_view {
27238  private:
27242 
27243  optional<object> is_loaded_package(const std::string& key) {
27244  auto loaded = reg.traverse_get<optional<object>>("_LOADED", key);
27245  bool is53mod = loaded && !(loaded->is<bool>() && !loaded->as<bool>());
27246  if (is53mod)
27247  return loaded;
27248 #if SOL_LUA_VERSION_I_ <= 501
27249  auto loaded51 = global.traverse_get<optional<object>>("package", "loaded", key);
27250  bool is51mod = loaded51 && !(loaded51->is<bool>() && !loaded51->as<bool>());
27251  if (is51mod)
27252  return loaded51;
27253 #endif
27254  return nullopt;
27255  }
27256 
27257  template <typename T>
27258  void ensure_package(const std::string& key, T&& sr) {
27259 #if SOL_LUA_VERSION_I_ <= 501
27260  auto pkg = global["package"];
27261  if (!pkg.valid()) {
27262  pkg = create_table_with("loaded", create_table_with(key, sr));
27263  }
27264  else {
27265  auto ld = pkg["loaded"];
27266  if (!ld.valid()) {
27267  ld = create_table_with(key, sr);
27268  }
27269  else {
27270  ld[key] = sr;
27271  }
27272  }
27273 #endif
27274  auto loaded = reg["_LOADED"];
27275  if (!loaded.valid()) {
27276  loaded = create_table_with(key, sr);
27277  }
27278  else {
27279  loaded[key] = sr;
27280  }
27281  }
27282 
27283  template <typename Fx>
27284  object require_core(const std::string& key, Fx&& action, bool create_global = true) {
27285  optional<object> loaded = is_loaded_package(key);
27286  if (loaded && loaded->valid())
27287  return std::move(*loaded);
27288  int before = lua_gettop(L);
27289  action();
27290  int after = lua_gettop(L);
27291  if (before == after) {
27292  // I mean, you were supposed to return
27293  // something, ANYTHING, from your requires script. I guess I'll just
27294  // but some trash in here, it's on you after that?
27295  ensure_package(key, static_cast<void*>(L));
27296  return object(L, lua_nil);
27297  }
27298  stack_reference sr(L, -1);
27299  if (create_global)
27300  set(key, sr);
27301  ensure_package(key, sr);
27302  return stack::pop<object>(L);
27303  }
27304 
27305  public:
27308 
27309  state_view(lua_State* Ls) : L(Ls), reg(Ls, LUA_REGISTRYINDEX), global(Ls, global_tag) {
27310  }
27311 
27313  }
27314 
27316  return L;
27317  }
27318 
27319  template <typename... Args>
27320  void open_libraries(Args&&... args) {
27321  static_assert(meta::all_same<lib, meta::unqualified_t<Args>...>::value, "all types must be libraries");
27322  if constexpr (sizeof...(args) == 0) {
27323  luaL_openlibs(L);
27324  return;
27325  }
27326  else {
27327  lib libraries[1 + sizeof...(args)] = { lib::count, std::forward<Args>(args)... };
27328 
27329  for (auto&& library : libraries) {
27330  switch (library) {
27331 #if SOL_LUA_VERSION_I_ <= 501 && SOL_IS_ON(SOL_USE_LUAJIT)
27332  case lib::coroutine:
27333 #endif // luajit opens coroutine base stuff
27334  case lib::base:
27335  luaL_requiref(L, "base", luaopen_base, 1);
27336  lua_pop(L, 1);
27337  break;
27338  case lib::package:
27339  luaL_requiref(L, "package", luaopen_package, 1);
27340  lua_pop(L, 1);
27341  break;
27342 #if SOL_IS_OFF(SOL_USE_LUAJIT)
27343  case lib::coroutine:
27344 #if SOL_LUA_VERSION_I_ > 501
27345  luaL_requiref(L, "coroutine", luaopen_coroutine, 1);
27346  lua_pop(L, 1);
27347 #endif // Lua 5.2+ only
27348  break;
27349 #endif // Not LuaJIT - comes builtin
27350  case lib::string:
27351  luaL_requiref(L, "string", luaopen_string, 1);
27352  lua_pop(L, 1);
27353  break;
27354  case lib::table:
27355  luaL_requiref(L, "table", luaopen_table, 1);
27356  lua_pop(L, 1);
27357  break;
27358  case lib::math:
27359  luaL_requiref(L, "math", luaopen_math, 1);
27360  lua_pop(L, 1);
27361  break;
27362  case lib::bit32:
27363 #if SOL_IS_ON(SOL_USE_LUAJIT)
27364  luaL_requiref(L, "bit32", luaopen_bit, 1);
27365  lua_pop(L, 1);
27366 #elif SOL_IS_ON(SOL_LUA_BIT32_LIB)
27367  luaL_requiref(L, "bit32", luaopen_bit32, 1);
27368  lua_pop(L, 1);
27369 #else
27370 #endif
27371  break;
27372  case lib::io:
27373  luaL_requiref(L, "io", luaopen_io, 1);
27374  lua_pop(L, 1);
27375  break;
27376  case lib::os:
27377  luaL_requiref(L, "os", luaopen_os, 1);
27378  lua_pop(L, 1);
27379  break;
27380  case lib::debug:
27381  luaL_requiref(L, "debug", luaopen_debug, 1);
27382  lua_pop(L, 1);
27383  break;
27384  case lib::utf8:
27385 #if SOL_LUA_VERSION_I_ > 502 && SOL_IS_OFF(SOL_USE_LUAJIT)
27386  luaL_requiref(L, "utf8", luaopen_utf8, 1);
27387  lua_pop(L, 1);
27388 #endif // Lua 5.3+ only
27389  break;
27390  case lib::ffi:
27391 #if SOL_IS_ON(SOL_USE_LUAJIT) && SOL_IS_OFF(SOL_LUAJIT_FFI_DISABLED)
27392  luaL_requiref(L, "ffi", luaopen_ffi, 1);
27393  lua_pop(L, 1);
27394 #endif // LuaJIT only
27395  break;
27396  case lib::jit:
27397 #if SOL_IS_ON(SOL_USE_LUAJIT)
27398  luaL_requiref(L, "jit", luaopen_jit, 0);
27399  lua_pop(L, 1);
27400 #endif // LuaJIT Only
27401  break;
27402  case lib::count:
27403  default:
27404  break;
27405  }
27406  }
27407  }
27408  }
27409 
27410  object require(const std::string& key, lua_CFunction open_function, bool create_global = true) {
27411  luaL_requiref(L, key.c_str(), open_function, create_global ? 1 : 0);
27412  return stack::pop<object>(L);
27413  }
27414 
27415  object require_script(const std::string& key, const string_view& code, bool create_global = true,
27416  const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27417  auto action = [this, &code, &chunkname, &mode]() { stack::script(L, code, chunkname, mode); };
27418  return require_core(key, action, create_global);
27419  }
27420 
27421  object require_file(const std::string& key, const std::string& filename, bool create_global = true, load_mode mode = load_mode::any) {
27422  auto action = [this, &filename, &mode]() { stack::script_file(L, filename, mode); };
27423  return require_core(key, action, create_global);
27424  }
27425 
27427  optional<table> maybe_package = this->global["package"];
27428  if (!maybe_package) {
27429  // package lib wasn't opened
27430  // open package lib
27431  return;
27432  }
27433  table& package = *maybe_package;
27434  // yay for version differences...
27435  // one day Lua 5.1 will die a peaceful death
27436  // and its old bones will find blissful rest
27437  auto loaders_proxy = package
27438 #if SOL_LUA_VERSION_I_ < 502
27439  ["loaders"]
27440 #else
27441  ["searchers"]
27442 #endif
27443  ;
27444  if (!loaders_proxy.valid()) {
27445  // nothing to clear
27446  return;
27447  }
27448  // we need to create the table for loaders
27449  // table does not exist, so create and move forward
27450  loaders_proxy = new_table(1, 0);
27451  }
27452 
27453  template <typename Fx>
27454  void add_package_loader(Fx&& fx, bool clear_all_package_loaders = false) {
27455  optional<table> maybe_package = this->global["package"];
27456  if (!maybe_package) {
27457  // package lib wasn't opened
27458  // open package lib
27459  return;
27460  }
27461  table& package = *maybe_package;
27462  // yay for version differences...
27463  // one day Lua 5.1 will die a peaceful death
27464  // and its old bones will find blissful rest
27465  auto loaders_proxy = package
27466 #if SOL_LUA_VERSION_I_ < 502
27467  ["loaders"]
27468 #else
27469  ["searchers"]
27470 #endif
27471  ;
27472  bool make_new_table = clear_all_package_loaders || !loaders_proxy.valid();
27473  if (make_new_table) {
27474  // we need to create the table for loaders
27475  // table does not exist, so create and move forward
27476  loaders_proxy = new_table(1, 0);
27477  }
27478  optional<table> maybe_loaders = loaders_proxy;
27479  if (!maybe_loaders) {
27480  // loaders/searches
27481  // thing exists in package, but it
27482  // ain't a table or a table-alike...!
27483  return;
27484  }
27485  table loaders = loaders_proxy;
27486  loaders.add(std::forward<Fx>(fx));
27487  }
27488 
27489  template <typename E>
27491  const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27492  detail::typical_chunk_name_t basechunkname = {};
27493  const char* chunknametarget = detail::make_chunk_name("lua_Reader", chunkname, basechunkname);
27494  load_status x = static_cast<load_status>(lua_load(L, reader, data, chunknametarget, to_string(mode).c_str()));
27495  if (x != load_status::ok) {
27496  return protected_function_result(L, absolute_index(L, -1), 0, 1, static_cast<call_status>(x));
27497  }
27499  set_environment(env, pf);
27500  return pf();
27501  }
27502 
27504  lua_Reader reader, void* data, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27505  detail::typical_chunk_name_t basechunkname = {};
27506  const char* chunknametarget = detail::make_chunk_name("lua_Reader", chunkname, basechunkname);
27507  load_status x = static_cast<load_status>(lua_load(L, reader, data, chunknametarget, to_string(mode).c_str()));
27508  if (x != load_status::ok) {
27509  return protected_function_result(L, absolute_index(L, -1), 0, 1, static_cast<call_status>(x));
27510  }
27512  return pf();
27513  }
27514 
27515  template <typename E>
27517  const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27518  detail::typical_chunk_name_t basechunkname = {};
27519  const char* chunknametarget = detail::make_chunk_name(code, chunkname, basechunkname);
27520  load_status x = static_cast<load_status>(luaL_loadbufferx(L, code.data(), code.size(), chunknametarget, to_string(mode).c_str()));
27521  if (x != load_status::ok) {
27522  return protected_function_result(L, absolute_index(L, -1), 0, 1, static_cast<call_status>(x));
27523  }
27525  set_environment(env, pf);
27526  return pf();
27527  }
27528 
27530  const string_view& code, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27531  detail::typical_chunk_name_t basechunkname = {};
27532  const char* chunknametarget = detail::make_chunk_name(code, chunkname, basechunkname);
27533  load_status x = static_cast<load_status>(luaL_loadbufferx(L, code.data(), code.size(), chunknametarget, to_string(mode).c_str()));
27534  if (x != load_status::ok) {
27535  return protected_function_result(L, absolute_index(L, -1), 0, 1, static_cast<call_status>(x));
27536  }
27538  return pf();
27539  }
27540 
27541  template <typename E>
27542  protected_function_result do_file(const std::string& filename, const basic_environment<E>& env, load_mode mode = load_mode::any) {
27543  load_status x = static_cast<load_status>(luaL_loadfilex(L, filename.c_str(), to_string(mode).c_str()));
27544  if (x != load_status::ok) {
27545  return protected_function_result(L, absolute_index(L, -1), 0, 1, static_cast<call_status>(x));
27546  }
27548  set_environment(env, pf);
27549  return pf();
27550  }
27551 
27552  protected_function_result do_file(const std::string& filename, load_mode mode = load_mode::any) {
27553  load_status x = static_cast<load_status>(luaL_loadfilex(L, filename.c_str(), to_string(mode).c_str()));
27554  if (x != load_status::ok) {
27555  return protected_function_result(L, absolute_index(L, -1), 0, 1, static_cast<call_status>(x));
27556  }
27558  return pf();
27559  }
27560 
27561  template <typename Fx,
27565  lua_Reader reader, void* data, Fx&& on_error, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27566  protected_function_result pfr = do_reader(reader, data, chunkname, mode);
27567  if (!pfr.valid()) {
27568  return on_error(L, std::move(pfr));
27569  }
27570  return pfr;
27571  }
27572 
27574  lua_Reader reader, void* data, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27575  return safe_script(reader, data, script_default_on_error, chunkname, mode);
27576  }
27577 
27578  template <typename Fx,
27582  const string_view& code, Fx&& on_error, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27583  protected_function_result pfr = do_string(code, chunkname, mode);
27584  if (!pfr.valid()) {
27585  return on_error(L, std::move(pfr));
27586  }
27587  return pfr;
27588  }
27589 
27590  template <typename Fx, typename E>
27592  const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27593  protected_function_result pfr = do_string(code, env, chunkname, mode);
27594  if (!pfr.valid()) {
27595  return on_error(L, std::move(pfr));
27596  }
27597  return pfr;
27598  }
27599 
27600  template <typename E>
27602  const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27603  return safe_script(code, env, script_default_on_error, chunkname, mode);
27604  }
27605 
27607  const string_view& code, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27608  return safe_script(code, script_default_on_error, chunkname, mode);
27609  }
27610 
27611  template <typename Fx,
27614  protected_function_result safe_script_file(const std::string& filename, Fx&& on_error, load_mode mode = load_mode::any) {
27615  protected_function_result pfr = do_file(filename, mode);
27616  if (!pfr.valid()) {
27617  return on_error(L, std::move(pfr));
27618  }
27619  return pfr;
27620  }
27621 
27622  template <typename Fx, typename E>
27624  const std::string& filename, const basic_environment<E>& env, Fx&& on_error, load_mode mode = load_mode::any) {
27625  protected_function_result pfr = do_file(filename, env, mode);
27626  if (!pfr.valid()) {
27627  return on_error(L, std::move(pfr));
27628  }
27629  return pfr;
27630  }
27631 
27632  template <typename E>
27634  return safe_script_file(filename, env, script_default_on_error, mode);
27635  }
27636 
27638  return safe_script_file(filename, script_default_on_error, mode);
27639  }
27640 
27641  template <typename E>
27643  const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27644  detail::typical_chunk_name_t basechunkname = {};
27645  const char* chunknametarget = detail::make_chunk_name("lua_Reader", chunkname, basechunkname);
27646  int index = lua_gettop(L);
27647  if (lua_load(L, reader, data, chunknametarget, to_string(mode).c_str())) {
27648  lua_error(L);
27649  }
27651  if (lua_pcall(L, 0, LUA_MULTRET, 0)) {
27652  lua_error(L);
27653  }
27654  int postindex = lua_gettop(L);
27655  int returns = postindex - index;
27656  return unsafe_function_result(L, (std::max)(postindex - (returns - 1), 1), returns);
27657  }
27658 
27660  lua_Reader reader, void* data, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27661  int index = lua_gettop(L);
27662  stack::script(L, reader, data, chunkname, mode);
27663  int postindex = lua_gettop(L);
27664  int returns = postindex - index;
27665  return unsafe_function_result(L, (std::max)(postindex - (returns - 1), 1), returns);
27666  }
27667 
27668  template <typename E>
27670  const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27671  detail::typical_chunk_name_t basechunkname = {};
27672  const char* chunknametarget = detail::make_chunk_name(code, chunkname, basechunkname);
27673  int index = lua_gettop(L);
27674  if (luaL_loadbufferx(L, code.data(), code.size(), chunknametarget, to_string(mode).c_str())) {
27675  lua_error(L);
27676  }
27678  if (lua_pcall(L, 0, LUA_MULTRET, 0)) {
27679  lua_error(L);
27680  }
27681  int postindex = lua_gettop(L);
27682  int returns = postindex - index;
27683  return unsafe_function_result(L, (std::max)(postindex - (returns - 1), 1), returns);
27684  }
27685 
27687  const string_view& code, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27688  int index = lua_gettop(L);
27689  stack::script(L, code, chunkname, mode);
27690  int postindex = lua_gettop(L);
27691  int returns = postindex - index;
27692  return unsafe_function_result(L, (std::max)(postindex - (returns - 1), 1), returns);
27693  }
27694 
27695  template <typename E>
27697  int index = lua_gettop(L);
27698  if (luaL_loadfilex(L, filename.c_str(), to_string(mode).c_str())) {
27699  lua_error(L);
27700  }
27702  if (lua_pcall(L, 0, LUA_MULTRET, 0)) {
27703  lua_error(L);
27704  }
27705  int postindex = lua_gettop(L);
27706  int returns = postindex - index;
27707  return unsafe_function_result(L, (std::max)(postindex - (returns - 1), 1), returns);
27708  }
27709 
27711  int index = lua_gettop(L);
27712  stack::script_file(L, filename, mode);
27713  int postindex = lua_gettop(L);
27714  int returns = postindex - index;
27715  return unsafe_function_result(L, (std::max)(postindex - (returns - 1), 1), returns);
27716  }
27717 
27718  template <typename Fx,
27722  const string_view& code, Fx&& on_error, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27723  return safe_script(code, std::forward<Fx>(on_error), chunkname, mode);
27724  }
27725 
27726  template <typename Fx,
27729  protected_function_result script_file(const std::string& filename, Fx&& on_error, load_mode mode = load_mode::any) {
27730  return safe_script_file(filename, std::forward<Fx>(on_error), mode);
27731  }
27732 
27733  template <typename Fx, typename E>
27734  protected_function_result script(const string_view& code, const basic_environment<E>& env, Fx&& on_error,
27735  const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27736  return safe_script(code, env, std::forward<Fx>(on_error), chunkname, mode);
27737  }
27738 
27739  template <typename Fx, typename E>
27740  protected_function_result script_file(const std::string& filename, const basic_environment<E>& env, Fx&& on_error, load_mode mode = load_mode::any) {
27741  return safe_script_file(filename, env, std::forward<Fx>(on_error), mode);
27742  }
27743 
27745  const string_view& code, const environment& env, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27746  return safe_script(code, env, script_default_on_error, chunkname, mode);
27747  }
27748 
27749  protected_function_result script_file(const std::string& filename, const environment& env, load_mode mode = load_mode::any) {
27750  return safe_script_file(filename, env, script_default_on_error, mode);
27751  }
27752 
27753 #if SOL_IS_ON(SOL_SAFE_FUNCTION_OBJECTS)
27755  lua_Reader reader, void* data, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27756  return safe_script(reader, data, chunkname, mode);
27757  }
27758 
27759  protected_function_result script(
27760  const string_view& code, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27761  return safe_script(code, chunkname, mode);
27762  }
27763 
27764  protected_function_result script_file(const std::string& filename, load_mode mode = load_mode::any) {
27765  return safe_script_file(filename, mode);
27766  }
27767 #else
27768  unsafe_function_result script(const string_view& code, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27769  return unsafe_script(code, chunkname, mode);
27770  }
27771 
27772  unsafe_function_result script_file(const std::string& filename, load_mode mode = load_mode::any) {
27773  return unsafe_script_file(filename, mode);
27774  }
27775 #endif
27776  load_result load(const string_view& code, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27777  detail::typical_chunk_name_t basechunkname = {};
27778  const char* chunknametarget = detail::make_chunk_name(code, chunkname, basechunkname);
27779  load_status x = static_cast<load_status>(luaL_loadbufferx(L, code.data(), code.size(), chunknametarget, to_string(mode).c_str()));
27780  return load_result(L, absolute_index(L, -1), 1, 1, x);
27781  }
27782 
27783  load_result load_buffer(const char* buff, size_t size, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27784  return load(string_view(buff, size), chunkname, mode);
27785  }
27786 
27788  const std::byte* buff, size_t size, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27789  return load(string_view(reinterpret_cast<const char*>(buff), size), chunkname, mode);
27790  }
27791 
27792  load_result load_file(const std::string& filename, load_mode mode = load_mode::any) {
27793  load_status x = static_cast<load_status>(luaL_loadfilex(L, filename.c_str(), to_string(mode).c_str()));
27794  return load_result(L, absolute_index(L, -1), 1, 1, x);
27795  }
27796 
27797  load_result load(lua_Reader reader, void* data, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
27798  detail::typical_chunk_name_t basechunkname = {};
27799  const char* chunknametarget = detail::make_chunk_name("lua_Reader", chunkname, basechunkname);
27800  load_status x = static_cast<load_status>(lua_load(L, reader, data, chunknametarget, to_string(mode).c_str()));
27801  return load_result(L, absolute_index(L, -1), 1, 1, x);
27802  }
27803 
27804  iterator begin() const {
27805  return global.begin();
27806  }
27807 
27808  iterator end() const {
27809  return global.end();
27810  }
27811 
27813  return global.cbegin();
27814  }
27815 
27817  return global.cend();
27818  }
27819 
27821  // if we return a reference
27822  // we'll be screwed a bit
27823  return global;
27824  }
27825 
27827  return global;
27828  }
27829 
27830  table registry() const {
27831  return reg;
27832  }
27833 
27835  return total_memory_used(lua_state());
27836  }
27837 
27838  int stack_top() const {
27839  return stack::top(L);
27840  }
27841 
27842  int stack_clear() {
27843  int s = stack_top();
27844  lua_pop(L, s);
27845  return s;
27846  }
27847 
27848  bool supports_gc_mode(gc_mode mode) const noexcept {
27849 #if SOL_LUA_VERSION_I_ >= 504
27850  // supports all modes
27851  (void)mode;
27852  return true;
27853 #endif
27854  return mode == gc_mode::default_value;
27855  }
27856 
27857  bool is_gc_on() const {
27858 #if SOL_LUA_VERSION_I_ >= 502
27859  return lua_gc(lua_state(), LUA_GCISRUNNING, 0) == 1;
27860 #else
27861  // You cannot turn it off in Lua 5.1
27862  return true;
27863 #endif
27864  }
27865 
27867  lua_gc(lua_state(), LUA_GCCOLLECT, 0);
27868  }
27869 
27870  void collect_gc() {
27871  collect_garbage();
27872  }
27873 
27874  bool step_gc(int step_size_kilobytes) {
27875  // THOUGHT: std::chrono-alikes to map "kilobyte size" here...?
27876  // Make it harder to give MB or KB to a B parameter...?
27877  // Probably overkill for now.
27878 #if SOL_LUA_VERSION_I_ >= 504
27879  // The manual implies that this function is almost always successful...
27880  // is it?? It could depend on the GC mode...
27881  return lua_gc(lua_state(), LUA_GCSTEP, step_size_kilobytes) != 0;
27882 #else
27883  return lua_gc(lua_state(), LUA_GCSTEP, step_size_kilobytes) == 1;
27884 #endif
27885  }
27886 
27887  void restart_gc() {
27888  lua_gc(lua_state(), LUA_GCRESTART, 0);
27889  }
27890 
27891  void stop_gc() {
27892  lua_gc(lua_state(), LUA_GCSTOP, 0);
27893  }
27894 
27895  // Returns the old GC mode. Check support using the supports_gc_mode function.
27896  gc_mode change_gc_mode_incremental(int pause, int step_multiplier, int step_byte_size) {
27897  // "What the fuck does any of this mean??"
27898  // http://www.lua.org/manual/5.4/manual.html#2.5.1
27899 
27900  // THOUGHT: std::chrono-alikes to map "byte size" here...?
27901  // Make it harder to give MB or KB to a B parameter...?
27902  // Probably overkill for now.
27903 #if SOL_LUA_VERSION_I_ >= 504
27904  int old_mode = lua_gc(lua_state(), LUA_GCINC, pause, step_multiplier, step_byte_size);
27905  if (old_mode == LUA_GCGEN) {
27906  return gc_mode::generational;
27907  }
27908  else if (old_mode == LUA_GCINC) {
27909  return gc_mode::incremental;
27910  }
27911 #else
27912  lua_gc(lua_state(), LUA_GCSETPAUSE, pause);
27913  lua_gc(lua_state(), LUA_GCSETSTEPMUL, step_multiplier);
27914  (void)step_byte_size; // means nothing in older versions
27915 #endif
27916  return gc_mode::default_value;
27917  }
27918 
27919  // Returns the old GC mode. Check support using the supports_gc_mode function.
27920  gc_mode change_gc_mode_generational(int minor_multiplier, int major_multiplier) {
27921 #if SOL_LUA_VERSION_I_ >= 504
27922  // "What does this shit mean?"
27923  // http://www.lua.org/manual/5.4/manual.html#2.5.2
27924  int old_mode = lua_gc(lua_state(), LUA_GCGEN, minor_multiplier, major_multiplier);
27925  if (old_mode == LUA_GCGEN) {
27926  return gc_mode::generational;
27927  }
27928  else if (old_mode == LUA_GCINC) {
27929  return gc_mode::incremental;
27930  }
27931 #else
27932  (void)minor_multiplier;
27933  (void)major_multiplier;
27934 #endif
27935  return gc_mode::default_value;
27936  }
27937 
27938  operator lua_State*() const {
27939  return lua_state();
27940  }
27941 
27943  lua_atpanic(lua_state(), panic);
27944  }
27945 
27947  set_default_exception_handler(lua_state(), handler);
27948  }
27949 
27950  template <typename... Args, typename... Keys>
27951  decltype(auto) get(Keys&&... keys) const {
27952  return global.get<Args...>(std::forward<Keys>(keys)...);
27953  }
27954 
27955  template <typename T, typename Key>
27956  decltype(auto) get_or(Key&& key, T&& otherwise) const {
27957  return global.get_or(std::forward<Key>(key), std::forward<T>(otherwise));
27958  }
27959 
27960  template <typename T, typename Key, typename D>
27961  decltype(auto) get_or(Key&& key, D&& otherwise) const {
27962  return global.get_or<T>(std::forward<Key>(key), std::forward<D>(otherwise));
27963  }
27964 
27965  template <typename... Args>
27966  state_view& set(Args&&... args) {
27967  global.set(std::forward<Args>(args)...);
27968  return *this;
27969  }
27970 
27971  template <typename T, typename... Keys>
27972  decltype(auto) traverse_get(Keys&&... keys) const {
27973  return global.traverse_get<T>(std::forward<Keys>(keys)...);
27974  }
27975 
27976  template <typename... Args>
27978  global.traverse_set(std::forward<Args>(args)...);
27979  return *this;
27980  }
27981 
27982  template <typename Class, typename... Args>
27984  return global.new_usertype<Class>(std::forward<Args>(args)...);
27985  }
27986 
27987  template <bool read_only = true, typename... Args>
27988  state_view& new_enum(const string_view& name, Args&&... args) {
27989  global.new_enum<read_only>(name, std::forward<Args>(args)...);
27990  return *this;
27991  }
27992 
27993  template <typename T, bool read_only = true>
27994  state_view& new_enum(const string_view& name, std::initializer_list<std::pair<string_view, T>> items) {
27995  global.new_enum<T, read_only>(name, std::move(items));
27996  return *this;
27997  }
27998 
27999  template <typename Fx>
28000  void for_each(Fx&& fx) {
28001  global.for_each(std::forward<Fx>(fx));
28002  }
28003 
28004  template <typename T>
28006  return global[std::forward<T>(key)];
28007  }
28008 
28009  template <typename T>
28011  return global[std::forward<T>(key)];
28012  }
28013 
28014  template <typename Sig, typename... Args, typename Key>
28015  state_view& set_function(Key&& key, Args&&... args) {
28016  global.set_function<Sig>(std::forward<Key>(key), std::forward<Args>(args)...);
28017  return *this;
28018  }
28019 
28020  template <typename... Args, typename Key>
28021  state_view& set_function(Key&& key, Args&&... args) {
28022  global.set_function(std::forward<Key>(key), std::forward<Args>(args)...);
28023  return *this;
28024  }
28025 
28026  template <typename Name>
28027  table create_table(Name&& name, int narr = 0, int nrec = 0) {
28028  return global.create(std::forward<Name>(name), narr, nrec);
28029  }
28030 
28031  template <typename Name, typename Key, typename Value, typename... Args>
28032  table create_table(Name&& name, int narr, int nrec, Key&& key, Value&& value, Args&&... args) {
28033  return global.create(std::forward<Name>(name), narr, nrec, std::forward<Key>(key), std::forward<Value>(value), std::forward<Args>(args)...);
28034  }
28035 
28036  template <typename Name, typename... Args>
28037  table create_named_table(Name&& name, Args&&... args) {
28038  table x = global.create_with(std::forward<Args>(args)...);
28039  global.set(std::forward<Name>(name), x);
28040  return x;
28041  }
28042 
28043  table create_table(int narr = 0, int nrec = 0) {
28044  return create_table(lua_state(), narr, nrec);
28045  }
28046 
28047  template <typename Key, typename Value, typename... Args>
28048  table create_table(int narr, int nrec, Key&& key, Value&& value, Args&&... args) {
28049  return create_table(lua_state(), narr, nrec, std::forward<Key>(key), std::forward<Value>(value), std::forward<Args>(args)...);
28050  }
28051 
28052  template <typename... Args>
28054  return create_table_with(lua_state(), std::forward<Args>(args)...);
28055  }
28056 
28057  static inline table create_table(lua_State* L, int narr = 0, int nrec = 0) {
28058  return global_table::create(L, narr, nrec);
28059  }
28060 
28061  template <typename Key, typename Value, typename... Args>
28062  static inline table create_table(lua_State* L, int narr, int nrec, Key&& key, Value&& value, Args&&... args) {
28063  return global_table::create(L, narr, nrec, std::forward<Key>(key), std::forward<Value>(value), std::forward<Args>(args)...);
28064  }
28065 
28066  template <typename... Args>
28067  static inline table create_table_with(lua_State* L, Args&&... args) {
28068  return global_table::create_with(L, std::forward<Args>(args)...);
28069  }
28070  };
28071 } // namespace sol
28072 
28073 // end of sol/state_view.hpp
28074 
28075 // beginning of sol/thread.hpp
28076 
28077 namespace sol {
28080 
28082  }
28083 
28084  lua_State* lua_state() const noexcept {
28085  return L;
28086  }
28087  operator lua_State*() const noexcept {
28088  return lua_state();
28089  }
28090  lua_State* operator->() const noexcept {
28091  return lua_state();
28092  }
28093  };
28094 
28095  namespace stack {
28096  template <>
28099  lua_pushthread(lts.L);
28100  return 1;
28101  }
28102  };
28103 
28104  template <>
28106  lua_thread_state get(lua_State* L, int index, record& tracking) {
28107  tracking.use(1);
28109  return lts;
28110  }
28111  };
28112 
28113  template <>
28115  template <typename Handler>
28116  optional<lua_thread_state> get(lua_State* L, int index, Handler&& handler, record& tracking) {
28118  if (lts.lua_state() == nullptr) {
28119  handler(L, index, type::thread, type_of(L, index), "value is not a valid thread type");
28120  return nullopt;
28121  }
28122  tracking.use(1);
28123  return lts;
28124  }
28125  };
28126  } // namespace stack
28127 
28128  template <typename ref_t>
28129  class basic_thread : public basic_object<ref_t> {
28130  private:
28132 
28133  public:
28134  using base_t::lua_state;
28135 
28136  basic_thread() noexcept = default;
28137  basic_thread(const basic_thread&) = default;
28139  template <typename T,
28140  meta::enable<meta::neg<std::is_same<meta::unqualified_t<T>, basic_thread>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
28141  basic_thread(T&& r) : base_t(std::forward<T>(r)) {
28142 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
28143  auto pp = stack::push_pop(*this);
28145  stack::check<basic_thread>(lua_state(), -1, handler);
28146 #endif // Safety
28147  }
28148  basic_thread(const stack_reference& r) : basic_thread(r.lua_state(), r.stack_index()) {};
28149  basic_thread(stack_reference&& r) : basic_thread(r.lua_state(), r.stack_index()) {};
28150  basic_thread& operator=(const basic_thread&) = default;
28151  basic_thread& operator=(basic_thread&&) = default;
28152  template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
28153  basic_thread(lua_State* L, T&& r) : base_t(L, std::forward<T>(r)) {
28154 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
28155  auto pp = stack::push_pop(*this);
28157  stack::check<basic_thread>(lua_state(), -1, handler);
28158 #endif // Safety
28159  }
28160  basic_thread(lua_State* L, int index = -1) : base_t(L, index) {
28161 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
28163  stack::check<basic_thread>(L, index, handler);
28164 #endif // Safety
28165  }
28167 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
28168  auto pp = stack::push_pop(*this);
28170  stack::check<basic_thread>(lua_state(), -1, handler);
28171 #endif // Safety
28172  }
28173  basic_thread(lua_State* L, lua_State* actualthread) : basic_thread(L, lua_thread_state { actualthread }) {
28174  }
28175  basic_thread(lua_State* L, this_state actualthread) : basic_thread(L, lua_thread_state { actualthread.L }) {
28176  }
28177  basic_thread(lua_State* L, lua_thread_state actualthread) : base_t(L, -stack::push(L, actualthread)) {
28178 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
28180  stack::check<basic_thread>(lua_state(), -1, handler);
28181 #endif // Safety
28183  lua_pop(lua_state(), 1);
28184  }
28185  }
28186 
28187  state_view state() const {
28188  return state_view(this->thread_state());
28189  }
28190 
28191  bool is_main_thread() const {
28192  return stack::is_main_thread(this->thread_state());
28193  }
28194 
28196  auto pp = stack::push_pop(*this);
28197  lua_State* lthread = lua_tothread(lua_state(), -1);
28198  return lthread;
28199  }
28200 
28202  lua_State* lthread = thread_state();
28203  auto lstat = static_cast<thread_status>(lua_status(lthread));
28204  if (lstat == thread_status::ok) {
28205  lua_Debug ar;
28206  if (lua_getstack(lthread, 0, &ar) > 0)
28207  return thread_status::ok;
28208  else if (lua_gettop(lthread) == 0)
28209  return thread_status::dead;
28210  else
28211  return thread_status::yielded;
28212  }
28213  return lstat;
28214  }
28215 
28217  return create(lua_state());
28218  }
28219 
28221  lua_newthread(L);
28222  basic_thread result(L);
28224  lua_pop(L, 1);
28225  }
28226  return result;
28227  }
28228  };
28229 
28230  typedef basic_thread<reference> thread;
28231  typedef basic_thread<stack_reference> stack_thread;
28232 } // namespace sol
28233 
28234 // end of sol/thread.hpp
28235 
28236 namespace sol {
28237 
28238  class state : private std::unique_ptr<lua_State, detail::state_deleter>, public state_view {
28239  private:
28240  typedef std::unique_ptr<lua_State, detail::state_deleter> unique_base;
28241 
28242  public:
28245  }
28246 
28247  state(lua_CFunction panic, lua_Alloc alfunc, void* alpointer = nullptr)
28248  : unique_base(lua_newstate(alfunc, alpointer)), state_view(unique_base::get()) {
28250  }
28251 
28252  state(const state&) = delete;
28253  state(state&&) = default;
28254  state& operator=(const state&) = delete;
28255  state& operator=(state&& that) {
28256  state_view::operator=(std::move(that));
28257  unique_base::operator=(std::move(that));
28258  return *this;
28259  }
28260 
28261  using state_view::get;
28262 
28264  }
28265  };
28266 } // namespace sol
28267 
28268 // end of sol/state.hpp
28269 
28270 // beginning of sol/coroutine.hpp
28271 
28272 namespace sol {
28273  template <typename Reference>
28274  class basic_coroutine : public basic_object<Reference> {
28275  private:
28278 
28279  private:
28281 
28282  void luacall(std::ptrdiff_t argcount, std::ptrdiff_t) {
28283 #if SOL_LUA_VERSION_I_ >= 504
28284  int nresults;
28285  stats = static_cast<call_status>(lua_resume(lua_state(), nullptr, static_cast<int>(argcount), &nresults));
28286 #else
28287  stats = static_cast<call_status>(lua_resume(lua_state(), nullptr, static_cast<int>(argcount)));
28288 #endif
28289  }
28290 
28291  template <std::size_t... I, typename... Ret>
28292  auto invoke(types<Ret...>, std::index_sequence<I...>, std::ptrdiff_t n) {
28293  luacall(n, sizeof...(Ret));
28294  return stack::pop<std::tuple<Ret...>>(lua_state());
28295  }
28296 
28297  template <std::size_t I, typename Ret>
28298  Ret invoke(types<Ret>, std::index_sequence<I>, std::ptrdiff_t n) {
28299  luacall(n, 1);
28300  return stack::pop<Ret>(lua_state());
28301  }
28302 
28303  template <std::size_t I>
28304  void invoke(types<void>, std::index_sequence<I>, std::ptrdiff_t n) {
28305  luacall(n, 0);
28306  }
28307 
28308  protected_function_result invoke(types<>, std::index_sequence<>, std::ptrdiff_t n) {
28309  int firstreturn = 1;
28310  luacall(n, LUA_MULTRET);
28311  int poststacksize = lua_gettop(this->lua_state());
28312  int returncount = poststacksize - (firstreturn - 1);
28313  if (error()) {
28314  if (m_error_handler.valid()) {
28315  string_view err = stack::get<string_view>(this->lua_state(), poststacksize);
28316  m_error_handler.push();
28317  stack::push(this->lua_state(), err);
28318  lua_call(lua_state(), 1, 1);
28319  }
28320  return protected_function_result(this->lua_state(), lua_absindex(this->lua_state(), -1), 1, returncount, status());
28321  }
28322  return protected_function_result(this->lua_state(), firstreturn, returncount, returncount, status());
28323  }
28324 
28325  public:
28326  using base_t::lua_state;
28327 
28328  basic_coroutine() = default;
28329  template <typename T,
28333  basic_coroutine(T&& r) noexcept
28334  : base_t(std::forward<T>(r)), m_error_handler(detail::get_default_handler<reference, is_main_threaded<base_t>::value>(r.lua_state())) {
28335 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
28336  if (!is_function<meta::unqualified_t<T>>::value) {
28337  auto pp = stack::push_pop(*this);
28339  stack::check<basic_coroutine>(lua_state(), -1, handler);
28340  }
28341 #endif // Safety
28342  }
28343 
28344  basic_coroutine(const basic_coroutine& other) = default;
28345  basic_coroutine& operator=(const basic_coroutine&) = default;
28346 
28347  basic_coroutine(basic_coroutine&& other) noexcept : base_t(std::move(other)), m_error_handler(this->lua_state(), std::move(other.m_error_handler)) {
28348  }
28349 
28351  base_t::operator=(std::move(other));
28352  // must change the state, since it could change on the coroutine type
28353  m_error_handler = handler_t(this->lua_state(), std::move(other.m_error_handler));
28354  return *this;
28355  }
28356 
28359  }
28362  }
28363  basic_coroutine(const basic_function<base_t>& b, handler_t eh) noexcept : base_t(b), m_error_handler(std::move(eh)) {
28364  }
28365  basic_coroutine(basic_function<base_t>&& b, handler_t eh) noexcept : base_t(std::move(b)), m_error_handler(std::move(eh)) {
28366  }
28368  : basic_coroutine(r.lua_state(), r.stack_index(), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(r.lua_state())) {
28369  }
28371  : basic_coroutine(r.lua_state(), r.stack_index(), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(r.lua_state())) {
28372  }
28373  basic_coroutine(const stack_reference& r, handler_t eh) noexcept : basic_coroutine(r.lua_state(), r.stack_index(), std::move(eh)) {
28374  }
28375  basic_coroutine(stack_reference&& r, handler_t eh) noexcept : basic_coroutine(r.lua_state(), r.stack_index(), std::move(eh)) {
28376  }
28377 
28378  template <typename Super>
28381  }
28382  template <typename Super>
28385  }
28386  template <typename Proxy, typename HandlerReference,
28389  basic_coroutine(Proxy&& p, HandlerReference&& eh) : basic_coroutine(detail::force_cast<base_t>(p), std::forward<HandlerReference>(eh)) {
28390  }
28391 
28392  template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
28393  basic_coroutine(lua_State* L, T&& r) noexcept
28395  }
28396  template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
28397  basic_coroutine(lua_State* L, T&& r, handler_t eh) : base_t(L, std::forward<T>(r)), m_error_handler(std::move(eh)) {
28398 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
28399  auto pp = stack::push_pop(*this);
28401  stack::check<basic_coroutine>(lua_state(), -1, handler);
28402 #endif // Safety
28403  }
28404 
28405  basic_coroutine(lua_nil_t n) : base_t(n), m_error_handler(n) {
28406  }
28407 
28408  basic_coroutine(lua_State* L, int index = -1)
28410  }
28411  basic_coroutine(lua_State* L, int index, handler_t eh) : base_t(L, index), m_error_handler(std::move(eh)) {
28412 #ifdef SOL_SAFE_REFERENCES
28414  stack::check<basic_coroutine>(L, index, handler);
28415 #endif // Safety
28416  }
28419  }
28420  basic_coroutine(lua_State* L, absolute_index index, handler_t eh) : base_t(L, index), m_error_handler(std::move(eh)) {
28421 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
28423  stack::check<basic_coroutine>(L, index, handler);
28424 #endif // Safety
28425  }
28428  }
28429  basic_coroutine(lua_State* L, raw_index index, handler_t eh) : base_t(L, index), m_error_handler(std::move(eh)) {
28430 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
28432  stack::check<basic_coroutine>(L, index, handler);
28433 #endif // Safety
28434  }
28437  }
28438  basic_coroutine(lua_State* L, ref_index index, handler_t eh) : base_t(L, index), m_error_handler(std::move(eh)) {
28439 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
28440  auto pp = stack::push_pop(*this);
28442  stack::check<basic_coroutine>(lua_state(), -1, handler);
28443 #endif // Safety
28444  }
28445 
28446  call_status status() const noexcept {
28447  return stats;
28448  }
28449 
28450  bool error() const noexcept {
28451  call_status cs = status();
28452  return cs != call_status::ok && cs != call_status::yielded;
28453  }
28454 
28455  bool runnable() const noexcept {
28456  return base_t::valid() && (status() == call_status::yielded);
28457  }
28458 
28459  explicit operator bool() const noexcept {
28460  return runnable();
28461  }
28462 
28463  template <typename... Args>
28465  return call<>(std::forward<Args>(args)...);
28466  }
28467 
28468  template <typename... Ret, typename... Args>
28469  decltype(auto) operator()(types<Ret...>, Args&&... args) {
28470  return call<Ret...>(std::forward<Args>(args)...);
28471  }
28472 
28473  template <typename... Ret, typename... Args>
28474  decltype(auto) call(Args&&... args) {
28475  // some users screw up coroutine.create
28476  // and try to use it with sol::coroutine without ever calling the first resume in Lua
28477  // this makes the stack incompatible with other kinds of stacks: protect against this
28478  // make sure coroutines don't screw us over
28479  base_t::push();
28480  int pushcount = stack::multi_push_reference(lua_state(), std::forward<Args>(args)...);
28481  return invoke(types<Ret...>(), std::make_index_sequence<sizeof...(Ret)>(), pushcount);
28482  }
28483 
28484  private:
28486  };
28487 } // namespace sol
28488 
28489 // end of sol/coroutine.hpp
28490 
28491 // beginning of sol/userdata.hpp
28492 
28493 namespace sol {
28494  template <typename base_type>
28495  class basic_userdata : public basic_table<base_type> {
28496  private:
28498 
28499  public:
28500  using base_t::lua_state;
28501 
28502  basic_userdata() noexcept = default;
28503  template <typename T,
28504  meta::enable<meta::neg<std::is_same<meta::unqualified_t<T>, basic_userdata>>, meta::neg<std::is_same<base_t, stack_reference>>,
28505  is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
28506  basic_userdata(T&& r) noexcept : base_t(std::forward<T>(r)) {
28507 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
28508  if (!is_userdata<meta::unqualified_t<T>>::value) {
28509  auto pp = stack::push_pop(*this);
28510  type_assert(lua_state(), -1, type::userdata);
28511  }
28512 #endif // Safety
28513  }
28514  basic_userdata(const basic_userdata&) = default;
28515  basic_userdata(basic_userdata&&) = default;
28516  basic_userdata& operator=(const basic_userdata&) = default;
28517  basic_userdata& operator=(basic_userdata&&) = default;
28518  basic_userdata(const stack_reference& r) : basic_userdata(r.lua_state(), r.stack_index()) {
28519  }
28520  basic_userdata(stack_reference&& r) : basic_userdata(r.lua_state(), r.stack_index()) {
28521  }
28522  template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
28523  basic_userdata(lua_State* L, T&& r) : base_t(L, std::forward<T>(r)) {
28524 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
28525  auto pp = stack::push_pop(*this);
28527  stack::check<basic_userdata>(L, -1, handler);
28528 #endif // Safety
28529  }
28530  basic_userdata(lua_State* L, int index = -1) : base_t(detail::no_safety, L, index) {
28531 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
28533  stack::check<basic_userdata>(L, index, handler);
28534 #endif // Safety
28535  }
28537 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
28538  auto pp = stack::push_pop(*this);
28540  stack::check<basic_userdata>(L, -1, handler);
28541 #endif // Safety
28542  }
28543  };
28544 
28545  template <typename base_type>
28546  class basic_lightuserdata : public basic_object_base<base_type> {
28548 
28549  public:
28550  using base_t::lua_state;
28551 
28552  basic_lightuserdata() noexcept = default;
28553  template <typename T,
28554  meta::enable<meta::neg<std::is_same<meta::unqualified_t<T>, basic_lightuserdata>>, meta::neg<std::is_same<base_t, stack_reference>>,
28555  is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
28556  basic_lightuserdata(T&& r) noexcept : base_t(std::forward<T>(r)) {
28557 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
28559  auto pp = stack::push_pop(*this);
28560  type_assert(lua_state(), -1, type::lightuserdata);
28561  }
28562 #endif // Safety
28563  }
28564  basic_lightuserdata(const basic_lightuserdata&) = default;
28566  basic_lightuserdata& operator=(const basic_lightuserdata&) = default;
28567  basic_lightuserdata& operator=(basic_lightuserdata&&) = default;
28568  basic_lightuserdata(const stack_reference& r) : basic_lightuserdata(r.lua_state(), r.stack_index()) {
28569  }
28570  basic_lightuserdata(stack_reference&& r) : basic_lightuserdata(r.lua_state(), r.stack_index()) {
28571  }
28572  template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
28573  basic_lightuserdata(lua_State* L, T&& r) : basic_lightuserdata(L, std::forward<T>(r)) {
28574 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
28575  auto pp = stack::push_pop(*this);
28577  stack::check<basic_lightuserdata>(lua_state(), -1, handler);
28578 #endif // Safety
28579  }
28580  basic_lightuserdata(lua_State* L, int index = -1) : base_t(L, index) {
28581 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
28583  stack::check<basic_lightuserdata>(L, index, handler);
28584 #endif // Safety
28585  }
28587 #if SOL_IS_ON(SOL_SAFE_REFERENCES)
28588  auto pp = stack::push_pop(*this);
28590  stack::check<basic_lightuserdata>(lua_state(), index, handler);
28591 #endif // Safety
28592  }
28593  };
28594 
28595 } // namespace sol
28596 
28597 // end of sol/userdata.hpp
28598 
28599 // beginning of sol/as_args.hpp
28600 
28601 namespace sol {
28602  template <typename T>
28603  struct as_args_t {
28604  T src;
28605  };
28606 
28607  template <typename Source>
28608  auto as_args(Source&& source) {
28609  return as_args_t<Source> { std::forward<Source>(source) };
28610  }
28611 
28612  namespace stack {
28613  template <typename T>
28615  int push(lua_State* L, const as_args_t<T>& e) {
28616  int p = 0;
28617  for (const auto& i : e.src) {
28618  p += stack::push(L, i);
28619  }
28620  return p;
28621  }
28622  };
28623  } // namespace stack
28624 } // namespace sol
28625 
28626 // end of sol/as_args.hpp
28627 
28628 // beginning of sol/variadic_args.hpp
28629 
28630 #include <limits>
28631 #include <iterator>
28632 
28633 namespace sol {
28634  struct variadic_args {
28635  private:
28637  int index;
28639 
28640  public:
28644  typedef std::ptrdiff_t difference_type;
28648  typedef std::reverse_iterator<iterator> reverse_iterator;
28649  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
28650 
28651  variadic_args() = default;
28652  variadic_args(lua_State* luastate, int stackindex = -1) : L(luastate), index(lua_absindex(luastate, stackindex)), stacktop(lua_gettop(luastate)) {
28653  }
28654  variadic_args(lua_State* luastate, int stackindex, int lastindex) : L(luastate), index(lua_absindex(luastate, stackindex)), stacktop(lastindex) {
28655  }
28656  variadic_args(const variadic_args&) = default;
28657  variadic_args& operator=(const variadic_args&) = default;
28658  variadic_args(variadic_args&& o) : L(o.L), index(o.index), stacktop(o.stacktop) {
28659  // Must be manual, otherwise destructor will screw us
28660  // return count being 0 is enough to keep things clean
28661  // but will be thorough
28662  o.L = nullptr;
28663  o.index = 0;
28664  o.stacktop = 0;
28665  }
28667  L = o.L;
28668  index = o.index;
28669  stacktop = o.stacktop;
28670  // Must be manual, otherwise destructor will screw us
28671  // return count being 0 is enough to keep things clean
28672  // but will be thorough
28673  o.L = nullptr;
28674  o.index = 0;
28675  o.stacktop = 0;
28676  return *this;
28677  }
28678 
28680  return iterator(L, index, stacktop + 1);
28681  }
28683  return iterator(L, stacktop + 1, stacktop + 1);
28684  }
28686  return const_iterator(L, index, stacktop + 1);
28687  }
28689  return const_iterator(L, stacktop + 1, stacktop + 1);
28690  }
28692  return begin();
28693  }
28695  return end();
28696  }
28697 
28699  return std::reverse_iterator<iterator>(begin());
28700  }
28702  return std::reverse_iterator<iterator>(end());
28703  }
28705  return std::reverse_iterator<const_iterator>(begin());
28706  }
28708  return std::reverse_iterator<const_iterator>(end());
28709  }
28711  return std::reverse_iterator<const_iterator>(cbegin());
28712  }
28714  return std::reverse_iterator<const_iterator>(cend());
28715  }
28716 
28717  int push() const {
28718  return push(L);
28719  }
28720 
28721  int push(lua_State* target) const {
28722  int pushcount = 0;
28723  for (int i = index; i <= stacktop; ++i) {
28724  lua_pushvalue(L, i);
28725  pushcount += 1;
28726  }
28727  if (target != L) {
28728  lua_xmove(L, target, pushcount);
28729  }
28730  return pushcount;
28731  }
28732 
28733  template <typename T>
28734  decltype(auto) get(difference_type index_offset = 0) const {
28735  return stack::get<T>(L, index + static_cast<int>(index_offset));
28736  }
28737 
28738  type get_type(difference_type index_offset = 0) const noexcept {
28739  return type_of(L, index + static_cast<int>(index_offset));
28740  }
28741 
28743  return stack_proxy(L, index + static_cast<int>(index_offset));
28744  }
28745 
28747  return L;
28748  };
28749  int stack_index() const {
28750  return index;
28751  };
28752  int leftover_count() const {
28753  return stacktop - (index - 1);
28754  }
28755  std::size_t size() const {
28756  return static_cast<std::size_t>(leftover_count());
28757  }
28758  int top() const {
28759  return stacktop;
28760  }
28761  };
28762 
28763  namespace stack {
28764  template <>
28766  static variadic_args get(lua_State* L, int index, record& tracking) {
28767  tracking.last = 0;
28768  return variadic_args(L, index);
28769  }
28770  };
28771 
28772  template <>
28774  static int push(lua_State* L, const variadic_args& ref) {
28775  return ref.push(L);
28776  }
28777  };
28778  } // namespace stack
28779 } // namespace sol
28780 
28781 // end of sol/variadic_args.hpp
28782 
28783 // beginning of sol/variadic_results.hpp
28784 
28785 // beginning of sol/as_returns.hpp
28786 
28787 namespace sol {
28788  template <typename T>
28789  struct as_returns_t : private detail::ebco<T> {
28790  private:
28792 
28793  public:
28794  using base_t::base_t;
28795  using base_t::value;
28796  };
28797 
28798  template <typename Source>
28799  auto as_returns(Source&& source) {
28800  return as_returns_t<std::decay_t<Source>> { std::forward<Source>(source) };
28801  }
28802 
28803  namespace stack {
28804  template <typename T>
28806  int push(lua_State* L, const as_returns_t<T>& e) {
28807  auto& src = detail::unwrap(e.value());
28808  int p = 0;
28809  for (const auto& i : src) {
28810  p += stack::push(L, i);
28811  }
28812  return p;
28813  }
28814  };
28815  } // namespace stack
28816 } // namespace sol
28817 
28818 // end of sol/as_returns.hpp
28819 
28820 #include <vector>
28821 
28822 namespace sol {
28823 
28824  template <typename Al = typename std::allocator<object>>
28825  struct basic_variadic_results : public std::vector<object, Al> {
28826  private:
28827  using base_t = std::vector<object, Al>;
28828 
28829  public:
28831  }
28832 
28834  this->reserve(fr.return_count());
28835  this->insert(this->cend(), fr.begin(), fr.end());
28836  }
28837 
28839  this->reserve(fr.return_count());
28840  this->insert(this->cend(), fr.begin(), fr.end());
28841  }
28842 
28843  template <typename Arg0, typename... Args,
28845  std::is_same<meta::unqualified_t<Arg0>, protected_function_result>> = meta::enabler>
28846  basic_variadic_results(Arg0&& arg0, Args&&... args) : base_t(std::forward<Arg0>(arg0), std::forward<Args>(args)...) {
28847  }
28848 
28851  };
28852 
28854  private:
28856 
28857  public:
28858  using base_t::base_t;
28859  };
28860 
28861  template <typename Al>
28863 
28864  template <>
28866 
28867  namespace stack {
28868  template <typename Al>
28871  int p = 0;
28872  for (const auto& i : e) {
28873  p += stack::push(L, i);
28874  }
28875  return p;
28876  }
28877  };
28878 
28879  template <>
28881  int push(lua_State* L, const variadic_results& r) {
28882  using base_t = basic_variadic_results<>;
28883  return stack::push(L, static_cast<const base_t&>(r));
28884  }
28885  };
28886  } // namespace stack
28887 
28888 } // namespace sol
28889 
28890 // end of sol/variadic_results.hpp
28891 
28892 #if SOL_IS_ON(SOL_COMPILER_GCC)
28893 #pragma GCC diagnostic pop
28894 #elif SOL_IS_ON(SOL_COMPILER_CLANG)
28895 #elif SOL_IS_ON(SOL_COMPILER_VCXX)
28896 #pragma warning(pop)
28897 #endif // g++
28898 
28899 #if SOL_IS_ON(SOL_INSIDE_UNREAL_ENGINE)
28900 #undef check
28901 #pragma pop_macro("check")
28902 #endif // Unreal Engine 4 Bullshit
28903 
28904 #endif // SOL_HPP
28905 // end of sol/sol.hpp
28906 
28907 #endif // SOL_SINGLE_INCLUDE_HPP
sol::detail::unique_fallback< std::shared_ptr< T > >::rebind_actual_type
std::shared_ptr< X > rebind_actual_type
Definition: sol.hpp:9138
sol::state_view::collect_gc
void collect_gc()
Definition: sol.hpp:27870
sol::stack::unqualified_pusher< as_container_t< T > >::push_lvalue
static int push_lvalue(std::true_type, lua_State *L, const C &cont)
Definition: sol.hpp:23176
sol::u_detail::usertype_storage_base::auxiliary_keys
std::unordered_map< stateless_reference, stateless_reference, stateless_reference_hash, stateless_reference_equals > auxiliary_keys
Definition: sol.hpp:23681
sol::detail::default_construct::operator()
void operator()(T &&obj, Args &&... args) const
Definition: sol.hpp:6931
sol::stack::unqualified_check_getter< std::variant< Tn... >, C >::V_size
std::variant_size< V > V_size
Definition: sol.hpp:14493
sol::basic_thread::basic_thread
basic_thread(lua_State *L, lua_thread_state actualthread)
Definition: sol.hpp:28177
sol::stack::stateless_push_popper::stateless_push_popper
stateless_push_popper(lua_State *L_, T object_) noexcept
Definition: sol.hpp:10058
sol::stack::unqualified_pusher< Signature, std::enable_if_t< meta::is_member_object_or_function_v< Signature > > >::push
static int push(lua_State *L, Args &&... args)
Definition: sol.hpp:20156
sol::container_detail::u_c_launch::real_pairs_traits
static int real_pairs_traits(std::false_type, lua_State *L)
Definition: sol.hpp:22934
sol::basic_table_core::begin
iterator begin() const
Definition: sol.hpp:25778
sol::basic_coroutine::operator()
protected_function_result operator()(Args &&... args)
Definition: sol.hpp:28464
sol::container_detail::usertype_container_default::end
static iterator end(lua_State *L_, T &)
Definition: sol.hpp:21746
sol::state_view::reg
table reg
Definition: sol.hpp:27240
sol::container_detail::has_erase_key
meta::boolean< has_erase_key_test< T >::value > has_erase_key
Definition: sol.hpp:21575
sol::function_result
unsafe_function_result function_result
Definition: forward.hpp:1191
sol::detail::create_if_nil
@ create_if_nil
Definition: sol.hpp:7745
sol::stack::unqualified_pusher< raw_index >::push
static int push(lua_State *L, raw_index ri)
Definition: sol.hpp:15618
sol::detail::tagged
Definition: sol.hpp:6968
sol::automagic_enrollments::less_than_operator
bool less_than_operator
Definition: sol.hpp:8709
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::find_associative_lookup
static detail::error_result find_associative_lookup(std::false_type, lua_State *L_, T &self, Iter &, std::size_t idx)
Definition: sol.hpp:22110
sol::meta_function::addition
@ addition
sol::type::number
@ number
sol::error::what
virtual const char * what() const noexcept override
Definition: sol.hpp:4593
sol::container_detail::u_c_launch::real_index_get_traits
static int real_index_get_traits(std::true_type, lua_State *L)
Definition: sol.hpp:22847
lua_tonumberx
LUA_API lua_Number lua_tonumberx(lua_State *L, int idx, int *pisnum)
Definition: lapi.c:373
sol::is_function
Definition: sol.hpp:8554
sol::unsafe_function_result::operator=
unsafe_function_result & operator=(unsafe_function_result &&o) noexcept
Definition: sol.hpp:17473
lua_newuserdata
#define lua_newuserdata(L, s)
Definition: lua.h:412
sol::function_detail::member_function::call
static int call(lua_State *L, member_function &self) noexcept(traits_type::is_noexcept)
Definition: sol.hpp:19531
sol::u_detail::maybe_get_usertype_storage
optional< usertype_storage< T > & > maybe_get_usertype_storage(lua_State *L_)
Definition: sol.hpp:24300
sol::register_main_thread
void register_main_thread(lua_State *L)
Definition: sol.hpp:27075
sol::stack::unqualified_getter< this_state >::get
static this_state get(lua_State *L, int, record &tracking)
Definition: sol.hpp:14131
sol::detail::proxy_key_t
meta::conditional_t< meta::is_specialization_of_v< meta::unqualified_t< T >, std::tuple >, T, std::tuple< meta::conditional_t< std::is_array_v< meta::unqualified_t< T > >, std::remove_reference_t< T > &, meta::unqualified_t< T > >> > proxy_key_t
Definition: sol.hpp:16954
sol::stateless_reference::copy_ref
int copy_ref(lua_State *L_) const noexcept
Definition: sol.hpp:10166
sol::stack::unqualified_pusher< as_container_t< T > >::push_lvalue
static int push_lvalue(std::false_type, lua_State *L, const C &cont)
Definition: sol.hpp:23181
sol::meta::tuple_element
std::tuple_element< N, std::remove_reference_t< Tuple > > tuple_element
Definition: sol.hpp:1504
sol::load_result::load_result
load_result() noexcept
Definition: sol.hpp:26821
sol::pairs_iterator::pointer
value_type * pointer
Definition: sol.hpp:25205
sol::detail::implicit_wrapper::implicit_wrapper
implicit_wrapper(T *value_)
Definition: sol.hpp:7294
sol::state_view::create_table_with
static table create_table_with(lua_State *L, Args &&... args)
Definition: sol.hpp:28067
sol::base_classes_tag
bases base_classes_tag
Definition: sol.hpp:9334
sol::protected_function_result::operator=
protected_function_result & operator=(const protected_function_result &)=delete
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::is_input_iterator
std::is_same< iterator_category, std::input_iterator_tag > is_input_iterator
Definition: sol.hpp:21778
sol::optional::operator*
SOL_TL_OPTIONAL_11_CONSTEXPR T && operator*() &&
\exclude
Definition: sol.hpp:5914
sol::state_view::get
decltype(auto) get(Keys &&... keys) const
Definition: sol.hpp:27951
sol::detail::set_default_handler
void set_default_handler(lua_State *L, const T &ref)
Definition: sol.hpp:20789
sol::usertype_proxy::operator=
usertype_proxy && operator=(T &&other) &&
Definition: sol.hpp:24619
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::ipairs
static int ipairs(lua_State *L_)
Definition: sol.hpp:22804
sol::pairs_iterator::const_reference
const value_type & const_reference
Definition: sol.hpp:25208
sol::u_detail::usertype_storage_base_index
constexpr const int usertype_storage_base_index
Definition: sol.hpp:23249
sol::state_view::safe_script
protected_function_result safe_script(const string_view &code, Fx &&on_error, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27581
sol::wrap::type
F type
Definition: sol.hpp:19103
sol::environment
basic_environment< reference > environment
Definition: forward.hpp:1152
sol::basic_coroutine::operator=
basic_coroutine & operator=(basic_coroutine &&other) noexcept
Definition: sol.hpp:28350
sol::protected_function_result::begin
const_iterator begin() const
Definition: sol.hpp:17356
LUA_ERRFILE
#define LUA_ERRFILE
Definition: lauxlib.h:27
sol::basic_table_core::basic_table_core
basic_table_core(lua_State *L, global_tag_t t) noexcept
Definition: sol.hpp:25775
sol::stack::unqualified_pusher< this_main_state >::push
static int push(lua_State *, const this_main_state &) noexcept
Definition: sol.hpp:15974
sol::container_detail::has_traits_erase_test
Definition: sol.hpp:21431
sol::stack_iterator::operator+=
stack_iterator & operator+=(difference_type idx)
Definition: sol.hpp:17052
sol::usertype_traits::name
static const std::string & name()
Definition: sol.hpp:9086
sol::as_container_t
Definition: forward.hpp:1240
sol::stack::unqualified_getter< detail::as_value_tag< T > >::get_no_lua_nil
static T * get_no_lua_nil(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14192
LUA_GCSTOP
#define LUA_GCSTOP
Definition: lua.h:319
sol::stateless_reference_equals::stateless_reference_equals
stateless_reference_equals(lua_State *L_) noexcept
Definition: sol.hpp:10732
sol::detail::conjunction< B >
Definition: sol.hpp:4732
sol::detail::ebco< T &, tag >::m_ref
T * m_ref
Definition: sol.hpp:7214
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::next_K
meta::conditional_t< is_matched_lookup::value, std::ptrdiff_t, K > next_K
Definition: sol.hpp:21772
sol::u_detail::string_for_each_metatable_func
Definition: sol.hpp:23565
sol::make_light
auto make_light(T &l)
Definition: sol.hpp:7478
sol::detail::state_deleter
Definition: sol.hpp:6956
sol::basic_protected_function::basic_protected_function
basic_protected_function(const stack_reference &r, handler_t eh)
Definition: sol.hpp:20886
sol::basic_reference::basic_reference
basic_reference(const stack_reference &r) noexcept
Definition: sol.hpp:10464
sol::state_view::globals
global_table & globals()
Definition: sol.hpp:27826
luaL_callmeta
LUALIB_API int luaL_callmeta(lua_State *L, int obj, const char *event)
Definition: lauxlib.c:861
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::pairs_associative
static int pairs_associative(std::false_type, lua_State *L_)
Definition: sol.hpp:22501
sol::stack_guard::L
lua_State * L
Definition: sol.hpp:10897
sol::detail::optional_copy_base< T, false >::optional_copy_base
optional_copy_base(const optional_copy_base &rhs)
Definition: sol.hpp:5039
sol::detail::optional_operations_base::get
SOL_TL_OPTIONAL_11_CONSTEXPR T & get() &
Definition: sol.hpp:5008
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::add_insert
static detail::error_result add_insert(std::true_type, lua_State *, T &self, stack_object value, Iter &pos)
Definition: sol.hpp:22168
LUA_TFUNCTION
#define LUA_TFUNCTION
Definition: lua.h:71
left
lu_byte left
Definition: lparser.c:1226
sol::protected_function_result::operator=
protected_function_result & operator=(protected_function_result &&o) noexcept
Definition: sol.hpp:17266
sol::call_detail::agnostic_lua_call_wrapper< bases< Args... >, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *, const bases< Args... > &)
Definition: sol.hpp:18492
sol::basic_coroutine::basic_coroutine
basic_coroutine(lua_State *L, int index=-1)
Definition: sol.hpp:28408
sol::in_place_type_t
std::in_place_type_t< T > in_place_type_t
Definition: sol.hpp:4616
sol::stack::push_environment_of
int push_environment_of(lua_State *L, int target_index=-1)
Definition: sol.hpp:14757
sol::basic_environment::basic_environment
basic_environment(lua_State *L, new_table nt)
Definition: sol.hpp:26590
sol::u_detail::lua_reference_func::value
reference value
Definition: sol.hpp:23632
sol::this_state::L
lua_State * L
Definition: sol.hpp:7756
sol::basic_object::basic_object
basic_object(lua_nil_t r)
Definition: sol.hpp:16861
nlohmann::detail::hash
std::size_t hash(const BasicJsonType &j)
hash a JSON value
Definition: json.hpp:5097
sol::table_proxy::lua_state
lua_State * lua_state() const
Definition: sol.hpp:24947
lua_pushliteral
#define lua_pushliteral(L, s)
Definition: lua.h:382
sol::detail::lua_cfunction_trampoline
int lua_cfunction_trampoline(lua_State *L, lua_CFunction f)
Definition: sol.hpp:8796
lua_rotate
LUA_API void lua_rotate(lua_State *L, int idx, int n)
Definition: lapi.c:235
sol::basic_table_core::set_fx
void set_fx(types<>, Key &&key, Fx &&fx)
Definition: sol.hpp:26053
sol::container_detail::has_traits_index_set
meta::boolean< has_traits_index_set_test< T >::value > has_traits_index_set
Definition: sol.hpp:21593
lua_pcall
#define lua_pcall(L, n, r, f)
Definition: lua.h:287
sol::constant_automagic_enrollments
Definition: sol.hpp:8716
sol::stack::push_pop_at
push_popper_at push_pop_at(T &&object_)
Definition: sol.hpp:10112
sol::u_detail::update_bases_func::base_class_check_func
detail::inheritance_check_function base_class_check_func
Definition: sol.hpp:23646
sol::optional::disjunction
SOL_TL_OPTIONAL_11_CONSTEXPR optional disjunction(const optional &rhs) &
Definition: sol.hpp:5586
sol::override_value
constexpr override_value_t override_value
Definition: sol.hpp:7738
sol::stack::unqualified_pusher< as_container_t< T > >::push_rvalue
static int push_rvalue(std::true_type, lua_State *L, C &&cont)
Definition: sol.hpp:23186
sol::container_detail::has_traits_ipairs
meta::boolean< has_traits_ipairs_test< T >::value > has_traits_ipairs
Definition: sol.hpp:21599
sol::function_detail::overloaded_function::overload_list
std::tuple< Functions... > overload_list
Definition: sol.hpp:19620
sol::destructor_wrapper< void >
Definition: sol.hpp:7039
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::end
static iterator end(lua_State *, T &self)
Definition: sol.hpp:22596
sol::basic_function::dump
Container dump() const
Definition: sol.hpp:20690
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::set_associative
static detail::error_result set_associative(std::false_type, iterator &it, stack_object value)
Definition: sol.hpp:21921
sol::basic_object::basic_object
basic_object(const proxy_base< Super > &r) noexcept
Definition: sol.hpp:16870
sol::call_detail::constructor_match::p_umf_
stack::stack_detail::undefined_metatable * p_umf_
Definition: sol.hpp:18164
detail::operator*
FMT_CONSTEXPR auto operator*(fp x, fp y) -> fp
Definition: format.h:1701
sol::stack::unqualified_checker< std::variant< Tn... >, type::poly >::V
std::variant< Tn... > V
Definition: sol.hpp:12905
sol::usertype_traits::qualified_name
static const std::string & qualified_name()
Definition: sol.hpp:9090
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::iter::~iter
~iter()
Definition: sol.hpp:21794
sol::stack::unqualified_pusher< forward_as_value_t< T > >::push
static int push(lua_State *L, forward_as_value_t< T > &&value_)
Definition: sol.hpp:15946
sol::this_state::operator->
lua_State * operator->() const noexcept
Definition: sol.hpp:7765
sol::stack_guard::~stack_guard
~stack_guard()
Definition: sol.hpp:10913
luaopen_base
LUAMOD_API int luaopen_base(lua_State *L)
Definition: lbaselib.c:516
sol::state_view::state_view
state_view(lua_State *Ls)
Definition: sol.hpp:27309
sol::base
Definition: forward.hpp:1273
sol::basic_object::basic_object
basic_object(lua_State *L_, global_tag_t t)
Definition: sol.hpp:16859
sol::meta::unqualified_tuple_element_t
unqualified_t< tuple_element_t< N, Tuple > > unqualified_tuple_element_t
Definition: sol.hpp:1513
sol::detail::optional_operations_base::construct
void construct(Args &&... args) noexcept
Definition: sol.hpp:4982
sol::basic_table_core::basic_table_core
basic_table_core(lua_State *L, T &&r)
Definition: sol.hpp:25727
sol::stack::unqualified_pusher< ref_index >::push
static int push(lua_State *L, ref_index ri)
Definition: sol.hpp:15629
sol::stack_dependencies::operator[]
const int & operator[](std::size_t i) const
Definition: sol.hpp:7083
sol::u_detail::binding::uF
meta::unqualified_t< Fq > uF
Definition: sol.hpp:23458
sol::reference
basic_reference< false > reference
Definition: forward.hpp:1100
sol::stack::unqualified_getter< detail::as_value_tag< T > >::get
static T & get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14231
op
#define op
sol::u_detail::new_index_target_fail
int new_index_target_fail(lua_State *L_, void *)
Definition: sol.hpp:23561
sol::stack::unqualified_getter< std::tuple< Tn... > >::apply
static R apply(std::index_sequence< I, Ix... >, lua_State *L, int index, record &tracking, Args &&... args)
Definition: sol.hpp:14302
sol::type_of
type type_of(lua_State *L, int index)
Definition: sol.hpp:8075
sol::env_key_t
Definition: sol.hpp:7336
sol::optional::take
optional take() &&
\group take
Definition: sol.hpp:5645
sol::basic_thread::basic_thread
basic_thread(const stack_reference &r)
Definition: sol.hpp:28148
sol::load_mode
load_mode
Definition: sol.hpp:7842
sol::basic_table_core::clear
void clear()
Definition: sol.hpp:25805
sol::container_detail::u_c_launch::index_of_call
static int index_of_call(lua_State *L)
Definition: sol.hpp:23083
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::iter::iter
iter(lua_State *L_, int stack_index, T &source, iterator it) noexcept
Definition: sol.hpp:22668
lua_setupvalue
const LUA_API char * lua_setupvalue(lua_State *L, int funcindex, int n)
Definition: lapi.c:1390
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::add_push_back
static detail::error_result add_push_back(std::true_type, lua_State *, T &self, stack_object value, Iter &)
Definition: sol.hpp:22188
sol::state_view::safe_script_file
protected_function_result safe_script_file(const std::string &filename, load_mode mode=load_mode::any)
Definition: sol.hpp:27637
sol::constructor_handler
Definition: sol.hpp:9584
sol::function_detail::overloaded_function::operator()
int operator()(lua_State *L)
Definition: sol.hpp:19644
sol::basic_reference::basic_reference
basic_reference(lua_State *L_, const stack_reference &r) noexcept
Definition: sol.hpp:10506
sol::optional::or_else
optional< T > or_else(F &&f) const &&
\exclude
Definition: sol.hpp:5490
sol::main_safe_function
basic_protected_function< main_reference, false, reference > main_safe_function
Definition: forward.hpp:1163
sol::container_detail::u_c_launch::real_get_traits
static int real_get_traits(std::false_type, lua_State *L)
Definition: sol.hpp:22898
sol::stateless_reference::stateless_reference
stateless_reference(lua_State *L_, const stateless_reference &r) noexcept
Definition: sol.hpp:10214
basic_string_view::data
constexpr auto data() const noexcept -> const Char *
Definition: core.h:457
sol::call_detail::lua_call_wrapper< T, readonly_wrapper< F >, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, readonly_wrapper< F > &&rw)
Definition: sol.hpp:18645
sol::wrap
Definition: sol.hpp:19102
sol::stack_proxy::stack_proxy
stack_proxy()
Definition: sol.hpp:17191
sol::basic_thread::state
state_view state() const
Definition: sol.hpp:28187
sol::optional< T & >::m_value
T * m_value
Definition: sol.hpp:6846
detail::first
auto first(const T &value, const Tail &...) -> const T &
Definition: compile.h:60
sol::stack::top
int top(lua_State *L)
Definition: sol.hpp:11684
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::value_type
typename T::value_type value_type
Definition: sol.hpp:21766
sol::container_detail::u_c_launch::real_get_traits
static int real_get_traits(std::true_type, lua_State *L)
Definition: sol.hpp:22894
sol::meta_function::type
@ type
sol::stack::unqualified_getter< env_key_t >::get
static environment get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:26768
sol::this_main_state::operator->
lua_State * operator->() const noexcept
Definition: sol.hpp:7784
sol::stack::unqualified_pusher< std::function< Signature > >::push
static int push(lua_State *L, std::function< Signature > &&fx)
Definition: sol.hpp:20144
sol::stack::unqualified_checker< detail::as_pointer_tag< T >, type::userdata >::check
static bool check(lua_State *L_, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:12879
sol::basic_usertype::set_fx
void set_fx(types< R(Args...)>, Key &&key, Fx &&fx)
Definition: sol.hpp:26326
luaL_getmetafield
LUALIB_API int luaL_getmetafield(lua_State *L, int obj, const char *event)
Definition: lauxlib.c:845
sol::stack::stack_detail::integer_value_fits
bool integer_value_fits(const T &value)
Definition: sol.hpp:14701
sol::readonly_wrapper
Definition: sol.hpp:17989
sol::detail::is_swappable
Definition: sol.hpp:4903
sol::stack::unqualified_pusher< no_construction >::push
static int push(lua_State *L, no_construction c, function_detail::call_indicator)
Definition: sol.hpp:20284
sol::gc_mode
gc_mode
Definition: sol.hpp:7877
sol::u_detail::maybe_get_usertype_storage_base
optional< usertype_storage_base & > maybe_get_usertype_storage_base(lua_State *L_, int index)
Definition: sol.hpp:24275
sol::basic_table_core::set
basic_table_core & set(Args &&... args)
Definition: sol.hpp:25862
sol::basic_coroutine::m_error_handler
handler_t m_error_handler
Definition: sol.hpp:28485
sol::meta::meta_detail::is_explicitly_dereferenceable_test
decltype(std::declval< T >().operator*()) is_explicitly_dereferenceable_test
Definition: sol.hpp:2060
sol::call_detail::call_wrapped
int call_wrapped(lua_State *L, Fx &&fx, Args &&... args)
Definition: sol.hpp:18933
sol::protected_function
safe_function protected_function
Definition: forward.hpp:1168
sol::state_view::set_function
state_view & set_function(Key &&key, Args &&... args)
Definition: sol.hpp:28015
sol::is_transparent_argument_v
constexpr bool is_transparent_argument_v
Definition: sol.hpp:8116
sol::optional< T & >::reset
void reset() noexcept
Destroys the stored value if one exists, making the optional empty.
Definition: sol.hpp:6841
sol::detail::ebco< T, tag, std::enable_if_t<!std::is_reference_v< T > &&std::is_class_v< T > &&!std::is_final_v< T > > >::value
T && value() &&noexcept
Definition: sol.hpp:7206
sol::this_state::lua_state
lua_State * lua_state() const noexcept
Definition: sol.hpp:7769
sol::stack::stack_detail::not_enough_stack_space_string
constexpr const char * not_enough_stack_space_string
Definition: sol.hpp:11549
sol::stack::stateless_push_popper::m_L
lua_State * m_L
Definition: sol.hpp:10054
lua_geti
LUA_API int lua_geti(lua_State *L, int idx, lua_Integer n)
Definition: lapi.c:689
sol::stateless_reference::reset
void reset(lua_State *L_) noexcept
Definition: sol.hpp:10305
sol::stack::field_getter< std::tuple< Args... >, b, raw, C >::get
void get(lua_State *L, Keys &&keys)
Definition: sol.hpp:16183
sol::meta::supports_op_left_shift
Definition: sol.hpp:2655
sol::stack::push_popper::m_object
T m_object
Definition: sol.hpp:10006
sol::stateless_reference::copy_assign_ref
lua_State * copy_assign_ref(lua_State *L_, lua_State *rL, const stateless_reference &r)
Definition: sol.hpp:10173
sol::state_view::unsafe_script
unsafe_function_result unsafe_script(const string_view &code, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27686
sol::basic_table_core::tuple_set
void tuple_set(std::index_sequence< I... >, Pairs &&pairs)
Definition: sol.hpp:25527
sol::stack::push_popper< true, T, C >::Tu
meta::unqualified_t< T > Tu
Definition: sol.hpp:10023
sol::make_optional
constexpr optional< Ret > make_optional(U &&v)
Definition: sol.hpp:6183
sol::u_detail::binding
Definition: sol.hpp:23457
sol::stack::unqualified_pusher< basic_string_view< Ch, Traits > >::push
static int push(lua_State *L, const basic_string_view< Ch, Traits > &sv)
Definition: sol.hpp:15584
sol::optional::or_else
optional< T > SOL_TL_OPTIONAL_11_CONSTEXPR or_else(F &&f) const &
\exclude
Definition: sol.hpp:5483
sol::u_detail::usertype_storage_base::usertype_storage_base
usertype_storage_base(lua_State *L_)
Definition: sol.hpp:23697
sol::optional< T & >::map_or_else
detail::invoke_result_t< U > map_or_else(F &&f, U &&u) const &&
Definition: sol.hpp:6585
sol::is_actual_type_rebindable_for_v
constexpr bool is_actual_type_rebindable_for_v
Definition: sol.hpp:9322
SOL_ID_SIZE_I_
#define SOL_ID_SIZE_I_
Definition: sol.hpp:608
lua_pushglobaltable
#define lua_pushglobaltable(L)
Definition: lua.h:384
sol::basic_table_core::get
decltype(auto) get(Keys &&... keys) const
Definition: sol.hpp:25812
sol::protected_function_result
Definition: sol.hpp:17228
sol::protected_function_result::size_type
std::size_t size_type
Definition: sol.hpp:17241
call
bool call(const std::string &service_name, MReq &req, MRes &res)
sol::call_status::ok
@ ok
sol::yielding_t::func
T func
Definition: sol.hpp:7344
sol::detail::not_enough_stack_space_string
constexpr const char * not_enough_stack_space_string
Definition: sol.hpp:9510
sol::unsafe_function_result::valid
bool valid() const noexcept
Definition: sol.hpp:17544
sol::stack_iterator::operator-=
stack_iterator & operator-=(difference_type idx)
Definition: sol.hpp:17057
sol::call_detail::lua_call_wrapper< T, readonly_wrapper< F >, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, const readonly_wrapper< F > &rw)
Definition: sol.hpp:18667
sol::basic_lightuserdata::basic_lightuserdata
basic_lightuserdata(stack_reference &&r)
Definition: sol.hpp:28570
sol::has_any_flag
constexpr bool has_any_flag(Left left, Right right) noexcept
Definition: sol.hpp:8694
sol::coroutine
basic_coroutine< reference > coroutine
Definition: forward.hpp:1213
sol::detail::ptr
T * ptr(T *val)
Definition: sol.hpp:2116
sol::detail::accumulate_list
Definition: sol.hpp:8379
sol::stack::unqualified_getter< std::function< Signature > >::get_std_func
static std::function< Signature > get_std_func(types< R... >, lua_State *L, int index)
Definition: sol.hpp:21244
sol::unsafe_function_result::const_reverse_iterator
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: sol.hpp:17454
sol::detail::not_a_number
constexpr const char * not_a_number
Definition: sol.hpp:9501
sol::meta::identity_t
typename identity< T >::type identity_t
Definition: sol.hpp:1432
sol::basic_environment::basic_environment
basic_environment(env_key_t, const basic_reference< b > &extraction_target)
Definition: sol.hpp:26609
sol::lua_value::set_lua_state
static void set_lua_state(lua_State *L)
Definition: sol.hpp:26968
sol::u_detail::usertype_storage_base::clear
void clear()
Definition: sol.hpp:23797
sol::stack_dependencies
Definition: sol.hpp:7068
sol::stack::unqualified_pusher< as_table_t< T > >::push
static int push(lua_State *L, const T &value_)
Definition: sol.hpp:15127
sol::detail::protected_handler::protected_handler
protected_handler(lua_State *L_, const Target &target_)
Definition: sol.hpp:20757
detail::state
state
Definition: core.h:2305
sol::optional::operator=
optional & operator=(optional< U > &&rhs)
Definition: sol.hpp:5824
sol::detail::std_shim::std_shim
std_shim(unsafe_function lua_func)
Definition: sol.hpp:21213
sol::call_detail::lua_call_wrapper< T, property_wrapper< R, W >, is_index, is_variable, checked, boost, clean_stack, C >::P
meta::conditional_t< is_index, R, W > P
Definition: sol.hpp:18801
sol::type::string
@ string
align
Definition: core.h:2016
sol::usertype_proxy::lua_state
lua_State * lua_state() const
Definition: sol.hpp:24704
sol::detail::not_enough_stack_space_environment
constexpr const char * not_enough_stack_space_environment
Definition: sol.hpp:9514
sol::meta::pop_front_type< types< Arg, Args... > >::type
types< Args... > type
Definition: sol.hpp:1500
sol::dump_error::m_ec
int m_ec
Definition: sol.hpp:20545
sol::container_detail::usertype_container_default::index_get
static int index_get(lua_State *L_)
Definition: sol.hpp:21684
sol::stack::unqualified_pusher< policy_wrapper< F, Policies... > >::push
static int push(lua_State *L, P &&p)
Definition: sol.hpp:20424
sol::stack::field_getter
Definition: sol.hpp:11431
sol::detail::implicit_wrapper
Definition: sol.hpp:7291
sol::stack::unqualified_pusher< detail::tagged< T, constructor_list< Lists... > > >::push
static int push(lua_State *L, constructor_list< Lists... >)
Definition: sol.hpp:20309
sol::meta::meta_detail::basic_traits::is_noexcept
static constexpr const bool is_noexcept
Definition: sol.hpp:1553
sol::stack_iterator::stack_iterator
stack_iterator(const stack_iterator< proxy_t, true > &r)
Definition: sol.hpp:17007
sol::new_table
Definition: sol.hpp:7793
sol::pairs_iterator
Definition: sol.hpp:25195
lua_setglobal
LUA_API void lua_setglobal(lua_State *L, const char *name)
Definition: lapi.c:841
sol::basic_coroutine::invoke
protected_function_result invoke(types<>, std::index_sequence<>, std::ptrdiff_t n)
Definition: sol.hpp:28308
sol::stack_guard::stack_guard
stack_guard(lua_State *L, int top, std::function< void(int, int)> fx=detail::stack_fail)
Definition: sol.hpp:10903
sol::meta_function::modulus
@ modulus
sol::safe_function_result
protected_function_result safe_function_result
Definition: forward.hpp:1187
sol::container_detail::u_c_launch::real_empty_call
static int real_empty_call(lua_State *L)
Definition: sol.hpp:23022
sol::detail::deprecate_type
Definition: sol.hpp:21291
sol::meta::meta_detail::basic_traits::function_type
R() function_type(Args...)
Definition: sol.hpp:1563
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::iter::source
T & source
Definition: sol.hpp:21787
sol::member_function_wrapper::traits_type
lua_bind_traits< F > traits_type
Definition: sol.hpp:17762
sol::stack::unqualified_pusher< wchar_t[N]>::push
static int push(lua_State *L, const wchar_t(&str)[N], std::size_t sz)
Definition: sol.hpp:15844
sol::meta::count_for_pack_v
constexpr std::size_t count_for_pack_v
Definition: sol.hpp:2317
sol::detail::std_shim< void >::std_shim
std_shim(unsafe_function lua_func)
Definition: sol.hpp:21226
bytes
Definition: format.h:4101
sol::meta_function::garbage_collect
@ garbage_collect
sol::function_detail::upvalue_member_variable
Definition: sol.hpp:19220
sol::stack::unqualified_pusher< const wchar_t * >
Definition: sol.hpp:15639
sol::stack_iterator::value_type
proxy_t value_type
Definition: sol.hpp:16997
sol::stack_safe_function
basic_protected_function< stack_reference, false, reference > stack_safe_function
Definition: forward.hpp:1165
sol::stack::unqualified_pusher< detail::as_pointer_tag< T > >::push_keyed
static int push_keyed(lua_State *L, K &&k, T *obj)
Definition: sol.hpp:14864
sol::function_detail::upvalue_member_variable::function_type
std::remove_pointer_t< std::decay_t< Function > > function_type
Definition: sol.hpp:19221
sol::stack::unqualified_checker< std::variant< Tn... >, type::poly >::V_is_empty
std::integral_constant< bool, V_size::value==0 > V_is_empty
Definition: sol.hpp:12907
sol::returns_self
returns_self_with returns_self
Definition: sol.hpp:7066
sol::stack::unqualified_getter< as_table_t< T > >::max_size_check
static bool max_size_check(std::true_type, T &cont, std::size_t idx)
Definition: sol.hpp:13607
sol::protected_function_result::cend
const_iterator cend() const
Definition: sol.hpp:17365
sol::stack::unqualified_check_get
decltype(auto) unqualified_check_get(lua_State *L, int index=-lua_size< meta::unqualified_t< T >>::value)
Definition: sol.hpp:11952
sol::container_detail::u_c_launch
Definition: sol.hpp:22842
LUA_GCINC
#define LUA_GCINC
Definition: lua.h:329
sol::unsafe_function_result::operator=
unsafe_function_result & operator=(const unsafe_function_result &)=delete
sol::meta::meta_detail::void_tuple_element_t
typename void_tuple_element< I, T >::type void_tuple_element_t
Definition: sol.hpp:1545
LUA_MULTRET
#define LUA_MULTRET
Definition: lua.h:36
lua_resume
LUA_API int lua_resume(lua_State *L, lua_State *from, int nargs, int *nresults)
Definition: ldo.c:773
sol::automagic_flags
automagic_flags
Definition: sol.hpp:8653
sol::meta::meta_detail::fx_traits
Definition: sol.hpp:1573
sol::stack::set_field
void set_field(lua_State *L, Key &&key, Value &&value)
Definition: sol.hpp:12125
sol::meta_function::power_of
@ power_of
sol::stack_iterator::L
lua_State * L
Definition: sol.hpp:17000
sol::constructor_wrapper::constructor_wrapper
constructor_wrapper(Arg &&arg, Args &&... args)
Definition: sol.hpp:7009
sol::detail::protected_handler::protected_handler
protected_handler(std::false_type, lua_State *L_, const Target &target_)
Definition: sol.hpp:20744
sol::function_detail::overloaded_function::call
static int call(types< Fx >, meta::index_value< I >, types< R... >, types< Args... >, lua_State *L, int, int, overload_list &ol)
Definition: sol.hpp:19631
sol::stack::unqualified_pusher< detail::as_value_tag< T > >::push_fx
static int push_fx(lua_State *L, F &&f, Args &&... args)
Definition: sol.hpp:14808
sol::stack::unqualified_checker< std::pair< A, B >, type::poly >::check
static bool check(lua_State *L_, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:12896
sol::container_detail::usertype_container_default
Definition: sol.hpp:21668
sol::main_reference
basic_reference< true > main_reference
Definition: forward.hpp:1101
sol::is_userdata_v
constexpr bool is_userdata_v
Definition: sol.hpp:8570
sol::table_proxy::get_type
type get_type() const
Definition: sol.hpp:24936
sol::wrap::call
static int call(lua_State *L) noexcept(noexcept(c_call< type, f >(L)))
Definition: sol.hpp:19105
sol::function_detail::upvalue_member_variable::call
static int call(lua_State *L) noexcept(traits_type::is_noexcept)
Definition: sol.hpp:19251
sol::stack::unqualified_getter< std::tuple< Tn... > >::apply
static R apply(std::index_sequence<>, lua_State *, int, record &, Args &&... args)
Definition: sol.hpp:14296
sol::stateless_stack_reference::abandon
void abandon(lua_State *=nullptr) noexcept
Definition: sol.hpp:9729
sol::basic_table_core< true >::is_raw_set_direct_tableless
std::false_type is_raw_set_direct_tableless
Definition: sol.hpp:25483
sol::stack::unqualified_interop_checker::check
static bool check(lua_State *, int, type, Handler &&, record &)
Definition: sol.hpp:12394
sol::table_proxy::operator=
table_proxy && operator=(T &&other) &&
Definition: sol.hpp:24802
sol::detail::ebco< T &&, tag >::ebco
ebco(T &&v) noexcept
Definition: sol.hpp:7241
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::erase_associative_lookup
static detail::error_result erase_associative_lookup(std::true_type, lua_State *, T &self, const K &key)
Definition: sol.hpp:22338
sol::property_wrapper::write
const W & write() const
Definition: sol.hpp:17942
sol::basic_table_core::create
table create(Name &&name, int narr=0, int nrec=0)
Definition: sol.hpp:26102
sol::meta_function::subtraction
@ subtraction
sol::meta::meta_detail::unique_actual_type
Definition: sol.hpp:9167
sol::property
decltype(auto) property(F &&f, G &&g)
Definition: sol.hpp:17956
sol::stack_count
Definition: sol.hpp:7414
sol::script_throw_on_error
protected_function_result script_throw_on_error(lua_State *L, protected_function_result result)
Definition: sol.hpp:27154
sol::operator&=
constexpr automagic_flags & operator&=(automagic_flags &left, automagic_flags right) noexcept
Definition: sol.hpp:8683
sol::detail::debug::print_section
void print_section(const std::string &message, lua_State *L)
Definition: sol.hpp:14691
lua_tostring
#define lua_tostring(L, i)
Definition: lua.h:387
sol::lib::utf8
@ utf8
sol::stack_iterator::reference
meta::conditional_t< is_const, const proxy_t, proxy_t > reference
Definition: sol.hpp:16995
sol::stack::popper::pop
static decltype(auto) pop(lua_State *L)
Definition: sol.hpp:16047
LUA_RIDX_MAINTHREAD
#define LUA_RIDX_MAINTHREAD
Definition: lua.h:84
sol::is_value_semantic_for_function_v
constexpr bool is_value_semantic_for_function_v
Definition: sol.hpp:8442
sol::pairs_iterator::value_type
std::pair< object, object > value_type
Definition: sol.hpp:25202
sol::variadic_args::push
int push(lua_State *target) const
Definition: sol.hpp:28721
sol::reference_hash::operator()
result_type operator()(const basic_reference< lb > &lhs) const noexcept
Definition: sol.hpp:10797
sol::stack_guard::check_stack
bool check_stack(int modification=0) const
Definition: sol.hpp:10905
sol::function_detail::member_function::function_type
std::remove_pointer_t< std::decay_t< Function > > function_type
Definition: sol.hpp:19518
sol::stack_count::stack_count
stack_count(int cnt)
Definition: sol.hpp:7417
luaL_Reg
Definition: lauxlib.h:38
sol::stateless_stack_reference::equals
bool equals(lua_State *L_, lua_nil_t) const noexcept
Definition: sol.hpp:9745
sol::stack::probe_field_getter< std::tuple< Args... >, P, b, raw, C >::apply
probe apply(std::index_sequence< I, I1, In... >, int sofar, lua_State *L, Keys &&keys, int tableindex)
Definition: sol.hpp:16358
sol::basic_object::base_t
basic_object_base< base_type > base_t
Definition: sol.hpp:16823
sol::stateless_reference::stateless_reference
stateless_reference(lua_State *L_, const stack_reference &r) noexcept
Definition: sol.hpp:10239
sol::unsafe_function_result::L
lua_State * L
Definition: sol.hpp:17441
udp_client.default
default
Definition: udp_client.py:10
sol::detail::base_class_check_key
decltype(auto) base_class_check_key()
Definition: sol.hpp:9342
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::find_comparative
static detail::error_result find_comparative(std::false_type, lua_State *, T &)
Definition: sol.hpp:22116
lua_Reader
const typedef char *(* lua_Reader)(lua_State *L, void *ud, size_t *sz)
Definition: lua.h:117
sol::pairs_iterator::operator=
pairs_iterator & operator=(pairs_iterator &&right) noexcept
Definition: sol.hpp:25232
sol::detail::indexed_insert::registration_table
lua_reg_table & registration_table
Definition: sol.hpp:11416
LUA_OK
#define LUA_OK
Definition: lua.h:49
sol::meta::is_pointer_like_v
constexpr bool is_pointer_like_v
Definition: sol.hpp:2068
sol::stack::stack_detail::check_types
bool check_types(lua_State *, int, Handler &&, record &)
Definition: sol.hpp:11983
sol::protected_function_result::abandon
void abandon() noexcept
Definition: sol.hpp:17400
sol::call_syntax::dot
@ dot
sol::stack::stack_detail::metatable_setup::L
lua_State * L
Definition: sol.hpp:23129
sol::meta::call_operator_deducible_v
constexpr bool call_operator_deducible_v
Definition: sol.hpp:1532
sol::stack_reference::stack_reference
stack_reference(lua_State *L, int i) noexcept
Definition: sol.hpp:9759
sol::unsafe_function_result::index
int index
Definition: sol.hpp:17442
sol::detail::debug::print_stack
void print_stack(lua_State *L)
Definition: sol.hpp:14687
LUA_REFNIL
#define LUA_REFNIL
Definition: lauxlib.h:87
sol::container_detail::has_traits_index_of_test
Definition: sol.hpp:21407
sol::function_detail::upvalue_this_member_function::call
static int call(lua_State *L) noexcept(traits_type::is_noexcept)
Definition: sol.hpp:19366
sol::detail::ebco::m_value
T m_value
Definition: sol.hpp:7135
sol::basic_coroutine::invoke
auto invoke(types< Ret... >, std::index_sequence< I... >, std::ptrdiff_t n)
Definition: sol.hpp:28292
luaopen_utf8
LUAMOD_API int() luaopen_utf8(lua_State *L)
Definition: lutf8lib.c:283
sol::protected_function_result::popcount
int popcount
Definition: sol.hpp:17233
std::hash<::sol::optional< T > >::operator()
::std::size_t operator()(const ::sol::optional< T > &o) const
Definition: sol.hpp:6855
sol::stateless_stack_reference::reset
void reset(lua_State *) noexcept
Definition: sol.hpp:9721
sol::basic_object::basic_object
basic_object(detail::no_safety_tag, lua_State *L_, ref_index index_)
Definition: sol.hpp:16837
sol::stack::unqualified_pusher< protected_function_result >::push
static int push(lua_State *L, const protected_function_result &pfr)
Definition: sol.hpp:17417
sol::load_result::L
lua_State * L
Definition: sol.hpp:26814
sol::member_function_wrapper::invoker
Definition: sol.hpp:17785
sol::load_result::load_result
load_result(load_result &&o) noexcept
Definition: sol.hpp:26833
sol::meta::supports_op_equal
Definition: sol.hpp:2649
sol::as_returns
auto as_returns(Source &&source)
Definition: sol.hpp:28799
sol::detail::ref_clean::~ref_clean
~ref_clean()
Definition: sol.hpp:25450
sol::meta::enable_t::_
@ _
sol::optional::value_or
constexpr T value_or(U &&u) const &
Definition: sol.hpp:5987
sol::stack::unqualified_pusher< function_sig< Sigs... > >::push_yielding
static int push_yielding(lua_State *L, Arg0 &&arg0, Args &&... args)
Definition: sol.hpp:20045
sol::stack::unqualified_pusher< std::initializer_list< T > >::push
static int push(lua_State *L, const std::initializer_list< T > &il) noexcept
Definition: sol.hpp:15165
sol::detail::optional_delete_assign_base
Definition: sol.hpp:5175
sol::detail::yield_tag
constexpr yield_tag_t yield_tag
Definition: sol.hpp:7310
sol::u16string_view
std::u16string_view u16string_view
Definition: sol.hpp:2137
sol::stateless_stack_reference
Definition: sol.hpp:9659
sol::stack::stack_detail::uu_pusher::push
static int push(lua_State *L, Arg &&arg, Args &&... args)
Definition: sol.hpp:14896
sol::u_detail::usertype_storage_base::add_entry
void add_entry(string_view sv, index_call_storage ics)
Definition: sol.hpp:23757
sol::pairs_iterator::operator*
reference operator*() noexcept
Definition: sol.hpp:25344
sol::is_lua_reference_v
constexpr bool is_lua_reference_v
Definition: sol.hpp:8100
sol::main_global_table
main_table_core< true > main_global_table
Definition: forward.hpp:1129
sol::stack::unqualified_pusher< nested< T > >::push
static int push(lua_State *L, const nested< T > &nested_wrapper_) noexcept
Definition: sol.hpp:15151
sol::stack::unqualified_pusher< detail::as_value_tag< T > >::push
static int push(lua_State *L)
Definition: sol.hpp:14841
sol::stack_reference::pop
void pop(lua_State *L_, int pop_count_=1) const noexcept
Definition: sol.hpp:9800
sol::stack::record::last
int last
Definition: sol.hpp:11477
sol::basic_protected_function::set_error_handler
void set_error_handler(ErrorHandler_ &&error_handler_) noexcept
Definition: sol.hpp:21067
sol::stack::unqualified_pusher< factory_wrapper< Functions... > >::push
static int push(lua_State *L, factory_wrapper< Functions... > &&fw, function_detail::call_indicator)
Definition: sol.hpp:20270
sol::detail::is_non_factory_constructor_v
constexpr bool is_non_factory_constructor_v
Definition: sol.hpp:8611
sol::stack_reference
Definition: sol.hpp:9750
sol::basic_lua_table::basic_lua_table
basic_lua_table(lua_State *L, int index=-1)
Definition: sol.hpp:26444
sol::lib::base
@ base
sol::stack::field_getter< std::tuple< Args... >, b, raw, C >::get
void get(lua_State *L, Keys &&keys, int tableindex)
Definition: sol.hpp:16188
sol::basic_reference::basic_reference
basic_reference(lua_State *L_, basic_reference< r_main_only > &&r) noexcept
Definition: sol.hpp:10487
config.hpp
sol::table_proxy::set_function
table_proxy && set_function(Args &&... args) &&
Definition: sol.hpp:24785
sol::meta::neg
boolean<!T::value > neg
Definition: sol.hpp:2213
sol::basic_metatable::set_function
basic_metatable & set_function(Key &&key, Args &&... args)
Definition: sol.hpp:26227
sol::protected_function_result::rbegin
reverse_iterator rbegin()
Definition: sol.hpp:17369
sol::call_detail::lua_call_wrapper< T, property_wrapper< R, W >, is_index, is_variable, checked, boost, clean_stack, C >::object_type
meta::unqualified_t< typename traits_type::template arg_at< 0 > > object_type
Definition: sol.hpp:18805
sol::stack::unqualified_getter< std::function< Signature > >::fx_t
meta::bind_traits< Signature > fx_t
Definition: sol.hpp:21239
sol::detail::inheritance::type_check_bases
static bool type_check_bases(types< Base, Args... >, const string_view &ti)
Definition: sol.hpp:9371
sol::meta::is_optional_v
constexpr bool is_optional_v
Definition: sol.hpp:6884
sol::optional< T & >::has_value
constexpr bool has_value() const noexcept
Definition: sol.hpp:6798
sol::meta::meta_detail::callable_traits< R(T::*), true >::free_args_list
types< T, Arg > free_args_list
Definition: sol.hpp:2006
sol::stack::stateless_push_popper< false, T, std::enable_if_t< is_stack_based_v< meta::unqualified_t< T > > > >::~stateless_push_popper
~stateless_push_popper()
Definition: sol.hpp:10097
sol::u_detail::index_call_storage::index
index_call_function * index
Definition: sol.hpp:23441
sol::function_detail::overloaded_function::on_success
Definition: sol.hpp:19637
sol::stack::unqualified_pusher< detail::tagged< T, destructor_wrapper< void > > >::push
static int push(lua_State *L, destructor_wrapper< void >)
Definition: sol.hpp:20368
sol::call_detail::construct
int construct(lua_State *L)
Definition: sol.hpp:18380
sol::detail::unique_fallback< std::unique_ptr< T, D > >::pointer
typename std::unique_ptr< T, D >::pointer pointer
Definition: sol.hpp:9152
sol::stateless_stack_reference_equals::operator()
bool operator()(const stateless_stack_reference &lhs, lua_nil_t rhs) const
Definition: sol.hpp:9875
sol::function_detail::upvalue_member_variable::operator()
int operator()(lua_State *L) noexcept(traits_type::is_noexcept)
Definition: sol.hpp:19273
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::get_category
static detail::error_result get_category(std::random_access_iterator_tag, lua_State *L_, T &self, K &key)
Definition: sol.hpp:21881
sol::type::poly
@ poly
sol::monostate
Used to represent an optional with no data; essentially a bool.
Definition: sol.hpp:4706
sol::detail::attempt_alloc
bool attempt_alloc(lua_State *L, std::size_t ptr_align, std::size_t ptr_size, std::size_t value_align, std::size_t allocated_size, void *&pointer_adjusted, void *&data_adjusted)
Definition: sol.hpp:11138
sol::optional< T & >::swap
void swap(optional &rhs) noexcept
Definition: sol.hpp:6764
sol::container_detail::u_c_launch::real_add_call
static int real_add_call(lua_State *L)
Definition: sol.hpp:22986
sol::basic_environment::base_t
basic_table< base_type > base_t
Definition: sol.hpp:26575
sol::basic_protected_function::handler_t
Handler handler_t
Definition: sol.hpp:20834
sol::container_detail::u_c_launch::real_ipairs_traits
static int real_ipairs_traits(std::true_type, lua_State *L)
Definition: sol.hpp:22942
sol::meta_function::construct
@ construct
sol::function_detail::select
void select(lua_State *L, Fx &&fx, Args &&... args)
Definition: sol.hpp:19973
sol::basic_table_core::basic_table_core
basic_table_core(detail::no_safety_tag, lua_nil_t n)
Definition: sol.hpp:25693
sol::container_detail::u_c_launch::real_index_call
static int real_index_call(lua_State *L)
Definition: sol.hpp:22855
sol::basic_protected_function::basic_protected_function
basic_protected_function(lua_State *L_, int index_, handler_t eh)
Definition: sol.hpp:20921
sol::meta::meta_detail::adl_sol_lua_interop_get_test_t
decltype(sol_lua_interop_get(types< T >(), static_cast< lua_State * >(nullptr), -1, static_cast< void * >(nullptr), std::declval< stack::record & >())) adl_sol_lua_interop_get_test_t
Definition: sol.hpp:11503
sol::wrapper< F, std::enable_if_t< std::is_member_object_pointer< meta::unqualified_t< F > >::value > >::traits_type
lua_bind_traits< meta::unqualified_t< F > > traits_type
Definition: sol.hpp:17704
nonstd::span_lite::size_t
span_CONFIG_SIZE_TYPE size_t
Definition: span.hpp:576
sol::optional< T & >::map_or
U map_or(F &&f, U &&u) &
Maps the stored value with f if there is one, otherwise returns u.
Definition: sol.hpp:6526
sol::stack::stack_detail::push_reference
int push_reference(lua_State *L, Arg &&arg, Args &&... args)
Definition: sol.hpp:11803
sol::basic_function::dump
int dump(lua_Writer writer, void *userdata, bool strip=false) const
Definition: sol.hpp:20685
sol::stack::unqualified_check_getter< std::variant< Tn... >, C >::get_one
static optional< V > get_one(std::integral_constant< std::size_t, I >, lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:14517
sol::meta::at_in_pack_t
typename at_in_pack< I, Args... >::type at_in_pack_t
Definition: sol.hpp:2283
sol::detail::is_msvc_callable_rigged_v
constexpr bool is_msvc_callable_rigged_v
Definition: sol.hpp:8417
sol::stack::unqualified_pusher< wchar_t * >::push
static int push(lua_State *L, const wchar_t *str)
Definition: sol.hpp:15664
sol::stack::stack_detail::get_as_upvalues_using_function
std::pair< T, int > get_as_upvalues_using_function(lua_State *L, int function_index=-1)
Definition: sol.hpp:16468
sol::basic_function::basic_function
basic_function(lua_State *L, int index=-1)
Definition: sol.hpp:20660
sol::stack::unqualified_pusher< lua_nil_t >::push
static int push(lua_State *L, lua_nil_t) noexcept
Definition: sol.hpp:15173
sol::basic_protected_function::invoke
protected_function_result invoke(types<>, std::index_sequence<>, std::ptrdiff_t n, detail::protected_handler< b, handler_t > &h) const
Definition: sol.hpp:21109
sol::stack::unqualified_getter< const void * >::get
static const void * get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14184
sol::state_view::L
lua_State * L
Definition: sol.hpp:27239
sol::this_state::this_state
this_state(lua_State *Ls)
Definition: sol.hpp:7758
sol::stack::record::record
record() noexcept
Definition: sol.hpp:11480
sol::stack::raw_set_field
void raw_set_field(lua_State *L, Key &&key, Value &&value, int tableindex)
Definition: sol.hpp:12140
lua_replace
#define lua_replace(L, idx)
Definition: lua.h:394
sol::u_detail::make_string_view
auto make_string_view(base_classes_tag)
Definition: sol.hpp:23289
sol::container_detail::u_c_launch::real_size_traits
static int real_size_traits(std::true_type, lua_State *L)
Definition: sol.hpp:22966
sol::stack_count::count
int count
Definition: sol.hpp:7415
sol::optional::operator*
constexpr const T & operator*() const &
Definition: sol.hpp:5909
sol::unsafe_function_result
Definition: sol.hpp:17439
sol::stack::unqualified_pusher< user< T > >::push
static int push(lua_State *L, no_metatable_t, const user< T > &u)
Definition: sol.hpp:15369
sol::detail::static_trampoline
int static_trampoline(lua_State *L)
Definition: sol.hpp:8825
sol::unsafe_function_result::crend
const_reverse_iterator crend() const
Definition: sol.hpp:17536
sol::u_detail::binding::binding
binding(Args &&... args)
Definition: sol.hpp:23468
sol::base::type
types type
Definition: sol.hpp:1299
sol::basic_function::basic_function
basic_function(const stack_reference &r)
Definition: sol.hpp:20646
sol::stack::unqualified_getter< as_table_t< T > >::push_back_at_end
static void push_back_at_end(std::true_type, types< V >, lua_State *L, T &cont, std::size_t)
Definition: sol.hpp:13583
sol::detail::swallow
std::initializer_list< int > swallow
Definition: sol.hpp:1460
sol::stack::unqualified_pusher< destructor_wrapper< Fx > >::push
static int push(lua_State *L, const destructor_wrapper< Fx > &c)
Definition: sol.hpp:20403
sol::set_default_state
void set_default_state(lua_State *L, lua_CFunction panic_function=&default_at_panic, lua_CFunction traceback_function=c_call< decltype(&default_traceback_error_handler), &default_traceback_error_handler >, exception_handler_function exf=detail::default_exception_handler)
Definition: sol.hpp:27132
lua_getfield
LUA_API int lua_getfield(lua_State *L, int idx, const char *k)
Definition: lapi.c:683
sol::state_view::create_table
static table create_table(lua_State *L, int narr=0, int nrec=0)
Definition: sol.hpp:28057
sol::detail::aligned_space_for
constexpr std::size_t aligned_space_for()
Definition: sol.hpp:10992
sol::stack::unqualified_pusher< lua_value >::push
static int push(lua_State *L, lua_value &&lv)
Definition: sol.hpp:27054
sol::stack::stack_detail::push_function
Definition: sol.hpp:16009
sol::stack::unqualified_pusher< detail::tagged< T, constructor_wrapper< Fxs... > > >::push
static int push(lua_State *L, constructor_wrapper< Fxs... > &&c)
Definition: sol.hpp:20334
sol::basic_coroutine::basic_coroutine
basic_coroutine(lua_State *L, ref_index index, handler_t eh)
Definition: sol.hpp:28438
sol::detail::default_chunk_name
const std::string & default_chunk_name()
Definition: sol.hpp:16391
sol::stack::probe_field_getter< std::tuple< Args... >, P, b, raw, C >::apply
probe apply(std::index_sequence< I >, int sofar, lua_State *L, Keys &&keys, int tableindex)
Definition: sol.hpp:16352
sol::function_detail::call_wrapper_variable
int call_wrapper_variable(std::true_type, lua_State *L)
Definition: sol.hpp:19030
sol::detail::tagged::value
T & value() &
Definition: sol.hpp:6977
sol::call_detail::overload_match
int overload_match(Match &&matchfx, lua_State *L, int start, Args &&... args)
Definition: sol.hpp:18348
sol::stack::stack_detail::strip< non_null< T > >::type
T type
Definition: sol.hpp:11569
sol::basic_protected_function::basic_protected_function
basic_protected_function(const basic_function< base_t > &b)
Definition: sol.hpp:20874
sol::non_null
Definition: sol.hpp:7369
sol::thread_status::ok
@ ok
sol::basic_pairs_range::cend
pairs_sentinel cend() const noexcept
Definition: sol.hpp:25424
sol::meta::unwrap_unqualified_t
typename unwrap_unqualified< T >::type unwrap_unqualified_t
Definition: sol.hpp:2173
sol::basic_metatable::basic_metatable
basic_metatable(detail::no_safety_tag, lua_State *L, ref_index index)
Definition: sol.hpp:26143
sol::initializers
auto initializers(Functions &&... functions)
Definition: sol.hpp:7014
sol::operator|=
constexpr automagic_flags & operator|=(automagic_flags &left, automagic_flags right) noexcept
Definition: sol.hpp:8678
sol::detail::conjunction
Definition: sol.hpp:4730
sol::stack::unqualified_getter< as_table_t< T > >::insert_at_end
static void insert_at_end(std::true_type, types< V >, lua_State *L, T &cont, std::size_t)
Definition: sol.hpp:13593
sol::clear_flags
constexpr auto clear_flags(Left left, Right right) noexcept
Definition: sol.hpp:8699
sol::meta::has_insert_after
meta::boolean< meta_detail::has_insert_after_test< T >::value > has_insert_after
Definition: sol.hpp:2709
sol::basic_table_core::basic_table_core
basic_table_core(stack_reference &&r)
Definition: sol.hpp:25723
sol::basic_reference::operator=
basic_reference & operator=(const lua_nil_t &) noexcept
Definition: sol.hpp:10579
sol::meta::identity
Definition: sol.hpp:1427
sol::stack::stack_detail::uu_pusher::push_deep
static int push_deep(lua_State *L, Args &&... args)
Definition: sol.hpp:14909
sol::stack_guard::on_mismatch
std::function< void(int, int)> on_mismatch
Definition: sol.hpp:10899
sol::protect_t
Definition: forward.hpp:1250
sol::state_view::is_gc_on
bool is_gc_on() const
Definition: sol.hpp:27857
sol::stack::unqualified_pusher< constructor_wrapper< F, Fxs... > >::push
static int push(lua_State *L, const constructor_wrapper< F, Fxs... > &c)
Definition: sol.hpp:20353
sol::basic_coroutine::status
call_status status() const noexcept
Definition: sol.hpp:28446
sol::adl_barrier_detail::tie
tie_t< std::remove_reference_t< Tn >... > tie(Tn &&... argn)
Definition: sol.hpp:10868
sol::closure<>::upvalues
int upvalues
Definition: sol.hpp:7544
sol::stack::unqualified_pusher< char16_t >::push
static int push(lua_State *L, char16_t c)
Definition: sol.hpp:15884
sol::stack::unqualified_check_getter< std::variant< Tn... >, C >::V
std::variant< Tn... > V
Definition: sol.hpp:14492
sol::basic_protected_function::basic_protected_function
basic_protected_function(lua_State *L_, raw_index index_)
Definition: sol.hpp:20935
sol::function_detail::upvalue_member_variable< T, readonly_wrapper< Function > >::real_call
static int real_call(lua_State *L) noexcept(traits_type::is_noexcept)
Definition: sol.hpp:19289
sol::base_list
Definition: sol.hpp:9330
sol::basic_userdata::basic_userdata
basic_userdata(lua_State *L, ref_index index)
Definition: sol.hpp:28536
LUA_TSTRING
#define LUA_TSTRING
Definition: lua.h:69
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::clear_has
static void clear_has(std::false_type, lua_State *L_, T &)
Definition: sol.hpp:22394
sol::detail::yield_tag_t
Definition: sol.hpp:7309
sol::u_detail::maybe_as_usertype_storage_base
optional< usertype_storage_base & > maybe_as_usertype_storage_base(lua_State *L, int index)
Definition: sol.hpp:24256
sol::reference_equals::operator()
bool operator()(const basic_reference< lb > &lhs, const basic_reference< rb > &rhs) const noexcept
Definition: sol.hpp:10762
sol::detail::reserve
void reserve(std::basic_string< T, Tr, Al > &str, std::size_t hint)
Definition: sol.hpp:11373
sol::stack::coroutine_create_guard
void coroutine_create_guard(lua_State *L)
Definition: sol.hpp:11694
sol::meta::function_args_t
typename bind_traits< Signature >::args_list function_args_t
Definition: sol.hpp:2035
luaL_buffinit
LUALIB_API void luaL_buffinit(lua_State *L, luaL_Buffer *B)
Definition: lauxlib.c:629
basic_string_view
Definition: core.h:415
sol::detail::as_reference_tag
Definition: sol.hpp:10934
sol::stack_dependencies::operator[]
int & operator[](std::size_t i)
Definition: sol.hpp:7079
sol::container_detail::usertype_container_default::get
static int get(lua_State *L_)
Definition: sol.hpp:21680
sol::basic_coroutine::basic_coroutine
basic_coroutine(const basic_function< base_t > &b, handler_t eh) noexcept
Definition: sol.hpp:28363
sol::meta::meta_detail::has_internal_marker_impl
Definition: sol.hpp:1439
LUA_TTABLE
#define LUA_TTABLE
Definition: lua.h:70
sol::variadic_args::end
const_iterator end() const
Definition: sol.hpp:28688
sol::basic_object::basic_object
basic_object(lua_State *L_, raw_index index_) noexcept
Definition: sol.hpp:16881
LUA_GCISRUNNING
#define LUA_GCISRUNNING
Definition: lua.h:327
sol::function_detail::member_function::args_lists
meta::function_args_t< function_type > args_lists
Definition: sol.hpp:19520
sol::optional< T & >::optional
constexpr optional() noexcept
Definition: sol.hpp:6677
lua_pushthread
LUA_API int lua_pushthread(lua_State *L)
Definition: lapi.c:618
sol::detail::ebco::ebco
ebco(Arg &&arg, Args &&... args) noexcept(std::is_nothrow_constructible_v< T, Arg, Args... >)
Definition: sol.hpp:7156
sol::meta::meta_detail::is_probably_stateless_lambda
Definition: sol.hpp:2022
sol::global_tag_t
Definition: sol.hpp:7333
s
XmlRpcServer s
sol::detail::optional_storage_base::dummy
Definition: sol.hpp:4940
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::insert_has
static detail::error_result insert_has(std::true_type, lua_State *L_, T &self, stack_object key, stack_object value)
Definition: sol.hpp:22296
sol::optional::optional
optional(const optional< U > &rhs)
Definition: sol.hpp:5723
LUA_GCGEN
#define LUA_GCGEN
Definition: lua.h:328
sol::container_detail::has_traits_clear
has_clear< T > has_traits_clear
Definition: sol.hpp:21611
sol::stack_table_core
basic_table_core< b, stack_reference > stack_table_core
Definition: forward.hpp:1123
sol::meta::meta_detail::basic_traits::returns_list
tuple_types< R > returns_list
Definition: sol.hpp:1562
sol::meta::meta_detail::callable_traits< R(T::*), true >::args_tuple
std::tuple< Arg > args_tuple
Definition: sol.hpp:2004
sol::u_detail::usertype_storage_base::base_walk_index
static void base_walk_index(lua_State *L_, usertype_storage_base &self, bool &keep_going, int &base_result)
Definition: sol.hpp:23848
detail::uintptr_t
uint128_t uintptr_t
Definition: format.h:444
sol::u_detail::binding_data_equals::binding_data
void * binding_data
Definition: sol.hpp:23665
sol::container_detail::has_traits_find_test
Definition: sol.hpp:21395
sol::stack::unqualified_getter< char32_t >::get
static char32_t get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14064
sol::detail::unique_is_null
bool unique_is_null(lua_State *L_, T &value_) noexcept(unique_is_null_noexcept< std::remove_cv_t< T >>())
Definition: sol.hpp:9267
sol::usertype_traits::user_metatable
static const std::string & user_metatable()
Definition: sol.hpp:9098
sol::load_result::returncount
int returncount
Definition: sol.hpp:26816
sol::u_detail::binding::call_
static int call_(lua_State *L_)
Definition: sol.hpp:23483
sol::stateless_reference_hash::stateless_reference_hash
stateless_reference_hash(lua_State *L_) noexcept
Definition: sol.hpp:10782
sol::stack::stateless_push_popper< true, T, C >::~stateless_push_popper
~stateless_push_popper()
Definition: sol.hpp:10081
sol::basic_table_core::add
basic_table_core & add(Args &&... args)
Definition: sol.hpp:26038
sol::u_detail::usertype_storage_base::new_index_target_set
static int new_index_target_set(lua_State *L, void *target)
Definition: sol.hpp:23979
sol::meta::supports_adl_to_string
Definition: sol.hpp:2658
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::size_has
static auto size_has(std::false_type, lua_State *L_, T &self)
Definition: sol.hpp:22382
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::set_category
static detail::error_result set_category(std::random_access_iterator_tag, lua_State *L_, T &self, stack_object okey, stack_object value)
Definition: sol.hpp:21954
sol::basic_table_core::basic_table_core
basic_table_core(lua_State *L, int index=-1)
Definition: sol.hpp:25742
sol::stack::unqualified_pusher< char[N]>::push
static int push(lua_State *L, const char(&str)[N], std::size_t sz)
Definition: sol.hpp:15454
sol::meta::has_push_back
meta::boolean< meta_detail::has_push_back_test< T >::value > has_push_back
Definition: sol.hpp:2697
lua_pushinteger
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
Definition: lapi.c:507
sol::basic_table_core::traverse_raw_set
basic_table_core & traverse_raw_set(Keys &&... keys)
Definition: sol.hpp:25909
sol::u_detail::usertype_storage_base::named_index_table
stateless_reference named_index_table
Definition: sol.hpp:23687
sol::stack_dependencies::stack_indices
std::array< int, 64 > stack_indices
Definition: sol.hpp:7070
sol::detail::as_table_tag
Definition: sol.hpp:10942
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::iter::index
std::size_t index
Definition: sol.hpp:21789
X
#define X(name, r, bit)
Definition: zstd.c:4805
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::get_comparative
static detail::error_result get_comparative(std::false_type, lua_State *, T &, K &)
Definition: sol.hpp:21905
sol::detail::swap_adl_tests::is_adl_swap_noexcept
Definition: sol.hpp:4899
sol::nested::nested_type
T nested_type
Definition: sol.hpp:7613
LUA_ERRERR
#define LUA_ERRERR
Definition: lua.h:54
sol::stack::unqualified_pusher< const char16_t * >::push
static int push(lua_State *L, const char16_t *u16str, std::size_t sz)
Definition: sol.hpp:15710
sol::container_detail::u_c_launch::real_set_traits
static int real_set_traits(std::false_type, lua_State *L)
Definition: sol.hpp:22910
sol::container_detail::u_c_launch::real_insert_traits
static int real_insert_traits(std::true_type, lua_State *L)
Definition: sol.hpp:22990
sol::unicode::decoded_result
Definition: sol.hpp:13070
sol::global_tag
struct sol::global_tag_t global_tag
sol::basic_lua_table
Definition: forward.hpp:1134
sol::u_detail::maybe_get_usertype_storage_base_inside
optional< usertype_storage_base & > maybe_get_usertype_storage_base_inside(lua_State *L, int index)
Definition: sol.hpp:24264
sol::detail::property_always_true
bool property_always_true(meta_function)
Definition: sol.hpp:11377
sol::optional::map_or
U map_or(F &&f, U &&u) const &&
\group map_or
Definition: sol.hpp:5532
sol::optional< T & >::or_else
optional< T > SOL_TL_OPTIONAL_11_CONSTEXPR or_else(F &&f) const &
\exclude
Definition: sol.hpp:6496
sol::unsafe_function_result::iterator
stack_iterator< stack_proxy, false > iterator
Definition: sol.hpp:17451
sol::closure::upvalues
std::tuple< Upvalues... > upvalues
Definition: sol.hpp:7536
sol::state_view::require_core
object require_core(const std::string &key, Fx &&action, bool create_global=true)
Definition: sol.hpp:27284
luaL_loadbufferx
LUALIB_API int luaL_loadbufferx(lua_State *L, const char *buff, size_t size, const char *name, const char *mode)
Definition: lauxlib.c:828
sol::as_table_t::as_table_t
as_table_t(Arg &&arg, Args &&... args) noexcept(std::is_nothrow_constructible_v< base_t, Arg, Args... >)
Definition: sol.hpp:7592
sol::detail::ebco< T &&, tag >::value
T & value() &noexcept
Definition: sol.hpp:7246
sol::optional::disjunction
constexpr optional disjunction(optional &&rhs) const &
\group disjunction
Definition: sol.hpp:5613
sol::stack::unqualified_getter< void * >::get
static void * get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14176
sol::basic_reference::pop
void pop() const noexcept
Definition: sol.hpp:10614
sol::detail::protected_handler::~protected_handler
~protected_handler()
Definition: sol.hpp:20764
sol::container_detail::u_c_launch::real_new_index_call
static int real_new_index_call(lua_State *L)
Definition: sol.hpp:22926
sol::container_detail::has_traits_pairs
meta::boolean< has_traits_pairs_test< T >::value > has_traits_pairs
Definition: sol.hpp:21596
sol::lib::string
@ string
lua_Writer
int(* lua_Writer)(lua_State *L, const void *p, size_t sz, void *ud)
Definition: lua.h:119
sol::function_detail::upvalue_free_function::function_type
std::remove_pointer_t< std::decay_t< Function > > function_type
Definition: sol.hpp:19130
sol::is_stack_table_v
constexpr bool is_stack_table_v
Definition: sol.hpp:8551
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::end
static iterator end(lua_State *, T &self)
Definition: sol.hpp:22820
sol::variadic_args::value_type
stack_proxy value_type
Definition: sol.hpp:28642
sol::stateless_stack_reference_hash::lua_state
lua_State * lua_state() const noexcept
Definition: sol.hpp:9907
sol::detail::ebco< T &&, tag >::value
T && value() &&noexcept
Definition: sol.hpp:7254
sol::optional::operator*
SOL_TL_OPTIONAL_11_CONSTEXPR T & operator*() &
Definition: sol.hpp:5903
lua_getinfo
LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar)
Definition: ldebug.c:382
sol::optional::value
SOL_TL_OPTIONAL_11_CONSTEXPR T & value() &
Definition: sol.hpp:5940
sol::detail::void_t
typename voider< Ts... >::type void_t
Definition: sol.hpp:4804
sol::u_detail::string_for_each_metatable_func::idx_call
lua_CFunction idx_call
Definition: sol.hpp:23580
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::find_has_associative_lookup
static detail::error_result find_has_associative_lookup(std::true_type, lua_State *L_, T &self)
Definition: sol.hpp:22052
sol::meta::meta_detail::basic_traits::arity
static constexpr std::size_t arity
Definition: sol.hpp:1556
sol::variadic_args::rend
reverse_iterator rend()
Definition: sol.hpp:28701
sol::u_detail::update_bases_func::change_indexing
change_indexing_mem_func change_indexing
Definition: sol.hpp:23651
sol::yielding
yielding_t< std::decay_t< F > > yielding(F &&f)
Definition: sol.hpp:7362
sol::stack_iterator::operator->
pointer operator->()
Definition: sol.hpp:17020
sol::u_detail::destroy_usertype_storage
int destroy_usertype_storage(lua_State *L) noexcept
Definition: sol.hpp:24219
sol::env_key
constexpr env_key_t env_key
Definition: sol.hpp:7337
sol::container_detail::u_c_launch::real_set_traits
static int real_set_traits(std::true_type, lua_State *L)
Definition: sol.hpp:22906
sol::stack_dependencies::target
int target
Definition: sol.hpp:7069
sol::stack_aligned_stack_handler_function
basic_protected_function< stack_reference, true, stack_reference > stack_aligned_stack_handler_function
Definition: forward.hpp:1183
luaL_ref
LUALIB_API int luaL_ref(lua_State *L, int t)
Definition: lauxlib.c:660
sol::state_view::set
state_view & set(Args &&... args)
Definition: sol.hpp:27966
sol::tie_t::set_extra
void set_extra(std::true_type, std::index_sequence< I... >, T &&target)
Definition: sol.hpp:10841
sol::stack_reference::pointer
const void * pointer() const noexcept
Definition: sol.hpp:9804
sol::protected_function_result::iterator
stack_iterator< stack_proxy, false > iterator
Definition: sol.hpp:17242
sol::u_detail::simple_usertype_storage_index
constexpr const int simple_usertype_storage_index
Definition: sol.hpp:23253
sol::detail::as_unique_tag
Definition: sol.hpp:10940
sol::state_view::iterator
typename global_table::iterator iterator
Definition: sol.hpp:27306
LUA_GCSTEP
#define LUA_GCSTEP
Definition: lua.h:324
sol::unsafe_function_result::rbegin
reverse_iterator rbegin()
Definition: sol.hpp:17521
sol::optional
Definition: forward.hpp:1291
sol::basic_lightuserdata::basic_lightuserdata
basic_lightuserdata(lua_State *L, ref_index index)
Definition: sol.hpp:28586
sol::stack::unqualified_pusher< detail::as_unique_tag< T > >::push
static int push(lua_State *L, Args &&... args)
Definition: sol.hpp:14938
lua_rawgetp
LUA_API int lua_rawgetp(lua_State *L, int idx, const void *p)
Definition: lapi.c:746
sol::table_proxy::set_function
table_proxy & set_function(Args &&... args) &
Definition: sol.hpp:24779
sol::basic_lightuserdata
Definition: forward.hpp:1201
sol::basic_pairs_range::end
pairs_sentinel end() const noexcept
Definition: sol.hpp:25420
sol::call_detail::void_call
Definition: sol.hpp:18152
sol::push_invoke_t
Definition: sol.hpp:7694
sol::lua_size_v
constexpr int lua_size_v
Definition: sol.hpp:8405
sol::protected_function_result::pop_count
int pop_count() const noexcept
Definition: sol.hpp:17397
sol::u_detail::submetatable_type
submetatable_type
Definition: sol.hpp:23260
sol::basic_lightuserdata::base_t
basic_object_base< base_type > base_t
Definition: sol.hpp:28547
sol::stack_reference_equals::operator()
bool operator()(const stack_reference &lhs, const lua_nil_t &rhs) const
Definition: sol.hpp:9890
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::add_insert_after
static detail::error_result add_insert_after(std::true_type, lua_State *L_, T &self, stack_object value)
Definition: sol.hpp:22158
sol::protected_function_result::operator[]
stack_proxy operator[](difference_type index_offset) const
Definition: sol.hpp:17346
sol::basic_metatable::basic_metatable
basic_metatable(detail::no_safety_tag, lua_nil_t n)
Definition: sol.hpp:26139
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::pairs
static int pairs(lua_State *L_)
Definition: sol.hpp:22637
sol::container_detail::has_traits_index_set_test
Definition: sol.hpp:21443
sol::detail::default_handler_name
const char(& default_handler_name())[9]
Definition: sol.hpp:20733
sol::function_detail::upvalue_free_function::real_call
static int real_call(lua_State *L) noexcept(traits_type::is_noexcept)
Definition: sol.hpp:19133
sol::detail::is_destructor
Definition: sol.hpp:8635
sol::state_view::set_function
state_view & set_function(Key &&key, Args &&... args)
Definition: sol.hpp:28021
QwtTriangle::Right
@ Right
Definition: qwt_symbol.cpp:42
sol::stack_reference::get_type
type get_type() const noexcept
Definition: sol.hpp:9808
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::size_start
static std::size_t size_start(lua_State *L_, T &self)
Definition: sol.hpp:22427
sol::optional< T & >::conjunction
constexpr optional< typename std::decay< U >::type > conjunction(U &&u) const
Definition: sol.hpp:6592
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::get_src
static auto & get_src(lua_State *L_)
Definition: sol.hpp:21798
right
lu_byte right
Definition: lparser.c:1227
sol::basic_coroutine::runnable
bool runnable() const noexcept
Definition: sol.hpp:28455
sol::reference_equals::operator()
bool operator()(const basic_reference< lb > &lhs, const stack_reference &rhs) const noexcept
Definition: sol.hpp:10767
sol::types::indices
std::make_index_sequence< sizeof...(Args)> indices
Definition: forward.hpp:1261
lua_remove
#define lua_remove(L, idx)
Definition: lua.h:392
sol::basic_protected_function
Definition: forward.hpp:1159
sol::container_detail::has_traits_add
meta::boolean< has_traits_add_test< T >::value > has_traits_add
Definition: sol.hpp:21605
sol::container_detail::usertype_container_default::empty
static int empty(lua_State *L_)
Definition: sol.hpp:21721
sol::stack::unqualified_getter< std::reference_wrapper< T > >::get
static T & get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14267
sol::usertype_proxy::valid
bool valid() const
Definition: sol.hpp:24678
sol::meta::has_max_size
meta::boolean< meta_detail::has_max_size_test< T >::value > has_max_size
Definition: sol.hpp:2700
sol::meta::meta_detail::is_rebind_actual_type
meta::is_detected< is_rebind_actual_type_test_t, T, Element > is_rebind_actual_type
Definition: sol.hpp:9305
LUA_FILEHANDLE
#define LUA_FILEHANDLE
Definition: lauxlib.h:234
sol::stack::unqualified_pusher< detail::as_pointer_tag< T > >::U
meta::unqualified_t< T > U
Definition: sol.hpp:14848
sol::container_detail::u_c_launch::ipairs_call
static int ipairs_call(lua_State *L)
Definition: sol.hpp:23095
sol::nested::nested
nested(meta::unqualified_t< T > &&obj) noexcept(std::is_nothrow_constructible_v< base_t, meta::unqualified_t< T > && >)
Definition: sol.hpp:7622
sol::detail::fail_on_newindex
int fail_on_newindex(lua_State *L_)
Definition: sol.hpp:25455
sol::protected_function_result::lua_state
lua_State * lua_state() const noexcept
Definition: sol.hpp:17388
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::find
static int find(std::false_type, lua_State *L_)
Definition: sol.hpp:22708
SOL_IS_ON
#define SOL_IS_ON(OP_SYMBOL)
Definition: sol.hpp:56
sol::tie_size
Definition: sol.hpp:10816
sol::detail::ebco< T, tag, std::enable_if_t<!std::is_reference_v< T > &&std::is_class_v< T > &&!std::is_final_v< T > > >::operator=
ebco & operator=(const T &v) noexcept(std::is_nothrow_copy_assignable_v< T >)
Definition: sol.hpp:7189
sol::basic_reference::basic_reference
basic_reference(lua_State *L_, const basic_reference< r_main_only > &r) noexcept
Definition: sol.hpp:10469
sol::detail::make_chunk_name
const char * make_chunk_name(const string_view &code, const std::string &chunkname, char(&basechunkname)[N])
Definition: sol.hpp:16397
sol::meta_function::involution
@ involution
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::add_insert_after
static detail::error_result add_insert_after(std::false_type, lua_State *L_, T &self, stack_object value, Iter &)
Definition: sol.hpp:22144
sol::variadic_args::leftover_count
int leftover_count() const
Definition: sol.hpp:28752
sol::basic_reference::reset
void reset() noexcept
Definition: sol.hpp:10594
sol::unicode::unicode_detail::decode
static constexpr char32_t decode(unsigned char b0, unsigned char b1, unsigned char b2, unsigned char b3)
Definition: sol.hpp:13144
sol::basic_reference::basic_reference
basic_reference(basic_reference &&o) noexcept
Definition: sol.hpp:10545
sol::default_constructor
const auto default_constructor
Definition: sol.hpp:6997
sol::basic_coroutine::basic_coroutine
basic_coroutine(basic_coroutine &&other) noexcept
Definition: sol.hpp:28347
sol::stack::unqualified_getter< nested< T > >::get
static T get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:13891
sol::stack::unqualified_pusher< wchar_t * >::push
static int push(lua_State *L, const wchar_t *strb, const wchar_t *stre)
Definition: sol.hpp:15670
sol::stack::probe
Definition: sol.hpp:11464
sol::meta::meta_detail::basic_traits::free_function_type
meta::conditional_t< std::is_void< T >::value, R(Args...), R(first_type, Args...)> free_function_type
Definition: sol.hpp:1565
sol::stack_coroutine
basic_coroutine< stack_reference > stack_coroutine
Definition: forward.hpp:1223
sol::default_destructor
const destructor_wrapper< void > default_destructor
Definition: sol.hpp:7041
sol::basic_table_core< true >::is_raw_get_direct_tableless
std::false_type is_raw_get_direct_tableless
Definition: sol.hpp:25477
sol::stack::stack_detail::set_undefined_methods_on
void set_undefined_methods_on(stack_reference)
Definition: sol.hpp:23384
sol::u_detail::string_for_each_metatable_func::operator()
void operator()(lua_State *L_, submetatable_type smt_, stateless_reference &fast_index_table_)
Definition: sol.hpp:23583
sol::basic_protected_function::dump
Container dump(Fx &&on_error) const
Definition: sol.hpp:20978
sol::detail::default_destroy
Definition: sol.hpp:6936
sol::stack::stack_detail::undefined_metatable::on_new_table
undefined_method_func on_new_table
Definition: sol.hpp:11665
lua_pop
#define lua_pop(L, n)
Definition: lua.h:365
sol::detail::no_safety
struct sol::detail::no_safety_tag no_safety
sol::script_default_on_error
protected_function_result script_default_on_error(lua_State *L, protected_function_result pfr)
Definition: sol.hpp:27212
sol::u_detail::usertype_storage::index_call_with_bases
static int index_call_with_bases(lua_State *L)
Definition: sol.hpp:24037
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::add_insert_after
static detail::error_result add_insert_after(std::true_type, lua_State *, T &self, stack_object value, Iter &pos)
Definition: sol.hpp:22153
sol::stack_table
stack_table_core< false > stack_table
Definition: forward.hpp:1130
sol::stack::stack_detail::count_code_units_utf::operator()
void operator()(const unicode::encoded_result< Ch > er)
Definition: sol.hpp:13368
sol::optional< T & >::operator=
optional & operator=(U &&u)
Definition: sol.hpp:6730
sol::protected_function_result::const_reverse_iterator
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: sol.hpp:17245
sol::function_detail::upvalue_this_member_variable::real_call
static int real_call(lua_State *L) noexcept(std::is_nothrow_copy_assignable_v< T >)
Definition: sol.hpp:19403
sol::stack::push_popper_n::pop_count
int pop_count
Definition: sol.hpp:9985
sol::new_table::map_hint
int map_hint
Definition: sol.hpp:7795
sol::container_detail::has_traits_index_get_test
Definition: sol.hpp:21455
sol::unsafe_function_result::rend
const_reverse_iterator rend() const
Definition: sol.hpp:17530
sol::meta::unwrapped< std::reference_wrapper< T > >::type
T type
Definition: sol.hpp:2163
sol::detail::ebco< T, tag, std::enable_if_t<!std::is_reference_v< T > &&std::is_class_v< T > &&!std::is_final_v< T > > >::operator=
ebco & operator=(T &&v) noexcept(std::is_nothrow_move_assignable_v< T >)
Definition: sol.hpp:7193
sol::call_detail::lua_call_wrapper< T, constructor_wrapper< Cxs... >, is_index, is_variable, checked, boost, clean_stack, C >::onmatch::operator()
int operator()(types< Fx >, meta::index_value< I >, types< R... > r, types< Args... > a, lua_State *L, int, int start, F &f)
Definition: sol.hpp:18724
sol::stack::stack_detail::copy_code_units_utf::operator()
void operator()(const unicode::encoded_result< ErCh > er)
Definition: sol.hpp:13380
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::set_associative_find
static detail::error_result set_associative_find(std::false_type, lua_State *L_, T &self, stack_object key, stack_object value)
Definition: sol.hpp:22039
sol::meta_function::call_function
@ call_function
sol::basic_table_core::const_iterator
iterator const_iterator
Definition: sol.hpp:25710
sol::main_thread
lua_State * main_thread(lua_State *L_, lua_State *backup_if_unsupported_=nullptr)
Definition: sol.hpp:10124
sol::call_detail::agnostic_lua_call_wrapper< no_construction, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, const no_construction &)
Definition: sol.hpp:18485
sol::meta::conditional::type
T type
Definition: sol.hpp:1401
sol::stateless_reference::abandon
void abandon(lua_State *=nullptr)
Definition: sol.hpp:10339
sol::pairs_iterator::m_cached_key_value_pair
std::pair< object, object > m_cached_key_value_pair
Definition: sol.hpp:25386
sol::detail::no_safety_tag
Definition: sol.hpp:10145
lua_iscfunction
LUA_API int lua_iscfunction(lua_State *L, int idx)
Definition: lapi.c:291
sol::u_detail::usertype_storage
Definition: sol.hpp:23427
sol::meta::meta_detail::is_matched_lookup_impl
Definition: sol.hpp:2637
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::erase_associative_lookup
static detail::error_result erase_associative_lookup(std::false_type, lua_State *L_, T &self, K &key)
Definition: sol.hpp:22343
sol::make_object_userdata
object make_object_userdata(lua_State *L_, T &&value)
Definition: sol.hpp:16926
sol::stack_iterator::operator*
reference operator*() const
Definition: sol.hpp:17016
sol::state_view::cbegin
const_iterator cbegin() const
Definition: sol.hpp:27812
sol::stack_dependencies::size
std::size_t size() const
Definition: sol.hpp:7087
sol::basic_pairs_range::m_source
source_t m_source
Definition: sol.hpp:25395
sol::u_detail::string_for_each_metatable_func::is_unqualified_lua_reference
bool is_unqualified_lua_reference
Definition: sol.hpp:23573
sol::state_view::create_table
table create_table(Name &&name, int narr, int nrec, Key &&key, Value &&value, Args &&... args)
Definition: sol.hpp:28032
sol::stack_reference_equals
Definition: sol.hpp:9883
sol::detail::inheritance::type_unique_cast_bases
static bool type_unique_cast_bases(types<>, void *, void *, const string_view &)
Definition: sol.hpp:9407
sol
Definition: forward.hpp:1093
sol::call_detail::lua_call_wrapper< T, factory_wrapper< Fs... >, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, F &fx)
Definition: sol.hpp:18794
sol::factories
auto factories(Functions &&... functions)
Definition: sol.hpp:7027
SOL_DEPRECATED
#define SOL_DEPRECATED
Definition: sol.hpp:21285
sol::basic_table_core::basic_table_core
basic_table_core(detail::no_safety_tag, lua_State *L, int index)
Definition: sol.hpp:25695
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::at
static int at(lua_State *L_)
Definition: sol.hpp:22510
sol::protected_function_result::value_type
stack_proxy value_type
Definition: sol.hpp:17238
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::next_associative
static int next_associative(std::true_type, lua_State *L_)
Definition: sol.hpp:22444
sol::u_detail::string_for_each_metatable_func::meta_idx_call
lua_CFunction meta_idx_call
Definition: sol.hpp:23580
sol::dump_throw_on_error
int dump_throw_on_error(lua_State *L_, int result_code, lua_Writer writer_function, void *userdata_pointer_, bool strip)
Definition: sol.hpp:20572
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::iter::iter
iter(lua_State *L_, int stack_index, T &source_, iterator it_)
Definition: sol.hpp:21791
sol::detail::typical_file_chunk_name_t
char[SOL_FILE_ID_SIZE_I_] typical_file_chunk_name_t
Definition: sol.hpp:16389
sol::meta::meta_detail::is_adl_sol_lua_get_v
constexpr bool is_adl_sol_lua_get_v
Definition: sol.hpp:11523
sol::stateless_reference::push
int push(lua_State *L_) const noexcept
Definition: sol.hpp:10289
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::set
static int set(lua_State *L_)
Definition: sol.hpp:22534
sol::detail::optional_operations_base::get
constexpr const T && get() const &&
Definition: sol.hpp:5018
sol::variadic_args::crbegin
const_reverse_iterator crbegin() const
Definition: sol.hpp:28710
sol::stack::is_main_thread
bool is_main_thread(lua_State *L)
Definition: sol.hpp:11688
sol::stack::stack_detail::basic_check
Definition: sol.hpp:12377
sol::stack::unqualified_pusher< function_arguments< T, Args... > >::push
static int push(lua_State *L, const function_arguments< T, Args... > &fp)
Definition: sol.hpp:20107
sol::state_view::create_table
table create_table(Name &&name, int narr=0, int nrec=0)
Definition: sol.hpp:28027
sol::main_environment
basic_environment< main_reference > main_environment
Definition: forward.hpp:1153
sol::stack::push_popper
Definition: sol.hpp:10004
sol::state_view::require
object require(const std::string &key, lua_CFunction open_function, bool create_global=true)
Definition: sol.hpp:27410
sol::basic_table_core::set_fx
void set_fx(types< R(Args...)>, Key &&key, Fx &&fx)
Definition: sol.hpp:26048
sol::stack::stack_detail::not_enough_stack_space_meta_function_name
constexpr const char * not_enough_stack_space_meta_function_name
Definition: sol.hpp:11550
sol::meta::meta_detail::adl_sol_lua_check_access_test_t
decltype(sol_lua_check_access(types< T >(), static_cast< lua_State * >(nullptr), -1, std::declval< stack::record & >())) adl_sol_lua_check_access_test_t
Definition: sol.hpp:9234
sol::stack_global_table
stack_table_core< true > stack_global_table
Definition: forward.hpp:1131
sol::detail::insert_default_registrations
void insert_default_registrations(IFx &&ifx, Fx &&fx)
Definition: sol.hpp:23327
lua_pushfstring
const LUA_API char * lua_pushfstring(lua_State *L, const char *fmt,...)
Definition: lapi.c:560
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::index_adjustment
static std::ptrdiff_t index_adjustment(lua_State *, T &)
Definition: sol.hpp:22812
sol::meta::meta_detail::is_adl_sol_lua_check_access_v
constexpr bool is_adl_sol_lua_check_access_v
Definition: sol.hpp:9237
sol::stack::stack_detail::strip_t
typename strip< T >::type strip_t
Definition: sol.hpp:11572
sol::meta::is_probably_stateless_lambda
typename meta_detail::is_probably_stateless_lambda< T, std::is_empty_v< T > &&call_operator_deducible_v< T > >::type is_probably_stateless_lambda
Definition: sol.hpp:2029
sol::stack::unqualified_pusher< const char16_t * >
Definition: sol.hpp:15684
sol::unique_usertype_rebind_actual_t
typename unique_usertype_traits< T >::template rebind_actual_type< Element > unique_usertype_rebind_actual_t
Definition: sol.hpp:9220
sol::stack::push_popper< true, T, C >::~push_popper
~push_popper()
Definition: sol.hpp:10032
sol::stack::unqualified_getter< variadic_args >::get
static variadic_args get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:28766
sol::is_table
Definition: sol.hpp:8526
sol::stateless_reference::valid
bool valid(lua_State *) const noexcept
Definition: sol.hpp:10321
sol::detail::unique_tag
detail::inheritance_unique_cast_function unique_tag
Definition: sol.hpp:10953
sol::operator>=
constexpr bool operator>=(const optional< T > &lhs, const optional< U > &rhs)
\group relop
Definition: sol.hpp:6040
sol::lua_size
Definition: sol.hpp:8394
sol::stack::unqualified_pusher< as_container_t< T * > >::C
std::add_pointer_t< meta::unqualified_t< std::remove_pointer_t< T > >> C
Definition: sol.hpp:23206
sol::no_metatable
constexpr no_metatable_t no_metatable
Definition: sol.hpp:7340
sol::stack::multi_check
bool multi_check(lua_State *L, int index)
Definition: sol.hpp:12013
sol::meta::supports_op_less
Definition: sol.hpp:2646
sol::detail::lua_type_of
Definition: sol.hpp:8146
sol::container_detail::has_traits_insert_test
Definition: sol.hpp:21419
sol::container_detail::u_c_launch::T
std::remove_pointer_t< meta::unqualified_t< X > > T
Definition: sol.hpp:22843
sol::basic_usertype::operator[]
usertype_proxy< const basic_usertype &, std::decay_t< Key > > operator[](Key &&key) const
Definition: sol.hpp:26396
sol::state::operator=
state & operator=(state &&that)
Definition: sol.hpp:28255
sol::container_detail::has_traits_find
meta::boolean< has_traits_find_test< T >::value > has_traits_find
Definition: sol.hpp:21617
sol::optional< T & >::disjunction
SOL_TL_OPTIONAL_11_CONSTEXPR optional disjunction(optional &&rhs) &
\group disjunction
Definition: sol.hpp:6621
sol::basic_table_core::for_each
void for_each(Fx &&fx) const
Definition: sol.hpp:25971
sol::meta::meta_detail::is_adl_sol_lua_interop_get_v
constexpr bool is_adl_sol_lua_interop_get_v
Definition: sol.hpp:11526
sol::detail::handle_protected_exception
void handle_protected_exception(lua_State *L_, optional< const std::exception & > maybe_ex, const char *error, detail::protected_handler< ShouldPush_, Handler_ > &handler_)
Definition: sol.hpp:20816
sol::stack::probe_field_getter< std::tuple< Args... >, P, b, raw, C >::get
probe get(lua_State *L, Keys &&keys, int tableindex=-2)
Definition: sol.hpp:16367
sol::stack::unqualified_getter< lua_thread_state >::get
lua_thread_state get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:28106
arg
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
Definition: core.h:1875
sol::function_detail::select_member_function_with
void select_member_function_with(lua_State *L, Fx &&fx, T &&obj, Args &&... args)
Definition: sol.hpp:19922
sol::detail::ebco< T &, tag >::operator=
ebco & operator=(T &v) noexcept
Definition: sol.hpp:7224
lua_gettable
LUA_API int lua_gettable(lua_State *L, int idx)
Definition: lapi.c:668
sol::basic_table_core::create
static table create(lua_State *L, int narr=0, int nrec=0)
Definition: sol.hpp:26069
sol::usertype_proxy::key_type
detail::proxy_key_t< Key > key_type
Definition: sol.hpp:24559
sol::stack::unqualified_pusher< detail::as_table_tag< T > >::push
static int push(lua_State *L, const T &tablecont, nested_tag_t)
Definition: sol.hpp:15043
sol::state_view::script
unsafe_function_result script(const string_view &code, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27768
sol::basic_coroutine::basic_coroutine
basic_coroutine(lua_State *L, absolute_index index)
Definition: sol.hpp:28417
sol::stack::stateless_push_popper::m_object
T m_object
Definition: sol.hpp:10055
sol::table_proxy::set
table_proxy & set(T &&item) &
Definition: sol.hpp:24767
sol::basic_table_iterator::operator++
basic_table_iterator operator++(int) noexcept
Definition: sol.hpp:25089
sol::stack::unqualified_checker< std::tuple< Args... >, type::poly >::check
static bool check(lua_State *L_, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:12888
sol::detail::ebco
Definition: sol.hpp:7134
sol::u_detail::string_for_each_metatable_func::is_destruction
bool is_destruction
Definition: sol.hpp:23566
sol::stack::unqualified_pusher< const wchar_t * >::push
static int push(lua_State *L, const wchar_t *strb, const wchar_t *stre)
Definition: sol.hpp:15648
LUA_TBOOLEAN
#define LUA_TBOOLEAN
Definition: lua.h:66
sol::meta::sfinae_no_t
std::false_type sfinae_no_t
Definition: sol.hpp:1367
sol::detail::inheritance::type_cast_bases
static void * type_cast_bases(types< Base, Args... >, T *data, const string_view &ti)
Definition: sol.hpp:9389
sol::optional< T & >::operator->
SOL_TL_OPTIONAL_11_CONSTEXPR T * operator->()
Definition: sol.hpp:6778
sol::protected_function_result::reference_type
stack_proxy reference_type
Definition: sol.hpp:17237
sol::stack::unqualified_pusher< var_wrapper< T > >::push
static int push(lua_State *L, const var_wrapper< T > &vw)
Definition: sol.hpp:20245
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::insert_lookup
static detail::error_result insert_lookup(std::true_type, lua_State *L_, T &self, stack_object, stack_object value)
Definition: sol.hpp:22261
sol::metatable_key
constexpr metatable_key_t metatable_key
Definition: sol.hpp:7331
sol::in_place
constexpr std::in_place_t in_place
Definition: sol.hpp:4612
sol::basic_protected_function::basic_protected_function
basic_protected_function(lua_State *L_, absolute_index index_, handler_t eh)
Definition: sol.hpp:20929
sol::detail::unchecked
const unchecked_t unchecked
Definition: sol.hpp:1362
sol::u_detail::lua_reference_func::operator()
void operator()(lua_State *L_, submetatable_type smt_, stateless_reference &fast_index_table_)
Definition: sol.hpp:23634
sol::automagic_enrollments::destructor
bool destructor
Definition: sol.hpp:8705
sol::function_detail::upvalue_member_variable< T, readonly_wrapper< Function > >::function_type
std::remove_pointer_t< std::decay_t< Function > > function_type
Definition: sol.hpp:19286
sol::basic_bytecode::as_string_view
string_view as_string_view() const
Definition: sol.hpp:4501
sol::detail::optional_operations_base::get
SOL_TL_OPTIONAL_11_CONSTEXPR T && get() &&
Definition: sol.hpp:5014
sol::nullopt_t
std::nullopt_t nullopt_t
A tag type to represent an empty optional.
Definition: sol.hpp:5213
sol::wrapper::free_args_list
traits_type::args_list free_args_list
Definition: sol.hpp:17653
lua_isnoneornil
#define lua_isnoneornil(L, n)
Definition: lua.h:380
sol::basic_thread::create
basic_thread create()
Definition: sol.hpp:28216
sol::function_detail::member_variable::member_variable
member_variable(function_type v, Args &&... args) noexcept(std::is_nothrow_constructible_v< function_type, function_type > &&std::is_nothrow_constructible_v< T, Args... >)
Definition: sol.hpp:19573
sol::detail::optional_map_impl
auto optional_map_impl(Opt &&opt, F &&f) -> optional< monostate >
Definition: sol.hpp:6231
sol::unicode::encoded_result::error
error_code error
Definition: sol.hpp:13078
sol::is_table_like_v
constexpr bool is_table_like_v
Definition: sol.hpp:8582
sol::function_detail::upvalue_member_function::operator()
int operator()(lua_State *L) noexcept(traits_type::is_noexcept)
Definition: sol.hpp:19208
nonstd::span_lite::std11::false_type
integral_constant< bool, false > false_type
Definition: span.hpp:657
sol::as_nested_ref
nested< T > as_nested_ref(T &&container)
Definition: sol.hpp:7656
sol::has_flag
constexpr bool has_flag(Left left, Right right) noexcept
Definition: sol.hpp:8689
sol::detail::alloc_newuserdata
void * alloc_newuserdata(lua_State *L, std::size_t bytesize)
Definition: sol.hpp:10955
sol::detail::optional_delete_ctor_base
Definition: sol.hpp:5136
sol::detail::swap_adl_tests::tag
Definition: sol.hpp:4872
detail
Definition: args.h:19
sol::basic_usertype::set
basic_usertype & set(Key &&key, Value &&value)
Definition: sol.hpp:26358
sol::call_detail::lua_call_wrapper< T, overload_set< Fs... >, is_index, is_variable, checked, boost, clean_stack, C >::on_match::operator()
int operator()(types< Fx >, meta::index_value< I >, types< R... >, types< Args... >, lua_State *L, int, int, F &fx)
Definition: sol.hpp:18771
sol::stack::stack_detail::get_as_upvalues
std::pair< T, int > get_as_upvalues(lua_State *L, int index=2)
Definition: sol.hpp:16457
luaL_addlstring
LUALIB_API void luaL_addlstring(luaL_Buffer *B, const char *s, size_t l)
Definition: lauxlib.c:579
sol::stateless_reference_equals
Definition: sol.hpp:10729
sol::lib::os
@ os
sol::stateless_stack_reference::get_type
type get_type(lua_State *L_) const noexcept
Definition: sol.hpp:9711
sol::forward_as_value_t
Definition: sol.hpp:7716
sol::u_detail::new_index_fail
int new_index_fail(lua_State *L_)
Definition: sol.hpp:23557
sol::container_detail::has_traits_ipairs_test
Definition: sol.hpp:21515
sol::stack::unqualified_getter< std::variant< Tn... > >::get_one
static V get_one(std::integral_constant< std::size_t, std::variant_size_v< V >>, lua_State *L, int index, record &tracking)
Definition: sol.hpp:14327
sol::light::light
light(T &x)
Definition: sol.hpp:7454
sol::stack::unqualified_pusher< nullopt_t >::push
static int push(lua_State *L, nullopt_t) noexcept
Definition: sol.hpp:15953
sol::call_detail::lua_call_wrapper< T, function_arguments< Sig, P >, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, function_arguments< Sig, P > &&f)
Definition: sol.hpp:18925
sol::optional< T & >::disjunction
SOL_TL_OPTIONAL_11_CONSTEXPR optional disjunction(const optional &rhs) &
Definition: sol.hpp:6599
sol::stateless_stack_reference::registry_index
int registry_index() const noexcept
Definition: sol.hpp:9665
sol::meta::meta_detail::void_tuple_element
Definition: sol.hpp:1537
sol::call_detail::lua_call_wrapper< T, factory_wrapper< Fs... >, is_index, is_variable, checked, boost, clean_stack, C >::F
factory_wrapper< Fs... > F
Definition: sol.hpp:18784
sol::proxy_base::lua_state
lua_State * lua_state() const
Definition: sol.hpp:16959
sol::meta::is_member_object
std::integral_constant< bool, std::is_member_object_pointer_v< T >||is_specialization_of_v< T, readonly_wrapper > > is_member_object
Definition: sol.hpp:18027
writer
static int writer(lua_State *L, const void *b, size_t size, void *ud)
Definition: lstrlib.c:222
sol::basic_table_core::cbegin
const_iterator cbegin() const
Definition: sol.hpp:25789
sol::basic_metatable::base_t
basic_table< base_type > base_t
Definition: sol.hpp:26134
sol::thread_status::yielded
@ yielded
sol::detail::properties_enrollment_allowed
Definition: sol.hpp:11381
sol::closure::closure
closure(lua_CFunction f, Upvalues... targetupvalues)
Definition: sol.hpp:7537
sol::stack_guard
Definition: sol.hpp:10896
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::set_writable
static detail::error_result set_writable(std::false_type, lua_State *, T &, iterator &, stack_object)
Definition: sol.hpp:21931
sol::type_name
std::string type_name(lua_State *L, type t)
Definition: sol.hpp:8079
sol::is_lua_reference_or_proxy_v
constexpr bool is_lua_reference_or_proxy_v
Definition: sol.hpp:8106
sol::variadic_args::push
int push() const
Definition: sol.hpp:28717
sol::stack::get_usertype
decltype(auto) get_usertype(lua_State *L, int index=-lua_size_v< meta::unqualified_t< T >>)
Definition: sol.hpp:12074
sol::basic_table_core::empty
bool empty() const
Definition: sol.hpp:26006
sol::meta::meta_detail::callable_traits< R(T::*), true >::return_type
meta::conditional_t< std::is_array_v< R >, std::add_lvalue_reference_t< R >, R > return_type
Definition: sol.hpp:1996
sol::state_view::operator[]
table_proxy< const global_table &, detail::proxy_key_t< T > > operator[](T &&key) const
Definition: sol.hpp:28010
sol::state_view::stop_gc
void stop_gc()
Definition: sol.hpp:27891
sol::optional::disjunction
constexpr optional disjunction(const optional &rhs) const &
\group disjunction
Definition: sol.hpp:5591
sol::u_detail::submetatable_type::unique
@ unique
sol::lua_value
Definition: sol.hpp:26938
lua_Number
LUA_NUMBER lua_Number
Definition: lua.h:90
sol::protected_function_result::~protected_function_result
~protected_function_result()
Definition: sol.hpp:17407
sol::light::light
light(T *x)
Definition: sol.hpp:7456
sol::meta::meta_detail::adl_sol_lua_check_get_test_t
decltype(sol_lua_check_get(types< T >(), static_cast< lua_State * >(nullptr), -1, &no_panic, std::declval< stack::record & >())) adl_sol_lua_check_get_test_t
Definition: sol.hpp:11514
sol::meta::meta_detail::is_detected
Definition: sol.hpp:1383
sol::container_detail::u_c_launch::real_erase_call
static int real_erase_call(lua_State *L)
Definition: sol.hpp:23034
sol::state_view::global
global_table global
Definition: sol.hpp:27241
sol::basic_reference::pointer
const void * pointer() const noexcept
Definition: sol.hpp:10634
sol::basic_protected_function::basic_protected_function
basic_protected_function(lua_State *L_, T &&r, handler_t eh)
Definition: sol.hpp:20908
sol::stack::push_popper_n::L
lua_State * L
Definition: sol.hpp:9984
luaL_loadbuffer
#define luaL_loadbuffer(L, s, sz, n)
Definition: lauxlib.h:154
sol::stack_iterator::iterator_category
std::random_access_iterator_tag iterator_category
Definition: sol.hpp:16999
sol::stack_aligned_function
stack_aligned_unsafe_function stack_aligned_function
Definition: forward.hpp:1181
sol::meta_function::floor_division
@ floor_division
sol::function_detail::functor_function::functor_function
functor_function(function_type f, Args &&... args) noexcept(std::is_nothrow_constructible_v< function_type, function_type, Args... >)
Definition: sol.hpp:19492
sol::stack::stateless_push_popper::~stateless_push_popper
~stateless_push_popper()
Definition: sol.hpp:10065
sol::stack_reference::stack_reference
stack_reference(lua_State *L, absolute_index i) noexcept
Definition: sol.hpp:9761
sol::basic_protected_function::basic_protected_function
basic_protected_function(std::true_type, const basic_protected_function &other_) noexcept
Definition: sol.hpp:20837
lua_isstring
LUA_API int lua_isstring(lua_State *L, int idx)
Definition: lapi.c:310
sol::meta::detail::tuple_types_
Definition: sol.hpp:1472
sol::stack::unqualified_pusher< std::variant< Tn... > >::push
static int push(lua_State *L, std::variant< Tn... > &&v)
Definition: sol.hpp:16029
sol::basic_table
basic_table_core< false, base_type > basic_table
Definition: forward.hpp:1125
sol::detail::inheritance::bases_t
base< T >::type bases_t
Definition: sol.hpp:9364
detail::fp
basic_fp< unsigned long long > fp
Definition: format.h:1663
sol::state_view::add_package_loader
void add_package_loader(Fx &&fx, bool clear_all_package_loaders=false)
Definition: sol.hpp:27454
sol::stack::stack_detail::strip< user< T > >::type
T & type
Definition: sol.hpp:11565
sol::policy_wrapper::policy_wrapper
policy_wrapper(Fx &&fx, Args &&... args)
Definition: sol.hpp:7100
sol::detail::enable_if_t
typename std::enable_if< E, T >::type enable_if_t
Definition: sol.hpp:4724
boost
sol::meta::pop_front_type< types< Args... > >::type
types< Args... > type
Definition: sol.hpp:1494
sol::stack::unqualified_pusher< constructor_wrapper< F, Fxs... > >::push
static int push(lua_State *L, constructor_wrapper< F, Fxs... > &&c)
Definition: sol.hpp:20359
sol::weak_derive
Definition: forward.hpp:1278
sol::is_actual_type_rebindable_for
typename meta::meta_detail::is_actual_type_rebindable_for_test< unique_usertype_traits< T >, Element >::type is_actual_type_rebindable_for
Definition: sol.hpp:9319
sol::stack::unqualified_pusher< std::function< Signature > >::push
static int push(lua_State *L, detail::yield_tag_t, const std::function< Signature > &fx)
Definition: sol.hpp:20120
sol::unsafe_function_result::unsafe_function_result
unsafe_function_result() noexcept
Definition: sol.hpp:17456
sol::call_status::syntax
@ syntax
sol::type_panic_string
int type_panic_string(lua_State *L, int index, type expected, type actual, string_view message="") noexcept(false)
Definition: sol.hpp:9563
sol::variadic_args::cend
const_iterator cend() const
Definition: sol.hpp:28694
sol::function_detail::upvalue_this_member_variable< T, readonly_wrapper< Function > >::call
static int call(lua_State *L) noexcept(std::is_nothrow_copy_assignable_v< T >)
Definition: sol.hpp:19459
sol::stack::stack_detail::readonly_pairs
int readonly_pairs(lua_State *L_) noexcept
Definition: sol.hpp:25167
sol::function_detail::call_wrapper_function
int call_wrapper_function(std::true_type, lua_State *L)
Definition: sol.hpp:19054
sol::basic_function::basic_function
basic_function(lua_State *L, T &&r)
Definition: sol.hpp:20653
sol::writeonly_property
decltype(auto) writeonly_property(F &&f)
Definition: sol.hpp:17984
sol::meta::meta_detail::unique_usertype_get_with_state_test_t
decltype(unique_usertype_traits< T >::get(static_cast< lua_State * >(nullptr), std::declval< unique_usertype_actual_t< T > >())) unique_usertype_get_with_state_test_t
Definition: sol.hpp:9241
sol::meta::neg_v
constexpr bool neg_v
Definition: sol.hpp:2216
sol::container_detail::u_c_launch::real_index_set_traits
static int real_index_set_traits(std::true_type, lua_State *L)
Definition: sol.hpp:22918
lua_atpanic
LUA_API lua_CFunction lua_atpanic(lua_State *L, lua_CFunction panicf)
Definition: lapi.c:137
sol::meta::enabler
constexpr const auto enabler
Definition: sol.hpp:2238
sol::u_detail::binding_base::~binding_base
virtual ~binding_base()
Definition: sol.hpp:23452
sol::unsafe_function_result::rend
reverse_iterator rend()
Definition: sol.hpp:17524
mqtt_test_proto.x
x
Definition: mqtt_test_proto.py:34
luaL_Stream
Definition: lauxlib.h:237
sol::detail::no_comp::operator()
bool operator()(A &&, B &&) const
Definition: sol.hpp:12209
sol::is_variadic_arguments
Definition: sol.hpp:8119
sol::stack::pop
decltype(auto) pop(lua_State *L)
Definition: sol.hpp:12080
sol::detail::protected_handler::m_L
lua_State * m_L
Definition: sol.hpp:20740
sol::constructor_list
Definition: sol.hpp:6992
sol::lua_table
basic_lua_table< reference > lua_table
Definition: forward.hpp:1135
sol::lua_CFunction_ref
std::remove_pointer_t< lua_CFunction > lua_CFunction_ref
Definition: sol.hpp:7366
sol::detail::short_demangle_from_type_name
std::string short_demangle_from_type_name(std::string realname)
Definition: sol.hpp:9023
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::iterator_category
meta::iterator_tag< iterator >::type iterator_category
Definition: sol.hpp:21777
sol::userdata
basic_userdata< reference > userdata
Definition: forward.hpp:1210
sol::lua_value::value
reference && value() &&
Definition: sol.hpp:27023
sol::automagic_enrollments::pairs_operator
bool pairs_operator
Definition: sol.hpp:8706
sol::stateless_reference::reset
void reset(lua_State *L_, int index_) noexcept
Definition: sol.hpp:10312
sol::stateless_stack_reference::copy
stateless_stack_reference copy(lua_State *L_) const noexcept
Definition: sol.hpp:9733
sol::load_status
load_status
Definition: sol.hpp:7869
lua_type
LUA_API int lua_type(lua_State *L, int idx)
Definition: lapi.c:278
sol::function_detail::c_function_invocation
Definition: sol.hpp:19833
sol::function_detail::functor_function
Definition: sol.hpp:19487
sol::detail::tagged::value
T && value() &&
Definition: sol.hpp:6985
sol::optional::operator->
SOL_TL_OPTIONAL_11_CONSTEXPR T * operator->()
Definition: sol.hpp:5895
sol::u_detail::string_for_each_metatable_func::meta_new_idx_call
lua_CFunction meta_new_idx_call
Definition: sol.hpp:23580
sol::closure
Definition: sol.hpp:7534
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::add_copyable
static detail::error_result add_copyable(std::true_type, lua_State *L_, T &self, stack_object value)
Definition: sol.hpp:22248
sol::absolute_index::index
int index
Definition: sol.hpp:7395
luaopen_package
LUAMOD_API int luaopen_package(lua_State *L)
Definition: loadlib.c:739
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::set_comparative
static detail::error_result set_comparative(std::false_type, lua_State *, T &, stack_object, stack_object)
Definition: sol.hpp:21986
sol::factory_wrapper
Definition: sol.hpp:7019
sol::stateless_reference::get_type
type get_type(lua_State *L_) const noexcept
Definition: sol.hpp:10332
luaopen_math
LUAMOD_API int luaopen_math(lua_State *L)
Definition: lmathlib.c:751
sol::meta_function::index
@ index
sol::stack::unqualified_pusher< as_container_t< T > >::C
meta::unqualified_t< T > C
Definition: sol.hpp:23174
sol::u_detail::index_call_storage
Definition: sol.hpp:23440
sol::basic_lua_table::basic_lua_table
basic_lua_table(lua_State *L, T &&r)
Definition: sol.hpp:26432
sol::basic_table_core::create_with
table create_with(Args &&... args)
Definition: sol.hpp:26116
sol::unicode::error_code::sequence_too_short
@ sequence_too_short
sol::stack::unqualified_getter< T & >
Definition: sol.hpp:14258
sol::detail::ebco::operator=
ebco & operator=(T &&v) noexcept(std::is_nothrow_move_assignable_v< T >)
Definition: sol.hpp:7148
sol::function_detail::upvalue_this_member_variable< T, readonly_wrapper< Function > >::function_type
std::remove_pointer_t< std::decay_t< Function > > function_type
Definition: sol.hpp:19442
sol::unicode::error_code::ok
@ ok
sol::meta::meta_detail::always_true
Definition: sol.hpp:2369
sol::u_detail::string_for_each_metatable_func::p_ics
index_call_storage * p_ics
Definition: sol.hpp:23577
sol::stack::stack_detail::undefined_metatable
Definition: sol.hpp:11662
sol::meta::index_in
Definition: sol.hpp:2274
sol::stateless_stack_reference::pop
void pop(lua_State *L_, int pop_count=1) const noexcept
Definition: sol.hpp:9698
sol::stack::unqualified_pusher< overload_set< Functions... > >::push
static int push(lua_State *L, overload_set< Functions... > &&set)
Definition: sol.hpp:20181
sol::stack_environment
basic_environment< stack_reference > stack_environment
Definition: forward.hpp:1154
sol::basic_coroutine::basic_coroutine
basic_coroutine(lua_State *L, T &&r, handler_t eh)
Definition: sol.hpp:28397
mqtt_test_proto.msg
msg
Definition: mqtt_test_proto.py:43
sol::container_detail::u_c_launch::real_ipairs_traits
static int real_ipairs_traits(std::false_type, lua_State *L)
Definition: sol.hpp:22946
sol::u_detail::string_for_each_metatable_func::is_unqualified_lua_CFunction
bool is_unqualified_lua_CFunction
Definition: sol.hpp:23572
sol::call_detail::pick
auto & pick(std::false_type, property_wrapper< R, W > &f)
Definition: sol.hpp:18147
sol::detail::unique_fallback
Definition: sol.hpp:9124
sol::stack::unqualified_pusher< const char16_t * >::push
static int push(lua_State *L, const char16_t *strb, const char16_t *stre)
Definition: sol.hpp:15714
SOL_FILE_ID_SIZE_I_
#define SOL_FILE_ID_SIZE_I_
Definition: sol.hpp:616
sol::stack::unqualified_getter< error >::get
static error get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14163
sol::stateless_reference::stack_index
int stack_index() const noexcept
Definition: sol.hpp:10191
sol::detail::optional_storage_base< T, true >::m_value
T m_value
Definition: sol.hpp:4964
sol::meta::meta_detail::unique_usertype_is_null_with_state_test_t
decltype(unique_usertype_traits< T >::is_null(static_cast< lua_State * >(nullptr), std::declval< unique_usertype_actual_t< T > >())) unique_usertype_is_null_with_state_test_t
Definition: sol.hpp:9248
sol::basic_pairs_range::end
pairs_sentinel end() noexcept
Definition: sol.hpp:25416
sol::container_detail::u_c_launch::insert_call
static int insert_call(lua_State *L)
Definition: sol.hpp:23067
sol::stack::unqualified_pusher< detail::as_reference_tag >::push
static int push(lua_State *L, T &&obj)
Definition: sol.hpp:14884
sol::base_classes
const auto base_classes
Definition: sol.hpp:9335
sol::container_detail::u_c_launch::real_next_call
static int real_next_call(lua_State *L)
Definition: sol.hpp:22962
sol::detail::c_trampoline
int c_trampoline(lua_State *L, lua_CFunction f)
Definition: sol.hpp:8875
sol::stack::push_popper_at
Definition: sol.hpp:9971
sol::pairs_iterator::reference
value_type & reference
Definition: sol.hpp:25207
sol::protected_function_result::cbegin
const_iterator cbegin() const
Definition: sol.hpp:17362
sol::table_proxy::valid
bool valid() const
Definition: sol.hpp:24905
sol::container_detail::has_clear_test
Definition: sol.hpp:21310
sol::basic_coroutine::basic_coroutine
basic_coroutine(Proxy &&p, HandlerReference &&eh)
Definition: sol.hpp:28389
sol::basic_protected_function::dump
int dump(lua_Writer writer, void *userdata_pointer_, bool strip, Fx &&on_error) const
Definition: sol.hpp:20956
sol::meta::meta_detail::value_test_t
decltype(T::value) value_test_t
Definition: sol.hpp:9186
sol::meta::meta_detail::is_dereferenceable_test
decltype(*std::declval< T >()) is_dereferenceable_test
Definition: sol.hpp:2057
sol::stack::unqualified_getter< std::basic_string< wchar_t, Traits, Al > >::get
static S get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14023
sol::meta::meta_detail::is_adl_sol_lua_check_v
constexpr bool is_adl_sol_lua_check_v
Definition: sol.hpp:11529
sol::basic_lua_table::basic_lua_table
basic_lua_table(stack_reference &&r)
Definition: sol.hpp:26429
sol::automagic_flags::to_string_operator
@ to_string_operator
detail::find
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
Definition: core.h:2154
sol::lua_value::value
const reference & value() const &
Definition: sol.hpp:27015
sol::stack::qualified_check_getter::get
optional< R > get(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:14639
sol::u_detail::usertype_storage::index_call_
static int index_call_(lua_State *L)
Definition: sol.hpp:24018
sol::call_status::memory
@ memory
sol::container_detail::has_erase_test
Definition: sol.hpp:21371
sol::call_detail::lua_call_wrapper< T, property_wrapper< R, W >, is_index, is_variable, checked, boost, clean_stack, C >::traits_type
lua_bind_traits< U > traits_type
Definition: sol.hpp:18804
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::set_category
static detail::error_result set_category(std::input_iterator_tag, lua_State *L_, T &self, stack_object okey, stack_object value)
Definition: sol.hpp:21936
sol::stateless_reference::pointer
const void * pointer(lua_State *L_) const noexcept
Definition: sol.hpp:10325
sol::state_view::stack_top
int stack_top() const
Definition: sol.hpp:27838
sol::basic_object::basic_object
basic_object(lua_State *L_, absolute_index index_) noexcept
Definition: sol.hpp:16879
sol::detail::typed_static_trampoline
int typed_static_trampoline(lua_State *L)
Definition: sol.hpp:8881
sol::meta::meta_detail::callable_traits< R(T::*), true >::arg_at
void_tuple_element_t< i, args_tuple > arg_at
Definition: sol.hpp:2012
sol::u_detail::index_fail
int index_fail(lua_State *L_)
Definition: sol.hpp:23541
sol::meta::meta_detail::unique_valid
Definition: sol.hpp:9210
lua_setmetatable
LUA_API int lua_setmetatable(lua_State *L, int objindex)
Definition: lapi.c:927
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::add_push_back
static detail::error_result add_push_back(std::false_type, lua_State *L_, T &self, stack_object value)
Definition: sol.hpp:22204
sol::variadic_args::iterator
stack_iterator< stack_proxy, false > iterator
Definition: sol.hpp:28646
sol::load_mode::text
@ text
sol::stack::unqualified_getter< as_table_t< std::forward_list< T, Al > > >::get
static C get(std::true_type, lua_State *L, int index, record &tracking)
Definition: sol.hpp:13788
sol::basic_bytecode::base_t
std::vector< std::byte, Allocator > base_t
Definition: sol.hpp:4448
sol::u_detail::string_for_each_metatable_func::call_func
lua_CFunction call_func
Definition: sol.hpp:23576
sol::stack::unqualified_getter< std::function< Signature > >::args_lists
fx_t::args_list args_lists
Definition: sol.hpp:21240
sol::lua_value::lua_value
lua_value(reference r)
Definition: sol.hpp:27007
sol::detail::not_enough_stack_space_userdata
constexpr const char * not_enough_stack_space_userdata
Definition: sol.hpp:9512
sol::meta::has_insert
meta::boolean< meta_detail::has_insert_test< T >::value > has_insert
Definition: sol.hpp:2703
sol::meta::meta_detail::unique_actual_type< T, meta::void_t< typename T::actual_type > >::type
typename T::actual_type type
Definition: sol.hpp:9171
sol::basic_variadic_results::basic_variadic_results
basic_variadic_results(unsafe_function_result fr)
Definition: sol.hpp:28833
sol::stateless_reference::stateless_reference
stateless_reference(lua_State *L_, int index=-1) noexcept
Definition: sol.hpp:10258
sol::u_detail::usertype_storage_base::change_indexing
void change_indexing(lua_State *L_, submetatable_type submetatable_, void *derived_this_, stateless_stack_reference &t_, lua_CFunction index_, lua_CFunction new_index_, lua_CFunction meta_index_, lua_CFunction meta_new_index_)
Definition: sol.hpp:23948
sol::optional< T & >::and_then
SOL_TL_OPTIONAL_11_CONSTEXPR detail::invoke_result_t< F, T & > and_then(F &&f) &
Definition: sol.hpp:6329
sol::derive
Definition: forward.hpp:1268
sol::basic_thread::thread_state
lua_State * thread_state() const
Definition: sol.hpp:28195
sol::stack_proxy_base::is
bool is() const
Definition: sol.hpp:17138
nonstd::span_lite::std11::true_type
integral_constant< bool, true > true_type
Definition: span.hpp:656
sol::stack::unqualified_pusher< destructor_wrapper< Fx > >::push
static int push(lua_State *L, destructor_wrapper< Fx > &&c)
Definition: sol.hpp:20395
sol::detail::get_is_primitive
Definition: sol.hpp:12306
sol::meta::pop_front_type< types< Arg, Args... > >::front_type
Arg front_type
Definition: sol.hpp:1499
luaopen_debug
LUAMOD_API int luaopen_debug(lua_State *L)
Definition: ldblib.c:479
sol::state_view::create_named_table
table create_named_table(Name &&name, Args &&... args)
Definition: sol.hpp:28037
sol::operator<=
constexpr bool operator<=(const optional< T > &lhs, const optional< U > &rhs)
\group relop
Definition: sol.hpp:6035
sol::error::error
error(std::string &&str)
Definition: sol.hpp:4581
sol::basic_protected_function::invoke
Ret invoke(types< Ret >, std::index_sequence< I >, std::ptrdiff_t n, detail::protected_handler< b, handler_t > &h) const
Definition: sol.hpp:21098
sol::container_detail::has_traits_size
meta::boolean< has_traits_size_test< T >::value > has_traits_size
Definition: sol.hpp:21608
sol::unsafe_function_result::status
call_status status() const noexcept
Definition: sol.hpp:17540
sol::basic_protected_function::basic_protected_function
basic_protected_function(stack_reference &&r)
Definition: sol.hpp:20884
sol::userdata_value
Definition: sol.hpp:7430
sol::stack::push_popper< false, T, std::enable_if_t< is_stack_based_v< meta::unqualified_t< T > > > >::~push_popper
~push_popper()
Definition: sol.hpp:10047
sol::detail::resolve_v
constexpr Sig C::* resolve_v(std::true_type, Sig C::*mem_variable_ptr)
Definition: sol.hpp:19695
sol::stack::stack_detail::basic_check::check
static bool check(lua_State *L_, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:12379
sol::stack_iterator::operator++
stack_iterator operator++(int)
Definition: sol.hpp:17035
sol::container_detail::u_c_launch::real_index_get_traits
static int real_index_get_traits(std::false_type, lua_State *L)
Definition: sol.hpp:22851
sol::basic_object::operator=
basic_object & operator=(const base_type &b)
Definition: sol.hpp:16895
sol::pairs_iterator::m_next_function_ref
protected_function m_next_function_ref
Definition: sol.hpp:25384
sol::meta::is_invocable_v
constexpr bool is_invocable_v
Definition: sol.hpp:2667
lua_tothread
LUA_API lua_State * lua_tothread(lua_State *L, int idx)
Definition: lapi.c:456
sol::call_detail::lua_call_wrapper< T, property_wrapper< R, W >, is_index, is_variable, checked, boost, clean_stack, C >::wrap
wrapper< U > wrap
Definition: sol.hpp:18803
sol::unsafe_function_result::end
const_iterator end() const
Definition: sol.hpp:17511
sol::u_detail::string_for_each_metatable_func::is_static_new_index
bool is_static_new_index
Definition: sol.hpp:23570
sol::container_detail::container_decay::type
T type
Definition: sol.hpp:21636
sol::meta::meta_detail::basic_traits::is_member_function
static constexpr bool is_member_function
Definition: sol.hpp:1554
sol::state_view::do_reader
protected_function_result do_reader(lua_Reader reader, void *data, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27503
sol::detail::debug::dump_types
std::string dump_types(lua_State *L)
Definition: sol.hpp:14675
sol::meta::meta_detail::basic_traits< true, true, void, R, Args... >::arg_at
void_tuple_element_t< i, args_tuple > arg_at
Definition: sol.hpp:1569
sol::basic_table_core::basic_table_core
basic_table_core(lua_nil_t r) noexcept
Definition: sol.hpp:25772
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::index_set
static int index_set(lua_State *L_)
Definition: sol.hpp:22558
sol::detail::is_insert_mode
std::integral_constant< bool, std::is_same_v< T, override_value_t >||std::is_same_v< T, update_if_empty_t >||std::is_same_v< T, create_if_nil_t > > is_insert_mode
Definition: sol.hpp:7749
sol::stack::unqualified_pusher< const char32_t * >::convert_into
static int convert_into(lua_State *L, char *start, std::size_t, const char32_t *strb, const char32_t *stre)
Definition: sol.hpp:15763
sol::pairs_iterator::operator++
pairs_iterator & operator++()
Definition: sol.hpp:25302
sol::stack::set_field
void set_field(lua_State *L, Key &&key, Value &&value, int tableindex)
Definition: sol.hpp:12130
sol::stack::push_popper< true, T, C >::index_of
int index_of(const Tu &) const noexcept
Definition: sol.hpp:10028
sol::function_detail::overloaded_function::indices
std::make_index_sequence< sizeof...(Functions)> indices
Definition: sol.hpp:19621
sol::main_coroutine
basic_coroutine< main_reference > main_coroutine
Definition: forward.hpp:1218
sol::function_detail::functor_function::function_type
std::decay_t< meta::unwrap_unqualified_t< Func > > function_type
Definition: sol.hpp:19488
sol::call_detail::lua_call_wrapper< T, readonly_wrapper< F >, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, const readonly_wrapper< F > &rw, object_type &o)
Definition: sol.hpp:18678
sol::stateless_reference::deref
void deref(lua_State *L_) const noexcept
Definition: sol.hpp:10343
lua_pushnumber
LUA_API void lua_pushnumber(lua_State *L, lua_Number n)
Definition: lapi.c:499
sol::basic_insert_dump_writer
int basic_insert_dump_writer(lua_State *, const void *memory, size_t memory_size, void *userdata_pointer)
Definition: sol.hpp:4507
sol::function_detail::upvalue_this_member_function::operator()
int operator()(lua_State *L) noexcept(traits_type::is_noexcept)
Definition: sol.hpp:19388
sol::thread
basic_thread< reference > thread
Definition: forward.hpp:1212
sol::pairs_iterator::m_L
lua_State * m_L
Definition: sol.hpp:25383
sol::container_detail::u_c_launch::real_pairs_call
static int real_pairs_call(lua_State *L)
Definition: sol.hpp:22938
sol::stack::stack_detail::push_function::L
lua_State * L
Definition: sol.hpp:16010
lua_pushstring
const LUA_API char * lua_pushstring(lua_State *L, const char *s)
Definition: lapi.c:532
luaopen_table
LUAMOD_API int luaopen_table(lua_State *L)
Definition: ltablib.c:425
sol::call_detail::lua_call_wrapper< T, constructor_list< Args... >, is_index, is_variable, checked, boost, clean_stack, C >::F
constructor_list< Args... > F
Definition: sol.hpp:18692
sol::reference_equals
Definition: sol.hpp:10748
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::deferred_uc
usertype_container< X > deferred_uc
Definition: sol.hpp:22656
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::index_get
static int index_get(lua_State *L_)
Definition: sol.hpp:22530
sol::stack::unqualified_check_getter
Definition: sol.hpp:11460
sol::function_detail::c_call_matcher::operator()
int operator()(types< Fx >, meta::index_value< I >, types< R >, types< Args... >, lua_State *L, int, int) const
Definition: sol.hpp:19066
sol::stack_iterator::operator>
bool operator>(const stack_iterator &r) const
Definition: sol.hpp:17094
sol::state_view::safe_script
protected_function_result safe_script(lua_Reader reader, void *data, Fx &&on_error, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27564
sol::u_detail::binding_data_equals::binding_data_equals
binding_data_equals(void *b)
Definition: sol.hpp:23667
sol::automagic_flags::length_operator
@ length_operator
sol::call_detail::lua_call_wrapper< T, readonly_wrapper< F >, is_index, is_variable, checked, boost, clean_stack, C >::object_type
typename wrap::object_type object_type
Definition: sol.hpp:18643
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::clear
static int clear(lua_State *L_)
Definition: sol.hpp:22612
sol::stack::unqualified_check
bool unqualified_check(lua_State *L, int index=-lua_size< meta::unqualified_t< T >>::value)
Definition: sol.hpp:11875
sol::u_detail::usertype_storage_base::static_base_index
new_index_call_storage static_base_index
Definition: sol.hpp:23692
sol::container_detail::u_c_launch::length_call
static int length_call(lua_State *L)
Definition: sol.hpp:23087
sol::basic_function::invoke
void invoke(types< void >, std::index_sequence< I >, std::ptrdiff_t n) const
Definition: sol.hpp:20613
sol::unicode::code_point_to_utf8
encoded_result< char > code_point_to_utf8(char32_t codepoint)
Definition: sol.hpp:13164
sol::stack::unqualified_pusher< char16_t[N]>::push
static int push(lua_State *L, const char16_t(&str)[N], std::size_t sz)
Definition: sol.hpp:15856
sol::stack_lua_table
basic_lua_table< stack_reference > stack_lua_table
Definition: forward.hpp:1136
lua_dump
LUA_API int lua_dump(lua_State *L, lua_Writer writer, void *data, int strip)
Definition: lapi.c:1103
sol::optional< T & >::disjunction
SOL_TL_OPTIONAL_11_CONSTEXPR optional disjunction(optional &&rhs) &&
\group disjunction
Definition: sol.hpp:6631
sol::basic_usertype::operator[]
usertype_proxy< basic_usertype &, std::decay_t< Key > > operator[](Key &&key)
Definition: sol.hpp:26391
sol::basic_function::dump
Container dump(Fx &&on_error) const
Definition: sol.hpp:20697
sol::optional::emplace
T & emplace(Args &&... args)
Definition: sol.hpp:5845
sol::stack_thread
basic_thread< stack_reference > stack_thread
Definition: forward.hpp:1222
sol::member_function_wrapper::free_args_list
types< object_type &, FArgs... > free_args_list
Definition: sol.hpp:17764
sol::state_view::script
protected_function_result script(const string_view &code, Fx &&on_error, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27721
sol::is_value_semantic_for_function
Definition: sol.hpp:8432
sol::basic_protected_function::basic_protected_function
basic_protected_function(stack_reference &&r, handler_t eh)
Definition: sol.hpp:20888
sol::container_detail::has_find_test
Definition: sol.hpp:21347
sol::stack::unqualified_getter< metatable_key_t >::get
static metatable get(lua_State *L, int index=-1)
Definition: sol.hpp:26552
sol::raw_index
Definition: sol.hpp:7384
lua_isinteger
LUA_API int lua_isinteger(lua_State *L, int idx)
Definition: lapi.c:297
sol::as_table_ref
as_table_t< T > as_table_ref(T &&container)
Definition: sol.hpp:7646
luaL_pushresult
LUALIB_API void luaL_pushresult(luaL_Buffer *B)
Definition: lauxlib.c:593
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::size
static int size(lua_State *L_)
Definition: sol.hpp:22788
sol::detail::typical_chunk_name_t
char[SOL_ID_SIZE_I_] typical_chunk_name_t
Definition: sol.hpp:16388
sol::variadic_args::variadic_args
variadic_args(lua_State *luastate, int stackindex=-1)
Definition: sol.hpp:28652
sol::basic_object::basic_object
basic_object(stack_reference &&r) noexcept
Definition: sol.hpp:16867
sol::static_stack_dependencies
Definition: sol.hpp:7062
sol::u_detail::usertype_storage_base::base_index
new_index_call_storage base_index
Definition: sol.hpp:23691
sol::basic_table_core::basic_table_core
basic_table_core(detail::no_safety_tag, T &&r) noexcept
Definition: sol.hpp:25702
sol::basic_function::operator()
unsafe_function_result operator()(Args &&... args) const
Definition: sol.hpp:20704
sol::stack::multi_check
bool multi_check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:12002
sol::container_detail::has_traits_insert
meta::boolean< has_traits_insert_test< T >::value > has_traits_insert
Definition: sol.hpp:21623
sol::unsafe_function_result::reference_type
stack_proxy reference_type
Definition: sol.hpp:17446
sol::stateless_reference::stateless_reference
stateless_reference(lua_State *L_, stateless_reference &&r) noexcept
Definition: sol.hpp:10226
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::set_associative_find
static detail::error_result set_associative_find(std::true_type, lua_State *L_, T &self, stack_object okey, stack_object value)
Definition: sol.hpp:22030
sol::detail::tagged::value_
T value_
Definition: sol.hpp:6970
sol::stack::stack_detail::get_optional
OptionalType get_optional(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:14546
sol::u_detail::string_for_each_metatable_func::new_idx_call
lua_CFunction new_idx_call
Definition: sol.hpp:23580
sol::basic_protected_function::basic_protected_function
basic_protected_function(lua_State *L_, raw_index index_, handler_t eh)
Definition: sol.hpp:20937
sol::detail::xmovable
bool xmovable(lua_State *leftL, lua_State *rightL)
Definition: sol.hpp:9649
sol::stack::unqualified_pusher< stack_count >::push
static int push(lua_State *, stack_count st) noexcept
Definition: sol.hpp:15184
ok
ROSCPP_DECL bool ok()
sol::state_view::registry
table registry() const
Definition: sol.hpp:27830
sol::is_stateless_lua_reference_v
constexpr bool is_stateless_lua_reference_v
Definition: sol.hpp:8090
sol::basic_coroutine::basic_coroutine
basic_coroutine(T &&r) noexcept
Definition: sol.hpp:28333
sol::function_detail::member_function::operator()
int operator()(lua_State *L) noexcept(traits_type::is_noexcept)
Definition: sol.hpp:19547
sol::meta::unwrapped
Definition: sol.hpp:2157
sol::this_state
Definition: sol.hpp:7755
sol::call_detail::constructor_match::obj_lua_ref_
reference * obj_lua_ref_
Definition: sol.hpp:18163
sol::stack::push_pop
stateless_push_popper< top_level, T > push_pop(lua_State *L_, T &&object_)
Definition: sol.hpp:10107
sol::load_result
Definition: sol.hpp:26812
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::get
static int get(lua_State *L_)
Definition: sol.hpp:22520
sol::container_detail::u_c_launch::clear_call
static int clear_call(lua_State *L)
Definition: sol.hpp:23071
std::allocator
sol::meta::count_for
Definition: sol.hpp:2320
sol::stack::unqualified_pusher< T, std::enable_if_t< is_container_v< T > > >::C
T C
Definition: sol.hpp:23216
sol::basic_object::basic_object
basic_object(detail::no_safety_tag, T &&r) noexcept
Definition: sol.hpp:16842
sol::is_lightuserdata_v
constexpr bool is_lightuserdata_v
Definition: sol.hpp:8564
sol::basic_environment
Definition: forward.hpp:1151
sol::lua_thread_state
Definition: sol.hpp:28078
sol::basic_lua_table::basic_lua_table
basic_lua_table(lua_nil_t r) noexcept
Definition: sol.hpp:26469
sol::stack::unqualified_pusher< const char * >
Definition: sol.hpp:15393
sol::basic_table_core::pairs
basic_pairs_range< basic_table_core > pairs() noexcept
Definition: sol.hpp:25797
sol::meta::is_builtin_type
std::integral_constant< bool, std::is_arithmetic< T >::value||std::is_pointer< T >::value||std::is_array< T >::value > is_builtin_type
Definition: sol.hpp:1435
sol::stack::stack_detail::undefined_metatable::operator()
void operator()() const
Definition: sol.hpp:11670
sol::this_main_state::lua_state
lua_State * lua_state() const noexcept
Definition: sol.hpp:7788
sol::detail::error_result::error_result
error_result(int results_)
Definition: sol.hpp:4557
sol::variadic_args::operator=
variadic_args & operator=(variadic_args &&o)
Definition: sol.hpp:28666
sol::unicode::decoded_result::error
error_code error
Definition: sol.hpp:13071
sol::meta::meta_detail::basic_traits< true, true, void, R, Args... >::first_type
meta::conditional_t< std::is_void< void >::value, int, void > & first_type
Definition: sol.hpp:1550
sol::is_stack_based
Definition: sol.hpp:8451
sol::call_detail::constructor_match::obj_
T * obj_
Definition: sol.hpp:18162
sol::variadic_args::variadic_args
variadic_args(lua_State *luastate, int stackindex, int lastindex)
Definition: sol.hpp:28654
lua_isnumber
LUA_API int lua_isnumber(lua_State *L, int idx)
Definition: lapi.c:303
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::find_associative_lookup
static detail::error_result find_associative_lookup(std::true_type, lua_State *L_, T &, Iter &it, std::size_t)
Definition: sol.hpp:22105
sol::stateless_reference::equals
bool equals(lua_State *L_, lua_nil_t) const noexcept
Definition: sol.hpp:10375
sol::basic_protected_function::invoke
void invoke(types< void >, std::index_sequence< I >, std::ptrdiff_t n, detail::protected_handler< b, handler_t > &h) const
Definition: sol.hpp:21104
sol::stack::stack_detail::not_enough_stack_space_generic
constexpr const char * not_enough_stack_space_generic
Definition: sol.hpp:11552
sol::basic_table_iterator::ref
reference_type ref
Definition: sol.hpp:25051
sol::basic_object::basic_object
basic_object(detail::no_safety_tag, lua_nil_t n)
Definition: sol.hpp:16833
f
f
sol::table_proxy::tbl
Table tbl
Definition: sol.hpp:24759
sol::stack::unqualified_getter< as_table_t< std::forward_list< T, Al > > >::get
static C get(types< K, V >, lua_State *L, int relindex, record &tracking)
Definition: sol.hpp:13865
sol::usertype_traits::user_gc_metatable
static const std::string & user_gc_metatable()
Definition: sol.hpp:9102
LUA_TTHREAD
#define LUA_TTHREAD
Definition: lua.h:73
sol::unicode::unicode_detail::combine_surrogates
static char32_t combine_surrogates(char16_t lead, char16_t trail)
Definition: sol.hpp:13157
sol::raw_index::index
int index
Definition: sol.hpp:7385
sol::stack::unqualified_checker< detail::as_value_tag< T >, type::userdata >::check
static bool check(types< U >, lua_State *L_, int index, type indextype, Handler &&handler, record &tracking)
Definition: sol.hpp:12802
sol::unsafe_function_result::get_type
type get_type(difference_type index_offset=0) const noexcept
Definition: sol.hpp:17494
sol::call_detail::agnostic_lua_call_wrapper::call
static int call(lua_State *L, Fx &&f, Args &&... args)
Definition: sol.hpp:18387
sol::detail::ebco< T &, tag >::ebco
ebco(T &v) noexcept
Definition: sol.hpp:7220
sol::detail::user_allocate
T * user_allocate(lua_State *L)
Definition: sol.hpp:11289
sol::protected_function_result::end
const_iterator end() const
Definition: sol.hpp:17359
sol::stack_reference::abandon
void abandon()
Definition: sol.hpp:9820
sol::basic_thread::basic_thread
basic_thread(stack_reference &&r)
Definition: sol.hpp:28149
sol::stateless_stack_reference::stateless_stack_reference
stateless_stack_reference(absolute_index index_) noexcept
Definition: sol.hpp:9678
sol::wrapper< F, std::enable_if_t< std::is_member_object_pointer< meta::unqualified_t< F > >::value > >::free_args_list
types< object_type &, return_type > free_args_list
Definition: sol.hpp:17708
sol::call_detail::overload_match_arity
int overload_match_arity(Match &&matchfx, lua_State *L, int fxarity, int start, Args &&... args)
Definition: sol.hpp:18336
sol::lua_bind_traits::runtime_variadics_t
std::integral_constant< bool, meta::count_for< is_variadic_arguments, typename base_t::args_list >::value !=0 > runtime_variadics_t
Definition: sol.hpp:8516
sol::stack::unqualified_getter< as_table_t< T > >::insert_at_end
static void insert_at_end(std::false_type, types< V >, lua_State *L, T &cont, std::size_t idx)
Definition: sol.hpp:13599
sol::container_detail::has_erase_key_test
Definition: sol.hpp:21383
sol::stateless_stack_reference_equals::stateless_stack_reference_equals
stateless_stack_reference_equals(lua_State *L_) noexcept
Definition: sol.hpp:9860
luaL_fileresult
LUALIB_API int luaL_fileresult(lua_State *L, int stat, const char *fname)
Definition: lauxlib.c:245
sol::detail::optional_move_base< T, false >::optional_move_base
optional_move_base(optional_move_base &&rhs) noexcept(std::is_nothrow_move_constructible< T >::value)
Definition: sol.hpp:5069
sol::container_detail::container_decay_t
typename container_decay< meta::unqualified_t< T > >::type container_decay_t
Definition: sol.hpp:21645
sol::basic_table_core::get_or
decltype(auto) get_or(Key &&key, T &&otherwise) const
Definition: sol.hpp:25821
sol::stack::unqualified_pusher< const wchar_t * >::push
static int push(lua_State *L, const wchar_t *wstr, std::size_t sz)
Definition: sol.hpp:15644
sol::basic_thread::is_main_thread
bool is_main_thread() const
Definition: sol.hpp:28191
sol::call_detail::lua_call_wrapper< T, overload_set< Fs... >, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, F &fx)
Definition: sol.hpp:18777
sol::protected_function_result::rend
const_reverse_iterator rend() const
Definition: sol.hpp:17378
sol::call_status::handler
@ handler
sol::unicode::utf8_to_code_point
decoded_result< It > utf8_to_code_point(It it, It last)
Definition: sol.hpp:13226
sol::detail::ebco::ebco
ebco(T &&v) noexcept(std::is_nothrow_move_constructible_v< T >)
Definition: sol.hpp:7143
sol::detail::i_am_secret
Definition: sol.hpp:6179
sol::meta::any_same
Definition: sol.hpp:2198
sol::state_view::restart_gc
void restart_gc()
Definition: sol.hpp:27887
sol::total_memory_used
std::size_t total_memory_used(lua_State *L)
Definition: sol.hpp:27143
sol::stack::push_pop
push_popper< top_level, T > push_pop(T &&x)
Definition: sol.hpp:10102
sol::stack::stack_detail::strip< std::reference_wrapper< T > >::type
T & type
Definition: sol.hpp:11561
sol::basic_coroutine::basic_coroutine
basic_coroutine(lua_State *L, int index, handler_t eh)
Definition: sol.hpp:28411
sol::unsafe_function_result::begin
iterator begin()
Definition: sol.hpp:17502
sol::argument_handler
Definition: sol.hpp:9592
sol::function_detail::call
int call(lua_State *L)
Definition: sol.hpp:17899
sol::pairs_iterator::operator==
friend bool operator==(const pairs_sentinel &, const pairs_iterator &left) noexcept
Definition: sol.hpp:25364
sol::state_view::do_string
protected_function_result do_string(const string_view &code, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27529
sol::u_detail::magic_index
constexpr const int magic_index
Definition: sol.hpp:23251
sol::basic_object::basic_object
basic_object(lua_State *L_, ref_index index_) noexcept
Definition: sol.hpp:16883
sol::meta_function::call_construct
@ call_construct
sol::meta_function::bitwise_right_shift
@ bitwise_right_shift
sol::u_detail::usertype_storage_base::is_using_new_index
bool is_using_new_index
Definition: sol.hpp:23694
sol::stack::stack_detail::not_enough_stack_space_integral
constexpr const char * not_enough_stack_space_integral
Definition: sol.hpp:11548
LUA_NOREF
#define LUA_NOREF
Definition: lauxlib.h:86
sol::unicode::unicode_detail::is_invalid
static constexpr bool is_invalid(unsigned char b)
Definition: sol.hpp:13118
sol::is_environment_v
constexpr bool is_environment_v
Definition: sol.hpp:8576
sol::main_lightuserdata
basic_lightuserdata< main_reference > main_lightuserdata
Definition: forward.hpp:1217
sol::stack::push_popper< false, T, std::enable_if_t< is_stack_based_v< meta::unqualified_t< T > > > >::index_of
int index_of(const Tu &object_) const noexcept
Definition: sol.hpp:10043
sol::stateless_stack_reference::valid
bool valid(lua_State *L) const noexcept
Definition: sol.hpp:9716
sol::meta::is_specialization_of_v
constexpr bool is_specialization_of_v
Definition: sol.hpp:1424
sol::overload_set
Definition: sol.hpp:13020
sol::stack::push_popper< true, T, C >::push_popper
push_popper(T) noexcept
Definition: sol.hpp:10025
sol::is_global_table_v
constexpr bool is_global_table_v
Definition: sol.hpp:8541
sol::type::table
@ table
sol::protected_function_result::valid
bool valid() const noexcept
Definition: sol.hpp:17288
sol::is_automagical
Definition: sol.hpp:8585
sol::detail::error_result::error_result
error_result(const char *format_string_, const char *first_message_)
Definition: sol.hpp:4560
sol::tie_t::set
void set(std::false_type, T &&target)
Definition: sol.hpp:10827
sol::detail::is_nothrow_swappable
Definition: sol.hpp:4914
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::add_associative
static detail::error_result add_associative(std::true_type, lua_State *L_, T &self, stack_object key)
Definition: sol.hpp:22229
sol::function_detail::upvalue_this_member_variable::call
static int call(lua_State *L) noexcept(std::is_nothrow_copy_assignable_v< T >)
Definition: sol.hpp:19419
sol::stack::unqualified_getter< as_table_t< T > >::get
static T get(types< K, V >, lua_State *L, int relindex, record &tracking)
Definition: sol.hpp:13757
sol::stack::unqualified_pusher< user< T > >::push
static int push(lua_State *L, no_metatable_t, user< T > &&u)
Definition: sol.hpp:15374
sol::stack::stack_detail::undefined_metatable::L
lua_State * L
Definition: sol.hpp:11663
sol::state_view::safe_script
protected_function_result safe_script(lua_Reader reader, void *data, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27573
sol::container_detail::u_c_launch::set_call
static int set_call(lua_State *L)
Definition: sol.hpp:23111
sol::wstring_view
std::wstring_view wstring_view
Definition: sol.hpp:2136
sol::detail::unique_fallback< std::shared_ptr< T > >::get
static pointer get(lua_State *, const std::shared_ptr< T > &p) noexcept
Definition: sol.hpp:9144
sol::basic_protected_function::invoke
auto invoke(types< Ret... >, std::index_sequence< I... >, std::ptrdiff_t n, detail::protected_handler< b, handler_t > &h) const
Definition: sol.hpp:21092
sol::state_view::operator[]
table_proxy< global_table &, detail::proxy_key_t< T > > operator[](T &&key)
Definition: sol.hpp:28005
sol::stack::unqualified_pusher< factory_wrapper< Functions... > >::push
static int push(lua_State *L, factory_wrapper< Functions... > &&fw)
Definition: sol.hpp:20258
sol::detail::optional_operations_base::hard_reset
void hard_reset() noexcept
Definition: sol.hpp:4976
sol::stack::unqualified_pusher< std::tuple< Args... > >::push
static int push(lua_State *L, T &&t)
Definition: sol.hpp:15911
sol::stateless_reference::stateless_reference
stateless_reference(int raw_ref_index) noexcept
Definition: sol.hpp:10203
sol::light::value
T * value() const
Definition: sol.hpp:7461
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::insert_copyable
static detail::error_result insert_copyable(std::false_type, lua_State *, T &, stack_object, stack_object)
Definition: sol.hpp:22313
sol::stack_proxy_base::push
int push(lua_State *L_) const
Definition: sol.hpp:17155
sol::stack::stack_detail::unqualified_interop_check
bool unqualified_interop_check(lua_State *L, int index, type index_type, Handler &&handler, record &tracking)
Definition: sol.hpp:11635
sol::detail::ebco< T, tag, std::enable_if_t<!std::is_reference_v< T > &&std::is_class_v< T > &&!std::is_final_v< T > > >::value
T & value() &noexcept
Definition: sol.hpp:7198
sol::is_proxy_primitive
Definition: sol.hpp:12322
sol::stack::unqualified_pusher< closure< Arg, Args... > >::push
static int push(std::index_sequence< I... >, lua_State *L, T &&c)
Definition: sol.hpp:15260
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::begin
static iterator begin(lua_State *, T &self)
Definition: sol.hpp:22586
sol::meta::meta_detail::on_even
meta::boolean<(TI::value % 2)==0 > on_even
Definition: sol.hpp:2295
sol::as_args_t
Definition: forward.hpp:1248
sol::protected_function_result::difference_type
std::ptrdiff_t difference_type
Definition: sol.hpp:17240
sol::stack::loose_table_check
bool loose_table_check(lua_State *L_, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:12344
sol::lib::io
@ io
sol::push_type_panic_string
int push_type_panic_string(lua_State *L, int index, type expected, type actual, string_view message, string_view aux_message) noexcept
Definition: sol.hpp:9551
sol::u_detail::index_call_storage::new_index
index_call_function * new_index
Definition: sol.hpp:23442
sol::dump_error::error_code
int error_code() const
Definition: sol.hpp:20551
sol::basic_protected_function::basic_protected_function
basic_protected_function(const basic_protected_function &other_) noexcept
Definition: sol.hpp:20859
sol::stack::unqualified_getter< stack_proxy_base >::get
static stack_proxy_base get(lua_State *L_, int index_=-1)
Definition: sol.hpp:17171
sol::stack::unqualified_pusher< detail::as_table_tag< T > >::push
static int push(std::false_type, lua_State *L, const T &tablecont)
Definition: sol.hpp:15051
sol::upvalue_index::index
int index
Definition: sol.hpp:7375
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::set_start
static detail::error_result set_start(lua_State *L_, T &self, stack_object key, stack_object value)
Definition: sol.hpp:22423
sol::stack::push_popper_at::push_popper_at
push_popper_at(lua_State *L_, int index_=-1, int count_=1)
Definition: sol.hpp:9975
SOL_CONTAINER_START_INDEX_I_
#define SOL_CONTAINER_START_INDEX_I_
Definition: sol.hpp:702
sol::no_panic
int no_panic(lua_State *, int, type, type, const char *=nullptr) noexcept
Definition: sol.hpp:9616
sol::basic_coroutine::basic_coroutine
basic_coroutine(lua_State *L, ref_index index)
Definition: sol.hpp:28435
sol::container_detail::u_c_launch::index_call
static int index_call(lua_State *L)
Definition: sol.hpp:23115
lua_Alloc
void *(* lua_Alloc)(void *ud, void *ptr, size_t osize, size_t nsize)
Definition: lua.h:125
sol::stack::unqualified_getter< std::basic_string< char32_t, Traits, Al > >::get
static std::basic_string< char32_t, Traits, Al > get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14038
sol::meta_function::gc_names
@ gc_names
sol::protected_function_result::pointer
stack_proxy * pointer
Definition: sol.hpp:17239
sol::stack::unqualified_pusher< std::pair< A, B > >::push
static int push(lua_State *L, T &&t)
Definition: sol.hpp:15919
sol::meta::is_detected
typename meta_detail::is_detected< Trait, void, Args... >::type is_detected
Definition: sol.hpp:1390
lua.h
basic_format_string
Definition: core.h:2768
lua_yield
#define lua_yield(L, n)
Definition: lua.h:305
package
string package
sol::protected_function_result::begin
iterator begin()
Definition: sol.hpp:17350
sol::optional::take
optional take() &
Definition: sol.hpp:5631
sol::detail::enable_if_ret_void
enable_if_t< returns_void< T &&, U... >::value > enable_if_ret_void
Definition: sol.hpp:4830
sol::container_detail::usertype_container_default::erase
static int erase(lua_State *L_)
Definition: sol.hpp:21725
sol::stack_unsafe_function
basic_function< stack_reference, false > stack_unsafe_function
Definition: forward.hpp:1164
sol::stack::unqualified_pusher< no_construction >::push
static int push(lua_State *L, no_construction)
Definition: sol.hpp:20279
sol::basic_coroutine::basic_coroutine
basic_coroutine(basic_function< base_t > &&b) noexcept
Definition: sol.hpp:28360
sol::get
stack_proxy get(const unsafe_function_result &fr)
Definition: sol.hpp:17614
luaL_getmetatable
#define luaL_getmetatable(L, n)
Definition: lauxlib.h:150
runtime
auto runtime(string_view s) -> runtime_format_string<>
Definition: core.h:2816
sol::weak_derive::value
static bool value
Definition: forward.hpp:1279
sol::constructor_wrapper::functions
std::tuple< Functions... > functions
Definition: sol.hpp:7007
sol::stack::stack_detail::copy_code_units_utf
Definition: sol.hpp:13374
sol::call_detail::lua_call_wrapper< T, protect_t< V >, is_index, is_variable, checked, boost, clean_stack, C >::F
protect_t< V > F
Definition: sol.hpp:18880
sol::basic_table_core::create
table create(int narr=0, int nrec=0)
Definition: sol.hpp:26092
sol::detail::protected_handler::target
const Target & target
Definition: sol.hpp:20741
sol::unsafe_function_result::return_count
int return_count() const
Definition: sol.hpp:17554
sol::meta_function::static_new_index
@ static_new_index
sol::u_detail::lua_reference_func
Definition: sol.hpp:23630
sol::automagic_enrollments
Definition: sol.hpp:8703
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::find
static int find(std::true_type, lua_State *L_)
Definition: sol.hpp:22693
sol::detail::error_result::error_result
error_result()
Definition: sol.hpp:4554
sol::container_detail::usertype_container_default::iterator
lua_nil_t iterator
Definition: sol.hpp:21673
sol::basic_reference::push
int push(lua_State *L_) const noexcept
Definition: sol.hpp:10599
sol::meta::meta_detail::is_specialization_of
Definition: sol.hpp:1415
sol::stack::unqualified_checker
Definition: sol.hpp:11455
sol::u_detail::lookup_failed_index
constexpr const int lookup_failed_index
Definition: sol.hpp:23258
sol::stack::stack_detail::get_function_pointer
Function * get_function_pointer(lua_State *, int, record &) noexcept
Definition: sol.hpp:20504
sol::call_detail::lua_call_wrapper< T, factory_wrapper< Fs... >, is_index, is_variable, checked, boost, clean_stack, C >::on_match::operator()
int operator()(types< Fx >, meta::index_value< I >, types< R... >, types< Args... >, lua_State *L, int, int, F &fx)
Definition: sol.hpp:18788
sol::ref_index::ref_index
ref_index(int idx)
Definition: sol.hpp:7406
sol::stack::push_popper_at::~push_popper_at
~push_popper_at()
Definition: sol.hpp:9977
sol::meta::count_for_pack
Definition: sol.hpp:2314
sol::optional< T & >::optional
constexpr optional(nullopt_t) noexcept
\group ctor_empty
Definition: sol.hpp:6681
sol::container_detail::u_c_launch::real_pairs_traits
static int real_pairs_traits(std::true_type, lua_State *L)
Definition: sol.hpp:22930
sol::state_view::memory_used
std::size_t memory_used() const
Definition: sol.hpp:27834
sol::detail::get
stack_proxy get(types< Args... >, meta::index_value< 0 >, meta::index_value< I >, const T &fr)
Definition: sol.hpp:17597
sol::state_view::create_table
static table create_table(lua_State *L, int narr, int nrec, Key &&key, Value &&value, Args &&... args)
Definition: sol.hpp:28062
sol::detail::error_result::argument_strings
std::array< const char *, 4 > argument_strings
Definition: sol.hpp:4552
sol::call_detail::lua_call_wrapper< T, readonly_wrapper< F >, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, readonly_wrapper< F > &&rw, object_type &o)
Definition: sol.hpp:18656
sol::detail::make_destructor
lua_CFunction make_destructor()
Definition: sol.hpp:12203
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::get
static int get(lua_State *L_)
Definition: sol.hpp:22748
sol::basic_object_base::base_t
ref_t base_t
Definition: sol.hpp:16765
sol::protected_function_result::returncount
int returncount
Definition: sol.hpp:17232
sol::meta::meta_detail::callable_traits< R(T::*), true >::Arg
return_type Arg
Definition: sol.hpp:1997
sol::function_detail::member_variable::return_type
meta::bind_traits< function_type >::return_type return_type
Definition: sol.hpp:19566
sol::detail::inheritance_check_function
decltype(&inheritance< void >::type_check) inheritance_check_function
Definition: sol.hpp:9486
sol::destructor
auto destructor(Fx &&fx)
Definition: sol.hpp:7044
sol::meta::is_associative
meta::all< has_key_type< T >, has_key_value_pair< T >, has_mapped_type< T > > is_associative
Definition: sol.hpp:2715
sol::stack::probe::success
bool success
Definition: sol.hpp:11465
sol::is_tieable
Definition: sol.hpp:10819
sol::basic_coroutine
Definition: forward.hpp:1203
sol::stack::unqualified_getter< std::tuple< Tn... > >::get
static R get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14308
sol::stack::multi_push
int multi_push(lua_State *L, T &&t, Args &&... args)
Definition: sol.hpp:11838
sol::load_status::syntax
@ syntax
sol::meta_function::bitwise_and
@ bitwise_and
sol::u_detail::usertype_storage::meta_index_call_with_bases
static int meta_index_call_with_bases(lua_State *L)
Definition: sol.hpp:24047
sol::meta_function::equal_to
@ equal_to
sol::stack::unqualified_pusher< push_invoke_t< T > >::push
static int push(lua_State *L, push_invoke_t< T > &&pi)
Definition: sol.hpp:20457
sol::stack::unqualified_getter< nullopt_t >::get
static nullopt_t get(lua_State *, int, record &tracking)
Definition: sol.hpp:14123
sol::stack::record::use
void use(int count) noexcept
Definition: sol.hpp:11482
sol::basic_reference::operator=
basic_reference & operator=(basic_reference<!main_only > &&r) noexcept
Definition: sol.hpp:10569
sol::d::u
Definition: sol.hpp:7280
sol::protected_function_result::get_type
type get_type(int index_offset=0) const noexcept
Definition: sol.hpp:17342
sol::detail::any_is_destructor_v
constexpr bool any_is_destructor_v
Definition: sol.hpp:8644
sol::detail::any_is_constructor_v
constexpr bool any_is_constructor_v
Definition: sol.hpp:8632
sol::basic_protected_function::set_default_handler
static void set_default_handler(const T &ref)
Definition: sol.hpp:21048
sol::pairs_iterator::operator==
friend bool operator==(const pairs_iterator &left, const pairs_sentinel &) noexcept
Definition: sol.hpp:25356
sol::detail::ebco::operator=
ebco & operator=(const T &v) noexcept(std::is_nothrow_copy_assignable_v< T >)
Definition: sol.hpp:7144
sol::stack::unqualified_getter< c_closure >::get
static c_closure get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14155
sol::container_detail::u_c_launch::real_add_traits
static int real_add_traits(std::true_type, lua_State *L)
Definition: sol.hpp:22978
sol::stack::unqualified_getter< char16_t >::get
static char16_t get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14045
sol_m_assert
#define sol_m_assert(message,...)
Definition: sol.hpp:2932
sol::closure<>::c_function
lua_CFunction c_function
Definition: sol.hpp:7543
LUA_OPEQ
#define LUA_OPEQ
Definition: lua.h:222
sol::argument_handler::operator()
int operator()(lua_State *L, int index, type expected, type actual, string_view message) const noexcept(false)
Definition: sol.hpp:9593
dummy
int dummy
Definition: lstrlib.c:1350
sol::load_result::stack_index
int stack_index() const noexcept
Definition: sol.hpp:26919
sol::u_detail::new_index_call_storage::new_binding_data
void * new_binding_data
Definition: sol.hpp:23447
sol::meta::disable
std::enable_if_t< neg< all< Args... > >::value, enable_t > disable
Definition: sol.hpp:2247
nonstd::span_lite::size
span_constexpr std::size_t size(span< T, Extent > const &spn)
Definition: span.hpp:1554
sol::stack::unqualified_getter< type >::get
static type get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:13975
sol::detail::direct_error
const auto direct_error
Definition: sol.hpp:4547
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::insert_after_has
static detail::error_result insert_after_has(std::true_type, lua_State *L_, T &self, stack_object where, stack_object value)
Definition: sol.hpp:22275
sol::call_status::gc
@ gc
sol::u_detail::get_usertype_storage
usertype_storage< T > & get_usertype_storage(lua_State *L_)
Definition: sol.hpp:24312
sol::detail::optional_move_base
Definition: sol.hpp:5055
sol::override_value_t
Definition: sol.hpp:7737
sol::stack::probe_raw_get_field
probe probe_raw_get_field(lua_State *L, Key &&key, int tableindex)
Definition: sol.hpp:12120
luaL_newmetatable
LUALIB_API int luaL_newmetatable(lua_State *L, const char *tname)
Definition: lauxlib.c:311
sol::basic_object::basic_object
basic_object(lua_State *L_, T &&r)
Definition: sol.hpp:16857
sol::policy_detail::handle_policy
void handle_policy(static_stack_dependencies< I, In... >, lua_State *L, int &)
Definition: sol.hpp:18079
sol::basic_coroutine::luacall
void luacall(std::ptrdiff_t argcount, std::ptrdiff_t)
Definition: sol.hpp:28282
sol::stateless_stack_reference_equals::is_transparent
std::true_type is_transparent
Definition: sol.hpp:9858
codepoint
static int codepoint(lua_State *L)
Definition: lutf8lib.c:122
sol::detail::lua_reg_table
luaL_Reg[64] lua_reg_table
Definition: sol.hpp:10950
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::get_category
static detail::error_result get_category(std::input_iterator_tag, lua_State *L_, T &self, K &key)
Definition: sol.hpp:21861
sol::stack::raw_get_field
void raw_get_field(lua_State *L, Key &&key, int tableindex)
Definition: sol.hpp:12100
sol::optional< T & >::emplace
T & emplace(Args &&... args) noexcept
Definition: sol.hpp:6751
sol::unicode::decoded_result::next
It next
Definition: sol.hpp:13073
sol::stack::push_popper< false, T, std::enable_if_t< is_stack_based_v< meta::unqualified_t< T > > > >::push_popper
push_popper(T) noexcept
Definition: sol.hpp:10040
sol::basic_reference::operator=
basic_reference & operator=(const basic_reference<!main_only > &r) noexcept
Definition: sol.hpp:10574
sol::basic_pairs_range::cbegin
const_iterator cbegin() const noexcept
Definition: sol.hpp:25412
sol::basic_coroutine::basic_coroutine
basic_coroutine(lua_nil_t n)
Definition: sol.hpp:28405
sol::state::unique_base
std::unique_ptr< lua_State, detail::state_deleter > unique_base
Definition: sol.hpp:28240
sol::unicode::unicode_detail::is_surrogate
static constexpr bool is_surrogate(char32_t u)
Definition: sol.hpp:13102
sol::lib::jit
@ jit
sol::container_detail::u_c_launch::at_call
static int at_call(lua_State *L)
Definition: sol.hpp:23103
sol::stack::stateless_push_popper< false, T, std::enable_if_t< is_stack_based_v< meta::unqualified_t< T > > > >::stateless_push_popper
stateless_push_popper(lua_State *L_, T) noexcept
Definition: sol.hpp:10090
sol::call_detail::overload_detail::overload_match_arity_single
int overload_match_arity_single(types< Fx, Fx1, Fxs... >, std::index_sequence< I, I1, In... >, std::index_sequence< M... >, Match &&matchfx, lua_State *L, int fxarity, int start, Args &&... args)
Definition: sol.hpp:18289
sol::basic_variadic_results::basic_variadic_results
basic_variadic_results()
Definition: sol.hpp:28830
sol::function_detail::call_wrapper_entry
int call_wrapper_entry(lua_State *L) noexcept(meta::bind_traits< F >::is_noexcept)
Definition: sol.hpp:19059
lua_len
LUA_API void lua_len(lua_State *L, int idx)
Definition: lapi.c:1291
sol::stack::unqualified_pusher< const char32_t * >
Definition: sol.hpp:15762
sol::is_table_like
std::integral_constant< bool, is_table_v< T >||is_environment_v< T >||is_userdata_v< T > > is_table_like
Definition: sol.hpp:8579
sol::stack::stack_detail::convert
void convert(const char *strb, const char *stre, F &&f)
Definition: sol.hpp:13387
sol::optional< T & >::operator*
SOL_TL_OPTIONAL_11_CONSTEXPR T & operator*()
Definition: sol.hpp:6786
sol::state_view::state_view
state_view(this_state Ls)
Definition: sol.hpp:27312
lua_rawset
LUA_API void lua_rawset(lua_State *L, int idx)
Definition: lapi.c:903
sol::operator&
constexpr automagic_flags operator&(automagic_flags left, automagic_flags right) noexcept
Definition: sol.hpp:8673
sol::basic_table_iterator::reference
value_type & reference
Definition: sol.hpp:25046
sol::stack::unqualified_pusher< T, std::enable_if_t< meta::is_optional_v< T > > >::ValueType
typename meta::unqualified_t< T >::value_type ValueType
Definition: sol.hpp:15928
sol::stack_reference_equals::operator()
bool operator()(const stack_reference &lhs, const stack_reference &rhs) const
Definition: sol.hpp:9894
sol::userdata_value::m_value
void * m_value
Definition: sol.hpp:7432
sol::unsafe_function_result::value_type
stack_proxy value_type
Definition: sol.hpp:17447
sol::unsafe_function_result::stack_index
int stack_index() const
Definition: sol.hpp:17551
sol::stateless_stack_reference_hash::operator()
result_type operator()(const argument_type &lhs) const noexcept
Definition: sol.hpp:9911
sol::stack::stack_detail::not_enough_stack_space_userdata
constexpr const char * not_enough_stack_space_userdata
Definition: sol.hpp:11551
sol::function_detail::functor_function::operator()
int operator()(lua_State *L) noexcept(noexcept(call_detail::call_wrapped< void, true, false >(L, invocation)))
Definition: sol.hpp:19506
sol::meta::meta_detail::basic_traits::args_tuple
std::tuple< Args... > args_tuple
Definition: sol.hpp:1559
sol::stack::unqualified_pusher< wchar_t * >::push
static int push(lua_State *L, const wchar_t *str, std::size_t len)
Definition: sol.hpp:15676
sol::is_table_v
constexpr bool is_table_v
Definition: sol.hpp:8533
sol::detail::policy_base_tag
Definition: sol.hpp:7058
sol::basic_pairs_range::begin
iterator begin() noexcept
Definition: sol.hpp:25404
sol::overload_set::functions
std::tuple< Functions... > functions
Definition: sol.hpp:13021
sol::u_detail::submetatable_type::const_reference
@ const_reference
sol::state_view::clear_package_loaders
void clear_package_loaders()
Definition: sol.hpp:27426
sol::load_result::get
T get() const
Definition: sol.hpp:26869
sol::function_arguments::function_arguments
function_arguments(Arg &&arg, Args &&... args)
Definition: sol.hpp:7560
sol::stack::stack_detail::uu_pusher::actual
unique_usertype_actual_t< T > actual
Definition: sol.hpp:14893
sol::stack_dependencies::len
std::size_t len
Definition: sol.hpp:7071
sol::meta::all
Definition: sol.hpp:2219
sol::u_detail::new_index_function_index
constexpr const int new_index_function_index
Definition: sol.hpp:23255
sol::meta::index_value
std::integral_constant< std::size_t, I > index_value
Definition: sol.hpp:1396
sol::stack_metatable
basic_metatable< stack_reference > stack_metatable
Definition: forward.hpp:1148
sol::lua_thread_state::operator->
lua_State * operator->() const noexcept
Definition: sol.hpp:28090
LUA_GCRESTART
#define LUA_GCRESTART
Definition: lua.h:320
sol::basic_object::operator=
basic_object & operator=(base_type &&b)
Definition: sol.hpp:16899
sol::stack::stack_detail::strip
Definition: sol.hpp:11556
sol::stateless_reference::registry_index
int registry_index() const noexcept
Definition: sol.hpp:10301
sol::optional::operator=
optional & operator=(U &&u)
Definition: sol.hpp:5783
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::get_associative_find
static detail::error_result get_associative_find(std::true_type, lua_State *L_, T &self, K &key)
Definition: sol.hpp:22406
sol::stack::stack_detail::get_into
S get_into(lua_State *L, int index, record &tracking)
Definition: sol.hpp:13411
sol::stack::unqualified_pusher< char * >::push
static int push(lua_State *L, const char *str, std::size_t len)
Definition: sol.hpp:15437
sol::make_reference_userdata
R make_reference_userdata(lua_State *L, T &&value)
Definition: sol.hpp:16735
sol::basic_table_core::basic_table_core
basic_table_core(lua_State *L, const new_table &nt)
Definition: sol.hpp:25736
sol::function_detail::upvalue_member_function::function_type
std::remove_pointer_t< std::decay_t< Function > > function_type
Definition: sol.hpp:19165
sol::stack::unqualified_getter< userdata_value >::get
static userdata_value get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:13930
sol::basic_table_iterator::basic_table_iterator
basic_table_iterator() noexcept
Definition: sol.hpp:25057
SOL_BOOST_NONE_CONSTEXPR_I_
#define SOL_BOOST_NONE_CONSTEXPR_I_
Definition: sol.hpp:816
sol::type_panic_c_str
int type_panic_c_str(lua_State *L, int index, type expected, type actual, const char *message=nullptr) noexcept(false)
Definition: sol.hpp:9568
sol::meta_function::static_index
@ static_index
sol::container_detail::usertype_container_default::size
static int size(lua_State *L_)
Definition: sol.hpp:21713
sol::state_view::collect_garbage
void collect_garbage()
Definition: sol.hpp:27866
sol::basic_protected_function::basic_protected_function
basic_protected_function(lua_nil_t n)
Definition: sol.hpp:20916
sol::call_detail::is_var_bind
Definition: sol.hpp:18961
sol::as_function
auto as_function(Args &&... args)
Definition: sol.hpp:7565
sol::member_function_wrapper::returns_list
meta::tuple_types< R > returns_list
Definition: sol.hpp:17765
sol::basic_object::basic_object
basic_object(std::integral_constant< bool, invert_and_pop >, lua_State *L_, int index_=-1) noexcept
Definition: sol.hpp:16826
sol::stack::luajit_exception_handler
void luajit_exception_handler(lua_State *L, int(*handler)(lua_State *, lua_CFunction)=detail::c_trampoline)
Definition: sol.hpp:16676
lua_insert
#define lua_insert(L, idx)
Definition: lua.h:390
sol::basic_variadic_results<>::base_t
std::vector< object, typename std::allocator< object > > base_t
Definition: sol.hpp:28827
sol::stack::unqualified_getter< std::nullptr_t >::get
static std::nullptr_t get(lua_State *, int, record &tracking)
Definition: sol.hpp:14115
sol::detail::protected_function_error
constexpr const char * protected_function_error
Definition: sol.hpp:9515
sol::u_detail::usertype_storage_base::properties
std::bitset< 64 > properties
Definition: sol.hpp:23695
sol::detail::is_tagged_v
constexpr bool is_tagged_v
Definition: sol.hpp:10946
sol::basic_protected_function::basic_protected_function
basic_protected_function(const basic_function< base_t > &b, handler_t eh)
Definition: sol.hpp:20878
sol::stack::clear
void clear(lua_State *L, int table_index)
Definition: sol.hpp:11710
sol::u_detail::submetatable_type::const_value
@ const_value
sol::basic_table_core::create
table create(Name &&name, int narr, int nrec, Key &&key, Value &&value, Args &&... args)
Definition: sol.hpp:26109
sol::stack::stack_detail::metatable_setup::metatable_setup
metatable_setup(lua_State *L)
Definition: sol.hpp:23131
sol::basic_metatable::basic_metatable
basic_metatable(lua_State *L, ref_index index)
Definition: sol.hpp:26201
sol::stack::unqualified_getter< as_table_t< T > >::get
static T get(lua_State *L, int relindex, record &tracking)
Definition: sol.hpp:13611
sol::basic_reference::basic_reference
basic_reference(basic_reference<!main_only > &&o) noexcept
Definition: sol.hpp:10553
sol::detail::ebco::value
T const & value() const &noexcept
Definition: sol.hpp:7164
sol::stateless_reference::stateless_reference
stateless_reference(lua_State *L_, absolute_index index_) noexcept
Definition: sol.hpp:10265
sol::basic_table_core::basic_table_core
basic_table_core(detail::no_safety_tag, lua_State *L, T &&r) noexcept
Definition: sol.hpp:25705
sol::stack::unqualified_pusher< char32_t >::push
static int push(lua_State *L, char32_t c)
Definition: sol.hpp:15892
sol::stack::unqualified_pusher< unsafe_function_result >::push
static int push(lua_State *L, const unsafe_function_result &fr)
Definition: sol.hpp:17572
sol::stack::unqualified_getter< detail::as_pointer_tag< T > >::get
static T * get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14238
sol::basic_reference::basic_reference
basic_reference(lua_State *L_, int index=-1) noexcept
Definition: sol.hpp:10521
sol::is_global_table
Definition: sol.hpp:8536
sol::basic_reference::registry_index
int registry_index() const noexcept
Definition: sol.hpp:10622
sol::u_detail::binding::data_
F data_
Definition: sol.hpp:23465
lua_rawget
LUA_API int lua_rawget(lua_State *L, int idx)
Definition: lapi.c:726
sol::optional::map_or_else
detail::invoke_result_t< U > map_or_else(F &&f, U &&u) &&
Definition: sol.hpp:5555
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::V
KV::second_type V
Definition: sol.hpp:21771
sol::member_function_wrapper::args_list
traits_type::args_list args_list
Definition: sol.hpp:17763
detail::invalid_code_point
constexpr FMT_INLINE_VARIABLE uint32_t invalid_code_point
Definition: format.h:662
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::find_comparative
static detail::error_result find_comparative(std::true_type, lua_State *L_, T &self)
Definition: sol.hpp:22122
sol::stack_iterator::pointer
meta::conditional_t< is_const, const proxy_t *, proxy_t * > pointer
Definition: sol.hpp:16996
sol::stack::check_usertype
bool check_usertype(lua_State *L, int index=-lua_size< meta::unqualified_t< T >>::value)
Definition: sol.hpp:11925
sol::lua_type_of_v
constexpr type lua_type_of_v
Definition: sol.hpp:8391
sol::state_view::load
load_result load(const string_view &code, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27776
sol::basic_object::operator=
basic_object & operator=(proxy_base< Super > &&r)
Definition: sol.hpp:16909
sol::meta_function::to_string
@ to_string
sol::basic_reference::basic_reference
basic_reference(const basic_reference<!main_only > &o) noexcept
Definition: sol.hpp:10549
sol::var
auto var(V &&v)
Definition: sol.hpp:18020
sol::stack::unqualified_pusher< constructor_list< L0, Lists... > >::cl_t
constructor_list< L0, Lists... > cl_t
Definition: sol.hpp:20317
sol::stack::stack_detail::metatable_setup
Definition: sol.hpp:23128
sol::function_detail::upvalue_member_function::real_call
static int real_call(lua_State *L) noexcept(traits_type::is_noexcept)
Definition: sol.hpp:19168
sol::stack::push_popper::Tu
meta::unqualified_t< T > Tu
Definition: sol.hpp:10005
sol::stack::unqualified_pusher< wchar_t >::push
static int push(lua_State *L, wchar_t c)
Definition: sol.hpp:15876
sol::detail::properties_enrollment_allowed::enrollments
automagic_enrollments & enrollments
Definition: sol.hpp:11384
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::empty_has
static bool empty_has(std::false_type, lua_State *L_, T &self)
Definition: sol.hpp:22402
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::erase_after_has
static detail::error_result erase_after_has(std::true_type, lua_State *L_, T &self, K &key)
Definition: sol.hpp:22347
sol::stack::unqualified_pusher< user< T > >::push
static int push(lua_State *L, Arg &&arg, Args &&... args)
Definition: sol.hpp:15343
sol::stack::unqualified_pusher< char16_t * >::push
static int push(lua_State *L, const char16_t *str, std::size_t len)
Definition: sol.hpp:15754
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::add_insert
static detail::error_result add_insert(std::true_type, lua_State *L_, T &self, stack_object value)
Definition: sol.hpp:22173
sol::policy_wrapper
Definition: forward.hpp:1252
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::add_insert_after
static detail::error_result add_insert_after(std::false_type, lua_State *, T &, stack_object)
Definition: sol.hpp:22148
sol::function_detail::member_variable
Definition: sol.hpp:19564
sol::unicode::encoded_result::code_units_size
std::size_t code_units_size
Definition: sol.hpp:13079
sol::basic_reference::basic_reference
basic_reference(lua_State *L_, lua_nil_t) noexcept
Definition: sol.hpp:10533
sol::self_dependency
static_stack_dependencies<-1, 1 > self_dependency
Definition: sol.hpp:7063
sol::state_view::load_file
load_result load_file(const std::string &filename, load_mode mode=load_mode::any)
Definition: sol.hpp:27792
sol::meta::meta_detail::basic_traits::return_type
R return_type
Definition: sol.hpp:1561
sol::basic_function::invoke
unsafe_function_result invoke(types<>, std::index_sequence<>, std::ptrdiff_t n) const
Definition: sol.hpp:20617
sol::stack::unqualified_getter< as_table_t< T > >::push_back_at_end
static void push_back_at_end(std::false_type, types< V > t, lua_State *L, T &cont, std::size_t idx)
Definition: sol.hpp:13588
sol::detail::state_deleter::operator()
void operator()(lua_State *L) const
Definition: sol.hpp:6957
sol::u_detail::submetatable_type::named
@ named
lua_tointeger
#define lua_tointeger(L, i)
Definition: lua.h:363
sol::detail::error_result::results
int results
Definition: sol.hpp:4550
sol::stack::unqualified_pusher< T *, std::enable_if_t< is_container_v< T > > >::push
static int push(lua_State *L, T *cont)
Definition: sol.hpp:23229
sol::optional::or_else
optional< T > SOL_TL_OPTIONAL_11_CONSTEXPR or_else(F &&f) &&
\exclude
Definition: sol.hpp:5466
sol::stack::unqualified_pusher< char * >::push
static int push(lua_State *L, const char *strb, const char *stre)
Definition: sol.hpp:15431
sol::basic_coroutine::basic_coroutine
basic_coroutine(const basic_function< base_t > &b) noexcept
Definition: sol.hpp:28357
sol::detail::optional_copy_assign_base
Definition: sol.hpp:5085
sol::stack::unqualified_pusher< stack_proxy_base >::push
static int push(lua_State *, const stack_proxy_base &proxy_reference)
Definition: sol.hpp:17178
sol::basic_reference::operator=
basic_reference & operator=(const basic_reference &r) noexcept
Definition: sol.hpp:10564
sol::detail::unique_fallback< std::unique_ptr< T, D > >::is_null
static bool is_null(lua_State *, const std::unique_ptr< T, D > &p) noexcept
Definition: sol.hpp:9155
sol::optional::take
optional take() const &
\group take
Definition: sol.hpp:5638
sol::basic_coroutine::basic_coroutine
basic_coroutine(const stack_reference &r) noexcept
Definition: sol.hpp:28367
sol::stack::unqualified_pusher< basic_variadic_results< Al > >::push
int push(lua_State *L, const basic_variadic_results< Al > &e)
Definition: sol.hpp:28870
sol::optional::map_or_else
detail::invoke_result_t< U > map_or_else(F &&f, U &&u) &
Maps the stored value with f if there is one, otherwise calls u and returns the result.
Definition: sol.hpp:5547
sol::function_detail::select_convertible
void select_convertible(types<>, lua_State *L, Fx &&fx, Args &&... args)
Definition: sol.hpp:19865
sol::function_detail::upvalue_member_variable::traits_type
lua_bind_traits< function_type > traits_type
Definition: sol.hpp:19222
sol::detail::ebco< T &&, tag >::ref
T && ref
Definition: sol.hpp:7236
sol::detail::error_result
Definition: sol.hpp:4549
lua_setfield
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
Definition: lapi.c:865
sol::optional::operator=
optional & operator=(const optional< U > &rhs)
Definition: sol.hpp:5800
sol::optional< T & >::or_else
optional< T > or_else(F &&f) &&
Definition: sol.hpp:6469
sol::stack::unqualified_pusher< variadic_results >::push
int push(lua_State *L, const variadic_results &r)
Definition: sol.hpp:28881
sol::stack::unqualified_pusher< Signature, std::enable_if_t< meta::all< std::is_function< std::remove_pointer_t< Signature > >, meta::neg< std::is_same< Signature, lua_CFunction > >, meta::neg< std::is_same< Signature, std::remove_pointer_t< lua_CFunction > > >, meta::neg< std::is_same< Signature, detail::lua_CFunction_noexcept > >, meta::neg< std::is_same< Signature, std::remove_pointer_t< detail::lua_CFunction_noexcept > > > >::value > >::push
static int push(lua_State *L, F &&f)
Definition: sol.hpp:20173
sol::is_function_binding
Definition: sol.hpp:18992
sol::unicode::unicode_detail::decode
static constexpr char32_t decode(unsigned char b0, unsigned char b1, unsigned char b2)
Definition: sol.hpp:13141
sol::stack::modify_unique_usertype_as
void modify_unique_usertype_as(const stack_reference &obj, F &&f)
Definition: sol.hpp:12145
sol::basic_userdata::basic_userdata
basic_userdata(lua_State *L, T &&r)
Definition: sol.hpp:28523
lua_pushcclosure
LUA_API void lua_pushcclosure(lua_State *L, lua_CFunction fn, int n)
Definition: lapi.c:573
sol::call_detail::constructor_match::constructor_match
constructor_match(T *obj_ptr, reference &obj_lua_ref, stack::stack_detail::undefined_metatable &umf)
Definition: sol.hpp:18166
sol::u_detail::usertype_storage_base::storage
std::vector< std::unique_ptr< binding_base > > storage
Definition: sol.hpp:23678
sol::basic_coroutine::basic_coroutine
basic_coroutine(stack_reference &&r, handler_t eh) noexcept
Definition: sol.hpp:28375
sol::detail::clean::L
lua_State * L
Definition: sol.hpp:25436
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::add_copyable
static detail::error_result add_copyable(std::true_type, lua_State *L_, T &self, stack_object value, Iter &pos)
Definition: sol.hpp:22244
sol::function_detail::overloaded_function
Definition: sol.hpp:19619
sol::table_proxy::key
key_type key
Definition: sol.hpp:24760
sol::basic_protected_function::dump
int dump(lua_Writer writer, void *userdata_pointer_, bool strip=false) const
Definition: sol.hpp:20966
sol::stack::call_from_top
decltype(auto) call_from_top(types< R > tr, types< Args... > ta, lua_State *L, Fx &&fx, FxArgs &&... args)
Definition: sol.hpp:16588
luaopen_io
LUAMOD_API int luaopen_io(lua_State *L)
Definition: liolib.c:819
sol::meta::any_same_v
constexpr bool any_same_v
Definition: sol.hpp:2204
sol::unicode::error_code::invalid_trailing_surrogate
@ invalid_trailing_surrogate
nlohmann::detail::make_index_sequence
make_integer_sequence< size_t, N > make_index_sequence
Definition: json.hpp:3151
sol::detail::inheritance_cast_function
decltype(&inheritance< void >::type_cast) inheritance_cast_function
Definition: sol.hpp:9487
sol::no_construction
Definition: sol.hpp:6999
sol::overload_set::overload_set
overload_set(Arg &&arg, Args &&... args)
Definition: sol.hpp:13023
sol::u_detail::usertype_storage_base::const_reference_index_table
stateless_reference const_reference_index_table
Definition: sol.hpp:23685
sol::function_arguments
Definition: sol.hpp:7557
sol::stateless_reference::operator=
stateless_reference & operator=(stateless_reference &&o) noexcept
Definition: sol.hpp:10283
sol::detail::not_enough_stack_space_integral
constexpr const char * not_enough_stack_space_integral
Definition: sol.hpp:9509
sol::state_view::for_each
void for_each(Fx &&fx)
Definition: sol.hpp:28000
LUAL_BUFFERSIZE
#define LUAL_BUFFERSIZE
Definition: luaconf.h:763
sol::closure::c_function
lua_CFunction c_function
Definition: sol.hpp:7535
sol::detail::is_msvc_callable_rigged
meta::any< meta::is_specialization_of< T, push_invoke_t >, meta::is_specialization_of< T, as_table_t >, meta::is_specialization_of< T, forward_as_value_t >, meta::is_specialization_of< T, as_container_t >, meta::is_specialization_of< T, nested >, meta::is_specialization_of< T, yielding_t > > is_msvc_callable_rigged
Definition: sol.hpp:8414
sol::detail::unique_fallback< std::shared_ptr< T > >::pointer
typename std::pointer_traits< std::shared_ptr< T > >::element_type * pointer
Definition: sol.hpp:9131
sol::lua_value::lua_value
lua_value(lua_State *L_, T &&value)
Definition: sol.hpp:26973
sol::container_detail::u_c_launch::real_erase_traits
static int real_erase_traits(std::false_type, lua_State *L)
Definition: sol.hpp:23030
sol::stack::unqualified_pusher< basic_bytecode< Allocator > >::push
static int push(lua_State *L, T &&bc, const char *bytecode_name)
Definition: sol.hpp:15990
l_inspectstat
#define l_inspectstat(stat, what)
Definition: lauxlib.c:278
sol::table_proxy::setup_table
auto setup_table(std::true_type)
Definition: sol.hpp:24745
sol::stack::unqualified_pusher< std::variant< Tn... > >::push
static int push(lua_State *L, const std::variant< Tn... > &v)
Definition: sol.hpp:16025
sol::basic_function
Definition: forward.hpp:1157
sol::as_container_t::type
T type
Definition: sol.hpp:7671
sol::stack::unqualified_pusher< user< T > >::push
static int push(lua_State *L, user< T > &&u)
Definition: sol.hpp:15364
sol::type
type
Definition: sol.hpp:7883
sol::protected_function_result::return_count
int return_count() const noexcept
Definition: sol.hpp:17394
sol::optional< T & >::optional
constexpr optional(U &&u)
Definition: sol.hpp:6699
sol::stack::unqualified_pusher< char * >::push
static int push(lua_State *L, const char *str)
Definition: sol.hpp:15425
sol::state_view::require_script
object require_script(const std::string &key, const string_view &code, bool create_global=true, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27415
sol::detail::enable_from_other
detail::enable_if_t< std::is_constructible< T, Other >::value &&!std::is_constructible< T, optional< U > & >::value &&!std::is_constructible< T, optional< U > && >::value &&!std::is_constructible< T, const optional< U > & >::value &&!std::is_constructible< T, const optional< U > && >::value &&!std::is_convertible< optional< U > &, T >::value &&!std::is_convertible< optional< U > &&, T >::value &&!std::is_convertible< const optional< U > &, T >::value &&!std::is_convertible< const optional< U > &&, T >::value > enable_from_other
Definition: sol.hpp:4844
sol::stack::unqualified_checker< detail::as_pointer_tag< T >, type::userdata >::check
static bool check(lua_State *L_, int index, type indextype, Handler &&handler, record &tracking)
Definition: sol.hpp:12870
sol::stateless_stack_reference::copy_assign
void copy_assign(lua_State *, const stateless_stack_reference &right) noexcept
Definition: sol.hpp:9737
sol::usertype_proxy::operator=
usertype_proxy & operator=(T &&other) &
Definition: sol.hpp:24614
G
#define G(L)
Definition: lstate.h:330
sol::error::error
error(const std::string &str)
Definition: sol.hpp:4579
luaL_openlibs
LUALIB_API void luaL_openlibs(lua_State *L)
Definition: linit.c:57
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::iterator
value_type * iterator
Definition: sol.hpp:22660
sol::stateless_stack_reference::equals
bool equals(lua_State *L_, const stateless_stack_reference &r) const noexcept
Definition: sol.hpp:9741
sol::detail::usertype_unique_allocate
Real * usertype_unique_allocate(lua_State *L, T **&pref, unique_destructor *&dx, unique_tag *&id)
Definition: sol.hpp:11235
sol::returns_self_with
Definition: sol.hpp:7065
sol::stack::stateless_push_popper< false, T, std::enable_if_t< is_stack_based_v< meta::unqualified_t< T > > > >::Tu
meta::unqualified_t< T > Tu
Definition: sol.hpp:10087
sol::state_view::do_string
protected_function_result do_string(const string_view &code, const basic_environment< E > &env, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27516
sol::stack::unqualified_getter< lua_CFunction >::get
static lua_CFunction get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14147
sol::stack_lightuserdata
basic_lightuserdata< stack_reference > stack_lightuserdata
Definition: forward.hpp:1221
sol::stack::field_getter< std::tuple< Args... >, b, raw, C >::apply
void apply(std::index_sequence< 0, I... >, lua_State *L, Keys &&keys, int tableindex)
Definition: sol.hpp:16174
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::pairs
static int pairs(lua_State *L_)
Definition: sol.hpp:22796
sol::detail::is_non_factory_constructor
Definition: sol.hpp:8599
sol::stack::luajit_exception_off
void luajit_exception_off(lua_State *L)
Definition: sol.hpp:16693
range_format::map
@ map
sol::unsafe_function
basic_function< reference, false > unsafe_function
Definition: forward.hpp:1160
sol::container_detail::u_c_launch::real_index_of_call
static int real_index_of_call(lua_State *L)
Definition: sol.hpp:23050
sol::detail::demangle_once
std::string demangle_once()
Definition: sol.hpp:9018
sol::in_place_of
constexpr std::in_place_t in_place_of
Definition: sol.hpp:4613
sol::u_detail::lua_reference_func::key
reference key
Definition: sol.hpp:23631
sol::lua_value::thread_local_lua_state
static lua_State *& thread_local_lua_state()
Definition: sol.hpp:26956
sol::optional< T & >::operator=
optional & operator=(nullopt_t) noexcept
Definition: sol.hpp:6714
sol::stack::push
int push(lua_State *L, Arg &&arg, Args &&... args)
Definition: sol.hpp:11765
sol::optional::and_then
constexpr detail::invoke_result_t< F, const T & > and_then(F &&f) const &
Definition: sol.hpp:5335
sol::detail::ref_clean::ref_clean
ref_clean(lua_State *L_, int &pop_count_) noexcept
Definition: sol.hpp:25448
sol::state_view::change_gc_mode_incremental
gc_mode change_gc_mode_incremental(int pause, int step_multiplier, int step_byte_size)
Definition: sol.hpp:27896
sol::variadic_args::rend
const_reverse_iterator rend() const
Definition: sol.hpp:28707
sol::stack::unqualified_pusher< const char * >::push
static int push(lua_State *L, const char *str)
Definition: sol.hpp:15402
sol::type_panic_t::operator()
int operator()(lua_State *L, int index, type expected, type actual) const noexcept(false)
Definition: sol.hpp:9574
sol::upvalue_index::upvalue_index
upvalue_index(int idx)
Definition: sol.hpp:7376
sol::meta::conditional
Definition: sol.hpp:1399
sol::load_result::valid
bool valid() const noexcept
Definition: sol.hpp:26864
sol::container_detail::u_c_launch::real_find_traits
static int real_find_traits(std::true_type, lua_State *L)
Definition: sol.hpp:23038
sol::detail::indexed_insert::index
int & index
Definition: sol.hpp:11417
sol::container_detail::has_traits_next
meta::boolean< has_traits_next_test< T >::value > has_traits_next
Definition: sol.hpp:21602
sol::stack::unqualified_pusher< const char32_t * >::push
static int push(lua_State *L, const char32_t *u32str)
Definition: sol.hpp:15783
lua_newstate
LUA_API lua_State * lua_newstate(lua_Alloc f, void *ud)
Definition: lstate.c:354
sol::meta::meta_detail::adl_sol_lua_push_exact_test_t
decltype(sol_lua_push(types< T >(), static_cast< lua_State * >(nullptr), std::declval< Args >()...)) adl_sol_lua_push_exact_test_t
Definition: sol.hpp:11520
sol::stateless_reference_equals::operator()
bool operator()(const lua_nil_t &lhs, const stateless_reference &rhs) const noexcept
Definition: sol.hpp:10735
sol::detail::clean::~clean
~clean()
Definition: sol.hpp:25439
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::insert_copyable
static detail::error_result insert_copyable(std::true_type, lua_State *L_, T &self, stack_object key, stack_object value)
Definition: sol.hpp:22304
sol::basic_object::basic_object
basic_object(proxy_base< Super > &&r) noexcept
Definition: sol.hpp:16873
sol::meta::meta_detail::unique_usertype_get_with_state_v
constexpr bool unique_usertype_get_with_state_v
Definition: sol.hpp:9244
sol::load_result::~load_result
~load_result()
Definition: sol.hpp:26923
sol::automagic_flags::pairs_operator
@ pairs_operator
sol::light::void_value
void * void_value() const
Definition: sol.hpp:7472
sol::stack::field_getter< std::pair< A, B >, b, raw, C >::get
void get(lua_State *L, Keys &&keys)
Definition: sol.hpp:16205
sol::detail::inheritance::type_unique_cast_with
static int type_unique_cast_with(void *source_data, void *target_data, const string_view &ti, const string_view &rebind_ti)
Definition: sol.hpp:9457
sol::is_lua_primitive
Definition: sol.hpp:8421
sol::usertype_proxy::push
int push(lua_State *L) const noexcept
Definition: sol.hpp:24689
sol::basic_coroutine::basic_coroutine
basic_coroutine(lua_State *L, raw_index index)
Definition: sol.hpp:28426
sol::stack::unqualified_getter< std::basic_string< char16_t, Traits, Al > >::get
static std::basic_string< char16_t, Traits, Al > get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14031
sol::state_view::script
protected_function_result script(const string_view &code, const environment &env, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27744
sol::stack_reference::stack_reference
stack_reference(lua_State *L, const stack_reference &r) noexcept
Definition: sol.hpp:9767
sol::pairs_iterator::~pairs_iterator
~pairs_iterator()
Definition: sol.hpp:25372
sol::stateless_stack_reference_equals
Definition: sol.hpp:9857
sol::basic_usertype::set_function
basic_usertype & set_function(Key &&key, Args &&... args)
Definition: sol.hpp:26385
sol::unsafe_function_result::end
iterator end()
Definition: sol.hpp:17505
sol::unsafe_function_result::~unsafe_function_result
~unsafe_function_result()
Definition: sol.hpp:17562
sol::basic_object::basic_object
basic_object(lua_State *L_, in_place_type_t< T >, Args &&... args) noexcept
Definition: sol.hpp:16886
sol::u_detail::index_function_index
constexpr const int index_function_index
Definition: sol.hpp:23254
sol::stateless_stack_reference::stack_index
int stack_index() const noexcept
Definition: sol.hpp:9702
sol::optional::map_or_else
detail::invoke_result_t< U > map_or_else(F &&f, U &&u) const &
Definition: sol.hpp:5563
sol::optional::optional
constexpr optional(detail::enable_if_t< std::is_constructible< T, Args... >::value, in_place_t >, Args &&... args)
Definition: sol.hpp:5686
sol::container_detail::usertype_container_default::next
static int next(lua_State *L_)
Definition: sol.hpp:21729
sol::protected_function_result::crend
const_reverse_iterator crend() const
Definition: sol.hpp:17384
sol::stack::stateless_push_popper< false, T, std::enable_if_t< is_stack_based_v< meta::unqualified_t< T > > > >::index_of
int index_of(const Tu &object_) const noexcept
Definition: sol.hpp:10093
sol::pairs_iterator::m_clear
void m_clear() noexcept
Definition: sol.hpp:25379
sol::container_detail::u_c_launch::real_empty_traits
static int real_empty_traits(std::true_type, lua_State *L)
Definition: sol.hpp:23014
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::add_associative
static detail::error_result add_associative(std::false_type, lua_State *L_, T &self, stack_object value)
Definition: sol.hpp:22239
sol::basic_coroutine::basic_coroutine
basic_coroutine(lua_State *L, T &&r) noexcept
Definition: sol.hpp:28393
sol::container_detail::usertype_container_default::set
static int set(lua_State *L_)
Definition: sol.hpp:21688
sol::usertype_proxy::set
usertype_proxy && set(T &&item) &&
Definition: sol.hpp:24607
sol::call_detail::call_user
int call_user(lua_State *L)
Definition: sol.hpp:18948
sol::state_view::globals
global_table globals() const
Definition: sol.hpp:27820
sol::stack::unqualified_getter< wchar_t >::get
static wchar_t get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14083
sol::meta::meta_detail::is_adl_sol_lua_check_get_v
constexpr bool is_adl_sol_lua_check_get_v
Definition: sol.hpp:11535
sol::optional::disjunction
SOL_TL_OPTIONAL_11_CONSTEXPR optional disjunction(optional &&rhs) &&
\group disjunction
Definition: sol.hpp:5618
sol::stack::push_reference
int push_reference(lua_State *L, Arg &&arg, Args &&... args)
Definition: sol.hpp:11828
sol::stack::get_call_syntax
call_syntax get_call_syntax(lua_State *L, const string_view &key, int index)
Definition: sol.hpp:16639
sol::stack::unqualified_pusher< std::basic_string< Ch, Traits, Al > >::push
static int push(lua_State *L, const std::basic_string< Ch, Traits, Al > &str)
Definition: sol.hpp:15555
lua_setuservalue
#define lua_setuservalue(L, idx)
Definition: lua.h:414
sol::lua_thread_state::L
lua_State * L
Definition: sol.hpp:28079
sol::stack::check
bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:11881
sol::container_detail::usertype_container_default::add
static int add(lua_State *L_)
Definition: sol.hpp:21697
sol::usertype_proxy::usertype_proxy
usertype_proxy(Table table, T &&k)
Definition: sol.hpp:24596
sol::meta::meta_detail::callable_traits< R(T::*), true >::signature_type
R(T::*) signature_type
Definition: sol.hpp:1999
sol::get_environment
basic_environment< E > get_environment(const T &target)
Definition: sol.hpp:26726
sol::wrapper< F, std::enable_if_t< std::is_member_object_pointer< meta::unqualified_t< F > >::value > >::call
static auto call(object_type &mem) -> detail::array_return_type< decltype(mem.*fx)>
Definition: sol.hpp:17712
sol::lib
lib
Definition: sol.hpp:7809
sol::member_function_wrapper
Definition: sol.hpp:17760
sol::is_unique_usertype
Definition: sol.hpp:9226
sol::state_view::safe_script_file
protected_function_result safe_script_file(const std::string &filename, Fx &&on_error, load_mode mode=load_mode::any)
Definition: sol.hpp:27614
sol::table_proxy::is_valid
bool is_valid(std::false_type)
Definition: sol.hpp:24751
sol::raw_index::raw_index
raw_index(int i)
Definition: sol.hpp:7386
sol::lib::coroutine
@ coroutine
sol::detail::clear_entries
void clear_entries(const reference &registry_reference)
Definition: sol.hpp:16428
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::index_set
static int index_set(lua_State *L_)
Definition: sol.hpp:22776
sol::stack::unqualified_checker< detail::as_value_tag< T >, type::userdata >::check
static bool check(lua_State *L_, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:12796
sol::stack_reference::valid
bool valid() const noexcept
Definition: sol.hpp:9816
sol::basic_usertype::set_fx
void set_fx(types<>, Key &&key, Fx &&fx, Args &&... args)
Definition: sol.hpp:26337
sol::is_container
Definition: sol.hpp:8122
sol::optional::and_then
SOL_TL_OPTIONAL_11_CONSTEXPR detail::invoke_result_t< F, T && > and_then(F &&f) &&
Definition: sol.hpp:5325
sol::container_detail::has_traits_index_get
meta::boolean< has_traits_index_get_test< T >::value > has_traits_index_get
Definition: sol.hpp:21590
sol::stack::unqualified_pusher< function_arguments< T, Args... > >::push_func
static int push_func(std::index_sequence< I... >, lua_State *L, FP &&fp)
Definition: sol.hpp:20103
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::erase
static int erase(lua_State *L_)
Definition: sol.hpp:22618
sol::nested
Definition: forward.hpp:1242
backward::details::move
const T & move(const T &v)
Definition: backward.hpp:394
sol::as_table_t::as_table_t
as_table_t(meta::unqualified_t< T > &&obj) noexcept(std::is_nothrow_constructible_v< base_t, meta::unqualified_t< T > && >)
Definition: sol.hpp:7587
sol::unicode::unicode_detail
Definition: sol.hpp:13083
sol::wrapper::returns_list
traits_type::returns_list returns_list
Definition: sol.hpp:17654
sol::set_environment
bool set_environment(const basic_environment< E > &env, const T &target)
Definition: sol.hpp:26721
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::erase
static int erase(lua_State *L_)
Definition: sol.hpp:22732
luaL_execresult
LUALIB_API int luaL_execresult(lua_State *L, int stat)
Definition: lauxlib.c:285
sol::stack_proxy_base::m_index
int m_index
Definition: sol.hpp:17124
lua_rawgeti
LUA_API int lua_rawgeti(lua_State *L, int idx, lua_Integer n)
Definition: lapi.c:738
sol::u_detail::index_call_storage::binding_data
void * binding_data
Definition: sol.hpp:23443
sol::check_handler_type
int(lua_State *, int, type, type, const char *) check_handler_type
Definition: forward.hpp:1297
sol::state_view::unsafe_script_file
unsafe_function_result unsafe_script_file(const std::string &filename, load_mode mode=load_mode::any)
Definition: sol.hpp:27710
sol::stack::qualified_getter
Definition: sol.hpp:11441
sol::main_function
main_unsafe_function main_function
Definition: forward.hpp:1179
sol::table_proxy::operator=
table_proxy & operator=(T &&other) &
Definition: sol.hpp:24791
sol::stack::unqualified_pusher< as_container_t< T > >::push
static int push(lua_State *L, as_container_t< T > &&as_cont)
Definition: sol.hpp:23199
sol::stack_iterator::stack_iterator
stack_iterator()
Definition: sol.hpp:17005
sol::stack::stack_detail::count_code_units_utf::needed_size
std::size_t needed_size
Definition: sol.hpp:13363
sol::state_view::new_enum
state_view & new_enum(const string_view &name, Args &&... args)
Definition: sol.hpp:27988
sol::detail::std_shim
Definition: sol.hpp:21210
sol::stack::unqualified_pusher< c_closure >::push
static int push(lua_State *L, c_closure cc)
Definition: sol.hpp:15248
sol::stack::push_environment_of
int push_environment_of(const T &target)
Definition: sol.hpp:14795
sol::stack_proxy_base::get_type
type get_type() const noexcept
Definition: sol.hpp:17147
sol::detail::protected_handler::protected_handler
protected_handler(std::true_type, lua_State *L_, const Target &target_)
Definition: sol.hpp:20751
sol::property_wrapper::property_wrapper
property_wrapper(Rx &&r, Wx &&w)
Definition: sol.hpp:17935
LUA_TUSERDATA
#define LUA_TUSERDATA
Definition: lua.h:72
sol::automagic_flags::all
@ all
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::iter::source
T & source
Definition: sol.hpp:22665
sol::detail::default_safe_function_calls
const bool default_safe_function_calls
Definition: sol.hpp:2853
sol::metatable_key_t
Definition: sol.hpp:7330
sol::stack::unqualified_getter< std::variant< Tn... > >::V
std::variant< Tn... > V
Definition: sol.hpp:14325
LUA_TNUMBER
#define LUA_TNUMBER
Definition: lua.h:68
sol::stack::unqualified_check_getter::get
static optional< R > get(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:14484
sol::optional< T & >::disjunction
constexpr optional disjunction(optional &&rhs) const &
\group disjunction
Definition: sol.hpp:6626
sol::container_detail::has_erase
meta::boolean< has_erase_test< T >::value > has_erase
Definition: sol.hpp:21572
sol::meta::meta_detail::basic_traits::free_function_pointer_type
meta::conditional_t< std::is_void< T >::value, R(*)(Args...), R(*)(first_type, Args...)> free_function_pointer_type
Definition: sol.hpp:1566
sol::stack_iterator::operator--
stack_iterator operator--(int)
Definition: sol.hpp:17046
sol::function_detail::call_set_variable
int call_set_variable(std::true_type, lua_State *L, T &&mem)
Definition: sol.hpp:19025
sol::stack::unqualified_pusher< absolute_index >::push
static int push(lua_State *L, absolute_index ai)
Definition: sol.hpp:15607
sol::unicode::encoded_result::code_units
std::array< C, 4 > code_units
Definition: sol.hpp:13080
sol::variadic_args::size
std::size_t size() const
Definition: sol.hpp:28755
sol::basic_lightuserdata::basic_lightuserdata
basic_lightuserdata(lua_State *L, int index=-1)
Definition: sol.hpp:28580
sol::call_status::file
@ file
sol::unicode::error_code::overlong_sequence
@ overlong_sequence
sol::detail::optional_operations_base::has_value
bool has_value() const
Definition: sol.hpp:5004
sol::detail::demangle
const std::string & demangle()
Definition: sol.hpp:9068
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::add_copyable
static detail::error_result add_copyable(std::false_type, lua_State *, T &, stack_object)
Definition: sol.hpp:22257
sol::meta::unqualified_t
typename unqualified< T >::type unqualified_t
Definition: sol.hpp:1376
sol::detail::optional_storage_base::m_has_value
bool m_has_value
Definition: sol.hpp:4946
sol::stack::get_field
void get_field(lua_State *L, Key &&key, int tableindex)
Definition: sol.hpp:12090
sol::meta::meta_detail::basic_traits::free_arity
static constexpr std::size_t free_arity
Definition: sol.hpp:1557
sol::load_result::lua_state
lua_State * lua_state() const noexcept
Definition: sol.hpp:26916
sol::lightuserdata_value::lightuserdata_value
lightuserdata_value(void *data)
Definition: sol.hpp:7423
sol::meta::is_probably_stateless_lambda_v
constexpr bool is_probably_stateless_lambda_v
Definition: sol.hpp:2032
sol::is_unique_usertype_v
constexpr bool is_unique_usertype_v
Definition: sol.hpp:9229
sol::container_detail::usertype_container_default::value_type
lua_nil_t value_type
Definition: sol.hpp:21674
sol::stack::unqualified_getter< this_main_state >::get
static this_main_state get(lua_State *L, int, record &tracking)
Definition: sol.hpp:14139
sol::stack_aligned_protected_function
stack_aligned_safe_function stack_aligned_protected_function
Definition: forward.hpp:1171
sol::detail::ebco< T, tag, std::enable_if_t<!std::is_reference_v< T > &&std::is_class_v< T > &&!std::is_final_v< T > > >::ebco
ebco(const T &v) noexcept(std::is_nothrow_copy_constructible_v< T >)
Definition: sol.hpp:7178
sol::variadic_args::begin
const_iterator begin() const
Definition: sol.hpp:28685
sol::stack::stack_detail::c_lua_next
int c_lua_next(lua_State *L_) noexcept
Definition: sol.hpp:25156
sol::protected_function_result::reverse_iterator
std::reverse_iterator< iterator > reverse_iterator
Definition: sol.hpp:17244
sol::variadic_args::size_type
std::size_t size_type
Definition: sol.hpp:28645
sol::detail::comparsion_operator_wrap
int comparsion_operator_wrap(lua_State *L)
Definition: sol.hpp:12269
sol::detail::array_return_type
meta::conditional_t< std::is_array< T >::value, std::add_lvalue_reference_t< T >, T > array_return_type
Definition: sol.hpp:17646
sol::basic_protected_function::basic_protected_function
basic_protected_function(Proxy &&p, HandlerReference &&eh)
Definition: sol.hpp:20900
sol::stack::unqualified_pusher< char32_t[N]>::push
static int push(lua_State *L, const char32_t(&str)[N])
Definition: sol.hpp:15864
sol::call_detail::lua_call_wrapper
Definition: sol.hpp:18508
sol::stack::unqualified_pusher< char32_t * >::push
static int push(lua_State *L, const char32_t *strb, const char32_t *stre)
Definition: sol.hpp:15825
sol::u_detail::string_for_each_metatable_func::change_indexing
change_indexing_mem_func change_indexing
Definition: sol.hpp:23581
sol::function_detail::upvalue_this_member_variable< T, readonly_wrapper< Function > >::operator()
int operator()(lua_State *L) noexcept(std::is_nothrow_copy_assignable_v< T >)
Definition: sol.hpp:19475
sol::call_detail::agnostic_lua_call_wrapper< var_wrapper< T >, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, F &&f)
Definition: sol.hpp:18423
sol::detail::invoke_result_impl< F, decltype(detail::invoke(std::declval< F >(), std::declval< Us >()...), void()), Us... >::type
decltype(detail::invoke(std::declval< F >(), std::declval< Us >()...)) type
Definition: sol.hpp:4788
sol::basic_function::luacall
void luacall(std::ptrdiff_t argcount, std::ptrdiff_t resultcount) const
Definition: sol.hpp:20596
LUA_SIGNATURE
#define LUA_SIGNATURE
Definition: lua.h:33
sol::protect_t::protect_t
protect_t(Arg &&arg, Args &&... args)
Definition: sol.hpp:18054
lua_State
Definition: lstate.h:304
sol::basic_table_core::raw_set
basic_table_core & raw_set(Args &&... args)
Definition: sol.hpp:25919
sol::operator+
stack_iterator< proxy_t, is_const > operator+(typename stack_iterator< proxy_t, is_const >::difference_type n, const stack_iterator< proxy_t, is_const > &r)
Definition: sol.hpp:17108
sol::state_view::new_usertype
usertype< Class > new_usertype(Args &&... args)
Definition: sol.hpp:27983
sol::load_result::index
int index
Definition: sol.hpp:26815
sol::this_main_state::this_main_state
this_main_state(lua_State *Ls)
Definition: sol.hpp:7777
sol::stack::unqualified_pusher< lightuserdata_value >::push
static int push(lua_State *L, lightuserdata_value userdata) noexcept
Definition: sol.hpp:15296
sol::basic_reference::operator=
basic_reference & operator=(basic_reference &&r) noexcept
Definition: sol.hpp:10559
LUA_GCCOUNT
#define LUA_GCCOUNT
Definition: lua.h:322
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::clear_has
static void clear_has(std::true_type, lua_State *, T &self)
Definition: sol.hpp:22390
sol::protected_function_result::err
call_status err
Definition: sol.hpp:17234
sol::stateless_stack_reference::stateless_stack_reference
stateless_stack_reference(raw_index index_) noexcept
Definition: sol.hpp:9680
sol::u_detail::update_bases_func::operator()
void operator()(lua_State *L_, submetatable_type smt_, stateless_reference &fast_index_table_)
Definition: sol.hpp:23653
sol::unicode::error_code::invalid_code_unit
@ invalid_code_unit
sol::stack::unqualified_pusher< meta_function >::push
static int push(lua_State *L, meta_function m)
Definition: sol.hpp:15595
sol::automagic_enrollments::equal_to_operator
bool equal_to_operator
Definition: sol.hpp:8712
sol::stack_iterator::sp
proxy_t sp
Definition: sol.hpp:17003
sol::stack::unqualified_pusher< var_wrapper< T > >::push
static int push(lua_State *L, var_wrapper< T > &&vw)
Definition: sol.hpp:20242
sol::basic_table_core< true >::is_set_direct_tableless
meta::boolean< stack::stack_detail::is_set_direct_tableless_v< T, top_level, false > > is_set_direct_tableless
Definition: sol.hpp:25480
sol::variadic_args::operator[]
stack_proxy operator[](difference_type index_offset) const
Definition: sol.hpp:28742
sol::detail::base_class_new_index_propogation_key
decltype(auto) base_class_new_index_propogation_key()
Definition: sol.hpp:9357
sol::meta::meta_detail::callable_traits
Definition: sol.hpp:1992
sol::meta::meta_detail::is_adl_sol_lua_interop_check_v
constexpr bool is_adl_sol_lua_interop_check_v
Definition: sol.hpp:11532
sol::detail::default_to_string
int default_to_string(lua_State *L)
Definition: sol.hpp:12258
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::insert
static int insert(lua_State *L_)
Definition: sol.hpp:22740
sol::state_view
Definition: sol.hpp:27237
sol::type::userdata
@ userdata
sol::basic_protected_function::get_error_handler
auto get_error_handler() const noexcept
Definition: sol.hpp:21052
sol::table_proxy::is
bool is() const
Definition: sol.hpp:24823
sol::operator<
constexpr bool operator<(const optional< T > &lhs, const optional< U > &rhs)
\group relop
Definition: sol.hpp:6025
sol::main_protected_function
main_safe_function main_protected_function
Definition: forward.hpp:1169
sol::u_detail::usertype_storage_base::string_keys
std::unordered_map< string_view, index_call_storage > string_keys
Definition: sol.hpp:23680
sol::meta::meta_detail::is_rebind_actual_type_test_t
typename T::template rebind_actual_type< Element > is_rebind_actual_type_test_t
Definition: sol.hpp:9302
sol::stack::unqualified_pusher< char >::push
static int push(lua_State *L, char c)
Definition: sol.hpp:15465
sol::constructors
constructor_list< Args... > constructors
Definition: sol.hpp:6995
sol::tie_t::operator=
tie_t & operator=(T &&value)
Definition: sol.hpp:10856
sol::detail::decay_t
typename std::decay< T >::type decay_t
Definition: sol.hpp:4722
sol::metatable_registry_key
Definition: sol.hpp:7517
sol::state_view::require_file
object require_file(const std::string &key, const std::string &filename, bool create_global=true, load_mode mode=load_mode::any)
Definition: sol.hpp:27421
sol::basic_metatable::basic_metatable
basic_metatable(lua_nil_t r) noexcept
Definition: sol.hpp:26220
sol::is_callable
Definition: sol.hpp:8139
sol::container_detail::has_traits_at_test
Definition: sol.hpp:21491
sol::error::error
error(detail::direct_error_tag, const std::string &str)
Definition: sol.hpp:4583
sol::container_detail::usertype_container_default::index_set
static int index_set(lua_State *L_)
Definition: sol.hpp:21692
sol::stack::unqualified_pusher< basic_string_view< Ch, Traits > >::push
static int push(lua_State *L, const basic_string_view< Ch, Traits > &sv, std::size_t n)
Definition: sol.hpp:15588
sol::unsafe_function_result::begin
const_iterator begin() const
Definition: sol.hpp:17508
sol::stack::unqualified_pusher< metatable_key_t >::push
static int push(lua_State *L, metatable_key_t)
Definition: sol.hpp:15191
sol::meta::meta_detail::is_actual_type_rebindable_for_test
Definition: sol.hpp:9311
sol::state_view::script_file
protected_function_result script_file(const std::string &filename, const environment &env, load_mode mode=load_mode::any)
Definition: sol.hpp:27749
sol::lib::table
@ table
sol::stack::probe::levels
int levels
Definition: sol.hpp:11466
sol::meta_function_names
const std::array< std::string, 37 > & meta_function_names()
Definition: sol.hpp:8027
sol::this_main_state
Definition: sol.hpp:7774
sol::call_syntax
call_syntax
Definition: sol.hpp:7840
sol::stack::unqualified_pusher< detail::tagged< T, policy_wrapper< F, Policies... > > >::push
static int push(lua_State *L, const Tagged &p)
Definition: sol.hpp:20438
sol::detail::implicit_wrapper::implicit_wrapper
implicit_wrapper(T &value_)
Definition: sol.hpp:7297
sol::container_detail::has_erase_after_test
Definition: sol.hpp:21334
sol::lua_nil
constexpr lua_nil_t lua_nil
Definition: sol.hpp:7314
sol::type::lua_nil
@ lua_nil
sol::meta::meta_detail::callable_traits< R(T::*), true >::returns_list
meta::tuple_types< return_type > returns_list
Definition: sol.hpp:2007
sol::detail::member_default_to_string
int member_default_to_string(std::false_type, lua_State *L)
Definition: sol.hpp:12226
sol::basic_table_core::operator[]
auto operator[](T &&key) &&
Definition: sol.hpp:26021
sol::detail::user_alloc_destroy
int user_alloc_destroy(lua_State *L) noexcept
Definition: sol.hpp:11337
sol::stateless_stack_reference::stateless_stack_reference
stateless_stack_reference(lua_State *L_, int index_) noexcept
Definition: sol.hpp:9672
sol::stack::stack_detail::interop_check
bool interop_check(lua_State *L, int index, type index_type, Handler &&handler, record &tracking)
Definition: sol.hpp:11651
lua_rawsetp
LUA_API void lua_rawsetp(lua_State *L, int idx, const void *p)
Definition: lapi.c:908
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::at_category
static detail::error_result at_category(std::random_access_iterator_tag, lua_State *L_, T &self, std::ptrdiff_t pos)
Definition: sol.hpp:21836
sol::container_detail::has_find
meta::boolean< has_find_test< T >::value > has_find
Definition: sol.hpp:21569
sol::meta::conditional_t
typename conditional< B >::template type< T, U > conditional_t
Definition: sol.hpp:1411
sol::basic_function::call
decltype(auto) call(Args &&... args) const
Definition: sol.hpp:20714
sol::basic_function::basic_function
basic_function(T &&r) noexcept
Definition: sol.hpp:20633
sol::detail::invoke
constexpr auto invoke(Fn &&f, Args &&... args) noexcept(noexcept(std::mem_fn(f)(std::forward< Args >(args)...))) -> decltype(std::mem_fn(f)(std::forward< Args >(args)...))
Definition: sol.hpp:4771
sol::detail::default_destroy::operator()
void operator()(T &&obj) const
Definition: sol.hpp:6944
sol::basic_userdata::basic_userdata
basic_userdata(lua_State *L, int index=-1)
Definition: sol.hpp:28530
sol::basic_reference::basic_reference
basic_reference(lua_State *L_, ref_index index) noexcept
Definition: sol.hpp:10529
sol::detail::insert_mode
insert_mode
Definition: sol.hpp:7745
sol::automagic_enrollments::less_than_or_equal_to_operator
bool less_than_or_equal_to_operator
Definition: sol.hpp:8710
sol::stack_dependencies::stack_dependencies
stack_dependencies(int stack_target, Args &&... args)
Definition: sol.hpp:7074
sol::optional::value
const SOL_TL_OPTIONAL_11_CONSTEXPR T & value() const &
Definition: sol.hpp:5951
sol::u_detail::clear_usertype_registry_names
void clear_usertype_registry_names(lua_State *L)
Definition: sol.hpp:24197
sol::meta::pop_front_type< types< Args... > >::front_type
void front_type
Definition: sol.hpp:1493
sol::stack::unqualified_pusher< char32_t[N]>::push
static int push(lua_State *L, const char32_t(&str)[N], std::size_t sz)
Definition: sol.hpp:15868
sol::call_syntax::colon
@ colon
sol::stack::unqualified_getter< lua_nil_t >::get
static lua_nil_t get(lua_State *, int, record &tracking)
Definition: sol.hpp:14107
sol::basic_protected_function::operator=
basic_protected_function & operator=(const basic_protected_function &other_)
Definition: sol.hpp:20862
sol::usertype
basic_usertype< T, reference > usertype
Definition: forward.hpp:1141
sol::destructor_wrapper::destructor_wrapper
destructor_wrapper(Function f)
Definition: sol.hpp:7034
std::swap
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition: json.hpp:21884
sol::meta_function::ipairs
@ ipairs
sol::meta_function::multiplication
@ multiplication
sol::basic_table_core
Definition: forward.hpp:1117
LUA_REGISTRYINDEX
#define LUA_REGISTRYINDEX
Definition: lua.h:44
sol::stack::unqualified_pusher< as_container_t< T > >::push_rvalue
static int push_rvalue(std::false_type, lua_State *L, const C &cont)
Definition: sol.hpp:23191
sol::state_view::const_iterator
typename global_table::const_iterator const_iterator
Definition: sol.hpp:27307
sol::stack::unqualified_getter< lua_value >::get
static lua_value get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:27061
sol::basic_protected_function::basic_protected_function
basic_protected_function(lua_State *L_, T &&r)
Definition: sol.hpp:20905
sol::detail::remove_reference_t
typename std::remove_reference< T >::type remove_reference_t
Definition: sol.hpp:4720
sol::is_main_threaded_v
constexpr bool is_main_threaded_v
Definition: sol.hpp:8448
sol::basic_table_core::set_resolved_function
void set_resolved_function(Key &&key, Args &&... args)
Definition: sol.hpp:26064
sol::basic_userdata::basic_userdata
basic_userdata(const stack_reference &r)
Definition: sol.hpp:28518
sol::meta::meta_detail::basic_traits::object_type
T object_type
Definition: sol.hpp:1560
sol::basic_metatable::set_fx
void set_fx(types< R(Args...)>, Key &&key, Fx &&fx)
Definition: sol.hpp:26155
sol::stack_proxy_base::push
int push() const
Definition: sol.hpp:17151
sol::wrapper< F, std::enable_if_t< std::is_member_object_pointer< meta::unqualified_t< F > >::value > >::returns_list
traits_type::returns_list returns_list
Definition: sol.hpp:17709
Name
@ Name
Definition: curvelist_view.h:46
sol::lua_value::lua_value
lua_value(lua_State *L_, reference r)
Definition: sol.hpp:27000
sol::meta::meta_detail::adl_sol_lua_interop_check_test_t
decltype(sol_lua_interop_check(types< T >(), static_cast< lua_State * >(nullptr), -1, type::none, &no_panic, std::declval< stack::record & >())) adl_sol_lua_interop_check_test_t
Definition: sol.hpp:11510
sol::associated_type_name
std::string associated_type_name(lua_State *L, int index, type t)
Definition: sol.hpp:9526
sol::meta::is_pointer_like
std::integral_constant< bool, !std::is_array_v< T > &&(std::is_pointer_v< T >||is_detected_v< meta_detail::is_explicitly_dereferenceable_test, T >)> is_pointer_like
Definition: sol.hpp:2065
sol::optional::emplace
detail::enable_if_t< std::is_constructible< T, std::initializer_list< U > &, Args &&... >::value, T & > emplace(std::initializer_list< U > il, Args &&... args)
Definition: sol.hpp:5856
sol::detail::optional_storage_base::optional_storage_base
SOL_TL_OPTIONAL_11_CONSTEXPR optional_storage_base(in_place_t, U &&... u)
Definition: sol.hpp:4930
sol::call_detail::lua_call_wrapper< T, property_wrapper< R, W >, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, F &&f, Args &&... args)
Definition: sol.hpp:18808
lua_touserdata
LUA_API void * lua_touserdata(lua_State *L, int idx)
Definition: lapi.c:450
sol::load_result::popcount
int popcount
Definition: sol.hpp:26817
sol::function_detail::member_variable::M
std::add_lvalue_reference_t< meta::unwrapped_t< std::remove_reference_t< decltype(detail::deref(member))> > > M
Definition: sol.hpp:19570
sol::stack::field_setter::set
void set(lua_State *L, Key &&key, Value &&value, int tableindex=default_table_index)
Definition: sol.hpp:16220
sol::basic_function::invoke
auto invoke(types< Ret... >, std::index_sequence< I... >, std::ptrdiff_t n) const
Definition: sol.hpp:20601
sol::basic_reference::get_type
type get_type() const noexcept
Definition: sol.hpp:10642
sol::meta::function_signature_t
typename bind_traits< Signature >::signature_type function_signature_t
Definition: sol.hpp:2038
sol::function_detail::upvalue_member_variable< T, readonly_wrapper< Function > >::call
static int call(lua_State *L) noexcept(traits_type::is_noexcept)
Definition: sol.hpp:19314
sol::wrapper< F, std::enable_if_t< std::is_function< std::remove_pointer_t< meta::unqualified_t< F > > >::value > >::traits_type
lua_bind_traits< std::remove_pointer_t< meta::unqualified_t< F > > > traits_type
Definition: sol.hpp:17671
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::clear
static int clear(lua_State *L_)
Definition: sol.hpp:22728
sol::stack::stack_detail::interop_get
decltype(auto) interop_get(lua_State *L, int index, void *unadjusted_pointer, record &tracking)
Definition: sol.hpp:11625
sol::container_detail::has_traits_pairs_test
Definition: sol.hpp:21503
d
d
lua_typename
const LUA_API char * lua_typename(lua_State *L, int t)
Definition: lapi.c:284
sol::stack::stateless_push_popper::index_of
int index_of(const Tu &) const noexcept
Definition: sol.hpp:10061
sol::basic_coroutine::invoke
void invoke(types< void >, std::index_sequence< I >, std::ptrdiff_t n)
Definition: sol.hpp:28304
sol::usertype_proxy::tuple_set
void tuple_set(std::index_sequence< I... >, T &&value) &
Definition: sol.hpp:24572
sol::nil
constexpr const nil_t & nil
Definition: sol.hpp:7323
sol::stack_iterator::operator+
stack_iterator operator+(difference_type idx) const
Definition: sol.hpp:17066
sol::container_detail::container_decay
Definition: sol.hpp:21635
sol::stack::unqualified_pusher< property_wrapper< F, G > >::push
static int push(lua_State *L, const property_wrapper< F, G > &pw)
Definition: sol.hpp:20227
sol::u_detail::usertype_storage_base::is_using_index
bool is_using_index
Definition: sol.hpp:23693
enable_if_t
typename std::enable_if< B, T >::type enable_if_t
Definition: core.h:271
sol::basic_protected_function::basic_protected_function
basic_protected_function(lua_State *L_, ref_index index_, handler_t eh)
Definition: sol.hpp:20945
sol::detail::deprecate_type::type
T type
Definition: sol.hpp:21292
sol::container_detail::u_c_launch::real_length_call
static int real_length_call(lua_State *L)
Definition: sol.hpp:22974
sol::stack::unqualified_pusher< detail::tagged< T, policy_wrapper< F, Policies... > > >::push
static int push(lua_State *L, Tagged &&p)
Definition: sol.hpp:20446
sol::constructor_handler::operator()
int operator()(lua_State *L, int index, type expected, type actual, string_view message) const noexcept(false)
Definition: sol.hpp:9585
sol::stack_proxy
Definition: sol.hpp:17189
sol::table_proxy::force
table_proxy & force()
Definition: sol.hpp:24951
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::size_has
static auto size_has(std::true_type, lua_State *, T &self)
Definition: sol.hpp:22386
sol::u_detail::usertype_storage_base
Definition: sol.hpp:23675
sol::basic_protected_function::basic_protected_function
basic_protected_function(proxy_base< Super > &&p)
Definition: sol.hpp:20895
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::iter::it
iterator it
Definition: sol.hpp:21788
sol::stack::stateless_push_popper< true, T, C >::Tu
meta::unqualified_t< T > Tu
Definition: sol.hpp:10072
sol::u_detail::binding_base
Definition: sol.hpp:23450
sol::u_detail::new_index_call_storage
Definition: sol.hpp:23446
sol::state_view::lua_state
lua_State * lua_state() const
Definition: sol.hpp:27315
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::empty
static int empty(lua_State *L_)
Definition: sol.hpp:22628
sol::usertype_proxy::operator=
usertype_proxy & operator=(std::initializer_list< T > other) &
Definition: sol.hpp:24624
sol::stack::unqualified_checker< std::variant< Tn... >, type::poly >::is_one
static bool is_one(std::integral_constant< std::size_t, I >, lua_State *L_, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:12922
sol::light::m_value
T * m_value
Definition: sol.hpp:7450
sol::operator!=
constexpr bool operator!=(const optional< T > &lhs, const optional< U > &rhs)
\group relop
Definition: sol.hpp:6020
sol::stack::unqualified_pusher< std::remove_pointer_t< detail::lua_CFunction_noexcept > >::push
static int push(lua_State *L, detail::lua_CFunction_noexcept func, int n=0)
Definition: sol.hpp:15225
sol::reference_equals::operator()
bool operator()(const lua_nil_t &lhs, const basic_reference< rb > &rhs) const noexcept
Definition: sol.hpp:10752
sol::meta::all_same
Definition: sol.hpp:2192
sol::unsafe_function_result::cend
const_iterator cend() const
Definition: sol.hpp:17517
nlohmann::detail::void
j template void())
Definition: json.hpp:4061
sol::container_detail::u_c_launch::find_call
static int find_call(lua_State *L)
Definition: sol.hpp:23079
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::add_push_back
static detail::error_result add_push_back(std::false_type, lua_State *L_, T &self, stack_object value, Iter &pos)
Definition: sol.hpp:22199
sol::meta::return_type_t
typename return_type< Args... >::type return_type_t
Definition: sol.hpp:2365
sol::stack::stack_detail::not_enough_stack_space_environment
constexpr const char * not_enough_stack_space_environment
Definition: sol.hpp:11553
sol::stateless_stack_reference_hash::result_type
std::size_t result_type
Definition: sol.hpp:9901
sol::nested_tag_t
Definition: sol.hpp:7642
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::insert_has
static detail::error_result insert_has(std::false_type, lua_State *L_, T &self, stack_object where, stack_object value)
Definition: sol.hpp:22300
sol::stack::unqualified_pusher< policy_wrapper< F, Policies... > >::push
static int push(lua_State *L, const P &p)
Definition: sol.hpp:20416
lua_getstack
LUA_API int lua_getstack(lua_State *L, int level, lua_Debug *ar)
Definition: ldebug.c:160
sol::protected_function_result::const_iterator
stack_iterator< stack_proxy, true > const_iterator
Definition: sol.hpp:17243
sol::global_table
table_core< true > global_table
Definition: forward.hpp:1127
sol::variadic_args::reverse_iterator
std::reverse_iterator< iterator > reverse_iterator
Definition: sol.hpp:28648
sol::stack::stack_detail::find_lua_next_function
std::optional< protected_function > find_lua_next_function(lua_State *L_)
Definition: sol.hpp:25149
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::get_it
static detail::error_result get_it(std::false_type, lua_State *L_, T &self, K &key)
Definition: sol.hpp:21911
sol::protected_function_result::crbegin
const_reverse_iterator crbegin() const
Definition: sol.hpp:17381
sol::stack::push_popper_at::L
lua_State * L
Definition: sol.hpp:9972
sol::meta::meta_detail::unique_usertype_is_null_with_state_v
constexpr bool unique_usertype_is_null_with_state_v
Definition: sol.hpp:9251
sol::function_detail::select_set_fx
void select_set_fx(lua_State *L, Args &&... args)
Definition: sol.hpp:19839
sol::tie_size< protected_function_result >
Definition: sol.hpp:17611
sol::stack::push_popper::push_popper
push_popper(T object_) noexcept
Definition: sol.hpp:10009
sol::meta::meta_detail::count_when_for_pack
Definition: sol.hpp:2304
sol::member_function_wrapper::invoke
static R invoke(O &mem, Args &&... args)
Definition: sol.hpp:17768
sol::stack::unqualified_pusher< char[N]>::push
static int push(lua_State *L, const char(&str)[N])
Definition: sol.hpp:15446
sol::is_main_threaded
Definition: sol.hpp:8445
sol::variadic_args::const_iterator
stack_iterator< stack_proxy, true > const_iterator
Definition: sol.hpp:28647
sol::stack::multi_push_reference
int multi_push_reference(lua_State *L, T &&t, Args &&... args)
Definition: sol.hpp:11850
sol::detail::ebco< T, tag, std::enable_if_t<!std::is_reference_v< T > &&std::is_class_v< T > &&!std::is_final_v< T > > >::ebco
ebco(T &&v) noexcept(std::is_nothrow_move_constructible_v< T >)
Definition: sol.hpp:7179
sol::policy_wrapper::policies
std::tuple< Policies... > policies
Definition: sol.hpp:7097
sol::function_detail::select_member_function
void select_member_function(lua_State *L, Fx &&fx, Args &&... args)
Definition: sol.hpp:19956
sol::usertype_proxy
Definition: sol.hpp:24557
sol::unsafe_function_result::unsafe_function_result
unsafe_function_result(lua_State *Ls, int idx=-1, int retnum=0) noexcept
Definition: sol.hpp:17457
sol::stack::unqualified_getter< std::string >::get
static std::string get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:13983
sol::stack::stateless_push_popper< true, T, C >::index_of
int index_of(lua_State *, const Tu &) const noexcept
Definition: sol.hpp:10077
sol::call_detail::lua_call_wrapper< T, destructor_wrapper< Fx >, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, F &&f)
Definition: sol.hpp:18753
sol::detail::optional_storage_base
Definition: sol.hpp:4925
sol::stack::stateless_push_popper< false, T, std::enable_if_t< is_stack_based_v< meta::unqualified_t< T > > > >::m_L
lua_State * m_L
Definition: sol.hpp:10088
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::find
static int find(lua_State *L_)
Definition: sol.hpp:22574
sol::basic_reference::basic_reference
basic_reference(stack_reference &&r) noexcept
Definition: sol.hpp:10466
sol::basic_table_core::new_usertype
usertype< Class > new_usertype(Key &&key)
Definition: sol.hpp:26482
sol::protected_function_result::end
iterator end()
Definition: sol.hpp:17353
sol::detail::accumulate
Definition: sol.hpp:8373
sol::meta::all_v
constexpr bool all_v
Definition: sol.hpp:2231
sol::optional::or_else
optional< T > or_else(F &&f) const &
Definition: sol.hpp:5473
sol::basic_metatable::basic_metatable
basic_metatable(lua_State *L, T &&r)
Definition: sol.hpp:26188
sol::u_detail::usertype_storage::index_call_with_bases_
static int index_call_with_bases_(lua_State *L)
Definition: sol.hpp:24025
sol::meta::enable
std::enable_if_t< all< Args... >::value, enable_t > enable
Definition: sol.hpp:2244
sol::variadic_args::top
int top() const
Definition: sol.hpp:28758
sol::stack::qualified_checker
Definition: sol.hpp:11457
sol::policies
auto policies(F &&f, Args &&... args)
Definition: sol.hpp:7110
sol::stack_iterator::operator--
stack_iterator & operator--()
Definition: sol.hpp:17041
sol::stack::unqualified_pusher< detail::tagged< T, destructor_wrapper< Fx > > >::push
static int push(lua_State *L, destructor_wrapper< Fx > &&c)
Definition: sol.hpp:20376
sol::u_detail::make_string
std::string make_string(Arg &&arg)
Definition: sol.hpp:23294
sol::is_stateless_lua_reference
Definition: sol.hpp:8084
sol::string_view_hash
std::hash< std::string_view > string_view_hash
Definition: sol.hpp:2139
sol::optional< T & >::optional
constexpr optional(const optional< U > &rhs)
\exclude
Definition: sol.hpp:6705
sol::u_detail::update_bases_func::p_derived_usb
void * p_derived_usb
Definition: sol.hpp:23650
sol::lua_value::lua_value
lua_value(arr il)
Definition: sol.hpp:26997
sol::variadic_results
Definition: sol.hpp:28853
sol::state_view::safe_script_file
protected_function_result safe_script_file(const std::string &filename, const basic_environment< E > &env, load_mode mode=load_mode::any)
Definition: sol.hpp:27633
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::empty_start
static bool empty_start(lua_State *L_, T &self)
Definition: sol.hpp:22435
sol::optional::map_or
U map_or(F &&f, U &&u) &
Maps the stored value with f if there is one, otherwise returns u.
Definition: sol.hpp:5513
sol::stack::unqualified_pusher< std::reference_wrapper< T > >::push
static int push(lua_State *L, const std::reference_wrapper< T > &t)
Definition: sol.hpp:15030
sol::optional< T & >::map_or
U map_or(F &&f, U &&u) const &
\group map_or
Definition: sol.hpp:6538
sol::basic_function::basic_function
basic_function(lua_State *L, ref_index index)
Definition: sol.hpp:20666
sol::stack::unqualified_getter< light< T > >::get
static light< T > get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:13946
sol::unicode::unicode_detail::decode
static constexpr char32_t decode(unsigned char b0, unsigned char b1)
Definition: sol.hpp:13138
sol::stack::stack_detail::unqualified_interop_get
decltype(auto) unqualified_interop_get(lua_State *L, int index, void *unadjusted_pointer, record &tracking)
Definition: sol.hpp:11609
sol::basic_reference
Definition: forward.hpp:1099
sol::detail::resolve_v
constexpr Sig C::* resolve_v(std::false_type, Sig C::*mem_func_ptr)
Definition: sol.hpp:19690
sol::function_detail::c_call_matcher
Definition: sol.hpp:19064
sol::stack_iterator::difference_type
std::ptrdiff_t difference_type
Definition: sol.hpp:16998
sol::call_detail::lua_call_wrapper< T, constructor_wrapper< Cxs... >, is_index, is_variable, checked, boost, clean_stack, C >::F
constructor_wrapper< Cxs... > F
Definition: sol.hpp:18720
sol::stack::unqualified_getter< user< T * > >::get
static T * get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:13965
sol::basic_protected_function::basic_protected_function
basic_protected_function(const stack_reference &r)
Definition: sol.hpp:20882
sol::basic_table_core::cend
const_iterator cend() const
Definition: sol.hpp:25793
sol::policy_detail::handle_policy
void handle_policy(P &&p, lua_State *L, int &pushed)
Definition: sol.hpp:18128
sol::variadic_args::index
int index
Definition: sol.hpp:28637
detail::set
constexpr auto set(type rhs) -> int
Definition: core.h:627
sol::basic_reference::copy_ref
int copy_ref() const noexcept
Definition: sol.hpp:10452
sol::state_view::load_buffer
load_result load_buffer(const char *buff, size_t size, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27783
sol::u_detail::binding::F
meta::conditional_t< meta::is_c_str_of_v< uF, char >||meta::is_c_str_of_v< uF, char16_t >||meta::is_c_str_of_v< uF, char32_t >||meta::is_c_str_of_v< uF, wchar_t >, std::add_pointer_t< std::add_const_t< std::remove_all_extents_t< Fq > >>, std::decay_t< Fq > > F
Definition: sol.hpp:23464
sol::function_detail::member_variable::call
static int call(lua_State *L, member_variable &self) noexcept(std::is_nothrow_copy_assignable_v< T >)
Definition: sol.hpp:19578
sol::stack_proxy_base
Definition: sol.hpp:17121
sol::variadic_args::variadic_args
variadic_args(variadic_args &&o)
Definition: sol.hpp:28658
sol::automagic_enrollments::length_operator
bool length_operator
Definition: sol.hpp:8711
sol::protected_function_result::index
int index
Definition: sol.hpp:17231
sol::container_detail::has_traits_empty
has_empty< T > has_traits_empty
Definition: sol.hpp:21614
sol::basic_protected_function::~basic_protected_function
~basic_protected_function()
Definition: sol.hpp:21037
sol::basic_table_iterator::operator++
basic_table_iterator & operator++() noexcept
Definition: sol.hpp:25071
sol::stack::unqualified_pusher< detail::tagged< T, constructor_wrapper< Fxs... > > >::push
static int push(lua_State *L, detail::tagged< T, constructor_wrapper< Fxs... >> &&c)
Definition: sol.hpp:20326
sol::protected_function_result::rbegin
const_reverse_iterator rbegin() const
Definition: sol.hpp:17375
sol::u_detail::usertype_storage_base::unique_index_table
stateless_reference unique_index_table
Definition: sol.hpp:23684
sol::detail::voider
Definition: sol.hpp:4800
sol::u_detail::usertype_storage_base::named_metatable
stateless_reference named_metatable
Definition: sol.hpp:23690
sol::tie_t::set_extra
void set_extra(std::false_type, std::index_sequence< I... >, T &&target)
Definition: sol.hpp:10847
lua_gettop
LUA_API int lua_gettop(lua_State *L)
Definition: lapi.c:169
sol::optional::disjunction
SOL_TL_OPTIONAL_11_CONSTEXPR optional disjunction(optional &&rhs) &
\group disjunction
Definition: sol.hpp:5608
sol::stack::qualified_getter< Optional, std::enable_if_t< meta::is_optional_v< Optional > > >::get
static Optional get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14646
sol::dump_pass_on_error
int dump_pass_on_error(lua_State *L_, int result_code, lua_Writer writer_function, void *userdata_pointer_, bool strip)
Definition: sol.hpp:20556
sol::detail::optional_storage_base::optional_storage_base
SOL_TL_OPTIONAL_11_CONSTEXPR optional_storage_base() noexcept
Definition: sol.hpp:4926
sol::wrapper< F, std::enable_if_t< std::is_member_object_pointer< meta::unqualified_t< F > >::value > >::return_type
traits_type::return_type return_type
Definition: sol.hpp:17706
sol::stack::unqualified_pusher< detail::as_table_tag< T > >::push
static int push(std::false_type, std::integral_constant< bool, is_nested >, lua_State *L, const T &tablecont)
Definition: sol.hpp:15072
sol::stateless_stack_reference::pointer
const void * pointer(lua_State *L_) const noexcept
Definition: sol.hpp:9706
sol::function_detail::call_set_assignable
int call_set_assignable(std::true_type, lua_State *L, T &&mem)
Definition: sol.hpp:19014
sol::stack::push_popper_n::push_popper_n
push_popper_n(lua_State *L_, int pop_count_)
Definition: sol.hpp:9986
sol::state_view::ensure_package
void ensure_package(const std::string &key, T &&sr)
Definition: sol.hpp:27258
sol::dump_error::dump_error
dump_error(int error_code_)
Definition: sol.hpp:20548
sol::basic_protected_function::basic_protected_function
basic_protected_function(lua_State *L_, ref_index index_)
Definition: sol.hpp:20943
sol::basic_table_iterator::basic_table_iterator
basic_table_iterator(reference_type x) noexcept
Definition: sol.hpp:25060
sol::container_detail::u_c_launch::real_next_traits
static int real_next_traits(std::true_type, lua_State *L)
Definition: sol.hpp:22954
sol::make_reference
R make_reference(lua_State *L, T &&value)
Definition: sol.hpp:16715
sol::detail::error_result::format_string
const char * format_string
Definition: sol.hpp:4551
sol::stack::unqualified_pusher< push_invoke_t< T > >::push
static int push(lua_State *L, const push_invoke_t< T > &pi)
Definition: sol.hpp:20466
sol::is_transparent_argument
Definition: sol.hpp:8109
sol::basic_pairs_range::basic_pairs_range
basic_pairs_range(source_t source_) noexcept
Definition: sol.hpp:25401
sol::stack::stateless_push_popper
Definition: sol.hpp:10052
sol::stack::unqualified_pusher< detail::tagged< T, constructor_wrapper< Fxs... > > >::push
static int push(lua_State *L, const constructor_wrapper< Fxs... > &c)
Definition: sol.hpp:20342
sol::meta::supports_op_less_equal
Definition: sol.hpp:2652
sol::stateless_reference::stateless_reference
stateless_reference(const stack_reference &r) noexcept
Definition: sol.hpp:10210
sol::stack::qualified_interop_getter
Definition: sol.hpp:11444
sol::optional::map_or
U map_or(F &&f, U &&u) &&
\group map_or
Definition: sol.hpp:5519
sol::stack::unqualified_checker::check
static bool check(lua_State *L_, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:12410
sol::function_detail::upvalue_member_function
Definition: sol.hpp:19164
sol::optional< T & >::value
const SOL_TL_OPTIONAL_11_CONSTEXPR T & value() const
Definition: sol.hpp:6822
lua_Integer
LUA_INTEGER lua_Integer
Definition: lua.h:94
sol::wrapper
Definition: sol.hpp:17650
sol::basic_table_core::basic_table_core
basic_table_core(T &&r) noexcept
Definition: sol.hpp:25761
sol::meta::meta_detail::is_adl_sol_lua_push_v
constexpr bool is_adl_sol_lua_push_v
Definition: sol.hpp:11538
sol::detail::inheritance::type_cast_with
static void * type_cast_with(void *voiddata, const string_view &ti)
Definition: sol.hpp:9401
sol::no_metatable_t
Definition: sol.hpp:7339
sol::u_detail::binding::index_call
static int index_call(lua_State *L_)
Definition: sol.hpp:23530
sol::stack::stack_detail::raw_table_set
void raw_table_set(lua_State *L, T &&arg, int tableindex=-2)
Definition: sol.hpp:16550
sol::call_construction
Definition: sol.hpp:7002
sol::stack::unqualified_getter< std::tuple< Tn... > >::R
std::tuple< decltype(stack::get< Tn >nullptr, 0))... > R
Definition: sol.hpp:14293
sol::detail::not_enough_stack_space_generic
constexpr const char * not_enough_stack_space_generic
Definition: sol.hpp:9513
sol::variadic_args::pointer
stack_proxy * pointer
Definition: sol.hpp:28643
sol::detail::with_function_tag
Definition: sol.hpp:10933
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::pairs_associative
static int pairs_associative(std::true_type, lua_State *L_)
Definition: sol.hpp:22492
lua_isboolean
#define lua_isboolean(L, n)
Definition: lua.h:377
sol::detail::as_pointer_tag
Definition: sol.hpp:10936
sol::state_view::safe_script
protected_function_result safe_script(const string_view &code, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27606
sol::call_detail::agnostic_lua_call_wrapper< std::reference_wrapper< T >, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, std::reference_wrapper< T > f)
Definition: sol.hpp:18500
sol::unsafe_function_result::returncount
int returncount
Definition: sol.hpp:17443
lua_isnil
#define lua_isnil(L, n)
Definition: lua.h:376
sol::stateless_reference::equals
bool equals(lua_State *L_, const stateless_reference &r) const noexcept
Definition: sol.hpp:10364
sol::detail::unique_fallback< std::unique_ptr< T, D > >::get
static pointer get(lua_State *, const std::unique_ptr< T, D > &p) noexcept
Definition: sol.hpp:9159
sol::optional< T & >::disjunction
constexpr optional disjunction(const optional &rhs) const &
\group disjunction
Definition: sol.hpp:6604
sol::u_detail::change_indexing_mem_func
void(usertype_storage_base::*)(lua_State *, submetatable_type, void *, stateless_stack_reference &, lua_CFunction, lua_CFunction, lua_CFunction, lua_CFunction) change_indexing_mem_func
Definition: sol.hpp:23438
sol::variadic_args::reference_type
stack_proxy reference_type
Definition: sol.hpp:28641
sol::state_view::script
protected_function_result script(const string_view &code, const basic_environment< E > &env, Fx &&on_error, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27734
sol::detail::properties_enrollment_allowed::operator()
bool operator()(meta_function mf) const
Definition: sol.hpp:11390
sol::detail::ebco< T &&, tag >::value
const T & value() const &noexcept
Definition: sol.hpp:7250
sol::meta_function::pairs
@ pairs
sol::detail::clean::clean
clean(lua_State *luastate)
Definition: sol.hpp:25437
sol::u_detail::usertype_storage_base::self_index_call
static int self_index_call(types< Bases... >, lua_State *L, usertype_storage_base &self)
Definition: sol.hpp:23868
sol::container_detail::u_c_launch::empty_call
static int empty_call(lua_State *L)
Definition: sol.hpp:23075
source
const char * source
Definition: lz4.h:767
sol::destructor_wrapper
Definition: sol.hpp:7032
QwtTriangle::Left
@ Left
Definition: qwt_symbol.cpp:41
luaopen_os
LUAMOD_API int luaopen_os(lua_State *L)
Definition: loslib.c:426
lua_settop
LUA_API void lua_settop(lua_State *L, int idx)
Definition: lapi.c:174
sol::u_detail::create_usertype_storage
usertype_storage< T > & create_usertype_storage(lua_State *L)
Definition: sol.hpp:24225
sol::optional::optional
constexpr optional(const T &u)
\exclude
Definition: sol.hpp:5716
sol::wrapper< F, std::enable_if_t< std::is_member_object_pointer< meta::unqualified_t< F > >::value > >::call
static auto call(Fx &&fx, object_type &mem) -> detail::array_return_type< decltype(mem.*fx)>
Definition: sol.hpp:17722
sol::meta::meta_detail::basic_traits::free_args_list
meta::conditional_t< std::is_void< T >::value, args_list, types< first_type, Args... > > free_args_list
Definition: sol.hpp:1564
sol::call_detail::lua_call_wrapper< T, constructor_wrapper< Cxs... >, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, F &f)
Definition: sol.hpp:18741
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::erase_key_has
static detail::error_result erase_key_has(std::true_type, lua_State *L_, T &self, K &key)
Definition: sol.hpp:22366
sol::stack_guard::stack_guard
stack_guard(lua_State *L)
Definition: sol.hpp:10901
sol::container_detail::usertype_container_default::index_of
static int index_of(lua_State *L_)
Definition: sol.hpp:21709
sol::detail::default_destroy::destroy
static void destroy(T &&obj)
Definition: sol.hpp:6938
sol::stateless_reference::move_assign
lua_State * move_assign(lua_State *L_, lua_State *rL, stateless_reference &&r)
Definition: sol.hpp:10181
luaopen_string
LUAMOD_API int luaopen_string(lua_State *L)
Definition: lstrlib.c:1812
sol::basic_metatable::set_fx
void set_fx(types<>, Key &&key, Fx &&fx)
Definition: sol.hpp:26160
sol::basic_bytecode
Definition: forward.hpp:1106
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::get_associative
static detail::error_result get_associative(std::true_type, lua_State *L_, Iter &it)
Definition: sol.hpp:21851
sol::optional< T & >::map_or_else
detail::invoke_result_t< U > map_or_else(F &&f, U &&u) &
Maps the stored value with f if there is one, otherwise calls u and returns the result.
Definition: sol.hpp:6560
sol::call_detail::lua_call_wrapper< T, policy_wrapper< F, Policies... >, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, P &fx)
Definition: sol.hpp:18899
sol::thread_status
thread_status
Definition: sol.hpp:7859
sol::basic_table_core::operator[]
auto operator[](T &&key) const &
Definition: sol.hpp:26016
sol::u_detail::usertype_storage::index_call
static int index_call(lua_State *L)
Definition: sol.hpp:24032
sol::state_view::supports_gc_mode
bool supports_gc_mode(gc_mode mode) const noexcept
Definition: sol.hpp:27848
sol::error
Definition: sol.hpp:4573
sol::stack::stack_detail::copy_code_units_utf::target_
Ch * target_
Definition: sol.hpp:13375
sol::optional< T & >::or_else
optional< T > or_else(F &&f) const &
Definition: sol.hpp:6486
sol::call_detail::constructor_match
Definition: sol.hpp:18161
sol::detail::align_user
void * align_user(void *ptr)
Definition: sol.hpp:11093
sol::lua_value::lua_value
lua_value(lua_State *L_, arr il)
Definition: sol.hpp:26990
sol::no_constructor
const auto no_constructor
Definition: sol.hpp:7000
sol::stack_aligned_unsafe_function
basic_function< stack_reference, true > stack_aligned_unsafe_function
Definition: forward.hpp:1166
sol::container_detail::u_c_launch::erase_call
static int erase_call(lua_State *L)
Definition: sol.hpp:23063
sol::stack::stack_detail::maybe_push_lua_next_function
bool maybe_push_lua_next_function(lua_State *L_)
Definition: sol.hpp:25129
lauxlib.h
sol::default_traceback_error_handler
int default_traceback_error_handler(lua_State *L)
Definition: sol.hpp:27111
sol::unicode::encoded_result
Definition: sol.hpp:13077
sol::function_sig
Definition: sol.hpp:7372
lualib.h
sol::meta::unqualified_tuple_element
unqualified< tuple_element_t< N, Tuple > > unqualified_tuple_element
Definition: sol.hpp:1510
sol::user
Definition: forward.hpp:1246
sol::unicode::unicode_detail::is_lead_surrogate
static constexpr bool is_lead_surrogate(char32_t u)
Definition: sol.hpp:13096
sol::operator==
constexpr bool operator==(const optional< T > &lhs, const optional< U > &rhs)
Compares two optional objects.
Definition: sol.hpp:6015
lua_pushboolean
LUA_API void lua_pushboolean(lua_State *L, int b)
Definition: lapi.c:599
sol::lightuserdata
basic_lightuserdata< reference > lightuserdata
Definition: forward.hpp:1211
sol::u_detail::binding_data_equals
Definition: sol.hpp:23664
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::captured_type
meta::conditional_t< is_associative::value||is_matched_lookup::value, std::add_lvalue_reference_t< V >, meta::conditional_t< is_lookup::value, V, iterator_return > > captured_type
Definition: sol.hpp:21776
sol::stack::unqualified_pusher< nested< T > >::push
static int push(lua_State *L, const T &nested_value) noexcept
Definition: sol.hpp:15140
sol::unsafe_function_result::operator[]
stack_proxy operator[](difference_type index_offset) const
Definition: sol.hpp:17498
sol::stateless_stack_reference::stateless_stack_reference
stateless_stack_reference(lua_State *, absolute_index index_) noexcept
Definition: sol.hpp:9674
sol::function_detail::upvalue_member_function::traits_type
lua_bind_traits< function_type > traits_type
Definition: sol.hpp:19166
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::find_has_associative_lookup
static detail::error_result find_has_associative_lookup(std::false_type, lua_State *L_, T &self)
Definition: sol.hpp:22076
sol::lua_value::ref_value
reference ref_value
Definition: sol.hpp:26965
sol::argument_handler< types< R, Args... > >::operator()
int operator()(lua_State *L, int index, type expected, type actual, string_view message) const noexcept(false)
Definition: sol.hpp:9601
sol::stack::unqualified_pusher< yielding_t< T > >::push
static int push(lua_State *L, const yielding_t< T > &f, Args &&... args)
Definition: sol.hpp:20078
sol::stack::call_into_lua
int call_into_lua(types< Ret0, Ret... > tr, types< Args... > ta, lua_State *L, int start, Fx &&fx, FxArgs &&... fxargs)
Definition: sol.hpp:16610
sol::state_view::change_gc_mode_generational
gc_mode change_gc_mode_generational(int minor_multiplier, int major_multiplier)
Definition: sol.hpp:27920
sol::pairs_iterator::operator!=
friend bool operator!=(const pairs_iterator &left, const pairs_iterator &right) noexcept
Definition: sol.hpp:25352
sol::stack::unqualified_pusher< char * >::push_sized
static int push_sized(lua_State *L, const char *str, std::size_t len)
Definition: sol.hpp:15419
sol::stack::clear
void clear(lua_State *L_, stateless_stack_reference &r)
Definition: sol.hpp:11741
lua_pushvalue
LUA_API void lua_pushvalue(lua_State *L, int idx)
Definition: lapi.c:264
sol::meta::is_member_object_or_function
std::integral_constant< bool, is_member_object_v< T >||std::is_member_pointer_v< T > > is_member_object_or_function
Definition: sol.hpp:18033
sol::stack_reference::stack_reference
stack_reference(lua_State *L, lua_nil_t) noexcept
Definition: sol.hpp:9757
sol::detail::base_class_cast_key
decltype(auto) base_class_cast_key()
Definition: sol.hpp:9347
sol::derive::type
types type
Definition: sol.hpp:1294
sol::container_detail::u_c_launch::real_at_call
static int real_at_call(lua_State *L)
Definition: sol.hpp:22890
sol::state_view::load
load_result load(lua_Reader reader, void *data, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27797
sol::as_table_t
Definition: forward.hpp:1238
sol::stateless_stack_reference_equals::m_L
lua_State * m_L
Definition: sol.hpp:9880
sol::basic_lua_table::basic_lua_table
basic_lua_table(lua_State *L, ref_index index)
Definition: sol.hpp:26450
sol::stack::pop_n
push_popper_n< top_level > pop_n(lua_State *L_, int pop_count_)
Definition: sol.hpp:10119
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::set_comparative
static detail::error_result set_comparative(std::true_type, lua_State *L_, T &self, stack_object okey, stack_object value)
Definition: sol.hpp:21971
sol::wrapper< F, std::enable_if_t< std::is_member_object_pointer< meta::unqualified_t< F > >::value > >::call
static void call(Fx &&fx, object_type &mem, Arg &&arg, Args &&...)
Definition: sol.hpp:17727
sol::meta::meta_detail::on_always
std::true_type on_always
Definition: sol.hpp:2301
sol::automagic_flags::less_than_operator
@ less_than_operator
sol::detail::std_shim::lua_func_
unsafe_function lua_func_
Definition: sol.hpp:21211
luaL_len
LUALIB_API lua_Integer luaL_len(lua_State *L, int idx)
Definition: lauxlib.c:871
sol::stack::unqualified_checker< std::variant< Tn... >, type::poly >::is_one
static bool is_one(std::integral_constant< std::size_t, 0 >, lua_State *L_, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:12910
sol::stack::unqualified_pusher< this_state >::push
static int push(lua_State *, const this_state &) noexcept
Definition: sol.hpp:15967
sol::stack::script
void script(lua_State *L, const string_view &code, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:16660
sol::stack::unqualified_getter< as_table_t< std::forward_list< T, Al > > >::get
static C get(std::false_type, lua_State *L, int relindex, record &tracking)
Definition: sol.hpp:13795
sol::optional< T & >::map_or
U map_or(F &&f, U &&u) &&
\group map_or
Definition: sol.hpp:6532
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::size
static int size(lua_State *L_)
Definition: sol.hpp:22606
sol::closure<>::closure
closure(lua_CFunction f, int upvalue_count=0)
Definition: sol.hpp:7545
sol::stack_object
basic_object< stack_reference > stack_object
Definition: forward.hpp:1219
luaL_loadfilex
LUALIB_API int luaL_loadfilex(lua_State *L, const char *filename, const char *mode)
Definition: lauxlib.c:776
sol::pairs_sentinel
Definition: sol.hpp:25193
sol::function_detail::upvalue_member_function::call
static int call(lua_State *L) noexcept(traits_type::is_noexcept)
Definition: sol.hpp:19186
sol::this_environment::this_environment
this_environment()
Definition: sol.hpp:26735
sol::stateless_reference::stateless_reference
stateless_reference(lua_State *L_, global_tag_t) noexcept
Definition: sol.hpp:10195
lua_close
LUA_API void lua_close(lua_State *L)
Definition: lstate.c:410
sol::error::what_reason
std::string what_reason
Definition: sol.hpp:4576
sol::stack::stack_detail::metatable_setup::operator()
void operator()()
Definition: sol.hpp:23134
sol::stack_reference_equals::operator()
bool operator()(const lua_nil_t &lhs, const stack_reference &rhs) const
Definition: sol.hpp:9886
sol::main_table
main_table_core< false > main_table
Definition: forward.hpp:1128
sol::basic_reference::~basic_reference
~basic_reference() noexcept
Definition: sol.hpp:10536
string_view
basic_string_view< char > string_view
Definition: core.h:518
sol::unsafe_function_result::difference_type
std::ptrdiff_t difference_type
Definition: sol.hpp:17449
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::T
std::remove_pointer_t< meta::unwrap_unqualified_t< container_decay_t< X > >> T
Definition: sol.hpp:21757
sol::state_view::script_file
unsafe_function_result script_file(const std::string &filename, load_mode mode=load_mode::any)
Definition: sol.hpp:27772
sol::stack::push_popper< false, T, std::enable_if_t< is_stack_based_v< meta::unqualified_t< T > > > >::Tu
meta::unqualified_t< T > Tu
Definition: sol.hpp:10038
sol::stack::stack_detail::is_get_direct_tableless_v
constexpr bool is_get_direct_tableless_v
Definition: sol.hpp:16071
sol::unsafe_function_result::unsafe_function_result
unsafe_function_result(unsafe_function_result &&o) noexcept
Definition: sol.hpp:17467
sol::stack_iterator::operator!=
bool operator!=(const stack_iterator &r) const
Definition: sol.hpp:17086
sol::type::function
@ function
sol::detail::returns_void_impl
Definition: sol.hpp:4823
sol::tie_t
Definition: sol.hpp:10822
sol::lib::bit32
@ bit32
sol::detail::optional_storage_base< T, true >::m_dummy
dummy m_dummy
Definition: sol.hpp:4963
sol::stateless_reference::stateless_reference
stateless_reference(lua_State *L_, ref_index index_) noexcept
Definition: sol.hpp:10267
sol::stack::unqualified_pusher
Definition: sol.hpp:11452
sol::stack::unqualified_pusher< userdata_value >::push
static int push(lua_State *L, userdata_value data)
Definition: sol.hpp:15382
sol::proxy_base
Definition: forward.hpp:1112
LUA_TNONE
#define LUA_TNONE
Definition: lua.h:63
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::push_type
meta::conditional_t< is_input_iterator::value, V, decltype(detail::deref_move_only(std::declval< captured_type >)))> push_type
Definition: sol.hpp:21779
sol::stack::field_getter::get
void get(lua_State *L, Key &&key, int tableindex=default_table_index)
Definition: sol.hpp:16107
sol::string_view
std::string_view string_view
Definition: sol.hpp:2135
sol::usertype_traits
Definition: forward.hpp:1255
sol::stateless_stack_reference_equals::operator()
bool operator()(const stateless_stack_reference &lhs, const stateless_stack_reference &rhs) const
Definition: sol.hpp:9867
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::empty
static int empty(lua_State *L_)
Definition: sol.hpp:22792
sol::member_function_wrapper::caller
Definition: sol.hpp:17777
sol::container_detail::u_c_launch::next_call
static int next_call(lua_State *L)
Definition: sol.hpp:23099
sol::function_detail::member_variable::function_type
std::remove_pointer_t< std::decay_t< Function > > function_type
Definition: sol.hpp:19565
sol::container_detail::u_c_launch::real_index_set_traits
static int real_index_set_traits(std::false_type, lua_State *L)
Definition: sol.hpp:22922
sol::basic_table_iterator::operator!=
bool operator!=(const basic_table_iterator &right) const noexcept
Definition: sol.hpp:25103
sol::stack::unqualified_getter::get
static decltype(auto) get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:13433
sol::pairs_iterator::difference_type
std::ptrdiff_t difference_type
Definition: sol.hpp:25204
sol::detail::associated_nullopt_v
constexpr auto associated_nullopt_v
Definition: sol.hpp:6905
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::set_associative_insert
static detail::error_result set_associative_insert(std::true_type, lua_State *, T &self, Iter &it, K &key, stack_object value)
Definition: sol.hpp:21993
lua_pushcfunction
#define lua_pushcfunction(L, f)
Definition: lua.h:371
sol::function_detail::overloaded_function::on_success::operator()
int operator()(Args &&... args) const
Definition: sol.hpp:19639
sol::detail::optional_storage_base::m_dummy
dummy m_dummy
Definition: sol.hpp:4942
sol::unicode::error_code::invalid_leading_surrogate
@ invalid_leading_surrogate
sol::meta::meta_detail::unique_element_type::type
typename std::pointer_traits< typename unique_actual_type< T >::type >::element_type type
Definition: sol.hpp:9196
sol::u_detail::string_for_each_metatable_func::p_key
std::string * p_key
Definition: sol.hpp:23574
sol::meta::meta_detail::callable_traits< R(T::*), true >::args_list
types< Arg > args_list
Definition: sol.hpp:2005
lua_getmetatable
LUA_API int lua_getmetatable(lua_State *L, int objindex)
Definition: lapi.c:769
sol::u_detail::string_for_each_metatable_func::p_derived_usb
void * p_derived_usb
Definition: sol.hpp:23579
sol::stack::unqualified_getter< lightuserdata_value >::get
static lightuserdata_value get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:13938
sol::basic_table_iterator::operator*
reference operator*() const noexcept
Definition: sol.hpp:25095
sol::container_detail::u_c_launch::real_insert_traits
static int real_insert_traits(std::false_type, lua_State *L)
Definition: sol.hpp:22994
sol::container_detail::has_traits_get_test
Definition: sol.hpp:21479
sol::detail::enable_forward_value
detail::enable_if_t< std::is_constructible< T, U && >::value &&!std::is_same< detail::decay_t< U >, in_place_t >::value &&!std::is_same< optional< T >, detail::decay_t< U > >::value > enable_forward_value
Definition: sol.hpp:4837
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::value_type
std::remove_extent_t< T > value_type
Definition: sol.hpp:22659
sol::stack::unqualified_pusher< const char * >::push
static int push(lua_State *L, const char *str, std::size_t len)
Definition: sol.hpp:15412
sol::detail::optional_storage_base::m_value
T m_value
Definition: sol.hpp:4943
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::set_associative
static detail::error_result set_associative(std::true_type, iterator &it, stack_object value)
Definition: sol.hpp:21915
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::find
static int find(lua_State *L_)
Definition: sol.hpp:22784
sol::stack::qualified_interop_checker::check
static bool check(lua_State *L_, int index, type index_type, Handler &&handler, record &tracking)
Definition: sol.hpp:12402
sol::stack::stack_detail::eval
static decltype(auto) eval(types< Arg, Args... >, std::index_sequence< I, Is... >, lua_State *L_, int start_index_, Handler &&handler_, record &tracking_, Fx &&fx_, FxArgs &&... fxargs_)
Definition: sol.hpp:16495
sol::basic_protected_function::dump
Container dump() const
Definition: sol.hpp:20971
sol::stack::unqualified_pusher< detail::tagged< T, no_construction > >::push
static int push(lua_State *L, detail::tagged< T, no_construction >)
Definition: sol.hpp:20291
lua_status
LUA_API int lua_status(lua_State *L)
Definition: lapi.c:1118
sol::meta_method
meta_function meta_method
Definition: sol.hpp:8025
sol::basic_thread::status
thread_status status() const
Definition: sol.hpp:28201
sol::stack::stack_detail::uu_pusher
Definition: sol.hpp:14891
sol::detail::not_enough_stack_space_meta_function_name
constexpr const char * not_enough_stack_space_meta_function_name
Definition: sol.hpp:9511
sol::basic_object::basic_object
basic_object(detail::no_safety_tag, lua_State *L_, int index_)
Definition: sol.hpp:16835
sol::optional< T & >::value
SOL_TL_OPTIONAL_11_CONSTEXPR T & value()
Definition: sol.hpp:6811
sol::unsafe_function_result::rbegin
const_reverse_iterator rbegin() const
Definition: sol.hpp:17527
sol::stack::stack_detail::undefined_metatable::key
const char * key
Definition: sol.hpp:11664
sol::stack::multi_push_reference
int multi_push_reference(lua_State *)
Definition: sol.hpp:11844
sol::detail::unique_destroy
int unique_destroy(lua_State *L) noexcept
Definition: sol.hpp:11327
sol::stack::push_popper_n< true >::push_popper_n
push_popper_n(lua_State *, int)
Definition: sol.hpp:9999
sol::load_status::gc
@ gc
sol::container_detail::u_c_launch::new_index_call
static int new_index_call(lua_State *L)
Definition: sol.hpp:23119
sol::basic_lightuserdata::basic_lightuserdata
basic_lightuserdata(const stack_reference &r)
Definition: sol.hpp:28568
sol::reference_equals::operator()
bool operator()(const basic_reference< lb > &lhs, const lua_nil_t &rhs) const noexcept
Definition: sol.hpp:10757
sol::table_proxy::tuple_set
void tuple_set(std::index_sequence< I... >, T &&value) &&
Definition: sol.hpp:24741
sol::basic_metatable::set
basic_metatable< base_type > & set(Key &&key, Value &&value)
Definition: sol.hpp:26531
sol::unsafe_function_result::crbegin
const_reverse_iterator crbegin() const
Definition: sol.hpp:17533
sol::is_variable_binding
Definition: sol.hpp:18986
sol::stack::stack_detail::strip::type
T type
Definition: sol.hpp:11557
sol::detail::remove_const_t
typename std::remove_const< T >::type remove_const_t
Definition: sol.hpp:4718
sol::stack::unqualified_getter< T * >::get
static T * get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14275
LUA_TLIGHTUSERDATA
#define LUA_TLIGHTUSERDATA
Definition: lua.h:67
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::at
static int at(lua_State *L_)
Definition: sol.hpp:22744
sol::meta::unwrap_unqualified
Definition: sol.hpp:2170
sol::basic_table_core::create
static table create(lua_State *L, int narr, int nrec, Key &&key, Value &&value, Args &&... args)
Definition: sol.hpp:26077
sol::pairs_iterator::m_key_index
int m_key_index
Definition: sol.hpp:25387
sol::container_detail::has_empty_test
Definition: sol.hpp:21322
sol::detail::resolve_f
constexpr void resolve_f(std::false_type, F &&)
Definition: sol.hpp:19675
sol::detail::stack_fail
void stack_fail(int, int)
Definition: sol.hpp:10885
sol::u_detail::usertype_storage_base::type_table
stateless_reference type_table
Definition: sol.hpp:23688
sol::container_detail::has_traits_next_test
Definition: sol.hpp:21527
sol::basic_protected_function::m_error_handler
handler_t m_error_handler
Definition: sol.hpp:21084
sol::stack::field_setter
Definition: sol.hpp:11436
sol::stateless_reference::stateless_reference
stateless_reference(lua_State *L_, const stateless_stack_reference &r) noexcept
Definition: sol.hpp:10255
sol::u_detail::binding::index_call_with_
static int index_call_with_(lua_State *L_, void *target)
Definition: sol.hpp:23500
sol::constructor_wrapper
Definition: sol.hpp:7006
sol::this_environment::env
optional< environment > env
Definition: sol.hpp:26733
sol::pairs_iterator::operator!=
friend bool operator!=(const pairs_sentinel &, const pairs_iterator &left) noexcept
Definition: sol.hpp:25368
sol::stack::push_popper_n::~push_popper_n
~push_popper_n()
Definition: sol.hpp:9992
sol::main_userdata
basic_userdata< main_reference > main_userdata
Definition: forward.hpp:1216
sol::property_wrapper::read
const R & read() const
Definition: sol.hpp:17950
LUA_ERRSYNTAX
#define LUA_ERRSYNTAX
Definition: lua.h:52
sol::meta::enable_t
enable_t
Definition: sol.hpp:2236
sol::container_detail::usertype_container_default::insert
static int insert(lua_State *L_)
Definition: sol.hpp:21701
sol::get
stack_proxy get(types< Args... > t, const protected_function_result &fr)
Definition: sol.hpp:17629
sol::container_detail::usertype_container_default::at
static int at(lua_State *L_)
Definition: sol.hpp:21676
sol::stack::unqualified_pusher< factory_wrapper< Functions... > >::push
static int push(lua_State *L, const factory_wrapper< Functions... > &fw, function_detail::call_indicator)
Definition: sol.hpp:20264
LUA_YIELD
#define LUA_YIELD
Definition: lua.h:50
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::empty_has
static bool empty_has(std::true_type, lua_State *, T &self)
Definition: sol.hpp:22398
sol::state_view::open_libraries
void open_libraries(Args &&... args)
Definition: sol.hpp:27320
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::add_copyable
static detail::error_result add_copyable(std::false_type, lua_State *L_, T &self, stack_object value, Iter &)
Definition: sol.hpp:22253
sol::meta::meta_detail::detect_deducible_signature
decltype(&F::operator()) detect_deducible_signature
Definition: sol.hpp:1525
sol::state_view::traverse_set
state_view & traverse_set(Args &&... args)
Definition: sol.hpp:27977
sol::exception_handler_function
int(*)(lua_State *, optional< const std::exception & >, string_view) exception_handler_function
Definition: sol.hpp:8733
sol::stack::stack_detail::impl_check_metatable
bool impl_check_metatable(lua_State *L_, int index, const std::string &metakey, bool poptable)
Definition: sol.hpp:12358
sol::u_detail::usertype_storage::meta_index_call
static int meta_index_call(lua_State *L)
Definition: sol.hpp:24042
sol::basic_table_core::basic_table_core
basic_table_core(detail::no_safety_tag, lua_State *L, ref_index index)
Definition: sol.hpp:25697
sol::stack::unqualified_getter< std::variant< Tn... > >::get_one
static V get_one(std::integral_constant< std::size_t, I >, lua_State *L, int index, record &tracking)
Definition: sol.hpp:14342
sol::stack::unqualified_pusher< detail::as_table_tag< T > >::push
static int push(std::true_type, std::integral_constant< bool, is_nested >, lua_State *L, const T &tablecont)
Definition: sol.hpp:15056
sol::basic_coroutine::basic_coroutine
basic_coroutine(const stack_reference &r, handler_t eh) noexcept
Definition: sol.hpp:28373
sol::function_detail::overloaded_function::overloaded_function
overloaded_function(Functions... fxs)
Definition: sol.hpp:19627
sol::stack::unqualified_pusher< basic_bytecode< Allocator > >::push
static int push(lua_State *L, T &&bc)
Definition: sol.hpp:16001
sol::wrapper< F, std::enable_if_t< std::is_function< std::remove_pointer_t< meta::unqualified_t< F > > >::value > >::returns_list
traits_type::returns_list returns_list
Definition: sol.hpp:17674
sol::stateless_stack_reference::stateless_stack_reference
stateless_stack_reference(lua_State *, raw_index index_) noexcept
Definition: sol.hpp:9676
sol::nested::nested
nested(Arg &&arg, Args &&... args) noexcept(std::is_nothrow_constructible_v< base_t, Arg, Args... >)
Definition: sol.hpp:7627
sol::basic_lua_table::basic_lua_table
basic_lua_table(T &&r) noexcept
Definition: sol.hpp:26460
sol::stateless_stack_reference_hash::stateless_stack_reference_hash
stateless_stack_reference_hash(lua_State *L_) noexcept
Definition: sol.hpp:9904
sol::stack_iterator::operator>=
bool operator>=(const stack_iterator &r) const
Definition: sol.hpp:17102
sol::usertype_traits::gc_table
static const std::string & gc_table()
Definition: sol.hpp:9106
sol::main_unsafe_function
basic_function< main_reference, false > main_unsafe_function
Definition: forward.hpp:1162
sol::meta::remove_member_pointer
Definition: sol.hpp:2176
sol::function_detail::upvalue_this_member_variable
Definition: sol.hpp:19400
sol::basic_object_base::is_stack
bool is_stack(std::true_type) const
Definition: sol.hpp:16779
SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE
#define SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(T)
Definition: sol.hpp:4687
sol::stateless_stack_reference::reset
void reset(lua_State *L_, int index_) noexcept
Definition: sol.hpp:9725
sol::stack::unqualified_pusher< detail::as_pointer_tag< T > >::push_fx
static int push_fx(lua_State *L, F &&f, T *obj)
Definition: sol.hpp:14851
sol::unsafe_function_result::const_iterator
stack_iterator< stack_proxy, true > const_iterator
Definition: sol.hpp:17452
lua_call
#define lua_call(L, n, r)
Definition: lua.h:283
sol::table_proxy::operator=
table_proxy && operator=(std::initializer_list< T > other) &&
Definition: sol.hpp:24818
sol::container_detail::has_traits_set_test
Definition: sol.hpp:21467
sol::detail::optional_move_assign_base
Definition: sol.hpp:5107
sol::basic_pairs_range
Definition: sol.hpp:25392
sol::basic_coroutine::basic_coroutine
basic_coroutine(proxy_base< Super > &&p)
Definition: sol.hpp:28383
sol::load_status::file
@ file
sol::stack::unqualified_getter< as_table_t< std::forward_list< T, Al > > >::get
static C get(lua_State *L, int relindex, record &tracking)
Definition: sol.hpp:13784
sol::call_status::yielded
@ yielded
sol::state_view::unsafe_script
unsafe_function_result unsafe_script(lua_Reader reader, void *data, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27659
sol::call_status::runtime
@ runtime
sol::create
const new_table create
Definition: sol.hpp:7807
set
ROSCPP_DECL void set(const std::string &key, bool b)
sol::detail::no_prop
Definition: sol.hpp:17924
sol::lua_type_of
Definition: sol.hpp:8386
sol::meta_registry_key
auto meta_registry_key(T &&key)
Definition: sol.hpp:7528
sol::reference_equals::operator()
bool operator()(const stack_reference &lhs, const basic_reference< rb > &rhs) const noexcept
Definition: sol.hpp:10772
sol::basic_table_core::new_enum
table new_enum(const string_view &name, Args &&... args)
Definition: sol.hpp:25938
sol::meta::sfinae_yes_t
std::true_type sfinae_yes_t
Definition: sol.hpp:1366
sol::basic_protected_function::luacall
call_status luacall(std::ptrdiff_t argcount, std::ptrdiff_t result_count_, detail::protected_handler< b, handler_t > &h) const
Definition: sol.hpp:21087
sol::automagic_flags::call_operator
@ call_operator
sol::detail::make_unique_deleter
std::unique_ptr< T, Dx > make_unique_deleter(Args &&... args)
Definition: sol.hpp:6963
sol::overload
decltype(auto) overload(Args &&... args)
Definition: sol.hpp:13032
sol::is_lua_index
Definition: sol.hpp:8500
sol::stack::unqualified_pusher< function_sig< Sigs... > >::push
static int push(lua_State *L, Arg0 &&arg0, Args &&... args)
Definition: sol.hpp:20061
lua_rawequal
LUA_API int lua_rawequal(lua_State *L, int index1, int index2)
Definition: lapi.c:322
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::set_it
static detail::error_result set_it(std::true_type, lua_State *L_, T &self, stack_object key, stack_object value)
Definition: sol.hpp:22043
sol::stack::check_get
decltype(auto) check_get(lua_State *L, int index=-lua_size< meta::unqualified_t< T >>::value)
Definition: sol.hpp:11975
sol::stack_iterator::operator++
stack_iterator & operator++()
Definition: sol.hpp:17030
sol::container_detail::u_c_launch::real_erase_traits
static int real_erase_traits(std::true_type, lua_State *L)
Definition: sol.hpp:23026
sol::function_detail::member_function::member_function
member_function(function_type f, Args &&... args) noexcept(std::is_nothrow_constructible_v< function_type, function_type > &&std::is_nothrow_constructible_v< T, Args... >)
Definition: sol.hpp:19526
sol::detail::is_speshul
Definition: sol.hpp:10812
sol::detail::trampoline
int trampoline(lua_State *L, Fx &&f, Args &&... args)
Definition: sol.hpp:8842
sol::basic_table_iterator::kvp
std::pair< object, object > kvp
Definition: sol.hpp:25050
sol::pairs_iterator::pairs_iterator
pairs_iterator() noexcept
Definition: sol.hpp:25210
sol::u_detail::usertype_storage_base::const_value_index_table
stateless_reference const_value_index_table
Definition: sol.hpp:23686
sol::stack::stack_detail::check_types
bool check_types(types< Args... >, lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:11995
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::get_associative
static detail::error_result get_associative(std::false_type, lua_State *L_, Iter &it)
Definition: sol.hpp:21857
sol::this_environment::this_environment
this_environment(environment e)
Definition: sol.hpp:26737
sol::u_detail::usertype_storage_index
constexpr const int usertype_storage_index
Definition: sol.hpp:23248
sol::detail::protected_handler::valid
bool valid() const noexcept
Definition: sol.hpp:20760
sol::wrapper< F, std::enable_if_t< std::is_member_object_pointer< meta::unqualified_t< F > >::value > >::object_type
traits_type::object_type object_type
Definition: sol.hpp:17705
sol::container_detail::is_forced_container
Definition: sol.hpp:21629
sol::detail::optional_map_impl
constexpr auto optional_map_impl(Opt &&opt, F &&f) -> optional< Ret >
Definition: sol.hpp:6224
sol::meta::call_operator_deducible
typename is_detected< meta_detail::detect_deducible_signature, F >::type call_operator_deducible
Definition: sol.hpp:1529
sol::meta::remove_member_pointer< R T::* >::type
R type
Definition: sol.hpp:2180
sol::basic_table_core::operator[]
auto operator[](T &&key) &
Definition: sol.hpp:26011
sol::meta_function::mode
@ mode
sol::stack::unqualified_pusher< detail::as_table_tag< T > >::push
static int push(std::true_type, lua_State *L, const T &tablecont)
Definition: sol.hpp:15047
sol::detail::non_lua_nil_t
Definition: sol.hpp:7327
sol::detail::deref
decltype(auto) deref(T &&item)
Definition: sol.hpp:2084
sol::stack::unqualified_pusher< const wchar_t * >::push
static int push(lua_State *L, const wchar_t *wstr)
Definition: sol.hpp:15640
sol::optional::operator->
constexpr const T * operator->() const
Definition: sol.hpp:5889
sol::basic_table_iterator::key_type
object key_type
Definition: sol.hpp:25040
sol::detail::align_usertype_unique
void * align_usertype_unique(void *ptr)
Definition: sol.hpp:11070
sol::detail::not_a_number_or_number_string_integral
constexpr const char * not_a_number_or_number_string_integral
Definition: sol.hpp:9505
sol::error::error
error(detail::direct_error_tag, std::string &&str)
Definition: sol.hpp:4585
start
ROSCPP_DECL void start()
sol::state_view::cend
const_iterator cend() const
Definition: sol.hpp:27816
sol::detail::cannot_destroy
int cannot_destroy(lua_State *L)
Definition: sol.hpp:11355
backward::Color::reset
@ reset
Definition: backward.hpp:3678
sol::basic_metatable::basic_metatable
basic_metatable(stack_reference &&r)
Definition: sol.hpp:26185
sol::tie_size< unsafe_function_result >
Definition: sol.hpp:17608
sol::meta::meta_detail::has_internal_marker_v
constexpr bool has_internal_marker_v
Definition: sol.hpp:1447
sol::stack::unqualified_getter< std::function< Signature > >::get
static std::function< Signature > get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:21249
sol::function_detail::overloaded_function::overloads
overload_list overloads
Definition: sol.hpp:19622
sol::bytecode_dump_writer
constexpr auto bytecode_dump_writer
Definition: sol.hpp:4526
udp_client.int
int
Definition: udp_client.py:11
sol::container_detail::usertype_container_default::begin
static iterator begin(lua_State *L_, T &)
Definition: sol.hpp:21741
sol::state_view::unsafe_script
unsafe_function_result unsafe_script(const string_view &code, const basic_environment< E > &env, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27669
sol::container_detail::has_traits_at
meta::boolean< has_traits_at_test< T >::value > has_traits_at
Definition: sol.hpp:21584
sol::protected_function_result::protected_function_result
protected_function_result(lua_State *Ls, int idx=-1, int retnum=0, int popped=0, call_status pferr=call_status::ok) noexcept
Definition: sol.hpp:17248
sol::detail::tagged::value
T const & value() const &
Definition: sol.hpp:6981
sol::stack_iterator::index
int index
Definition: sol.hpp:17001
sol::load_result::err
load_status err
Definition: sol.hpp:26818
sol::stack::stack_detail::check_metatable
bool check_metatable(lua_State *L_, int index=-2)
Definition: sol.hpp:12372
sol::meta::count_even_for_pack_v
constexpr std::size_t count_even_for_pack_v
Definition: sol.hpp:2341
sol::stack::stack_detail::check_get_arg
decltype(auto) check_get_arg(lua_State *L_, int index_, Handler &&handler_, record &tracking_)
Definition: sol.hpp:12164
sol::ref_index
Definition: sol.hpp:7404
sol::stack::probe_field_getter
Definition: sol.hpp:11433
sol::state_view::safe_script
protected_function_result safe_script(const string_view &code, const basic_environment< E > &env, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27601
sol::lib::debug
@ debug
luaopen_coroutine
LUAMOD_API int luaopen_coroutine(lua_State *L)
Definition: lcorolib.c:206
sol::stack::unqualified_pusher< lua_thread_state >::push
int push(lua_State *, lua_thread_state lts)
Definition: sol.hpp:28098
sol::detail::resolve_i
constexpr auto resolve_i(types< R(Args...)>, F &&) -> R(meta::unqualified_t< F >::*)(Args...)
Definition: sol.hpp:19662
sol::u_detail::index_target_fail
int index_target_fail(lua_State *L_, void *)
Definition: sol.hpp:23553
sol::stack::unqualified_pusher< detail::tagged< T, constructor_list< Lists... > > >::push
static int push(lua_State *L, detail::tagged< T, constructor_list< Lists... >>)
Definition: sol.hpp:20304
sol::basic_coroutine::basic_coroutine
basic_coroutine(basic_function< base_t > &&b, handler_t eh) noexcept
Definition: sol.hpp:28365
sol::stack::unqualified_pusher< const void * >::push
static int push(lua_State *L, const void *userdata) noexcept
Definition: sol.hpp:15285
luaL_prepbuffsize
LUALIB_API char * luaL_prepbuffsize(luaL_Buffer *B, size_t sz)
Definition: lauxlib.c:574
sol::is_callable_v
constexpr bool is_callable_v
Definition: sol.hpp:8142
sol::yielding_t
Definition: sol.hpp:7343
sol::basic_object::basic_object
basic_object(detail::no_safety_tag, lua_State *L_, T &&r) noexcept
Definition: sol.hpp:16846
sol::basic_object::operator=
basic_object & operator=(const proxy_base< Super > &r)
Definition: sol.hpp:16904
sol::basic_thread::basic_thread
basic_thread(lua_State *L, int index=-1)
Definition: sol.hpp:28160
reader
static const char * reader(lua_State *L, void *ud, size_t *size)
Definition: luac.c:126
sol::basic_thread::basic_thread
basic_thread(lua_State *L, this_state actualthread)
Definition: sol.hpp:28175
sol::stack::stack_detail::undefined_method_func
void(*)(stack_reference) undefined_method_func
Definition: sol.hpp:2865
sol::stack::unqualified_pusher< variadic_args >::push
static int push(lua_State *L, const variadic_args &ref)
Definition: sol.hpp:28774
sol::stack::stack_detail::is_get_direct_v
constexpr bool is_get_direct_v
Definition: sol.hpp:16074
sol::basic_reference::basic_reference
basic_reference(const basic_reference &o) noexcept
Definition: sol.hpp:10542
sol::detail::invoke
constexpr auto invoke(Fn &&f, Args &&... args) noexcept(noexcept(std::forward< Fn >(f)(std::forward< Args >(args)...))) -> decltype(std::forward< Fn >(f)(std::forward< Args >(args)...))
Definition: sol.hpp:4777
sol::detail::swap_adl_tests::uses_std
std::false_type uses_std(...)
sol::lua_value::lua_value
lua_value(T &&value)
Definition: sol.hpp:26977
sol::meta_function::type_info
@ type_info
sol::u_detail::usertype_storage::set
void set(lua_State *L, Key &&key, Value &&value)
Definition: sol.hpp:24192
sol::stack::qualified_interop_checker
Definition: sol.hpp:12400
sol::stack::maybe_indexable
bool maybe_indexable(lua_State *L, int index=-1)
Definition: sol.hpp:11679
sol::stack::record
Definition: sol.hpp:11476
sol::basic_protected_function::basic_protected_function
basic_protected_function(lua_State *L_, absolute_index index_)
Definition: sol.hpp:20927
LUA_TNIL
#define LUA_TNIL
Definition: lua.h:65
sol::usertype_proxy::get_type
type get_type() const
Definition: sol.hpp:24693
sol::is_lua_primitive_v
constexpr bool is_lua_primitive_v
Definition: sol.hpp:8429
sol::meta_function::call
@ call
sol::make_closure
closure< Args... > make_closure(lua_CFunction f, Args &&... args)
Definition: sol.hpp:7552
sol::function_detail::no_construction_error
int no_construction_error(lua_State *L)
Definition: sol.hpp:18134
sol::unsafe_function_result::cbegin
const_iterator cbegin() const
Definition: sol.hpp:17514
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::erase_integral
static detail::error_result erase_integral(std::true_type, lua_State *L_, T &self, K &key)
Definition: sol.hpp:22317
sol::stack_reference_hash
Definition: sol.hpp:9920
SOL_TL_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE
#define SOL_TL_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE(T)
Definition: sol.hpp:4688
lua_pushlstring
const LUA_API char * lua_pushlstring(lua_State *L, const char *s, size_t len)
Definition: lapi.c:520
sol::basic_object_base::is_stack
bool is_stack(std::false_type) const
Definition: sol.hpp:16784
sol::stack::unqualified_pusher< light< T > >::push
static int push(lua_State *L, light< T > l) noexcept
Definition: sol.hpp:15307
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::find_has
static detail::error_result find_has(std::false_type, lua_State *L_, T &self)
Definition: sol.hpp:22139
sol::protected_function_result::protected_function_result
protected_function_result(protected_function_result &&o) noexcept
Definition: sol.hpp:17259
sol::detail::align_usertype_pointer
void * align_usertype_pointer(void *ptr)
Definition: sol.hpp:11010
sol::stateless_reference::copy_assign
void copy_assign(lua_State *L_, const stateless_reference &right) noexcept
Definition: sol.hpp:10354
sol::basic_table_core::create_named
table create_named(Name &&name, Args &&... args)
Definition: sol.hpp:26121
sol::stack::stack_detail::push_as_upvalues
int push_as_upvalues(lua_State *L, T &item)
Definition: sol.hpp:16438
sol::basic_environment::basic_environment
basic_environment(env_key_t, const stack_reference &extraction_target)
Definition: sol.hpp:26600
sol::unicode::decoded_result::codepoint
char32_t codepoint
Definition: sol.hpp:13072
sol::detail::removals
constexpr std::array< string_view, 9 > removals
Definition: sol.hpp:8928
sol::lua_value::arr
Definition: sol.hpp:26940
sol::detail::unique_fallback::SOL_INTERNAL_UNSPECIALIZED_MARKER_
int SOL_INTERNAL_UNSPECIALIZED_MARKER_
Definition: sol.hpp:9125
sol::container_detail::usertype_container_default::find
static int find(lua_State *L_)
Definition: sol.hpp:21705
sol::basic_metatable::set_function
basic_metatable & set_function(Key &&key, Args &&... args)
Definition: sol.hpp:26233
sol::detail::attempt_alloc_unique
bool attempt_alloc_unique(lua_State *L, std::size_t ptr_align, std::size_t ptr_size, std::size_t real_align, std::size_t allocated_size, void *&pointer_adjusted, void *&dx_adjusted, void *&id_adjusted, void *&data_adjusted)
Definition: sol.hpp:11157
LUA_GCCOLLECT
#define LUA_GCCOLLECT
Definition: lua.h:321
SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE
#define SOL_TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T)
Definition: sol.hpp:4686
sol::container_detail::has_clear
meta::boolean< has_clear_test< T >::value > has_clear
Definition: sol.hpp:21563
sol::container_detail::has_traits_get
meta::boolean< has_traits_get_test< T >::value > has_traits_get
Definition: sol.hpp:21581
sol::u_detail::usertype_storage_base::update_bases
void update_bases(lua_State *L_, bases< Bases... >)
Definition: sol.hpp:23766
sol::is_to_stringable_v
constexpr bool is_to_stringable_v
Definition: sol.hpp:8136
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::get_comparative
static detail::error_result get_comparative(std::true_type, lua_State *L_, T &self, K &key)
Definition: sol.hpp:21895
sol::state_view::safe_script_file
protected_function_result safe_script_file(const std::string &filename, const basic_environment< E > &env, Fx &&on_error, load_mode mode=load_mode::any)
Definition: sol.hpp:27623
sol::absolute_index::absolute_index
absolute_index(lua_State *L, int idx)
Definition: sol.hpp:7396
sol::detail::ebco< T &, tag >
Definition: sol.hpp:7212
sol::detail::is_optional_impl
Definition: sol.hpp:4808
sol::state_view::begin
iterator begin() const
Definition: sol.hpp:27804
sol::stack::unqualified_pusher< factory_wrapper< Functions... > >::push
static int push(lua_State *L, const factory_wrapper< Functions... > &fw)
Definition: sol.hpp:20252
sol::meta_function::bitwise_xor
@ bitwise_xor
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::key_type
meta::unqualified_t< decltype(get_key(is_associative(), std::declval< std::add_lvalue_reference_t< value_type >>()))> key_type
Definition: sol.hpp:21782
COMPAT53_API
#define COMPAT53_API
Definition: sol.hpp:3175
sol::basic_table_core< true >::is_get_direct_tableless
meta::boolean< stack::stack_detail::is_get_direct_tableless_v< T, top_level, false > > is_get_direct_tableless
Definition: sol.hpp:25474
sol::stack::unqualified_getter< as_table_t< std::forward_list< T, Al > > >::C
std::forward_list< T, Al > C
Definition: sol.hpp:13782
sol::wrapper::args_list
traits_type::args_list args_list
Definition: sol.hpp:17652
sol::unicode::unicode_detail::replacement
static constexpr char32_t replacement
Definition: sol.hpp:13155
sol::detail::usertype_allocate
T * usertype_allocate(lua_State *L)
Definition: sol.hpp:11194
sol::detail::std_shim< void >::operator()
void operator()(Args &&... args)
Definition: sol.hpp:21230
sol::call_detail::lua_call_wrapper< T, function_arguments< Sig, P >, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, const function_arguments< Sig, P > &f)
Definition: sol.hpp:18915
sol::unsafe_function_result::reverse_iterator
std::reverse_iterator< iterator > reverse_iterator
Definition: sol.hpp:17453
SOL_LUA_VERSION_I_
#define SOL_LUA_VERSION_I_
Definition: sol.hpp:3021
sol::function_detail::upvalue_free_function
Definition: sol.hpp:19129
sol::stack::unqualified_getter< const char * >::get
static const char * get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:13993
sol::table_proxy::set
table_proxy && set(T &&item) &&
Definition: sol.hpp:24773
sol::stack_iterator::operator<=
bool operator<=(const stack_iterator &r) const
Definition: sol.hpp:17098
sol::stack::field_setter< std::tuple< Args... >, b, raw, C >::top_apply
void top_apply(std::index_sequence< I0, I... >, lua_State *L, Keys &&keys, Value &&value, int tableindex)
Definition: sol.hpp:16292
sol::stack_userdata
basic_userdata< stack_reference > stack_userdata
Definition: forward.hpp:1220
wstring_view
basic_string_view< wchar_t > wstring_view
Definition: xchar.h:42
sol::state_view::unsafe_script_file
unsafe_function_result unsafe_script_file(const std::string &filename, const basic_environment< E > &env, load_mode mode=load_mode::any)
Definition: sol.hpp:27696
sol::meta_function::unary_minus
@ unary_minus
sol::lua_thread_state::lua_thread_state
lua_thread_state(lua_State *Ls)
Definition: sol.hpp:28081
lua_xmove
LUA_API void lua_xmove(lua_State *from, lua_State *to, int n)
Definition: lapi.c:121
sol::detail::is_policy_v
constexpr bool is_policy_v
Definition: sol.hpp:7119
sol::gc_mode::incremental
@ incremental
sol::state_view::do_file
protected_function_result do_file(const std::string &filename, const basic_environment< E > &env, load_mode mode=load_mode::any)
Definition: sol.hpp:27542
sol::basic_object_base
Definition: forward.hpp:1195
sol::dump_error
Definition: sol.hpp:20543
sol::detail::unchecked_t
Definition: sol.hpp:1361
sol::stack::unqualified_pusher< std::function< Signature > >::push
static int push(lua_State *L, detail::yield_tag_t, std::function< Signature > &&fx)
Definition: sol.hpp:20128
sol::stack::unqualified_pusher< char16_t * >::push
static int push(lua_State *L, const char16_t *strb, const char16_t *stre)
Definition: sol.hpp:15748
sol::table_proxy::operator=
table_proxy & operator=(std::initializer_list< T > other) &
Definition: sol.hpp:24813
sol::stack::unqualified_pusher< const char * >::push
static int push(lua_State *L, const char *strb, const char *stre)
Definition: sol.hpp:15408
sol::stack_usertype
basic_usertype< T, stack_reference > stack_usertype
Definition: forward.hpp:1143
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::index_of
static int index_of(lua_State *L_)
Definition: sol.hpp:22780
sol::stack::check
bool check(lua_State *L, int index=-lua_size< meta::unqualified_t< T >>::value)
Definition: sol.hpp:11899
sol::dump_panic_on_error
int dump_panic_on_error(lua_State *L_, int result_code, lua_Writer writer_function, void *userdata_pointer_, bool strip)
Definition: sol.hpp:20564
sol::stack_reference::lua_state
lua_State * lua_state() const noexcept
Definition: sol.hpp:9812
lua_settable
LUA_API void lua_settable(lua_State *L, int idx)
Definition: lapi.c:849
sol::basic_table_core::set_function
basic_table_core & set_function(Key &&key, Args &&... args)
Definition: sol.hpp:26026
sol::detail::implicit_wrapper::value
T & value
Definition: sol.hpp:7292
sol::stack::field_setter< std::pair< A, B >, b, raw, C >::set
void set(lua_State *L, Keys &&keys, Value &&value, int tableindex=-1)
Definition: sol.hpp:16306
sol::stack::push_popper_at::index
int index
Definition: sol.hpp:9973
sol::meta::meta_detail::type_element_type_t
typename T::element_type type_element_type_t
Definition: sol.hpp:9192
sol::stack::set_ref
int set_ref(lua_State *L, T &&arg, int tableindex=-2)
Definition: sol.hpp:16560
sol::detail::ebco< T, tag, std::enable_if_t<!std::is_reference_v< T > &&std::is_class_v< T > &&!std::is_final_v< T > > >::ebco
ebco(Arg &&arg, Args &&... args) noexcept(std::is_nothrow_constructible_v< T, Arg, Args... >)
Definition: sol.hpp:7184
sol::optional< T & >::or_else
optional< T > SOL_TL_OPTIONAL_11_CONSTEXPR or_else(F &&f) &
Calls f if the optional is empty \requires std::invoke_result_t<F> must be void or convertible to opt...
Definition: sol.hpp:6452
sol::basic_metatable::basic_metatable
basic_metatable(detail::no_safety_tag, lua_State *L, T &&r) noexcept
Definition: sol.hpp:26151
sol::variadic_args::crend
const_reverse_iterator crend() const
Definition: sol.hpp:28713
sol::basic_table_iterator::difference_type
std::ptrdiff_t difference_type
Definition: sol.hpp:25044
sol::meta::has_insert_with_iterator
meta::boolean< meta_detail::has_insert_with_iterator_test< T >::value > has_insert_with_iterator
Definition: sol.hpp:2706
sol::automagic_flags::equal_to_operator
@ equal_to_operator
sol::is_lua_reference_or_proxy
Definition: sol.hpp:8103
sol::meta_function::less_than
@ less_than
sol::basic_metatable::set_fx
void set_fx(types<>, Key &&key, Fx &&fx, Args &&... args)
Definition: sol.hpp:26166
sol::basic_protected_function::basic_protected_function
basic_protected_function(std::false_type, const basic_protected_function &other_) noexcept
Definition: sol.hpp:20841
sol::automagic_flags::less_than_or_equal_to_operator
@ less_than_or_equal_to_operator
sol::meta_function::concatenation
@ concatenation
sol::basic_reference::pop
void pop(lua_State *L_, int n=1) const noexcept
Definition: sol.hpp:10618
sol::meta_function::new_index
@ new_index
sol::detail::none
@ none
Definition: sol.hpp:7745
sol::stateless_reference::ref
int ref
Definition: sol.hpp:10164
sol::factory_wrapper::functions
std::tuple< Functions... > functions
Definition: sol.hpp:7020
sol::stateless_stack_reference_hash::is_transparent
std::true_type is_transparent
Definition: sol.hpp:9902
sol::operator|
constexpr automagic_flags operator|(automagic_flags left, automagic_flags right) noexcept
Definition: sol.hpp:8668
sol::load_result::status
load_status status() const noexcept
Definition: sol.hpp:26860
sol::function_detail::upvalue_this_member_function::real_call
static int real_call(lua_State *L) noexcept(traits_type::is_noexcept)
Definition: sol.hpp:19352
sol::detail::align_usertype_unique_tag
void * align_usertype_unique_tag(void *ptr)
Definition: sol.hpp:11048
sol::basic_usertype
Definition: forward.hpp:1139
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::next
static int next(lua_State *L_)
Definition: sol.hpp:22808
sol::detail::default_construct::construct
static void construct(T &&obj, Args &&... args)
Definition: sol.hpp:6924
sol::detail::inheritance_unique_cast_function
decltype(&inheritance< void >::type_unique_cast< void >) inheritance_unique_cast_function
Definition: sol.hpp:9488
sol::stateless_stack_reference_hash::m_L
lua_State * m_L
Definition: sol.hpp:9917
sol::meta::identity::type
T type
Definition: sol.hpp:1428
lua_rawseti
LUA_API void lua_rawseti(lua_State *L, int idx, lua_Integer n)
Definition: lapi.c:915
sol::stack::unqualified_pusher< const char16_t * >::push
static int push(lua_State *L, const char16_t *u16str)
Definition: sol.hpp:15706
luaL_setfuncs
LUALIB_API void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup)
Definition: lauxlib.c:926
sol::stack::push_userdata
int push_userdata(lua_State *L, T &&t, Args &&... args)
Definition: sol.hpp:11783
sol::basic_thread::create
static basic_thread create(lua_State *L)
Definition: sol.hpp:28220
sol::optional< T & >::take
optional take() const &
\group take
Definition: sol.hpp:6651
sol::basic_table_core::pairs
basic_pairs_range< const basic_table_core > pairs() const noexcept
Definition: sol.hpp:25801
sol::table_proxy
Definition: forward.hpp:1114
sol::unique_usertype_element_t
typename meta::meta_detail::unique_element_type< unique_usertype_traits< T > >::type unique_usertype_element_t
Definition: sol.hpp:9217
sol::stack::unqualified_pusher< protect_t< T > >::push
static int push(lua_State *L, const protect_t< T > &pw)
Definition: sol.hpp:20204
sol::lib::ffi
@ ffi
sol::unicode::code_point_to_utf32
encoded_result< char32_t > code_point_to_utf32(char32_t codepoint)
Definition: sol.hpp:13217
sol::stack::unqualified_pusher< T, std::enable_if_t< meta::is_optional_v< T > > >::push
static int push(lua_State *L, Optional &&op)
Definition: sol.hpp:15931
sol::ref_index::index
int index
Definition: sol.hpp:7405
sol::packaged_coroutine
basic_packaged_coroutine< reference > packaged_coroutine
Definition: forward.hpp:1214
sol::stateless_stack_reference::push
int push(lua_State *L_) const noexcept
Definition: sol.hpp:9690
sol::optional::or_else
optional< T > or_else(F &&f) &&
Definition: sol.hpp:5456
sol::tie_t::set
void set(std::true_type, T &&target)
Definition: sol.hpp:10832
sol::basic_thread::basic_thread
basic_thread(lua_State *L, ref_index index)
Definition: sol.hpp:28166
sol::userdata_value::value
void * value() const
Definition: sol.hpp:7438
sol::meta::tuple_types
typename detail::tuple_types_< Args... >::type tuple_types
Definition: sol.hpp:1483
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::index_of
static int index_of(lua_State *L_)
Definition: sol.hpp:22580
sol::stateless_reference_hash::operator()
result_type operator()(const stateless_reference &lhs) const noexcept
Definition: sol.hpp:10785
luaL_unref
LUALIB_API void luaL_unref(lua_State *L, int t, int ref)
Definition: lauxlib.c:688
sol::stack_iterator
Definition: sol.hpp:16994
sol::meta::tuplefy
decltype(auto) tuplefy(X &&... x)
Definition: sol.hpp:2833
sol::detail::inheritance::type_check_with
static bool type_check_with(const string_view &ti)
Definition: sol.hpp:9380
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::get_it
static detail::error_result get_it(std::true_type, lua_State *L_, T &self, K &key)
Definition: sol.hpp:21891
sol::meta::disable_if_t
std::enable_if_t<!value, T > disable_if_t
Definition: sol.hpp:2241
sol::function_detail::class_indicator
Definition: sol.hpp:19803
sol::basic_userdata::basic_userdata
basic_userdata(stack_reference &&r)
Definition: sol.hpp:28520
sol::function_detail::upvalue_member_variable::real_call
static int real_call(lua_State *L) noexcept(traits_type::is_noexcept)
Definition: sol.hpp:19224
std
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::add_insert
static detail::error_result add_insert(std::false_type, lua_State *L_, T &self, stack_object value)
Definition: sol.hpp:22183
sol::detail::ref_clean
Definition: sol.hpp:25444
sol::optional< T & >::operator=
optional & operator=(const optional< U > &rhs)
Definition: sol.hpp:6741
sol::stack::probe_get_field
probe probe_get_field(lua_State *L, Key &&key, int tableindex)
Definition: sol.hpp:12110
sol::optional::swap
void swap(optional &rhs) noexcept(std::is_nothrow_move_constructible< T >::value &&detail::is_nothrow_swappable< T >::value)
Definition: sol.hpp:5868
sol::detail::not_a_number_integral
constexpr const char * not_a_number_integral
Definition: sol.hpp:9503
sol::optional< T & >::take
optional take() &&
\group take
Definition: sol.hpp:6658
sol::variadic_args::begin
iterator begin()
Definition: sol.hpp:28679
sol::detail::is_check
int is_check(lua_State *L)
Definition: sol.hpp:12215
sol::optional::optional
SOL_TL_OPTIONAL_11_CONSTEXPR optional(detail::enable_if_t< std::is_constructible< T, std::initializer_list< U > &, Args &&... >::value, in_place_t >, std::initializer_list< U > il, Args &&... args)
Definition: sol.hpp:5693
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::KV
meta::conditional_t< is_matched_lookup::value, std::pair< value_type, value_type >, meta::conditional_t< is_associative::value||is_lookup::value, value_type, std::pair< std::ptrdiff_t, value_type > > > KV
Definition: sol.hpp:21769
sol::usertype_proxy::tbl
Table tbl
Definition: sol.hpp:24592
sol::stack::unqualified_getter< char >::get
static char get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14002
sol::basic_metatable
Definition: forward.hpp:1146
sol::basic_protected_function::basic_protected_function
basic_protected_function(basic_function< base_t > &&b)
Definition: sol.hpp:20876
sol::call_detail::constructor_match::operator()
int operator()(types< Fx >, meta::index_value< I >, types< R... > r, types< Args... > a, lua_State *L, int, int start) const
Definition: sol.hpp:18171
sol::detail::default_exception_handler
int default_exception_handler(lua_State *L, optional< const std::exception & >, string_view what)
Definition: sol.hpp:8742
sol::in_place_index
constexpr in_place_index_t< I > in_place_index
Definition: sol.hpp:4623
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::next_associative
static int next_associative(std::false_type, lua_State *L_)
Definition: sol.hpp:22465
sol::detail::unwrap
auto unwrap(T &&item) -> decltype(std::forward< T >(item))
Definition: sol.hpp:2074
sol::basic_reference::valid
bool valid(lua_State *L_) const noexcept
Definition: sol.hpp:10630
sol::c_closure
closure c_closure
Definition: sol.hpp:7549
sol::stack_iterator::operator->
pointer operator->() const
Definition: sol.hpp:17025
sol::stack::push_reference
int push_reference(lua_State *L, T &&t, Args &&... args)
Definition: sol.hpp:11823
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::add_associative
static detail::error_result add_associative(std::false_type, lua_State *L_, T &self, stack_object value, Iter &pos)
Definition: sol.hpp:22235
sol::stack::field_setter< std::tuple< Args... >, b, raw, C >::set
void set(lua_State *L, Keys &&keys, Value &&value, int tableindex=-3)
Definition: sol.hpp:16298
sol::stack::unqualified_pusher< char16_t[N]>::push
static int push(lua_State *L, const char16_t(&str)[N])
Definition: sol.hpp:15852
sol::optional< T & >::and_then
constexpr detail::invoke_result_t< F, const T & > and_then(F &&f) const &&
Definition: sol.hpp:6360
sol::detail::std_shim::operator()
meta::return_type_t< R... > operator()(Args &&... args)
Definition: sol.hpp:21217
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::iter::~iter
~iter()
Definition: sol.hpp:22672
sol::as_nested
nested< meta::unqualified_t< T > > as_nested(T &&container)
Definition: sol.hpp:7661
sol::detail::call_exception_handler
int call_exception_handler(lua_State *L, optional< const std::exception & > maybe_ex, string_view what)
Definition: sol.hpp:8752
sol::stack::unqualified_check_getter< std::variant< Tn... >, C >::get_empty
static optional< V > get_empty(std::false_type, lua_State *L, int index, Handler &&handler, record &)
Definition: sol.hpp:14502
sol::u_detail::update_bases_func::base_class_cast_func
detail::inheritance_cast_function base_class_cast_func
Definition: sol.hpp:23647
sol::detail::usertype_unique_alloc_destroy
void usertype_unique_alloc_destroy(void *memory)
Definition: sol.hpp:11347
sol::u_detail::clear_usertype_storage
void clear_usertype_storage(lua_State *L)
Definition: sol.hpp:24320
sol::meta::at_in_pack< 0, Arg, Args... >::type
Arg type
Definition: sol.hpp:2290
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::add
static int add(lua_State *L_)
Definition: sol.hpp:22562
sol::unicode::utf16_to_code_point
decoded_result< It > utf16_to_code_point(It it, It last)
Definition: sol.hpp:13294
sol::is_lua_c_function_v
constexpr bool is_lua_c_function_v
Definition: sol.hpp:8651
sol::safe_function
basic_protected_function< reference, false, reference > safe_function
Definition: forward.hpp:1161
C
#define C(name, bit)
Definition: zstd.c:4811
sol::detail::no_comp
Definition: sol.hpp:12207
sol::policy_wrapper::value
F value
Definition: sol.hpp:7096
sol::detail::unique_fallback< std::shared_ptr< T > >::is_null
static bool is_null(lua_State *, const std::shared_ptr< T > &p) noexcept
Definition: sol.hpp:9140
sol::as_args_t::src
T src
Definition: sol.hpp:28604
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::begin
static iterator begin(lua_State *, T &self)
Definition: sol.hpp:22816
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::set_associative_insert
static detail::error_result set_associative_insert(std::false_type, lua_State *, T &self, Iter &it, K &key, stack_object)
Definition: sol.hpp:22012
lua_getglobal
LUA_API int lua_getglobal(lua_State *L, const char *name)
Definition: lapi.c:660
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::clear_start
static void clear_start(lua_State *L_, T &self)
Definition: sol.hpp:22431
sol::meta::meta_detail::void_tuple_element< I, std::tuple<> >::type
void type
Definition: sol.hpp:1541
sol::container_detail::get_value
decltype(auto) get_value(std::true_type, T &&t)
Definition: sol.hpp:21663
sol::stack::modify_unique_usertype
void modify_unique_usertype(const stack_reference &obj, F &&f)
Definition: sol.hpp:12155
sol::container_detail::has_erase_after
meta::boolean< has_erase_after_test< T >::value > has_erase_after
Definition: sol.hpp:21578
sol::stack::push_userdata
int push_userdata(lua_State *L, Arg &&arg, Args &&... args)
Definition: sol.hpp:11792
sol::call_detail::lua_call_wrapper< T, function_arguments< Sig, P >, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, function_arguments< Sig, P > &f)
Definition: sol.hpp:18920
sol::stack::stack_detail::uu_pusher::element
unique_usertype_element_t< T > element
Definition: sol.hpp:14892
sol::lua_thread_state::lua_state
lua_State * lua_state() const noexcept
Definition: sol.hpp:28084
lua_next
LUA_API int lua_next(lua_State *L, int idx)
Definition: lapi.c:1245
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::K
KV::first_type K
Definition: sol.hpp:21770
sol::stack::qualified_check_getter
Definition: sol.hpp:11462
sol::u32string_view
std::u32string_view u32string_view
Definition: sol.hpp:2138
sol::stack::stack_detail::push_function::push_function
push_function(lua_State *L_) noexcept
Definition: sol.hpp:16012
sol::destructor_wrapper::fx
Function fx
Definition: sol.hpp:7033
sol::stack::remove
void remove(lua_State *L_, int rawindex, int count)
Definition: sol.hpp:9945
sol::container_detail::u_c_launch::real_at_traits
static int real_at_traits(std::true_type, lua_State *L)
Definition: sol.hpp:22882
sol::stack::unqualified_pusher< detail::as_table_tag< T > >::push
static int push(lua_State *L, const T &tablecont)
Definition: sol.hpp:15039
sol::stateless_reference_hash
Definition: sol.hpp:10777
sol::this_main_state::L
lua_State * L
Definition: sol.hpp:7775
luaL_checkstack
LUALIB_API void luaL_checkstack(lua_State *L, int space, const char *msg)
Definition: lauxlib.c:380
sol::stack::unqualified_pusher< detail::as_value_tag< T > >::push_keyed
static int push_keyed(lua_State *L, K &&k, Args &&... args)
Definition: sol.hpp:14825
sol::stack::unqualified_pusher< std::basic_string< Ch, Traits, Al > >::push
static int push(lua_State *L, const std::basic_string< Ch, Traits, Al > &str, std::size_t sz)
Definition: sol.hpp:15568
sol::detail::properties_enrollment_allowed::properties
std::bitset< 64 > & properties
Definition: sol.hpp:11383
sol::optional< T & >::and_then
SOL_TL_OPTIONAL_11_CONSTEXPR detail::invoke_result_t< F, T & > and_then(F &&f) &&
Definition: sol.hpp:6339
sol::meta::void_t
void void_t
Definition: sol.hpp:1370
sol::basic_object::basic_object
basic_object(lua_State *L_, int index_=-1) noexcept
Definition: sol.hpp:16877
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::ipairs
static int ipairs(lua_State *L_)
Definition: sol.hpp:22642
sol::unicode::utf32_to_code_point
decoded_result< It > utf32_to_code_point(It it, It last)
Definition: sol.hpp:13332
sol::function_detail::member_function::member
T member
Definition: sol.hpp:19523
sol::basic_environment::basic_environment
basic_environment(lua_State *L, ref_index index)
Definition: sol.hpp:26623
sol::detail::ebco< T &, tag >::value
T & value() const noexcept
Definition: sol.hpp:7229
sol::basic_reference::push
int push() const noexcept
Definition: sol.hpp:10590
luaL_traceback
LUALIB_API void luaL_traceback(lua_State *L, lua_State *L1, const char *msg, int level)
Definition: lauxlib.c:131
lua_tonumber
#define lua_tonumber(L, i)
Definition: lua.h:362
sol::basic_coroutine::invoke
Ret invoke(types< Ret >, std::index_sequence< I >, std::ptrdiff_t n)
Definition: sol.hpp:28298
sol::basic_metatable::basic_metatable
basic_metatable(lua_State *L, int index=-1)
Definition: sol.hpp:26195
sol::basic_protected_function::basic_protected_function
basic_protected_function(basic_function< base_t > &&b, handler_t eh)
Definition: sol.hpp:20880
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::get_start
static detail::error_result get_start(lua_State *L_, T &self, K &key)
Definition: sol.hpp:22419
sol::container_detail::u_c_launch::real_clear_traits
static int real_clear_traits(std::false_type, lua_State *L)
Definition: sol.hpp:23006
sol::u_detail::index_call_function
int(lua_State *, void *) index_call_function
Definition: sol.hpp:23436
sol::detail::align_usertype_unique_destructor
void * align_usertype_unique_destructor(void *ptr)
Definition: sol.hpp:11026
sol::stack::field_setter< std::tuple< Args... >, b, raw, C >::apply
void apply(std::index_sequence< I0, I1, I... >, lua_State *L, Keys &&keys, Value &&value, int tableindex)
Definition: sol.hpp:16285
sol::state_view::step_gc
bool step_gc(int step_size_kilobytes)
Definition: sol.hpp:27874
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::erase_after_has
static detail::error_result erase_after_has(std::false_type, lua_State *, T &, const K &)
Definition: sol.hpp:22362
sol::basic_object::basic_object
basic_object(const stack_reference &r) noexcept
Definition: sol.hpp:16865
sol::stack::unqualified_pusher< new_table >::push
static int push(lua_State *L, const new_table &nt)
Definition: sol.hpp:15981
sol::stack::unqualified_getter< non_null< T * > >::get
static T * get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14251
sol::stack::stack_detail::is_set_direct_tableless_v
constexpr bool is_set_direct_tableless_v
Definition: sol.hpp:16086
sol::stack::call_lua
int call_lua(lua_State *L, int start, Fx &&fx, FxArgs &&... fxargs)
Definition: sol.hpp:16632
sol::stack::stack_detail::is_set_direct_v
constexpr bool is_set_direct_v
Definition: sol.hpp:16089
lua_seti
LUA_API void lua_seti(lua_State *L, int idx, lua_Integer n)
Definition: lapi.c:871
sol::stack::unqualified_pusher< as_container_t< T * > >::push
static int push(lua_State *L, T *cont)
Definition: sol.hpp:23208
sol::function_detail::upvalue_member_variable< T, readonly_wrapper< Function > >::operator()
int operator()(lua_State *L) noexcept(traits_type::is_noexcept)
Definition: sol.hpp:19336
sol::stack::stack_detail::count_code_units_utf::count_code_units_utf
count_code_units_utf()
Definition: sol.hpp:13365
sol::create_if_nil_t
Definition: sol.hpp:7741
sol::state_view::create_table_with
table create_table_with(Args &&... args)
Definition: sol.hpp:28053
sol::detail::is_not_insert_mode
meta::neg< is_insert_mode< T > > is_not_insert_mode
Definition: sol.hpp:7752
sol::container_detail::u_c_launch::pairs_call
static int pairs_call(lua_State *L)
Definition: sol.hpp:23091
sol::basic_reference::move_assign
void move_assign(basic_reference< r_main_only > &&r)
Definition: sol.hpp:10412
sol::u_detail::usertype_storage_base::m_L
lua_State * m_L
Definition: sol.hpp:23677
luaL_error
LUALIB_API int luaL_error(lua_State *L, const char *fmt,...)
Definition: lauxlib.c:234
Value
union Value Value
sol::detail::optional_copy_assign_base< T, false >::operator=
optional_copy_assign_base & operator=(const optional_copy_assign_base &rhs)
Definition: sol.hpp:5097
sol::detail::unique_get_noexcept
constexpr bool unique_get_noexcept() noexcept
Definition: sol.hpp:9278
sol::wrapper< F, std::enable_if_t< std::is_function< std::remove_pointer_t< meta::unqualified_t< F > > >::value > >::free_args_list
traits_type::args_list free_args_list
Definition: sol.hpp:17673
sol::stack::probe_field_getter< std::pair< A, B >, P, b, raw, C >::get
probe get(lua_State *L, Keys &&keys, int tableindex=-2)
Definition: sol.hpp:16336
sol::basic_table_iterator::~basic_table_iterator
~basic_table_iterator()
Definition: sol.hpp:25107
sol::basic_table_iterator
Definition: sol.hpp:25038
sol::basic_protected_function::basic_protected_function
basic_protected_function(lua_State *L_, int index_=-1)
Definition: sol.hpp:20919
sol::stack::qualified_checker::check
static bool check(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:12951
sol::stack::unqualified_pusher< char32_t * >::push
static int push(lua_State *L, const char32_t *str)
Definition: sol.hpp:15819
sol::stack::unqualified_check_getter< std::variant< Tn... >, C >::get
static optional< V > get(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:14526
sol::meta::is_member_object_or_function_v
constexpr bool is_member_object_or_function_v
Definition: sol.hpp:18036
sol::nested_tag
constexpr nested_tag_t nested_tag
Definition: sol.hpp:7643
sol::stack::unqualified_getter< std::variant< Tn... > >::get
static V get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14352
sol::optional< T & >::operator->
constexpr const T * operator->() const
Definition: sol.hpp:6772
sol::optional::or_else
optional< T > SOL_TL_OPTIONAL_11_CONSTEXPR or_else(F &&f) &
Calls f if the optional is empty \requires std::invoke_result_t<F> must be void or convertible to opt...
Definition: sol.hpp:5439
sol::stack::unqualified_pusher< yielding_t< T > >::push
static int push(lua_State *L, yielding_t< T > &&f, Args &&... args)
Definition: sol.hpp:20089
sol::function_detail::upvalue_member_variable< T, readonly_wrapper< Function > >::traits_type
lua_bind_traits< function_type > traits_type
Definition: sol.hpp:19287
sol::u_detail::binding::index_call_
static int index_call_(lua_State *L_)
Definition: sol.hpp:23524
sol::u_detail::base_walking_failed_index
constexpr const int base_walking_failed_index
Definition: sol.hpp:23257
sol::yielding_t::yielding_t
yielding_t(Arg0 &&arg0, Arg1 &&arg1, Args &&... args)
Definition: sol.hpp:7357
sol::basic_metatable::set_resolved_function
void set_resolved_function(Key &&key, Args &&... args)
Definition: sol.hpp:26171
sol::u_detail::usertype_storage_base::string_keys_storage
std::vector< std::unique_ptr< char[]> > string_keys_storage
Definition: sol.hpp:23679
default_value
def default_value(type_)
luaL_requiref
LUALIB_API void luaL_requiref(lua_State *L, const char *modname, lua_CFunction openf, int glb)
Definition: lauxlib.c:967
sol::readonly
auto readonly(R T::*v)
Definition: sol.hpp:18006
presentation_type::string
@ string
sol::function_detail::upvalue_this_member_function::function_type
std::remove_pointer_t< std::decay_t< Function > > function_type
Definition: sol.hpp:19349
sol::function_detail::upvalue_this_member_variable< T, readonly_wrapper< Function > >::traits_type
lua_bind_traits< function_type > traits_type
Definition: sol.hpp:19443
sol::stack::record::used
int used
Definition: sol.hpp:11478
sol::detail::inheritance::type_cast
static void * type_cast(void *voiddata, const string_view &ti)
Definition: sol.hpp:9395
sol::basic_table_iterator::operator==
bool operator==(const basic_table_iterator &right) const noexcept
Definition: sol.hpp:25099
sol::u_detail::toplevel_magic
constexpr const lua_Integer toplevel_magic
Definition: sol.hpp:23245
sol::container_detail::u_c_launch::real_insert_call
static int real_insert_call(lua_State *L)
Definition: sol.hpp:22998
sol::container_detail::u_c_launch::real_clear_call
static int real_clear_call(lua_State *L)
Definition: sol.hpp:23010
sol::upvalue_index
Definition: sol.hpp:7374
sol::detail::invoke_result_impl
Definition: sol.hpp:4784
sol::stateless_reference_equals::operator()
bool operator()(const stateless_reference &lhs, const lua_nil_t &rhs) const noexcept
Definition: sol.hpp:10739
sol::script_pass_on_error
protected_function_result script_pass_on_error(lua_State *, protected_function_result result)
Definition: sol.hpp:27150
sol::container_detail::usertype_container_default::T
std::remove_pointer_t< meta::unwrap_unqualified_t< X > > T
Definition: sol.hpp:21670
sol::optional::value_or
SOL_TL_OPTIONAL_11_CONSTEXPR T value_or(U &&u) &&
\group value_or
Definition: sol.hpp:5994
sol::optional< T & >::map_or_else
detail::invoke_result_t< U > map_or_else(F &&f, U &&u) const &
Definition: sol.hpp:6576
sol::meta::meta_detail::unqualified_non_alias
Definition: sol.hpp:1380
sol::function_detail::lua_c_wrapper
int lua_c_wrapper(lua_State *L)
Definition: sol.hpp:19810
sol::function_detail::member_variable::var
function_type var
Definition: sol.hpp:19568
B
#define B(name, bit)
sol::detail::enable_assign_forward
detail::enable_if_t<!std::is_same< optional< T >, detail::decay_t< U > >::value &&!detail::conjunction< std::is_scalar< T >, std::is_same< T, detail::decay_t< U > >>::value &&std::is_constructible< T, U >::value &&std::is_assignable< T &, U >::value > enable_assign_forward
Definition: sol.hpp:4849
sol::detail::invoke_result_t
typename invoke_result< F, Us... >::type invoke_result_t
Definition: sol.hpp:4795
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::add
static int add(lua_State *L_)
Definition: sol.hpp:22736
sol::stateless_reference::copy
stateless_reference copy(lua_State *L_) const noexcept
Definition: sol.hpp:10347
sol::basic_variadic_results::basic_variadic_results
basic_variadic_results(protected_function_result fr)
Definition: sol.hpp:28838
sol::stack::stack_detail::check_function_pointer
bool check_function_pointer(lua_State *L, int index, Handler &&handler, record &tracking) noexcept
Definition: sol.hpp:20478
sol::stack::unqualified_pusher< wchar_t[N]>::push
static int push(lua_State *L, const wchar_t(&str)[N])
Definition: sol.hpp:15840
ip
#define ip
sol::stack_proxy_base::stack_index
int stack_index() const
Definition: sol.hpp:17163
sol::stack::unqualified_getter< stack_proxy >::get
static stack_proxy get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:17208
sol::lua_bind_traits::base_t
meta::bind_traits< Signature > base_t
Definition: sol.hpp:8513
sol::basic_metatable::basic_metatable
basic_metatable(detail::no_safety_tag, T &&r) noexcept
Definition: sol.hpp:26148
sol::container_detail::container_decay< as_container_t< T > >::type
T type
Definition: sol.hpp:21641
sol::detail::unique_destructor
void(*)(void *) unique_destructor
Definition: sol.hpp:10952
sol::function_detail::member_variable::member
T member
Definition: sol.hpp:19569
sol::variadic_args::L
lua_State * L
Definition: sol.hpp:28636
lua_tocfunction
LUA_API lua_CFunction lua_tocfunction(lua_State *L, int idx)
Definition: lapi.c:432
sol::stack::unqualified_pusher< std::tuple< Args... > >::push
static int push(std::index_sequence< I... >, lua_State *L, T &&t)
Definition: sol.hpp:15901
sol::call_detail::lua_call_wrapper< T, protect_t< V >, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, F &fx, Args &&... args)
Definition: sol.hpp:18883
sol::stack::unqualified_interop_getter
Definition: sol.hpp:11446
sol::lua_size::SOL_INTERNAL_UNSPECIALIZED_MARKER_
int SOL_INTERNAL_UNSPECIALIZED_MARKER_
Definition: sol.hpp:8395
sol::protected_function_result::L
lua_State * L
Definition: sol.hpp:17230
sol::state_view::set_exception_handler
void set_exception_handler(exception_handler_function handler)
Definition: sol.hpp:27946
sol::stack::push_popper::~push_popper
~push_popper()
Definition: sol.hpp:10016
sol::function_detail::member_variable::args_lists
meta::bind_traits< function_type >::args_list args_lists
Definition: sol.hpp:19567
sol::detail::indexed_insert::operator()
void operator()(meta_function meta_function_name_, lua_CFunction c_function_)
Definition: sol.hpp:11421
sol::tie_t::base_t
std::tuple< std::add_lvalue_reference_t< Tn >... > base_t
Definition: sol.hpp:10824
sol::detail::adl_default_to_string
int adl_default_to_string(std::false_type, lua_State *L)
Definition: sol.hpp:12241
sol::member_function_wrapper::object_type
O object_type
Definition: sol.hpp:17761
sol::detail::fixup_void
conditional_t< std::is_void< U >::value, monostate, U > fixup_void
Definition: sol.hpp:4816
sol::meta::detail::tuple_types_::type
types< Args... > type
Definition: sol.hpp:1473
sol::detail::is_constructor
Definition: sol.hpp:8614
sol::pairs_iterator::operator==
friend bool operator==(const pairs_iterator &left, const pairs_iterator &right) noexcept
Definition: sol.hpp:25348
mqtt_test.data
dictionary data
Definition: mqtt_test.py:22
sol::detail::optional_move_assign_base< T, false >::operator=
optional_move_assign_base & operator=(optional_move_assign_base &&rhs) noexcept(std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value)
Definition: sol.hpp:5126
sol::unicode::error_code
error_code
Definition: sol.hpp:13048
sol::policy_wrapper::indices
std::index_sequence_for< Policies... > indices
Definition: sol.hpp:7094
SOL_TL_OPTIONAL_11_CONSTEXPR
#define SOL_TL_OPTIONAL_11_CONSTEXPR
\exclude
Definition: sol.hpp:4699
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::insert
static int insert(lua_State *L_)
Definition: sol.hpp:22568
sol::stack::unqualified_getter< detail::as_value_tag< T > >::get_no_lua_nil_from
static T * get_no_lua_nil_from(lua_State *L, void *udata, int index, record &)
Definition: sol.hpp:14207
sol::meta::meta_detail::on_odd
meta::boolean<(TI::value % 2)==1 > on_odd
Definition: sol.hpp:2298
sol::detail::inheritance::type_unique_cast_bases
static int type_unique_cast_bases(types< Base, Args... >, void *source_data, void *target_data, const string_view &ti)
Definition: sol.hpp:9412
sol::detail::ref_clean::L
lua_State * L
Definition: sol.hpp:25445
sol::state_view::safe_script
protected_function_result safe_script(const string_view &code, const basic_environment< E > &env, Fx &&on_error, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27591
lua_isnone
#define lua_isnone(L, n)
Definition: lua.h:379
sol::function_detail::upvalue_this_member_function::traits_type
lua_bind_traits< function_type > traits_type
Definition: sol.hpp:19350
sol::closure<>
Definition: sol.hpp:7542
sol::this_environment
Definition: sol.hpp:26732
sol::detail::protected_handler::stack_index
int stack_index
Definition: sol.hpp:20742
sol::stack::get_field
void get_field(lua_State *L, Key &&key)
Definition: sol.hpp:12085
sol::stack::stack_detail::not_enough_stack_space_floating
constexpr const char * not_enough_stack_space_floating
Definition: sol.hpp:11547
sol::stack_aligned_safe_function
basic_protected_function< stack_reference, true, reference > stack_aligned_safe_function
Definition: forward.hpp:1167
sol::new_table::new_table
new_table(int sequence_hint_, int map_hint_=0) noexcept
Definition: sol.hpp:7803
sol::optional::and_then
constexpr detail::invoke_result_t< F, const T && > and_then(F &&f) const &&
Definition: sol.hpp:5346
sol::new_table::sequence_hint
int sequence_hint
Definition: sol.hpp:7794
sol::default_at_panic
int default_at_panic(lua_State *L)
Definition: sol.hpp:27089
sol::u_detail::usertype_storage_base::set
void set(lua_State *L, Key &&key, Value &&value)
Definition: sol.hpp:24056
lua_newuserdatauv
LUA_API void * lua_newuserdatauv(lua_State *L, size_t size, int nuvalue)
Definition: lapi.c:1335
sol::detail::inheritance::type_check
static bool type_check(const string_view &ti)
Definition: sol.hpp:9375
sol::meta::meta_detail::unique_element_type
Definition: sol.hpp:9195
sol::detail::optional_operations_base
Definition: sol.hpp:4973
sol::call_constructor
const auto call_constructor
Definition: sol.hpp:7003
sol::meta::meta_detail::basic_traits::signature_type
std::remove_pointer_t< free_function_pointer_type > signature_type
Definition: sol.hpp:1567
sol::variadic_args::stack_index
int stack_index() const
Definition: sol.hpp:28749
sol::stack_reference::stack_reference
stack_reference(lua_State *L, raw_index i) noexcept
Definition: sol.hpp:9763
sol::meta::is_member_object_v
constexpr bool is_member_object_v
Definition: sol.hpp:18030
sol::u_detail::exact_function_index
constexpr const int exact_function_index
Definition: sol.hpp:23250
lua_getupvalue
const LUA_API char * lua_getupvalue(lua_State *L, int funcindex, int n)
Definition: lapi.c:1376
sol::stack::unqualified_pusher< overload_set< Functions... > >::push
static int push(lua_State *L, const overload_set< Functions... > &set)
Definition: sol.hpp:20187
sol::function_detail::member_function::invocation
function_type invocation
Definition: sol.hpp:19522
sol::basic_environment::basic_environment
basic_environment(stack_reference &&r)
Definition: sol.hpp:26587
sol::basic_protected_function::basic_protected_function
basic_protected_function(const proxy_base< Super > &p)
Definition: sol.hpp:20892
sol::type::thread
@ thread
sol::meta::meta_detail::unique_element_type< T, std::enable_if_t< meta::is_detected_v< type_test_t, T > > >::type
typename T::type type
Definition: sol.hpp:9206
sol::function_detail::upvalue_this_member_variable::operator()
int operator()(lua_State *L) noexcept(std::is_nothrow_copy_assignable_v< T >)
Definition: sol.hpp:19435
sol::stack::unqualified_pusher< std::nullptr_t >::push
static int push(lua_State *L, std::nullptr_t) noexcept
Definition: sol.hpp:15960
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::index_get
static int index_get(lua_State *L_)
Definition: sol.hpp:22758
sol::stack::stateless_push_popper< true, T, C >::stateless_push_popper
stateless_push_popper(lua_State *, T) noexcept
Definition: sol.hpp:10074
sol::optional::has_value
constexpr bool has_value() const noexcept
Definition: sol.hpp:5927
sol::type_assert
void type_assert(lua_State *L, int index, type expected, type actual) noexcept(false)
Definition: sol.hpp:9628
sol::basic_coroutine::basic_coroutine
basic_coroutine(const proxy_base< Super > &p)
Definition: sol.hpp:28379
sol::basic_function::invoke
Ret invoke(types< Ret >, std::index_sequence< I >, std::ptrdiff_t n) const
Definition: sol.hpp:20607
sol::basic_thread
Definition: forward.hpp:1207
sol::basic_usertype::set_resolved_function
void set_resolved_function(Key &&key, Args &&... args)
Definition: sol.hpp:26342
sol::container_detail::u_c_launch::real_get_call
static int real_get_call(lua_State *L)
Definition: sol.hpp:22902
sol::function_detail::upvalue_this_member_function
Definition: sol.hpp:19348
sol::meta::meta_detail::adl_sol_lua_get_test_t
decltype(sol_lua_get(types< T >(), static_cast< lua_State * >(nullptr), -1, std::declval< stack::record & >())) adl_sol_lua_get_test_t
Definition: sol.hpp:11499
lua_tointegerx
LUA_API lua_Integer lua_tointegerx(lua_State *L, int idx, int *pisnum)
Definition: lapi.c:383
sol::stack::push_popper::m_index
int m_index
Definition: sol.hpp:10007
sol::basic_environment::basic_environment
basic_environment(lua_State *L, T &&r) noexcept
Definition: sol.hpp:26646
sol::detail::optional_copy_base
Definition: sol.hpp:5027
sol::basic_table_core::traverse_get
decltype(auto) traverse_get(Keys &&... keys) const
Definition: sol.hpp:25840
sol::as_table_t::as_table_t
as_table_t(const meta::unqualified_t< T > &obj) noexcept(std::is_nothrow_constructible_v< base_t, const meta::unqualified_t< T > & >)
Definition: sol.hpp:7585
presentation_type::debug
@ debug
sol::u_detail::binding_data_equals::operator()
bool operator()(const std::unique_ptr< binding_base > &ptr) const
Definition: sol.hpp:23670
sol::stack_function
stack_unsafe_function stack_function
Definition: forward.hpp:1180
sol::resolve
constexpr auto resolve(R fun_ptr(Args...)) -> R(*)(Args...)
Definition: sol.hpp:19701
sol::detail::default_construct
Definition: sol.hpp:6922
sol::detail::force_cast
basic_function< Base > force_cast(T &p)
Definition: sol.hpp:20774
sol::unique_usertype_actual_t
typename meta::meta_detail::unique_actual_type< unique_usertype_traits< T > >::type unique_usertype_actual_t
Definition: sol.hpp:9182
sol::function_detail::upvalue_free_function::call
static int call(lua_State *L)
Definition: sol.hpp:19146
sol::stack_iterator::operator==
bool operator==(const stack_iterator &r) const
Definition: sol.hpp:17076
LUA_GCCOUNTB
#define LUA_GCCOUNTB
Definition: lua.h:323
sol::state_view::create_table
table create_table(int narr, int nrec, Key &&key, Value &&value, Args &&... args)
Definition: sol.hpp:28048
sol::usertype_traits::metatable
static const std::string & metatable()
Definition: sol.hpp:9094
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::is_writable
meta::neg< meta::any< std::is_const< V >, std::is_const< std::remove_reference_t< iterator_return > >, meta::neg< is_copyable > > > is_writable
Definition: sol.hpp:21781
lua_stringtonumber
LUA_API size_t lua_stringtonumber(lua_State *L, const char *s)
Definition: lapi.c:365
sol::state_view::script_file
protected_function_result script_file(const std::string &filename, Fx &&on_error, load_mode mode=load_mode::any)
Definition: sol.hpp:27729
sol::usertype_proxy::tuple_set
void tuple_set(std::index_sequence< I... >, T &&value) &&
Definition: sol.hpp:24582
luaL_getsubtable
LUALIB_API int luaL_getsubtable(lua_State *L, int idx, const char *fname)
Definition: lauxlib.c:947
sol::unicode::unicode_detail::sequence_length
static constexpr int sequence_length(unsigned char b)
Definition: sol.hpp:13131
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::find_has
static detail::error_result find_has(std::true_type, lua_State *L_, T &self)
Definition: sol.hpp:22100
sol::type::none
@ none
sol::optional< T & >::disjunction
SOL_TL_OPTIONAL_11_CONSTEXPR optional disjunction(const optional &rhs) &&
\group disjunction
Definition: sol.hpp:6609
LUA_ERRRUN
#define LUA_ERRRUN
Definition: lua.h:51
sol::operator>
constexpr bool operator>(const optional< T > &lhs, const optional< U > &rhs)
\group relop
Definition: sol.hpp:6030
sol::property_wrapper
Definition: sol.hpp:17928
sol::yielding_t::yielding_t
yielding_t(Arg &&arg)
Definition: sol.hpp:7354
sol::detail::enable_assign_from_other
detail::enable_if_t< std::is_constructible< T, Other >::value &&std::is_assignable< T &, Other >::value &&!std::is_constructible< T, optional< U > & >::value &&!std::is_constructible< T, optional< U > && >::value &&!std::is_constructible< T, const optional< U > & >::value &&!std::is_constructible< T, const optional< U > && >::value &&!std::is_convertible< optional< U > &, T >::value &&!std::is_convertible< optional< U > &&, T >::value &&!std::is_convertible< const optional< U > &, T >::value &&!std::is_convertible< const optional< U > &&, T >::value &&!std::is_assignable< T &, optional< U > & >::value &&!std::is_assignable< T &, optional< U > && >::value &&!std::is_assignable< T &, const optional< U > & >::value &&!std::is_assignable< T &, const optional< U > && >::value > enable_assign_from_other
Definition: sol.hpp:4858
lua_tolstring
const LUA_API char * lua_tolstring(lua_State *L, int idx, size_t *len)
Definition: lapi.c:399
sol::basic_table_core::create_with
static table create_with(lua_State *L, Args &&... args)
Definition: sol.hpp:26086
sol::stack_reference_hash::is_transparent
std::true_type is_transparent
Definition: sol.hpp:9923
sol::detail::override_value
@ override_value
Definition: sol.hpp:7745
sol::stack::unqualified_pusher< function_arguments< T, Args... > >::push
static int push(lua_State *L, function_arguments< T, Args... > &&fp)
Definition: sol.hpp:20111
lua_CFunction
int(* lua_CFunction)(lua_State *L)
Definition: lua.h:106
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::next_iter
static int next_iter(lua_State *L_)
Definition: sol.hpp:22712
sol::container_detail::u_c_launch::add_call
static int add_call(lua_State *L)
Definition: sol.hpp:23059
sol::detail::inheritance::type_unique_cast
static int type_unique_cast(void *source_data, void *target_data, const string_view &ti, const string_view &rebind_ti)
Definition: sol.hpp:9429
sol::detail::direct_error_tag
Definition: sol.hpp:4546
detail::arg_id_kind::name
@ name
sol::property_wrapper::read
R & read()
Definition: sol.hpp:17946
sol::meta::meta_detail::type_test_t
typename T::type type_test_t
Definition: sol.hpp:9189
sol::basic_table_core::size
size_t size() const
Definition: sol.hpp:25998
sol::var_wrapper
Definition: sol.hpp:18011
sol::call_detail::agnostic_lua_call_wrapper< detail::no_prop, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, const detail::no_prop &)
Definition: sol.hpp:18478
sol::detail::optional_operations_base::assign
void assign(Opt &&rhs)
Definition: sol.hpp:4988
sol::optional< T & >::or_else
optional< T > SOL_TL_OPTIONAL_11_CONSTEXPR or_else(F &&f) &&
\exclude
Definition: sol.hpp:6479
sol::stack::unqualified_pusher< property_wrapper< F, G > >::push
static int push(lua_State *L, property_wrapper< F, G > &&pw)
Definition: sol.hpp:20215
sol::detail::static_trampoline_noexcept
int static_trampoline_noexcept(lua_State *L) noexcept
Definition: sol.hpp:8831
sol::detail::conditional_t
typename std::conditional< B, T, F >::type conditional_t
Definition: sol.hpp:4726
sol::optional< T & >::value_or
constexpr T & value_or(U &&u) const
Definition: sol.hpp:6835
sol::detail::short_demangle_once
std::string short_demangle_once()
Definition: sol.hpp:9062
lua_pushnil
LUA_API void lua_pushnil(lua_State *L)
Definition: lapi.c:491
sol::types
Definition: forward.hpp:1260
sol::container_detail::usertype_container_default::pairs
static int pairs(lua_State *L_)
Definition: sol.hpp:21733
luaL_Stream::closef
lua_CFunction closef
Definition: lauxlib.h:239
sol::u_detail::binding::call
static int call(lua_State *L_)
Definition: sol.hpp:23489
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::next
static int next(lua_State *L_)
Definition: sol.hpp:22647
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::next_iter
static int next_iter(lua_State *L_)
Definition: sol.hpp:22486
sol::stack::unqualified_getter< meta_function >::get
static meta_function get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14094
sol::type_panic
const type_panic_t type_panic
Definition: sol.hpp:9582
sol::detail::clean
Definition: sol.hpp:25435
sol::function_detail::upvalue_this_member_variable::function_type
std::remove_pointer_t< std::decay_t< Function > > function_type
Definition: sol.hpp:19401
sol::detail::properties_enrollment_allowed::properties_enrollment_allowed
properties_enrollment_allowed(int &times_through_, std::bitset< 64 > &properties_, automagic_enrollments &enrollments_)
Definition: sol.hpp:11386
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::add_associative
static detail::error_result add_associative(std::true_type, lua_State *L_, T &self, stack_object key, Iter &pos)
Definition: sol.hpp:22210
sol::unicode::unicode_detail::is_trail_surrogate
static constexpr bool is_trail_surrogate(char32_t u)
Definition: sol.hpp:13099
sol::meta::unqualified
std::remove_cv< std::remove_reference_t< T > > unqualified
Definition: sol.hpp:1373
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::get_associative_find
static detail::error_result get_associative_find(std::false_type, lua_State *L_, T &self, K &key)
Definition: sol.hpp:22415
sol::u_detail::update_bases_func
Definition: sol.hpp:23645
sol::stack::unqualified_pusher< detail::as_value_tag< T > >::push
static int push(lua_State *L, Arg &&arg, Args &&... args)
Definition: sol.hpp:14831
sol::stack::unqualified_checker< std::variant< Tn... >, type::poly >::V_size
std::variant_size< V > V_size
Definition: sol.hpp:12906
sol::stack::unqualified_checker< std::variant< Tn... >, type::poly >::check
static bool check(lua_State *L_, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:12933
LUA_GCSETPAUSE
#define LUA_GCSETPAUSE
Definition: lua.h:325
sol::lua_value::value
reference & value() &
Definition: sol.hpp:27019
sol::call_detail::lua_call_wrapper< T, property_wrapper< R, W >, is_index, is_variable, checked, boost, clean_stack, C >::U
meta::unqualified_t< P > U
Definition: sol.hpp:18802
sol::stateless_reference::pop
void pop(lua_State *L_, int n=1) const noexcept
Definition: sol.hpp:10297
conditional_t
typename std::conditional< B, T, F >::type conditional_t
Definition: core.h:273
sol::stack::stack_detail::push_function::operator()
int operator()(T &&value) const
Definition: sol.hpp:16016
monostate
Definition: core.h:293
sol::load_status::ok
@ ok
sol::reference_hash
Definition: sol.hpp:10791
sol::automagic_flags::default_constructor
@ default_constructor
sol::protected_function_result::protected_function_result
protected_function_result() noexcept
Definition: sol.hpp:17247
sol::make_user
auto make_user(T &&u)
Definition: sol.hpp:7511
sol::stack::unqualified_getter< const char * >
Definition: sol.hpp:13992
sol::meta::is_not_move_only
neg< is_move_only< T > > is_not_move_only
Definition: sol.hpp:2818
sol::function_detail::c_call_raw
int c_call_raw(std::false_type, lua_State *L)
Definition: sol.hpp:19078
sol::stack_guard::top
int top
Definition: sol.hpp:10898
sol::container_detail::u_c_launch::real_clear_traits
static int real_clear_traits(std::true_type, lua_State *L)
Definition: sol.hpp:23002
sol::stack::unqualified_pusher< detail::as_pointer_tag< T > >::push
static int push(lua_State *L, Arg &&arg, Args &&... args)
Definition: sol.hpp:14870
sol::basic_table_iterator::const_reference
const typedef value_type & const_reference
Definition: sol.hpp:25047
sol::meta::meta_detail::unique_element_type< T, std::enable_if_t< meta::is_detected_v< type_element_type_t, T > > >::type
typename T::element_type type
Definition: sol.hpp:9201
sol::meta::is_string_like_or_constructible
meta::boolean< is_string_like_v< T >||is_string_constructible_v< T > > is_string_like_or_constructible
Definition: sol.hpp:2782
sol::lua_value::lua_value
lua_value(std::initializer_list< std::pair< lua_value, lua_value >> il)
Definition: sol.hpp:26987
SOL_IS_DEFAULT_OFF
#define SOL_IS_DEFAULT_OFF(OP_SYMBOL)
Definition: sol.hpp:59
sol::detail::usertype_allocate_pointer
T ** usertype_allocate_pointer(lua_State *L)
Definition: sol.hpp:11110
sol::state_view::end
iterator end() const
Definition: sol.hpp:27808
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::iterator
typename T::iterator iterator
Definition: sol.hpp:21765
sol::stack::stack_detail::msvc_is_ass_with_if_constexpr_push_enum
int msvc_is_ass_with_if_constexpr_push_enum(std::false_type, lua_State *, const T &)
Definition: sol.hpp:14752
sol::make_object
object make_object(lua_State *L_, T &&value)
Definition: sol.hpp:16916
sol::variadic_args::rbegin
const_reverse_iterator rbegin() const
Definition: sol.hpp:28704
sol::lib::count
@ count
sol::basic_protected_function::basic_protected_function
basic_protected_function(T &&r) noexcept
Definition: sol.hpp:20850
sol::stack_iterator::operator*
reference operator*()
Definition: sol.hpp:17012
sol::stack::unqualified_pusher< user< T > >::push
static int push(lua_State *L, const user< T > &u)
Definition: sol.hpp:15359
sol::stack::probe::probe
probe(bool s, int l)
Definition: sol.hpp:11468
sol::stack_reference::push
int push(lua_State *L_) const noexcept
Definition: sol.hpp:9792
sol::state_view::new_enum
state_view & new_enum(const string_view &name, std::initializer_list< std::pair< string_view, T >> items)
Definition: sol.hpp:27994
sol::usertype_proxy::push
int push() const noexcept
Definition: sol.hpp:24685
sol::optional< T & >::value_type
T & value_type
Definition: sol.hpp:6673
sol::basic_reference::valid
bool valid() const noexcept
Definition: sol.hpp:10626
sol::detail::is_constructor_v
constexpr bool is_constructor_v
Definition: sol.hpp:8626
presentation_type::pointer
@ pointer
sol::stack::unqualified_pusher< constructor_list< L0, Lists... > >::push
static int push(lua_State *L, cl_t cl)
Definition: sol.hpp:20318
sol::meta::unwrapped_t
typename unwrapped< T >::type unwrapped_t
Definition: sol.hpp:2167
sol::optional::and_then
SOL_TL_OPTIONAL_11_CONSTEXPR detail::invoke_result_t< F, T & > and_then(F &&f) &
Definition: sol.hpp:5315
sol::basic_reference::copy_assign_complex
void copy_assign_complex(const basic_reference< r_main_only > &r)
Definition: sol.hpp:10388
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::set_writable
static detail::error_result set_writable(std::true_type, lua_State *, T &, iterator &it, stack_object value)
Definition: sol.hpp:21927
sol::unsafe_function_result::abandon
void abandon() noexcept
Definition: sol.hpp:17557
sol::meta::any_v
constexpr bool any_v
Definition: sol.hpp:2234
lua_toboolean
LUA_API int lua_toboolean(lua_State *L, int idx)
Definition: lapi.c:393
sol::state
Definition: sol.hpp:28238
sol::meta::meta_detail::unique_actual_type< Templ< T, Rest... > >::type
T type
Definition: sol.hpp:9176
sol::lib::package
@ package
sol::basic_object_base::is
bool is() const
Definition: sol.hpp:16810
sol::protected_function_result::rend
reverse_iterator rend()
Definition: sol.hpp:17372
sol::meta::conditional< false >::type
U type
Definition: sol.hpp:1407
luaL_Stream::f
FILE * f
Definition: lauxlib.h:238
sol::state::state
state(lua_CFunction panic, lua_Alloc alfunc, void *alpointer=nullptr)
Definition: sol.hpp:28247
sol::optional< T & >::map_or_else
detail::invoke_result_t< U > map_or_else(F &&f, U &&u) &&
Definition: sol.hpp:6568
sol::detail::voider::type
void type
Definition: sol.hpp:4801
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::erase_key_has
static detail::error_result erase_key_has(std::false_type, lua_State *L_, T &self, K &key)
Definition: sol.hpp:22370
sol::stack_reference::push
int push() const noexcept
Definition: sol.hpp:9788
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::add_push_back
static detail::error_result add_push_back(std::true_type, lua_State *, T &self, stack_object value)
Definition: sol.hpp:22193
sol::state_view::set_panic
void set_panic(lua_CFunction panic)
Definition: sol.hpp:27942
remove_reference_t
typename std::remove_reference< T >::type remove_reference_t
Definition: core.h:276
sol::stack::unqualified_getter< std::function< Signature > >::return_types
meta::tuple_types< typename fx_t::return_type > return_types
Definition: sol.hpp:21241
sol::detail::resolve_i
constexpr auto resolve_i(types< Args... >, F &&f) -> decltype(resolve_i(types< R(Args...)>(), std::forward< F >(f)))
Definition: sol.hpp:19685
sol::detail::unique_is_null_noexcept
constexpr bool unique_is_null_noexcept() noexcept
Definition: sol.hpp:9256
sol::meta::is_tuple_v
constexpr bool is_tuple_v
Definition: sol.hpp:1468
sol::is_to_stringable
Definition: sol.hpp:8132
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::add_insert
static detail::error_result add_insert(std::false_type, lua_State *L_, T &self, stack_object value, Iter &pos)
Definition: sol.hpp:22179
sol::protect
auto protect(T &&value)
Definition: sol.hpp:18064
sol::unsafe_function_result::lua_state
lua_State * lua_state() const
Definition: sol.hpp:17548
sol::state_view::create_table
table create_table(int narr=0, int nrec=0)
Definition: sol.hpp:28043
sol::stack::unqualified_check_getter< lua_thread_state >::get
optional< lua_thread_state > get(lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:28116
sol::stack::unqualified_check_getter< std::variant< Tn... >, C >::get_one
static optional< V > get_one(std::integral_constant< std::size_t, 0 >, lua_State *L, int index, Handler &&handler, record &tracking)
Definition: sol.hpp:14512
sol::stack::qualified_getter::get
static decltype(auto) get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:13499
sol::as_function_reference
auto as_function_reference(Args &&... args)
Definition: sol.hpp:7570
luaL_newstate
LUALIB_API lua_State * luaL_newstate(void)
Definition: lauxlib.c:1087
sol::pairs_iterator::m_table_ref
sol::reference m_table_ref
Definition: sol.hpp:25385
sol::meta::count_for_to_pack_v
constexpr std::size_t count_for_to_pack_v
Definition: sol.hpp:2329
nlohmann::detail::index_sequence_for
make_index_sequence< sizeof...(Ts)> index_sequence_for
Definition: json.hpp:3159
sol::state::state
state(lua_CFunction panic=default_at_panic)
Definition: sol.hpp:28243
sol::function_detail::member_variable::operator()
int operator()(lua_State *L) noexcept(std::is_nothrow_copy_assignable_v< T >)
Definition: sol.hpp:19602
sol::wrapper< F, std::enable_if_t< std::is_function< std::remove_pointer_t< meta::unqualified_t< F > > >::value > >::args_list
traits_type::args_list args_list
Definition: sol.hpp:17672
sol::meta::has_key_value_pair
Definition: sol.hpp:2676
sol::pairs_iterator::iterator_category
std::input_iterator_tag iterator_category
Definition: sol.hpp:25203
sol::meta_function::length
@ length
sol::stack::push_popper::index_of
int index_of(const Tu &) const noexcept
Definition: sol.hpp:10012
sol::basic_object::basic_object
basic_object(lua_State *L_, lua_nil_t r) noexcept
Definition: sol.hpp:16875
sol::basic_variadic_results::basic_variadic_results
basic_variadic_results(Arg0 &&arg0, Args &&... args)
Definition: sol.hpp:28846
sol::stack::unqualified_pusher< as_container_t< T > >::push
static int push(lua_State *L, const as_container_t< T > &as_cont)
Definition: sol.hpp:23195
sol::state_view::stack_clear
int stack_clear()
Definition: sol.hpp:27842
sol::container_detail::get_key
decltype(auto) get_key(std::true_type, T &&t)
Definition: sol.hpp:21653
lua_Debug
Definition: lua.h:470
sol::detail::default_main_thread_name
const char(& default_main_thread_name())[9]
Definition: sol.hpp:9938
sol::load_result::load_result
load_result(lua_State *Ls, int stackindex=-1, int retnum=0, int popnum=0, load_status lerr=load_status::ok) noexcept
Definition: sol.hpp:26822
sol::detail::default_size
int default_size(lua_State *L)
Definition: sol.hpp:12263
sol::detail::deref_move_only
decltype(auto) deref_move_only(T &&item)
Definition: sol.hpp:2095
sol::stack::push_popper_at::count
int count
Definition: sol.hpp:9974
sol::stack::unqualified_getter< as_table_t< T > >::Tu
meta::unqualified_t< T > Tu
Definition: sol.hpp:13580
sol::basic_thread::basic_thread
basic_thread(lua_State *L, lua_State *actualthread)
Definition: sol.hpp:28173
sol::pairs_iterator::index
std::ptrdiff_t index() const
Definition: sol.hpp:25336
sol::type::lightuserdata
@ lightuserdata
sol::optional::value
SOL_TL_OPTIONAL_11_CONSTEXPR T && value() &&
\exclude
Definition: sol.hpp:5961
sol::optional::conjunction
constexpr optional< typename std::decay< U >::type > conjunction(U &&u) const
Definition: sol.hpp:5579
sol::basic_coroutine::basic_coroutine
basic_coroutine(lua_State *L, absolute_index index, handler_t eh)
Definition: sol.hpp:28420
sol::push_invoke
auto push_invoke(Fx &&fx)
Definition: sol.hpp:7711
sol::u_detail::usertype_storage_base::for_each_table
void for_each_table(lua_State *L_, Fx &&fx)
Definition: sol.hpp:23728
sol::is_lua_reference
Definition: sol.hpp:8093
sol::stack::unqualified_pusher< detail::lua_CFunction_noexcept >::push
static int push(lua_State *L, detail::lua_CFunction_noexcept func, int n=0)
Definition: sol.hpp:15236
SOL_OPTIMIZATION_STRING_CONVERSION_STACK_SIZE_I_
#define SOL_OPTIMIZATION_STRING_CONVERSION_STACK_SIZE_I_
Definition: sol.hpp:602
sol::basic_environment::set_on
bool set_on(const T &target) const
Definition: sol.hpp:26657
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::insert_after_has
static detail::error_result insert_after_has(std::false_type, lua_State *, T &, stack_object, stack_object)
Definition: sol.hpp:22291
sol::stack::unqualified_pusher< std::remove_pointer_t< lua_CFunction > >::push
static int push(lua_State *L, lua_CFunction func, int n=0) noexcept
Definition: sol.hpp:15202
sol::unicode::unicode_detail::is_overlong
static constexpr bool is_overlong(char32_t u, std::size_t bytes)
Definition: sol.hpp:13126
sol::stack::unqualified_pusher< void * >::push
static int push(lua_State *L, void *userdata) noexcept
Definition: sol.hpp:15274
sol::lightuserdata_value::value
void * value
Definition: sol.hpp:7422
sol::container_detail::has_traits_size_test
Definition: sol.hpp:21551
sol::load_status::memory
@ memory
sol::table_proxy::tuple_set
void tuple_set(std::index_sequence< I... >, T &&value) &
Definition: sol.hpp:24736
sol::detail::protected_handler
Definition: sol.hpp:20739
sol::metatable
basic_metatable< reference > metatable
Definition: forward.hpp:1147
sol::detail::oss_default_to_string
int oss_default_to_string(std::false_type, lua_State *L)
Definition: sol.hpp:12253
sol::detail::as_value_tag
Definition: sol.hpp:10938
sol::container_detail::u_c_launch::real_ipairs_call
static int real_ipairs_call(lua_State *L)
Definition: sol.hpp:22950
sol::meta::pop_front_type_t
typename pop_front_type< Arg >::type pop_front_type_t
Definition: sol.hpp:1489
sol::stack::unqualified_getter< as_table_t< T > >::get
static T get(std::false_type, lua_State *L, int relindex, record &tracking)
Definition: sol.hpp:13615
sol::basic_environment::basic_environment
basic_environment(T &&r) noexcept
Definition: sol.hpp:26633
sol::stack::unqualified_getter< as_table_t< T > >::get
static T get(std::true_type, lua_State *L, int index, record &tracking)
Definition: sol.hpp:13749
sol::state_view::load_buffer
load_result load_buffer(const std::byte *buff, size_t size, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27787
sol::stack_iterator::operator<
bool operator<(const stack_iterator &r) const
Definition: sol.hpp:17090
sol::basic_thread::basic_thread
basic_thread(lua_State *L, T &&r)
Definition: sol.hpp:28153
stacksize
#define stacksize(th)
Definition: lstate.h:142
sol::basic_table_core::basic_table_core
basic_table_core(lua_State *L, ref_index index)
Definition: sol.hpp:25749
sol::stack::field_setter< std::tuple< Args... >, b, raw, C >::apply
void apply(std::index_sequence< I >, lua_State *L, Keys &&keys, Value &&value, int tableindex)
Definition: sol.hpp:16279
sol::basic_coroutine::basic_coroutine
basic_coroutine(lua_State *L, raw_index index, handler_t eh)
Definition: sol.hpp:28429
sol::stack::unqualified_pusher< detail::tagged< T, destructor_wrapper< Fx > > >::push
static int push(lua_State *L, const destructor_wrapper< Fx > &c)
Definition: sol.hpp:20384
sol::stack_reference_hash::result_type
std::size_t result_type
Definition: sol.hpp:9922
sol::stack_iterator::operator[]
reference operator[](difference_type idx) const
Definition: sol.hpp:17072
sol::function_detail::functor_function::invocation
function_type invocation
Definition: sol.hpp:19489
sol::basic_table_core::new_enum
table new_enum(const string_view &name, std::initializer_list< std::pair< string_view, T >> items)
Definition: sol.hpp:25954
sol::meta::remove_member_pointer< R T::*const >::type
R type
Definition: sol.hpp:2185
sol::stack::unqualified_pusher< as_args_t< T > >::push
int push(lua_State *L, const as_args_t< T > &e)
Definition: sol.hpp:28615
sol::basic_table_core::set_fx
void set_fx(types<>, Key &&key, Fx &&fx, Args &&... args)
Definition: sol.hpp:26059
sol::stack::unqualified_pusher< const char * >::push_sized
static int push_sized(lua_State *L, const char *str, std::size_t len)
Definition: sol.hpp:15394
sol::function_detail::member_function::return_type
meta::function_return_t< function_type > return_type
Definition: sol.hpp:19519
sol::bad_optional_access
An exception for when an optional is accessed through specific methods while it is not engaged.
Definition: sol.hpp:5227
sol::container_detail::u_c_launch::real_size_traits
static int real_size_traits(std::false_type, lua_State *L)
Definition: sol.hpp:22970
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::erase_has
static detail::error_result erase_has(std::false_type, lua_State *L_, T &self, K &key)
Definition: sol.hpp:22378
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::at_start
static detail::error_result at_start(lua_State *L_, T &self, std::ptrdiff_t pos)
Definition: sol.hpp:21846
sol::variadic_args::difference_type
std::ptrdiff_t difference_type
Definition: sol.hpp:28644
sol::detail::optional_storage_base< T, true >::optional_storage_base
SOL_TL_OPTIONAL_11_CONSTEXPR optional_storage_base() noexcept
Definition: sol.hpp:4952
sol::optional< T & >::or_else
optional< T > or_else(F &&f) const &&
\exclude
Definition: sol.hpp:6503
sol::detail::ebco::value
T && value() &&noexcept
Definition: sol.hpp:7168
sol::stack::push_popper_n
Definition: sol.hpp:9983
sol::function_detail::overloaded_function::overloaded_function
overloaded_function(overload_list set)
Definition: sol.hpp:19624
lua_upvalueindex
#define lua_upvalueindex(i)
Definition: lua.h:45
sol::pairs_iterator::operator*
const_reference operator*() const noexcept
Definition: sol.hpp:25340
sol::detail::swap_adl_tests::is_std_swap_noexcept
Definition: sol.hpp:4892
lua_load
LUA_API int lua_load(lua_State *L, lua_Reader reader, void *data, const char *chunkname, const char *mode)
Definition: lapi.c:1080
sol::gc_mode::default_value
@ default_value
sol::is_stack_based_v
constexpr bool is_stack_based_v
Definition: sol.hpp:8466
sol::usertype_proxy::operator=
usertype_proxy && operator=(std::initializer_list< T > other) &&
Definition: sol.hpp:24629
sol::meta::pop_front_type
Definition: sol.hpp:1486
sol::detail::properties_enrollment_allowed::times_through
int & times_through
Definition: sol.hpp:11382
sol::basic_pairs_range::begin
iterator begin() const noexcept
Definition: sol.hpp:25408
sol::stack::unqualified_interop_checker
Definition: sol.hpp:12392
next
#define next(ls)
Definition: llex.c:32
sol::in_place_t
std::in_place_t in_place_t
Definition: sol.hpp:4611
sol::unicode::unicode_detail::is_continuation
static constexpr bool is_continuation(unsigned char b)
Definition: sol.hpp:13122
sol_c_assert
#define sol_c_assert(...)
Definition: sol.hpp:2907
sol::protected_function_result::stack_index
int stack_index() const noexcept
Definition: sol.hpp:17391
sol::stack::unqualified_getter< this_environment >::get
static this_environment get(lua_State *L, int, record &tracking)
Definition: sol.hpp:26776
sol::detail::ebco< T, tag, std::enable_if_t<!std::is_reference_v< T > &&std::is_class_v< T > &&!std::is_final_v< T > > >::value
T const & value() const &noexcept
Definition: sol.hpp:7202
sol::u_detail::register_usertype
int register_usertype(lua_State *L_, automagic_enrollments enrollments_={})
Definition: sol.hpp:24338
luaL_addvalue
LUALIB_API void luaL_addvalue(luaL_Buffer *B)
Definition: lauxlib.c:618
sol::basic_pairs_range::source_t
std::add_lvalue_reference_t< Source > source_t
Definition: sol.hpp:25394
sol::protected_function_result::get
decltype(auto) get(int index_offset=0) const
Definition: sol.hpp:17298
sol::main_object
basic_object< main_reference > main_object
Definition: forward.hpp:1215
sol::stack::stack_detail::undefined_metatable::undefined_metatable
undefined_metatable(lua_State *l, const char *k, undefined_method_func umf)
Definition: sol.hpp:11667
sol::meta::meta_detail::basic_traits::has_c_var_arg
static constexpr bool has_c_var_arg
Definition: sol.hpp:1555
sol::stack::unqualified_pusher< protect_t< T > >::push
static int push(lua_State *L, protect_t< T > &&pw)
Definition: sol.hpp:20196
sol::is_indeterminate_call_failure
bool is_indeterminate_call_failure(call_status c)
Definition: sol.hpp:7936
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::erase_start
static detail::error_result erase_start(lua_State *L_, T &self, K &key)
Definition: sol.hpp:22439
sol::call_detail::lua_call_wrapper::call
static int call(lua_State *L, Fx &&fx, Args &&... args)
Definition: sol.hpp:18510
sol::userdata_value::userdata_value
userdata_value(void *data)
Definition: sol.hpp:7435
LUA_GCSETSTEPMUL
#define LUA_GCSETSTEPMUL
Definition: lua.h:326
sol::call_detail::agnostic_lua_call_wrapper
Definition: sol.hpp:18385
sol::basic_usertype::tuple_set
void tuple_set(std::index_sequence< I... >, std::tuple< Args... > &&args)
Definition: sol.hpp:26320
sol::variadic_args::stacktop
int stacktop
Definition: sol.hpp:28638
sol::basic_reference::basic_reference
basic_reference(lua_State *oL, const basic_reference<!main_only > &o) noexcept
Definition: sol.hpp:10445
sol::u_detail::environment_index
constexpr const int environment_index
Definition: sol.hpp:23247
sol::stack::unqualified_getter< as_table_t< T > >::get
static T get(types< V > t, lua_State *L, int relindex, record &tracking)
Definition: sol.hpp:13621
sol::stack::stack_detail::unchecked_unqualified_get
decltype(auto) unchecked_unqualified_get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:11586
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::iter::keep_alive
reference keep_alive
Definition: sol.hpp:22664
sol::container_detail::u_c_launch::real_set_call
static int real_set_call(lua_State *L)
Definition: sol.hpp:22914
sol::function_detail::upvalue_this_member_variable< T, readonly_wrapper< Function > >::real_call
static int real_call(lua_State *L) noexcept(std::is_nothrow_copy_assignable_v< T >)
Definition: sol.hpp:19445
sol::is_environment
std::integral_constant< bool, is_userdata_v< T >||is_table_v< T >||meta::is_specialization_of_v< T, basic_environment > > is_environment
Definition: sol.hpp:8573
sol::stack_reference_equals::is_transparent
std::true_type is_transparent
Definition: sol.hpp:9884
sol::function_arguments::arguments
std::tuple< Ps... > arguments
Definition: sol.hpp:7558
sol::u_detail::string_for_each_metatable_func::is_new_index
bool is_new_index
Definition: sol.hpp:23568
sol::call_detail::lua_call_wrapper< T, overload_set< Fs... >, is_index, is_variable, checked, boost, clean_stack, C >::F
overload_set< Fs... > F
Definition: sol.hpp:18767
sol::set_default_exception_handler
void set_default_exception_handler(lua_State *L, exception_handler_function exf=&detail::default_exception_handler)
Definition: sol.hpp:8897
sol::detail::tagged::tagged
tagged(Arg &&arg, Args &&... args)
Definition: sol.hpp:6974
sol::stack::script
void script(lua_State *L, lua_Reader reader, void *data, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:16651
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::T
std::remove_pointer_t< meta::unwrap_unqualified_t< X > > T
Definition: sol.hpp:22655
sol::basic_table_core::create
table create(int narr, int nrec, Key &&key, Value &&value, Args &&... args)
Definition: sol.hpp:26097
sol::meta::has_size
meta::boolean< meta_detail::has_size_test< T >::value > has_size
Definition: sol.hpp:2712
sol::container_detail::usertype_container_default::clear
static int clear(lua_State *L_)
Definition: sol.hpp:21717
sol::stack_proxy_base::lua_state
lua_State * lua_state() const
Definition: sol.hpp:17160
sol::basic_reference::copy_ref
int copy_ref(lua_State *L_) const noexcept
Definition: sol.hpp:10456
sol::stack::unqualified_pusher< closure< Arg, Args... > >::push
static int push(lua_State *L, T &&c)
Definition: sol.hpp:15267
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::erase_integral
static detail::error_result erase_integral(std::false_type, lua_State *L_, T &self, const K &key)
Definition: sol.hpp:22326
sol::basic_coroutine::error
bool error() const noexcept
Definition: sol.hpp:28450
sol::type_panic_t
Definition: sol.hpp:9573
sol::stack::field_getter< std::pair< A, B >, b, raw, C >::get
void get(lua_State *L, Keys &&keys, int tableindex)
Definition: sol.hpp:16196
sol::meta::meta_detail::basic_traits
Definition: sol.hpp:1548
lua_compare
LUA_API int lua_compare(lua_State *L, int index1, int index2, int op)
Definition: lapi.c:345
sol::meta::index_in_pack
Definition: sol.hpp:2271
sol::detail::lua_CFunction_noexcept
int(* lua_CFunction_noexcept)(lua_State *L) noexcept
Definition: sol.hpp:7285
sol::detail::usertype_alloc_destroy
int usertype_alloc_destroy(lua_State *L) noexcept
Definition: sol.hpp:11316
eprosima::fastcdr::nullopt
static constexpr nullopt_t nullopt
nullopt is a constant of type nullopt_t that is used to indicate optional type with uninitialized sta...
Definition: optional.hpp:40
sol::pairs_iterator::operator!=
friend bool operator!=(const pairs_iterator &left, const pairs_sentinel &) noexcept
Definition: sol.hpp:25360
sol::member_function_wrapper::call
static R call(Fx &&fx, O &mem, Args &&... args)
Definition: sol.hpp:17773
sol::detail::not_enough_stack_space_floating
constexpr const char * not_enough_stack_space_floating
Definition: sol.hpp:9508
sol::meta::meta_detail::adl_sol_lua_check_test_t
decltype(sol_lua_check(types< T >(), static_cast< lua_State * >(nullptr), -1, &no_panic, std::declval< stack::record & >())) adl_sol_lua_check_test_t
Definition: sol.hpp:11506
sol::stack::unqualified_pusher< const char32_t * >::push
static int push(lua_State *L, const char32_t *u32str, std::size_t sz)
Definition: sol.hpp:15787
sol::detail::ebco::value
T & value() &noexcept
Definition: sol.hpp:7160
sol::meta::tuple_element_t
std::tuple_element_t< N, std::remove_reference_t< Tuple > > tuple_element_t
Definition: sol.hpp:1507
sol::detail::align_one
constexpr std::uintptr_t align_one(std::size_t alignment, std::size_t size, std::uintptr_t ptr)
Definition: sol.hpp:10979
sol::u_detail::update_bases_func::p_usb
usertype_storage_base * p_usb
Definition: sol.hpp:23649
Value
Definition: lobject.h:49
sol::lua_value::is
bool is() const
Definition: sol.hpp:27034
sol::meta_function::bitwise_or
@ bitwise_or
sol::stack::probe_field_getter::get
probe get(lua_State *L, Key &&key, int tableindex=-2)
Definition: sol.hpp:16322
sol::stateless_reference_equals::operator()
bool operator()(const stateless_reference &lhs, const stateless_reference &rhs) const noexcept
Definition: sol.hpp:10743
sol::stack_reference::pop
void pop() const noexcept
Definition: sol.hpp:9796
sol::detail::indexed_insert::indexed_insert
indexed_insert(lua_reg_table &registration_table_, int &index_ref_)
Definition: sol.hpp:11419
sol::stack::unqualified_pusher< std::function< Signature > >::push
static int push(lua_State *L, const std::function< Signature > &fx)
Definition: sol.hpp:20136
sol::stack::script_file
void script_file(lua_State *L, const std::string &filename, load_mode mode=load_mode::any)
Definition: sol.hpp:16670
sol::call_detail::lua_call_wrapper< T, policy_wrapper< F, Policies... >, is_index, is_variable, checked, boost, clean_stack, C >::P
policy_wrapper< F, Policies... > P
Definition: sol.hpp:18890
sol::unsafe_function_result::size_type
std::size_t size_type
Definition: sol.hpp:17450
sol::stack::stack_detail::get_size_hint
static int get_size_hint(const std::forward_list< V, Al > &)
Definition: sol.hpp:11580
sol::call_detail::agnostic_lua_call_wrapper< lua_CFunction_ref, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, lua_CFunction_ref f)
Definition: sol.hpp:18455
sol::detail::optional_storage_base::~optional_storage_base
~optional_storage_base()
Definition: sol.hpp:4933
sol::unique_usertype_traits
Definition: forward.hpp:1257
sol::stack::unqualified_get
decltype(auto) unqualified_get(lua_State *L, int index=-lua_size< meta::unqualified_t< T >>::value)
Definition: sol.hpp:12037
sol::meta_function::metatable
@ metatable
sol::call_detail::lua_call_wrapper< T, policy_wrapper< F, Policies... >, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(std::index_sequence< In... >, lua_State *L, P &fx)
Definition: sol.hpp:18893
sol::as_args
auto as_args(Source &&source)
Definition: sol.hpp:28608
sol::basic_protected_function::get_default_handler
static handler_t get_default_handler(lua_State *L_)
Definition: sol.hpp:21043
sol::pairs_iterator::m_iteration_index
int m_iteration_index
Definition: sol.hpp:25388
sol::state_view::is_loaded_package
optional< object > is_loaded_package(const std::string &key)
Definition: sol.hpp:27243
sol::wrapper::traits_type
lua_bind_traits< meta::unqualified_t< F > > traits_type
Definition: sol.hpp:17651
sol::detail::accumulate_and_mark
void accumulate_and_mark(const std::string &n, std::string &aux_message, int &marker)
Definition: sol.hpp:9517
sol::update_if_empty
constexpr update_if_empty_t update_if_empty
Definition: sol.hpp:7740
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::set
static int set(lua_State *L_)
Definition: sol.hpp:22762
sol::detail::handle_errors
int handle_errors(lua_State *L, const error_result &er)
Definition: sol.hpp:4565
lua_absindex
LUA_API int lua_absindex(lua_State *L, int idx)
Definition: lapi.c:162
sol::table_proxy::push
int push() const noexcept
Definition: sol.hpp:24912
sol::u_detail::maybe_get_usertype_storage_base
optional< usertype_storage_base & > maybe_get_usertype_storage_base(lua_State *L, const char *gcmetakey)
Definition: sol.hpp:24284
sol::factory_wrapper::factory_wrapper
factory_wrapper(Arg &&arg, Args &&... args)
Definition: sol.hpp:7022
sol::meta::unwrapped::type
T type
Definition: sol.hpp:2158
sol::optional< T & >::operator*
constexpr const T & operator*() const
Definition: sol.hpp:6792
sol::u_detail::binding::data
virtual void * data() override
Definition: sol.hpp:23471
sol::container_detail::has_traits_index_of
meta::boolean< has_traits_index_of_test< T >::value > has_traits_index_of
Definition: sol.hpp:21620
sol::basic_environment::basic_environment
basic_environment(lua_State *L, int index=-1)
Definition: sol.hpp:26617
sol::meta::count_odd_for_pack_v
constexpr std::size_t count_odd_for_pack_v
Definition: sol.hpp:2347
sol::container_detail::has_traits_add_test
Definition: sol.hpp:21539
lua_createtable
LUA_API void lua_createtable(lua_State *L, int narray, int nrec)
Definition: lapi.c:756
sol::u_detail::string_for_each_metatable_func::is_static_index
bool is_static_index
Definition: sol.hpp:23569
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::index_adjustment
static std::ptrdiff_t index_adjustment(lua_State *, T &)
Definition: sol.hpp:22633
sol::c_call
int c_call(lua_State *L)
Definition: sol.hpp:19089
sol::stack::unqualified_check_getter< std::variant< Tn... >, C >::get_empty
static optional< V > get_empty(std::true_type, lua_State *, int, Handler &&, record &)
Definition: sol.hpp:14497
sol::load_mode::any
@ any
sol::u_detail::usertype_storage_base::reference_index_table
stateless_reference reference_index_table
Definition: sol.hpp:23683
sol::container_detail::usertype_container_default::ipairs
static int ipairs(lua_State *L_)
Definition: sol.hpp:21737
sol::meta::meta_detail::is_rebind_actual_type_v
constexpr bool is_rebind_actual_type_v
Definition: sol.hpp:9308
sol::detail::disable_if_ret_void
enable_if_t<!returns_void< T &&, U... >::value > disable_if_ret_void
Definition: sol.hpp:4833
sol::optional::reset
void reset() noexcept
Destroys the stored value if one exists, making the optional empty.
Definition: sol.hpp:6000
sol::u_detail::update_bases_func::new_idx_call
lua_CFunction new_idx_call
Definition: sol.hpp:23648
sol::container_detail::u_c_launch::real_at_traits
static int real_at_traits(std::false_type, lua_State *L)
Definition: sol.hpp:22886
sol::swap
void swap(optional< T > &lhs, optional< T > &rhs) noexcept(noexcept(lhs.swap(rhs)))
\synopsis template <class T> void swap(optional<T> &lhs, optional<T> &rhs);
Definition: sol.hpp:6174
lua_gc
LUA_API int lua_gc(lua_State *L, int what,...)
Definition: lapi.c:1126
sol::bad_optional_access::what
const char * what() const noexcept override
Returns a pointer to a null-terminated string containing the reason for the exception.
Definition: sol.hpp:5232
sol::optional< T & >::take
optional take() &
Definition: sol.hpp:6644
sol::stack::unqualified_pusher< as_returns_t< T > >::push
int push(lua_State *L, const as_returns_t< T > &e)
Definition: sol.hpp:28806
sol::state_view::do_file
protected_function_result do_file(const std::string &filename, load_mode mode=load_mode::any)
Definition: sol.hpp:27552
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::set_it
static detail::error_result set_it(std::false_type, lua_State *L_, T &self, stack_object key, stack_object value)
Definition: sol.hpp:22047
sol::basic_reference::basic_reference
basic_reference(lua_State *L_, global_tag_t) noexcept
Definition: sol.hpp:10439
sol::u_detail::update_bases_func::meta_new_idx_call
lua_CFunction meta_new_idx_call
Definition: sol.hpp:23648
sol::stack::stack_detail::copy_code_units_utf::copy_code_units_utf
copy_code_units_utf(Ch *target)
Definition: sol.hpp:13377
sol::meta::is_detected_v
constexpr bool is_detected_v
Definition: sol.hpp:1393
sol::call_detail::construct_match
int construct_match(Match &&matchfx, lua_State *L, int fxarity, int start, Args &&... args)
Definition: sol.hpp:18354
sol::meta::meta_detail::index_in_pack
Definition: sol.hpp:2263
sol::meta::boolean_v
constexpr bool boolean_v
Definition: sol.hpp:2210
sol::bases
base_list< Args... > bases
Definition: sol.hpp:9332
sol::basic_environment::basic_environment
basic_environment(lua_nil_t r) noexcept
Definition: sol.hpp:26642
sol::usertype_proxy::key
key_type key
Definition: sol.hpp:24593
sol::call_status
call_status
Definition: sol.hpp:7848
sol::stack::unqualified_getter< basic_bytecode< Allocator > >::get
static basic_bytecode< Allocator > get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:21261
sol::function_detail::member_function
Definition: sol.hpp:19517
sol::stack_reference_hash::operator()
result_type operator()(const argument_type &lhs) const noexcept
Definition: sol.hpp:9925
sol::detail::associated_nullopt
Definition: sol.hpp:6889
sol::table
table_core< false > table
Definition: forward.hpp:1126
sol::optional< T & >::map_or
U map_or(F &&f, U &&u) const &&
\group map_or
Definition: sol.hpp:6545
sol::basic_table_iterator::iterator_category
std::input_iterator_tag iterator_category
Definition: sol.hpp:25043
sol::basic_table_iterator::mapped_type
object mapped_type
Definition: sol.hpp:25041
luaL_addsize
#define luaL_addsize(B, s)
Definition: lauxlib.h:203
sol::type_panic_t::operator()
int operator()(lua_State *L, int index, type expected, type actual, string_view message) const noexcept(false)
Definition: sol.hpp:9577
sol::wrapper::caller
Definition: sol.hpp:17661
sol::function_detail::class_indicator::type
T type
Definition: sol.hpp:19804
sol::stack::unqualified_pusher< const char16_t * >::convert_into
static int convert_into(lua_State *L, char *start, std::size_t, const char16_t *strb, const char16_t *stre)
Definition: sol.hpp:15685
S
#define S(x)
Definition: luac.c:667
sol::u_detail::usertype_storage_base::value_index_table
stateless_reference value_index_table
Definition: sol.hpp:23682
sol::stack::get_traceback_or_errors
error get_traceback_or_errors(lua_State *L)
Definition: sol.hpp:27221
sol::optional::operator=
optional & operator=(nullopt_t) noexcept
Definition: sol.hpp:5758
sol::variadic_args::end
iterator end()
Definition: sol.hpp:28682
sol::proxy_base_tag
Definition: sol.hpp:16949
sol::gc_mode::generational
@ generational
sol::type_error
void type_error(lua_State *L, int expected, int actual) noexcept(false)
Definition: sol.hpp:9620
sol::stack::stack_detail::not_enough_stack_space
constexpr const char * not_enough_stack_space
Definition: sol.hpp:11546
sol::stack::unqualified_getter< user< T > >::get
static std::add_lvalue_reference_t< T > get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:13955
sol::stack::unqualified_pusher< stack_proxy >::push
static int push(lua_State *, const stack_proxy &ref)
Definition: sol.hpp:17216
sol::meta::detail::tuple_types_< std::tuple< Args... > >::type
types< Args... > type
Definition: sol.hpp:1478
sol::stack::unqualified_pusher< char16_t * >::push
static int push(lua_State *L, const char16_t *str)
Definition: sol.hpp:15742
Table
Definition: lobject.h:724
sol::stack::unqualified_getter< T & >::get
static T & get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14259
lua_pushlightuserdata
LUA_API void lua_pushlightuserdata(lua_State *L, void *p)
Definition: lapi.c:610
sol::u_detail::is_indexer
int is_indexer(call_construction)
Definition: sol.hpp:23319
sol::u_detail::binding::call_with_
static int call_with_(lua_State *L_, void *target)
Definition: sol.hpp:23476
sol::container_detail::u_c_launch::real_add_traits
static int real_add_traits(std::false_type, lua_State *L)
Definition: sol.hpp:22982
sol::stack::push
int push(lua_State *L, T &&t, Args &&... args)
Definition: sol.hpp:11746
sol::meta::function_return_t
typename bind_traits< Signature >::return_type function_return_t
Definition: sol.hpp:2041
sol::basic_protected_function::operator()
protected_function_result operator()(Args &&... args) const
Definition: sol.hpp:20985
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::insert_lookup
static detail::error_result insert_lookup(std::false_type, lua_State *L_, T &self, stack_object where, stack_object value)
Definition: sol.hpp:22266
sol::stack::unqualified_pusher< T, std::enable_if_t< is_container_v< T > > >::push
static int push(lua_State *L, Args &&... args)
Definition: sol.hpp:23219
sol::light::light
light(void *x)
Definition: sol.hpp:7458
sol::detail::pick_main_thread
lua_State * pick_main_thread(lua_State *L_, lua_State *backup_if_unsupported=nullptr)
Definition: sol.hpp:10149
sol::optional< T & >::and_then
constexpr detail::invoke_result_t< F, const T & > and_then(F &&f) const &
Definition: sol.hpp:6349
sol::stack::unqualified_getter< as_table_t< T > >::max_size_check
static bool max_size_check(std::false_type, T &, std::size_t)
Definition: sol.hpp:13603
sol::stack::unqualified_pusher< lua_CFunction >::push
static int push(lua_State *L, lua_CFunction func, int n=0)
Definition: sol.hpp:15213
sol::stack::popper
Definition: sol.hpp:11449
sol::state_view::unsafe_script
unsafe_function_result unsafe_script(lua_Reader reader, void *data, const basic_environment< E > &env, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27642
sol::update_if_empty_t
Definition: sol.hpp:7739
sol::create_if_nil
constexpr create_if_nil_t create_if_nil
Definition: sol.hpp:7742
sol::property_wrapper::write
W & write()
Definition: sol.hpp:17938
sol::meta::disable_any
std::enable_if_t< neg< any< Args... > >::value, enable_t > disable_any
Definition: sol.hpp:2253
sol::stack::unqualified_getter< std::basic_string< wchar_t, Traits, Al > >::S
std::basic_string< wchar_t, Traits, Al > S
Definition: sol.hpp:14022
sol::detail::inheritance::type_check_bases
static bool type_check_bases(types<>, const string_view &)
Definition: sol.hpp:9366
sol::lua_bind_traits
Definition: sol.hpp:8511
sol::lib::math
@ math
sol::u_detail::string_for_each_metatable_func::poison_indexing
bool poison_indexing
Definition: sol.hpp:23571
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::get_src
static auto & get_src(lua_State *L_)
Definition: sol.hpp:22677
sol::stack::unqualified_getter
Definition: sol.hpp:11439
sol::basic_metatable::basic_metatable
basic_metatable(detail::no_safety_tag, lua_State *L, int index)
Definition: sol.hpp:26141
sol::basic_function::dump
int dump(lua_Writer writer, void *userdata, bool strip, Fx &&on_error) const
Definition: sol.hpp:20675
sol::u_detail::string_for_each_metatable_func::is_index
bool is_index
Definition: sol.hpp:23567
range_format::set
@ set
sol::detail::update_if_empty
@ update_if_empty
Definition: sol.hpp:7745
sol::function_detail::lua_c_noexcept_wrapper
int lua_c_noexcept_wrapper(lua_State *L) noexcept
Definition: sol.hpp:19822
sol::table_core
basic_table_core< b, reference > table_core
Definition: forward.hpp:1119
sol::basic_table_core::traverse_set_deep
void traverse_set_deep(int table_index, Key &&key, Keys &&... keys) const
Definition: sol.hpp:25631
LUA_ERRMEM
#define LUA_ERRMEM
Definition: lua.h:53
sol::meta::meta_detail::callable_traits< R(T::*), true >::object_type
T object_type
Definition: sol.hpp:1998
sol::lua_value::lua_value
lua_value(lua_State *L_, std::initializer_list< std::pair< lua_value, lua_value >> il)
Definition: sol.hpp:26980
sol::stack::unqualified_pusher< detail::tagged< T, no_construction > >::push
static int push(lua_State *L, no_construction, function_detail::call_indicator)
Definition: sol.hpp:20296
sol::stateless_reference::stateless_reference
stateless_reference(lua_State *, lua_nil_t) noexcept
Definition: sol.hpp:10271
sol::meta::any
Definition: sol.hpp:2225
sol::container_detail::has_empty
meta::boolean< has_empty_test< T >::value > has_empty
Definition: sol.hpp:21566
sol::stack_proxy_base::stack_proxy_base
stack_proxy_base(lua_State *L_, int index_)
Definition: sol.hpp:17129
sol::detail::ref_clean::pop_count
int & pop_count
Definition: sol.hpp:25446
sol::meta_function::storage
@ storage
sol::stack::unqualified_getter< as_table_t< std::forward_list< T, Al > > >::get
static C get(types< V >, lua_State *L, int relindex, record &tracking)
Definition: sol.hpp:13801
sol::stack_proxy_base::stack_proxy_base
stack_proxy_base()
Definition: sol.hpp:17127
sol::container_detail::u_c_launch::get_call
static int get_call(lua_State *L)
Definition: sol.hpp:23107
sol::variadic_args::lua_state
lua_State * lua_state() const
Definition: sol.hpp:28746
sol::stack_iterator::stack_iterator
stack_iterator(lua_State *luastate, int idx, int topidx)
Definition: sol.hpp:17009
sol::stack::stateless_push_popper::Tu
meta::unqualified_t< T > Tu
Definition: sol.hpp:10053
sol::u_detail::update_bases_func::meta_idx_call
lua_CFunction meta_idx_call
Definition: sol.hpp:23648
sol::basic_environment::basic_environment
basic_environment(lua_State *L, new_table t, const basic_reference< b > &fallback)
Definition: sol.hpp:26593
sol::stack::unqualified_getter< basic_string_view< char, Traits > >::get
static string_view get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:14012
mqtt_test.ret
ret
Definition: mqtt_test.py:30
sol::pairs_iterator::pairs_iterator
pairs_iterator(pairs_iterator &&right) noexcept
Definition: sol.hpp:25222
sol::main_table_core
basic_table_core< b, main_reference > main_table_core
Definition: forward.hpp:1121
sol::is_container_v
constexpr bool is_container_v
Definition: sol.hpp:8129
sol::variadic_args::const_reverse_iterator
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: sol.hpp:28649
sol::table_proxy::table_proxy
table_proxy(Table table, T &&k)
Definition: sol.hpp:24763
sol::call_detail::agnostic_lua_call_wrapper< detail::lua_CFunction_noexcept, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, detail::lua_CFunction_noexcept f)
Definition: sol.hpp:18470
sol::variadic_args::get_type
type get_type(difference_type index_offset=0) const noexcept
Definition: sol.hpp:28738
sol::detail::unique_get
auto unique_get(lua_State *L_, T &value_) noexcept(unique_get_noexcept< std::remove_cv_t< T >>())
Definition: sol.hpp:9289
sol::lua_type_of::SOL_INTERNAL_UNSPECIALIZED_MARKER_
int SOL_INTERNAL_UNSPECIALIZED_MARKER_
Definition: sol.hpp:8387
sol::unicode::code_point_to_utf16
encoded_result< char16_t > code_point_to_utf16(char32_t codepoint)
Definition: sol.hpp:13198
sol::pairs_iterator::const_pointer
value_type const * const_pointer
Definition: sol.hpp:25206
sol::detail::short_demangle
const std::string & short_demangle()
Definition: sol.hpp:9074
TValue
struct TValue TValue
sol::u_detail::string_for_each_metatable_func::p_usb
usertype_storage_base * p_usb
Definition: sol.hpp:23578
sol::detail::base_class_index_propogation_key
decltype(auto) base_class_index_propogation_key()
Definition: sol.hpp:9352
sol::detail::deleter
Definition: sol.hpp:6949
sol::detail::optional_storage_base< T, true >::optional_storage_base
SOL_TL_OPTIONAL_11_CONSTEXPR optional_storage_base(in_place_t, U &&... u)
Definition: sol.hpp:4956
sol::usertype_container
Definition: sol.hpp:21305
sol::absolute_index
Definition: sol.hpp:7394
sol::container_detail::u_c_launch::real_empty_traits
static int real_empty_traits(std::false_type, lua_State *L)
Definition: sol.hpp:23018
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::is_copyable
std::is_copy_assignable< V > is_copyable
Definition: sol.hpp:21780
sol::state_view::do_reader
protected_function_result do_reader(lua_Reader reader, void *data, const basic_environment< E > &env, const std::string &chunkname=detail::default_chunk_name(), load_mode mode=load_mode::any)
Definition: sol.hpp:27490
sol::basic_variadic_results
Definition: sol.hpp:28825
sol::stack::unqualified_pusher< forward_as_value_t< T > >::push
static int push(lua_State *L, const forward_as_value_t< T > &value_)
Definition: sol.hpp:15942
sol::stack::unqualified_pusher< as_table_t< T > >::push
static int push(lua_State *L, const as_table_t< T > &value_)
Definition: sol.hpp:15117
sol::detail::optional_operations_base::get
const SOL_TL_OPTIONAL_11_CONSTEXPR T & get() const &
Definition: sol.hpp:5011
sol::light
Definition: forward.hpp:1244
sol::stack::stack_detail::unchecked_get_arg
decltype(auto) unchecked_get_arg(lua_State *L_, int index_, record &tracking_)
Definition: sol.hpp:12172
sol::stack_proxy_base::m_L
lua_State * m_L
Definition: sol.hpp:17123
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::at_category
static detail::error_result at_category(std::input_iterator_tag, lua_State *L_, T &self, std::ptrdiff_t pos)
Definition: sol.hpp:21816
sol::detail::ebco::ebco
ebco(const T &v) noexcept(std::is_nothrow_copy_constructible_v< T >)
Definition: sol.hpp:7142
sol::basic_table_core::traverse_set
basic_table_core & traverse_set(Keys &&... keys)
Definition: sol.hpp:25849
sol::protect_t::value
T value
Definition: sol.hpp:18051
sol::basic_metatable::basic_metatable
basic_metatable(T &&r) noexcept
Definition: sol.hpp:26211
sol::detail::get_default_handler
Reference get_default_handler(lua_State *L_)
Definition: sol.hpp:20779
nullptr
#define nullptr
Definition: backward.hpp:386
sol::array_value
typename lua_value::arr array_value
Definition: sol.hpp:27045
luaL_tolstring
const LUALIB_API char * luaL_tolstring(lua_State *L, int idx, size_t *len)
Definition: lauxlib.c:883
sol::is_stack_table
Definition: sol.hpp:8544
sol::u_detail::usertype_storage_base::gc_names_table
stateless_reference gc_names_table
Definition: sol.hpp:23689
sol::container_detail::has_traits_set
meta::boolean< has_traits_set_test< T >::value > has_traits_set
Definition: sol.hpp:21587
sol::stack::unqualified_pusher< lua_value >::push
static int push(lua_State *L, const lua_value &lv)
Definition: sol.hpp:27050
sol::meta::meta_detail::adl_sol_lua_push_test_t
decltype(sol_lua_push(static_cast< lua_State * >(nullptr), std::declval< Args >()...)) adl_sol_lua_push_test_t
Definition: sol.hpp:11517
sol::optional::map_or
U map_or(F &&f, U &&u) const &
\group map_or
Definition: sol.hpp:5525
sol::basic_usertype::set_function
basic_usertype & set_function(Key &&key, Args &&... args)
Definition: sol.hpp:26379
sol::basic_reference::basic_reference
basic_reference(lua_State *L_, global_tag_t, global_tag_t) noexcept
Definition: sol.hpp:10442
sol::detail::ptr
T * ptr(T &val)
Definition: sol.hpp:2106
sol::meta::enable_any
std::enable_if_t< any< Args... >::value, enable_t > enable_any
Definition: sol.hpp:2250
sol::detail::std_shim< void >::lua_func_
unsafe_function lua_func_
Definition: sol.hpp:21224
sol::stack_protected_function
stack_safe_function stack_protected_function
Definition: forward.hpp:1170
sol::automagic_enrollments::default_constructor
bool default_constructor
Definition: sol.hpp:8704
sol::stack::unqualified_pusher< const char32_t * >::push
static int push(lua_State *L, const char32_t *strb, const char32_t *stre)
Definition: sol.hpp:15791
D
#define D(name, bit)
sol::stack::unqualified_pusher< char32_t * >::push
static int push(lua_State *L, const char32_t *str, std::size_t len)
Definition: sol.hpp:15831
sol::stateless_reference::equals
bool equals(lua_State *L_, const stateless_stack_reference &r) const noexcept
Definition: sol.hpp:10370
panic
static int panic(lua_State *L)
Definition: lauxlib.c:1021
sol::stack::unqualified_check_getter< std::variant< Tn... >, C >::V_is_empty
std::integral_constant< bool, V_size::value==0 > V_is_empty
Definition: sol.hpp:14494
sol::meta::supports_to_string_member
Definition: sol.hpp:2661
sol::nested::nested
nested(const meta::unqualified_t< T > &obj) noexcept(std::is_nothrow_constructible_v< base_t, const meta::unqualified_t< T > & >)
Definition: sol.hpp:7620
sol::state_view::script_file
protected_function_result script_file(const std::string &filename, const basic_environment< E > &env, Fx &&on_error, load_mode mode=load_mode::any)
Definition: sol.hpp:27740
sol::as_returns_t
Definition: sol.hpp:28789
sol::stack::unqualified_pusher< detail::tagged< T, constructor_wrapper< Fxs... > > >::push
static int push(lua_State *L, const detail::tagged< T, const constructor_wrapper< Fxs... >> &c)
Definition: sol.hpp:20330
sol::detail::deleter::operator()
void operator()(T *p) const
Definition: sol.hpp:6951
sol::table_proxy::push
int push(lua_State *L) const noexcept
Definition: sol.hpp:24916
sol::stack_proxy::stack_proxy
stack_proxy(lua_State *L, int index)
Definition: sol.hpp:17193
sol::variadic_args::cbegin
const_iterator cbegin() const
Definition: sol.hpp:28691
sol::call_detail::lua_call_wrapper< T, yielding_t< Y >, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, F &&f)
Definition: sol.hpp:18908
sol::u_detail::usertype_storage_base::~usertype_storage_base
~usertype_storage_base()
Definition: sol.hpp:23985
sol::stateless_reference::stateless_reference
stateless_reference(stack_reference &&r) noexcept
Definition: sol.hpp:10212
sol::container_detail::u_c_launch::real_find_traits
static int real_find_traits(std::false_type, lua_State *L)
Definition: sol.hpp:23042
sol::variadic_args
Definition: sol.hpp:28634
sol::basic_table_core::set_function
basic_table_core & set_function(Key &&key, Args &&... args)
Definition: sol.hpp:26032
sol::meta_function::bitwise_left_shift
@ bitwise_left_shift
sol::function_detail::functor_function::call
static int call(lua_State *L, functor_function &self) noexcept(noexcept(call_detail::call_wrapped< void, true, false >(L, self.invocation)))
Definition: sol.hpp:19496
sol::usertype_proxy::set
usertype_proxy & set(T &&item) &
Definition: sol.hpp:24600
sol::protected_function_result::status
call_status status() const noexcept
Definition: sol.hpp:17284
sol::meta_function::bitwise_not
@ bitwise_not
sol::call_detail::void_call< T, types< Args... > >::call
static void call(Args...)
Definition: sol.hpp:18156
sol::meta::boolean
std::integral_constant< bool, B > boolean
Definition: sol.hpp:2207
sol::stateless_stack_reference_equals::lua_state
lua_State * lua_state() const noexcept
Definition: sol.hpp:9863
sol::basic_object::basic_object
basic_object(lua_State *L_, in_place_t, T &&arg, Args &&... args) noexcept
Definition: sol.hpp:16890
sol::stack::unqualified_pusher< table_proxy< Table, Key > >::push
static int push(lua_State *L, const table_proxy< Table, Key > &p)
Definition: sol.hpp:25022
sol::basic_table_core::iterator
basic_table_iterator< ref_t > iterator
Definition: sol.hpp:25709
sol::function_detail::select_member_variable
void select_member_variable(lua_State *L, Fx &&fx, Args &&... args)
Definition: sol.hpp:19871
sol::meta::find_in_pack_v
Definition: sol.hpp:2256
sol::pass_as_value
auto pass_as_value(T &value_ref_)
Definition: sol.hpp:7733
sol::basic_table_iterator::pointer
value_type * pointer
Definition: sol.hpp:25045
sol::function_detail::call_indicator
Definition: sol.hpp:19807
nlohmann::detail::index_sequence
integer_sequence< size_t, Ints... > index_sequence
Definition: json.hpp:3097
sol::meta_function::less_than_or_equal_to
@ less_than_or_equal_to
sol::types::size
static constexpr std::size_t size()
Definition: sol.hpp:1287
sol::pairs_iterator::pairs_iterator
pairs_iterator(const Source &source_) noexcept
Definition: sol.hpp:25244
lua_newthread
LUA_API lua_State * lua_newthread(lua_State *L)
Definition: lstate.c:285
sol::stateless_reference
Definition: sol.hpp:10159
sol::unsafe_function_result::pointer
stack_proxy * pointer
Definition: sol.hpp:17448
sol::container_detail::u_c_launch::real_next_traits
static int real_next_traits(std::false_type, lua_State *L)
Definition: sol.hpp:22958
sol::lightuserdata_value
Definition: sol.hpp:7421
sol::u_detail::get_usertype_storage_base
usertype_storage_base & get_usertype_storage_base(lua_State *L_, const char *gcmetakey)
Definition: sol.hpp:24291
sol::stack::unqualified_pusher< T *, std::enable_if_t< is_container_v< T > > >::C
std::add_pointer_t< meta::unqualified_t< std::remove_pointer_t< T > >> C
Definition: sol.hpp:23227
sol::basic_coroutine::basic_coroutine
basic_coroutine(stack_reference &&r) noexcept
Definition: sol.hpp:28370
lua_error
LUA_API int lua_error(lua_State *L)
Definition: lapi.c:1230
sol::detail::inheritance
Definition: sol.hpp:9363
sol::call_detail::lua_call_wrapper< T, constructor_list< Args... >, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, F &)
Definition: sol.hpp:18694
sol::meta_function::division
@ division
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::erase_has
static detail::error_result erase_has(std::true_type, lua_State *L_, T &self, K &key)
Definition: sol.hpp:22374
sol::meta::meta_detail::basic_traits::args_list
types< Args... > args_list
Definition: sol.hpp:1558
sol::basic_protected_function::abandon
void abandon() noexcept
Definition: sol.hpp:21078
sol::meta_function
meta_function
Definition: sol.hpp:7983
sol::optional::disjunction
SOL_TL_OPTIONAL_11_CONSTEXPR optional disjunction(const optional &rhs) &&
\group disjunction
Definition: sol.hpp:5596
sol::detail::indexed_insert
Definition: sol.hpp:11415
sol::in_place_type
constexpr std::in_place_type_t< T > in_place_type
Definition: sol.hpp:4618
sol::container_detail::usertype_container_default< X, std::enable_if_t< std::is_array< std::remove_pointer_t< meta::unwrap_unqualified_t< X > > >::value > >::iter::it
iterator it
Definition: sol.hpp:22666
sol::readonly_property
decltype(auto) readonly_property(F &&f)
Definition: sol.hpp:17979
sol::automagic_enrollments::call_operator
bool call_operator
Definition: sol.hpp:8708
sol::u_detail::string_for_each_metatable_func::p_binding_ref
reference * p_binding_ref
Definition: sol.hpp:23575
sol::thread_status::dead
@ dead
sol::basic_function::basic_function
basic_function(lua_nil_t n)
Definition: sol.hpp:20650
sol::stack_iterator::stacktop
int stacktop
Definition: sol.hpp:17002
sol::stateless_stack_reference_equals::operator()
bool operator()(lua_nil_t lhs, const stateless_stack_reference &rhs) const
Definition: sol.hpp:9871
sol::detail::inheritance::type_cast_bases
static void * type_cast_bases(types<>, T *, const string_view &)
Definition: sol.hpp:9384
lua_topointer
const LUA_API void * lua_topointer(lua_State *L, int idx)
Definition: lapi.c:469
sol::basic_table_iterator::value_type
std::pair< object, object > value_type
Definition: sol.hpp:25042
sol::basic_userdata
Definition: forward.hpp:1199
sol::basic_usertype::set_fx
void set_fx(types<>, Key &&key, Fx &&fx)
Definition: sol.hpp:26331
sol::in_place_index_t
std::in_place_index_t< I > in_place_index_t
Definition: sol.hpp:4621
sol::stack::stack_detail::unchecked_get
decltype(auto) unchecked_get(lua_State *L, int index, record &tracking)
Definition: sol.hpp:11598
sol::optional::optional
optional(optional< U > &&rhs)
Definition: sol.hpp:5740
sol::u_detail::update_bases_func::idx_call
lua_CFunction idx_call
Definition: sol.hpp:23648
sol::stack::stack_detail::count_code_units_utf
Definition: sol.hpp:13362
sol::basic_lightuserdata::basic_lightuserdata
basic_lightuserdata(lua_State *L, T &&r)
Definition: sol.hpp:28573
udp_client.args
args
Definition: udp_client.py:12
sol::stateless_stack_reference_hash
Definition: sol.hpp:9899
sol::as_container
auto as_container(T &&value)
Definition: sol.hpp:7689
sol::table_proxy::key_type
detail::proxy_key_t< Key > key_type
Definition: sol.hpp:24723
sol::basic_object
Definition: forward.hpp:1197
sol::wrapper< F, std::enable_if_t< std::is_member_object_pointer< meta::unqualified_t< F > >::value > >::args_list
traits_type::args_list args_list
Definition: sol.hpp:17707
sol::basic_table_core::end
iterator end() const
Definition: sol.hpp:25785
sol::container_detail::has_traits_erase
meta::boolean< has_traits_erase_test< T >::value > has_traits_erase
Definition: sol.hpp:21626
sol::call_detail::construct_trampolined
int construct_trampolined(lua_State *L)
Definition: sol.hpp:18361
sol::as_table
as_table_t< meta::unqualified_t< T > > as_table(T &&container)
Definition: sol.hpp:7651
sol::container_detail::usertype_container_default< X, std::enable_if_t< meta::all< is_forced_container< meta::unqualified_t< X > >, meta::has_value_type< meta::unqualified_t< container_decay_t< X > > >, meta::has_iterator< meta::unqualified_t< container_decay_t< X > > > >::value > >::iter::keep_alive
reference keep_alive
Definition: sol.hpp:21786
sol::container_detail::u_c_launch::real_find_call
static int real_find_call(lua_State *L)
Definition: sol.hpp:23046
sol::stack_iterator::operator-
difference_type operator-(const stack_iterator &r) const
Definition: sol.hpp:17062
sol::stack::unqualified_pusher< user< T > >::push_with
static int push_with(lua_State *L, Key &&name, Args &&... args)
Definition: sol.hpp:15319
sol::lua_nil_t
Definition: sol.hpp:7313
sol::state::~state
~state()
Definition: sol.hpp:28263
sol::basic_reference::deref
void deref() const noexcept
Definition: sol.hpp:10448
sol::basic_reference::lua_state
lua_State * lua_state() const noexcept
Definition: sol.hpp:10646
sol::stack::unqualified_pusher::push
static int push(lua_State *L, Args &&... args)
Definition: sol.hpp:14948
sol::basic_lua_table::basic_lua_table
basic_lua_table(lua_State *L, const new_table &nt)
Definition: sol.hpp:26439
sol::call_detail::agnostic_lua_call_wrapper< lua_CFunction, is_index, is_variable, checked, boost, clean_stack, C >::call
static int call(lua_State *L, lua_CFunction f)
Definition: sol.hpp:18462
sol::detail::swap_adl_tests::can_swap
std::true_type can_swap(int) noexcept(noexcept(swap(std::declval< T & >(), std::declval< U & >())))
sol::variadic_args::rbegin
reverse_iterator rbegin()
Definition: sol.hpp:28698
sol::detail::not_a_number_or_number_string
constexpr const char * not_a_number_or_number_string
Definition: sol.hpp:9502
sol::basic_function::basic_function
basic_function(stack_reference &&r)
Definition: sol.hpp:20648
sol::optional::map_or_else
detail::invoke_result_t< U > map_or_else(F &&f, U &&u) const &&
Definition: sol.hpp:5572
sol::detail::default_exception_handler_name
const char(& default_exception_handler_name())[11]
Definition: sol.hpp:8736
sol::stack::stateless_push_popper::m_index
int m_index
Definition: sol.hpp:10056
sol::meta::meta_detail::is_adl_sol_lua_push_exact_v
constexpr bool is_adl_sol_lua_push_exact_v
Definition: sol.hpp:11541
sol::load_result::operator=
load_result & operator=(load_result &&o) noexcept
Definition: sol.hpp:26843
sol::meta::at_in_pack
Definition: sol.hpp:2280


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Aug 11 2024 02:24:26