summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-04-14 02:19:52 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2013-04-14 02:19:52 +0200
commit120ce3327618dea784a0482f1db6295b4168062c (patch)
tree0d6be55744f10da7361ad55d381cafc32a8eb2c9
parent419e509d1b2760c0f84bd825ed6a0cb107cee45f (diff)
downloadlualibs-120ce3327618dea784a0482f1db6295b4168062c.tar.gz
work around merging restrictions
-rw-r--r--lualibs-basic.lua51
-rw-r--r--lualibs-extended.lua75
-rw-r--r--lualibs.lua29
3 files changed, 81 insertions, 74 deletions
diff --git a/lualibs-basic.lua b/lualibs-basic.lua
index 63a7cd0..4a17bdc 100644
--- a/lualibs-basic.lua
+++ b/lualibs-basic.lua
@@ -11,33 +11,46 @@ local lualibs_basic_module = {
license = "See ConTeXt's mreadme.pdf for the license",
}
+local find_file, error, warn, info
if luatexbase and luatexbase.provides_module then
- local _,_,_ = luatexbase.provides_module(lualibs_basic_module)
+ error, warn, info = luatexbase.provides_module(lualibs_basic_module)
+else
+ error, warn, info = texio.write_nl, texio.write_nl, texio.write_nl -- stub
end
-local loadmodule = lualibs.loadmodule
+local loadmodule = lualibs.loadmodule
+local stringformat = string.format
-loadmodule("lualibs-lua.lua")
-loadmodule("lualibs-lpeg.lua")
-loadmodule("lualibs-function.lua")
-loadmodule("lualibs-string.lua")
-loadmodule("lualibs-table.lua")
-loadmodule("lualibs-boolean.lua")
-loadmodule("lualibs-number.lua")
-loadmodule("lualibs-math.lua")
-loadmodule("lualibs-io.lua")
-loadmodule("lualibs-os.lua")
-loadmodule("lualibs-file.lua")
-loadmodule("lualibs-md5.lua")
-loadmodule("lualibs-dir.lua")
-loadmodule("lualibs-unicode.lua")
-loadmodule("lualibs-url.lua")
-loadmodule("lualibs-set.lua")
+local res
+if lualibs.prefer_merged then
+ res = loadmodule('lualibs-basic-merged.lua')
+else
+ info"Ignoring merged packages."
+end
+
+if not res then
+ info(stringformat("Falling back to “%s”.", basename))
+ loadmodule("lualibs-lua.lua")
+ loadmodule("lualibs-lpeg.lua")
+ loadmodule("lualibs-function.lua")
+ loadmodule("lualibs-string.lua")
+ loadmodule("lualibs-table.lua")
+ loadmodule("lualibs-boolean.lua")
+ loadmodule("lualibs-number.lua")
+ loadmodule("lualibs-math.lua")
+ loadmodule("lualibs-io.lua")
+ loadmodule("lualibs-os.lua")
+ loadmodule("lualibs-file.lua")
+ loadmodule("lualibs-md5.lua")
+ loadmodule("lualibs-dir.lua")
+ loadmodule("lualibs-unicode.lua")
+ loadmodule("lualibs-url.lua")
+ loadmodule("lualibs-set.lua")
+end
-- these don’t look much basic to me:
--l-pdfview.lua
--l-xml.lua
-
-- vim:tw=71:sw=2:ts=2:expandtab
-- End of File `lualibs.lua'.
diff --git a/lualibs-extended.lua b/lualibs-extended.lua
index a6550db..a21bc50 100644
--- a/lualibs-extended.lua
+++ b/lualibs-extended.lua
@@ -11,6 +11,16 @@ local lualibs_extended_module = {
license = "See ConTeXt's mreadme.pdf for the license",
}
+local find_file, error, warn, info
+if luatexbase and luatexbase.provides_module then
+ error, warn, info = luatexbase.provides_module(lualibs_extended_module)
+else
+ error, warn, info = texio.write_nl, texio.write_nl, texio.write_nl -- stub
+end
+
+local stringformat = string.format
+local loadmodule = lualibs.loadmodule
+
--[[doc--
Here we define some functions that fake the elaborate logging/tracking
mechanism Context provides.
@@ -83,11 +93,9 @@ For these cases we provide a copy of the original \verb|arg| list and
restore it after we are done loading.
--doc]]--
-local backup_store --- will be populated after util-sto
+local backup_store = { }
+
local fake_context = function ( )
- if not backup_store then
- backup_store = utilities.storage.allocate()
- end
if _G.logs then backup_store.logs = _G.logs end
if _G.trackers then backup_store.trackers = _G.trackers end
_G.logs = fake_logs"logs"
@@ -110,34 +118,43 @@ local unfake_context = function ( )
end
end
-local loadmodule = lualibs.loadmodule
-
-loadmodule("lualibs-util-str.lua")--- string formatters (fast)
-loadmodule("lualibs-util-tab.lua")--- extended table operations
-loadmodule("lualibs-util-sto.lua")--- storage (hash allocation)
-----------("lualibs-util-pck.lua")---!packers; necessary?
-----------("lualibs-util-seq.lua")---!sequencers (function chaining)
-----------("lualibs-util-mrg.lua")---!only relevant in mtx-package
-loadmodule("lualibs-util-prs.lua")--- miscellaneous parsers; cool. cool cool cool
-----------("lualibs-util-fmt.lua")---!column formatter (rarely used)
-loadmodule("lualibs-util-dim.lua")--- conversions between dimensions
-loadmodule("lualibs-util-jsn.lua")--- JSON parser
+fake_context()
+local res
+if lualibs.prefer_merged then
+ res = loadmodule('lualibs-extended-merged.lua')
+else
+ info"Ignoring merged packages."
+end
-fake_context()
+if not res then
+ info(stringformat("Falling back to “%s”.", basename))
+ loadmodule("lualibs-util-str.lua")--- string formatters (fast)
+ loadmodule("lualibs-util-tab.lua")--- extended table operations
+ loadmodule("lualibs-util-sto.lua")--- storage (hash allocation)
+ ----------("lualibs-util-pck.lua")---!packers; necessary?
+ ----------("lualibs-util-seq.lua")---!sequencers (function chaining)
+ ----------("lualibs-util-mrg.lua")---!only relevant in mtx-package
+ loadmodule("lualibs-util-prs.lua")--- miscellaneous parsers; cool. cool cool cool
+ ----------("lualibs-util-fmt.lua")---!column formatter (rarely used)
+ loadmodule("lualibs-util-dim.lua")--- conversions between dimensions
+ ----------("lualibs-util-jsn.lua")--- JSON parser
+
+ ----------("lualibs-trac-set.lua")---!generalization of trackers
+ ----------("lualibs-trac-log.lua")---!logging
+ loadmodule("lualibs-trac-inf.lua")--- timing/statistics
+ loadmodule("lualibs-util-lua.lua")--- operations on lua bytecode
+ loadmodule("lualibs-util-deb.lua")--- extra debugging
+ loadmodule("lualibs-util-tpl.lua")--- templating
+ loadmodule("lualibs-util-sta.lua")--- stacker (for writing pdf)
+ -------------------------------------!data-* -- Context specific
+ ----------("lualibs-util-lib.lua")---!swiglib; there is a luatex-swiglib
+ loadmodule("lualibs-util-env.lua")--- environment arguments
+ ----------("lualibs-mult-ini.lua")---
+ ----------("lualibs-core-con.lua")---
+end
-----------("lualibs-trac-set.lua")---!generalization of trackers
-----------("lualibs-trac-log.lua")---!logging
-loadmodule("lualibs-trac-inf.lua")--- timing/statistics
-loadmodule("lualibs-util-lua.lua")--- operations on lua bytecode
-loadmodule("lualibs-util-deb.lua")--- extra debugging
-loadmodule("lualibs-util-tpl.lua")--- templating
-loadmodule("lualibs-util-sta.lua")--- stacker (for writing pdf)
--------------------------------------!data-* -- Context specific
-----------("lualibs-util-lib.lua")---!swiglib; there is a luatex-swiglib
-loadmodule("lualibs-util-env.lua")--- environment arguments
-----------("lualibs-mult-ini.lua")---
-----------("lualibs-core-con.lua")---
+loadmodule"lualibs-util-jsn.lua"--- cannot be merged because of return statement
unfake_context() --- TODO check if this works at runtime
diff --git a/lualibs.lua b/lualibs.lua
index cd0034e..59d7907 100644
--- a/lualibs.lua
+++ b/lualibs.lua
@@ -12,7 +12,7 @@ local lualibs_module = {
}
--- TODO should be set in some global config
-local prefer_merged = true ---false
+prefer_merged = true ---false
local load_extended = true ---false
if config and config.lualibs then
@@ -59,36 +59,13 @@ local p_nosuffix = (1 - p_suffix)^0
local p_hassuffix = (p_nosuffix) * p_suffix
local p_stripsuffix = lpeg.C(p_nosuffix) * p_suffix
-local loadmerged = function (basename)
- basename = lualibs_module.name .. "-" .. basename
- if not lpegmatch(p_hassuffix, basename) then -- force .lua suffix
- basename = basename .. ".lua"
- end
- local res
- if prefer_merged then
- local mergedname = lpegmatch(p_stripsuffix, basename) .. merged_suffix
- res = loadmodule(mergedname, "merged package")
- else
- info"Ignoring merged packages."
- end
- if not res then -- package not present, load individual libs
- info(stringformat("Falling back to “%s”.", basename))
- res = loadmodule(basename, "metapackage")
- end
- if res == false then
- error(stringformat("Could not load metapackage “%s”.", basename))
- end
-end
-
--[[doc--
The separation of the “basic” from the “extended” sets coincides with
the split into luat-bas.mkiv and luat-lib.mkiv.
--doc]]--
-loadmerged"basic.lua"
---inspect(table.keys(table))
---inspect(table.keys(string))
+loadmodule"lualibs-basic.lua"
if load_extended == true then
- loadmerged"extended.lua"
+ loadmodule"lualibs-extended.lua"
end
-- vim:tw=71:sw=2:ts=2:expandtab