From 3015aac8bcb38ed2d00b8f5205bd54d82b96e71a Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 21 Feb 2015 10:36:37 +0100 Subject: util.*: Remove use of module() function, make all module functions local and return them in a table at the end --- util/filters.lua | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'util/filters.lua') diff --git a/util/filters.lua b/util/filters.lua index 427dcb7c..f405c0bd 100644 --- a/util/filters.lua +++ b/util/filters.lua @@ -8,11 +8,11 @@ local t_insert, t_remove = table.insert, table.remove; -module "filters" +local _ENV = nil; local new_filter_hooks = {}; -function initialize(session) +local function initialize(session) if not session.filters then local filters = {}; session.filters = filters; @@ -36,7 +36,7 @@ function initialize(session) return session.filter; end -function add_filter(session, type, callback, priority) +local function add_filter(session, type, callback, priority) if not session.filters then initialize(session); end @@ -60,7 +60,7 @@ function add_filter(session, type, callback, priority) filter_list[callback] = priority; end -function remove_filter(session, type, callback) +local function remove_filter(session, type, callback) if not session.filters then return; end local filter_list = session.filters[type]; if filter_list and filter_list[callback] then @@ -74,11 +74,11 @@ function remove_filter(session, type, callback) end end -function add_filter_hook(callback) +local function add_filter_hook(callback) t_insert(new_filter_hooks, callback); end -function remove_filter_hook(callback) +local function remove_filter_hook(callback) for i=1,#new_filter_hooks do if new_filter_hooks[i] == callback then t_remove(new_filter_hooks, i); @@ -86,4 +86,10 @@ function remove_filter_hook(callback) end end -return _M; +return { + initialize = initialize; + add_filter = add_filter; + remove_filter = remove_filter; + add_filter_hook = add_filter_hook; + remove_filter_hook = remove_filter_hook; +}; -- cgit v1.2.3