mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
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:
parent
309947d704
commit
9f189df874
@ -26,6 +26,9 @@
|
|||||||
// comes from https://github.com/keplerproject/lua-compat-5.2
|
// comes from https://github.com/keplerproject/lua-compat-5.2
|
||||||
// but has been modified in many places for use with Sol and luajit,
|
// but has been modified in many places for use with Sol and luajit,
|
||||||
// though the core abstractions remain the same
|
// though the core abstractions remain the same
|
||||||
|
|
||||||
|
#ifndef SOL_NO_COMPAT
|
||||||
|
|
||||||
#include "compatibility/version.hpp"
|
#include "compatibility/version.hpp"
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -38,4 +41,6 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // SOL_NO_COMPAT
|
||||||
|
|
||||||
#endif // SOL_COMPATIBILITY_HPP
|
#endif // SOL_COMPATIBILITY_HPP
|
||||||
|
@ -144,6 +144,27 @@ void luaL_pushresult(luaL_Buffer_52 *B);
|
|||||||
#define luaL_pushresultsize(B, s) \
|
#define luaL_pushresultsize(B, s) \
|
||||||
(luaL_addsize(B, s), luaL_pushresult(B))
|
(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 /* Lua 5.1 */
|
||||||
|
|
||||||
#endif // SOL_5_1_0_H
|
#endif // SOL_5_1_0_H
|
Loading…
x
Reference in New Issue
Block a user