elua: support for passing data to modules via require

This commit is contained in:
Daniel Kolesa 2014-08-21 15:32:03 +01:00
parent ba35fe91d1
commit 5d5185f900
2 changed files with 4 additions and 5 deletions

View File

@ -86,12 +86,12 @@ local find_loader = function(modname, env)
return nil, table.concat(err)
end
M.require = function(modname)
M.require = function(modname, ...)
local v = loaded[modname]
if v ~= nil then return v end
local loader, err = find_loader(modname)
if not loader then error(err, 2) end
local ret = loader(modname)
local ret = loader(modname, ...)
if ret ~= nil then
loaded[modname] = ret
return ret

View File

@ -558,7 +558,7 @@ local cutil = require("cutil")
local util = require("util")
local eo = require("eo")
local M = %s
local M = ...
local __lib
@ -572,8 +572,7 @@ end
cutil.init_module(init, shutdown)
]]):format(self.fname, self.klass:full_name_get(), modn, self.libname,
self.libname))
]]):format(self.fname, self.klass:full_name_get(), self.libname, self.libname))
self:gen_children(s)