diff options
author | Marius <mariausol@gmail.com> | 2012-10-19 01:20:13 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2012-10-19 01:20:13 +0300 |
commit | 69d2352af4b60929b37fc49f3bdb263977016244 (patch) | |
tree | db5eb11398e345dfa23b4c4500fb93575d2afb7c /tex/context/base/luat-ini.lua | |
parent | c18f7cbe51449a611ea1819fedd9a4ff18529b7d (diff) | |
download | context-69d2352af4b60929b37fc49f3bdb263977016244.tar.gz |
stable 2012.05.30 11:26
Diffstat (limited to 'tex/context/base/luat-ini.lua')
-rw-r--r-- | tex/context/base/luat-ini.lua | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/tex/context/base/luat-ini.lua b/tex/context/base/luat-ini.lua index 94c878eb1..204cc7bd1 100644 --- a/tex/context/base/luat-ini.lua +++ b/tex/context/base/luat-ini.lua @@ -8,11 +8,12 @@ if not modules then modules = { } end modules ['luat-ini'] = { -- rather experimental down here ... will change with lua 5.2 -- -local debug = require("debug") - +local debug = require "debug" local string, table, lpeg, math, io, system = string, table, lpeg, math, io, system local next, setfenv = next, setfenv or debug.setfenv +local mark = utilities.storage.mark + --[[ldx-- <p>We cannot load anything yet. However what we will do us reserve a fewtables. These can be used for runtime user data or third party modules and will not be @@ -25,6 +26,15 @@ moduledata = moduledata or { } -- only for development team documentdata = documentdata or { } -- for users (e.g. raw data) parametersets = parametersets or { } -- experimental for team +document = document or { } -- only for context itself + +--[[ldx-- +<p>These can be used/set by the caller program; <t>mtx-context.lua</t> does it.</p> +--ldx]]-- + +document.arguments = mark(document.arguments or { }) +document.files = mark(document.files or { }) + --[[ldx-- <p>Please create a namespace within these tables before using them!</p> @@ -147,3 +157,33 @@ end storage.register("lua/numbers", lua.numbers, "lua.numbers") storage.register("lua/messages", lua.messages, "lua.messages") + +--~ local arguments, files = document.arguments, document.files -- set later + +function document.setargument(key,value) + document.arguments[key] = value +end + +function document.setdefaultargument(key,default) + local v = document.arguments[key] + if v == nil or v == "" then + document.arguments[key] = default + end +end + +function document.getargument(key,default) + local v = document.arguments[key] + if type(v) == "boolean" then + v = (v and "yes") or "no" + document.arguments[key] = v + end + context(v or default or "") +end + +function document.setfilename(i,name) + document.files[tonumber(i)] = name +end + +function document.getfilename(i) + context(document.files[i] or "") +end |