summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-05-18 22:21:56 +0000
committerKarl Berry <karl@freefriends.org>2013-05-18 22:21:56 +0000
commit10524dbd61251e90a8ea78a0d3393b7169c49e95 (patch)
tree27f2ea41cc0c83beeaaf75fc2f44d0a87ccf28de
parent2472c585a2dee03ef4665514cb651e5976fd134a (diff)
luatexbase (18may13)
git-svn-id: svn://tug.org/texlive/trunk@30562 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/luatex/luatexbase/NEWS2
-rw-r--r--Master/texmf-dist/doc/luatex/luatexbase/luatexbase-attr.pdfbin470285 -> 473100 bytes
-rw-r--r--Master/texmf-dist/doc/luatex/luatexbase/luatexbase-cctb.pdfbin500530 -> 500530 bytes
-rw-r--r--Master/texmf-dist/doc/luatex/luatexbase/luatexbase-compat.pdfbin497806 -> 497806 bytes
-rw-r--r--Master/texmf-dist/doc/luatex/luatexbase/luatexbase-loader.pdfbin444808 -> 444808 bytes
-rw-r--r--Master/texmf-dist/doc/luatex/luatexbase/luatexbase-mcb.pdfbin514508 -> 514508 bytes
-rw-r--r--Master/texmf-dist/doc/luatex/luatexbase/luatexbase-modutils.pdfbin494422 -> 494422 bytes
-rw-r--r--Master/texmf-dist/doc/luatex/luatexbase/luatexbase-regs.pdfbin487141 -> 487141 bytes
-rw-r--r--Master/texmf-dist/doc/luatex/luatexbase/luatexbase.pdfbin412487 -> 412487 bytes
-rw-r--r--Master/texmf-dist/source/luatex/luatexbase/luatexbase-attr.dtx63
-rw-r--r--Master/texmf-dist/tex/luatex/luatexbase/attr.lua26
11 files changed, 59 insertions, 32 deletions
diff --git a/Master/texmf-dist/doc/luatex/luatexbase/NEWS b/Master/texmf-dist/doc/luatex/luatexbase/NEWS
index 9ad27e2a48d..311ed94f9dd 100644
--- a/Master/texmf-dist/doc/luatex/luatexbase/NEWS
+++ b/Master/texmf-dist/doc/luatex/luatexbase/NEWS
@@ -7,7 +7,7 @@
attr
- hack to make luatexbase and luatex.sty compatible for attribute
allocation (same thing should be done for catcodetables)
- - adding whatsit nodes allocation functions (see doc)
+ - adding user-defined whatsit node allocation functions (see doc)
modutils
- adding functions to check the availability and version of a module
- fixing small error in module date requirement
diff --git a/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-attr.pdf b/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-attr.pdf
index 1883b03930d..1652ce46df6 100644
--- a/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-attr.pdf
+++ b/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-attr.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-cctb.pdf b/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-cctb.pdf
index 741ecce1fd9..580675eaa7a 100644
--- a/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-cctb.pdf
+++ b/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-cctb.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-compat.pdf b/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-compat.pdf
index 57b8993f5e2..ed69d0ad92a 100644
--- a/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-compat.pdf
+++ b/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-compat.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-loader.pdf b/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-loader.pdf
index a7bbcdf0186..e1a32480b42 100644
--- a/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-loader.pdf
+++ b/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-loader.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-mcb.pdf b/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-mcb.pdf
index 9c7d5dac724..2013298330f 100644
--- a/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-mcb.pdf
+++ b/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-mcb.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-modutils.pdf b/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-modutils.pdf
index 580ac47d926..70f80dd3ec4 100644
--- a/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-modutils.pdf
+++ b/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-modutils.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-regs.pdf b/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-regs.pdf
index 6fa084f9abe..95ed519e71d 100644
--- a/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-regs.pdf
+++ b/Master/texmf-dist/doc/luatex/luatexbase/luatexbase-regs.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/luatex/luatexbase/luatexbase.pdf b/Master/texmf-dist/doc/luatex/luatexbase/luatexbase.pdf
index d7e6452bb5e..5393aecd59e 100644
--- a/Master/texmf-dist/doc/luatex/luatexbase/luatexbase.pdf
+++ b/Master/texmf-dist/doc/luatex/luatexbase/luatexbase.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/luatex/luatexbase/luatexbase-attr.dtx b/Master/texmf-dist/source/luatex/luatexbase/luatexbase-attr.dtx
index d19240b4b67..5b7288fc098 100644
--- a/Master/texmf-dist/source/luatex/luatexbase/luatexbase-attr.dtx
+++ b/Master/texmf-dist/source/luatex/luatexbase/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}
@@ -434,6 +434,8 @@ luatexbase.new_attribute = new_attribute
% \end{macrocode}
%
% Unset an attribute the correct way depending on \luatex's version.
+% The constant \verb+unset_value+ can be retrieved by calling
+% \verb+get_unset_value()+ to apply to nodes.
%
% \begin{macrocode}
local unset_value = (luatexbase.luatexversion < 37) and -1 or -2147483647
@@ -441,9 +443,14 @@ function unset_attribute(name)
tex.setattribute(attributes[name], unset_value)
end
luatexbase.unset_attribute = unset_attribute
+luatexbase.get_unset_value = function () return unset_value end
% \end{macrocode}
%
-% User whatsit allocation (experimental).
+% Allocation of user-defined whatsit nodes (experimental).
+% User-defined whatsit nodes (or user whatsits) are ignored by the
+% \luatex engine. They can thus be used to store information in
+% node lists without doing any harm. User whatsits can be
+% distinguished by an id that is stored in node field |user_id|.
%
% \begin{macrocode}
--- cf. luatexref-t.pdf, sect. 8.1.4.25
@@ -457,18 +464,18 @@ local anonymous_whatsits = 0
local anonymous_prefix = "anon"
% \end{macrocode}
%
-% The whatsit allocation is split into two functions:
+% User whatsit allocation is split into two functions:
% \verb|new_user_whatsit_id| registers a new id (an integer)
% and returns it. It is up to the user what he actually does
% with the return value.
%
-% Registering whatsits without a name, though supported, is
+% Registering user whatsits without a name, though supported, is
% not exactly good style. In these cases we generate a name
% from a counter.
%
-% In addition to the whatsit name, it is possible and even
+% In addition to the user whatsit name, it is possible and even
% encouraged to specify the name of the package that will be
-% using the whatsit as the second argument.
+% using the user whatsit as the second argument.
%
% \begin{macrocode}
--- string -> string -> int
@@ -512,23 +519,36 @@ luatexbase.new_user_whatsit_id = new_user_whatsit_id
% \end{macrocode}
%
% \verb|new_user_whatsit| first registers a new id and then also
-% creates the corresponding whatsit of subtype “user defined”.
+% creates the corresponding whatsit node of subtype “user-defined”.
% We return a nullary function that delivers copies of the whatsit.
%
+% Alternatively, the first argument can be a whatsit node that
+% will then be used as prototype. Note that in this case a
+% \emph{copy} of the prototype will be stored in the closure,
+% eliminating side-effects.
+%
% \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
- return function ( ) return copynode(whatsit) end, id
+--- (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
+ elseif req.id == whatsit_t and req.subtype == user_defined_t then
+ id = req.user_id
+ whatsit = copynode(req)
+ if not whatsit_ids[id] then
+ warning("whatsit id %d unregistered; "
+ .. "inconsistencies may arise", id)
+ end
+ end
+ return function () return copynode(whatsit) end, id
end
luatexbase.new_user_whatsit = new_user_whatsit
-luatexbase.new_user_whatsit_factory = new_user_whatsit --- for Stephan
% \end{macrocode}
%
-% If one knows the name of a whatsit, its corresponding id
+% If one knows the name of a user whatsit, its corresponding id
% can be retrieved by means of \verb|get_user_whatsit_id|.
%
% \begin{macrocode}
@@ -545,11 +565,11 @@ luatexbase.get_user_whatsit_id = get_user_whatsit_id
% The inverse lookup is also possible via \verb|get_user_whatsit_name|.
% Here it finally becomes obvious why it is beneficial to supply a package
% name -- it adds information about who created and might be relying on the
-% whatsit in question. First return value is the whatsit name, the second
-% the package identifier it was registered with.
+% user whatsit in question. First return value is the user whatsit name, the
+% second the package identifier it was registered with.
%
-% We issue a warning and return empty strings in case the asked whatsit is
-% unregistered.
+% We issue a warning and return empty strings in case the argument
+% doesn't correspond to a registered user whatsit id.
%
% \begin{macrocode}
--- int | fun | node -> (string, string)
@@ -611,7 +631,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" "
@@ -626,7 +646,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
diff --git a/Master/texmf-dist/tex/luatex/luatexbase/attr.lua b/Master/texmf-dist/tex/luatex/luatexbase/attr.lua
index d089c8b0865..e86bbdedfda 100644
--- a/Master/texmf-dist/tex/luatex/luatexbase/attr.lua
+++ b/Master/texmf-dist/tex/luatex/luatexbase/attr.lua
@@ -77,6 +77,7 @@ function unset_attribute(name)
tex.setattribute(attributes[name], unset_value)
end
luatexbase.unset_attribute = unset_attribute
+luatexbase.get_unset_value = function () return unset_value end
--- cf. luatexref-t.pdf, sect. 8.1.4.25
local user_whatsits = { --- (package, (name, id hash)) hash
__unassociated = { }, --- those without package name
@@ -124,16 +125,24 @@ local new_user_whatsit_id = function (name, package)
return id
end
luatexbase.new_user_whatsit_id = new_user_whatsit_id
---- 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
- return function ( ) return copynode(whatsit) end, id
+--- (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
+ elseif req.id == whatsit_t and req.subtype == user_defined_t then
+ id = req.user_id
+ whatsit = copynode(req)
+ if not whatsit_ids[id] then
+ warning("whatsit id %d unregistered; "
+ .. "inconsistencies may arise", id)
+ end
+ end
+ return function () return copynode(whatsit) end, id
end
luatexbase.new_user_whatsit = new_user_whatsit
-luatexbase.new_user_whatsit_factory = new_user_whatsit --- for Stephan
--- string -> string -> int
local get_user_whatsit_id = function (name, package)
if not package then
@@ -206,7 +215,6 @@ end
luatexbase.dump_registered_whatsits = dump_registered_whatsits
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