This update allows for many more definition macros and teh use of a configuration header to be combined with the single.py

Allow for configuration macros to aid in fixing #631
pull/636/head
ThePhD 2018-04-17 12:29:03 -04:00
parent 2de6447e73
commit 479575c0ca
48 changed files with 1851 additions and 1684 deletions

15
.style.yapf Normal file
View File

@ -0,0 +1,15 @@
[style]
based_on_style = pep8
use_tabs = true
indent_width = 5
spaces_before_comment = 1
spaces_around_power_operator = true
space_between_ending_comma_and_closing_bracket = true
continuation_align_style = SPACE
split_before_first_argument = false
split_complex_comprehension = true
dedent_closing_brackets = false
coalesce_brackets = true
align_closing_bracket_with_visual_indent = false

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

182
single.py
View File

@ -7,15 +7,23 @@ import datetime as dt
# python 3 compatibility
try:
import cStringIO as sstream
import cStringIO as sstream
except ImportError:
from io import StringIO
from io import StringIO
description = "Converts sol to a single file for convenience."
# command line parser
parser = argparse.ArgumentParser(usage='%(prog)s [options...]', description=description)
parser.add_argument('--output', '-o', nargs='+', help='name and location of where to place file (and forward declaration file)', metavar='file', default='sol.hpp')
parser = argparse.ArgumentParser(
usage='%(prog)s [options...]', description=description)
parser.add_argument(
'--output',
'-o',
nargs='+',
help=
'name and location of where to place file (and forward declaration file)',
metavar='file',
default='sol.hpp')
parser.add_argument('--quiet', help='suppress all output', action='store_true')
args = parser.parse_args()
@ -23,9 +31,9 @@ single_file = ''
forward_single_file = ''
single_file = args.output[0]
if len(args.output) > 1:
forward_single_file = args.output[1]
forward_single_file = args.output[1]
else:
a,b = os.path.splitext(single_file)
a, b = os.path.splitext(single_file)
forward_single_file = a + '_forward' + b
script_path = os.path.normpath(os.path.dirname(os.path.realpath(__file__)))
working_dir = os.getcwd()
@ -67,84 +75,100 @@ module_path = os.path.join(script_path)
includes = set([])
standard_include = re.compile(r'#include <(.*?)>')
local_include = re.compile(r'#(\s*?)include "(.*?)"')
project_include = re.compile(r'#(\s*?)include <sol/(.*?)>')
pragma_once_cpp = re.compile(r'(\s*)#(\s*)pragma(\s+)once')
ifndef_cpp = re.compile(r'#ifndef SOL_.*?_HPP')
define_cpp = re.compile(r'#define SOL_.*?_HPP')
endif_cpp = re.compile(r'#endif // SOL_.*?_HPP')
def get_include(line, base_path):
local_match = local_include.match(line)
if local_match:
# local include found
full_path = os.path.normpath(os.path.join(base_path, local_match.group(2))).replace('\\', '/')
return full_path
return None
def get_include(line, base_path):
local_match = local_include.match(line)
if local_match:
# local include found
full_path = os.path.normpath(
os.path.join(base_path, local_match.group(2))).replace(
'\\', '/')
return full_path
project_match = project_include.match(line)
if project_match:
# local include found
full_path = os.path.normpath(
os.path.join(base_path, project_match.group(2))).replace(
'\\', '/')
return full_path
return None
def is_include_guard(line):
return ifndef_cpp.match(line) or define_cpp.match(line) or endif_cpp.match(line)
return ifndef_cpp.match(line) or define_cpp.match(
line) or endif_cpp.match(line) or pragma_once_cpp.match(line)
def get_revision():
return os.popen('git rev-parse --short HEAD').read().strip()
return os.popen('git rev-parse --short HEAD').read().strip()
def get_version():
return os.popen('git describe --tags --abbrev=0').read().strip()
return os.popen('git describe --tags --abbrev=0').read().strip()
def process_file(filename, out):
global includes
filename = os.path.normpath(filename)
relativefilename = filename.replace(script_path + os.sep, "").replace("\\", "/")
global includes
filename = os.path.normpath(filename)
relativefilename = filename.replace(script_path + os.sep, "").replace(
"\\", "/")
if filename in includes:
return
if filename in includes:
return
includes.add(filename)
includes.add(filename)
if not args.quiet:
print('processing {}'.format(filename))
out.write('// beginning of {}\n\n'.format(relativefilename))
empty_line_state = True
if not args.quiet:
print('processing {}'.format(filename))
with open(filename, 'r', encoding='utf-8') as f:
for line in f:
# skip comments
if line.startswith('//'):
continue
out.write('// beginning of {}\n\n'.format(relativefilename))
empty_line_state = True
# skip include guard non-sense
if is_include_guard(line):
continue
with open(filename, 'r', encoding='utf-8') as f:
for line in f:
# skip comments
if line.startswith('//'):
continue
# get relative directory
base_path = os.path.dirname(filename)
# skip include guard non-sense
if is_include_guard(line):
continue
# check if it's a standard file
std = standard_include.search(line)
if std:
std_file = os.path.join('std', std.group(0))
if std_file in includes:
continue
includes.add(std_file)
# get relative directory
base_path = os.path.dirname(filename)
# see if it's an include file
name = get_include(line, base_path)
# check if it's a standard file
std = standard_include.search(line)
if std:
std_file = os.path.join('std', std.group(0))
if std_file in includes:
continue
includes.add(std_file)
if name:
process_file(name, out)
continue
# see if it's an include file
name = get_include(line, base_path)
empty_line = len(line.strip()) == 0
if name:
process_file(name, out)
continue
if empty_line and empty_line_state:
continue
empty_line = len(line.strip()) == 0
empty_line_state = empty_line
if empty_line and empty_line_state:
continue
# line is fine
out.write(line)
empty_line_state = empty_line
out.write('// end of {}\n\n'.format(relativefilename))
# line is fine
out.write(line)
out.write('// end of {}\n\n'.format(relativefilename))
version = get_version()
@ -153,49 +177,61 @@ include_guard = 'SOL_SINGLE_INCLUDE_HPP'
forward_include_guard = 'SOL_SINGLE_INCLUDE_FORWARD_HPP'
processed_files = [os.path.join(script_path, x) for x in ['sol.hpp']]
forward_processed_files = [os.path.join(script_path, x) for x in ['sol/forward.hpp']]
forward_processed_files = [
os.path.join(script_path, x) for x in ['sol/forward.hpp']
]
result = ''
forward_result = ''
if not args.quiet:
print('Current version: {version} (revision {revision})\n'.format(version = version, revision = revision))
print('Creating single header for sol')
print('Current version: {version} (revision {revision})\n'.format(
version=version, revision=revision))
print('Creating single header for sol')
ss = StringIO()
ss.write(intro.format(time=dt.datetime.utcnow(), revision=revision, version=version, guard=include_guard))
ss.write(
intro.format(
time=dt.datetime.utcnow(),
revision=revision,
version=version,
guard=include_guard))
for processed_file in processed_files:
process_file(processed_file, ss)
process_file(processed_file, ss)
ss.write('#endif // {}\n'.format(include_guard))
result = ss.getvalue()
ss.close()
if not args.quiet:
print('finished creating single header for sol\n')
print('finished creating single header for sol\n')
if not args.quiet:
print('Creating single forward declaration header for sol')
print('Creating single forward declaration header for sol')
includes = set([])
forward_ss = StringIO()
forward_ss.write(intro.format(time=dt.datetime.utcnow(), revision=revision, version=version, guard=forward_include_guard))
forward_ss.write(
intro.format(
time=dt.datetime.utcnow(),
revision=revision,
version=version,
guard=forward_include_guard))
for forward_processed_file in forward_processed_files:
process_file(forward_processed_file, forward_ss)
process_file(forward_processed_file, forward_ss)
forward_ss.write('#endif // {}\n'.format(forward_include_guard))
forward_result = forward_ss.getvalue()
forward_ss.close()
if not args.quiet:
print('finished creating single forward declaration header for sol\n')
print('finished creating single forward declaration header for sol\n')
with open(single_file, 'w', encoding='utf-8') as f:
if not args.quiet:
print('writing {}...'.format(single_file))
f.write(result)
if not args.quiet:
print('writing {}...'.format(single_file))
f.write(result)
with open(forward_single_file, 'w', encoding='utf-8') as f:
if not args.quiet:
print('writing {}...'.format(forward_single_file))
f.write(forward_result)
if not args.quiet:
print('writing {}...'.format(forward_single_file))
f.write(forward_result)

14
sol.hpp
View File

@ -23,24 +23,24 @@
#define SOL_HPP
#if defined(UE_BUILD_DEBUG) || defined(UE_BUILD_DEVELOPMENT) || defined(UE_BUILD_TEST) || defined(UE_BUILD_SHIPPING) || defined(UE_SERVER)
#define SOL_INSIDE_UNREAL
#define SOL_INSIDE_UNREAL 1
#endif // Unreal Engine 4 bullshit
#ifdef SOL_INSIDE_UNREAL
#if defined(SOL_INSIDE_UNREAL) && SOL_INSIDE_UNREAL
#ifdef check
#define SOL_INSIDE_UNREAL_REMOVED_CHECK
#undef check
#endif
#endif // Unreal Engine 4 Bullshit
#ifdef __GNUC__
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#pragma GCC diagnostic ignored "-Wconversion"
#if __GNUC__ > 6
#pragma GCC diagnostic ignored "-Wnoexcept-type"
#endif
#elif defined __clang__
#elif defined(__clang__)
// we'll just let this alone for now
#elif defined _MSC_VER
#pragma warning( push )
@ -61,14 +61,14 @@
#include "sol/variadic_args.hpp"
#include "sol/variadic_results.hpp"
#ifdef __GNUC__
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#elif defined _MSC_VER
#pragma warning( push )
#endif // g++
#ifdef SOL_INSIDE_UNREAL
#ifdef SOL_INSIDE_UNREAL_REMOVED_CHECK
#if defined(SOL_INSIDE_UNREAL) && SOL_INSIDE_UNREAL
#if defined(SOL_INSIDE_UNREAL_REMOVED_CHECK) && SOL_INSIDE_UNREAL_REMOVED_CHECK
#if DO_CHECK
#define check(expr) { if(UNLIKELY(!(expr))) { FDebug::LogAssertFailedMessage( #expr, __FILE__, __LINE__ ); _DebugBreakAndPromptForRemote(); FDebug::AssertFailed( #expr, __FILE__, __LINE__ ); CA_ASSUME(false); } }
#else

View File

@ -200,7 +200,7 @@ namespace meta {
typedef R (T::*function_pointer_type)(Args..., ...) const volatile&&;
};
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE
#if defined(SOL_NOEXCEPT_FUNCTION_TYPE) && SOL_NOEXCEPT_FUNCTION_TYPE
template <typename R, typename... Args>
struct fx_traits<R(Args...) noexcept, false> : basic_traits<true, false, void, R, Args...> {
@ -373,7 +373,7 @@ namespace meta {
typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile&&;
};
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE
#if defined(SOL_NOEXCEPT_FUNCTION_TYPE) && SOL_NOEXCEPT_FUNCTION_TYPE
template <typename R, typename... Args>
struct fx_traits<R __stdcall(Args...) noexcept, false> : basic_traits<true, false, void, R, Args...> {

View File

@ -314,7 +314,7 @@ namespace sol {
}
};
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE
#if defined(SOL_NOEXCEPT_FUNCTION_TYPE) && SOL_NOEXCEPT_FUNCTION_TYPE
template <bool is_index, bool is_variable, bool checked, int boost, bool clean_stack, typename C>
struct agnostic_lua_call_wrapper<detail::lua_CFunction_noexcept, is_index, is_variable, checked, boost, clean_stack, C> {
static int call(lua_State* L, detail::lua_CFunction_noexcept f) {
@ -371,7 +371,7 @@ namespace sol {
template <typename Fx>
static int call(lua_State* L, Fx&& f) {
typedef std::conditional_t<std::is_void<T>::value, object_type, T> Ta;
#ifdef SOL_SAFE_USERTYPE
#if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE
auto maybeo = stack::check_get<Ta*>(L, 1);
if (!maybeo || maybeo.value() == nullptr) {
return luaL_error(L, "sol: received nil for 'self' argument (use ':' for accessing member functions, make sure member variables are preceeded by the actual object with '.' syntax)");
@ -401,7 +401,7 @@ namespace sol {
template <typename V>
static int call_assign(std::true_type, lua_State* L, V&& f) {
typedef std::conditional_t<std::is_void<T>::value, object_type, T> Ta;
#ifdef SOL_SAFE_USERTYPE
#if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE
auto maybeo = stack::check_get<Ta*>(L, 1);
if (!maybeo || maybeo.value() == nullptr) {
if (is_variable) {
@ -461,7 +461,7 @@ namespace sol {
template <typename V>
static int call(lua_State* L, V&& f) {
typedef std::conditional_t<std::is_void<T>::value, object_type, T> Ta;
#ifdef SOL_SAFE_USERTYPE
#if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE
auto maybeo = stack::check_get<Ta*>(L, 1);
if (!maybeo || maybeo.value() == nullptr) {
if (is_variable) {
@ -642,7 +642,7 @@ namespace sol {
typedef meta::pop_front_type_t<typename traits_type::free_args_list> args_list;
typedef T Ta;
typedef std::remove_pointer_t<object_type> Oa;
#ifdef SOL_SAFE_USERTYPE
#if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE
auto maybeo = stack::check_get<Ta*>(L, 1);
if (!maybeo || maybeo.value() == nullptr) {
if (is_variable) {

View File

@ -32,15 +32,17 @@
#include "feature_test.hpp"
#include "compatibility/version.hpp"
#ifndef SOL_NO_COMPAT
#if !defined(SOL_NO_COMPAT) || !(SOL_NO_COMPAT)
#if defined(SOL_USING_CXX_LUA)
#if defined(SOL_USING_CXX_LUA) && SOL_USING_CXX_LUA
#ifndef COMPAT53_LUA_CPP
#define COMPAT53_LUA_CPP 1
#endif // Build Lua Compat layer as C++
#endif
#endif
#include "compatibility//compat-5.3.h"
#ifndef COMPAT53_INCLUDE_SOURCE
#define COMPAT53_INCLUDE_SOURCE 1
#endif // Build Compat Layer Inline
#include "compatibility/compat-5.3.h"
#endif // SOL_NO_COMPAT

File diff suppressed because it is too large Load Diff

View File

@ -1,420 +1,421 @@
#ifndef COMPAT53_H_
#define COMPAT53_H_
#include <stddef.h>
#include <limits.h>
#include <string.h>
#if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP)
extern "C" {
#endif
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP)
}
#endif
#undef COMPAT53_INCLUDE_SOURCE
#if defined(COMPAT53_PREFIX)
/* - change the symbol names of functions to avoid linker conflicts
* - compat-5.3.c needs to be compiled (and linked) separately
*/
# if !defined(COMPAT53_API)
# define COMPAT53_API extern
# endif
#else /* COMPAT53_PREFIX */
/* - make all functions static and include the source.
* - compat-5.3.c doesn't need to be compiled (and linked) separately
*/
# define COMPAT53_PREFIX compat53
# undef COMPAT53_API
# if defined(__GNUC__) || defined(__clang__)
# define COMPAT53_API __attribute__((__unused__)) static
# else
# define COMPAT53_API static
# endif
# define COMPAT53_INCLUDE_SOURCE
#endif /* COMPAT53_PREFIX */
#define COMPAT53_CONCAT_HELPER(a, b) a##b
#define COMPAT53_CONCAT(a, b) COMPAT53_CONCAT_HELPER(a, b)
/* declarations for Lua 5.1 */
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 501
/* XXX not implemented:
* lua_arith (new operators)
* lua_upvalueid
* lua_upvaluejoin
* lua_version
* lua_yieldk
*/
#ifndef LUA_OK
# define LUA_OK 0
#endif
#ifndef LUA_OPADD
# define LUA_OPADD 0
#endif
#ifndef LUA_OPSUB
# define LUA_OPSUB 1
#endif
#ifndef LUA_OPMUL
# define LUA_OPMUL 2
#endif
#ifndef LUA_OPDIV
# define LUA_OPDIV 3
#endif
#ifndef LUA_OPMOD
# define LUA_OPMOD 4
#endif
#ifndef LUA_OPPOW
# define LUA_OPPOW 5
#endif
#ifndef LUA_OPUNM
# define LUA_OPUNM 6
#endif
#ifndef LUA_OPEQ
# define LUA_OPEQ 0
#endif
#ifndef LUA_OPLT
# define LUA_OPLT 1
#endif
#ifndef LUA_OPLE
# define LUA_OPLE 2
#endif
/* LuaJIT/Lua 5.1 does not have the updated
* error codes for thread status/function returns (but some patched versions do)
* define it only if it's not found
*/
#if !defined(LUA_ERRGCMM)
/* Use + 2 because in some versions of Lua (Lua 5.1)
* LUA_ERRFILE is defined as (LUA_ERRERR+1)
* so we need to avoid it (LuaJIT might have something at this
* integer value too)
*/
# define LUA_ERRGCMM (LUA_ERRERR + 2)
#endif /* LUA_ERRGCMM define */
typedef size_t lua_Unsigned;
typedef struct luaL_Buffer_53 {
luaL_Buffer b; /* make incorrect code crash! */
char *ptr;
size_t nelems;
size_t capacity;
lua_State *L2;
} luaL_Buffer_53;
#define luaL_Buffer luaL_Buffer_53
/* In PUC-Rio 5.1, userdata is a simple FILE*
* In LuaJIT, it's a struct where the first member is a FILE*
* We can't support the `closef` member
*/
typedef struct luaL_Stream {
FILE *f;
} luaL_Stream;
#define lua_absindex COMPAT53_CONCAT(COMPAT53_PREFIX, _absindex)
COMPAT53_API int lua_absindex (lua_State *L, int i);
#define lua_arith COMPAT53_CONCAT(COMPAT53_PREFIX, _arith)
COMPAT53_API void lua_arith (lua_State *L, int op);
#define lua_compare COMPAT53_CONCAT(COMPAT53_PREFIX, _compare)
COMPAT53_API int lua_compare (lua_State *L, int idx1, int idx2, int op);
#define lua_copy COMPAT53_CONCAT(COMPAT53_PREFIX, _copy)
COMPAT53_API void lua_copy (lua_State *L, int from, int to);
#define lua_getuservalue(L, i) \
(lua_getfenv((L), (i)), lua_type((L), -1))
#define lua_setuservalue(L, i) \
(luaL_checktype((L), -1, LUA_TTABLE), lua_setfenv((L), (i)))
#define lua_len COMPAT53_CONCAT(COMPAT53_PREFIX, _len)
COMPAT53_API void lua_len (lua_State *L, int i);
#define lua_pushstring(L, s) \
(lua_pushstring((L), (s)), lua_tostring((L), -1))
#define lua_pushlstring(L, s, len) \
((((len) == 0) ? lua_pushlstring((L), "", 0) : lua_pushlstring((L), (s), (len))), lua_tostring((L), -1))
#ifndef luaL_newlibtable
# define luaL_newlibtable(L, l) \
(lua_createtable((L), 0, sizeof((l))/sizeof(*(l))-1))
#endif
#ifndef luaL_newlib
# define luaL_newlib(L, l) \
(luaL_newlibtable((L), (l)), luaL_register((L), NULL, (l)))
#endif
#define lua_pushglobaltable(L) \
lua_pushvalue((L), LUA_GLOBALSINDEX)
#define lua_rawgetp COMPAT53_CONCAT(COMPAT53_PREFIX, _rawgetp)
COMPAT53_API int lua_rawgetp (lua_State *L, int i, const void *p);
#define lua_rawsetp COMPAT53_CONCAT(COMPAT53_PREFIX, _rawsetp)
COMPAT53_API void lua_rawsetp(lua_State *L, int i, const void *p);
#define lua_rawlen(L, i) lua_objlen((L), (i))
#define lua_tointegerx COMPAT53_CONCAT(COMPAT53_PREFIX, _tointegerx)
COMPAT53_API lua_Integer lua_tointegerx (lua_State *L, int i, int *isnum);
#define lua_tonumberx COMPAT53_CONCAT(COMPAT53_PREFIX, _tonumberx)
COMPAT53_API lua_Number lua_tonumberx (lua_State *L, int i, int *isnum);
#define luaL_checkversion COMPAT53_CONCAT(COMPAT53_PREFIX, L_checkversion)
COMPAT53_API void luaL_checkversion (lua_State *L);
#define lua_load COMPAT53_CONCAT(COMPAT53_PREFIX, _load_53)
COMPAT53_API int lua_load (lua_State *L, lua_Reader reader, void *data, const char* source, const char* mode);
#define luaL_loadfilex COMPAT53_CONCAT(COMPAT53_PREFIX, L_loadfilex)
COMPAT53_API int luaL_loadfilex (lua_State *L, const char *filename, const char *mode);
#define luaL_loadbufferx COMPAT53_CONCAT(COMPAT53_PREFIX, L_loadbufferx)
COMPAT53_API int luaL_loadbufferx (lua_State *L, const char *buff, size_t sz, const char *name, const char *mode);
#define luaL_checkstack COMPAT53_CONCAT(COMPAT53_PREFIX, L_checkstack_53)
COMPAT53_API void luaL_checkstack (lua_State *L, int sp, const char *msg);
#define luaL_getsubtable COMPAT53_CONCAT(COMPAT53_PREFIX, L_getsubtable)
COMPAT53_API int luaL_getsubtable (lua_State* L, int i, const char *name);
#define luaL_len COMPAT53_CONCAT(COMPAT53_PREFIX, L_len)
COMPAT53_API lua_Integer luaL_len (lua_State *L, int i);
#define luaL_setfuncs COMPAT53_CONCAT(COMPAT53_PREFIX, L_setfuncs)
COMPAT53_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);
#define luaL_setmetatable COMPAT53_CONCAT(COMPAT53_PREFIX, L_setmetatable)
COMPAT53_API void luaL_setmetatable (lua_State *L, const char *tname);
#define luaL_testudata COMPAT53_CONCAT(COMPAT53_PREFIX, L_testudata)
COMPAT53_API void *luaL_testudata (lua_State *L, int i, const char *tname);
#define luaL_traceback COMPAT53_CONCAT(COMPAT53_PREFIX, L_traceback)
COMPAT53_API void luaL_traceback (lua_State *L, lua_State *L1, const char *msg, int level);
#define luaL_fileresult COMPAT53_CONCAT(COMPAT53_PREFIX, L_fileresult)
COMPAT53_API int luaL_fileresult (lua_State *L, int stat, const char *fname);
#define luaL_execresult COMPAT53_CONCAT(COMPAT53_PREFIX, L_execresult)
COMPAT53_API int luaL_execresult (lua_State *L, int stat);
#define lua_callk(L, na, nr, ctx, cont) \
((void)(ctx), (void)(cont), lua_call((L), (na), (nr)))
#define lua_pcallk(L, na, nr, err, ctx, cont) \
((void)(ctx), (void)(cont), lua_pcall((L), (na), (nr), (err)))
#define lua_resume(L, from, nargs) \
((void)(from), lua_resume((L), (nargs)))
#define luaL_buffinit COMPAT53_CONCAT(COMPAT53_PREFIX, _buffinit_53)
COMPAT53_API void luaL_buffinit (lua_State *L, luaL_Buffer_53 *B);
#define luaL_prepbuffsize COMPAT53_CONCAT(COMPAT53_PREFIX, _prepbufsize_53)
COMPAT53_API char *luaL_prepbuffsize (luaL_Buffer_53 *B, size_t s);
#define luaL_addlstring COMPAT53_CONCAT(COMPAT53_PREFIX, _addlstring_53)
COMPAT53_API void luaL_addlstring (luaL_Buffer_53 *B, const char *s, size_t l);
#define luaL_addvalue COMPAT53_CONCAT(COMPAT53_PREFIX, _addvalue_53)
COMPAT53_API void luaL_addvalue (luaL_Buffer_53 *B);
#define luaL_pushresult COMPAT53_CONCAT(COMPAT53_PREFIX, _pushresult_53)
COMPAT53_API void luaL_pushresult (luaL_Buffer_53 *B);
#undef luaL_buffinitsize
#define luaL_buffinitsize(L, B, s) \
(luaL_buffinit((L), (B)), luaL_prepbuffsize((B), (s)))
#undef luaL_prepbuffer
#define luaL_prepbuffer(B) \
luaL_prepbuffsize((B), LUAL_BUFFERSIZE)
#undef luaL_addchar
#define luaL_addchar(B, c) \
((void)((B)->nelems < (B)->capacity || luaL_prepbuffsize((B), 1)), \
((B)->ptr[(B)->nelems++] = (c)))
#undef luaL_addsize
#define luaL_addsize(B, s) \
((B)->nelems += (s))
#undef luaL_addstring
#define luaL_addstring(B, s) \
luaL_addlstring((B), (s), strlen((s)))
#undef luaL_pushresultsize
#define luaL_pushresultsize(B, s) \
(luaL_addsize((B), (s)), luaL_pushresult((B)))
#if defined(LUA_COMPAT_APIINTCASTS)
#define lua_pushunsigned(L, n) \
lua_pushinteger((L), (lua_Integer)(n))
#define lua_tounsignedx(L, i, is) \
((lua_Unsigned)lua_tointegerx((L), (i), (is)))
#define lua_tounsigned(L, i) \
lua_tounsignedx((L), (i), NULL)
#define luaL_checkunsigned(L, a) \
((lua_Unsigned)luaL_checkinteger((L), (a)))
#define luaL_optunsigned(L, a, d) \
((lua_Unsigned)luaL_optinteger((L), (a), (lua_Integer)(d)))
#endif
#endif /* Lua 5.1 only */
/* declarations for Lua 5.1 and 5.2 */
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM <= 502
typedef int lua_KContext;
typedef int (*lua_KFunction)(lua_State *L, int status, lua_KContext ctx);
#define lua_dump(L, w, d, s) \
((void)(s), lua_dump((L), (w), (d)))
#define lua_getfield(L, i, k) \
(lua_getfield((L), (i), (k)), lua_type((L), -1))
#define lua_gettable(L, i) \
(lua_gettable((L), (i)), lua_type((L), -1))
#define lua_geti COMPAT53_CONCAT(COMPAT53_PREFIX, _geti)
COMPAT53_API int lua_geti (lua_State *L, int index, lua_Integer i);
#define lua_isinteger COMPAT53_CONCAT(COMPAT53_PREFIX, _isinteger)
COMPAT53_API int lua_isinteger (lua_State *L, int index);
#define lua_numbertointeger(n, p) \
((*(p) = (lua_Integer)(n)), 1)
#define lua_rawget(L, i) \
(lua_rawget((L), (i)), lua_type((L), -1))
#define lua_rawgeti(L, i, n) \
(lua_rawgeti((L), (i), (n)), lua_type((L), -1))
#define lua_rotate COMPAT53_CONCAT(COMPAT53_PREFIX, _rotate)
COMPAT53_API void lua_rotate (lua_State *L, int idx, int n);
#define lua_seti COMPAT53_CONCAT(COMPAT53_PREFIX, _seti)
COMPAT53_API void lua_seti (lua_State *L, int index, lua_Integer i);
#define lua_stringtonumber COMPAT53_CONCAT(COMPAT53_PREFIX, _stringtonumber)
COMPAT53_API size_t lua_stringtonumber (lua_State *L, const char *s);
#define luaL_tolstring COMPAT53_CONCAT(COMPAT53_PREFIX, L_tolstring)
COMPAT53_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len);
#define luaL_getmetafield(L, o, e) \
(luaL_getmetafield((L), (o), (e)) ? lua_type((L), -1) : LUA_TNIL)
#define luaL_newmetatable(L, tn) \
(luaL_newmetatable((L), (tn)) ? (lua_pushstring((L), (tn)), lua_setfield((L), -2, "__name"), 1) : 0)
#define luaL_requiref COMPAT53_CONCAT(COMPAT53_PREFIX, L_requiref_53)
COMPAT53_API void luaL_requiref (lua_State *L, const char *modname,
lua_CFunction openf, int glb );
#endif /* Lua 5.1 and Lua 5.2 */
/* declarations for Lua 5.2 */
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 502
/* XXX not implemented:
* lua_isyieldable
* lua_getextraspace
* lua_arith (new operators)
* lua_pushfstring (new formats)
*/
#define lua_getglobal(L, n) \
(lua_getglobal((L), (n)), lua_type((L), -1))
#define lua_getuservalue(L, i) \
(lua_getuservalue((L), (i)), lua_type((L), -1))
#define lua_pushlstring(L, s, len) \
(((len) == 0) ? lua_pushlstring((L), "", 0) : lua_pushlstring((L), (s), (len)))
#define lua_rawgetp(L, i, p) \
(lua_rawgetp((L), (i), (p)), lua_type((L), -1))
#define LUA_KFUNCTION(_name) \
static int (_name)(lua_State *L, int status, lua_KContext ctx); \
static int (_name ## _52)(lua_State *L) { \
lua_KContext ctx; \
int status = lua_getctx(L, &ctx); \
return (_name)(L, status, ctx); \
} \
static int (_name)(lua_State *L, int status, lua_KContext ctx)
#define lua_pcallk(L, na, nr, err, ctx, cont) \
lua_pcallk((L), (na), (nr), (err), (ctx), cont ## _52)
#define lua_callk(L, na, nr, ctx, cont) \
lua_callk((L), (na), (nr), (ctx), cont ## _52)
#define lua_yieldk(L, nr, ctx, cont) \
lua_yieldk((L), (nr), (ctx), cont ## _52)
#ifdef lua_call
# undef lua_call
# define lua_call(L, na, nr) \
(lua_callk)((L), (na), (nr), 0, NULL)
#endif
#ifdef lua_pcall
# undef lua_pcall
# define lua_pcall(L, na, nr, err) \
(lua_pcallk)((L), (na), (nr), (err), 0, NULL)
#endif
#ifdef lua_yield
# undef lua_yield
# define lua_yield(L, nr) \
(lua_yieldk)((L), (nr), 0, NULL)
#endif
#endif /* Lua 5.2 only */
/* other Lua versions */
#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 || LUA_VERSION_NUM > 503
# error "unsupported Lua version (i.e. not Lua 5.1, 5.2, or 5.3)"
#endif /* other Lua versions except 5.1, 5.2, and 5.3 */
/* helper macro for defining continuation functions (for every version
* *except* Lua 5.2) */
#ifndef LUA_KFUNCTION
#define LUA_KFUNCTION(_name) \
static int (_name)(lua_State *L, int status, lua_KContext ctx)
#endif
#if defined(COMPAT53_INCLUDE_SOURCE)
# include "compat-5.3.c"
#endif
#endif /* COMPAT53_H_ */
#ifndef KEPLER_PROJECT_COMPAT53_H_
#define KEPLER_PROJECT_COMPAT53_H_
#include <stddef.h>
#include <limits.h>
#include <string.h>
#if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP)
extern "C" {
#endif
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#if defined(__cplusplus) && !defined(COMPAT53_LUA_CPP)
}
#endif
#ifndef COMPAT53_PREFIX
/* we chose this name because many other lua bindings / libs have
* their own compatibility layer, and that use the compat53 declaration
* frequently, causing all kinds of linker / compiler issues
*/
# define COMPAT53_PREFIX kp_compat53
#endif // COMPAT53_PREFIX
#ifndef COMPAT53_API
# if defined(COMPAT53_INCLUDE_SOURCE) && COMPAT53_INCLUDE_SOURCE
# if defined(__GNUC__) || defined(__clang__)
# define COMPAT53_API __attribute__((__unused__)) static
# else
# define COMPAT53_API static
# endif /* Clang/GCC */
# else /* COMPAT53_INCLUDE_SOURCE */
/* we are not including source, so everything is extern */
# define COMPAT53_API extern
# endif /* COMPAT53_INCLUDE_SOURCE */
#endif /* COMPAT53_PREFIX */
#define COMPAT53_CONCAT_HELPER(a, b) a##b
#define COMPAT53_CONCAT(a, b) COMPAT53_CONCAT_HELPER(a, b)
/* declarations for Lua 5.1 */
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 501
/* XXX not implemented:
* lua_arith (new operators)
* lua_upvalueid
* lua_upvaluejoin
* lua_version
* lua_yieldk
*/
#ifndef LUA_OK
# define LUA_OK 0
#endif
#ifndef LUA_OPADD
# define LUA_OPADD 0
#endif
#ifndef LUA_OPSUB
# define LUA_OPSUB 1
#endif
#ifndef LUA_OPMUL
# define LUA_OPMUL 2
#endif
#ifndef LUA_OPDIV
# define LUA_OPDIV 3
#endif
#ifndef LUA_OPMOD
# define LUA_OPMOD 4
#endif
#ifndef LUA_OPPOW
# define LUA_OPPOW 5
#endif
#ifndef LUA_OPUNM
# define LUA_OPUNM 6
#endif
#ifndef LUA_OPEQ
# define LUA_OPEQ 0
#endif
#ifndef LUA_OPLT
# define LUA_OPLT 1
#endif
#ifndef LUA_OPLE
# define LUA_OPLE 2
#endif
/* LuaJIT/Lua 5.1 does not have the updated
* error codes for thread status/function returns (but some patched versions do)
* define it only if it's not found
*/
#if !defined(LUA_ERRGCMM)
/* Use + 2 because in some versions of Lua (Lua 5.1)
* LUA_ERRFILE is defined as (LUA_ERRERR+1)
* so we need to avoid it (LuaJIT might have something at this
* integer value too)
*/
# define LUA_ERRGCMM (LUA_ERRERR + 2)
#endif /* LUA_ERRGCMM define */
typedef size_t lua_Unsigned;
typedef struct luaL_Buffer_53 {
luaL_Buffer b; /* make incorrect code crash! */
char *ptr;
size_t nelems;
size_t capacity;
lua_State *L2;
} luaL_Buffer_53;
#define luaL_Buffer luaL_Buffer_53
/* In PUC-Rio 5.1, userdata is a simple FILE*
* In LuaJIT, it's a struct where the first member is a FILE*
* We can't support the `closef` member
*/
typedef struct luaL_Stream {
FILE *f;
} luaL_Stream;
#define lua_absindex COMPAT53_CONCAT(COMPAT53_PREFIX, _absindex)
COMPAT53_API int lua_absindex(lua_State *L, int i);
#define lua_arith COMPAT53_CONCAT(COMPAT53_PREFIX, _arith)
COMPAT53_API void lua_arith(lua_State *L, int op);
#define lua_compare COMPAT53_CONCAT(COMPAT53_PREFIX, _compare)
COMPAT53_API int lua_compare(lua_State *L, int idx1, int idx2, int op);
#define lua_copy COMPAT53_CONCAT(COMPAT53_PREFIX, _copy)
COMPAT53_API void lua_copy(lua_State *L, int from, int to);
#define lua_getuservalue(L, i) \
(lua_getfenv((L), (i)), lua_type((L), -1))
#define lua_setuservalue(L, i) \
(luaL_checktype((L), -1, LUA_TTABLE), lua_setfenv((L), (i)))
#define lua_len COMPAT53_CONCAT(COMPAT53_PREFIX, _len)
COMPAT53_API void lua_len(lua_State *L, int i);
#define lua_pushstring(L, s) \
(lua_pushstring((L), (s)), lua_tostring((L), -1))
#define lua_pushlstring(L, s, len) \
((((len) == 0) ? lua_pushlstring((L), "", 0) : lua_pushlstring((L), (s), (len))), lua_tostring((L), -1))
#ifndef luaL_newlibtable
# define luaL_newlibtable(L, l) \
(lua_createtable((L), 0, sizeof((l))/sizeof(*(l))-1))
#endif
#ifndef luaL_newlib
# define luaL_newlib(L, l) \
(luaL_newlibtable((L), (l)), luaL_register((L), NULL, (l)))
#endif
#define lua_pushglobaltable(L) \
lua_pushvalue((L), LUA_GLOBALSINDEX)
#define lua_rawgetp COMPAT53_CONCAT(COMPAT53_PREFIX, _rawgetp)
COMPAT53_API int lua_rawgetp(lua_State *L, int i, const void *p);
#define lua_rawsetp COMPAT53_CONCAT(COMPAT53_PREFIX, _rawsetp)
COMPAT53_API void lua_rawsetp(lua_State *L, int i, const void *p);
#define lua_rawlen(L, i) lua_objlen((L), (i))
#define lua_tointeger(L, i) lua_tointegerx((L), (i), NULL)
#define lua_tonumberx COMPAT53_CONCAT(COMPAT53_PREFIX, _tonumberx)
COMPAT53_API lua_Number lua_tonumberx(lua_State *L, int i, int *isnum);
#define luaL_checkversion COMPAT53_CONCAT(COMPAT53_PREFIX, L_checkversion)
COMPAT53_API void luaL_checkversion(lua_State *L);
#define lua_load COMPAT53_CONCAT(COMPAT53_PREFIX, _load_53)
COMPAT53_API int lua_load(lua_State *L, lua_Reader reader, void *data, const char* source, const char* mode);
#define luaL_loadfilex COMPAT53_CONCAT(COMPAT53_PREFIX, L_loadfilex)
COMPAT53_API int luaL_loadfilex(lua_State *L, const char *filename, const char *mode);
#define luaL_loadbufferx COMPAT53_CONCAT(COMPAT53_PREFIX, L_loadbufferx)
COMPAT53_API int luaL_loadbufferx(lua_State *L, const char *buff, size_t sz, const char *name, const char *mode);
#define luaL_checkstack COMPAT53_CONCAT(COMPAT53_PREFIX, L_checkstack_53)
COMPAT53_API void luaL_checkstack(lua_State *L, int sp, const char *msg);
#define luaL_getsubtable COMPAT53_CONCAT(COMPAT53_PREFIX, L_getsubtable)
COMPAT53_API int luaL_getsubtable(lua_State* L, int i, const char *name);
#define luaL_len COMPAT53_CONCAT(COMPAT53_PREFIX, L_len)
COMPAT53_API lua_Integer luaL_len(lua_State *L, int i);
#define luaL_setfuncs COMPAT53_CONCAT(COMPAT53_PREFIX, L_setfuncs)
COMPAT53_API void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup);
#define luaL_setmetatable COMPAT53_CONCAT(COMPAT53_PREFIX, L_setmetatable)
COMPAT53_API void luaL_setmetatable(lua_State *L, const char *tname);
#define luaL_testudata COMPAT53_CONCAT(COMPAT53_PREFIX, L_testudata)
COMPAT53_API void *luaL_testudata(lua_State *L, int i, const char *tname);
#define luaL_traceback COMPAT53_CONCAT(COMPAT53_PREFIX, L_traceback)
COMPAT53_API void luaL_traceback(lua_State *L, lua_State *L1, const char *msg, int level);
#define luaL_fileresult COMPAT53_CONCAT(COMPAT53_PREFIX, L_fileresult)
COMPAT53_API int luaL_fileresult(lua_State *L, int stat, const char *fname);
#define luaL_execresult COMPAT53_CONCAT(COMPAT53_PREFIX, L_execresult)
COMPAT53_API int luaL_execresult(lua_State *L, int stat);
#define lua_callk(L, na, nr, ctx, cont) \
((void)(ctx), (void)(cont), lua_call((L), (na), (nr)))
#define lua_pcallk(L, na, nr, err, ctx, cont) \
((void)(ctx), (void)(cont), lua_pcall((L), (na), (nr), (err)))
#define lua_resume(L, from, nargs) \
((void)(from), lua_resume((L), (nargs)))
#define luaL_buffinit COMPAT53_CONCAT(COMPAT53_PREFIX, _buffinit_53)
COMPAT53_API void luaL_buffinit(lua_State *L, luaL_Buffer_53 *B);
#define luaL_prepbuffsize COMPAT53_CONCAT(COMPAT53_PREFIX, _prepbufsize_53)
COMPAT53_API char *luaL_prepbuffsize(luaL_Buffer_53 *B, size_t s);
#define luaL_addlstring COMPAT53_CONCAT(COMPAT53_PREFIX, _addlstring_53)
COMPAT53_API void luaL_addlstring(luaL_Buffer_53 *B, const char *s, size_t l);
#define luaL_addvalue COMPAT53_CONCAT(COMPAT53_PREFIX, _addvalue_53)
COMPAT53_API void luaL_addvalue(luaL_Buffer_53 *B);
#define luaL_pushresult COMPAT53_CONCAT(COMPAT53_PREFIX, _pushresult_53)
COMPAT53_API void luaL_pushresult(luaL_Buffer_53 *B);
#undef luaL_buffinitsize
#define luaL_buffinitsize(L, B, s) \
(luaL_buffinit((L), (B)), luaL_prepbuffsize((B), (s)))
#undef luaL_prepbuffer
#define luaL_prepbuffer(B) \
luaL_prepbuffsize((B), LUAL_BUFFERSIZE)
#undef luaL_addchar
#define luaL_addchar(B, c) \
((void)((B)->nelems < (B)->capacity || luaL_prepbuffsize((B), 1)), \
((B)->ptr[(B)->nelems++] = (c)))
#undef luaL_addsize
#define luaL_addsize(B, s) \
((B)->nelems += (s))
#undef luaL_addstring
#define luaL_addstring(B, s) \
luaL_addlstring((B), (s), strlen((s)))
#undef luaL_pushresultsize
#define luaL_pushresultsize(B, s) \
(luaL_addsize((B), (s)), luaL_pushresult((B)))
#if defined(LUA_COMPAT_APIINTCASTS)
#define lua_pushunsigned(L, n) \
lua_pushinteger((L), (lua_Integer)(n))
#define lua_tounsignedx(L, i, is) \
((lua_Unsigned)lua_tointegerx((L), (i), (is)))
#define lua_tounsigned(L, i) \
lua_tounsignedx((L), (i), NULL)
#define luaL_checkunsigned(L, a) \
((lua_Unsigned)luaL_checkinteger((L), (a)))
#define luaL_optunsigned(L, a, d) \
((lua_Unsigned)luaL_optinteger((L), (a), (lua_Integer)(d)))
#endif
#endif /* Lua 5.1 only */
/* declarations for Lua 5.1 and 5.2 */
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM <= 502
typedef int lua_KContext;
typedef int(*lua_KFunction)(lua_State *L, int status, lua_KContext ctx);
#define lua_dump(L, w, d, s) \
((void)(s), lua_dump((L), (w), (d)))
#define lua_getfield(L, i, k) \
(lua_getfield((L), (i), (k)), lua_type((L), -1))
#define lua_gettable(L, i) \
(lua_gettable((L), (i)), lua_type((L), -1))
#define lua_geti COMPAT53_CONCAT(COMPAT53_PREFIX, _geti)
COMPAT53_API int lua_geti(lua_State *L, int index, lua_Integer i);
#define lua_isinteger COMPAT53_CONCAT(COMPAT53_PREFIX, _isinteger)
COMPAT53_API int lua_isinteger(lua_State *L, int index);
#define lua_tointegerx COMPAT53_CONCAT(COMPAT53_PREFIX, _tointegerx_53)
COMPAT53_API lua_Integer lua_tointegerx(lua_State *L, int i, int *isnum);
#define lua_numbertointeger(n, p) \
((*(p) = (lua_Integer)(n)), 1)
#define lua_rawget(L, i) \
(lua_rawget((L), (i)), lua_type((L), -1))
#define lua_rawgeti(L, i, n) \
(lua_rawgeti((L), (i), (n)), lua_type((L), -1))
#define lua_rotate COMPAT53_CONCAT(COMPAT53_PREFIX, _rotate)
COMPAT53_API void lua_rotate(lua_State *L, int idx, int n);
#define lua_seti COMPAT53_CONCAT(COMPAT53_PREFIX, _seti)
COMPAT53_API void lua_seti(lua_State *L, int index, lua_Integer i);
#define lua_stringtonumber COMPAT53_CONCAT(COMPAT53_PREFIX, _stringtonumber)
COMPAT53_API size_t lua_stringtonumber(lua_State *L, const char *s);
#define luaL_tolstring COMPAT53_CONCAT(COMPAT53_PREFIX, L_tolstring)
COMPAT53_API const char *luaL_tolstring(lua_State *L, int idx, size_t *len);
#define luaL_getmetafield(L, o, e) \
(luaL_getmetafield((L), (o), (e)) ? lua_type((L), -1) : LUA_TNIL)
#define luaL_newmetatable(L, tn) \
(luaL_newmetatable((L), (tn)) ? (lua_pushstring((L), (tn)), lua_setfield((L), -2, "__name"), 1) : 0)
#define luaL_requiref COMPAT53_CONCAT(COMPAT53_PREFIX, L_requiref_53)
COMPAT53_API void luaL_requiref(lua_State *L, const char *modname,
lua_CFunction openf, int glb);
#endif /* Lua 5.1 and Lua 5.2 */
/* declarations for Lua 5.2 */
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 502
/* XXX not implemented:
* lua_isyieldable
* lua_getextraspace
* lua_arith (new operators)
* lua_pushfstring (new formats)
*/
#define lua_getglobal(L, n) \
(lua_getglobal((L), (n)), lua_type((L), -1))
#define lua_getuservalue(L, i) \
(lua_getuservalue((L), (i)), lua_type((L), -1))
#define lua_pushlstring(L, s, len) \
(((len) == 0) ? lua_pushlstring((L), "", 0) : lua_pushlstring((L), (s), (len)))
#define lua_rawgetp(L, i, p) \
(lua_rawgetp((L), (i), (p)), lua_type((L), -1))
#define LUA_KFUNCTION(_name) \
static int (_name)(lua_State *L, int status, lua_KContext ctx); \
static int (_name ## _52)(lua_State *L) { \
lua_KContext ctx; \
int status = lua_getctx(L, &ctx); \
return (_name)(L, status, ctx); \
} \
static int (_name)(lua_State *L, int status, lua_KContext ctx)
#define lua_pcallk(L, na, nr, err, ctx, cont) \
lua_pcallk((L), (na), (nr), (err), (ctx), cont ## _52)
#define lua_callk(L, na, nr, ctx, cont) \
lua_callk((L), (na), (nr), (ctx), cont ## _52)
#define lua_yieldk(L, nr, ctx, cont) \
lua_yieldk((L), (nr), (ctx), cont ## _52)
#ifdef lua_call
# undef lua_call
# define lua_call(L, na, nr) \
(lua_callk)((L), (na), (nr), 0, NULL)
#endif
#ifdef lua_pcall
# undef lua_pcall
# define lua_pcall(L, na, nr, err) \
(lua_pcallk)((L), (na), (nr), (err), 0, NULL)
#endif
#ifdef lua_yield
# undef lua_yield
# define lua_yield(L, nr) \
(lua_yieldk)((L), (nr), 0, NULL)
#endif
#endif /* Lua 5.2 only */
/* other Lua versions */
#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 || LUA_VERSION_NUM > 503
# error "unsupported Lua version (i.e. not Lua 5.1, 5.2, or 5.3)"
#endif /* other Lua versions except 5.1, 5.2, and 5.3 */
/* helper macro for defining continuation functions (for every version
* *except* Lua 5.2) */
#ifndef LUA_KFUNCTION
#define LUA_KFUNCTION(_name) \
static int (_name)(lua_State *L, int status, lua_KContext ctx)
#endif
#if defined(COMPAT53_INCLUDE_SOURCE) && COMPAT53_INCLUDE_SOURCE == 1
# include "compat-5.3.c"
#endif
#endif /* KEPLER_PROJECT_COMPAT53_H_ */

View File

@ -26,15 +26,15 @@
#include "../feature_test.hpp"
#if defined(SOL_USING_CXX_LUA)
#if defined(SOL_USING_CXX_LUA) && SOL_USING_CXX_LUA
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#ifdef SOL_USING_CXX_LUAJIT
#if defined(SOL_USING_CXX_LUAJIT) && SOL_USING_CXX_LUAJIT
#include <luajit.h>
#endif // C++ LuaJIT ... whatever that means
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) && !defined(SOL_EXCEPTIONS_ALWAYS_UNSAFE)
#define SOL_EXCEPTIONS_SAFE_PROPAGATION
#if (!defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) || !(SOL_EXCEPTIONS_SAFE_PROPAGATION)) && (!defined(SOL_EXCEPTIONS_ALWAYS_UNSAFE) || !(SOL_EXCEPTIONS_ALWAYS_UNSAFE))
#define SOL_EXCEPTIONS_SAFE_PROPAGATION 1
#endif // Exceptions can be propagated safely using C++-compiled Lua
#else
#include <lua.hpp>
@ -51,7 +51,7 @@
#define SOL_LUA_VERSION LUA_VERSION_NUM
#elif defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 501
#define SOL_LUA_VERSION LUA_VERSION_NUM
#elif !defined(LUA_VERSION_NUM)
#elif !defined(LUA_VERSION_NUM) || !(LUA_VERSION_NUM)
// Definitely 5.0
#define SOL_LUA_VERSION 500
#else

220
sol/config.hpp Normal file
View File

@ -0,0 +1,220 @@
// sol2
// The MIT License (MIT)
// Copyright (c) 2013-2018 Rapptz, ThePhD and contributors
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef SOL_CONFIG_HPP
#define SOL_CONFIG_HPP
#ifdef _MSC_VER
#if defined(_DEBUG) && !defined(NDEBUG)
#ifndef SOL_IN_DEBUG_DETECTED
#define SOL_IN_DEBUG_DETECTED 1
#endif
#endif // VC++ Debug macros
#ifndef _CPPUNWIND
#ifndef SOL_NO_EXCEPTIONS
#define SOL_NO_EXCEPTIONS 1
#endif
#endif // Automatic Exceptions
#ifndef _CPPRTTI
#ifndef SOL_NO_RTTI
#define SOL_NO_RTTI 1
#endif
#endif // Automatic RTTI
#elif defined(__GNUC__) || defined(__clang__)
#if !defined(NDEBUG) && !defined(__OPTIMIZE__)
#ifndef SOL_IN_DEBUG_DETECTED
#define SOL_IN_DEBUG_DETECTED 1
#endif
#endif // Not Debug && g++ optimizer flag
#ifndef __EXCEPTIONS
#ifndef SOL_NO_EXCEPTIONS
#define SOL_NO_EXCEPTIONS 1
#endif
#endif // No Exceptions
#ifndef __GXX_RTTI
#ifndef SOL_NO_RTII
#define SOL_NO_RTTI 1
#endif
#endif // No RTTI
#endif // vc++ || clang++/g++
// If this is defined, turn on all the safety checks automatically
#if defined(SOL_CHECK_ARGUMENTS) && SOL_CHECK_ARGUMENTS
// Checks low-level getter function
// (and thusly, affects nearly entire framework)
#if !defined(SOL_SAFE_GETTER)
#define SOL_SAFE_GETTER 1
#endif
// Checks access on usertype functions
// local my_obj = my_type.new()
// my_obj.my_member_function()
// -- bad syntax and crash
#if !defined(SOL_SAFE_USERTYPE)
#define SOL_SAFE_USERTYPE 1
#endif
// Checks sol::reference derived boundaries
// sol::function ref(L, 1);
// sol::userdata sref(L, 2);
#if !defined(SOL_SAFE_REFERENCES)
#define SOL_SAFE_REFERENCES 1
#endif
// Changes all typedefs of sol::function to point to the
// protected_function version, instead of unsafe_function
#if !defined(SOL_SAFE_FUNCTION)
#define SOL_SAFE_FUNCTION 1
#endif
// Checks function parameters and
// returns upon call into/from Lua
// local a = 1
// local b = "woof"
// my_c_function(a, b)
#if !defined(SOL_SAFE_FUNCTION_CALLS)
#define SOL_SAFE_FUNCTION_CALLS 1
#endif
// Checks conversions
// int v = lua["bark"];
// int v2 = my_sol_function();
#if !defined(SOL_SAFE_PROXIES)
#define SOL_SAFE_PROXIES 1
#endif
// Check overflowing number conversions
// for things like 64 bit integers that don't fit in a typical lua_Number
// for Lua 5.1 and 5.2
#if !defined(SOL_SAFE_NUMERICS)
#define SOL_SAFE_NUMERICS 1
#endif
// Turn off Number Precision Checks
// if this is defined, we do not do range
// checks on integers / unsigned integers that might
// be bigger than what Lua can represent
#if !defined(SOL_NO_CHECK_NUMBER_PRECISION)
// off by default
#define SOL_NO_CHECK_NUMBER_PRECISION 0
#endif
#endif // Turn on Safety for all if top-level macro is defined
// If we are in debug, turn on certain safety checks
#if defined(SOL_IN_DEBUG_DETECTED) && SOL_IN_DEBUG_DETECTED
#if !defined(SOL_SAFE_REFERENCES)
// Ensure that references are forcefully type-checked upon construction
#define SOL_SAFE_REFERENCES 1
#endif
// Safe usertypes checks for errors such as
// obj = my_type.new()
// obj.f() -- note the '.' instead of ':'
// usertypes should be safe no matter what
#if !defined(SOL_SAFE_USERTYPE)
#define SOL_SAFE_USERTYPE 1
#endif
#if !defined(SOL_SAFE_FUNCTION_CALLS)
// Function calls from Lua should be automatically safe in debug mode
#define SOL_SAFE_FUNCTION_CALLS 1
#endif
// Print any exceptions / errors that occur
// in debug mode to the default error stream / console
#if !defined(SOL_PRINT_ERRORS)
#define SOL_PRINT_ERRORS 1
#endif
#endif // DEBUG: Turn on all debug safety features for VC++ / g++ / clang++ and similar
// Print any exceptions / errors that occur
// This is normally off due to relying on
// <iostream> to get std::cerr / std::cout
// so it is only defined in debug modes
#if !defined(SOL_PRINT_ERRORS)
// off by default here
#define SOL_PRINT_ERRORS 0
#endif
// The default on_error handler should not throw/assert/print/abort,
// but simply pass the value through back to the user
// problematic due to not having a stable [[nodiscard]] attribute in C++11,
// off by default
#if !defined(SOL_DEFAULT_PASS_ON_ERROR)
// off by default here
#define SOL_DEFAULT_PASS_ON_ERROR 0
#endif
// Interop allows userdata from external systems
// with external memory layout and metatable names
// to be registered. It costs something to perform
// the checker / differentiation for sol2 usertypes versus
// external ones however, so this is off by default
#if !defined(SOL_ENABLE_INTEROP)
// off by default here
#define SOL_ENABLE_INTEROP 0
#endif
// Mac OSX and Objective C define a nil keyword
// we cannot use that for the sol::type::nil define
#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) || defined(__OBJC__) || defined(nil)
#if !defined(SOL_NO_NIL)
#define SOL_NO_NIL 1
#endif
#endif // avoiding nil defines / keywords
// If we are using boost, there are a number of optimizations we can perform
// Boost has unordered_map with Compatible Key and CompatibleHash
// Boost also has a decent optional, and we check for this later
// and define our optional to use boost in that scenario
#if defined(SOL_USE_BOOST) && SOL_USE_BOOST
#ifndef SOL_UNORDERED_MAP_COMPATIBLE_HASH
#define SOL_UNORDERED_MAP_COMPATIBLE_HASH 1
#endif // SOL_UNORDERED_MAP_COMPATIBLE_HASH
#endif
// For strings being serialized and
// deserialized from and to utf8
// this controls the size of the buffer we create on the stack,
// in # of utf8 code units
// a buffer of 1KB covers almost all the strings
// we care about: anything larger and the user should know better
#ifndef SOL_STACK_STRING_OPTIMIZATION_SIZE
#define SOL_STACK_STRING_OPTIMIZATION_SIZE 1024
#endif // Optimized conversion routines using a KB or so off the stack
#endif // SOL_CONFIG_HPP

View File

@ -596,7 +596,7 @@ namespace sol {
};
static auto& get_src(lua_State* L) {
#ifdef SOL_SAFE_USERTYPE
#if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE
auto p = stack::check_get<T*>(L, 1);
if (!p) {
luaL_error(L, "sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)", detail::demangle<T>().c_str());
@ -1313,7 +1313,7 @@ namespace sol {
static auto& get_src(lua_State* L) {
auto p = stack::check_get<T*>(L, 1);
#ifdef SOL_SAFE_USERTYPE
#if defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE
if (!p) {
luaL_error(L, "sol: 'self' is not of type '%s' (pass 'self' as first argument with ':' or call on proper type)", detail::demangle<T>().c_str());
}
@ -1438,7 +1438,11 @@ namespace sol {
}
static std::ptrdiff_t index_adjustment(lua_State*, T&) {
#if defined(SOL_CONTAINERS_START_INDEX)
return (SOL_CONTAINERS_START) == 0 ? 0 : -(SOL_CONTAINERS_START);
#else
return -1;
#endif
}
static iterator begin(lua_State*, T& self) {

View File

@ -63,7 +63,7 @@ namespace sol {
auto maybenameview = stack::check_get<string_view>(L, 2);
if (maybenameview) {
const string_view& nameview = *maybenameview;
#ifdef SOL_UNORDERED_MAP_COMPATIBLE_HASH
#if defined(SOL_UNORDERED_MAP_COMPATIBLE_HASH) && SOL_UNORDERED_MAP_COMPATIBLE_HASH
auto it = calls.find(nameview, string_view_hash(), std::equal_to<string_view>());
#else
std::string name(nameview.data(), nameview.size());

View File

@ -85,7 +85,7 @@ namespace sol {
template <typename T, meta::enable<meta::neg<std::is_same<meta::unqualified_t<T>, basic_coroutine>>, meta::neg<std::is_base_of<proxy_base_tag, meta::unqualified_t<T>>>, meta::neg<std::is_same<base_t, stack_reference>>, meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
basic_coroutine(T&& r) noexcept
: base_t(std::forward<T>(r)), error_handler(detail::get_default_handler<reference, is_main_threaded<base_t>::value>(r.lua_state())) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
if (!is_function<meta::unqualified_t<T>>::value) {
auto pp = stack::push_pop(*this);
constructor_handler handler{};
@ -142,7 +142,7 @@ namespace sol {
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
basic_coroutine(lua_State* L, T&& r, handler_t eh)
: base_t(L, std::forward<T>(r)), error_handler(std::move(eh)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
auto pp = stack::push_pop(*this);
constructor_handler handler{};
stack::check<basic_coroutine>(lua_state(), -1, handler);
@ -168,7 +168,7 @@ namespace sol {
}
basic_coroutine(lua_State* L, absolute_index index, handler_t eh)
: base_t(L, index), error_handler(std::move(eh)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
constructor_handler handler{};
stack::check<basic_coroutine>(L, index, handler);
#endif // Safety
@ -178,7 +178,7 @@ namespace sol {
}
basic_coroutine(lua_State* L, raw_index index, handler_t eh)
: base_t(L, index), error_handler(std::move(eh)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
constructor_handler handler{};
stack::check<basic_coroutine>(L, index, handler);
#endif // Safety
@ -188,7 +188,7 @@ namespace sol {
}
basic_coroutine(lua_State* L, ref_index index, handler_t eh)
: base_t(L, index), error_handler(std::move(eh)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
auto pp = stack::push_pop(*this);
constructor_handler handler{};
stack::check<basic_coroutine>(lua_state(), -1, handler);

View File

@ -62,7 +62,7 @@ namespace sol {
basic_environment(env_t, const stack_reference& extraction_target)
: base_t(detail::no_safety, extraction_target.lua_state(), (stack::push_environment_of(extraction_target), -1)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
constructor_handler handler{};
stack::check<env_t>(this->lua_state(), -1, handler);
#endif // Safety
@ -71,7 +71,7 @@ namespace sol {
template <bool b>
basic_environment(env_t, const basic_reference<b>& extraction_target)
: base_t(detail::no_safety, extraction_target.lua_state(), (stack::push_environment_of(extraction_target), -1)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
constructor_handler handler{};
stack::check<env_t>(this->lua_state(), -1, handler);
#endif // Safety
@ -79,14 +79,14 @@ namespace sol {
}
basic_environment(lua_State* L, int index = -1)
: base_t(detail::no_safety, L, index) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
constructor_handler handler{};
stack::check<basic_environment>(L, index, handler);
#endif // Safety
}
basic_environment(lua_State* L, ref_index index)
: base_t(detail::no_safety, L, index) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
auto pp = stack::push_pop(*this);
constructor_handler handler{};
stack::check<basic_environment>(L, -1, handler);
@ -95,7 +95,7 @@ namespace sol {
template <typename T, meta::enable<meta::neg<meta::any_same<meta::unqualified_t<T>, basic_environment>>, meta::neg<std::is_same<base_type, stack_reference>>, meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
basic_environment(T&& r) noexcept
: base_t(detail::no_safety, std::forward<T>(r)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
if (!is_environment<meta::unqualified_t<T>>::value) {
auto pp = stack::push_pop(*this);
constructor_handler handler{};
@ -110,7 +110,7 @@ namespace sol {
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
basic_environment(lua_State* L, T&& r) noexcept
: base_t(detail::no_safety, L, std::forward<T>(r)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
if (!is_environment<meta::unqualified_t<T>>::value) {
auto pp = stack::push_pop(*this);
constructor_handler handler{};

View File

@ -35,7 +35,7 @@ namespace sol {
class error : public std::runtime_error {
private:
// Because VC++ is a fuccboi
// Because VC++ is upsetting, most of the time!
std::string w;
public:

View File

@ -30,7 +30,7 @@
#endif // C++17 features macro
#endif // C++17 features check
#ifdef SOL_CXX17_FEATURES
#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
// TODO: there is a bug in the VC++ compiler??
// on /std:c++latest under x86 conditions (VS 15.5.2),
// compiler errors are tossed for noexcept markings being on function types
@ -51,138 +51,6 @@
#endif // Clang screws up variant
#endif // C++17 only
#ifdef _MSC_VER
#if defined(_DEBUG) && !defined(NDEBUG)
#ifndef SOL_IN_DEBUG_DETECTED
#define SOL_IN_DEBUG_DETECTED 1
#endif
#endif // VC++ Debug macros
#ifndef _CPPUNWIND
#ifndef SOL_NO_EXCEPTIONS
#define SOL_NO_EXCEPTIONS 1
#endif
#endif // Automatic Exceptions
#ifndef _CPPRTTI
#ifndef SOL_NO_RTTI
#define SOL_NO_RTTI 1
#endif
#endif // Automatic RTTI
#elif defined(__GNUC__) || defined(__clang__)
#if !defined(NDEBUG) && !defined(__OPTIMIZE__)
#ifndef SOL_IN_DEBUG_DETECTED
#define SOL_IN_DEBUG_DETECTED 1
#endif
#endif // Not Debug && g++ optimizer flag
#ifndef __EXCEPTIONS
#ifndef SOL_NO_EXCEPTIONS
#define SOL_NO_EXCEPTIONS 1
#endif
#endif // No Exceptions
#ifndef __GXX_RTTI
#ifndef SOL_NO_RTII
#define SOL_NO_RTTI 1
#endif
#endif // No RTTI
#endif // vc++ || clang++/g++
#if defined(SOL_CHECK_ARGUMENTS)
// turn things on automatically
// Checks low-level getter function
// (and thusly, affects nearly entire framework)
#if !defined(SOL_SAFE_GETTER)
#define SOL_SAFE_GETTER 1
#endif
// Checks access on usertype functions
// local my_obj = my_type.new()
// my_obj.my_member_function()
// -- bad syntax and crash
#if !defined(SOL_SAFE_USERTYPE)
#define SOL_SAFE_USERTYPE 1
#endif
// Checks sol::reference derived boundaries
// sol::function ref(L, 1);
// sol::userdata sref(L, 2);
#if !defined(SOL_SAFE_REFERENCES)
#define SOL_SAFE_REFERENCES 1
#endif
// Changes all typedefs of sol::function to point to the
// protected_function version, instead of unsafe_function
#if !defined(SOL_SAFE_FUNCTION)
#define SOL_SAFE_FUNCTION 1
#endif
// Checks function parameters and
// returns upon call into/from Lua
// local a = 1
// local b = "woof"
// my_c_function(a, b)
#if !defined(SOL_SAFE_FUNCTION_CALLS)
#define SOL_SAFE_FUNCTION_CALLS 1
#endif
// Checks conversions
// int v = lua["bark"];
// int v2 = my_sol_function();
#if !defined(SOL_SAFE_PROXIES)
#define SOL_SAFE_PROXIES 1
#endif
// Check overflowing number conversions
// for things like 64 bit integers that don't fit in a typical lua_Number
// for Lua 5.1 and 5.2
#if !defined(SOL_SAFE_NUMERICS)
#define SOL_SAFE_NUMERICS 1
#endif
#endif // Turn on Safety for all if top-level macro is defined
#ifdef SOL_IN_DEBUG_DETECTED
#if !defined(SOL_SAFE_REFERENCES)
// Ensure that references are forcefully type-checked upon construction
#define SOL_SAFE_REFERENCES 1
#endif
#if !defined(SOL_SAFE_USERTYPE)
// Usertypes should be safe no matter what
#define SOL_SAFE_USERTYPE 1
#endif
#if !defined(SOL_SAFE_FUNCTION_CALLS)
// Function calls from Lua should be automatically safe in debug mode
#define SOL_SAFE_FUNCTION_CALLS 1
#endif
#endif // Turn on all debug safety features for VC++ / g++ / clang++ and similar
#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) || defined(__OBJC__) || defined(nil)
#if !defined(SOL_NO_NIL)
#define SOL_NO_NIL 1
#endif
#endif // avoiding nil defines / keywords
#ifdef SOL_USE_BOOST
#ifndef SOL_UNORDERED_MAP_COMPATIBLE_HASH
#define SOL_UNORDERED_MAP_COMPATIBLE_HASH
#endif // SOL_UNORDERED_MAP_COMPATIBLE_HASH
#endif // Boost has unordered_map with Compatible Key and CompatibleHash
#ifndef SOL_STACK_STRING_OPTIMIZATION_SIZE
#define SOL_STACK_STRING_OPTIMIZATION_SIZE 1024
#endif // Optimized conversion routines using a KB or so off the stack
#include <sol/config.hpp>
#endif // SOL_FEATURE_TEST_HPP

View File

@ -81,7 +81,7 @@ namespace sol {
using main_protected_function = main_safe_function;
using stack_protected_function = stack_safe_function;
using stack_aligned_protected_function = stack_aligned_safe_function;
#ifdef SOL_SAFE_FUNCTION
#if defined(SOL_SAFE_FUNCTION) && SOL_SAFE_FUNCTION
using function = protected_function;
using main_function = main_protected_function;
using stack_function = stack_protected_function;
@ -96,7 +96,7 @@ namespace sol {
struct unsafe_function_result;
struct protected_function_result;
using safe_function_result = protected_function_result;
#ifdef SOL_SAFE_FUNCTION
#if defined(SOL_SAFE_FUNCTION) && SOL_SAFE_FUNCTION
using function_result = safe_function_result;
#else
using function_result = unsafe_function_result;

View File

@ -31,7 +31,7 @@
namespace sol {
namespace detail {
const bool default_safe_function_calls =
#ifdef SOL_SAFE_FUNCTION_CALLS
#if defined(SOL_SAFE_FUNCTION_CALLS) && SOL_SAFE_FUNCTION_CALLS
true;
#else
false;

View File

@ -199,7 +199,7 @@ namespace sol {
stack::push(L, f);
}
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE
#if defined(SOL_NOEXCEPT_FUNCTION_TYPE) && SOL_NOEXCEPT_FUNCTION_TYPE
template <bool is_yielding>
static void select_function(std::true_type, lua_State* L, detail::lua_CFunction_noexcept f) {
// TODO: support yielding
@ -299,8 +299,8 @@ namespace sol {
template <typename Signature>
struct 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>>>
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE
,
#if defined(SOL_NOEXCEPT_FUNCTION_TYPE) && SOL_NOEXCEPT_FUNCTION_TYPE
,
meta::neg<std::is_same<Signature, detail::lua_CFunction_noexcept>>, meta::neg<std::is_same<Signature, std::remove_pointer_t<detail::lua_CFunction_noexcept>>>
#endif // noexcept function types
>::value>> {

View File

@ -120,7 +120,7 @@ namespace sol {
inline int c_call(lua_State* L) {
typedef meta::unqualified_t<F> Fu;
typedef std::integral_constant<bool, std::is_same<Fu, lua_CFunction>::value
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE
#if defined(SOL_NOEXCEPT_FUNCTION_TYPE) && SOL_NOEXCEPT_FUNCTION_TYPE
|| std::is_same<Fu, detail::lua_CFunction_noexcept>::value
#endif
> is_raw;

View File

@ -29,7 +29,7 @@
namespace sol {
#ifdef SOL_CXX17_FEATURES
#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
using in_place_t = std::in_place_t;
constexpr std::in_place_t in_place{};
constexpr std::in_place_t in_place_of{};

View File

@ -48,7 +48,7 @@ namespace sol {
template <typename T>
decltype(auto) tagged_get(types<T>) const {
#ifdef SOL_SAFE_PROXIES
#if defined(SOL_SAFE_PROXIES) && SOL_SAFE_PROXIES != 0
if (!valid()) {
type_panic_c_str(L, index, type_of(L, index), type::none);
}
@ -64,7 +64,7 @@ namespace sol {
}
error tagged_get(types<error>) const {
#ifdef SOL_SAFE_PROXIES
#if defined(SOL_SAFE_PROXIES) && SOL_SAFE_PROXIES != 0
if (valid()) {
type_panic_c_str(L, index, type_of(L, index), type::none, "expecting an error type (a string, from Lua)");
}

View File

@ -26,7 +26,7 @@
#include "compatibility.hpp"
#include "in_place.hpp"
#if defined(SOL_USE_BOOST)
#if defined(SOL_USE_BOOST) && SOL_USE_BOOST
#include <boost/optional.hpp>
#else
#include "optional_implementation.hpp"
@ -34,7 +34,7 @@
namespace sol {
#if defined(SOL_USE_BOOST)
#if defined(SOL_USE_BOOST) && SOL_USE_BOOST
template <typename T>
using optional = boost::optional<T>;
using nullopt_t = boost::none_t;

View File

@ -41,7 +41,7 @@
#include <functional>
#include <string>
#include <stdexcept>
#ifdef SOL_NO_EXCEPTIONS
#if defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS
#include <cstdlib>
#endif // Exceptions

View File

@ -77,7 +77,7 @@ namespace sol {
int firstreturn = 1;
int returncount = 0;
call_status code = call_status::ok;
#ifndef SOL_NO_EXCEPTIONS
#if !defined(SOL_NO_EXCEPTIONS) || !SOL_NO_EXCEPTIONS
auto onexcept = [&](optional<const std::exception&> maybe_ex, const char* error) {
h.stackindex = 0;
if (b) {
@ -90,7 +90,7 @@ namespace sol {
}
};
(void)onexcept;
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) || defined(SOL_LUAJIT)
#if (!defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) || !SOL_NO_EXCEPTIONS_SAFE_PROPAGATION) || (defined(SOL_LUAJIT) && SOL_LUAJIT)
try {
#endif // Safe Exception Propagation
#endif // No Exceptions
@ -99,7 +99,7 @@ namespace sol {
poststacksize = lua_gettop(lua_state()) - static_cast<int>(h.valid());
returncount = poststacksize - (firstreturn - 1);
#ifndef SOL_NO_EXCEPTIONS
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) || defined(SOL_LUAJIT)
#if (!defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) || !SOL_NO_EXCEPTIONS_SAFE_PROPAGATION) || (defined(SOL_LUAJIT) && SOL_LUAJIT)
}
// Handle C++ errors thrown from C++ functions bound inside of lua
catch (const char* error) {
@ -117,7 +117,7 @@ namespace sol {
firstreturn = lua_gettop(lua_state());
return protected_function_result(lua_state(), firstreturn, 0, 1, call_status::runtime);
}
#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION)
#if (!defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) || !SOL_NO_EXCEPTIONS_SAFE_PROPAGATION)
// LuaJIT cannot have the catchall when the safe propagation is on
// but LuaJIT will swallow all C++ errors
// if we don't at least catch std::exception ones
@ -143,7 +143,7 @@ namespace sol {
template <typename T, meta::enable<meta::neg<std::is_same<meta::unqualified_t<T>, basic_protected_function>>, meta::neg<std::is_base_of<proxy_base_tag, meta::unqualified_t<T>>>, meta::neg<std::is_same<base_t, stack_reference>>, meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
basic_protected_function(T&& r) noexcept
: base_t(std::forward<T>(r)), error_handler(get_default_handler(r.lua_state())) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
if (!is_function<meta::unqualified_t<T>>::value) {
auto pp = stack::push_pop(*this);
constructor_handler handler{};
@ -200,7 +200,7 @@ namespace sol {
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
basic_protected_function(lua_State* L, T&& r, handler_t eh)
: base_t(L, std::forward<T>(r)), error_handler(std::move(eh)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
auto pp = stack::push_pop(*this);
constructor_handler handler{};
stack::check<basic_protected_function>(lua_state(), -1, handler);
@ -216,7 +216,7 @@ namespace sol {
}
basic_protected_function(lua_State* L, int index, handler_t eh)
: base_t(L, index), error_handler(std::move(eh)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
constructor_handler handler{};
stack::check<basic_protected_function>(L, index, handler);
#endif // Safety
@ -226,7 +226,7 @@ namespace sol {
}
basic_protected_function(lua_State* L, absolute_index index, handler_t eh)
: base_t(L, index), error_handler(std::move(eh)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
constructor_handler handler{};
stack::check<basic_protected_function>(L, index, handler);
#endif // Safety
@ -236,7 +236,7 @@ namespace sol {
}
basic_protected_function(lua_State* L, raw_index index, handler_t eh)
: base_t(L, index), error_handler(std::move(eh)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
constructor_handler handler{};
stack::check<basic_protected_function>(L, index, handler);
#endif // Safety
@ -246,7 +246,7 @@ namespace sol {
}
basic_protected_function(lua_State* L, ref_index index, handler_t eh)
: base_t(L, index), error_handler(std::move(eh)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
auto pp = stack::push_pop(*this);
constructor_handler handler{};
stack::check<basic_protected_function>(lua_state(), -1, handler);

View File

@ -54,7 +54,7 @@ namespace sol {
template <typename T>
decltype(auto) tagged_get(types<T>, int index_offset) const {
int target = index + index_offset;
#ifdef SOL_SAFE_PROXIES
#if defined(SOL_SAFE_PROXIES) && SOL_SAFE_PROXIES
if (!valid()) {
type t = type_of(L, target);
type_panic_c_str(L, target, t, type::none, "bad get from protected_function_result (is not an error)");
@ -73,7 +73,7 @@ namespace sol {
error tagged_get(types<error>, int index_offset) const {
int target = index + index_offset;
#ifdef SOL_SAFE_PROXIES
#if defined(SOL_SAFE_PROXIES) && SOL_SAFE_PROXIES
if (valid()) {
type t = type_of(L, target);
type_panic_c_str(L, target, t, type::none, "bad get from protected_function_result (is an error)");

View File

@ -70,7 +70,7 @@ namespace sol {
string_view accessor = stack::get<string_view>(L, keyidx);
variable_wrapper* varwrap = nullptr;
{
#ifdef SOL_UNORDERED_MAP_COMPATIBLE_HASH
#if defined(SOL_UNORDERED_MAP_COMPATIBLE_HASH) && SOL_UNORDERED_MAP_COMPATIBLE_HASH
string_view& accessorkey = accessor;
auto vit = variables.find(accessorkey, string_view_hash(), std::equal_to<string_view>());
#else
@ -86,7 +86,7 @@ namespace sol {
}
bool function_failed = false;
{
#ifdef SOL_UNORDERED_MAP_COMPATIBLE_HASH
#if defined(SOL_UNORDERED_MAP_COMPATIBLE_HASH) && SOL_UNORDERED_MAP_COMPATIBLE_HASH
string_view& accessorkey = accessor;
auto fit = functions.find(accessorkey, string_view_hash(), std::equal_to<string_view>());
#else
@ -453,19 +453,19 @@ namespace sol {
switch (mf) {
case meta_function::construct:
if (prop) {
#ifndef SOL_NO_EXCEPTIONS
throw error("sol: 2 separate constructor (new) functions were set on this type. Please specify only 1 sol::meta_function::construct/'new' type AND wrap the function in a sol::factories/initializers call, as shown by the documentation and examples, otherwise you may create problems");
#else
#if defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS
assert(false && "sol: 2 separate constructor (new) functions were set on this type. Please specify only 1 sol::meta_function::construct/'new' type AND wrap the function in a sol::factories/initializers call, as shown by the documentation and examples, otherwise you may create problems");
#else
throw error("sol: 2 separate constructor (new) functions were set on this type. Please specify only 1 sol::meta_function::construct/'new' type AND wrap the function in a sol::factories/initializers call, as shown by the documentation and examples, otherwise you may create problems");
#endif
}
break;
case meta_function::garbage_collect:
if (prop) {
#ifndef SOL_NO_EXCEPTIONS
throw error("sol: 2 separate constructor (new) functions were set on this type. Please specify only 1 sol::meta_function::construct/'new' type AND wrap the function in a sol::factories/initializers call, as shown by the documentation and examples, otherwise you may create problems");
#else
#if defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS
assert(false && "sol: 2 separate constructor (new) functions were set on this type. Please specify only 1 sol::meta_function::construct/'new' type AND wrap the function in a sol::factories/initializers call, as shown by the documentation and examples, otherwise you may create problems");
#else
throw error("sol: 2 separate constructor (new) functions were set on this type. Please specify only 1 sol::meta_function::construct/'new' type AND wrap the function in a sol::factories/initializers call, as shown by the documentation and examples, otherwise you may create problems");
#endif
}
return;

View File

@ -99,7 +99,7 @@ namespace stack {
static bool check(lua_State* L, int index, Handler&& handler, record& tracking) {
tracking.use(1);
#if SOL_LUA_VERSION >= 503
#ifdef SOL_STRINGS_ARE_NUMBERS
#if defined(SOL_STRINGS_ARE_NUMBERS) && SOL_STRINGS_ARE_NUMBERS
int isnum = 0;
lua_tointegerx(L, index, &isnum);
const bool success = isnum != 0;
@ -107,20 +107,27 @@ namespace stack {
// expected type, actual type
handler(L, index, type::number, type_of(L, index), "not a numeric type or numeric string");
}
#else
#elif (defined(SOL_SAFE_NUMERICS) && SOL_SAFE_NUMERICS) && !(defined(SOL_NO_CHECK_NUMBER_PRECISION) && SOL_NO_CHECK_NUMBER_PRECISION)
// this check is precise, does not convert
if (lua_isinteger(L, index) == 1) {
return true;
}
const bool success = false;
if (!success) {
// expected type, actual type
handler(L, index, type::number, type_of(L, index), "not a numeric (integral) type");
}
#else
type t = type_of(L, index);
const bool success = t == type::number;
#endif // If numbers are enabled, use the imprecise check
if (!success) {
// expected type, actual type
handler(L, index, type::number, type_of(L, index), "not a numeric type");
}
#endif // If numbers are enabled, use the imprecise check
return success;
#else
#ifndef SOL_STRINGS_ARE_NUMBERS
#if !defined(SOL_STRINGS_ARE_NUMBERS) || !SOL_STRINGS_ARE_NUMBERS
// must pre-check, because it will convert
type t = type_of(L, index);
if (t != type::number) {
@ -131,17 +138,21 @@ namespace stack {
#endif // Do not allow strings to be numbers
int isnum = 0;
const lua_Number v = lua_tonumberx(L, index, &isnum);
const bool success = isnum != 0 && static_cast<lua_Number>(llround(v)) == v;
const bool success = isnum != 0
#if (defined(SOL_SAFE_NUMERICS) && SOL_SAFE_NUMERICS) && !(defined(SOL_NO_CHECK_NUMBER_PRECISION) && SOL_NO_CHECK_NUMBER_PRECISION)
&& static_cast<lua_Number>(llround(v)) == v
#endif // Safe numerics and number precision checking
;
if (!success) {
// expected type, actual type
#ifndef SOL_STRINGS_ARE_NUMBERS
#if defined(SOL_STRINGS_ARE_NUMBERS) && SOL_STRINGS_ARE_NUMBERS
handler(L, index, type::number, t, "not a numeric type");
#else
handler(L, index, type::number, type_of(L, index), "not a numeric type or numeric string");
#endif
}
return success;
#endif
#endif // Lua Version 5.3 versus others
}
};
@ -150,7 +161,14 @@ namespace stack {
template <typename Handler>
static bool check(lua_State* L, int index, Handler&& handler, record& tracking) {
tracking.use(1);
#ifndef SOL_STRINGS_ARE_NUMBERS
#if defined(SOL_STRINGS_ARE_NUMBERS) && SOL_STRINGS_ARE_NUMBERS
bool success = lua_isnumber(L, index) == 1;
if (!success) {
// expected type, actual type
handler(L, index, type::number, type_of(L, index), "not a numeric type or numeric string");
}
return success;
#else
type t = type_of(L, index);
bool success = t == type::number;
if (!success) {
@ -158,14 +176,7 @@ namespace stack {
handler(L, index, type::number, t, "not a numeric type");
}
return success;
#else
bool success = lua_isnumber(L, index) == 1;
if (!success) {
// expected type, actual type
handler(L, index, type::number, type_of(L, index), "not a numeric type or numeric string");
}
return success;
#endif
#endif // Strings are Numbers
}
};
@ -424,7 +435,7 @@ namespace stack {
template <typename U, typename Handler>
static bool check(types<U>, lua_State* L, int index, type indextype, Handler&& handler, record& tracking) {
#ifdef SOL_ENABLE_INTEROP
#if defined(SOL_ENABLE_INTEROP) && SOL_ENABLE_INTEROP
userdata_checker<extensible<T>> uc;
(void)uc;
if (uc.check(L, index, indextype, handler, tracking)) {
@ -577,8 +588,8 @@ namespace stack {
}
};
#ifdef SOL_CXX17_FEATURES
#ifdef SOL_STD_VARIANT
#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
template <typename... Tn, typename C>
struct checker<std::variant<Tn...>, type::poly, C> {
typedef std::variant<Tn...> V;

View File

@ -85,7 +85,7 @@ namespace stack {
int isnum = 0;
const lua_Number value = lua_tonumberx(L, index, &isnum);
if (isnum != 0) {
#if defined(SOL_SAFE_NUMERICS) && !defined(SOL_NO_CHECK_NUMBER_PRECISION)
#if (defined(SOL_SAFE_NUMERICS) && SOL_SAFE_NUMERICS) && !(defined(SOL_NO_CHECK_NUMBER_PRECISION) && SOL_NO_CHECK_NUMBER_PRECISION)
const auto integer_value = llround(value);
if (static_cast<lua_Number>(integer_value) == value) {
tracking.use(1);
@ -144,8 +144,8 @@ namespace stack {
}
};
#ifdef SOL_CXX17_FEATURES
#ifdef SOL_STD_VARIANT
#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
template <typename... Tn>
struct check_getter<std::variant<Tn...>> {
typedef std::variant<Tn...> V;

View File

@ -88,7 +88,7 @@ namespace sol {
inline void* align_usertype_pointer(void* ptr) {
typedef std::integral_constant<bool,
#ifdef SOL_NO_MEMORY_ALIGNMENT
#if defined(SOL_NO_MEMORY_ALIGNMENT) && SOL_NO_MEMORY_ALIGNMENT
false
#else
(std::alignment_of<void*>::value > 1)
@ -104,7 +104,7 @@ namespace sol {
inline void* align_usertype_unique_destructor(void* ptr) {
typedef std::integral_constant<bool,
#ifdef SOL_NO_MEMORY_ALIGNMENT
#if defined(SOL_NO_MEMORY_ALIGNMENT) && SOL_NO_MEMORY_ALIGNMENT
false
#else
(std::alignment_of<unique_destructor>::value > 1)
@ -123,7 +123,7 @@ namespace sol {
template <typename T, bool pre_aligned = false>
inline void* align_usertype_unique(void* ptr) {
typedef std::integral_constant<bool,
#ifdef SOL_NO_MEMORY_ALIGNMENT
#if defined(SOL_NO_MEMORY_ALIGNMENT) && SOL_NO_MEMORY_ALIGNMENT
false
#else
(std::alignment_of<T>::value > 1)
@ -144,7 +144,7 @@ namespace sol {
template <typename T>
inline void* align_user(void* ptr) {
typedef std::integral_constant<bool,
#ifdef SOL_NO_MEMORY_ALIGNMENT
#if defined(SOL_NO_MEMORY_ALIGNMENT) && SOL_NO_MEMORY_ALIGNMENT
false
#else
(std::alignment_of<T>::value > 1)
@ -161,7 +161,7 @@ namespace sol {
template <typename T>
inline T** usertype_allocate_pointer(lua_State* L) {
typedef std::integral_constant<bool,
#ifdef SOL_NO_MEMORY_ALIGNMENT
#if defined(SOL_NO_MEMORY_ALIGNMENT) && SOL_NO_MEMORY_ALIGNMENT
false
#else
(std::alignment_of<T*>::value > 1)
@ -198,7 +198,7 @@ namespace sol {
template <typename T>
inline T* usertype_allocate(lua_State* L) {
typedef std::integral_constant<bool,
#ifdef SOL_NO_MEMORY_ALIGNMENT
#if defined(SOL_NO_MEMORY_ALIGNMENT) && SOL_NO_MEMORY_ALIGNMENT
false
#else
(std::alignment_of<T*>::value > 1 || std::alignment_of<T>::value > 1)
@ -278,7 +278,7 @@ namespace sol {
template <typename T, typename Real>
inline Real* usertype_unique_allocate(lua_State* L, T**& pref, unique_destructor*& dx) {
typedef std::integral_constant<bool,
#ifdef SOL_NO_MEMORY_ALIGNMENT
#if defined(SOL_NO_MEMORY_ALIGNMENT) && SOL_NO_MEMORY_ALIGNMENT
false
#else
(std::alignment_of<T*>::value > 1 || std::alignment_of<unique_destructor>::value > 1 || std::alignment_of<Real>::value > 1)
@ -352,7 +352,7 @@ namespace sol {
template <typename T>
inline T* user_allocate(lua_State* L) {
typedef std::integral_constant<bool,
#ifdef SOL_NO_MEMORY_ALIGNMENT
#if defined(SOL_NO_MEMORY_ALIGNMENT) && SOL_NO_MEMORY_ALIGNMENT
false
#else
(std::alignment_of<T>::value > 1)
@ -705,7 +705,7 @@ namespace sol {
namespace stack_detail {
#ifdef SOL_SAFE_GETTER
#if defined(SOL_SAFE_GETTER) && SOL_SAFE_GETTER
template <typename T>
inline auto tagged_get(types<T>, lua_State* L, int index, record& tracking) -> decltype(stack_detail::unchecked_get<T>(L, index, tracking)) {
auto op = check_get<T>(L, index, type_panic_c_str, tracking);
@ -782,7 +782,7 @@ namespace sol {
template <typename T>
inline decltype(auto) get_usertype(lua_State* L, int index, record& tracking) {
#ifdef SOL_SAFE_GETTER
#if defined(SOL_SAFE_GETTER) && SOL_SAFE_GETTER
return stack_detail::tagged_get(types<std::conditional_t<std::is_pointer<T>::value, detail::as_pointer_tag<std::remove_pointer_t<T>>, detail::as_value_tag<T>>>(), L, index, tracking);
#else
return stack_detail::unchecked_get<std::conditional_t<std::is_pointer<T>::value, detail::as_pointer_tag<std::remove_pointer_t<T>>, detail::as_value_tag<T>>>(L, index, tracking);

View File

@ -36,9 +36,9 @@
#include <utility>
#include <cstdlib>
#include <cmath>
#ifdef SOL_CXX17_FEATURES
#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
#include <string_view>
#ifdef SOL_STD_VARIANT
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
#include <variant>
#endif // Apple clang screwed up
#endif // C++17
@ -712,7 +712,7 @@ namespace stack {
struct getter<detail::as_value_tag<T>> {
static T* get_no_lua_nil(lua_State* L, int index, record& tracking) {
void* memory = lua_touserdata(L, index);
#ifdef SOL_ENABLE_INTEROP
#if defined(SOL_ENABLE_INTEROP) && SOL_ENABLE_INTEROP
userdata_getter<extensible<T>> ug;
(void)ug;
auto ugr = ug.get(L, index, memory, tracking);
@ -842,8 +842,8 @@ namespace stack {
}
};
#ifdef SOL_CXX17_FEATURES
#ifdef SOL_STD_VARIANT
#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
template <typename... Tn>
struct getter<std::variant<Tn...>> {
typedef std::variant<Tn...> V;

View File

@ -31,7 +31,7 @@
namespace sol {
namespace detail {
inline void stack_fail(int, int) {
#ifndef SOL_NO_EXCEPTIONS
#if !(defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS)
throw error(detail::direct_error, "imbalanced stack after operation finish");
#else
// Lol, what do you want, an error printout? :3c

View File

@ -47,7 +47,7 @@ namespace stack {
template <typename T>
struct popper<T, std::enable_if_t<is_stack_based<meta::unqualified_t<T>>::value>> {
static_assert(meta::neg<std::is_base_of<stack_reference, meta::unqualified_t<T>>>::value, "You cannot pop something that derives from stack_reference: it will not remain on the stack and thusly will go out of scope!");
static_assert(meta::neg<is_stack_based<meta::unqualified_t<T>>>::value, "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 scope!");
};
}
} // namespace sol::stack

View File

@ -35,9 +35,9 @@
#include <type_traits>
#include <cassert>
#include <limits>
#ifdef SOL_CXX17_FEATURES
#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
#include <string_view>
#ifdef SOL_STD_VARIANT
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
#include <variant>
#endif // Can use variant
#endif // C++17
@ -214,19 +214,19 @@ namespace stack {
lua_pushinteger(L, static_cast<lua_Integer>(value));
return 1;
}
#endif
#if defined(SOL_SAFE_NUMERICS) && !defined(SOL_NO_CHECK_NUMBER_PRECISION)
#endif // Lua 5.3 and above
#if (defined(SOL_SAFE_NUMERICS) && SOL_SAFE_NUMERICS) && !(defined(SOL_NO_CHECK_NUMBER_PRECISION) && SOL_NO_CHECK_NUMBER_PRECISION)
if (static_cast<T>(llround(static_cast<lua_Number>(value))) != value) {
#ifdef SOL_NO_EXCEPTIONS
#if defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS
// Is this really worth it?
assert(false && "integer value will be misrepresented in lua");
lua_pushnumber(L, static_cast<lua_Number>(value));
return 1;
#else
throw error(detail::direct_error, "integer value will be misrepresented in lua");
#endif
#endif // No Exceptions
}
#endif
#endif // Safe Numerics and Number Precision Check
lua_pushnumber(L, static_cast<lua_Number>(value));
return 1;
}
@ -288,7 +288,7 @@ namespace stack {
}
lua_pop(L, 1 + p);
}
#endif
#endif // Lua Version 5.3 and others
}
// TODO: figure out a better way to do this...?
//set_field(L, -1, cont.size());
@ -388,7 +388,7 @@ namespace stack {
}
};
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE
#if defined(SOL_NOEXCEPT_FUNCTION_TYPE) && SOL_NOEXCEPT_FUNCTION_TYPE
template <>
struct pusher<std::remove_pointer_t<detail::lua_CFunction_noexcept>> {
static int push(lua_State* L, detail::lua_CFunction_noexcept func, int n = 0) {
@ -988,8 +988,8 @@ namespace stack {
}
};
#ifdef SOL_CXX17_FEATURES
#ifdef SOL_STD_VARIANT
#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
namespace stack_detail {
struct push_function {

View File

@ -49,7 +49,7 @@ namespace sol {
}
inline int default_at_panic(lua_State* L) {
#ifdef SOL_NO_EXCEPTIONS
#if defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS
(void)L;
return -1;
#else
@ -58,7 +58,7 @@ namespace sol {
if (message) {
std::string err(message, messagesize);
lua_settop(L, 0);
#ifdef SOL_PRINT_ERRORS
#if defined(SOL_PRINT_ERRORS) && SOL_PRINT_ERRORS
std::cerr << "[sol2] An error occurred and panic has been invoked: ";
std::cerr << err;
std::cerr << std::endl;
@ -66,8 +66,8 @@ namespace sol {
throw error(err);
}
lua_settop(L, 0);
throw error(std::string("An unexpected error occurred and forced the lua state to call atpanic"));
#endif
throw error(std::string("An unexpected error occurred and panic has been invoked"));
#endif // Printing Errors
}
inline int default_traceback_error_handler(lua_State* L) {
@ -83,11 +83,11 @@ namespace sol {
const string_view& traceback = maybetraceback.value();
msg.assign(traceback.data(), traceback.size());
}
#ifdef SOL_PRINT_ERRORS
std::cerr << "[sol2] An error occurred: ";
std::cerr << msg;
std::cerr << std::endl;
#endif
#if defined(SOL_PRINT_ERRORS) && SOL_PRINT_ERRORS
//std::cerr << "[sol2] An error occurred and was caught in traceback: ";
//std::cerr << msg;
//std::cerr << std::endl;
#endif // Printing
return stack::push(L, msg);
}
@ -115,7 +115,7 @@ namespace sol {
std::string err = "sol: ";
err += to_string(result.status());
err += " error";
#ifndef SOL_NO_EXCEPTIONS
#if !(defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS)
std::exception_ptr eptr = std::current_exception();
if (eptr) {
err += " with a ";
@ -144,12 +144,12 @@ namespace sol {
string_view serr = stack::get<string_view>(L, result.stack_index());
err.append(serr.data(), serr.size());
}
#ifdef SOL_PRINT_ERRORS
#if defined(SOL_PRINT_ERRORS) && SOL_PRINT_ERRORS
std::cerr << "[sol2] An error occurred and has been passed to an error handler: ";
std::cerr << err;
std::cerr << std::endl;
#endif
#ifdef SOL_NO_EXCEPTIONS
#if !(defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS)
// replacing information of stack error into pfr
int target = result.stack_index();
if (result.pop_count() > 0) {
@ -169,7 +169,7 @@ namespace sol {
}
inline protected_function_result script_default_on_error(lua_State* L, protected_function_result pfr) {
#ifdef SOL_DEFAULT_PASS_ON_ERROR
#if defined(SOL_DEFAULT_PASS_ON_ERROR) && SOL_DEFAULT_PASS_ON_ERROR
return script_pass_on_error(L, std::move(pfr));
#else
return script_throw_on_error(L, std::move(pfr));

View File

@ -391,7 +391,7 @@ namespace sol {
return safe_script_file(filename, env, script_default_on_error, mode);
}
#ifdef SOL_SAFE_FUNCTION
#if defined(SOL_SAFE_FUNCTION) && SOL_SAFE_FUNCTION
protected_function_result script(const string_view& code, const std::string& chunkname = detail::default_chunk_name(), load_mode mode = load_mode::any) {
return safe_script(code, chunkname, mode);
}

View File

@ -27,16 +27,16 @@
#include "feature_test.hpp"
#include <cstddef>
#include <string>
#ifdef SOL_CXX17_FEATURES
#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
#include <string_view>
#endif // C++17 features
#include <functional>
#ifdef SOL_USE_BOOST
#if defined(SOL_USE_BOOST) && SOL_USE_BOOST
#include <boost/functional/hash.hpp>
#endif
namespace sol {
#ifdef SOL_CXX17_FEATURES
#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
template <typename C, typename T = std::char_traits<C>>
using basic_string_view = std::basic_string_view<C, T>;
typedef std::string_view string_view;
@ -139,7 +139,7 @@ namespace sol {
}
result_type operator()(const argument_type& r) const {
#ifdef SOL_USE_BOOST
#if defined(SOL_USE_BOOST) && SOL_USE_BOOST
return boost::hash_range(r.begin(), r.end());
#else
// Modified, from libstdc++

View File

@ -218,7 +218,7 @@ namespace sol {
template <typename T, meta::enable_any<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
basic_table_core(lua_State* L, T&& r)
: base_t(L, std::forward<T>(r)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
auto pp = stack::push_pop(*this);
constructor_handler handler{};
stack::check<basic_table_core>(lua_state(), -1, handler);
@ -232,14 +232,14 @@ namespace sol {
}
basic_table_core(lua_State* L, int index = -1)
: basic_table_core(detail::no_safety, L, index) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
constructor_handler handler{};
stack::check<basic_table_core>(L, index, handler);
#endif // Safety
}
basic_table_core(lua_State* L, ref_index index)
: basic_table_core(detail::no_safety, L, index) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
auto pp = stack::push_pop(*this);
constructor_handler handler{};
stack::check<basic_table_core>(lua_state(), -1, handler);
@ -248,7 +248,7 @@ namespace sol {
template <typename T, meta::enable<meta::neg<meta::any_same<meta::unqualified_t<T>, basic_table_core>>, meta::neg<std::is_same<base_type, stack_reference>>, meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
basic_table_core(T&& r) noexcept
: basic_table_core(detail::no_safety, std::forward<T>(r)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
if (!is_table<meta::unqualified_t<T>>::value) {
auto pp = stack::push_pop(*this);
constructor_handler handler{};

View File

@ -90,7 +90,7 @@ namespace sol {
template <typename T, meta::enable<meta::neg<std::is_same<meta::unqualified_t<T>, basic_thread>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
basic_thread(T&& r)
: base_t(std::forward<T>(r)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
auto pp = stack::push_pop(*this);
constructor_handler handler{};
stack::check<basic_thread>(lua_state(), -1, handler);
@ -105,7 +105,7 @@ namespace sol {
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
basic_thread(lua_State* L, T&& r)
: base_t(L, std::forward<T>(r)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
auto pp = stack::push_pop(*this);
constructor_handler handler{};
stack::check<basic_thread>(lua_state(), -1, handler);
@ -113,14 +113,14 @@ namespace sol {
}
basic_thread(lua_State* L, int index = -1)
: base_t(L, index) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
constructor_handler handler{};
stack::check<basic_thread>(L, index, handler);
#endif // Safety
}
basic_thread(lua_State* L, ref_index index)
: base_t(L, index) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
auto pp = stack::push_pop(*this);
constructor_handler handler{};
stack::check<basic_thread>(lua_state(), -1, handler);
@ -134,7 +134,7 @@ namespace sol {
}
basic_thread(lua_State* L, lua_thread_state actualthread)
: base_t(L, -stack::push(L, actualthread)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
constructor_handler handler{};
stack::check<basic_thread>(lua_state(), -1, handler);
#endif // Safety

View File

@ -560,7 +560,7 @@ namespace sol {
template <typename T>
using is_string_like = any<
is_specialization_of<meta::unqualified_t<T>, std::basic_string>,
#ifdef SOL_CXX17_FEATURES
#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
is_specialization_of<meta::unqualified_t<T>, std::basic_string_view>,
#else
is_specialization_of<meta::unqualified_t<T>, basic_string_view>,
@ -573,7 +573,7 @@ namespace sol {
meta::all<std::is_array<unqualified_t<T>>, std::is_same<meta::unqualified_t<std::remove_all_extents_t<meta::unqualified_t<T>>>, char>>,
std::is_same<unqualified_t<T>, const char*>,
std::is_same<unqualified_t<T>, char>, std::is_same<unqualified_t<T>, std::string>, std::is_same<unqualified_t<T>, std::initializer_list<char>>
#ifdef SOL_CXX17_FEATURES
#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
, std::is_same<unqualified_t<T>, std::string_view>
#endif
>;

View File

@ -37,7 +37,7 @@
#include <array>
#include <initializer_list>
#include <string>
#ifdef SOL_CXX17_FEATURES
#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
#include <string_view>
#ifdef SOL_STD_VARIANT
#include <variant>
@ -982,7 +982,7 @@ namespace sol {
template <>
struct lua_type_of<meta_function> : std::integral_constant<type, type::string> {};
#ifdef SOL_CXX17_FEATURES
#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES
#ifdef SOL_STD_VARIANT
template <typename... Tn>
struct lua_type_of<std::variant<Tn...>> : std::integral_constant<type, type::poly> {};

View File

@ -71,7 +71,7 @@ namespace sol {
template <typename T, meta::enable<meta::neg<std::is_same<meta::unqualified_t<T>, basic_function>>, meta::neg<std::is_same<base_t, stack_reference>>, meta::neg<std::is_same<lua_nil_t, meta::unqualified_t<T>>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
basic_function(T&& r) noexcept
: base_t(std::forward<T>(r)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
if (!is_function<meta::unqualified_t<T>>::value) {
auto pp = stack::push_pop(*this);
constructor_handler handler{};
@ -95,7 +95,7 @@ namespace sol {
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
basic_function(lua_State* L, T&& r)
: base_t(L, std::forward<T>(r)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
auto pp = stack::push_pop(*this);
constructor_handler handler{};
stack::check<basic_function>(lua_state(), -1, handler);
@ -103,14 +103,14 @@ namespace sol {
}
basic_function(lua_State* L, int index = -1)
: base_t(L, index) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
constructor_handler handler{};
stack::check<basic_function>(L, index, handler);
#endif // Safety
}
basic_function(lua_State* L, ref_index index)
: base_t(L, index) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
auto pp = stack::push_pop(*this);
constructor_handler handler{};
stack::check<basic_function>(lua_state(), -1, handler);

View File

@ -39,7 +39,7 @@ namespace sol {
template <typename T, meta::enable<meta::neg<std::is_same<meta::unqualified_t<T>, basic_userdata>>, meta::neg<std::is_same<base_t, stack_reference>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
basic_userdata(T&& r) noexcept
: base_t(std::forward<T>(r)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
if (!is_userdata<meta::unqualified_t<T>>::value) {
auto pp = stack::push_pop(*this);
type_assert(lua_state(), -1, type::userdata);
@ -59,7 +59,7 @@ namespace sol {
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
basic_userdata(lua_State* L, T&& r)
: base_t(L, std::forward<T>(r)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
auto pp = stack::push_pop(*this);
constructor_handler handler{};
stack::check<basic_userdata>(L, -1, handler);
@ -67,14 +67,14 @@ namespace sol {
}
basic_userdata(lua_State* L, int index = -1)
: base_t(detail::no_safety, L, index) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
constructor_handler handler{};
stack::check<basic_userdata>(L, index, handler);
#endif // Safety
}
basic_userdata(lua_State* L, ref_index index)
: base_t(detail::no_safety, L, index) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
auto pp = stack::push_pop(*this);
constructor_handler handler{};
stack::check<basic_userdata>(L, -1, handler);
@ -93,7 +93,7 @@ namespace sol {
template <typename T, meta::enable<meta::neg<std::is_same<meta::unqualified_t<T>, basic_lightuserdata>>, meta::neg<std::is_same<base_t, stack_reference>>, is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
basic_lightuserdata(T&& r) noexcept
: base_t(std::forward<T>(r)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
if (!is_lightuserdata<meta::unqualified_t<T>>::value) {
auto pp = stack::push_pop(*this);
type_assert(lua_state(), -1, type::lightuserdata);
@ -113,7 +113,7 @@ namespace sol {
template <typename T, meta::enable<is_lua_reference<meta::unqualified_t<T>>> = meta::enabler>
basic_lightuserdata(lua_State* L, T&& r)
: basic_lightuserdata(L, std::forward<T>(r)) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
auto pp = stack::push_pop(*this);
constructor_handler handler{};
stack::check<basic_lightuserdata>(lua_state(), -1, handler);
@ -121,14 +121,14 @@ namespace sol {
}
basic_lightuserdata(lua_State* L, int index = -1)
: base_t(L, index) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
constructor_handler handler{};
stack::check<basic_lightuserdata>(L, index, handler);
#endif // Safety
}
basic_lightuserdata(lua_State* L, ref_index index)
: base_t(L, index) {
#ifdef SOL_SAFE_REFERENCES
#if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
auto pp = stack::push_pop(*this);
constructor_handler handler{};
stack::check<basic_lightuserdata>(lua_state(), index, handler);

View File

@ -151,7 +151,7 @@ namespace sol {
template <typename T, typename Regs>
inline void make_length_op_const(std::true_type, Regs& l, int& index) {
const char* name = to_string(meta_function::length).c_str();
#ifdef __clang__
#if defined(__clang__)
l[index] = luaL_Reg{ name, &c_call<decltype(&T::size), &T::size> };
#else
typedef decltype(std::declval<T>().size()) R;
@ -164,7 +164,7 @@ namespace sol {
template <typename T, typename Regs>
inline void make_length_op_const(std::false_type, Regs& l, int& index) {
const char* name = to_string(meta_function::length).c_str();
#ifdef __clang__
#if defined(__clang__)
l[index] = luaL_Reg{ name, &c_call<decltype(&T::size), &T::size> };
#else
typedef decltype(std::declval<T>().size()) R;

View File

@ -216,7 +216,7 @@ namespace sol {
template <typename T, bool is_index>
inline int indexing_fail(lua_State* L) {
if (is_index) {
#if 0 //def SOL_SAFE_USERTYPE
#if 0 //defined(SOL_SAFE_USERTYPE) && SOL_SAFE_USERTYPE
auto maybeaccessor = stack::get<optional<string_view>>(L, is_index ? -1 : -2);
string_view accessor = maybeaccessor.value_or(string_detail::string_shim("(unknown)"));
return luaL_error(L, "sol: attempt to index (get) nil value \"%s\" on userdata (bad (misspelled?) key name or does not exist)", accessor.data());
@ -253,14 +253,14 @@ namespace sol {
return;
}
string_view& accessor_view = maybeaccessor.value();
#ifdef SOL_UNORDERED_MAP_COMPATIBLE_HASH
#if defined(SOL_UNORDERED_MAP_COMPATIBLE_HASH) && SOL_UNORDERED_MAP_COMPATIBLE_HASH
auto preexistingit = functions.find(accessor_view, string_view_hash(), std::equal_to<string_view>());
#else
std::string accessor(accessor_view.data(), accessor_view.size());
auto preexistingit = functions.find(accessor);
#endif
if (preexistingit == functions.cend()) {
#ifdef SOL_UNORDERED_MAP_COMPATIBLE_HASH
#if defined(SOL_UNORDERED_MAP_COMPATIBLE_HASH) && SOL_UNORDERED_MAP_COMPATIBLE_HASH
std::string accessor(accessor_view.data(), accessor_view.size());
#endif
functions.emplace_hint(preexistingit, std::move(accessor), object(L, 3));
@ -282,14 +282,14 @@ namespace sol {
mapping_t& mapping = umc.mapping;
std::vector<object>& runtime = umc.runtime;
int target = static_cast<int>(runtime.size());
#ifdef SOL_UNORDERED_MAP_COMPATIBLE_HASH
#if defined(SOL_UNORDERED_MAP_COMPATIBLE_HASH) && SOL_UNORDERED_MAP_COMPATIBLE_HASH
auto preexistingit = mapping.find(accessor_view, string_view_hash(), std::equal_to<string_view>());
#else
std::string accessor(accessor_view.data(), accessor_view.size());
auto preexistingit = mapping.find(accessor);
#endif
if (preexistingit == mapping.cend()) {
#ifdef SOL_UNORDERED_MAP_COMPATIBLE_HASH
#if defined(SOL_UNORDERED_MAP_COMPATIBLE_HASH) && SOL_UNORDERED_MAP_COMPATIBLE_HASH
std::string accessor(accessor_view.data(), accessor_view.size());
#endif
runtime.emplace_back(L, 3);
@ -486,7 +486,7 @@ namespace sol {
switch (mf) {
case meta_function::construct:
if (properties[i]) {
#ifndef SOL_NO_EXCEPTIONS
#if !(defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS)
throw error("sol: 2 separate constructor (new) functions were set on this type. Please specify only 1 sol::meta_function::construct/'new' type AND wrap the function in a sol::factories/initializers call, as shown by the documentation and examples, otherwise you may create problems");
#else
assert(false && "sol: 2 separate constructor (new) functions were set on this type. Please specify only 1 sol::meta_function::construct/'new' type AND wrap the function in a sol::factories/initializers call, as shown by the documentation and examples, otherwise you may create problems");
@ -495,7 +495,7 @@ namespace sol {
break;
case meta_function::garbage_collect:
if (destructfunc != nullptr) {
#ifndef SOL_NO_EXCEPTIONS
#if !(defined(SOL_NO_EXCEPTIONS) && SOL_NO_EXCEPTIONS)
throw error("sol: 2 separate constructor (new) functions were set on this type. Please specify only 1 sol::meta_function::construct/'new' type AND wrap the function in a sol::factories/initializers call, as shown by the documentation and examples, otherwise you may create problems");
#else
assert(false && "sol: 2 separate constructor (new) functions were set on this type. Please specify only 1 sol::meta_function::construct/'new' type AND wrap the function in a sol::factories/initializers call, as shown by the documentation and examples, otherwise you may create problems");
@ -576,7 +576,7 @@ namespace sol {
int runtime_target = 0;
usertype_detail::member_search member = nullptr;
{
#ifdef SOL_UNORDERED_MAP_COMPATIBLE_HASH
#if defined(SOL_UNORDERED_MAP_COMPATIBLE_HASH) && SOL_UNORDERED_MAP_COMPATIBLE_HASH
string_view name = stack::get<string_view>(L, keyidx);
auto memberit = f.mapping.find(name, string_view_hash(), std::equal_to<string_view>());
#else

View File

@ -225,7 +225,8 @@ namespace sol {
struct wrapper<R (O::*)(Args..., ...) const volatile&&> : public member_function_wrapper<R (O::*)(Args..., ...) const volatile&, R, O, Args...> {
};
#ifdef SOL_NOEXCEPT_FUNCTION_TYPE //noexcept has become a part of a function's type
#if defined(SOL_NOEXCEPT_FUNCTION_TYPE) && SOL_NOEXCEPT_FUNCTION_TYPE
//noexcept has become a part of a function's type
template <typename R, typename O, typename... Args>
struct wrapper<R (O::*)(Args...) noexcept> : public member_function_wrapper<R (O::*)(Args...) noexcept, R, O, Args...> {