Comparison

util/pluginloader.lua @ 5021:85b2689dbcfe

Eliminate direct setfenv usage
author Florian Zeitz <florob@babelmonkeys.de>
date Fri, 08 Jun 2012 05:04:38 +0200
parent 4154:3785a9bb7f11
child 5072:586c9106a106
comparison
equal deleted inserted replaced
5020:ef1eb65acbba 5021:85b2689dbcfe
14 plugin_dir[#plugin_dir + 1] = path; 14 plugin_dir[#plugin_dir + 1] = path;
15 end 15 end
16 16
17 local io_open, os_time = io.open, os.time; 17 local io_open, os_time = io.open, os.time;
18 local loadstring, pairs = loadstring, pairs; 18 local loadstring, pairs = loadstring, pairs;
19 local envload = require "util.envload".envload;
19 20
20 module "pluginloader" 21 module "pluginloader"
21 22
22 local function load_file(names) 23 local function load_file(names)
23 local file, err, path; 24 local file, err, path;
46 }; 47 };
47 48
48 return load_file(names); 49 return load_file(names);
49 end 50 end
50 51
51 function load_code(plugin, resource) 52 function load_code(plugin, resource, env)
52 local content, err = load_resource(plugin, resource); 53 local content, err = load_resource(plugin, resource);
53 if not content then return content, err; end 54 if not content then return content, err; end
54 local path = err; 55 local path = err;
55 local f, err = loadstring(content, "@"..path); 56 local f, err = envload(content, "@"..path, env);
56 if not f then return f, err; end 57 if not f then return f, err; end
57 return f, path; 58 return f, path;
58 end 59 end
59 60
60 return _M; 61 return _M;