-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathUtil.cpp
More file actions
63 lines (46 loc) · 1.23 KB
/
Util.cpp
File metadata and controls
63 lines (46 loc) · 1.23 KB
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
60
61
62
#include "../funcs.h"
#include "../template/in.h"
static const struct luaL_Reg util_funcs[] = {
IN_NONE(print_array),
#if AF_API_VERSION >= 31
{
"af_print_array_gen", [](lua_State * L)
{
lua_settop(L, 3); // exp, arr, precision
af_err err = af_print_array_gen(S(L, 1), GetArray(L, 2), I(L, 3));
lua_pushinteger(L, err);// exp, arr, precision, err
return 1;
}
}, {
"af_array_to_string", [](lua_State * L)
{
lua_settop(L, 4); // exp, arr, precision, transpose
char * output;
af_err err = af_array_to_string(&output, S(L, 1), GetArray(L, 2), I(L, 3), B(L, 4));
lua_pushinteger(L, err);// exp, arr, precision, transpose, err
lua_pushstring(L, output); // exp, arr, precision, transpose, output
free(output);
return 2;
}
},
#endif
{
"af_get_version", [](lua_State * L)
{
lua_settop(L, 0); // (empty)
int major, minor, patch;
af_err err = af_get_version(&major, &minor, &patch);
lua_pushinteger(L, err);// err
lua_pushinteger(L, major); // err, major
lua_pushinteger(L, minor); // err, major, minor
lua_pushinteger(L, patch); // err, major, minor, patch
return 4;
}
},
{ NULL, NULL }
};
int Util (lua_State * L)
{
luaL_register(L, NULL, util_funcs);
return 0;
}