summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/attr-ini.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/attr-ini.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/attr-ini.lua74
1 files changed, 40 insertions, 34 deletions
diff --git a/Master/texmf-dist/tex/context/base/attr-ini.lua b/Master/texmf-dist/tex/context/base/attr-ini.lua
index 206a86d79b5..1e518467cff 100644
--- a/Master/texmf-dist/tex/context/base/attr-ini.lua
+++ b/Master/texmf-dist/tex/context/base/attr-ini.lua
@@ -20,6 +20,9 @@ local attributes = attributes
local sharedstorage = storage.shared
+local texgetcount = tex.getcount
+local texsetattribute = tex.setattribute
+
attributes.names = attributes.names or { }
attributes.numbers = attributes.numbers or { }
attributes.list = attributes.list or { }
@@ -35,13 +38,13 @@ storage.register("attributes/names", names, "attributes.names")
storage.register("attributes/numbers", numbers, "attributes.numbers")
storage.register("attributes/list", list, "attributes.list")
-function attributes.define(name,number) -- at the tex end
- if not numbers[name] then
- numbers[name] = number
- names[number] = name
- list[number] = { }
- end
-end
+-- function attributes.define(name,number) -- at the tex end
+-- if not numbers[name] then
+-- numbers[name] = number
+-- names[number] = name
+-- list[number] = { }
+-- end
+-- end
--[[ldx--
<p>We reserve this one as we really want it to be always set (faster).</p>
@@ -55,33 +58,14 @@ are only used when no attribute is set at the \TEX\ end which normally
happens in <l n='context'/>.</p>
--ldx]]--
-sharedstorage.attributes_last_private = sharedstorage.attributes_last_private or 127
-
--- to be considered (so that we can use an array access):
---
--- local private = { } attributes.private = private
---
--- setmetatable(private, {
--- __index = function(t,name)
--- local number = sharedstorage.attributes_last_private
--- if number < 1023 then -- tex.count.minallocatedattribute - 1
--- number = number + 1
--- sharedstorage.attributes_last_private = number
--- end
--- numbers[name], names[number], list[number] = number, name, { }
--- private[name] = number
--- return number
--- end,
--- __call = function(t,name)
--- return t[name]
--- end
--- } )
+sharedstorage.attributes_last_private = sharedstorage.attributes_last_private or 127
+sharedstorage.attributes_last_public = sharedstorage.attributes_last_public or 1024
function attributes.private(name) -- at the lua end (hidden from user)
local number = numbers[name]
if not number then
local last = sharedstorage.attributes_last_private
- if last < 1023 then -- tex.count.minallocatedattribute - 1
+ if last < 1023 then
last = last + 1
sharedstorage.attributes_last_private = last
else
@@ -94,6 +78,29 @@ function attributes.private(name) -- at the lua end (hidden from user)
return number
end
+function attributes.public(name) -- at the lua end (hidden from user)
+ local number = numbers[name]
+ if not number then
+ local last = sharedstorage.attributes_last_public
+ if last < 65535 then
+ last = last + 1
+ sharedstorage.attributes_last_public = last
+ else
+ report_attribute("no more room for public attributes")
+ os.exit()
+ end
+ number = last
+ numbers[name], names[number], list[number] = number, name, { }
+ end
+ return number
+end
+
+attributes.system = attributes.private
+
+function attributes.define(name,number,category)
+ return (attributes[category or "public"] or attributes["public"])(name,number)
+end
+
-- tracers
local report_attribute = logs.reporter("attributes")
@@ -121,11 +128,10 @@ end
-- interface
-commands.defineattribute = attributes.define
-commands.showattributes = attributes.showcurrent
+commands.showattributes = attributes.showcurrent
-function commands.getprivateattribute(name)
- context(attributes.private(name))
+function commands.defineattribute(name,category)
+ context(attributes.define(name,category))
end
-- rather special
@@ -155,7 +161,7 @@ function commands.restorecurrentattributes(name)
local font = t.font
if attr then
for k, v in next, attr do
- tex.attribute[k] = v
+ texsetattribute(k,v)
end
end
if font then