[vlc-devel] commit: Simplify lua http's custom.lua. Print any errors while loading custom.lua in the debug output. ( Antoine Cellerier )

git version control git at videolan.org
Sun Dec 27 20:20:18 CET 2009


vlc | branch: master | Antoine Cellerier <dionoea at videolan.org> | Tue Dec 22 00:24:38 2009 +0100| [d34809417bb615fb7d9ec63fc10845e74bad6384] | committer: Antoine Cellerier 

Simplify lua http's custom.lua. Print any errors while loading custom.lua in the debug output.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d34809417bb615fb7d9ec63fc10845e74bad6384
---

 share/lua/http/custom.lua |   26 +++++++++-----------------
 share/lua/intf/http.lua   |    2 +-
 2 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/share/lua/http/custom.lua b/share/lua/http/custom.lua
index f0483d7..ab02358 100644
--- a/share/lua/http/custom.lua
+++ b/share/lua/http/custom.lua
@@ -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()
diff --git a/share/lua/intf/http.lua b/share/lua/intf/http.lua
index 19ed26a..0543765 100644
--- a/share/lua/intf/http.lua
+++ b/share/lua/intf/http.lua
@@ -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




More information about the vlc-devel mailing list