-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathIO.cpp
More file actions
131 lines (100 loc) · 2.59 KB
/
IO.cpp
File metadata and controls
131 lines (100 loc) · 2.59 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include "../funcs.h"
#include "../utils.h"
#include "../template/out.h"
static const struct luaL_Reg io_funcs[] = {
#if AF_API_VERSION >= 31
{
"af_delete_image_memory", [](lua_State * L)
{
lua_settop(L, 1); // ptr
af_err err = af_delete_image_memory(GetMemory(L, 1));
lua_pushinteger(L, err);// ptr, err
return 1;
}
},
#endif
OUT_ARG2(load_image, STRING_PROXY, bool),
#if AF_API_VERSION >= 31
{
"af_load_image_memory", [](lua_State * L)
{
lua_settop(L, 1); // ptr
af_array * arr_ud = NewArray(L);// ptr, arr_ud
af_err err = af_load_image_memory(arr_ud, GetMemory(L, 1));
return PushErr(L, err); // ptr, err, arr_ud
}
},
#endif
#if AF_API_VERSION >= 32
{
"af_load_image_native", [](lua_State * L)
{
lua_settop(L, 1); // filename
af_array * arr_ud = NewArray(L);// filename, arr_ud
af_err err = af_load_image_native(arr_ud, S(L, 1));
return PushErr(L, err); // filename, err, arr_ud
}
},
#endif
OUT_ARG2(read_array_index, STRING_PROXY, unsigned),
OUT_ARG2(read_array_key, STRING_PROXY, STRING_PROXY),
{
"af_read_array_key_check", [](lua_State * L)
{
lua_settop(L, 2); // filename, key
int index = -1;
af_err err = af_read_array_key_check(&index, S(L, 1), S(L, 2));
lua_pushinteger(L, err);// filename, key, err
lua_pushinteger(L, index); // filename, key, err, index
return 2;
}
}, {
"af_save_array", [](lua_State * L)
{
lua_settop(L, 4); // key, arr, filename, append
int index = -1;
af_err err = af_save_array(&index, S(L, 1), GetArray(L, 2), S(L, 3), B(L, 4));
lua_pushinteger(L, err);// key, arr, filename, append, err
lua_pushinteger(L, index); // key, arr, filename, append, err, index
return 2;
}
}, {
"af_save_image", [](lua_State * L)
{
lua_settop(L, 2); // filename, arr
af_err err = af_save_image(S(L, 1), GetArray(L, 2));
lua_pushinteger(L, err);// filename, arr, err
return 1;
}
},
#if AF_API_VERSION >= 31
{
"af_save_image_memory", [](lua_State * L)
{
lua_settop(L, 2); // arr, format
void * ptr;
af_err err = af_save_image_memory(&ptr, GetArray(L, 1), Arg<af_image_format>(L, 2));
lua_pushinteger(L, err);// arr, format, err
lua_pushlightuserdata(L, ptr); // arr, format, err, ptr
return 2;
}
},
#endif
#if AF_API_VERSION >= 32
{
"af_save_image_native", [](lua_State * L)
{
lua_settop(L, 2); // filename, arr
af_err err = af_save_image_native(S(L, 1), GetArray(L, 2));
lua_pushinteger(L, err);// filename, arr, err
return 1;
}
},
#endif
{ NULL, NULL }
};
int IO (lua_State * L)
{
luaL_register(L, NULL, io_funcs);
return 0;
}