Add support for eLua including options for Lua Tiny RAM (LTR)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12813 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
2aeed2fd48
commit
91d22324e7
6 changed files with 217 additions and 30 deletions
|
|
@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release.
|
|||
Version 2.0.5 (in progress)
|
||||
===========================
|
||||
|
||||
2011-09-14: wsfulton
|
||||
[Lua] Patch #3408012 from Raman Gopalan - add support for embedded Lua (eLua)
|
||||
including options for targeting Lua Tiny RAM (LTR).
|
||||
|
||||
2011-09-14: wsfulton
|
||||
[C#] Add boost_intrusive_ptr.i library contribution from patch #3401571.
|
||||
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ Past SWIG developers and major contributors include:
|
|||
Duncan Temple Lang (R)
|
||||
Miklos Vajna <vmiklos@frugalware.org> (PHP directors)
|
||||
Mark Gossage (mark@gossage.cjb.net) (Lua)
|
||||
Raman Gopalan (ramangopalan@gmail.com) (eLua)
|
||||
Gonzalo Garramuno (ggarra@advancedsl.com.ar) (Ruby, Ruby's UTL)
|
||||
John Lenz (Guile, MzScheme updates, Chicken module, runtime system)
|
||||
Ian Lance Taylor (Go)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,30 @@
|
|||
* This file is parsed by SWIG before reading any other interface file.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%insert("runtime") %{
|
||||
/* Lua flavors */
|
||||
#define SWIG_LUA_LUA 1
|
||||
#define SWIG_LUA_ELUA 2
|
||||
#define SWIG_LUA_ELUAC 3
|
||||
|
||||
#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
|
||||
# define SWIG_LUA_CONSTTAB_INT(B, C) SWIG_LUA_INT, (char *)B, (long)C, 0, 0, 0
|
||||
# define SWIG_LUA_CONSTTAB_FLOAT(B, C) SWIG_LUA_FLOAT, (char *)B, 0, (double)C, 0, 0
|
||||
# define SWIG_LUA_CONSTTAB_STRING(B, C) SWIG_LUA_STRING, (char *)B, 0, 0, (void *)C, 0
|
||||
# define SWIG_LUA_CONSTTAB_CHAR(B, C) SWIG_LUA_CHAR, (char *)B, (long)C, 0, 0, 0
|
||||
# else
|
||||
# define SWIG_LUA_CONSTTAB_INT(B, C) LSTRKEY(B), LNUMVAL(C)
|
||||
# define SWIG_LUA_CONSTTAB_FLOAT(B, C) LSTRKEY(B), LNUMVAL(C)
|
||||
# define SWIG_LUA_CONSTTAB_STRING(B, C) LSTRKEY(B), LSTRVAL(C)
|
||||
# define SWIG_LUA_CONSTTAB_CHAR(B, C) LSTRKEY(B), LNUMVAL(C)
|
||||
#endif
|
||||
|
||||
#if (SWIG_LUA_TARGET == SWIG_LUA_ELUA) || (SWIG_LUA_TARGET == SWIG_LUA_ELUAC)
|
||||
# define LRO_STRVAL(v) {{.p = (char *) v}, LUA_TSTRING}
|
||||
# define LSTRVAL LRO_STRVAL
|
||||
#endif
|
||||
%}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* includes
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -18,27 +42,27 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
// this basically adds to a table of constants
|
||||
%typemap(consttab) int, unsigned int, short, unsigned short, long, unsigned long, unsigned char, signed char, bool, enum SWIGTYPE
|
||||
{ SWIG_LUA_INT, (char *)"$symname", (long) $value, 0, 0, 0}
|
||||
{SWIG_LUA_CONSTTAB_INT("$symname", $value)}
|
||||
|
||||
%typemap(consttab) float, double
|
||||
{ SWIG_LUA_FLOAT, (char *)"$symname", 0, (double) $value, 0, 0}
|
||||
{SWIG_LUA_CONSTTAB_FLOAT("$symname", $value)}
|
||||
|
||||
%typemap(consttab) long long, unsigned long long, signed long long
|
||||
{ SWIG_LUA_FLOAT, (char *)"$symname", 0, (double) $value, 0, 0}
|
||||
{SWIG_LUA_CONSTTAB_FLOAT("$symname", $value)}
|
||||
|
||||
%typemap(consttab) const long long&, const unsigned long long&, const signed long long&
|
||||
{ SWIG_LUA_FLOAT, (char *)"$symname", 0, (double) *$value, 0, 0}
|
||||
{SWIG_LUA_CONSTTAB_FLOAT("$symname", *$value)}
|
||||
|
||||
%typemap(consttab) char *, const char *, char [], const char []
|
||||
{ SWIG_LUA_STRING, (char *)"$symname", 0, 0, (void *)$value, 0}
|
||||
{SWIG_LUA_CONSTTAB_STRING("$symname", $value)}
|
||||
|
||||
// note: char is treated as a seperate special type
|
||||
// signed char & unsigned char are numbers
|
||||
%typemap(consttab) char
|
||||
{ SWIG_LUA_CHAR, (char *)"$symname", (long)$value, 0, 0, 0}
|
||||
{SWIG_LUA_CONSTTAB_CHAR("$symname", $value)}
|
||||
|
||||
%typemap(consttab) long long, unsigned long long
|
||||
{ SWIG_LUA_STRING, (char *) "$symname", 0, 0, (void *)"$value", 0}
|
||||
{SWIG_LUA_CONSTTAB_STRING("$symname", "$value")}
|
||||
|
||||
%typemap(consttab) SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &, SWIGTYPE []
|
||||
{ SWIG_LUA_POINTER, (char *)"$symname", 0, 0, (void *)$value, &$1_descriptor}
|
||||
|
|
|
|||
|
|
@ -181,12 +181,24 @@ SWIGINTERN int SWIG_Lua_module_get(lua_State* L)
|
|||
lua_tostring(L,2));
|
||||
*/
|
||||
/* get the metatable */
|
||||
#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
|
||||
assert(lua_istable(L,1)); /* just in case */
|
||||
#else
|
||||
assert(lua_isrotable(L,1));
|
||||
#endif
|
||||
lua_getmetatable(L,1); /* get the metatable */
|
||||
#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
|
||||
assert(lua_istable(L,-1)); /* just in case */
|
||||
#else
|
||||
assert(lua_isrotable(L,-1));
|
||||
#endif
|
||||
SWIG_Lua_get_table(L,".get"); /* get the .get table */
|
||||
lua_remove(L,3); /* remove metatable */
|
||||
#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
|
||||
if (lua_istable(L,-1))
|
||||
#else
|
||||
if (lua_isrotable(L,-1))
|
||||
#endif
|
||||
{
|
||||
/* look for the key in the .get table */
|
||||
lua_pushvalue(L,2); /* key */
|
||||
|
|
@ -201,7 +213,7 @@ SWIGINTERN int SWIG_Lua_module_get(lua_State* L)
|
|||
}
|
||||
lua_pop(L,1); /* remove the .get */
|
||||
lua_pushnil(L); /* return a nil */
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* the module.set method used for setting linked data */
|
||||
|
|
@ -213,12 +225,24 @@ SWIGINTERN int SWIG_Lua_module_set(lua_State* L)
|
|||
(3) any for the new value
|
||||
*/
|
||||
/* get the metatable */
|
||||
#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
|
||||
assert(lua_istable(L,1)); /* just in case */
|
||||
#else
|
||||
assert(lua_isrotable(L,1));
|
||||
#endif
|
||||
lua_getmetatable(L,1); /* get the metatable */
|
||||
#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
|
||||
assert(lua_istable(L,-1)); /* just in case */
|
||||
#else
|
||||
assert(lua_isrotable(L,-1));
|
||||
#endif
|
||||
SWIG_Lua_get_table(L,".set"); /* get the .set table */
|
||||
lua_remove(L,4); /* remove metatable */
|
||||
#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
|
||||
if (lua_istable(L,-1))
|
||||
#else
|
||||
if (lua_isrotable(L,-1))
|
||||
#endif
|
||||
{
|
||||
/* look for the key in the .set table */
|
||||
lua_pushvalue(L,2); /* key */
|
||||
|
|
@ -230,6 +254,11 @@ SWIGINTERN int SWIG_Lua_module_set(lua_State* L)
|
|||
lua_call(L,1,0);
|
||||
return 0;
|
||||
}
|
||||
#if (SWIG_LUA_TARGET == SWIG_LUA_ELUA)
|
||||
else {
|
||||
return 0; // Exits stoically if an invalid key is initialized.
|
||||
}
|
||||
#endif
|
||||
}
|
||||
lua_settop(L,3); /* reset back to start */
|
||||
/* we now have the table, key & new value, so just set directly */
|
||||
|
|
@ -237,6 +266,7 @@ SWIGINTERN int SWIG_Lua_module_set(lua_State* L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
|
||||
/* registering a module in lua. Pushes the module table on the stack. */
|
||||
SWIGINTERN void SWIG_Lua_module_begin(lua_State* L,const char* name)
|
||||
{
|
||||
|
|
@ -291,6 +321,7 @@ SWIGINTERN void SWIG_Lua_module_add_variable(lua_State* L,const char* name,lua_C
|
|||
}
|
||||
lua_pop(L,1); /* tidy stack (remove meta) */
|
||||
}
|
||||
#endif
|
||||
|
||||
/* adding a function module */
|
||||
SWIGINTERN void SWIG_Lua_module_add_function(lua_State* L,const char* name,lua_CFunction fn)
|
||||
|
|
@ -705,6 +736,7 @@ SWIGRUNTIME int SWIG_Lua_equal(lua_State* L)
|
|||
* global variable support code: class/struct typemap functions
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
|
||||
/* Install Constants */
|
||||
SWIGINTERN void
|
||||
SWIG_Lua_InstallConstants(lua_State* L, swig_lua_const_info constants[]) {
|
||||
|
|
@ -746,6 +778,7 @@ SWIG_Lua_InstallConstants(lua_State* L, swig_lua_const_info constants[]) {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* executing lua code from within the wrapper
|
||||
|
|
|
|||
|
|
@ -21,14 +21,22 @@ extern "C" {
|
|||
added at the very end of the code
|
||||
the function is always called SWIG_init, but an eariler #define will rename it
|
||||
*/
|
||||
#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
|
||||
SWIGEXPORT int SWIG_init(lua_State* L)
|
||||
#else
|
||||
LUALIB_API int SWIG_init(lua_State* L)
|
||||
#endif
|
||||
{
|
||||
#if (SWIG_LUA_TARGET == SWIG_LUA_LUA) || (SWIG_LUA_TARGET == SWIG_LUA_ELUA)
|
||||
int i;
|
||||
/* start with global table */
|
||||
lua_pushvalue(L,LUA_GLOBALSINDEX);
|
||||
/* SWIG's internal initalisation */
|
||||
SWIG_InitializeModule((void*)L);
|
||||
SWIG_PropagateClientData();
|
||||
#endif
|
||||
|
||||
#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
|
||||
/* add a global fn */
|
||||
SWIG_Lua_add_function(L,"swig_type",SWIG_Lua_type);
|
||||
SWIG_Lua_add_function(L,"swig_equals",SWIG_Lua_equal);
|
||||
|
|
@ -42,6 +50,9 @@ SWIGEXPORT int SWIG_init(lua_State* L)
|
|||
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);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (SWIG_LUA_TARGET == SWIG_LUA_LUA) || (SWIG_LUA_TARGET == SWIG_LUA_ELUA)
|
||||
/* set up base class pointers (the hierachy) */
|
||||
for (i = 0; swig_types[i]; i++){
|
||||
if (swig_types[i]->clientdata){
|
||||
|
|
@ -54,8 +65,14 @@ SWIGEXPORT int SWIG_init(lua_State* L)
|
|||
SWIG_Lua_class_register(L,(swig_lua_class*)(swig_types[i]->clientdata));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (SWIG_LUA_TARGET == SWIG_LUA_LUA)
|
||||
/* constants */
|
||||
SWIG_Lua_InstallConstants(L,swig_constants);
|
||||
#endif
|
||||
|
||||
#if (SWIG_LUA_TARGET == SWIG_LUA_LUA) || (SWIG_LUA_TARGET == SWIG_LUA_ELUA)
|
||||
/* invoke user-specific initialization */
|
||||
SWIG_init_user(L);
|
||||
/* end module */
|
||||
|
|
@ -63,6 +80,9 @@ SWIGEXPORT int SWIG_init(lua_State* L)
|
|||
point, we have the globals table and out module table on the stack. Returning
|
||||
one value makes the module table the result of the require command. */
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@
|
|||
* ver009
|
||||
class support: ok for basic types, but methods still TDB
|
||||
(code is VERY messed up & needs to be cleaned)
|
||||
|
||||
|
||||
* ver010
|
||||
Added support for embedded Lua. Try swig -lua -help for more information
|
||||
*/
|
||||
|
||||
char cvsroot_lua_cxx[] = "$Id$";
|
||||
|
|
@ -83,11 +83,15 @@ void display_mapping(DOH *d) {
|
|||
NEW LANGUAGE NOTE:END ************************************************/
|
||||
static const char *usage = (char *) "\
|
||||
Lua Options (available with -lua)\n\
|
||||
-elua - Generates LTR compatible wrappers for smaller devices running elua\n\
|
||||
-eluac - LTR compatible wrappers in \"crass compress\" mode for elua\n\
|
||||
-nomoduleglobal - Do not register the module name as a global variable \n\
|
||||
but return the module table from calls to require.\n\
|
||||
\n";
|
||||
|
||||
static int nomoduleglobal = 0;
|
||||
static int elua_ltr = 0;
|
||||
static int eluac_ltr = 0;
|
||||
|
||||
/* NEW LANGUAGE NOTE:***********************************************
|
||||
To add a new language, you need to derive your class from
|
||||
|
|
@ -111,6 +115,9 @@ private:
|
|||
String *s_methods_tab; // table of class methods
|
||||
String *s_attr_tab; // table of class atributes
|
||||
String *s_luacode; // luacode to be called during init
|
||||
String *s_dot_get; // table of variable 'get' functions
|
||||
String *s_dot_set; // table of variable 'set' functions
|
||||
String *s_vars_meta_tab; // metatable for variables
|
||||
|
||||
int have_constructor;
|
||||
int have_destructor;
|
||||
|
|
@ -176,6 +183,12 @@ public:
|
|||
} else if (strcmp(argv[i], "-nomoduleglobal") == 0) {
|
||||
nomoduleglobal = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if(strcmp(argv[i], "-elua") == 0) {
|
||||
elua_ltr = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if(strcmp(argv[i], "-eluac") == 0) {
|
||||
eluac_ltr = 1;
|
||||
Swig_mark_arg(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -255,6 +268,10 @@ public:
|
|||
s_var_tab = NewString("");
|
||||
// s_methods_tab = NewString("");
|
||||
s_const_tab = NewString("");
|
||||
|
||||
s_dot_get = NewString("");
|
||||
s_dot_set = NewString("");
|
||||
s_vars_meta_tab = NewString("");
|
||||
|
||||
s_luacode = NewString("");
|
||||
Swig_register_filebyname("luacode", s_luacode);
|
||||
|
|
@ -267,6 +284,13 @@ public:
|
|||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIGLUA\n");
|
||||
|
||||
if (elua_ltr)
|
||||
Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_ELUA\n");
|
||||
else if (eluac_ltr)
|
||||
Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_ELUAC\n");
|
||||
else
|
||||
Printf(f_runtime, "#define SWIG_LUA_TARGET SWIG_LUA_LUA\n");
|
||||
|
||||
if (nomoduleglobal) {
|
||||
Printf(f_runtime, "#define SWIG_LUA_NO_MODULE_GLOBAL\n");
|
||||
} else {
|
||||
|
|
@ -287,12 +311,31 @@ public:
|
|||
Printf(f_header, "#define SWIG_name \"%s\"\n", module);
|
||||
Printf(f_header, "#define SWIG_init luaopen_%s\n", module);
|
||||
Printf(f_header, "#define SWIG_init_user luaopen_%s_user\n\n", module);
|
||||
Printf(f_header, "#define SWIG_LUACODE luaopen_%s_luacode\n\n", module);
|
||||
Printf(f_header, "#define SWIG_LUACODE luaopen_%s_luacode\n", module);
|
||||
|
||||
Printf(s_cmd_tab, "\nstatic const struct luaL_reg swig_commands[] = {\n");
|
||||
Printf(s_var_tab, "\nstatic swig_lua_var_info swig_variables[] = {\n");
|
||||
Printf(s_const_tab, "\nstatic swig_lua_const_info swig_constants[] = {\n");
|
||||
Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
|
||||
if (elua_ltr || eluac_ltr)
|
||||
Printf(f_header, "#define swig_commands %s_map\n\n", module);
|
||||
|
||||
if (elua_ltr || eluac_ltr) {
|
||||
Printf(s_cmd_tab, "\n#define MIN_OPT_LEVEL 2\n#include \"lrodefs.h\"\n");
|
||||
Printf(s_cmd_tab, "#include \"lrotable.h\"\n");
|
||||
Printf(s_cmd_tab, "\nconst LUA_REG_TYPE swig_constants[];\n");
|
||||
if (elua_ltr)
|
||||
Printf(s_cmd_tab, "const LUA_REG_TYPE mt[];\n");
|
||||
|
||||
Printf(s_cmd_tab, "\nconst LUA_REG_TYPE swig_commands[] = {\n");
|
||||
Printf(s_const_tab, "\nconst LUA_REG_TYPE swig_constants[] = {\n");
|
||||
Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
|
||||
if (elua_ltr) {
|
||||
Printf(s_dot_get, "\nconst LUA_REG_TYPE dot_get[] = {\n");
|
||||
Printf(s_dot_set, "\nconst LUA_REG_TYPE dot_set[] = {\n");
|
||||
}
|
||||
} else {
|
||||
Printf(s_cmd_tab, "\nstatic const struct luaL_reg swig_commands[] = {\n");
|
||||
Printf(s_var_tab, "\nstatic swig_lua_var_info swig_variables[] = {\n");
|
||||
Printf(s_const_tab, "\nstatic swig_lua_const_info swig_constants[] = {\n");
|
||||
Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
|
||||
}
|
||||
|
||||
/* %init code inclusion, effectively in the SWIG_init function */
|
||||
Printf(f_init, "void SWIG_init_user(lua_State* L)\n{\n");
|
||||
|
|
@ -303,11 +346,39 @@ public:
|
|||
Printf(f_wrappers, "#ifdef __cplusplus\n}\n#endif\n");
|
||||
|
||||
// Done. Close up the module & write to the wrappers
|
||||
Printv(s_cmd_tab, tab4, "{0,0}\n", "};\n", NIL);
|
||||
Printv(s_var_tab, tab4, "{0,0,0}\n", "};\n", NIL);
|
||||
Printv(s_const_tab, tab4, "{0,0,0,0,0,0}\n", "};\n", NIL);
|
||||
Printv(f_wrappers, s_cmd_tab, s_var_tab, s_const_tab, NIL);
|
||||
SwigType_emit_type_table(f_runtime, f_wrappers);
|
||||
if (elua_ltr || eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"const\"), LROVAL(swig_constants)},\n", NIL);
|
||||
if (elua_ltr)
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"__metatable\"), LROVAL(mt)},\n", NIL);
|
||||
Printv(s_cmd_tab, tab4, "{LNILKEY, LNILVAL}\n", "};\n", NIL);
|
||||
Printv(s_const_tab, tab4, "{LNILKEY, LNILVAL}\n", "};\n", NIL);
|
||||
} else {
|
||||
Printv(s_cmd_tab, tab4, "{0,0}\n", "};\n", NIL);
|
||||
Printv(s_var_tab, tab4, "{0,0,0}\n", "};\n", NIL);
|
||||
Printv(s_const_tab, tab4, "{0,0,0,0,0,0}\n", "};\n", NIL);
|
||||
}
|
||||
|
||||
if (elua_ltr) {
|
||||
/* Generate the metatable */
|
||||
Printf(s_vars_meta_tab, "\nconst LUA_REG_TYPE mt[] = {\n");
|
||||
Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\"__index\"), LFUNCVAL(SWIG_Lua_module_get)},\n", NIL);
|
||||
Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\"__newindex\"), LFUNCVAL(SWIG_Lua_module_set)},\n", NIL);
|
||||
Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\".get\"), LROVAL(dot_get)},\n", NIL);
|
||||
Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\".set\"), LROVAL(dot_set)},\n", NIL);
|
||||
Printv(s_vars_meta_tab, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL);
|
||||
|
||||
Printv(s_dot_get, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL);
|
||||
Printv(s_dot_set, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL);
|
||||
}
|
||||
|
||||
if (elua_ltr || eluac_ltr) {
|
||||
/* Final close up of wrappers */
|
||||
Printv(f_wrappers, s_cmd_tab, s_dot_get, s_dot_set, s_vars_meta_tab, s_var_tab, s_const_tab, NIL);
|
||||
SwigType_emit_type_table(f_runtime, f_wrappers);
|
||||
} else {
|
||||
Printv(f_wrappers, s_cmd_tab, s_var_tab, s_const_tab, NIL);
|
||||
SwigType_emit_type_table(f_runtime, f_wrappers);
|
||||
}
|
||||
|
||||
/* NEW LANGUAGE NOTE:***********************************************
|
||||
this basically combines several of the strings together
|
||||
|
|
@ -333,6 +404,9 @@ public:
|
|||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
Delete(s_dot_get);
|
||||
Delete(s_dot_set);
|
||||
Delete(s_vars_meta_tab);
|
||||
|
||||
/* Done */
|
||||
return SWIG_OK;
|
||||
|
|
@ -661,9 +735,13 @@ public:
|
|||
/* Now register the function with the interpreter. */
|
||||
if (!Getattr(n, "sym:overloaded")) {
|
||||
// add_method(n, iname, wname, description);
|
||||
if (current==NO_CPP || current==STATIC_FUNC) // emit normal fns & static fns
|
||||
Printv(s_cmd_tab, tab4, "{ \"", iname, "\", ", Swig_name_wrapper(iname), "},\n", NIL);
|
||||
if (current==NO_CPP || current==STATIC_FUNC) { // emit normal fns & static fns
|
||||
if(elua_ltr || eluac_ltr)
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "\")", ", LFUNCVAL(", Swig_name_wrapper(iname), ")", "},\n", NIL);
|
||||
else
|
||||
Printv(s_cmd_tab, tab4, "{ \"", iname, "\", ", Swig_name_wrapper(iname), "},\n", NIL);
|
||||
// Printv(s_cmd_tab, tab4, "{ SWIG_prefix \"", iname, "\", (swig_wrapper_func) ", Swig_name_wrapper(iname), "},\n", NIL);
|
||||
}
|
||||
} else {
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
dispatchFunction(n);
|
||||
|
|
@ -787,8 +865,17 @@ public:
|
|||
setName = NewString("SWIG_Lua_set_immutable"); // error message
|
||||
//setName = NewString("0");
|
||||
}
|
||||
|
||||
// register the variable
|
||||
Printf(s_var_tab, "%s{ \"%s\", %s, %s },\n", tab4, iname, getName, setName);
|
||||
if (elua_ltr) {
|
||||
Printf(s_dot_get, "%s{LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", tab4, iname, getName);
|
||||
Printf(s_dot_set, "%s{LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", tab4, iname, setName);
|
||||
} else if (eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "_get", "\")", ", LFUNCVAL(", getName, ")", "},\n", NIL);
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "_set", "\")", ", LFUNCVAL(", setName, ")", "},\n", NIL);
|
||||
} else {
|
||||
Printf(s_var_tab, "%s{ \"%s\", %s, %s },\n", tab4, iname, getName, setName);
|
||||
}
|
||||
Delete(getName);
|
||||
Delete(setName);
|
||||
return result;
|
||||
|
|
@ -822,7 +909,7 @@ public:
|
|||
Replaceall(tm, "$target", name);
|
||||
Replaceall(tm, "$value", value);
|
||||
Replaceall(tm, "$nsname", nsname);
|
||||
Printf(s_const_tab, "%s,\n", tm);
|
||||
Printf(s_const_tab, " %s,\n", tm);
|
||||
} else if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) {
|
||||
Replaceall(tm, "$source", value);
|
||||
Replaceall(tm, "$target", name);
|
||||
|
|
@ -1006,7 +1093,17 @@ public:
|
|||
Printv(f_wrappers, "static swig_lua_class _wrap_class_", mangled_classname, " = { \"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL);
|
||||
|
||||
if (have_constructor) {
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
if (elua_ltr) {
|
||||
Printf(s_cmd_tab, " {LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", class_name, \
|
||||
Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
} else if (eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", "new_", class_name, "\")", ", LFUNCVAL(", \
|
||||
Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)), ")", "},\n", NIL);
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
} else {
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
}
|
||||
Delete(constructor_name);
|
||||
constructor_name = 0;
|
||||
} else {
|
||||
|
|
@ -1014,7 +1111,12 @@ public:
|
|||
}
|
||||
|
||||
if (have_destructor) {
|
||||
Printv(f_wrappers, ", swig_delete_", class_name, NIL);
|
||||
if (eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", "free_", class_name, "\")", ", LFUNCVAL(", "swig_delete_", class_name, ")", "},\n", NIL);
|
||||
Printv(f_wrappers, ", swig_delete_", class_name, NIL);
|
||||
} else {
|
||||
Printv(f_wrappers, ", swig_delete_", class_name, NIL);
|
||||
}
|
||||
} else {
|
||||
Printf(f_wrappers, ",0");
|
||||
}
|
||||
|
|
@ -1080,6 +1182,12 @@ public:
|
|||
sname = NewString("SWIG_Lua_set_immutable"); // error message
|
||||
}
|
||||
Printf(s_attr_tab,"%s{ \"%s\", %s, %s},\n",tab4,symname,gname,sname);
|
||||
if (eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", class_name, "_", symname, "_get", "\")", \
|
||||
", LFUNCVAL(", gname, ")", "},\n", NIL);
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", class_name, "_", symname, "_set", "\")", \
|
||||
", LFUNCVAL(", sname, ")", "},\n", NIL);
|
||||
}
|
||||
Delete(gname);
|
||||
Delete(sname);
|
||||
return SWIG_OK;
|
||||
|
|
@ -1160,9 +1268,7 @@ public:
|
|||
*/
|
||||
String *runtimeCode() {
|
||||
String *s = NewString("");
|
||||
const char *filenames[] = { "luarun.swg", 0
|
||||
}
|
||||
; // must be 0 termiated
|
||||
const char *filenames[] = { "luarun.swg", 0 } ; // must be 0 terminated
|
||||
String *sfile;
|
||||
for (int i = 0; filenames[i] != 0; i++) {
|
||||
sfile = Swig_include_sys(filenames[i]);
|
||||
|
|
@ -1173,7 +1279,6 @@ public:
|
|||
Delete(sfile);
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue