Fixed issues with C++ classes and hierachies across multiple source files.
Fixed imports test case & added run test. Added Examples/imports. Added typename for raw lua_State* Added documentation on native functions. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9748 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
cea5ba04fa
commit
61fdde65cc
19 changed files with 820 additions and 481 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -21,56 +21,56 @@ extern "C" {
|
|||
void SWIG_init_user(lua_State* L );
|
||||
|
||||
/* this is the initialization function
|
||||
added at the very end of the code
|
||||
the function is always called SWIG_init, but an eariler #define will rename it
|
||||
added at the very end of the code
|
||||
the function is always called SWIG_init, but an eariler #define will rename it
|
||||
*/
|
||||
SWIGEXPORT int SWIG_init(lua_State* L)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
/* start with global table */
|
||||
lua_pushvalue(L,LUA_GLOBALSINDEX);
|
||||
/* start with global table */
|
||||
lua_pushvalue(L,LUA_GLOBALSINDEX);
|
||||
|
||||
SWIG_InitializeModule((void*)L);
|
||||
SWIG_PropagateClientData();
|
||||
SWIG_InitializeModule((void*)L);
|
||||
SWIG_PropagateClientData();
|
||||
|
||||
/* invoke user-specific initialization */
|
||||
SWIG_init_user(L);
|
||||
/* invoke user-specific initialization */
|
||||
SWIG_init_user(L);
|
||||
|
||||
/* add a global fn */
|
||||
SWIG_Lua_add_function(L,"swig_type",SWIG_Lua_type);
|
||||
SWIG_Lua_add_function(L,"swig_equals",SWIG_Lua_equal);
|
||||
/* add a global fn */
|
||||
SWIG_Lua_add_function(L,"swig_type",SWIG_Lua_type);
|
||||
SWIG_Lua_add_function(L,"swig_equals",SWIG_Lua_equal);
|
||||
|
||||
/* begin the module (its a table with the same name as the module) */
|
||||
SWIG_Lua_module_begin(L,SWIG_name);
|
||||
/* add commands/functions */
|
||||
for (i = 0; swig_commands[i].name; i++){
|
||||
SWIG_Lua_module_add_function(L,swig_commands[i].name,swig_commands[i].func);
|
||||
}
|
||||
/*luaL_openlib(L,NULL,swig_commands,0);*/
|
||||
/* all in one */
|
||||
/*luaL_openlib(L,SWIG_name,swig_commands,0);*/
|
||||
/* add variables */
|
||||
for (i = 0; swig_variables[i].name; i++){
|
||||
SWIG_Lua_module_add_variable(L,swig_variables[i].name,swig_variables[i].get,swig_variables[i].set);
|
||||
}
|
||||
/* begin the module (its a table with the same name as the module) */
|
||||
SWIG_Lua_module_begin(L,SWIG_name);
|
||||
/* add commands/functions */
|
||||
for (i = 0; swig_commands[i].name; i++){
|
||||
SWIG_Lua_module_add_function(L,swig_commands[i].name,swig_commands[i].func);
|
||||
}
|
||||
/*luaL_openlib(L,NULL,swig_commands,0);*/
|
||||
/* all in one */
|
||||
/*luaL_openlib(L,SWIG_name,swig_commands,0);*/
|
||||
/* add variables */
|
||||
for (i = 0; swig_variables[i].name; i++){
|
||||
SWIG_Lua_module_add_variable(L,swig_variables[i].name,swig_variables[i].get,swig_variables[i].set);
|
||||
}
|
||||
|
||||
/* additional registration structs & classes in lua: */
|
||||
for (i = 0; swig_types[i]; i++){
|
||||
if (swig_types[i]->clientdata){
|
||||
SWIG_Lua_class_register(L,(swig_lua_class*)(swig_types[i]->clientdata));
|
||||
}
|
||||
}
|
||||
/* additional registration structs & classes in lua: */
|
||||
for (i = 0; swig_types[i]; i++){
|
||||
if (swig_types[i]->clientdata){
|
||||
SWIG_Lua_class_register(L,(swig_lua_class*)(swig_types[i]->clientdata));
|
||||
}
|
||||
}
|
||||
|
||||
/* constants */
|
||||
SWIG_Lua_InstallConstants(L,swig_constants);
|
||||
/* constants */
|
||||
SWIG_Lua_InstallConstants(L,swig_constants);
|
||||
|
||||
/* end module */
|
||||
/*SWIG_Lua_module_end(L);*/
|
||||
lua_pop(L,1); /* tidy stack (remove module table)*/
|
||||
lua_pop(L,1); /* tidy stack (remove global table)*/
|
||||
/* end module */
|
||||
/*SWIG_Lua_module_end(L);*/
|
||||
lua_pop(L,1); /* tidy stack (remove module table)*/
|
||||
lua_pop(L,1); /* tidy stack (remove global table)*/
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Lua 5.1 has a different name for importing libraries
|
||||
|
|
@ -81,7 +81,7 @@ There is a #define in the wrapper to rename 'SWIG_import' to the correct name
|
|||
|
||||
SWIGEXPORT int SWIG_import(lua_State* L)
|
||||
{
|
||||
return SWIG_init(L);
|
||||
return SWIG_init(L);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -197,6 +197,13 @@ with the relevant operators.
|
|||
%typemap(out) long long, unsigned long long, signed long long
|
||||
%{ lua_pushnumber(L, (lua_Number) $1); SWIG_arg++;%}
|
||||
|
||||
/* It is possible to also pass a lua_State* into a function, so
|
||||
void fn(int a, float b, lua_State* s) is wrappable as
|
||||
> fn(1,4.3) -- note: the state is implicitly passed in
|
||||
*/
|
||||
%typemap(in, numinputs=0) lua_State*
|
||||
%{$1 = L;%}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* typecheck rules
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue