mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
hunt down all uses of the k
variants of lua_pcall and lua_call
This commit is contained in:
parent
a6d209fbec
commit
2ca0393a94
|
@ -20,8 +20,8 @@
|
|||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// This file was generated with a script.
|
||||
// Generated 2017-09-10 01:37:11.449518 UTC
|
||||
// This header was generated with sol v2.18.2 (revision 8409a82)
|
||||
// Generated 2017-09-10 08:09:11.282097 UTC
|
||||
// This header was generated with sol v2.18.2 (revision a6d209f)
|
||||
// https://github.com/ThePhD/sol2
|
||||
|
||||
#ifndef SOL_SINGLE_INCLUDE_HPP
|
||||
|
@ -1933,6 +1933,25 @@ COMPAT53_API void luaL_requiref (lua_State *L, const char *modname,
|
|||
/* definitions for Lua 5.1 only */
|
||||
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 501
|
||||
|
||||
#if defined(__GLIBC__) || defined(_POSIX_VERSION) || defined(__APPLE__) || (!defined (__MINGW32__) && defined(__GNUC__) && (__GNUC__ < 6))
|
||||
#ifndef COMPAT53_HAVE_STRERROR_R
|
||||
#define COMPAT53_HAVE_STRERROR_R
|
||||
#endif // have strerror_r
|
||||
#if ((defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || (defined(_XOPEN_SOURCE) || _XOPEN_SOURCE >= 600)) && (!defined(_GNU_SOURCE) || !_GNU_SOURCE)
|
||||
#ifndef COMPAT53_HAVE_STRERROR_R_XSI
|
||||
#define COMPAT53_HAVE_STRERROR_R_XSI
|
||||
#endif // XSI-Compliant strerror_r
|
||||
#else
|
||||
#ifndef COMPAT53_HAVE_STRERROR_R_GNU
|
||||
#define COMPAT53_HAVE_STRERROR_R_GNU
|
||||
#endif // GNU variant strerror_r
|
||||
#endif // XSI/Posix vs. GNU strerror_r
|
||||
#elif defined(_MSC_VER) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || defined(__STDC_LIB_EXT1__)
|
||||
#ifndef COMPAT53_HAVE_STRERROR_S
|
||||
#define COMPAT53_HAVE_STRERROR_S
|
||||
#endif // GNU variant strerror_r
|
||||
#endif // strerror_r vs. strerror_s vs. strerror usage
|
||||
|
||||
#ifndef COMPAT53_LUA_FILE_BUFFER_SIZE
|
||||
#define COMPAT53_LUA_FILE_BUFFER_SIZE 4096
|
||||
#endif // Lua File Buffer Size
|
||||
|
@ -2250,36 +2269,37 @@ COMPAT53_API void luaL_traceback (lua_State *L, lua_State *L1,
|
|||
COMPAT53_API int luaL_fileresult (lua_State *L, int stat, const char *fname) {
|
||||
const char* s = NULL;
|
||||
int en = errno; /* calls to Lua API may change this value */
|
||||
#if defined(COMPAT53_HAVE_STRERROR_R) || defined(COMPAT53_HAVE_STRERROR_S)
|
||||
char buf[512] = { 0 };
|
||||
#endif // buffer for threadsafe variants of strerror if possible
|
||||
if (stat) {
|
||||
lua_pushboolean(L, 1);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
lua_pushnil(L);
|
||||
#if defined(__GLIBC__) || defined(_POSIX_VERSION) || defined(__APPLE__) || (!defined (__MINGW32__) && defined(__GNUC__) && (__GNUC__ < 6))
|
||||
#if defined(COMPAT53_HAVE_STRERROR_R)
|
||||
/* use strerror_r here, because it's available on these specific platforms */
|
||||
char buf[512] = {0};
|
||||
#if ((defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || (defined(_XOPEN_SOURCE) || _XOPEN_SOURCE >= 600)) && (!defined(_GNU_SOURCE) || !_GNU_SOURCE)
|
||||
#if defined(COMPAT53_HAVE_STRERROR_R_XSI)
|
||||
/* XSI Compliant */
|
||||
strerror_r(en, buf, 512);
|
||||
s = buf;
|
||||
#else
|
||||
/* GNU-specific which returns const char* */
|
||||
/* GNU-specific which returns const char* */
|
||||
s = strerror_r(en, buf, 512);
|
||||
#endif
|
||||
#elif defined(_MSC_VER) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
|
||||
#elif defined(COMPAT53_HAVE_STRERROR_S)
|
||||
/* for MSVC and other C11 implementations, use strerror_s
|
||||
* since it's provided by default by the libraries
|
||||
*/
|
||||
char buf[512] = {0};
|
||||
*/
|
||||
strerror_s(buf, 512, en);
|
||||
s = buf;
|
||||
#else
|
||||
/* fallback, but
|
||||
* strerror is not guaranteed to be threadsafe due to modifying
|
||||
* errno itself and some impls not locking a static buffer for it
|
||||
* ... but it works in 99% of cases, so I don't need the reason to stop
|
||||
* the train now
|
||||
* ... but most known systems have threadsafe errno: this might only change
|
||||
* if the locale is changed out from under someone while this function is being called
|
||||
*/
|
||||
s = strerror(en);
|
||||
#endif
|
||||
|
@ -2292,7 +2312,7 @@ COMPAT53_API int luaL_fileresult (lua_State *L, int stat, const char *fname) {
|
|||
}
|
||||
}
|
||||
|
||||
static const char* compat53_f_parser_handler (lua_State *L, void *data, size_t *size) {
|
||||
static const char* compat53_f_parser_handler (lua_State *, void *data, size_t *size) {
|
||||
struct compat53_f_parser_buffer *p = (struct compat53_f_parser_buffer*)data;
|
||||
size_t readcount = fread(p->buffer + p->start, sizeof(*p->buffer), sizeof(p->buffer), p->file);
|
||||
if (ferror(p->file) != 0 || feof(p->file) != 0) {
|
||||
|
@ -2314,10 +2334,10 @@ static int checkmode (lua_State *L, const char *mode, const char *modename, int
|
|||
|
||||
COMPAT53_API int luaL_loadfilex (lua_State *L, const char *filename, const char *mode) {
|
||||
FILE* fp;
|
||||
int err;
|
||||
int c;
|
||||
int status = LUA_OK;
|
||||
#if defined(_MSC_VER)
|
||||
int err = 0;
|
||||
err = fopen_s(&fp, filename, "rb");
|
||||
if (err != 0) {
|
||||
fclose(fp);
|
||||
|
@ -11561,7 +11581,7 @@ namespace sol {
|
|||
class basic_function : public base_t {
|
||||
private:
|
||||
void luacall(std::ptrdiff_t argcount, std::ptrdiff_t resultcount) const {
|
||||
lua_callk(lua_state(), static_cast<int>(argcount), static_cast<int>(resultcount), 0, nullptr);
|
||||
lua_call(lua_state(), static_cast<int>(argcount), static_cast<int>(resultcount));
|
||||
}
|
||||
|
||||
template<std::size_t... I, typename... Ret>
|
||||
|
@ -11847,7 +11867,7 @@ namespace sol {
|
|||
private:
|
||||
template <bool b>
|
||||
call_status luacall(std::ptrdiff_t argcount, std::ptrdiff_t resultcount, detail::protected_handler<b, handler_t>& h) const {
|
||||
return static_cast<call_status>(lua_pcallk(lua_state(), static_cast<int>(argcount), static_cast<int>(resultcount), h.stackindex, 0, nullptr));
|
||||
return static_cast<call_status>(lua_pcall(lua_state(), static_cast<int>(argcount), static_cast<int>(resultcount), h.stackindex));
|
||||
}
|
||||
|
||||
template<std::size_t... I, bool b, typename... Ret>
|
||||
|
@ -15519,7 +15539,7 @@ namespace sol {
|
|||
for (int i = 1; i <= before; ++i) {
|
||||
lua_pushvalue(L, i);
|
||||
}
|
||||
lua_callk(L, before, LUA_MULTRET, 0, nullptr);
|
||||
lua_call(L, before, LUA_MULTRET);
|
||||
int after = lua_gettop(L);
|
||||
return after - before;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace sol {
|
|||
for (int i = 1; i <= before; ++i) {
|
||||
lua_pushvalue(L, i);
|
||||
}
|
||||
lua_callk(L, before, LUA_MULTRET, 0, nullptr);
|
||||
lua_call(L, before, LUA_MULTRET);
|
||||
int after = lua_gettop(L);
|
||||
return after - before;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user