/script_binding/lua/lua_ftk_file.c

http://ftk.googlecode.com/ · C · 59 lines · 46 code · 12 blank · 1 comment · 1 complexity · 22d596f1acd3a822d80636a8ee6b6aef MD5 · raw file

  1. /*This file is generated by luagen.*/
  2. #include "lua_ftk_file.h"
  3. #include "lua_ftk_callbacks.h"
  4. static void tolua_reg_types (lua_State* L)
  5. {
  6. tolua_usertype(L, "FtkFile");
  7. }
  8. static int lua_ftk_file_get_info(lua_State* L)
  9. {
  10. tolua_Error err = {0};
  11. Ret retv;
  12. const char* file_name;
  13. FtkFileInfo* info;
  14. int param_ok = tolua_isstring(L, 1, 0, &err) && tolua_isusertype(L, 2, "FtkFileInfo", 0, &err);
  15. return_val_if_fail(param_ok, 0);
  16. file_name = tolua_tostring(L, 1, 0);
  17. info = tolua_tousertype(L, 2, 0);
  18. retv = ftk_file_get_info(file_name, info);
  19. tolua_pushnumber(L, (lua_Number)retv);
  20. return 1;
  21. }
  22. static int lua_ftk_file_get_mime_type(lua_State* L)
  23. {
  24. tolua_Error err = {0};
  25. const char* retv;
  26. const char* file_name;
  27. int param_ok = tolua_isstring(L, 1, 0, &err);
  28. return_val_if_fail(param_ok, 0);
  29. file_name = tolua_tostring(L, 1, 0);
  30. retv = ftk_file_get_mime_type(file_name);
  31. tolua_pushstring(L, (const char*)retv);
  32. return 1;
  33. }
  34. int tolua_ftk_file_init(lua_State* L)
  35. {
  36. tolua_open(L);
  37. tolua_reg_types(L);
  38. tolua_module(L, NULL, 0);
  39. tolua_beginmodule(L, NULL);
  40. tolua_cclass(L,"FtkFile", "FtkFile", "", NULL);
  41. tolua_beginmodule(L, "FtkFile");
  42. tolua_function(L, "GetInfo", lua_ftk_file_get_info);
  43. tolua_function(L, "GetMimeType", lua_ftk_file_get_mime_type);
  44. tolua_endmodule(L);
  45. tolua_endmodule(L);
  46. return 1;
  47. }