PageRenderTime 305ms CodeModel.GetById 140ms app.highlight 63ms RepoModel.GetById 98ms app.codeStats 0ms

/script_binding/lua/lua_ftk_structs.c

http://ftk.googlecode.com/
C | 362 lines | 291 code | 71 blank | 0 comment | 30 complexity | e0cee8c6486d31bcb78bc55349a1d862 MD5 | raw file
  1
  2#include "lua_ftk_typedef.h"
  3#include "lua_ftk_structs.h"
  4
  5static void tolua_reg_types (lua_State* L)
  6{
  7	tolua_usertype(L, "FtkGc");
  8	tolua_usertype(L, "FtkEvent");
  9}
 10
 11int lua_ftk_gc_create(lua_State* L)
 12{
 13	FtkGc* retv = calloc(1, sizeof(FtkGc));
 14	tolua_pushusertype_and_takeownership(L, (void*)retv, "FtkGc");
 15
 16	return 1;
 17}
 18
 19static int tolua_get_FtkGc_ref(lua_State* L)
 20{
 21	lua_Number retv;
 22	FtkGc* thiz = (FtkGc*)  tolua_tousertype(L, 1, 0);
 23	return_val_if_fail(thiz != NULL, 0);
 24	retv = (lua_Number)thiz->ref;
 25	tolua_pushnumber(L, (lua_Number)retv);
 26
 27	return 1;
 28}
 29
 30static int tolua_set_FtkGc_ref(lua_State* L)
 31{
 32	FtkGc* thiz = (FtkGc*)  tolua_tousertype(L, 1, 0);
 33	return_val_if_fail(thiz != NULL, 0);
 34	thiz->ref = (int) (tolua_tonumber(L, 2, 0));
 35
 36	return 1;
 37}
 38
 39static int tolua_get_FtkGc_mask(lua_State* L)
 40{
 41	lua_Number retv;
 42	FtkGc* thiz = (FtkGc*)  tolua_tousertype(L, 1, 0);
 43	return_val_if_fail(thiz != NULL, 0);
 44	retv = (lua_Number)thiz->mask;
 45	tolua_pushnumber(L, (lua_Number)retv);
 46
 47	return 1;
 48}
 49
 50static int tolua_set_FtkGc_mask(lua_State* L)
 51{
 52	FtkGc* thiz = (FtkGc*)  tolua_tousertype(L, 1, 0);
 53	return_val_if_fail(thiz != NULL, 0);
 54	thiz->mask = (int) (tolua_tonumber(L, 2, 0));
 55
 56	return 1;
 57}
 58
 59static int tolua_get_FtkGc_bg(lua_State* L)
 60{
 61	void* retv;
 62	FtkGc* thiz = (FtkGc*)  tolua_tousertype(L, 1, 0);
 63	return_val_if_fail(thiz != NULL, 0);
 64	retv = (void*)&(thiz->bg);
 65	tolua_pushusertype(L, retv, "FtkColor");
 66
 67	return 1;
 68}
 69
 70static int tolua_set_FtkGc_bg(lua_State* L)
 71{
 72	FtkGc* thiz = (FtkGc*)  tolua_tousertype(L, 1, 0);
 73	return_val_if_fail(thiz != NULL, 0);
 74	thiz->bg = (*(FtkColor*)tolua_tousertype(L, 2, 0));
 75
 76	return 1;
 77}
 78
 79static int tolua_get_FtkGc_fg(lua_State* L)
 80{
 81	void* retv;
 82	FtkGc* thiz = (FtkGc*)  tolua_tousertype(L, 1, 0);
 83	return_val_if_fail(thiz != NULL, 0);
 84	retv = (void*)&(thiz->fg);
 85	tolua_pushusertype(L, retv, "FtkColor");
 86
 87	return 1;
 88}
 89
 90static int tolua_set_FtkGc_fg(lua_State* L)
 91{
 92	FtkGc* thiz = (FtkGc*)  tolua_tousertype(L, 1, 0);
 93	return_val_if_fail(thiz != NULL, 0);
 94	thiz->fg = (*(FtkColor*)tolua_tousertype(L, 2, 0));
 95
 96	return 1;
 97}
 98
 99static int tolua_get_FtkGc_bitmap(lua_State* L)
100{
101	void* retv;
102	FtkGc* thiz = (FtkGc*)  tolua_tousertype(L, 1, 0);
103	return_val_if_fail(thiz != NULL, 0);
104	retv = (void*)thiz->bitmap;
105	tolua_pushusertype(L, (FtkBitmap*)retv, "FtkBitmap");
106
107	return 1;
108}
109
110static int tolua_set_FtkGc_bitmap(lua_State* L)
111{
112	FtkGc* thiz = (FtkGc*)  tolua_tousertype(L, 1, 0);
113	return_val_if_fail(thiz != NULL, 0);
114	thiz->bitmap = (FtkBitmap*) (tolua_tousertype(L, 2, 0));
115
116	return 1;
117}
118
119static int tolua_get_FtkGc_alpha(lua_State* L)
120{
121	lua_Number retv;
122	FtkGc* thiz = (FtkGc*)  tolua_tousertype(L, 1, 0);
123	return_val_if_fail(thiz != NULL, 0);
124	retv = thiz->alpha;
125	tolua_pushnumber(L, (lua_Number)retv);
126
127	return 1;
128}
129
130static int tolua_set_FtkGc_alpha(lua_State* L)
131{
132	FtkGc* thiz = (FtkGc*)  tolua_tousertype(L, 1, 0);
133	return_val_if_fail(thiz != NULL, 0);
134	thiz->alpha = (char)tolua_tonumber(L, 2, 0);
135
136	return 1;
137}
138
139static int tolua_get_FtkGc_line_mask(lua_State* L)
140{
141	lua_Number retv;
142	FtkGc* thiz = (FtkGc*)  tolua_tousertype(L, 1, 0);
143	return_val_if_fail(thiz != NULL, 0);
144	retv = (lua_Number)thiz->line_mask;
145	tolua_pushnumber(L, (lua_Number)retv);
146
147	return 1;
148}
149
150static int tolua_set_FtkGc_line_mask(lua_State* L)
151{
152	FtkGc* thiz = (FtkGc*)  tolua_tousertype(L, 1, 0);
153	return_val_if_fail(thiz != NULL, 0);
154	thiz->line_mask = (int) (tolua_tonumber(L, 2, 0));
155
156	return 1;
157}
158
159int lua_ftk_event_create(lua_State* L)
160{
161	FtkEvent* retv = calloc(1, sizeof(FtkEvent));
162	tolua_pushusertype_and_takeownership(L, (void*)retv, "FtkEvent");
163
164	return 1;
165}
166
167static int tolua_get_FtkEvent_type(lua_State* L)
168{
169	lua_Number retv;
170	FtkEvent* thiz = (FtkEvent*)  tolua_tousertype(L, 1, 0);
171	return_val_if_fail(thiz != NULL, 0);
172	retv = (lua_Number)thiz->type;
173	tolua_pushnumber(L, (lua_Number)retv);
174
175	return 1;
176}
177
178static int tolua_set_FtkEvent_type(lua_State* L)
179{
180	FtkEvent* thiz = (FtkEvent*)  tolua_tousertype(L, 1, 0);
181	return_val_if_fail(thiz != NULL, 0);
182	thiz->type = tolua_tonumber(L, 2, 0);
183
184	return 1;
185}
186
187static int tolua_get_FtkEvent_widget(lua_State* L)
188{
189	void* retv;
190	FtkEvent* thiz = (FtkEvent*)  tolua_tousertype(L, 1, 0);
191	return_val_if_fail(thiz != NULL, 0);
192	retv = (void*)thiz->widget;
193	tolua_pushusertype(L, (FtkWidget*)retv, "FtkWidget");
194
195	return 1;
196}
197
198static int tolua_set_FtkEvent_widget(lua_State* L)
199{
200	FtkEvent* thiz = (FtkEvent*)  tolua_tousertype(L, 1, 0);
201	return_val_if_fail(thiz != NULL, 0);
202	thiz->widget = (FtkWidget*) (tolua_tousertype(L, 2, 0));
203
204	return 1;
205}
206
207static int tolua_get_FtkEvent_time(lua_State* L)
208{
209	lua_Number retv;
210	FtkEvent* thiz = (FtkEvent*)  tolua_tousertype(L, 1, 0);
211	return_val_if_fail(thiz != NULL, 0);
212	retv = (lua_Number)thiz->time;
213	tolua_pushnumber(L, (lua_Number)retv);
214
215	return 1;
216}
217
218static int tolua_set_FtkEvent_time(lua_State* L)
219{
220	FtkEvent* thiz = (FtkEvent*)  tolua_tousertype(L, 1, 0);
221	return_val_if_fail(thiz != NULL, 0);
222	thiz->time = (int) (tolua_tonumber(L, 2, 0));
223
224	return 1;
225}
226
227static int tolua_get_FtkEvent_u_key_code(lua_State* L)
228{
229	lua_Number retv;
230	FtkEvent* thiz = (FtkEvent*)  tolua_tousertype(L, 1, 0);
231	return_val_if_fail(thiz != NULL, 0);
232	retv = (lua_Number)thiz->u.key.code;
233	tolua_pushnumber(L, (lua_Number)retv);
234
235	return 1;
236}
237
238static int tolua_set_FtkEvent_u_key_code(lua_State* L)
239{
240	FtkEvent* thiz = (FtkEvent*)  tolua_tousertype(L, 1, 0);
241	return_val_if_fail(thiz != NULL, 0);
242	thiz->u.key.code = (int) (tolua_tonumber(L, 2, 0));
243
244	return 1;
245}
246
247static int tolua_get_FtkEvent_u_mouse_press(lua_State* L)
248{
249	lua_Number retv;
250	FtkEvent* thiz = (FtkEvent*)  tolua_tousertype(L, 1, 0);
251	return_val_if_fail(thiz != NULL, 0);
252	retv = (lua_Number)thiz->u.mouse.press;
253	tolua_pushnumber(L, (lua_Number)retv);
254
255	return 1;
256}
257
258static int tolua_set_FtkEvent_u_mouse_press(lua_State* L)
259{
260	FtkEvent* thiz = (FtkEvent*)  tolua_tousertype(L, 1, 0);
261	return_val_if_fail(thiz != NULL, 0);
262	thiz->u.mouse.press = (int) (tolua_tonumber(L, 2, 0));
263
264	return 1;
265}
266
267static int tolua_get_FtkEvent_u_mouse_button(lua_State* L)
268{
269	lua_Number retv;
270	FtkEvent* thiz = (FtkEvent*)  tolua_tousertype(L, 1, 0);
271	return_val_if_fail(thiz != NULL, 0);
272	retv = (lua_Number)thiz->u.mouse.button;
273	tolua_pushnumber(L, (lua_Number)retv);
274
275	return 1;
276}
277
278static int tolua_set_FtkEvent_u_mouse_button(lua_State* L)
279{
280	FtkEvent* thiz = (FtkEvent*)  tolua_tousertype(L, 1, 0);
281	return_val_if_fail(thiz != NULL, 0);
282	thiz->u.mouse.button = (int) (tolua_tonumber(L, 2, 0));
283
284	return 1;
285}
286
287static int tolua_get_FtkEvent_u_mouse_x(lua_State* L)
288{
289	lua_Number retv;
290	FtkEvent* thiz = (FtkEvent*)  tolua_tousertype(L, 1, 0);
291	return_val_if_fail(thiz != NULL, 0);
292	retv = (lua_Number)thiz->u.mouse.x;
293	tolua_pushnumber(L, (lua_Number)retv);
294
295	return 1;
296}
297
298static int tolua_set_FtkEvent_u_mouse_x(lua_State* L)
299{
300	FtkEvent* thiz = (FtkEvent*)  tolua_tousertype(L, 1, 0);
301	return_val_if_fail(thiz != NULL, 0);
302	thiz->u.mouse.x = (int) (tolua_tonumber(L, 2, 0));
303
304	return 1;
305}
306
307static int tolua_get_FtkEvent_u_mouse_y(lua_State* L)
308{
309	lua_Number retv;
310	FtkEvent* thiz = (FtkEvent*)  tolua_tousertype(L, 1, 0);
311	return_val_if_fail(thiz != NULL, 0);
312	retv = (lua_Number)thiz->u.mouse.y;
313	tolua_pushnumber(L, (lua_Number)retv);
314
315	return 1;
316}
317
318static int tolua_set_FtkEvent_u_mouse_y(lua_State* L)
319{
320	FtkEvent* thiz = (FtkEvent*)  tolua_tousertype(L, 1, 0);
321	return_val_if_fail(thiz != NULL, 0);
322	thiz->u.mouse.y = (int) (tolua_tonumber(L, 2, 0));
323
324	return 1;
325}
326
327int tolua_ftk_structs_init(lua_State* L)
328{
329	tolua_open(L);
330	tolua_reg_types(L);
331	tolua_module(L, NULL, 0);
332	tolua_beginmodule(L, NULL);
333
334	tolua_cclass(L, "FtkEvent", "FtkEvent", "", NULL);
335	tolua_beginmodule(L, "FtkEvent");
336	tolua_function(L, "Create", lua_ftk_event_create);
337	tolua_variable(L, "type",tolua_get_FtkEvent_type, tolua_set_FtkEvent_type);
338	tolua_variable(L, "widget",tolua_get_FtkEvent_widget, tolua_set_FtkEvent_widget);
339	tolua_variable(L, "time",tolua_get_FtkEvent_time, tolua_set_FtkEvent_time);
340	tolua_variable(L, "u_key_code",tolua_get_FtkEvent_u_key_code, tolua_set_FtkEvent_u_key_code);
341	tolua_variable(L, "u_mouse_press",tolua_get_FtkEvent_u_mouse_press, tolua_set_FtkEvent_u_mouse_press);
342	tolua_variable(L, "u_mouse_button",tolua_get_FtkEvent_u_mouse_button, tolua_set_FtkEvent_u_mouse_button);
343	tolua_variable(L, "u_mouse_x",tolua_get_FtkEvent_u_mouse_x, tolua_set_FtkEvent_u_mouse_x);
344	tolua_variable(L, "u_mouse_y",tolua_get_FtkEvent_u_mouse_y, tolua_set_FtkEvent_u_mouse_y);
345	tolua_endmodule(L);
346	
347	tolua_cclass(L, "FtkGc", "FtkGc", "", NULL);
348	tolua_beginmodule(L, "FtkGc");
349	tolua_function(L, "Create", lua_ftk_gc_create);
350	tolua_variable(L, "ref",tolua_get_FtkGc_ref, tolua_set_FtkGc_ref);
351	tolua_variable(L, "mask",tolua_get_FtkGc_mask, tolua_set_FtkGc_mask);
352	tolua_variable(L, "bg",tolua_get_FtkGc_bg, tolua_set_FtkGc_bg);
353	tolua_variable(L, "fg",tolua_get_FtkGc_fg, tolua_set_FtkGc_fg);
354	tolua_variable(L, "bitmap",tolua_get_FtkGc_bitmap, tolua_set_FtkGc_bitmap);
355	tolua_variable(L, "alpha",tolua_get_FtkGc_alpha, tolua_set_FtkGc_alpha);
356	tolua_variable(L, "line_mask",tolua_get_FtkGc_line_mask, tolua_set_FtkGc_line_mask);
357	tolua_endmodule(L);
358	
359	tolua_endmodule(L);
360
361	return 1;
362}