1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-25 20:36:38 +02:00

lua: fix macros used to return values

This commit is contained in:
Sébastien Helleu
2018-07-13 21:25:51 +02:00
parent bf48efffec
commit 2682fb450d
2 changed files with 41 additions and 22 deletions
+40 -22
View File
@@ -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 */