Exemple #1
0
static void userinit (void) {
  lua_baselibopen(L);
  lua_iolibopen(L);
  lua_strlibopen(L);
  lua_mathlibopen(L);
  lua_dblibopen(L);
  /* add your libraries here */
}
Exemple #2
0
LuaBase::LuaBase() :
		_translationMode(0), _frameTimeCollection(0) {
	s_instance = this;

	lua_iolibopen();
	lua_strlibopen();
	lua_mathlibopen();
}
Exemple #3
0
void lua_init()
{
	g_pLuaVm = lua_open();
	lua_baselibopen(g_pLuaVm);
	lua_tablibopen(g_pLuaVm);
	lua_iolibopen(g_pLuaVm);
	lua_strlibopen(g_pLuaVm);
	lua_mathlibopen(g_pLuaVm);
	register_lua_functions(g_pLuaVm);

	g_pEffectLuaVm = lua_open();
	lua_baselibopen(g_pEffectLuaVm);
	lua_tablibopen(g_pEffectLuaVm);
	lua_iolibopen(g_pEffectLuaVm);
	lua_strlibopen(g_pEffectLuaVm);
	lua_mathlibopen(g_pEffectLuaVm);
	register_lua_functions(g_pEffectLuaVm);
}
Exemple #4
0
int main() {
	int i;

#ifndef NOSERIAL
	serial_init(57600);
	usleep(2000000);
	printf("Serial OK\r\n");
#endif

	atexit(quit);

	g_registry = new Registry();
	g_registry->set("DataDir", "/GRIMDATA");
	g_registry->set("good_times", "TRUE");

	g_driver = new DriverRonin();
	g_engine = new Engine();
	g_resourceloader = new ResourceLoader();
	g_localizer = new Localizer();
	g_mixer = new SoundMixer();
	g_mixer->setVolume(255);
	g_timer = new Timer();
	g_smush = new Smush();
	g_imuse = new Imuse(20);

	Bitmap *splash_bm = NULL;
	splash_bm = g_resourceloader->loadBitmap("splash.bm");
	splash_bm->ref();

	g_driver->clearScreen();
	splash_bm->draw();
	g_driver->flipBuffer();

	splash_bm->deref();

	lua_iolibopen();
	lua_strlibopen();
	lua_mathlibopen();

	register_lua();
	g_lua_initialized = true;

	bundle_dofile("_system.lua");

	lua_pushnil();		// resumeSave
	lua_pushnil();		// bootParam
//	lua_pushnumber(0);		// bootParam
	lua_call("BOOT");

	g_engine->setMode(ENGINE_MODE_NORMAL);
	g_engine->mainLoop();

	quit();

	return 0;
}
Exemple #5
0
void context_new_VM(context_t * context)
{
	context_lock_list();
	context->luaVM = lua_open();
	lua_baselibopen(context->luaVM);
	lua_tablibopen(context->luaVM);
	lua_iolibopen(context->luaVM);
	lua_strlibopen(context->luaVM);
	lua_mathlibopen(context->luaVM);

	register_lua_functions(context);
	context_unlock_list();
}
Exemple #6
0
static void userinit (void) {
  lua_baselibopen(L);
  lua_iolibopen(L);
  lua_strlibopen(L);
  lua_mathlibopen(L);
  lua_dblibopen(L);
  /* add your libraries here */
  lua_socketlibopen(L);
  md5lib_open(L);
  wrap_register(L);
  ltime_register(L);
  luaopen_posix(L);
  drop_register(L);
}
Exemple #7
0
int main(void)
{
 int rc;
 L=lua_open(0);
 lua_baselibopen(L);
 lua_iolibopen(L);
 lua_strlibopen(L);
 lua_mathlibopen(L);
 lua_dblibopen(L);
 start_trace(stderr);
 rc=lua_dofile(L,0);
 stop_trace();
 return rc;
}
classLUA::classLUA (int iStackSize)
{
	m_pState = lua_open (0);

    if ( m_pState ) 
	{
        lua_baselibopen(m_pState);
        lua_mathlibopen(m_pState);
        lua_iolibopen(m_pState);
    }

    m_pBuffer = NULL;
	m_lBufferSize = 0;
}
Exemple #9
0
int main(int argc, char *argv[])
{
    /* initialize Lua */
    lua_State *L = lua_open(0);

    /* open libraries */
    lua_baselibopen(L);
    lua_iolibopen(L);
    lua_strlibopen(L);
    lua_mathlibopen(L);
    lua_socketlibopen(L);
    lua_muwlibopen(L);

    /* execute the specified file */
    return lua_dofile(L, argv[1]);
}
Exemple #10
0
bool kgmLuaOpen()
{
  if(lua_main)
    return false;

  lua_main = lua_open(0);

  if(!lua_main)
    return false;


  lua_baselibopen (lua_main);
  lua_iolibopen (lua_main);
  lua_strlibopen (lua_main);
  lua_mathlibopen (lua_main);
  lua_dblibopen (lua_main);

  return true;
}
Exemple #11
0
/*
** Python prototype: "lua_state <-- lua_open([stack_size])"
** opens a Lua State and returns it to Python
** accepts an optional parameter informing the size of the stack Lua should use
** (measured in number of elements)
*/
static PyObject *Py_lua_open(PyObject *self, PyObject *args) {
lua_State *L;
int stack_size = 0;
PyObject *result = NULL;

   if (PyArg_ParseTuple(args, "|i:lua_open", &stack_size)) {
      L = lua_open(stack_size);
      lua_baselibopen(L);
      lua_iolibopen(L);
      lua_strlibopen(L);
      lua_mathlibopen(L);
      lua_dblibopen(L);

      lua_register(L, "_LuaPy_callPythonFunction", Lua_callPythonFunction);
      lua_register(L, "_LuaPy_setErrorMessage",    Lua_setErrorMessage);
      lua_dostring(L, LUA_init_state);
      result = Py_BuildValue("i", L);
   }
   return result;
}
int main (int argc, char *argv[])
{
  int i;

  OleInitialize(NULL);

  SetConsoleTitle(LUACOM_VERSION);

#if defined(LUA4)
  lua_State *lua_state = lua_open(0);
  lua_baselibopen (lua_state);
  lua_mathlibopen (lua_state);
  lua_iolibopen   (lua_state);
  lua_strlibopen (lua_state);
#elif defined(LUA5)
  lua_State *lua_state = lua_open();
  luaopen_base (lua_state);
  luaopen_math (lua_state);
  luaopen_io   (lua_state);
  luaopen_string (lua_state);
  luaopen_table (lua_state);
#endif

  lua_pushstring(lua_state, "> "); lua_setglobal(lua_state, "_PROMPT");

  luacom_open(lua_state);
  init_windows(lua_state);
  if (argc < 2) {  /* no arguments? */
    if (isatty(0)) {
      printf("%s  %s\n", LUACOM_VERSION, LUACOM_COPYRIGHT);
      manual_input(lua_state, 1);
    }
    else
      ldo(lua_state, lua_dofile, NULL);  /* executes stdin as a file */
  }
  else for (i=1; i<argc; i++) {
    if (argv[i][0] == '-') {  /* option? */
      switch (argv[i][1]) {
        case 0:
          ldo(lua_state, lua_dofile, NULL);  /* executes stdin as a file */
          break;
        case 'i':
          manual_input(lua_state, 1);
          break;
        case 'q':
          manual_input(lua_state, 0);
          break;
        case 'v':
          printf("%s  %s\n(written by %s)\n\n",
                 LUACOM_VERSION, LUACOM_COPYRIGHT, LUACOM_AUTHORS);
          break;
        case 'e':
          i++;
          if (ldo(lua_state, lua_dostring, argv[i]) != 0) {
            fprintf(stderr, "lua: error running argument `%s'\n", argv[i]);
            return 1;
          }
          break;
        default:
          print_message();
          exit(1);
      }
    }
    else if (strchr(argv[i], '='))
      assign(lua_state, argv[i]);
    else {
      int result = ldo(lua_state, lua_dofile, argv[i]);
      if (result) {
        if (result == 2) {
          fprintf(stderr, "lua: cannot execute file ");
          perror(argv[i]);
        }
        exit(1);
      }
    }
  }

  luacom_close(lua_state);
  lua_close(lua_state);

  OleUninitialize();

  return 0;
}
Exemple #13
0
int main ( int argc, char **argv )
{
    IupOpen(&argc, &argv);
#ifndef IUPLUA_NO_GL
    IupGLCanvasOpen();
#endif
#ifndef IUPLUA_NO_CD
    IupControlsOpen();
    IupPPlotOpen();
#endif

    lua_open();

    lua_setdebug(1);

    lua_iolibopen( );
    lua_strlibopen( );
    lua_mathlibopen( );

    iuplua_open( );
    iupkey_open( );
#ifndef IUPLUA_NO_GL
    iupgllua_open();
#endif
#ifndef IUPLUA_NO_CD
    iupcontrolslua_open();
    iup_pplotlua_open();
    cdlua_open();
    cdluaiup_open();
#endif
#ifndef IUPLUA_NO_IM
    iupimlua_open();
    imlua_open();
#endif

    if (argc <= 1)
    {
        if(!iuplua_dofile("console3.lua"))
        {
#ifdef TEC_BIGENDIAN
#ifdef TEC_64
#include "loh/console3_be64.loh"
#else
#include "loh/console3_be32.loh"
#endif
#else
#ifdef TEC_64
#ifdef WIN64
#include "loh/console3_le64w.loh"
#else
#include "loh/console3_le64.loh"
#endif
#else
#include "loh/console3.loh"
#endif
#endif
        }
    }
    else
    {
        int ok = 1,
            i  = 1;

        /* Running all .lua given as arguments */
        while(ok & (i < argc))
        {
            ok = iuplua_dofile(argv[i]);
            i++;
        }

        if(!ok)
        {
            return EXIT_FAILURE;
        }
    }

#ifndef IUPLUA_NO_CD
    cdlua_close();
    IupControlsClose();
#endif
    IupClose();

    lua_close();

    return EXIT_SUCCESS;
}
Exemple #14
0
int main (int argc, char* argv[])
{
 lua_State* L = lua_open(0);
 lua_baselibopen(L);
 lua_iolibopen(L);
 lua_strlibopen(L);
 lua_pushstring(L,TOLUA_VERSION); lua_setglobal(L,"TOLUA_VERSION");

 if (argc==1)
 {
  help();
  return 0;
 }
 else
 {
  int i, t;
  lua_newtable(L);
  lua_pushvalue(L,-1);
  lua_setglobal(L,"flags");
  t = lua_gettop(L);
  for (i=1; i<argc; ++i)
  {
   if (*argv[i] == '-')
   {
    switch (argv[i][1])
    {
     case 'v': version(); return 0;
     case 'h': help(); return 0;
     case 'p': setfield(L,t,"p",""); break;
     case 'P': setfield(L,t,"P",""); break;
     case 'o': setfield(L,t,"o",argv[++i]); break;
     case 'n': setfield(L,t,"n",argv[++i]); break;
     case 'H': setfield(L,t,"H",argv[++i]); break;
     default: error(argv[i]); break;
    }
   }
   else
   {
    setfield(L,t,"f",argv[i]);
    break;
   }
  }
  lua_pop(L,1);
 }

#if 1
 {
  int tolua_tolualua_open(lua_State* L);
  tolua_tolualua_open(L);
 }
#else
 {
  int i;
  char* p;
  char  path[BUFSIZ];
  char* files[] = {
                   "basic.lua",
                   "feature.lua",
                   "verbatim.lua",
                   "code.lua",
                   "typedef.lua",
                   "container.lua",
                   "package.lua",
                   "module.lua",
                   "define.lua",
                   "enumerate.lua",
                   "declaration.lua",
                   "variable.lua",
                   "array.lua",
                   "function.lua",
                   "operator.lua",
                   "class.lua",
                   "clean.lua",
                   "doit.lua",
                   NULL
                  };
  strcpy(path,argv[0]);
  p = strrchr(path,'/');
  p = (p==NULL) ? path : p+1;
  for (i=0; files[i]; ++i)
  {
   sprintf(p,"%s",files[i]);
   lua_dofile(L,path); 
  }
 }

#endif
 return 0;
}