summaryrefslogtreecommitdiff
path: root/tex/context/base/back-ini.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/back-ini.lua')
-rw-r--r--tex/context/base/back-ini.lua194
1 files changed, 37 insertions, 157 deletions
diff --git a/tex/context/base/back-ini.lua b/tex/context/base/back-ini.lua
index 4e990aa38..5cabc16ac 100644
--- a/tex/context/base/back-ini.lua
+++ b/tex/context/base/back-ini.lua
@@ -6,10 +6,9 @@ if not modules then modules = { } end modules ['back-ini'] = {
license = "see context related readme files"
}
--- I need to check what is actually needed, maybe some can become
--- locals.
+local setmetatable = setmetatable
-backends = backends or { }
+backends = backends or { }
local backends = backends
local trace_backend = false trackers.register("backend.initializers", function(v) trace_finalizers = v end)
@@ -20,143 +19,35 @@ local function nothing() return nil end
backends.nothing = nothing
-backends.nodeinjections = {
-
- rgbcolor = nothing,
- cmykcolor = nothing,
- graycolor = nothing,
- spotcolor = nothing,
-
- transparency = nothing,
-
- overprint = nothing,
- knockout = nothing,
-
- positive = nothing,
- negative = nothing,
-
- effect = nothing,
-
- startlayer = nothing,
- stoplayer = nothing,
- switchlayer = nothing,
-
- reference = nothing,
- destination = nothing,
-
- addtags = nothing,
-
- insertu3d = nothing,
- insertswf = nothing,
- insertmovie = nothing,
- insertsound = nothing,
-
- injectbitmap = nothing,
-
-}
-
-backends.codeinjections = {
-
- prerollreference = nothing,
-
- presetsymbol = nothing,
- presetsymbollist = nothing,
- registersymbol = nothing,
- registeredsymbol = nothing,
-
- registercomment = nothing,
-
- embedfile = nothing,
- attachfile = nothing,
- attachmentid = nothing,
-
- adddocumentinfo = nothing,
- setupidentity = nothing,
- setupcanvas = nothing,
-
- setpagetransition = nothing,
-
- defineviewerlayer = nothing,
- useviewerlayer = nothing,
-
- addbookmarks = nothing,
-
- addtransparencygroup = nothing,
-
- typesetfield = nothing,
- doiffieldelse = nothing,
- doiffieldgroupelse = nothing,
- doiffieldsetelse = nothing,
- definefield = nothing,
- clonefield = nothing,
- definefieldset = nothing,
- setfieldcalculationset = nothing,
- getfieldgroup = nothing,
- getfieldset = nothing,
- setformsmethod = nothing,
- getdefaultfieldvalue = nothing,
-
- flushpageactions = nothing,
- flushdocumentactions = nothing,
-
- insertrenderingwindow = nothing,
- processrendering = nothing,
-
- setfigurecolorspace = nothing,
- setfigurealternative = nothing,
- setfiguremask = nothing,
-
- enabletags = nothing,
-
- mergereferences = nothing,
- mergeviewerlayers = nothing,
-
- setformat = nothing,
- getformatoption = nothing,
- supportedformats = nothing,
-
- -- called in tex
-
- finalizepage = nothing, -- will go when we have a hook at the lua end
-
- finishreference = nothing,
-
- getoutputfilename = nothing,
-
+local mt = {
+ __index = function(t,k)
+ t[k] = nothing
+ return nothing
+ end
}
-backends.registrations = {
-
- grayspotcolor = nothing,
- rgbspotcolor = nothing,
- cmykspotcolor = nothing,
-
- grayindexcolor = nothing,
- rgbindexcolor = nothing,
- cmykindexcolor = nothing,
-
- spotcolorname = nothing,
-
- transparency = nothing,
+local nodeinjections = { } setmetatable(nodeinjections, mt)
+local codeinjections = { } setmetatable(codeinjections, mt)
+local registrations = { } setmetatable(registrations, mt)
+local tables = { }
+local defaults = {
+ nodeinjections = nodeinjections,
+ codeinjections = codeinjections,
+ registrations = registrations,
+ tables = tables,
}
-local comment = { "comment", "" }
+backends.defaults = defaults
-backends.tables = {
- vfspecials = {
- red = comment,
- green = comment,
- blue = comment,
- black = comment,
- startslant = comment,
- stopslant = comment,
- }
-}
+backends.nodeinjections = { } setmetatable(backends.nodeinjections, { __index = nodeinjections })
+backends.codeinjections = { } setmetatable(backends.codeinjections, { __index = codeinjections })
+backends.registrations = { } setmetatable(backends.registrations, { __index = registrations })
+backends.tables = { } setmetatable(backends.tables, { __index = tables })
backends.current = "unknown"
-function backends.install(what) -- these can become metatables
+function backends.install(what)
if type(what) == "string" then
local backend = backends[what]
if backend then
@@ -164,32 +55,10 @@ function backends.install(what) -- these can become metatables
report_backend("initializing backend %s (%s)",what,backend.comment or "no comment")
end
backends.current = what
- for _, category in next, { "nodeinjections", "codeinjections", "registrations", "tables" } do
- local plugin = backend[category]
- local whereto = backends[category]
- if plugin then
- for name, meaning in next, whereto do
- if plugin[name] then
- whereto[name] = plugin[name]
- -- report_backend("installing function %s in category %s of %s",name,category,what)
- elseif trace_backend then
- report_backend("no function %s in category %s of %s",name,category,what)
- end
- end
- elseif trace_backend then
- report_backend("no category %s in %s",category,what)
- end
- -- extra checks
- for k, v in next, whereto do
- if not plugin[k] then
- report_backend("entry %s in %s is not set",k,category)
- end
- end
- for k, v in next, plugin do
- if not whereto[k] then
- report_backend("entry %s in %s is not used",k,category)
- end
- end
+ for category, default in next, defaults do
+ local target, plugin = backends[category], backend[category]
+ setmetatable(plugin, { __index = default })
+ setmetatable(target, { __index = plugin })
end
elseif trace_backend then
report_backend("no backend named %s",what)
@@ -205,3 +74,14 @@ statistics.register("used backend", function()
return nil
end
end)
+
+local comment = { "comment", "" }
+
+tables.vfspecials = {
+ red = comment,
+ green = comment,
+ blue = comment,
+ black = comment,
+ startslant = comment,
+ stopslant = comment,
+}