blob: 423c7190b234b7ab9d13bb584f1ca21e902fd7ba [file] [log] [blame]
Vince Harronb46a6ee2015-06-02 18:58:48 -07001/* -----------------------------------------------------------------------------
2 * luaruntime.swg
3 *
4 * all the runtime code for .
5 * ----------------------------------------------------------------------------- */
6
7%runtime "swigrun.swg"; /* Common C API type-checking code */
8%runtime "luarun.swg"; /* Lua runtime stuff */
9
10%insert(initbeforefunc) "swiginit.swg"
11
12%insert(initbeforefunc) %{
13
14/* Forward declaration of where the user's %init{} gets inserted */
15void SWIG_init_user(lua_State* L );
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20/* this is the initialization function
21 added at the very end of the code
22 the function is always called SWIG_init, but an earlier #define will rename it
23*/
24#if ((SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_ELUAC))
25LUALIB_API int SWIG_init(lua_State* L)
26#else
27SWIGEXPORT int SWIG_init(lua_State* L) /* default Lua action */
28#endif
29{
30#if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) /* valid for both Lua and eLua */
31 int i;
32 /* start with global table */
33 lua_pushglobaltable (L);
34 /* SWIG's internal initalisation */
35 SWIG_InitializeModule((void*)L);
36 SWIG_PropagateClientData();
37#endif
38
39#if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC))
40 /* add a global fn */
41 SWIG_Lua_add_function(L,"swig_type",SWIG_Lua_type);
42 SWIG_Lua_add_function(L,"swig_equals",SWIG_Lua_equal);
43 /* begin the module (its a table with the same name as the module) */
44 SWIG_Lua_module_begin(L,SWIG_name);
45 /* add commands/functions */
46 for (i = 0; swig_commands[i].name; i++){
47 SWIG_Lua_module_add_function(L,swig_commands[i].name,swig_commands[i].func);
48 }
49 /* add variables */
50 for (i = 0; swig_variables[i].name; i++){
51 SWIG_Lua_module_add_variable(L,swig_variables[i].name,swig_variables[i].get,swig_variables[i].set);
52 }
53#endif
54
55#if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)
56 /* set up base class pointers (the hierarchy) */
57 for (i = 0; swig_types[i]; i++){
58 if (swig_types[i]->clientdata){
59 SWIG_Lua_init_base_class(L,(swig_lua_class*)(swig_types[i]->clientdata));
60 }
61 }
62 /* additional registration structs & classes in lua */
63 for (i = 0; swig_types[i]; i++){
64 if (swig_types[i]->clientdata){
65 SWIG_Lua_class_register(L,(swig_lua_class*)(swig_types[i]->clientdata));
66 }
67 }
68#endif
69
70#if ((SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUA) && (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC))
71 /* constants */
72 SWIG_Lua_InstallConstants(L,swig_constants);
73#endif
74
75#if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC)
76 /* invoke user-specific initialization */
77 SWIG_init_user(L);
78 /* end module */
79 /* Note: We do not clean up the stack here (Lua will do this for us). At this
80 point, we have the globals table and out module table on the stack. Returning
81 one value makes the module table the result of the require command. */
82 return 1;
83#else
84 return 0;
85#endif
86}
87
88#ifdef __cplusplus
89}
90#endif
91
92%}
93
94/* Note: the initialization function is closed after all code is generated */
95