]> git.sesse.net Git - vlc/commitdiff
Simplify lua http's custom.lua. Print any errors while loading custom.lua in the...
authorAntoine Cellerier <dionoea@videolan.org>
Mon, 21 Dec 2009 23:24:38 +0000 (00:24 +0100)
committerAntoine Cellerier <dionoea@videolan.org>
Sun, 27 Dec 2009 19:12:16 +0000 (20:12 +0100)
share/lua/http/custom.lua
share/lua/intf/http.lua

index f0483d7e4f90fa89b114acd5984b2bc187a4406a..ab0235841fbd71ea52d63e344c52adc6a65cdb0e 100644 (file)
@@ -1,25 +1,17 @@
 local _G = _G
 module("custom",package.seeall)
 
-local dialogs_cache = {}
+local dialogs = setmetatable({}, {
+__index = function(self, name)
+    -- Cache the dialogs
+    return rawget(self, name) or
+           rawget(rawset(self, name, process(http_dir.."/dialogs/"..name)), name)
+end})
 
-function dialog_preload(name)
-    if not dialogs_cache[name] then
-        -- Cache the dialogs
-        dialogs_cache[name] = process(http_dir.."/dialogs/"..name)
+_G.dialogs = function(...)
+    for i=1, select("#",...) do
+        dialogs[(select(i,...))]()
     end
 end
 
-function dialog(name)
-    dialog_preload(name)
-    dialogs_cache[name]()
-end
-
-function dialogs(...)
-    for i=1,select("#",...) do
-        dialog(select(i,...))
-    end
-end
-
-_G.dialogs = dialogs
 _G.vlm = vlc.vlm()
index 19ed26a8c1378df17f2c75cb14ce17fae3b17375..054376517d4d0fffc464c8c3d23b8f82ff665bc4 100644 (file)
@@ -258,7 +258,7 @@ do
     package.path = http_dir.."/?.lua"
     local ok, err = pcall(require,"custom")
     if not ok then
-        vlc.msg.warn("Couldn't load "..http_dir.."/custom.lua")
+        vlc.msg.warn("Couldn't load "..http_dir.."/custom.lua",err)
     else
         vlc.msg.dbg("Loaded "..http_dir.."/custom.lua")
     end