summaryrefslogtreecommitdiff
path: root/luatexbase-attr.dtx
diff options
context:
space:
mode:
authorManuel Pégourié-Gonnard <mpg@elzevir.fr>2010-03-11 15:53:06 +0100
committerManuel Pégourié-Gonnard <mpg@elzevir.fr>2010-03-11 16:13:54 +0100
commit6fd9e351fad8a6d4df2d2841a29da7fa99806463 (patch)
tree3ae70d1f2dbeeb78032dc156c3457f8be9c3258b /luatexbase-attr.dtx
parent3fbad52bf5c3a8e0d20ed01f784b048afdd34332 (diff)
downloadluatexbase-6fd9e351fad8a6d4df2d2841a29da7fa99806463.tar.gz
Start working on attr.
Diffstat (limited to 'luatexbase-attr.dtx')
-rw-r--r--luatexbase-attr.dtx50
1 files changed, 24 insertions, 26 deletions
diff --git a/luatexbase-attr.dtx b/luatexbase-attr.dtx
index fe68a3b..8f68efc 100644
--- a/luatexbase-attr.dtx
+++ b/luatexbase-attr.dtx
@@ -144,23 +144,22 @@ and the derived files
% the other |\new*| macros, to $65536$ attributes can be allocated.
%
% \begin{macrocode}
-\newcount\luatexattdefcounter
-\luatexattdefcounter = 1
+\newcount\lltxb@attribute@alloc
+\lltxb@attribute@alloc\m@ne
\def\newluatexattribute#1{%
- \ifnum\luatexattdefcounter<65535\relax %
- \global\advance\luatexattdefcounter by 1\relax %
- \allocationnumber\luatexattdefcounter %
- \ifluatex %
- \global\luatexattributedef#1=\allocationnumber %
- \fi %
+ \ifnum\lltxb@attribute@alloc<65535\relax
+ \global\advance\lltxb@attribute@alloc\@ne
+ \allocationnumber\lltxb@attribute@alloc
+ \ifluatex
+ \global\luatexattributedef#1=\allocationnumber
+ \fi
\wlog{\string#1=\string\luatexattribute\the\allocationnumber}%
- \luadirect{%
- luatextra.attributedef_from_tex([[\noexpand#1]],
- '\number\allocationnumber')}%
- \else %
+ \begingroup\escapechar\m@ne \expandafter\endgroup
+ \directlua{luatextra.attributedef_from_tex(
+ '\luatexluaescapestring{\string#1}', '\number\allocationnumber')}%
+ \else
\errmessage{No room for a new \string\attribute}%
- \fi %
-}
+ \fi}
% \end{macrocode}
%
% Two convenient macros, one to set an attribute (basically just a
@@ -170,15 +169,14 @@ and the derived files
%
% \begin{macrocode}
\def\setluatexattribute#1#2{%
- #1=\numexpr#2\relax %
+ #1=\numexpr#2\relax
}
\def\unsetluatexattribute#1{%
- \ifnum\luatexversion<37\relax %
- #1=-1\relax %
- \else %
- #1=-"7FFFFFFF\relax %
- \fi %
-}
+ \ifnum\luatexversion<37\relax
+ #1=-1\relax
+ \else
+ #1=-"7FFFFFFF\relax
+ \fi}
% \end{macrocode}
%
% \begin{macrocode}
@@ -208,11 +206,11 @@ and the derived files
% can simply call |tex.attributenumber[myattribute]|.
%
% \begin{macrocode}
-luatextra.attributes = {}
-tex.attributenumber = luatextra.attributes
-function luatextra.attributedef_from_tex(name, number)
- truename = name:gsub('[\\ ]', '')
- luatextra.attributes[truename] = tonumber(number)
+module('luatextra', package.seeall)
+attributes = {}
+tex.attributenumber = attributes
+function attributedef_from_tex(name, number)
+ attributes[name] = tonumber(number)
end
% \end{macrocode}
%