summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-05-17 17:37:18 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2013-05-17 17:37:18 +0200
commita9178223ec8b11a5de7937e3bd5f4492eb6ceea6 (patch)
treed2f2fac0283d60a17a1b8012ddfdaa2cdb3b3c42
parentf173f5c12fe3f8741451ae643ab56320c112fc52 (diff)
downloadluatexbase-a9178223ec8b11a5de7937e3bd5f4492eb6ceea6.tar.gz
have ``new_user_whatsit()`` accept prototype as first argument
-rw-r--r--luatexbase-attr.dtx39
1 files changed, 16 insertions, 23 deletions
diff --git a/luatexbase-attr.dtx b/luatexbase-attr.dtx
index 3e01827..f10e2de 100644
--- a/luatexbase-attr.dtx
+++ b/luatexbase-attr.dtx
@@ -262,7 +262,7 @@ See the aforementioned source file(s) for copyright and licensing information.
%
% \subsubsection{Primitives needed}
%
-% First load \pk{luatexbase-modutils} (hence \pk{luatexbase-loader}
+% First load \pk{luatexbase-modutils} (hence \pk{luatexbase-loader}
% and \pk{luatexbase-compat}), and make sure \pk{luatex.sty} is loaded too.
%
% \begin{macrocode}
@@ -523,28 +523,22 @@ luatexbase.new_user_whatsit_id = new_user_whatsit_id
% We return a nullary function that delivers copies of the whatsit.
%
% \begin{macrocode}
---- string -> string -> (unit -> node_t, int)
-local new_user_whatsit = function (name, package)
- local id = new_user_whatsit_id(name, package)
- local whatsit = newnode(whatsit_t, user_defined_t)
- whatsit.user_id = id
- --- unit -> node_t
- local generator = function (proto)
- local res
- if proto then
- local proto_id = proto.user_id
- if proto_id ~= id then --- mismatch
- warning("overriding user_id %d of whatsit prototype (now: %d)",
- proto.user_id, id)
- end
- res = copynode(proto)
- res.user_id = id
- else
- res = copynode(whatsit)
+--- (string | node_t) -> string -> ((unit -> node_t) * int)
+local new_user_whatsit = function (req, package)
+ local id, whatsit
+ if type(req) == "string" then
+ id = new_user_whatsit_id(req, package)
+ whatsit = newnode(whatsit_t, user_defined_t)
+ whatsit.user_id = id
+ else -- node
+ id = req.user_id
+ whatsit = copynode(req)
+ if not whatsit_ids[id] then
+ warning("whatsit id %d unregistered; "
+ .. "inconsistencies may arise", id)
end
- return res
end
- return generator, id
+ return function () return copynode(whatsit) end, id
end
luatexbase.new_user_whatsit = new_user_whatsit
% \end{macrocode}
@@ -632,7 +626,7 @@ local dump_registered_whatsits = function (asked_package)
--- mess up line breaking, so concatenation is unusable ...
local first = true
for i=1, #whatsit_list do
- if first then
+ if first then
first = false
else -- indent
texiowrite_nl" "
@@ -647,7 +641,6 @@ luatexbase.dump_registered_whatsits = dump_registered_whatsits
% \begin{macrocode}
luatexbase.newattribute = new_attribute
luatexbase.newuserwhatsit = new_user_whatsit
-luatexbase.newuserwhatsitfactory = new_user_whatsit_factory
luatexbase.newuserwhatsitid = new_user_whatsit_id
luatexbase.getuserwhatsitid = get_user_whatsit_id
luatexbase.getuserwhatsitname = get_user_whatsit_name