lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello:

I'm not sure where to insert the initialization function that was created via
toLua, and, despite various attempts, my simple test fails when called from
Lua.  Do you have any suggestions.  Is there an example, that demos this?
 Thank you very much in advance for your help.

David

int main (int argc, char *argv[])
{
  int i;
  int result = 0;
  
  iolib_open ();
  strlib_open ();
  mathlib_open ();
    
  toLua_test_1_open ();			/* via toLua ? */
  
  lua_register("testC", testC);
  if (argc < 2)
  . . . etc.
}


----------------------
Here is the output from toLua:
----------------------
#include "test_1.h"

#ifdef __cplusplus
extern "C"{
#endif
#include "lua.h"
#include "tolua.h"
#ifdef __cplusplus
}
#endif

static void toLua_beep (void)
{
 short i;

 if (!toLua_nistype(1,TOLUA_NUMBER_TAG)) {toLua_wrongarg("beep",1,"short");
return;}
 else  i = (short)toLua_ngetnumber(1);

 if (lua_getparam(2) != LUA_NOOBJECT) toLua_toomanyargs("beep");

 {
  beep(i);
 }
}

static void toLua_init_tags  (void)
{
 toLua_libtag("test_1");
}


/* ----------------------------------- PUBLIC INTERFACE */
void toLua_test_1_open (void)
{
 lua_beginblock();
 toLua_init();
 toLua_init_tags();

 /* Bind constants */

 /* Bind variables */

 /* Bind functions */
 lua_register("beep",toLua_beep);

 /* Bind classes */
 lua_endblock();

}

#ifdef __cplusplus
static int dummy = toLua_test_1_open();
#endif