PageRenderTime 51ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/linkermod/toluainterface.cpp

http://luaboost.googlecode.com/
C++ | 303 lines | 257 code | 25 blank | 21 comment | 19 complexity | 43379e74260049cf733829eac4e694af MD5 | raw file
  1. /*
  2. ** Lua binding: interface
  3. ** Generated automatically by tolua++-1.0.92 on 02/16/09 11:38:00.
  4. */
  5. #ifndef __cplusplus
  6. #include "stdlib.h"
  7. #endif
  8. #include "string.h"
  9. #include "tolua++.h"
  10. /* Exported function */
  11. TOLUA_API int tolua_interface_open (lua_State* tolua_S);
  12. #include "interface.h"
  13. /* function to release collected object via destructor */
  14. #ifdef __cplusplus
  15. static int tolua_collect_Ss (lua_State* tolua_S)
  16. {
  17. Ss* self = (Ss*) tolua_tousertype(tolua_S,1,0);
  18. Mtolua_delete(self);
  19. return 0;
  20. }
  21. #endif
  22. /* function to register type */
  23. static void tolua_reg_types (lua_State* tolua_S)
  24. {
  25. tolua_usertype(tolua_S,"Ss");
  26. }
  27. /* method: new of class Ss */
  28. #ifndef TOLUA_DISABLE_tolua_interface_Ss_new00
  29. static int tolua_interface_Ss_new00(lua_State* tolua_S)
  30. {
  31. #ifndef TOLUA_RELEASE
  32. tolua_Error tolua_err;
  33. if (
  34. !tolua_isusertable(tolua_S,1,"Ss",0,&tolua_err) ||
  35. !tolua_isnoobj(tolua_S,2,&tolua_err)
  36. )
  37. goto tolua_lerror;
  38. else
  39. #endif
  40. {
  41. {
  42. Ss* tolua_ret = (Ss*) Mtolua_new((Ss)());
  43. tolua_pushusertype(tolua_S,(void*)tolua_ret,"Ss");
  44. }
  45. }
  46. return 1;
  47. #ifndef TOLUA_RELEASE
  48. tolua_lerror:
  49. tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
  50. return 0;
  51. #endif
  52. }
  53. #endif //#ifndef TOLUA_DISABLE
  54. /* method: new_local of class Ss */
  55. #ifndef TOLUA_DISABLE_tolua_interface_Ss_new00_local
  56. static int tolua_interface_Ss_new00_local(lua_State* tolua_S)
  57. {
  58. #ifndef TOLUA_RELEASE
  59. tolua_Error tolua_err;
  60. if (
  61. !tolua_isusertable(tolua_S,1,"Ss",0,&tolua_err) ||
  62. !tolua_isnoobj(tolua_S,2,&tolua_err)
  63. )
  64. goto tolua_lerror;
  65. else
  66. #endif
  67. {
  68. {
  69. Ss* tolua_ret = (Ss*) Mtolua_new((Ss)());
  70. tolua_pushusertype(tolua_S,(void*)tolua_ret,"Ss");
  71. tolua_register_gc(tolua_S,lua_gettop(tolua_S));
  72. }
  73. }
  74. return 1;
  75. #ifndef TOLUA_RELEASE
  76. tolua_lerror:
  77. tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err);
  78. return 0;
  79. #endif
  80. }
  81. #endif //#ifndef TOLUA_DISABLE
  82. /* get function: i of class Ss */
  83. #ifndef TOLUA_DISABLE_tolua_get_Ss_i
  84. static int tolua_get_Ss_i(lua_State* tolua_S)
  85. {
  86. Ss* self = (Ss*) tolua_tousertype(tolua_S,1,0);
  87. #ifndef TOLUA_RELEASE
  88. if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'i'",NULL);
  89. #endif
  90. tolua_pushnumber(tolua_S,(lua_Number)self->i);
  91. return 1;
  92. }
  93. #endif //#ifndef TOLUA_DISABLE
  94. /* set function: i of class Ss */
  95. #ifndef TOLUA_DISABLE_tolua_set_Ss_i
  96. static int tolua_set_Ss_i(lua_State* tolua_S)
  97. {
  98. Ss* self = (Ss*) tolua_tousertype(tolua_S,1,0);
  99. #ifndef TOLUA_RELEASE
  100. tolua_Error tolua_err;
  101. if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'i'",NULL);
  102. if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
  103. tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
  104. #endif
  105. self->i = ((int) tolua_tonumber(tolua_S,2,0))
  106. ;
  107. return 0;
  108. }
  109. #endif //#ifndef TOLUA_DISABLE
  110. /* get function: a of class Ss */
  111. #ifndef TOLUA_DISABLE_tolua_get_Ss_a
  112. static int tolua_get_Ss_a(lua_State* tolua_S)
  113. {
  114. Ss* self = (Ss*) tolua_tousertype(tolua_S,1,0);
  115. #ifndef TOLUA_RELEASE
  116. if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'a'",NULL);
  117. #endif
  118. tolua_pushnumber(tolua_S,(lua_Number)self->a);
  119. return 1;
  120. }
  121. #endif //#ifndef TOLUA_DISABLE
  122. /* set function: a of class Ss */
  123. #ifndef TOLUA_DISABLE_tolua_set_Ss_a
  124. static int tolua_set_Ss_a(lua_State* tolua_S)
  125. {
  126. Ss* self = (Ss*) tolua_tousertype(tolua_S,1,0);
  127. #ifndef TOLUA_RELEASE
  128. tolua_Error tolua_err;
  129. if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'a'",NULL);
  130. if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
  131. tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
  132. #endif
  133. self->a = ((char) tolua_tonumber(tolua_S,2,0))
  134. ;
  135. return 0;
  136. }
  137. #endif //#ifndef TOLUA_DISABLE
  138. /* get function: b of class Ss */
  139. #ifndef TOLUA_DISABLE_tolua_get_Ss_b
  140. static int tolua_get_Ss_b(lua_State* tolua_S)
  141. {
  142. Ss* self = (Ss*) tolua_tousertype(tolua_S,1,0);
  143. #ifndef TOLUA_RELEASE
  144. if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'b'",NULL);
  145. #endif
  146. tolua_pushnumber(tolua_S,(lua_Number)self->b);
  147. return 1;
  148. }
  149. #endif //#ifndef TOLUA_DISABLE
  150. /* set function: b of class Ss */
  151. #ifndef TOLUA_DISABLE_tolua_set_Ss_b
  152. static int tolua_set_Ss_b(lua_State* tolua_S)
  153. {
  154. Ss* self = (Ss*) tolua_tousertype(tolua_S,1,0);
  155. #ifndef TOLUA_RELEASE
  156. tolua_Error tolua_err;
  157. if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'b'",NULL);
  158. if (!tolua_isnumber(tolua_S,2,0,&tolua_err))
  159. tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
  160. #endif
  161. self->b = ((double) tolua_tonumber(tolua_S,2,0))
  162. ;
  163. return 0;
  164. }
  165. #endif //#ifndef TOLUA_DISABLE
  166. /* get function: str of class Ss */
  167. #ifndef TOLUA_DISABLE_tolua_get_Ss_str
  168. static int tolua_get_Ss_str(lua_State* tolua_S)
  169. {
  170. Ss* self = (Ss*) tolua_tousertype(tolua_S,1,0);
  171. #ifndef TOLUA_RELEASE
  172. if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'str'",NULL);
  173. #endif
  174. tolua_pushcppstring(tolua_S,(const char*)self->str);
  175. return 1;
  176. }
  177. #endif //#ifndef TOLUA_DISABLE
  178. /* set function: str of class Ss */
  179. #ifndef TOLUA_DISABLE_tolua_set_Ss_str
  180. static int tolua_set_Ss_str(lua_State* tolua_S)
  181. {
  182. Ss* self = (Ss*) tolua_tousertype(tolua_S,1,0);
  183. #ifndef TOLUA_RELEASE
  184. tolua_Error tolua_err;
  185. if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'str'",NULL);
  186. if (!tolua_iscppstring(tolua_S,2,0,&tolua_err))
  187. tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
  188. #endif
  189. self->str = ((string) tolua_tocppstring(tolua_S,2,0))
  190. ;
  191. return 0;
  192. }
  193. #endif //#ifndef TOLUA_DISABLE
  194. /* get function: chararray of class Ss */
  195. #ifndef TOLUA_DISABLE_tolua_get_Ss_chararray
  196. static int tolua_get_Ss_chararray(lua_State* tolua_S)
  197. {
  198. Ss* self = (Ss*) tolua_tousertype(tolua_S,1,0);
  199. #ifndef TOLUA_RELEASE
  200. if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'chararray'",NULL);
  201. #endif
  202. tolua_pushstring(tolua_S,(const char*)self->chararray);
  203. return 1;
  204. }
  205. #endif //#ifndef TOLUA_DISABLE
  206. /* set function: chararray of class Ss */
  207. #ifndef TOLUA_DISABLE_tolua_set_Ss_chararray
  208. static int tolua_set_Ss_chararray(lua_State* tolua_S)
  209. {
  210. Ss* self = (Ss*) tolua_tousertype(tolua_S,1,0);
  211. #ifndef TOLUA_RELEASE
  212. tolua_Error tolua_err;
  213. if (!self) tolua_error(tolua_S,"invalid 'self' in accessing variable 'chararray'",NULL);
  214. if (!tolua_istable(tolua_S,2,0,&tolua_err))
  215. tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);
  216. #endif
  217. strncpy((char*)
  218. self->chararray,(const char*)tolua_tostring(tolua_S,2,0),10-1);
  219. return 0;
  220. }
  221. #endif //#ifndef TOLUA_DISABLE
  222. /* function: printHi */
  223. #ifndef TOLUA_DISABLE_tolua_interface_printHi00
  224. static int tolua_interface_printHi00(lua_State* tolua_S)
  225. {
  226. #ifndef TOLUA_RELEASE
  227. tolua_Error tolua_err;
  228. if (
  229. !tolua_isnoobj(tolua_S,1,&tolua_err)
  230. )
  231. goto tolua_lerror;
  232. else
  233. #endif
  234. {
  235. {
  236. int tolua_ret = (int) printHi();
  237. tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
  238. }
  239. }
  240. return 1;
  241. #ifndef TOLUA_RELEASE
  242. tolua_lerror:
  243. tolua_error(tolua_S,"#ferror in function 'printHi'.",&tolua_err);
  244. return 0;
  245. #endif
  246. }
  247. #endif //#ifndef TOLUA_DISABLE
  248. /* Open function */
  249. TOLUA_API int tolua_interface_open (lua_State* tolua_S)
  250. {
  251. tolua_open(tolua_S);
  252. tolua_reg_types(tolua_S);
  253. tolua_module(tolua_S,NULL,0);
  254. tolua_beginmodule(tolua_S,NULL);
  255. #ifdef __cplusplus
  256. tolua_cclass(tolua_S,"Ss","Ss","",tolua_collect_Ss);
  257. #else
  258. tolua_cclass(tolua_S,"Ss","Ss","",NULL);
  259. #endif
  260. tolua_beginmodule(tolua_S,"Ss");
  261. tolua_function(tolua_S,"new",tolua_interface_Ss_new00);
  262. tolua_function(tolua_S,"new_local",tolua_interface_Ss_new00_local);
  263. tolua_function(tolua_S,".call",tolua_interface_Ss_new00_local);
  264. tolua_variable(tolua_S,"i",tolua_get_Ss_i,tolua_set_Ss_i);
  265. tolua_variable(tolua_S,"a",tolua_get_Ss_a,tolua_set_Ss_a);
  266. tolua_variable(tolua_S,"b",tolua_get_Ss_b,tolua_set_Ss_b);
  267. tolua_variable(tolua_S,"str",tolua_get_Ss_str,tolua_set_Ss_str);
  268. tolua_variable(tolua_S,"chararray",tolua_get_Ss_chararray,tolua_set_Ss_chararray);
  269. tolua_endmodule(tolua_S);
  270. tolua_function(tolua_S,"printHi",tolua_interface_printHi00);
  271. tolua_endmodule(tolua_S);
  272. return 1;
  273. }
  274. #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501
  275. TOLUA_API int luaopen_interface (lua_State* tolua_S) {
  276. return tolua_interface_open(tolua_S);
  277. };
  278. #endif