示例#1
0
static void iuplua_openlibs (lua_State *L) {
  lua_pushliteral(L, LUA_COPYRIGHT);
  lua_setglobal(L, "_COPYRIGHT");  /* set global _COPYRIGHT */

#ifdef USE_STATIC
  /* iuplua initialization */
  iuplua_open(L);
#ifdef IUPLUA_IMGLIB
  luaopen_iupluaimglib(L);
#endif

/* luaopen_lfs(L); */

#ifndef IUPLUA_NO_GL
  iupgllua_open(L);
/*  luaopen_luagl(L); */
#endif
#ifndef IUPLUA_NO_CD
  iupcontrolslua_open(L);
  iup_pplotlua_open(L);
  cdlua_open(L);
  cdluaiup_open(L);
#endif
#ifndef IUPLUA_NO_IM
  iupimlua_open(L);
  imlua_open(L);
  imlua_open_process(L);
#endif
#ifndef IUPLUA_NO_IM
#ifndef IUPLUA_NO_CD
  cdluaim_open(L);
#endif
#endif
#endif
}
示例#2
0
static void iuplua_openlibs(lua_State *L) 
{
  lua_pushliteral(L, LUA_COPYRIGHT);
  lua_setglobal(L, "_COPYRIGHT");  /* set global _COPYRIGHT */

  /* iuplua initialization */
  iuplua_open(L);

#ifdef USE_STATIC
  /* disable require */
  iuplua_dostring(L, "function require() end ", "static_require");

#ifdef IUPLUA_IMGLIB
  luaopen_iupluaimglib(L);
#endif
#ifdef IUPLUA_TUIO
  iuptuiolua_open(L);
#endif
#ifdef IUPLUA_WEB
  iupweblua_open(L);
#endif
#ifdef IUPLUA_SCINTILLA
  iup_scintillalua_open(L);
#endif

/* luaopen_lfs(L); */

#ifndef IUPLUA_NO_GL
  iupgllua_open(L);
  iupglcontrolslua_open(L);
#ifdef USE_LUAGL
  luaopen_luagl(L);
#endif
#endif
#ifndef IUPLUA_NO_CD
  iupcontrolslua_open(L);
  iupmatrixexlua_open(L);
  iup_plotlua_open(L);
  cdlua_open(L);
  cdluaiup_open(L);
  cdInitContextPlus();
#endif
#ifndef IUPLUA_NO_IM
  iupimlua_open(L);
  imlua_open(L);
  imlua_open_process(L);
#endif
#ifndef IUPLUA_NO_IM
#ifndef IUPLUA_NO_CD
  cdluaim_open(L);
#endif
#endif
#endif
}
示例#3
0
int main(int argc, char ** argv)
{
  setExecutablePath(argv[0]);

  lua_State *L = lua_open();

  luaL_openlibs(L);

#if USE_IUP
  iuplua_open(L);
  cdlua_open(L);
  cdluaiup_open(L);

  iupkey_open(L);
  iupimlua_open(L);
  IupImageLibOpen ();
  iupcontrolslua_open(L);
  imlua_open(L);
  imlua_open_process(L);
#endif

  luaopen_pack(L);
  luaopen_lfs(L);
  luaopen_marshal(L);
  luaopen_mime_core(L);
  luaopen_socket_core(L);

  pdfdoc_register(L);
  pdfpage_register(L);
  clipboard_register(L);
  luaopen_system(L);
  luaopen_compare(L);

#if _DEBUG 
  lua_pushboolean(L, true);
  lua_setfield(L, LUA_GLOBALSINDEX, "_DEBUG");
#endif
  
  char luaFile[512] = "";
  char playlistFile[512] = "";
  int beginIndex = 1;
  if (argc > 1)
  {
    int strl = strlen(argv[1]);
    bool isLuaFile = strcmp(&argv[1][strl-4], ".lua") == 0;
    if (isLuaFile)
    {
      beginIndex = 2;
      strcpy_s(luaFile, sizeof(luaFile), argv[1]);
    }
    else if (strcmp(&argv[1][strl-5], ".sing") == 0
      || strcmp(&argv[1][strl-4], ".m3u") == 0
      || strcmp(&argv[1][strl-4], ".txt") == 0)
    {
    }
  }
  if (!luaFile[0])
  {
    lua_pushboolean(L, true);
    lua_setfield(L, LUA_GLOBALSINDEX, "APPLOADED");
	const char* execPath = getExecutablePath();
	sprintf_s(luaFile, sizeof(luaFile), "%s\\%s", execPath, "main.lua");
  }
    
  int temp_int = luaL_loadfile(L,luaFile);
  
  int returnval = 0;
  if (temp_int)
  {
    const char *error = lua_tostring(L, -1);
    printf("Error in file: \"%s\"\n", luaFile);
    printf("%s\n", error);
    returnval = 1;
  }
  else
  {
    const char *error;

    for (int i = beginIndex; i < argc; i++)
      lua_pushstring(L, argv[i]);

    if (docall(L,argc-beginIndex,0))
    {
      error = lua_tostring(L, -1);
      if (error)
        std::cout << error;
      returnval = 1;
    }
  }
  close(L);

  return returnval;
}