-
Notifications
You must be signed in to change notification settings - Fork 0
/
nluadef.h
59 lines (47 loc) · 1.23 KB
/
nluadef.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* See Licensing and Copyright notice in naev.h
*/
#ifndef NLUADEF_H
# define NLUADEF_H
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#include "log.h"
/*
* debug stuff
*/
#ifdef DEBUGGING
#ifdef DEBUG_PARANOID
#define NLUA_DEBUG(str, args...) \
(DEBUG("Lua: "str"\n", ## args), abort())
#else /* DEBUG_PARANOID */
#define NLUA_DEBUG(str, args...) \
(DEBUG("Lua: "str"\n", ## args))
#endif /* DEBUG_PARANOID */
#define NLUA_INVALID_PARAMETER(L) \
{ \
DEBUG( "Invalid parameter for %s.", __func__ ); \
luaL_error( L, "Invalid parameter for %s.", __func__ ); \
return 0; \
}
#define NLUA_MIN_ARGS(n) \
if (lua_gettop(L) < n) { \
DEBUG( "Too few arguments for %s.", __func__ ); \
luaL_error( L, "Too few arguments for %s.", __func__ ); \
return 0; \
}
#else /* DEBUGGING */
#define NLUA_DEBUG(str, args...) do {;} while(0)
#define NLUA_MIN_ARGS(n) do {;} while(0)
#define NLUA_INVALID_PARAMETER(L) do {;} while(0)
#endif /* DEBUGGING */
/*
* Error stuff.
*/
#define NLUA_ERROR(L,str, args...) (luaL_error(L,str, ## args))
/*
* comfortability macros
*/
#define luaL_dobuffer(L, b, n, s) \
(luaL_loadbuffer(L, b, n, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
#endif /* NLUADEF_H */