[latex3-commits] [l3svn] branch master updated: MAke l3color-extra loadable

noreply at latex-project.org noreply at latex-project.org
Wed Oct 11 08:28:34 CEST 2017


This is an automated email from the git hooks/post-receive script.

joseph pushed a commit to branch master
in repository l3svn.

The following commit(s) were added to refs/heads/master by this push:
       new  7768ff7   MAke l3color-extra loadable
7768ff7 is described below

commit 7768ff77fa4c39583af8003c9a17b1fbe09ef780
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Wed Oct 11 07:26:47 2017 +0100

    MAke l3color-extra loadable
    
    Various internal changes to make the code clearer, including ensuring that
    the 'return' value of parsing is not stored as \l__color_current_tl where
    that is not appropriate.
    
    This now can create colours directly (hence loading), though the parser is
    untested.
    
    One obvious question at this stage is whether in package mode data should
    be exchanged with (x)color.
---
 l3trial/l3color-extra/l3color-extra.dtx            |  130 ++++++++++++--------
 .../l3color-extra/testfiles/m3color-extra001.lvt   |   18 +++
 .../l3color-extra/testfiles/m3color-extra001.tlg   |    3 +
 3 files changed, 103 insertions(+), 48 deletions(-)

diff --git a/l3trial/l3color-extra/l3color-extra.dtx b/l3trial/l3color-extra/l3color-extra.dtx
index 87bd53a..7d1c805 100644
--- a/l3trial/l3color-extra/l3color-extra.dtx
+++ b/l3trial/l3color-extra/l3color-extra.dtx
@@ -261,10 +261,10 @@
 %    \end{macrocode}
 % \end{variable}
 %
-% \begin{macro}[int]{\@@_parse:nn}
-% \begin{macro}[aux]{\@@_parse:n}
-% \begin{macro}[aux]{\@@_parse:w}
-% \begin{macro}[aux]{\@@_parse_loop_init:nn}
+% \begin{macro}[int]{\@@_parse:nN}
+% \begin{macro}[aux]{\@@_parse_aux:nN, \@@_parse_aux:VN}
+% \begin{macro}[aux]{\@@_parse:Nw}
+% \begin{macro}[aux]{\@@_parse_loop_init:Nnn}
 % \begin{macro}[aux]{\@@_parse_loop:w}
 % \begin{macro}[aux]{\@@_parse_loop:nn}
 % \begin{macro}[aux]{\@@_parse_break:w}
@@ -281,7 +281,7 @@
 %   otherwise expands, then starts working through the expression itself.
 %   At the end, we apply the payload.
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_parse:nn #1#2
+\cs_new_protected:Npn \@@_parse:nN #1#2
   {
     \group_begin:
       \seq_map_inline:Nn \l_char_active_seq
@@ -289,32 +289,31 @@
           \tl_set:Nx \l_@@_tmp_tl { \cs_to_str:N ##1 }
           \char_set_active_eq:NN ##1 \l_@@_tmp_tl
         }
-      \tl_set:Nx \l_@@_tmp_tl {#2}
+      \tl_set:Nx \l_@@_tmp_tl {#1}
     \exp_args:NNV \group_end:
-    \@@_parse:V \l_@@_tmp_tl
-    #1
+    \@@_parse_aux:VN \l_@@_tmp_tl #2
   }
 %    \end{macrocode}
 %   Before going to all of the effort of parsing an expression, these two
 %   precursor functions look for a pre-defined name, either on its own or
 %   with a trailing |!| (which is the same thing).
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_parse:n #1
+\cs_new_protected:Npn \@@_parse:nN #1#2
   {
     \tl_if_exist:cTF { l_@@_named_ #1 _tl }
-      { \tl_set_eq:Nc \l__color_current_tl { l_@@_named_ #1 _tl } }
-      { \@@_parse:w #1 ! \q_stop }
+      { \tl_set_eq:Nc #2 { l_@@_named_ #1 _tl } }
+      { \@@_parse:Nw #2#1 ! \q_stop }
   }
-\cs_new_protected:Npn \@@_parse:w #1 ! #2 \q_stop
+\cs_new_protected:Npn \@@_parse:Nw #1#2 ! #3 \q_stop
   {
-    \@@_if_defined:nTF {#1}
+    \@@_if_defined:nTF {#2}
       {
-        \tl_if_blank:nTF {#2}
-          { \tl_set_eq:Nc \l__color_current_tl { l_@@_named_ #1 _tl } }
-          { \@@_parse_loop_init:nn {#1} {#2} }
+        \tl_if_blank:nTF {#3}
+          { \tl_set_eq:Nc #1 { l_@@_named_ #2 _tl } }
+          { \@@_parse_loop_init:Nnn #1 {#2} {#3} }
       }
       {
-        \msg_kernel_error:nnn { color } { unknown-color } {#2}
+        \msg_kernel_error:nnn { color } { unknown-color } {#3}
         \tl_set_eq:NN \l__color_current_tl \l_@@_named_black_tl
       }
   }
@@ -323,15 +322,15 @@
 %   detail of the first color. That will determine the model we use for the
 %   calculation: splitting here makes checking that a bit easier.
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_parse_loop_init:nn #1#2
+\cs_new_protected:Npn \@@_parse_loop_init:Nnn #1#2#3
   {
     \group_begin:
-      \@@_extract:nNN {#1} \l_@@_model_tl \l_@@_value_tl
-      \@@_parse_loop:w #2 ! ! ! ! \q_stop
+      \@@_extract:nNN {#2} \l_@@_model_tl \l_@@_value_tl
+      \@@_parse_loop:w #3 ! ! ! ! \q_stop
       \tl_set:Nx \l_@@_tmp_tl
         { \l_@@_model_tl \c_space_tl \l_@@_value_tl }
     \exp_args:NNNV \group_end:
-    \tl_set:Nn \l__color_current_tl \l_@@_tmp_tl
+    \tl_set:Nn #1 \l_@@_tmp_tl
   }
 %    \end{macrocode}
 %   This is the loop proper: there can be an open-ended set of colors to parse,
@@ -480,20 +479,64 @@
 % \end{macro}
 % \end{macro}
 %
+% \subsection{Selecting colors}
+%
+% \begin{macro}{\color_select:n}
+% \begin{macro}{\color_select:nn}
+%   Parse the input expressions then get the driver to actually activate
+%   them.
+%    \begin{macrocode}
+\cs_new_protected:Npn \color_select:n {#1}
+  {
+    \@@_parse:nN {#1} \l_@@_current_tl
+    \__driver_color_select: 
+  }
+\cs_new_protected:Npn \color_select:nn #1#2
+  {
+    \@@_direct:nnN {#1} {#2} \l_@@_current_tl
+    \__driver_color_select:
+  }
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
 % \subsection{Direct model use}
 %
-% \begin{macro}{\@@_use:nnn}
+% \begin{macro}{\@@_direct:nnN}
+%   Directly set a color based on a model/value combination.
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_use:nnn #1#2#3
+\cs_new_protected:Npn \@@_direct:nnN #1#2#3
   {
-    \cs_if_exist:cTF { @@_parse_ #2 :w }
+    \cs_if_exist:cTF { @@_parse_ #1 :w }
       {
-        \tl_set:Nx \l__color_current_tl
-          { #2 ~ \use:c {  @@_parse_ #2 :w } #3 , 0 , 0 , 0 , 0 \q_stop }
-        #1
+        \tl_set:Nx #3
+          { #1 ~ \use:c {  @@_parse_ #1 :w } #3 , 0 , 0 , 0 , 0 \q_stop }
       }
       {
-        \__msg_kernel_error:nnn { color } { invalid-model } {#2}
+        \__msg_kernel_error:nnn { color } { invalid-model } {#1}
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
+% \subsection{Defining named colors}
+%
+% \begin{variable}{\l_@@_named_tl}
+%   Space to store the detail of the named color.
+%    \begin{macrocode}
+\tl_new:N \l_@@_named_tl
+%    \end{macrocode}
+% \end{variable}
+%
+% \begin{macro}{\@@_store:nN}
+%   Store the named color unless it has an invalid name.
+%     \begin{macrocode}
+\cs_new_protected:Npn \@@_store:nN #1#2
+  {
+    \str_if_eq:nnF {#1} { . }
+      {
+        \tl_clear_new:c { l_@@_named_ #1 _tl }
+        \tl_set_eq:cN { l_@@_named_ #1 _tl } #2
       }
   }
 %    \end{macrocode}
@@ -505,18 +548,24 @@
 %   Defining named colors has to include a step to force creation of the
 %   underlying token list to avoid errors when checking is enabled.
 %    \begin{macrocode}
-\cs_new_protected:Npn \color_set:nn #1
-  { \@@_parse:nn { \@@_store:n {#1} } }
+\cs_new_protected:Npn \color_set:nn #1#2
+  {
+    \@@_parse:nN {#2} \l_@@_named_tl
+    \@@_store:nN {#1} \l_@@_named_tl
+  }
 \cs_new_protected:Npn \color_set:nnn #1
-  { \@@_use:nnn { \@@_store:n {#1} } }
+  {
+    \@@_direct:nnN {#2} {#3} \l_@@_named_tl
+    \@@_store:nN  {#1} \l_@@_named_tl
+  }
 \cs_new_protected:Npn \color_set_eq:nn #1#2
   {
     \@@_if_defined:nTF {#2}
       {
         \tl_clear_new:c { l_@@_named_ #1 _tl }
         \str_if_eq:nnTF {#2} { . }
-          { \tl_et_eq:cN { l_@@_named_ #1 _tl } \l__color_current_tl }
-          { \tl_et_eq:cc { l_@@_named_ #1 _tl } { l_@@_named_ #2 _tl } }
+          { \tl_set_eq:cN { l_@@_named_ #1 _tl } \l__color_current_tl }
+          { \tl_set_eq:cc { l_@@_named_ #1 _tl } { l_@@_named_ #2 _tl } }
       }
       {
         \msg_kernel_error:nnn { color } { unknown-color } {#2}
@@ -530,21 +579,6 @@
 % \end{macro}
 % \end{macro}
 %
-% \begin{macro}{\color_select:n}
-% \begin{macro}{\color_select:nn}
-%   Parse the input expressions then get the driver to actually activate
-%   them.
-%    \begin{macrocode}
-\cs_new_protected:Npn \color_select:n
-  { \@@_parse:nn { \__driver_color_select: } }
-\cs_new_protected:Npn \color_select:nn
-  { \@@_use:nnn { \__driver_color_select: } }
-%    \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
-% \subsection{Pre-defined color names}
-%
 % \begin{macrocode}
 \color_set:nnn { black } { gray } { 0 }
 \color_set:nnn { white } { gray } { 0 }
diff --git a/l3trial/l3color-extra/testfiles/m3color-extra001.lvt b/l3trial/l3color-extra/testfiles/m3color-extra001.lvt
new file mode 100644
index 0000000..ab2e593
--- /dev/null
+++ b/l3trial/l3color-extra/testfiles/m3color-extra001.lvt
@@ -0,0 +1,18 @@
+%
+% Copyright (C) 2017 The LaTeX3 Project
+%
+
+\documentclass{minimal}
+
+\input{regression-test}
+
+\RequirePackage[check-declarations,log-functions]{expl3}
+\RequirePackage{l3color-extra}
+
+\START
+
+\AUTHOR{Joseph Wright}
+
+\ExplSyntaxOn
+ 
+\END
\ No newline at end of file
diff --git a/l3trial/l3color-extra/testfiles/m3color-extra001.tlg b/l3trial/l3color-extra/testfiles/m3color-extra001.tlg
new file mode 100644
index 0000000..ea9d1d8
--- /dev/null
+++ b/l3trial/l3color-extra/testfiles/m3color-extra001.tlg
@@ -0,0 +1,3 @@
+This is a generated file for the LaTeX (2e + expl3) validation system.
+Don't change this file in any respect.
+Author: Joseph Wright

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the latex3-commits mailing list