%% This is file `l3ref-tmp.sty',
%%
%% 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 a tmp file in place of a future kernel module
%% and subject to change without notice.
%%
\ProvidesExplPackage{l3ref-tmp}{2021-06-23}{}
  {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_ \tl_to_str:n {#1} _ \tl_to_str:n {#2} _tl }
    \tl_gset:cn { g__ref_label_ \tl_to_str:n {#1} _ \tl_to_str:n {#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'.
