111 local setfenv, rawget, tostring = _G.setfenv, _G.rawget, _G.tostring; |
111 local setfenv, rawget, tostring = _G.setfenv, _G.rawget, _G.tostring; |
112 parsers.lua = {}; |
112 parsers.lua = {}; |
113 function parsers.lua.load(data, filename) |
113 function parsers.lua.load(data, filename) |
114 local env; |
114 local env; |
115 -- The ' = true' are needed so as not to set off __newindex when we assign the functions below |
115 -- The ' = true' are needed so as not to set off __newindex when we assign the functions below |
116 env = setmetatable({ Host = true; host = true; Component = true, component = true, |
116 env = setmetatable({ |
117 Include = true, include = true, RunScript = dofile }, { __index = function (t, k) |
117 Host = true; host = true; Component = true, component = true, |
118 return rawget(_G, k) or |
118 Include = true, include = true, RunScript = dofile }, { |
119 function (settings_table) |
119 __index = function (t, k) |
120 config[__currenthost or "*"][k] = settings_table; |
120 return rawget(_G, k) or |
121 end; |
121 function (settings_table) |
122 end, |
122 config[__currenthost or "*"][k] = settings_table; |
123 __newindex = function (t, k, v) |
123 end; |
124 set(env.__currenthost or "*", "core", k, v); |
124 end, |
125 end}); |
125 __newindex = function (t, k, v) |
|
126 set(env.__currenthost or "*", "core", k, v); |
|
127 end |
|
128 }); |
126 |
129 |
127 rawset(env, "__currenthost", "*") -- Default is global |
130 rawset(env, "__currenthost", "*") -- Default is global |
128 function env.Host(name) |
131 function env.Host(name) |
129 if rawget(config, name) and rawget(config[name].core, "component_module") then |
132 if rawget(config, name) and rawget(config[name].core, "component_module") then |
130 error(format("Host %q clashes with previously defined %s Component %q, for services use a sub-domain like conference.%s", |
133 error(format("Host %q clashes with previously defined %s Component %q, for services use a sub-domain like conference.%s", |