Undocumented macro for turning of compat (for the time being)

adding of luaL_loadbufferx as part of the 5.1 compat layer
This commit is contained in:
ThePhD 2016-05-05 16:36:15 -04:00
parent 309947d704
commit 9f189df874
2 changed files with 26 additions and 0 deletions

View File

@ -26,6 +26,9 @@
// comes from https://github.com/keplerproject/lua-compat-5.2
// but has been modified in many places for use with Sol and luajit,
// though the core abstractions remain the same
#ifndef SOL_NO_COMPAT
#include "compatibility/version.hpp"
#ifdef __cplusplus
extern "C" {
@ -38,4 +41,6 @@ extern "C" {
}
#endif
#endif // SOL_NO_COMPAT
#endif // SOL_COMPATIBILITY_HPP

View File

@ -144,6 +144,27 @@ void luaL_pushresult(luaL_Buffer_52 *B);
#define luaL_pushresultsize(B, s) \
(luaL_addsize(B, s), luaL_pushresult(B))
typedef struct kepler_lua_compat_get_string_view {
const char *s;
size_t size;
} kepler_lua_compat_get_string_view;
inline const char* kepler_lua_compat_get_string(lua_State* L, void* ud, size_t* size) {
kepler_lua_compat_get_string_view* ls = (kepler_lua_compat_get_string_view*) ud;
(void)L;
if (ls->size == 0) return NULL;
*size = ls->size;
ls->size = 0;
return ls->s;
}
inline int luaL_loadbufferx(lua_State* L, const char* buff, size_t size, const char* name, const char* mode) {
kepler_lua_compat_get_string_view ls;
ls.s = buff;
ls.size = size;
return lua_load(L, getS, &ls, name, mode);
}
#endif /* Lua 5.1 */
#endif // SOL_5_1_0_H