diff options
author | Karl Berry <karl@freefriends.org> | 2011-07-31 18:27:06 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-07-31 18:27:06 +0000 |
commit | dac945b204407dae96f70ec228206516093156d7 (patch) | |
tree | 02ca182689947e45dec95e17ba08b503c959bd17 /Master/texmf-dist/tex/latex/l3kernel/l3keys.sty | |
parent | c1840548792cfbc7c9f746da1d53d89b94406e72 (diff) |
l3kernel (5jun11)
git-svn-id: svn://tug.org/texlive/trunk@23282 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/l3kernel/l3keys.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/l3kernel/l3keys.sty | 475 |
1 files changed, 475 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/l3kernel/l3keys.sty b/Master/texmf-dist/tex/latex/l3kernel/l3keys.sty new file mode 100644 index 00000000000..b12add10c9c --- /dev/null +++ b/Master/texmf-dist/tex/latex/l3kernel/l3keys.sty @@ -0,0 +1,475 @@ +%% +%% This is file `l3keys.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% l3keys.dtx (with options: `package') +%% +%% EXPERIMENTAL CODE +%% +%% Do not distribute this file without also distributing the +%% source files specified above. +%% +%% Do not distribute a modified version of this file. +%% +%% File: l3keys.dtx Copyright (C) 2009-2011 The LaTeX3 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 "expl3 bundle" (The Work in LPPL) +%% and all files in that bundle must be distributed together. +%% +%% The released version of this bundle is available from CTAN. +%% +%% ----------------------------------------------------------------------- +%% +%% The development version of the bundle can be found at +%% +%% http://www.latex-project.org/svnroot/experimental/trunk/ +%% +%% for those people who are interested. +%% +%%%%%%%%%%% +%% NOTE: %% +%%%%%%%%%%% +%% +%% Snapshots taken from the repository represent work in progress and may +%% not work or may contain conflicting material! We therefore ask +%% people _not_ to put them into distributions, archives, etc. without +%% prior consultation with the LaTeX3 Project. +%% +%% ----------------------------------------------------------------------- +\RequirePackage{l3names} +\GetIdInfo$Id: l3keys.dtx 2478 2011-06-19 21:34:23Z joseph $ + {L3 Experimental key-value interfaces} +\ProvidesExplPackage + {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} +\package_check_loaded_expl: +\tl_const:Nn \c_keys_code_root_tl { key~code~>~ } +\tl_const:Nn \c_keys_vars_root_tl { key~var~>~ } +\tl_const:Nn \c_keys_props_root_tl { key~prop~>~ } +\tl_const:Nn \c_keys_value_forbidden_tl { forbidden } +\tl_const:Nn \c_keys_value_required_tl { required } +\int_new:N \l_keys_choice_int +\tl_new:N \l_keys_choices_tl +\tl_new:N \l_keys_key_tl +\tl_new:N \l_keys_module_tl +\bool_new:N \l_keys_no_value_bool +\tl_new:N \l_keys_path_tl +\tl_new:N \l_keys_property_tl +\tl_new:N \l_keys_value_tl +\cs_new_protected:Npn \keys_define:nn + { \keys_define_aux:onn \l_keys_module_tl } +\cs_new_protected:Npn \keys_define_aux:nnn #1#2#3 + { + \tl_set:Nx \l_keys_module_tl { \tl_to_str:n {#2} } + \keyval_parse:NNn \keys_define_elt:n \keys_define_elt:nn {#3} + \tl_set:Nn \l_keys_module_tl {#1} + } +\cs_generate_variant:Nn \keys_define_aux:nnn { o } +\cs_new_protected_nopar:Npn \keys_define_elt:n #1 + { + \bool_set_true:N \l_keys_no_value_bool + \keys_define_elt_aux:nn {#1} { } + } +\cs_new_protected:Npn \keys_define_elt:nn #1#2 + { + \bool_set_false:N \l_keys_no_value_bool + \keys_define_elt_aux:nn {#1} {#2} + } +\cs_new_protected:Npn \keys_define_elt_aux:nn #1#2 { + \keys_property_find:n {#1} + \cs_if_exist:cTF { \c_keys_props_root_tl \l_keys_property_tl } + { \keys_define_key:n {#2} } + { + \msg_kernel_error:nnxx { keys } { property-unknown } + { \l_keys_property_tl } { \l_keys_path_tl } + } +} +\cs_new_protected_nopar:Npn \keys_property_find:n #1 + { + \tl_set:Nx \l_keys_path_tl { \l_keys_module_tl / } + \tl_if_in:nnTF {#1} { . } + { \keys_property_find_aux:w #1 \q_stop } + { \msg_kernel_error:nnx { keys } { key-no-property } {#1} } + } +\cs_new_protected_nopar:Npn \keys_property_find_aux:w #1 . #2 \q_stop + { + \tl_set:Nx \l_keys_path_tl { \l_keys_path_tl \tl_to_str:n {#1} } + \tl_if_in:nnTF {#2} { . } + { + \tl_set:Nx \l_keys_path_tl { \l_keys_path_tl . } + \keys_property_find_aux:w #2 \q_stop + } + { \tl_set:Nn \l_keys_property_tl { . #2 } } + } +\cs_new_protected:Npn \keys_define_key:n #1 + { + \bool_if:NTF \l_keys_no_value_bool + { + \exp_after:wN \keys_define_key_aux:w + \l_keys_property_tl \q_stop + { \use:c { \c_keys_props_root_tl \l_keys_property_tl } } + { + \msg_kernel_error:nnxx { keys } + { property-requires-value } { \l_keys_property_tl } + { \l_keys_path_tl } + } + } + { \use:c { \c_keys_props_root_tl \l_keys_property_tl } {#1} } + } +\cs_new_protected:Npn \keys_define_key_aux:w #1 : #2 \q_stop + { \tl_if_empty:nTF {#2} } +\cs_new_nopar:Npn \keys_bool_set:NN #1#2 + { + \cs_if_exist:NF #1 { \bool_new:N #1 } + \keys_choice_make: + \keys_cmd_set:nx { \l_keys_path_tl / true } + { \exp_not:c { bool_ #2 set_true:N } \exp_not:N #1 } + \keys_cmd_set:nx { \l_keys_path_tl / false } + { \exp_not:c { bool_ #2 set_false:N } \exp_not:N #1 } + \keys_cmd_set:nn { \l_keys_path_tl / unknown } + { + \msg_kernel_error:nnx { keys } { boolean-values-only } + { \l_keys_key_tl } + } + \keys_default_set:n { true } + } +\cs_new_protected_nopar:Npn \keys_choice_make: + { + \keys_cmd_set:nn { \l_keys_path_tl } + { \keys_choice_find:n {##1} } + \keys_cmd_set:nn { \l_keys_path_tl / unknown } + { + \msg_kernel_error:nnxx { keys } { choice-unknown } + { \l_keys_path_tl } {##1} + } + } +\cs_new_protected:Npn \keys_choices_generate:n #1 + { + \cs_if_exist:cTF + { \c_keys_vars_root_tl \l_keys_path_tl .choice~code } + { + \keys_choice_make: + \int_zero:N \l_keys_choice_int + \clist_map_function:nN {#1} \keys_choices_generate_aux:n + } + { + \msg_kernel_error:nnx { keys } + { generate-choices-before-code } { \l_keys_path_tl } + } + } +\cs_new_protected_nopar:Npn \keys_choices_generate_aux:n #1 + { + \keys_cmd_set:nx { \l_keys_path_tl / #1 } + { + \exp_not:n { \tl_set:Nn \l_keys_choice_tl } {#1} + \exp_not:n { \int_set:Nn \l_keys_choice_int } + { \int_use:N \l_keys_choice_int } + \exp_not:v + { \c_keys_vars_root_tl \l_keys_path_tl .choice~code } + } + \int_incr:N \l_keys_choice_int + } +\cs_new_protected:Npn \keys_choice_code_store:x #1 + { + \cs_if_exist:cF + { \c_keys_vars_root_tl \l_keys_path_tl .choice~code } + { + \tl_new:c + { \c_keys_vars_root_tl \l_keys_path_tl .choice~code } + } + \tl_set:cx { \c_keys_vars_root_tl \l_keys_path_tl .choice~code } + {#1} + } +\cs_new_protected:Npn \keys_cmd_set:nn #1#2 + { + \keys_cmd_set_aux:n {#1} + \cs_set:cpn { \c_keys_code_root_tl #1 } ##1 {#2} + } +\cs_new_protected:Npn \keys_cmd_set:nx #1#2 + { + \keys_cmd_set_aux:n {#1} + \cs_set:cpx { \c_keys_code_root_tl #1 } ##1 {#2} + } +\cs_new_protected_nopar:Npn \keys_cmd_set_aux:n #1 + { + \tl_clear_new:c { \c_keys_vars_root_tl #1 .default } + \tl_set:cn { \c_keys_vars_root_tl #1 .default } { \q_no_value } + \tl_clear_new:c { \c_keys_vars_root_tl #1 .req } + } +\cs_new_protected:Npn \keys_default_set:n #1 + { \tl_set:cn { \c_keys_vars_root_tl \l_keys_path_tl .default } {#1} } +\cs_generate_variant:Nn \keys_default_set:n { V } +\cs_new_protected_nopar:Npn \keys_meta_make:n #1 + { + \exp_args:NNo \keys_cmd_set:nn \l_keys_path_tl + { \exp_after:wN \keys_set:nn \exp_after:wN { \l_keys_module_tl } {#1} } + } +\cs_new_protected_nopar:Npn \keys_meta_make:x #1 + { + \keys_cmd_set:nx { \l_keys_path_tl } + { \exp_not:N \keys_set:nn { \l_keys_module_tl } {#1} } + } +\cs_new_protected_nopar:Npn \keys_value_requirement:n #1 + { + \tl_set_eq:cc + { \c_keys_vars_root_tl \l_keys_path_tl .req } + { c_keys_value_ #1 _tl } + } +\cs_new_protected_nopar:Npn \keys_variable_set:NnNN #1#2#3#4 + { + \cs_if_exist:NF #1 { \use:c { #2 _new:N } #1 } + \keys_cmd_set:nx { \l_keys_path_tl } + { \exp_not:c { #2 _ #3 set:N #4 } \exp_not:N #1 {##1} } + } +\cs_new_protected_nopar:Npn \keys_variable_set:NnN #1#2#3 + { \keys_variable_set:NnNN #1 {#2} { } #3 } +\cs_generate_variant:Nn \keys_variable_set:NnNN { c } +\cs_generate_variant:Nn \keys_variable_set:NnN { c } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .bool_set:N } #1 + { \keys_bool_set:NN #1 { } } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .bool_gset:N } #1 + { \keys_bool_set:NN #1 g } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .choice: } + { \keys_choice_make: } +\cs_new_protected:cpn { \c_keys_props_root_tl .code:n } #1 + { \keys_cmd_set:nn { \l_keys_path_tl } {#1} } +\cs_new_protected:cpn { \c_keys_props_root_tl .code:x } #1 + { \keys_cmd_set:nx { \l_keys_path_tl } {#1} } +\cs_new_protected:cpn { \c_keys_props_root_tl .choice_code:n } #1 + { \keys_choice_code_store:x { \exp_not:n {#1} } } +\cs_new_protected:cpn { \c_keys_props_root_tl .choice_code:x } #1 + { \keys_choice_code_store:x {#1} } +\cs_new_protected:cpn { \c_keys_props_root_tl .default:n } #1 + { \keys_default_set:n {#1} } +\cs_new_protected:cpn { \c_keys_props_root_tl .default:V } #1 + { \keys_default_set:V #1 } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .dim_set:N } #1 + { \keys_variable_set:NnN #1 { dim } n } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .dim_set:c } #1 + { \keys_variable_set:cnN {#1} { dim } n } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .dim_gset:N } #1 + { \keys_variable_set:NnNN #1 { dim } g n } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .dim_gset:c } #1 + { \keys_variable_set:cnNN {#1} { dim } g n } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .fp_set:N } #1 + { \keys_variable_set:NnN #1 { fp } n } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .fp_set:c } #1 + { \keys_variable_set:cnN {#1} { fp } n } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .fp_gset:N } #1 + { \keys_variable_set:NnNN #1 { fp } g n } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .fp_gset:c } #1 + { \keys_variable_set:cnNN {#1} { fp } g n } +\cs_new_protected:cpn { \c_keys_props_root_tl .generate_choices:n } #1 + { \keys_choices_generate:n {#1} } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .int_set:N } #1 + { \keys_variable_set:NnN #1 { int } n } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .int_set:c } #1 + { \keys_variable_set:cnN {#1} { int } n } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .int_gset:N } #1 + { \keys_variable_set:NnNN #1 { int } g n } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .int_gset:c } #1 + { \keys_variable_set:cnNN {#1} { int } g n } +\cs_new_protected:cpn { \c_keys_props_root_tl .meta:n } #1 + { \keys_meta_make:n {#1} } +\cs_new_protected:cpn { \c_keys_props_root_tl .meta:x } #1 + { \keys_meta_make:x {#1} } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .skip_set:N } #1 + { \keys_variable_set:NnN #1 { skip } n } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .skip_set:c } #1 + { \keys_variable_set:cnN {#1} { skip } n } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .skip_gset:N } #1 + { \keys_variable_set:NnNN #1 { skip } g n } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .skip_gset:c } #1 + { \keys_variable_set:cnNN {#1} { skip } g n } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .tl_set:N } #1 + { \keys_variable_set:NnN #1 { tl } n } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .tl_set:c } #1 + { \keys_variable_set:cnN {#1} { tl } n } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .tl_set_x:N } #1 + { \keys_variable_set:NnN #1 { tl } x } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .tl_set_x:c } #1 + { \keys_variable_set:cnN {#1} { tl } x } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .tl_gset:N } #1 + { \keys_variable_set:NnNN #1 { tl } g n } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .tl_gset:c } #1 + { \keys_variable_set:cnNN {#1} { tl } g n } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .tl_gset_x:N } #1 + { \keys_variable_set:NnNN #1 { tl } g x } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .tl_gset_x:c } #1 + { \keys_variable_set:cnNN {#1} { tl } g x } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .value_forbidden: } + { \keys_value_requirement:n { forbidden } } +\cs_new_protected_nopar:cpn { \c_keys_props_root_tl .value_required: } + { \keys_value_requirement:n { required } } +\cs_new_protected:Npn \keys_set:nn + { \keys_set_aux:onn { \l_keys_module_tl } } +\cs_new_protected:Npn \keys_set_aux:nnn #1#2#3 + { + \tl_set:Nn \l_keys_module_tl {#2} + \keyval_parse:NNn \keys_set_elt:n \keys_set_elt:nn {#3} + \tl_set:Nn \l_keys_module_tl {#1} + } +\cs_generate_variant:Nn \keys_set:nn { nV , nv , no } +\cs_generate_variant:Nn \keys_set_aux:nnn { o } +\cs_new_protected_nopar:Npn \keys_set_elt:n #1 + { + \bool_set_true:N \l_keys_no_value_bool + \keys_set_elt_aux:nn {#1} { } + } +\cs_new_protected:Npn \keys_set_elt:nn #1#2 + { + \bool_set_false:N \l_keys_no_value_bool + \keys_set_elt_aux:nn {#1} {#2} + } +\cs_new_protected:Npn \keys_set_elt_aux:nn #1#2 + { + \tl_set:Nx \l_keys_key_tl { \tl_to_str:n {#1} } + \tl_set:Nx \l_keys_path_tl { \l_keys_module_tl / \l_keys_key_tl } + \keys_value_or_default:n {#2} + \bool_if:nTF + { + \keys_if_value_p:n { required } && + \l_keys_no_value_bool + } + { + \msg_kernel_error:nnx { keys } { value-required } + { \l_keys_path_tl } + } + { + \bool_if:nTF + { + \keys_if_value_p:n { forbidden } && + ! \l_keys_no_value_bool + } + { + \msg_kernel_error:nnxx { keys } { value-forbidden } + { \l_keys_path_tl } { \l_keys_value_tl } + } + { \keys_execute: } + } + } +\cs_new_protected:Npn \keys_value_or_default:n #1 + { + \tl_set:Nn \l_keys_value_tl {#1} + \bool_if:NT \l_keys_no_value_bool + { + \quark_if_no_value:cF { \c_keys_vars_root_tl \l_keys_path_tl .default } + { + \tl_set_eq:Nc \l_keys_value_tl + { \c_keys_vars_root_tl \l_keys_path_tl .default } + } + } + } +\prg_new_conditional:Npnn \keys_if_value:n #1 { p } + { + \tl_if_eq:ccTF { c_keys_value_ #1 _tl } + { \c_keys_vars_root_tl \l_keys_path_tl .req } + { \prg_return_true: } + { \prg_return_false: } + } +\cs_new_nopar:Npn \keys_execute: + { \keys_execute:nn { \l_keys_path_tl } { \keys_execute_unknown: } } +\cs_new_nopar:Npn \keys_execute_unknown: + { + \keys_execute:nn { \l_keys_module_tl / unknown } + { + \msg_kernel_error:nnxx { keys } { key-unknown } + { \l_keys_path_tl } { \l_keys_module_tl } + } + } +\cs_new_nopar:Npn \keys_execute:nn #1#2 + { + \cs_if_exist:cTF { \c_keys_code_root_tl #1 } + { + \exp_args:Nno \use:c { \c_keys_code_root_tl #1 } + \l_keys_value_tl + } + {#2} + } +\cs_new_nopar:Npn \keys_choice_find:n #1 + { + \keys_execute:nn { \l_keys_path_tl / \tl_to_str:n {#1} } + { \keys_execute:nn { \l_keys_path_tl / unknown } { } } + } +\prg_new_conditional:Npnn \keys_if_exist:nn #1#2 { p , T , F , TF } + { + \cs_if_exist:cTF { \c_keys_code_root_tl #1 / #2 } + { \prg_return_true:} + { \prg_return_false:} + } +\cs_new_nopar:Npn \keys_show:nn #1#2 + { \cs_show:c { \c_keys_code_root_tl #1 / \tl_to_str:n {#2} } } +\msg_kernel_new:nnnn { keys } { boolean-values-only } + { Key~'#1'~accepts~boolean~values~only. } + { The~key~'#1'~only~accepts~the~values~'true'~and~'false'. } +\msg_kernel_new:nnnn { keys } { choice-unknown } + { Choice~'#2'~unknown~for~key~'#1'. } + { + The~key~'#1'~takes~a~limited~number~of~values.\\ + The~input~given,~'#2',~is~not~on~the~list~accepted. + } +\msg_kernel_new:nnnn { keys } { generate-choices-before-code } + { No~code~available~to~generate~choices~for~key~'#1'. } + { + \c_msg_coding_error_text_tl + Before~using~.generate_choices:n~the~code~should~be~defined~ + with~'.choice_code:n'~or~'.choice_code:x'. + } +\msg_kernel_new:nnnn { keys } { key-no-property } + { No~property~given~in~definition~of~key~'#1'. } + { + \c_msg_coding_error_text_tl + Inside~\keys_define:nn each~key~name + needs~a~property: \\ + ~ ~ #1 .<property> \\ + LaTeX~did~not~find~a~'.'~to~indicate~the~start~of~a~property. + } +\msg_kernel_new:nnnn { keys } { key-unknown } + { The~key~'#1'~is~unknown~and~is~being~ignored. } + { + The~module~'#2'~does~not~have~a~key~called~#1'.\\ + Check~that~you~have~spelled~the~key~name~correctly. + } +\msg_kernel_new:nnnn { keys } { option-unknown } + { Unknown~option~'#1'~for~package~#2. } + { + LaTeX~has~been~asked~to~set~an~option~called~'#1'~ + but~the~#2~package~has~not~created~an~option~with~this~name. + } +\msg_kernel_new:nnnn { keys } { property-requires-value } + { The~property~'#1'~requires~a~value. } + { + \c_msg_coding_error_text_tl + LaTeX~was~asked~to~set~property~'#2'~for~key~'#1'.\\ + No~value~was~given~for~the~property,~and~one~is~required. + } +\msg_kernel_new:nnnn { keys } { property-unknown } + { The~key~property~'#1'~is~unknown. } + { + \c_msg_coding_error_text_tl + LaTeX~has~been~asked~to~set~the~property~'#1'~for~key~'#2':~ + this~property~is~not~defined. + } +\msg_kernel_new:nnnn { keys } { value-forbidden } + { The~key~'#1'~does~not~taken~a~value. } + { + The~key~'#1'~should~be~given~without~a~value.\\ + LaTeX~will~ignore~the~given~value~'#2'. + } +\msg_kernel_new:nnnn { keys } { value-required } + { The~key~'#1'~requires~a~value. } + { + The~key~'#1'~must~have~a~value.\\ + No~value~was~present:~the~key~will~be~ignored. + } +%% +%% +%% End of file `l3keys.sty'. |