-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathhelper.h
40 lines (37 loc) · 2.03 KB
/
helper.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
/* SPDX-License-Identifier: MIT */
/*
* Author: Jianhui Zhao <[email protected]>
*/
#ifndef __LUA_FFI_HELPER_H
#define __LUA_FFI_HELPER_H
#define stack_dump(L, title) \
do { \
int top = lua_gettop(L); \
int i; \
printf("--------stack dump:%s--------\n", title); \
for (i = 1; i <= top; i++) { \
int t = lua_type(L, i); \
printf("%2d: ", i); \
switch (t) { \
case LUA_TSTRING: \
printf("'%s'", lua_tostring(L, i)); \
break; \
case LUA_TBOOLEAN: \
printf(lua_toboolean(L, i) ? "true" : "false"); \
break; \
case LUA_TNUMBER: \
printf("%g", lua_tonumber(L, i)); \
break; \
case LUA_TLIGHTUSERDATA: \
printf("%p", lua_topointer(L, i)); \
break; \
default: \
printf("%s", lua_typename(L, t)); \
break; \
} \
printf(" "); \
} \
printf("\n"); \
printf("++++++++++++++++++++++++++\n"); \
} while (0)
#endif