# HG changeset patch # User Matthew Wild # Date 1331761020 0 # Node ID 17785dbd9d5877d0a876c8ec262ce6d67b4a447f # Parent 69746db53125b6e39362512546ce77758d466c9c modulemanager: Some refactoring. Deprecate module.host = "*", modules should call module:set_global() (which has been around since forever) diff -r 69746db53125 -r 17785dbd9d58 core/modulemanager.lua --- a/core/modulemanager.lua Wed Mar 14 21:33:15 2012 +0000 +++ b/core/modulemanager.lua Wed Mar 14 21:37:00 2012 +0000 @@ -123,6 +123,7 @@ if not modulemap[host] then modulemap[host] = {}; + hosts[host].modules = modulemap[host]; end if modulemap[host][module_name] then @@ -148,8 +149,6 @@ api_instance.environment = pluginenv; setfenv(mod, pluginenv); - hosts[host].modules = modulemap[host]; - modulemap[host][module_name] = pluginenv; local ok, err = pcall(mod); if ok then @@ -161,15 +160,18 @@ end end - -- Use modified host, if the module set one - if api_instance.host == "*" and host ~= "*" then - modulemap[host][module_name] = nil; - modulemap["*"][module_name] = pluginenv; - api_instance:set_global(); + modulemap[pluginenv.module.host][module_name] = pluginenv; + if pluginenv.module.host == "*" then + if not pluginenv.module.global then -- COMPAT w/pre-0.9 + log("warn", "mod_%s: Setting module.host = '*' deprecated, call module:set_global() instead", module_name); + api_instance:set_global(); + end + else + hosts[host].modules[module_name] = pluginenv; end - else + end + if not ok then log("error", "Error initializing module '%s' on '%s': %s", module_name, host, err or "nil"); - do_unload_module(api_instance.host, module_name); -- Ignore error, module may be partially-loaded end return ok and pluginenv, err; end