summaryrefslogtreecommitdiff
path: root/macros/luatex/optex/alloc.opm
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/optex/alloc.opm')
-rw-r--r--macros/luatex/optex/alloc.opm71
1 files changed, 56 insertions, 15 deletions
diff --git a/macros/luatex/optex/alloc.opm b/macros/luatex/optex/alloc.opm
index 81d9e6606d..238e824e1a 100644
--- a/macros/luatex/optex/alloc.opm
+++ b/macros/luatex/optex/alloc.opm
@@ -2,6 +2,10 @@
\_codedecl \newdimen {Allocators for registers <2020-01-23>} % loaded in format
+ \_doc -----------------------------
+ The limits are set first.
+ \_cod -----------------------------
+
\_chardef\_maicount = 65535 % Max Allocation Index for counts registers in LuaTeX
\_let\_maidimen = \_maicount
\_let\_maiskip = \_maicount
@@ -12,6 +16,10 @@
\_chardef\_maiwrite = 15
\_chardef\_maifam = 255
+ \_doc -----------------------------
+ Each allocation macro needs its own counter.
+ \_cod -----------------------------
+
\_countdef\_countalloc=10 \_countalloc=255
\_countdef\_dimenalloc=11 \_dimenalloc=255
\_countdef\_skipalloc=12 \_skipalloc=255
@@ -22,6 +30,14 @@
\_countdef\_writealloc=17 \_writealloc=-1
\_countdef\_mathalloc=18 \_mathalloc=3
+ \_doc -----------------------------
+ The common allocation macro
+ \`\_allocator` `\<sequence> {<type>} \<primitive declarator>`
+ is defined. This idea was used in classical plain \TeX/ by
+ Donald Knuth too but the macro from plain \TeX/ seems to be
+ more complicated:).
+ \_cod -----------------------------
+
\_def\_allocator #1#2#3{%
\_global\_advance\_cs{_#2alloc}by1
\_ifnum\_cs{_#2alloc}>\_cs{_mai#2}%
@@ -32,6 +48,13 @@
\fi
}
+ \_doc -----------------------------
+ The allocation macros
+ \`\newcount`, \`\newdimen`, \`\newskip`, \`\newmuskip`, \`\newbox`,
+ \`\newtoks`, \`\newread`, \`\newwrite` and \`\newmath`
+ are defined here.
+ \_cod -----------------------------
+
\_def\_newcount #1{\_allocator #1{count}\_countdef}
\_def\_newdimen #1{\_allocator #1{dimen}\_dimendef}
\_def\_newskip #1{\_allocator #1{skip}\_skipdef}
@@ -42,6 +65,12 @@
\_def\_newwrite #1{\_allocator #1{write}\_chardef}
\_def\_newmath #1{\_allocator #1{fam}\_chardef}
+\_public \newcount \newdimen \newskip \newmuskip \newbox \newtoks \newread \newwrite \newmath ;
+
+ \_doc -----------------------------
+ The \`\newinsert` macro is defined differently than others.
+ \_cod -----------------------------
+
\_newcount\_insertalloc \_insertalloc=255
\_chardef\_insertmin = 201
@@ -54,6 +83,12 @@
\_wlog {\_string#1=\_string\_insert\_the\_insertalloc}%
\_fi
}
+\_public \newinsert ;
+
+ \_doc -----------------------------
+ Other allocation macros \`\newattribute` and \`\newcatodetable`
+ have their counter allocated by the `\newcount` macro.
+ \_cod -----------------------------
\_newcount \_attributealloc \_attributealloc=0
\_chardef\_maiattribute=\_maicount
@@ -63,26 +98,37 @@
\_chardef\_maicatcodetable=32767
\_def\_newcatcodetable #1{\_allocator #1{catcodetable}\_chardef}
+\_public \newattribute \newcatcodetable ;
+
+ \_doc -----------------------------
+ We declare public and private versions of `\tmpnum` and `\tmpdim`
+ registers separately. They are independent registers.
+ \_cod -----------------------------
+
\_newcount \tmpnum \_newcount \_tmpnum
\_newdimen \tmpdim \_newdimen \_tmpdim
+ \_doc -----------------------------
+ A few registers are initialized like in plain\TeX/. Note that `\z@` and `\z@skip` from
+ plain\TeX/ is `\zo` and `\zoskip` because we absolutely
+ don't support the `@` category dance.
+ Note that `\p@` is not defined because we can write 1pt which is more
+ legible.
+ \_cod -----------------------------
+
\_newdimen\_maxdimen \_maxdimen=16383.99999pt % the largest legal <dimen>
\_newskip\_hideskip \_hideskip=-1000pt plus 1fill % negative but can grow
\_newskip\_centering \_centering=0pt plus 1000pt minus 1000pt
\_newskip\_zoskip \_zoskip=0pt plus0pt minus0pt
\_newbox\_voidbox % permanently void box register
-\_public
- \newcount \newdimen \newskip \newmuskip \newbox \newtoks \newread \newwrite \newmath
- \newattribute \newcatcodetable
- \insertmin \newinsert
- \maxdimen \hideskip \centering \zoskip \voidbox ;
+\_public \maxdimen \hideskip \centering \zoskip \voidbox ;
\_endcode %---------------------------------------------------
Like plain\TeX, the allocators `\newcount`, `\newwrite`, etc. are defined.
-The registers are allocated from 256 to `\mai<type>` which is 65535 in
-LuaTeX.
+The registers are allocated from 256 to the `\_mai<type>` which is 65535 in
+\LuaTeX/.
Unlike in Plain\TeX/, the mentioned allocators are not `\outer`.
@@ -95,8 +141,10 @@ is wider.
Inserts are allocated form 254 to 201 using `\newinsert`.
You can define your own allocation concept (for example for allocation of
-arrays) from top of registers array. For example for counts:
+arrays) from top of registers array. The example shows a definition of
+the array-like declarator of counters.
+\nobreak
\begtt
\newcount \_maicount % redefine maximal allocation index as variable
\_maicount = \maicount % first value is top of the array
@@ -114,11 +162,4 @@ arrays) from top of registers array. For example for counts:
}
\endtt
-The `\tmpnum` and `\tmpdim` are allocated, individual instance for internal
-macros and for user's macros.
-
-A few registers are initialized like in plain\TeX/. Note that `\z@` and `\z@skip` from
-plain\TeX/ is `\zo` and `\zoskip` because we don't support the `@` category dance.
-Note that `\p@` is not defined because we can write 1pt which is more
-legible.