diff options
author | Philipp Gesang <phg42.2a@gmail.com> | 2013-04-30 12:06:26 +0200 |
---|---|---|
committer | Philipp Gesang <phg42.2a@gmail.com> | 2013-04-30 12:06:26 +0200 |
commit | ec9027b5a79546bf9babb7d97b778551cd25b29e (patch) | |
tree | f2d1d57a0f5e0cac8c8f9fdea3ba12a6b6805f90 /luatexbase-attr.dtx | |
parent | 846cbb8f66e71a1a441dab2ba0d9ab44a5883368 (diff) | |
parent | 167c1b6ba8310c4adc0275fab52e746711aadab5 (diff) | |
download | luatexbase-ec9027b5a79546bf9babb7d97b778551cd25b29e.tar.gz |
merge eroux/master
Diffstat (limited to 'luatexbase-attr.dtx')
-rw-r--r-- | luatexbase-attr.dtx | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/luatexbase-attr.dtx b/luatexbase-attr.dtx index a3b2e46..ded08b3 100644 --- a/luatexbase-attr.dtx +++ b/luatexbase-attr.dtx @@ -145,7 +145,7 @@ See the aforementioned source file(s) for copyright and licensing information. % number of the attribute associated to |\fooattr| assuming it was defined % using |\newluatexattribute\fooattr|, something that \luatex currently % doesn't support (you can get the current value of the associated attribute -% as |tex.atrribute.fooattr|, but not the attribute number). +% as |tex.attribute.fooattr|, but not the attribute number). % % There are several ways to work around this. For example, it is possible to % extract the number at any time from the |\meaning| of |\fooattr|. @@ -158,7 +158,7 @@ See the aforementioned source file(s) for copyright and licensing information. % % Also, two Lua functions are provided that are analogous to the above \tex % macros (actually, the macros are wrappers around the functions): -% |luatexbase.new_attributes|\parg{name} allocates a new attribute, without +% |luatexbase.new_attribute|\parg{name} allocates a new attribute, without % defining a corresponding \tex control sequence (only an entry in % |luatexbase.attributes| is created. It usually returns the number of the % allocated attribute. If room is missing, it raises an error, unless the @@ -283,14 +283,16 @@ See the aforementioned source file(s) for copyright and licensing information. % \subsubsection{Load supporting Lua module} % % First load \pk{luatexbase-loader} (hence \pk{luatexbase-compat}), then -% the supporting Lua module. +% the supporting Lua module. We make sure luatex.sty is loaded. % % \begin{macrocode} \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname RequirePackage\endcsname\relax \input luatexbase-loader.sty + \input luatex.sty \else \RequirePackage{luatexbase-loader} + \RequirePackage{luatex} \fi \luatexbase@directlua{require('luatexbase.attr')} % \end{macrocode} @@ -351,14 +353,34 @@ module('luatexbase', package.seeall) attributes = {} % \end{macrocode} % -% The allocation function. Unlike other registers, allocate starting from 255. -% Some code (e.g., font handling coming from Con\tex{}t) behaves strangely -% with \verb+\attribute0+. What is more the font loader allocates its own -% attributes in the range from 127 to 254. Since there is plenty of room -% here, it doesn't seem bad to skep a few items in order to avoid clashes. +% There are currently two functions that create a new attribute.One is in +% |oberdiek| bundle, the other is this one. We will hack a little in order +% to make them compatible. The other function uses |LuT@AllocAttribute| as +% attribute counter, we will keep it in sync with ours. A possible problem +% might also appear: the other function starts attribute allocation at 0, +% which might break luaotfload. We output an error if a new attribute has +% already been allocated with number 0. % % \begin{macrocode} -local last_alloc = 255 +local luatex_sty_counter = 'LuT@AllocAttribute' +if tex.count[luatex_sty_counter] then + if tex.count[luatex_sty_counter] > -1 then + error("luatexbase error: attribute 0 has already been set by \newattribute" + .."macro from luatex.sty, not belonging to this package, this makes" + .."luaotfload unuseable. Please report to the maintainer of luatex.sty") + else + tex.count[luatex_sty_counter] = 0 + end +end +% \end{macrocode} +% +% The allocaton function. Unlike other registers, allocate starting from 1. +% Some code (eg, font handling coming from Con\tex{}t) behaves strangely +% with \verb+\attribute0+ and since there is plenty of room here, it +% doesn't seem bad to ``loose'' one item in order to avoid this problem. +% +% \begin{macrocode} +local last_alloc = 0 function new_attribute(name, silent) if last_alloc >= 65535 then if silent then @@ -367,7 +389,14 @@ function new_attribute(name, silent) error("No room for a new \\attribute", 1) end end + local lsc = tex.count[luatex_sty_counter] + if lsc and lsc > last_alloc then + last_alloc = lsc + end last_alloc = last_alloc + 1 + if lsc then + tex.setcount('global', luatex_sty_counter, last_alloc) + end attributes[name] = last_alloc unset_attribute(name) if not silent then |