util/import.lua

Fri, 30 Jan 2009 17:40:25 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Fri, 30 Jan 2009 17:40:25 +0000
changeset 759
5cccfb5da6cb
parent 758
b1885732e979
child 760
90ce865eebd8
permissions
-rw-r--r--

0.2->0.3

759
5cccfb5da6cb 0.2->0.3
Matthew Wild <mwild1@gmail.com>
parents: 758
diff changeset
1 -- Prosody IM v0.3
519
cccd610a0ef9 Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents: 49
diff changeset
2 -- Copyright (C) 2008 Matthew Wild
cccd610a0ef9 Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents: 49
diff changeset
3 -- Copyright (C) 2008 Waqas Hussain
cccd610a0ef9 Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents: 49
diff changeset
4 --
758
b1885732e979 GPL->MIT!
Matthew Wild <mwild1@gmail.com>
parents: 615
diff changeset
5 -- This project is MIT/X11 licensed. Please see the
b1885732e979 GPL->MIT!
Matthew Wild <mwild1@gmail.com>
parents: 615
diff changeset
6 -- COPYING file in the source package for more information.
519
cccd610a0ef9 Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents: 49
diff changeset
7 --
cccd610a0ef9 Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents: 49
diff changeset
8
cccd610a0ef9 Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents: 49
diff changeset
9
49
1cd2a8db392d New "import" module to help tidy up all the local declarations at the top of modules
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10
1cd2a8db392d New "import" module to help tidy up all the local declarations at the top of modules
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 local t_insert = table.insert;
1cd2a8db392d New "import" module to help tidy up all the local declarations at the top of modules
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 function import(module, ...)
1cd2a8db392d New "import" module to help tidy up all the local declarations at the top of modules
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 local m = package.loaded[module] or require(module);
1cd2a8db392d New "import" module to help tidy up all the local declarations at the top of modules
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 if type(m) == "table" and ... then
1cd2a8db392d New "import" module to help tidy up all the local declarations at the top of modules
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 local ret = {};
1cd2a8db392d New "import" module to help tidy up all the local declarations at the top of modules
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 for _, f in ipairs{...} do
1cd2a8db392d New "import" module to help tidy up all the local declarations at the top of modules
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 t_insert(ret, m[f]);
1cd2a8db392d New "import" module to help tidy up all the local declarations at the top of modules
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 end
1cd2a8db392d New "import" module to help tidy up all the local declarations at the top of modules
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 return unpack(ret);
1cd2a8db392d New "import" module to help tidy up all the local declarations at the top of modules
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 end
1cd2a8db392d New "import" module to help tidy up all the local declarations at the top of modules
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 return m;
1cd2a8db392d New "import" module to help tidy up all the local declarations at the top of modules
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 end

mercurial