lua: fix macros used to return values
parent
bf48efffec
commit
2682fb450d
|
@ -56,6 +56,7 @@ Bug fixes::
|
|||
* irc: send whole IRC message including IRCv3 tags in the signals irc_in, irc_in2, irc_raw_in and irc_raw_in2 (issue #787)
|
||||
* irc: fix memory leak when receiving a message with IRCv3 tags
|
||||
* guile: fix memory leak in 7 functions returning allocated strings
|
||||
* lua: fix macros used to return values
|
||||
* php: fix return code of functions config_write_option and config_write_line
|
||||
* php: fix memory leak in 72 functions returning allocated strings
|
||||
* python: fix crash when loading a script with Python >= 3.7 (issue #1219)
|
||||
|
|
|
@ -70,38 +70,56 @@
|
|||
#define API_STATIC_STRING(__string) \
|
||||
plugin_script_get_static_string(&lua_data, __string);
|
||||
#define API_RETURN_OK \
|
||||
lua_pushinteger (L, 1); \
|
||||
return 1
|
||||
{ \
|
||||
lua_pushinteger (L, 1); \
|
||||
return 1; \
|
||||
}
|
||||
#define API_RETURN_ERROR \
|
||||
lua_pushinteger (L, 0); \
|
||||
return 1
|
||||
{ \
|
||||
lua_pushinteger (L, 0); \
|
||||
return 1; \
|
||||
}
|
||||
#define API_RETURN_EMPTY \
|
||||
lua_pushstring (L, ""); \
|
||||
return 0
|
||||
{ \
|
||||
lua_pushstring (L, ""); \
|
||||
return 0; \
|
||||
}
|
||||
#define API_RETURN_STRING(__string) \
|
||||
lua_pushstring (L, \
|
||||
(__string) ? __string : ""); \
|
||||
return 1
|
||||
{ \
|
||||
lua_pushstring (L, \
|
||||
(__string) ? __string : ""); \
|
||||
return 1; \
|
||||
}
|
||||
#define API_RETURN_STRING_FREE(__string) \
|
||||
lua_pushstring (L, \
|
||||
(__string) ? __string : ""); \
|
||||
if (__string) \
|
||||
free (__string); \
|
||||
return 1
|
||||
{ \
|
||||
lua_pushstring (L, \
|
||||
(__string) ? __string : ""); \
|
||||
if (__string) \
|
||||
free (__string); \
|
||||
return 1; \
|
||||
}
|
||||
#if LUA_VERSION_NUM >= 503
|
||||
#define API_RETURN_INT(__int) \
|
||||
lua_pushinteger (L, __int); \
|
||||
return 1
|
||||
{ \
|
||||
lua_pushinteger (L, __int); \
|
||||
return 1; \
|
||||
}
|
||||
#define API_RETURN_LONG(__long) \
|
||||
lua_pushinteger (L, __long); \
|
||||
return 1
|
||||
{ \
|
||||
lua_pushinteger (L, __long); \
|
||||
return 1; \
|
||||
}
|
||||
#else
|
||||
#define API_RETURN_INT(__int) \
|
||||
lua_pushnumber (L, __int); \
|
||||
return 1
|
||||
{ \
|
||||
lua_pushnumber (L, __int); \
|
||||
return 1; \
|
||||
}
|
||||
#define API_RETURN_LONG(__long) \
|
||||
lua_pushnumber (L, __long); \
|
||||
return 1
|
||||
{ \
|
||||
lua_pushnumber (L, __long); \
|
||||
return 1; \
|
||||
}
|
||||
#endif /* LUA_VERSION_NUM >= 503 */
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue