[latex3-commits] [git/LaTeX3-latex3-latex3] coffins: Track scope when creating coffins (d56cbb7)
Joseph Wright
joseph.wright at morningstar2.co.uk
Sun Jan 20 21:50:51 CET 2019
Repository : https://github.com/latex3/latex3
On branch : coffins
Link : https://github.com/latex3/latex3/commit/d56cbb7996b4adf78452724f6dc666421040af68
>---------------------------------------------------------------
commit d56cbb7996b4adf78452724f6dc666421040af68
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Fri Jan 18 12:32:38 2019 +0000
Track scope when creating coffins
First stage of allowing global coffins
>---------------------------------------------------------------
d56cbb7996b4adf78452724f6dc666421040af68
l3kernel/l3coffins.dtx | 34 ++++++++++++++++++++++++++++---
l3kernel/testfiles/m3expl001.luatex.tlg | 2 ++
l3kernel/testfiles/m3expl001.ptex.tlg | 2 ++
l3kernel/testfiles/m3expl001.tlg | 2 ++
l3kernel/testfiles/m3expl001.uptex.tlg | 2 ++
l3kernel/testfiles/m3expl001.xetex.tlg | 2 ++
l3kernel/testfiles/m3expl003.luatex.tlg | 2 ++
l3kernel/testfiles/m3expl003.ptex.tlg | 2 ++
l3kernel/testfiles/m3expl003.tlg | 2 ++
l3kernel/testfiles/m3expl003.uptex.tlg | 2 ++
l3kernel/testfiles/m3expl003.xetex.tlg | 2 ++
11 files changed, 51 insertions(+), 3 deletions(-)
diff --git a/l3kernel/l3coffins.dtx b/l3kernel/l3coffins.dtx
index a0b9908..bfd08af 100644
--- a/l3kernel/l3coffins.dtx
+++ b/l3kernel/l3coffins.dtx
@@ -463,14 +463,14 @@
% \begin{macro}[EXP, pTF]{\coffin_if_exist:N, \coffin_if_exist:c}
% Several of the higher-level coffin functions would give multiple
% errors if the coffin does not exist. A cleaner way to handle this
-% is provided here: both the box and the coffin structure are
-% checked.
+% is provided here: the box and scope must exist. (The handle property
+% list may not be present for a new coffin.)
% \begin{macrocode}
\prg_new_conditional:Npnn \coffin_if_exist:N #1 { p , T , F , TF }
{
\cs_if_exist:NTF #1
{
- \cs_if_exist:cTF { l_@@_poles_ \@@_to_value:N #1 _prop }
+ \cs_if_exist:cTF { g_@@_scope_ \@@_to_value:N #1 _tl }
{ \prg_return_true: }
{ \prg_return_false: }
}
@@ -498,6 +498,30 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\@@_check_scope:NN}
+% A simple check to ensure that coffins are used correctly. If the scope
+% is not yet set, it is determined at this stage.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_check_scope:NN #1#2
+ {
+ \@@_if_exist:NT #1
+ {
+ \tl_if_empty:cTF { g_@@_scope_ \@@_to_value:N #1 _tl }
+ { \tl_gset:cn { g_@@_scope_ \@@_to_value:N #1 _tl } {#2} }
+ {
+ \str_if_eq:eeF
+ { \tl_use:c { g_@@_scope_ \@@_to_value:N #1 _tl } } {#2}
+ {
+ \__kernel_msg_error:nnx { kernel } { wrong-coffin-scope }
+ { \token_to_str:N #1 }
+ \tl_gset:cn { g_@@_scope_ \@@_to_value:N #1 _tl } {#2}
+ }
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\coffin_clear:N, \coffin_clear:c}
% Clearing coffins means emptying the box and resetting all of the
% structures.
@@ -528,6 +552,7 @@
{
\box_new:N #1
\debug_suspend:
+ \tl_new:c { g_@@_scope_ \@@_to_value:N #1 _tl }
\prop_clear_new:c { l_@@_corners_ \@@_to_value:N #1 _prop }
\prop_clear_new:c { l_@@_poles_ \@@_to_value:N #1 _prop }
\prop_gset_eq:cN { l_@@_corners_ \@@_to_value:N #1 _prop }
@@ -1762,6 +1787,9 @@
Size~of~coffin~#1 : #2 \\
Poles~of~coffin~#1 : #3 .
}
+\__kernel_msg_new:nnnn { kernel } { wrong-coffin-scope }
+ { Incorrect~coffin~scope~usage~with~'#1'. }
+ { The~coffin~'#1'~is~being~set~in~the~wrong~scope. }
% \end{macrocode}
%
% \begin{macrocode}
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index ed45e0c..00e99c0 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -5299,6 +5299,7 @@ Defining \coffin_if_exist:cT on line ...
Defining \coffin_if_exist:cF on line ...
Defining \coffin_if_exist:cTF on line ...
Defining \__coffin_if_exist:NT on line ...
+Defining \__coffin_check_scope:NN on line ...
Defining \coffin_clear:N on line ...
Defining \coffin_clear:c on line ...
Defining \coffin_new:N on line ...
@@ -5403,6 +5404,7 @@ Defining message LaTeX/kernel/no-pole-intersection on line ...
Defining message LaTeX/kernel/unknown-coffin on line ...
Defining message LaTeX/kernel/unknown-coffin-pole on line ...
Defining message LaTeX/kernel/show-coffin on line ...
+Defining message LaTeX/kernel/wrong-coffin-scope on line ...
Defining \__lua_escape:n on line ...
Defining \__lua_now:n on line ...
Defining \__lua_shipout:n on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index d6d0883..afae9db 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -5595,6 +5595,7 @@ Defining \coffin_if_exist:cT on line ...
Defining \coffin_if_exist:cF on line ...
Defining \coffin_if_exist:cTF on line ...
Defining \__coffin_if_exist:NT on line ...
+Defining \__coffin_check_scope:NN on line ...
Defining \coffin_clear:N on line ...
Defining \coffin_clear:c on line ...
Defining \coffin_new:N on line ...
@@ -5699,6 +5700,7 @@ Defining message LaTeX/kernel/no-pole-intersection on line ...
Defining message LaTeX/kernel/unknown-coffin on line ...
Defining message LaTeX/kernel/unknown-coffin-pole on line ...
Defining message LaTeX/kernel/show-coffin on line ...
+Defining message LaTeX/kernel/wrong-coffin-scope on line ...
Defining \__lua_escape:n on line ...
Defining \__lua_now:n on line ...
Defining \__lua_shipout:n on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index d84605b..3764f74 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -5595,6 +5595,7 @@ Defining \coffin_if_exist:cT on line ...
Defining \coffin_if_exist:cF on line ...
Defining \coffin_if_exist:cTF on line ...
Defining \__coffin_if_exist:NT on line ...
+Defining \__coffin_check_scope:NN on line ...
Defining \coffin_clear:N on line ...
Defining \coffin_clear:c on line ...
Defining \coffin_new:N on line ...
@@ -5699,6 +5700,7 @@ Defining message LaTeX/kernel/no-pole-intersection on line ...
Defining message LaTeX/kernel/unknown-coffin on line ...
Defining message LaTeX/kernel/unknown-coffin-pole on line ...
Defining message LaTeX/kernel/show-coffin on line ...
+Defining message LaTeX/kernel/wrong-coffin-scope on line ...
Defining \__lua_escape:n on line ...
Defining \__lua_now:n on line ...
Defining \__lua_shipout:n on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index 8de076d..4140187 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -5592,6 +5592,7 @@ Defining \coffin_if_exist:cT on line ...
Defining \coffin_if_exist:cF on line ...
Defining \coffin_if_exist:cTF on line ...
Defining \__coffin_if_exist:NT on line ...
+Defining \__coffin_check_scope:NN on line ...
Defining \coffin_clear:N on line ...
Defining \coffin_clear:c on line ...
Defining \coffin_new:N on line ...
@@ -5696,6 +5697,7 @@ Defining message LaTeX/kernel/no-pole-intersection on line ...
Defining message LaTeX/kernel/unknown-coffin on line ...
Defining message LaTeX/kernel/unknown-coffin-pole on line ...
Defining message LaTeX/kernel/show-coffin on line ...
+Defining message LaTeX/kernel/wrong-coffin-scope on line ...
Defining \__lua_escape:n on line ...
Defining \__lua_now:n on line ...
Defining \__lua_shipout:n on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index 88b2e23..18f07f8 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -5310,6 +5310,7 @@ Defining \coffin_if_exist:cT on line ...
Defining \coffin_if_exist:cF on line ...
Defining \coffin_if_exist:cTF on line ...
Defining \__coffin_if_exist:NT on line ...
+Defining \__coffin_check_scope:NN on line ...
Defining \coffin_clear:N on line ...
Defining \coffin_clear:c on line ...
Defining \coffin_new:N on line ...
@@ -5414,6 +5415,7 @@ Defining message LaTeX/kernel/no-pole-intersection on line ...
Defining message LaTeX/kernel/unknown-coffin on line ...
Defining message LaTeX/kernel/unknown-coffin-pole on line ...
Defining message LaTeX/kernel/show-coffin on line ...
+Defining message LaTeX/kernel/wrong-coffin-scope on line ...
Defining \__lua_escape:n on line ...
Defining \__lua_now:n on line ...
Defining \__lua_shipout:n on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index ed45e0c..00e99c0 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -5299,6 +5299,7 @@ Defining \coffin_if_exist:cT on line ...
Defining \coffin_if_exist:cF on line ...
Defining \coffin_if_exist:cTF on line ...
Defining \__coffin_if_exist:NT on line ...
+Defining \__coffin_check_scope:NN on line ...
Defining \coffin_clear:N on line ...
Defining \coffin_clear:c on line ...
Defining \coffin_new:N on line ...
@@ -5403,6 +5404,7 @@ Defining message LaTeX/kernel/no-pole-intersection on line ...
Defining message LaTeX/kernel/unknown-coffin on line ...
Defining message LaTeX/kernel/unknown-coffin-pole on line ...
Defining message LaTeX/kernel/show-coffin on line ...
+Defining message LaTeX/kernel/wrong-coffin-scope on line ...
Defining \__lua_escape:n on line ...
Defining \__lua_now:n on line ...
Defining \__lua_shipout:n on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index d6d0883..afae9db 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -5595,6 +5595,7 @@ Defining \coffin_if_exist:cT on line ...
Defining \coffin_if_exist:cF on line ...
Defining \coffin_if_exist:cTF on line ...
Defining \__coffin_if_exist:NT on line ...
+Defining \__coffin_check_scope:NN on line ...
Defining \coffin_clear:N on line ...
Defining \coffin_clear:c on line ...
Defining \coffin_new:N on line ...
@@ -5699,6 +5700,7 @@ Defining message LaTeX/kernel/no-pole-intersection on line ...
Defining message LaTeX/kernel/unknown-coffin on line ...
Defining message LaTeX/kernel/unknown-coffin-pole on line ...
Defining message LaTeX/kernel/show-coffin on line ...
+Defining message LaTeX/kernel/wrong-coffin-scope on line ...
Defining \__lua_escape:n on line ...
Defining \__lua_now:n on line ...
Defining \__lua_shipout:n on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index d84605b..3764f74 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -5595,6 +5595,7 @@ Defining \coffin_if_exist:cT on line ...
Defining \coffin_if_exist:cF on line ...
Defining \coffin_if_exist:cTF on line ...
Defining \__coffin_if_exist:NT on line ...
+Defining \__coffin_check_scope:NN on line ...
Defining \coffin_clear:N on line ...
Defining \coffin_clear:c on line ...
Defining \coffin_new:N on line ...
@@ -5699,6 +5700,7 @@ Defining message LaTeX/kernel/no-pole-intersection on line ...
Defining message LaTeX/kernel/unknown-coffin on line ...
Defining message LaTeX/kernel/unknown-coffin-pole on line ...
Defining message LaTeX/kernel/show-coffin on line ...
+Defining message LaTeX/kernel/wrong-coffin-scope on line ...
Defining \__lua_escape:n on line ...
Defining \__lua_now:n on line ...
Defining \__lua_shipout:n on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 8de076d..4140187 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -5592,6 +5592,7 @@ Defining \coffin_if_exist:cT on line ...
Defining \coffin_if_exist:cF on line ...
Defining \coffin_if_exist:cTF on line ...
Defining \__coffin_if_exist:NT on line ...
+Defining \__coffin_check_scope:NN on line ...
Defining \coffin_clear:N on line ...
Defining \coffin_clear:c on line ...
Defining \coffin_new:N on line ...
@@ -5696,6 +5697,7 @@ Defining message LaTeX/kernel/no-pole-intersection on line ...
Defining message LaTeX/kernel/unknown-coffin on line ...
Defining message LaTeX/kernel/unknown-coffin-pole on line ...
Defining message LaTeX/kernel/show-coffin on line ...
+Defining message LaTeX/kernel/wrong-coffin-scope on line ...
Defining \__lua_escape:n on line ...
Defining \__lua_now:n on line ...
Defining \__lua_shipout:n on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index 88b2e23..18f07f8 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -5310,6 +5310,7 @@ Defining \coffin_if_exist:cT on line ...
Defining \coffin_if_exist:cF on line ...
Defining \coffin_if_exist:cTF on line ...
Defining \__coffin_if_exist:NT on line ...
+Defining \__coffin_check_scope:NN on line ...
Defining \coffin_clear:N on line ...
Defining \coffin_clear:c on line ...
Defining \coffin_new:N on line ...
@@ -5414,6 +5415,7 @@ Defining message LaTeX/kernel/no-pole-intersection on line ...
Defining message LaTeX/kernel/unknown-coffin on line ...
Defining message LaTeX/kernel/unknown-coffin-pole on line ...
Defining message LaTeX/kernel/show-coffin on line ...
+Defining message LaTeX/kernel/wrong-coffin-scope on line ...
Defining \__lua_escape:n on line ...
Defining \__lua_now:n on line ...
Defining \__lua_shipout:n on line ...
More information about the latex3-commits
mailing list