Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/windirstat.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Schneider <oliver@assarbad.net>2012-12-18 09:27:02 +0400
committerOliver Schneider <oliver@assarbad.net>2012-12-18 09:27:02 +0400
commit1e34ecfcd11e5bc4d3a303d01fe038e2c6432e0f (patch)
tree98c6e7bf12b83410eb40eb808e7720d645c184b9 /sandbox
parent57a15c2d0244a3fbef2609a45b40be40a0cc39dd (diff)
- Finalized the w32resembed.c module
- WDS_Lua_C.h now includes other used headers ...
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/luaconf/lua_conf.cpp54
-rw-r--r--sandbox/luaconf/lua_conf.lua9
2 files changed, 12 insertions, 51 deletions
diff --git a/sandbox/luaconf/lua_conf.cpp b/sandbox/luaconf/lua_conf.cpp
index a8951fd..884f5fd 100644
--- a/sandbox/luaconf/lua_conf.cpp
+++ b/sandbox/luaconf/lua_conf.cpp
@@ -3,7 +3,6 @@
#include "stdafx.h"
#include "lua_conf.h"
-#include "modules/w32resembed.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@@ -11,25 +10,6 @@
namespace
{
- static int traceback (lua_State *L) {
- if (!lua_isstring(L, 1)) /* 'message' not a string? */
- return 1; /* keep it intact */
- lua_getfield(L, LUA_GLOBALSINDEX, "debug");
- if (!lua_istable(L, -1)) {
- lua_pop(L, 1);
- return 1;
- }
- lua_getfield(L, -1, "traceback");
- if (!lua_isfunction(L, -1)) {
- lua_pop(L, 2);
- return 1;
- }
- lua_pushvalue(L, 1); /* pass error message */
- lua_pushinteger(L, 2); /* skip this function and traceback */
- lua_call(L, 2, 1); /* call debug.traceback */
- return 1;
- }
-
static void l_message (const char *pname, const char *msg)
{
if (pname) fprintf(stderr, "%s: ", pname);
@@ -48,25 +28,6 @@ namespace
}
return status;
}
-
- static int docall (lua_State *L, int narg, int clear)
- {
- int status;
- int base = lua_gettop(L) - narg; /* function index */
- lua_pushcfunction(L, traceback); /* push traceback function */
- lua_insert(L, base); /* put it under chunk and args */
- status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base);
- lua_remove(L, base); /* remove traceback function */
- /* force a complete garbage collection in case of errors */
- if (status != 0) lua_gc(L, LUA_GCCOLLECT, 0);
- return status;
- }
-
- static int dostring (lua_State *L, const char *s) {
- const char *name = "dostring";
- int status = luaL_loadbuffer(L, s, strlen(s), name) || docall(L, 0, 1);
- return report(L, status);
- }
}
using namespace std;
@@ -76,12 +37,21 @@ int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
lua_State* L = luaWDS_open();
if(L)
{
- enumerateEmbeddedLuaScripts(L);
- int ret;
+ int ret = w32res_enumerateEmbeddedLuaScripts(L);
+ if(ret)
+ {
+ luaL_error(L, "Failed to enum the resources (%d)", report(L, ret));
+ lua_close(L);
+ return EXIT_FAILURE;
+ }
+ if(lua_istable(L, -1))
+ {
+ lua_pop(L, 1);
+ }
ret = luaL_dofile(L, "lua_conf.lua");
if(ret)
{
- luaL_error(L, "Failed to load lua_conf.lua (%d)", ret);
+ luaL_error(L, "Failed to load lua_conf.lua (%d)", report(L, ret));
lua_close(L);
return EXIT_FAILURE;
}
diff --git a/sandbox/luaconf/lua_conf.lua b/sandbox/luaconf/lua_conf.lua
index 07a1e2c..a21842e 100644
--- a/sandbox/luaconf/lua_conf.lua
+++ b/sandbox/luaconf/lua_conf.lua
@@ -24,18 +24,9 @@ if winres then
end
end
-for k,v in pairs(winres.scripts) do
- package.preload[k:lower()] = function(...)
- return winres.c_loader(k:lower())
- end
-end
-table.foreach(package, print)
dumptable('package.preload', package.preload)
dumptable('winreg', winreg)
x = require "helloworld"
dumptable('package.loaded', package.loaded)
dumptable('package.loaded.helloworld', x)
x.hello()
-
---
-