configmanager: Add parsers() method to return an array of supported config formats

Sat, 09 Jan 2010 06:59:47 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Sat, 09 Jan 2010 06:59:47 +0000
changeset 2427
343a9eb7540e
parent 2426
4cef9808662a
child 2428
3ba9db4b9311

configmanager: Add parsers() method to return an array of supported config formats

core/configmanager.lua file | annotate | diff | comparison | revisions
--- a/core/configmanager.lua	Sat Jan 09 06:53:23 2010 +0000
+++ b/core/configmanager.lua	Sat Jan 09 06:59:47 2010 +0000
@@ -9,8 +9,8 @@
 
 
 local _G = _G;
-local 	setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type = 
-		setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type;
+local 	setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table =
+		setmetatable, loadfile, pcall, rawget, rawset, io, error, dofile, type, pairs, table;
 
 local eventmanager = require "core.eventmanager";
 
@@ -94,6 +94,15 @@
 	end
 end
 
+-- _M needed to avoid name clash with local 'parsers'
+function _M.parsers()
+	local p = {};
+	for format in pairs(parsers) do
+		table.insert(p, format);
+	end
+	return p;
+end
+
 -- Built-in Lua parser
 do
 	local loadstring, pcall, setmetatable = _G.loadstring, _G.pcall, _G.setmetatable;

mercurial