summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/pdfmanagement-testphase/l3ref-tmp.sty
blob: 32ec132f7754f863d0b8ba16afd7db11463934c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
%%
%% This is file `l3ref-tmp.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% l3ref.dtx  (with options: `package')
%%
%% Copyright (C) 2020-2021 The LaTeX Project
%%
%% It may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License (LPPL), either version 1.3c of
%% this license or (at your option) any later version.  The latest
%% version of this license is in the file:
%%
%%    http://www.latex-project.org/lppl.txt
%%
%% This file is part of the "l3ref bundle" (The Work in LPPL)
%% and all files in that bundle must be distributed together.
%%
%% File: l3ref.dtx
\ProvidesExplPackage{l3ref-tmp}{2020-10-09}{}
  {L3 Experimental cross-referencing}
\cs_new_protected:Npn \ref_attribute_gset:nnnn #1#2#3#4
  {
    \exp_args:Nx \__ref_attribute_gset:nnnn { \tl_to_str:n {#1} }
      {#2} {#3} {#4}
  }
\cs_new_protected:Npn \__ref_attribute_gset:nnnn #1#2#3#4
  {
    \cs_gset:cpn { __ref_attribute_ #1 : } {#4}
    \tl_gclear_new:c { g__ref_default_ #1 _tl }
    \tl_gset:cn { g__ref_default_ #1 _tl } {#2}
    \bool_if_exist:cF { g__ref_shipout_ #1 _tl }
      { \bool_new:c { g__ref_shipout_ #1 _tl } }
    \str_case:nnF {#3}
      {
        { now } { { \bool_gset_false:c { g__ref_shipout_ #1 _tl } } }
        { shipout }
          { \bool_gset_true:c { g__ref_shipout_ #1 _tl } }
      }
      { \msg_error:nnnn { ref } { unknown-setpoint } {#1} {#3} }
  }
\cs_new_protected:Npn \ref_label:nN #1#2
  { \ref_label:nV {#1} #2 }
\cs_new_protected:Npn \ref_label:nn #1#2
  { \exp_args:Nx \__ref_label:nn { \tl_to_str:n {#1} } {#2} }
\cs_generate_variant:Nn \ref_label:nn { nV }
\cs_new_protected:Npn \__ref_label:nn #1#2
  {
    \legacy_if:nT { @filesw }
      {
        \iow_shipout_x:Nx \@auxout
          {
            \token_to_str:N \newlabeldata
              {#1}
              { \clist_map_function:nN {#2} \__ref_label_attribute:n }
          }
      }
  }
\cs_new:Npn \__ref_label_attribute:n #1
  { \exp_args:Ne \__ref_label_attribute_aux:n { \tl_to_str:n {#1} } }
\cs_new:Npn \__ref_label_attribute_aux:n #1
  {
    \cs_if_exist:cTF { __ref_attribute_ #1 : }
      {
        {#1}
        {
          \bool_if:cTF { g__ref_shipout_ #1 _tl }
            { \exp_not:c }
            { \use:c }
              { __ref_attribute_ #1 : }
        }
      }
      { \msg_expandable_error:nnn { ref } { attribute-not-defined } {#1} }
  }
\cs_new:Npn \ref_value:nn #1#2
  {
    \exp_args:Nee \__ref_value:nn { \tl_to_str:n {#1} } { \tl_to_str:n {#2} }
  }
\cs_new:Npn \__ref_value:nn #1#2
  {
    \tl_if_exist:cTF { g__ref_label_ #1 _ #2 _tl }
      { \tl_use:c { g__ref_label_ #1 _ #2 _tl } }
      {
        \tl_if_exist:cTF { g__ref_default_ #2 _tl }
          { \tl_use:c { g__ref_default_ #2 _tl } }
          { \exp_not:n { \textbf { ?? } } }
      }
  }
\prg_new_conditional:Npnn \ref_if_exist:nn #1#2 { p , T , F,  TF }  % #1 label #2 attribute
  {
    \tl_if_exist:cTF { g__ref_label_ \tl_to_str:n {#1} _ \tl_to_str:n {#2} _tl }
      {
        \prg_return_true:
      }
      {
        \prg_return_false:
      }
  }
\cs_new_protected:Npn \newlabeldata #1#2
  {
    \__ref_data:nnn {#1} #2 { \q_recursion_tail } { ? } \q_recursion_stop
  }
\cs_new_protected:Npn \__ref_data:nnn #1#2#3
  {
    \quark_if_recursion_tail_stop:n {#2}
    \tl_gclear_new:c { g__ref_label_ #1 _ #2 _tl }
    \tl_gset:cn { g__ref_label_ #1 _ #2 _tl } {#3}
    \__ref_data:nnn {#1}
  }
\ref_attribute_gset:nnnn { abspage } { 0 } { shipout }
  { \int_use:N \g_shipout_readonly_int }
\ref_attribute_gset:nnnn { page } { 0 } { shipout } { \thepage }
\clist_new:N \g_ref_main_clist
\clist_gput_right:Nn \g_ref_main_clist { page }
\msg_new:nnnn { ref } { attribute-not-defined }
  { Attribute~'#1'~not~defined. }
  {
    LaTeX~has~been~asked~to~use~attribute~'#1',~but~this~
    name~has~not~been~defined.
  }
\msg_new:nnnn { ref } { unknown-setpoint }
  { Unknown~keyword~'#3'~for~setting~attribute~'#1'. }
  {
    LaTeX~has~been~asked~to~set~the~attribute~'#1',~but~the~keyword~
    '#3'~is~not~one~of~the~two~known~values:~'now'~or~'shipout'.
  }
%%
%%
%% End of file `l3ref.sty'.