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
|
%D \module
%D [ file=mult-chk,
%D version=2009.04.13,
%D title=\CONTEXT\ Multilingual Macros,
%D subtitle=Checking,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
\writestatus{loading}{ConTeXt Multilingual Macros / Checking}
%D This is very experimental code that eventually might be used
%D once we have split the whole code base.
%D \startbuffer
%D \getcheckedparameters[MyTest][MyNamespace][a=1,b=2,c=3,d=4,crap=whatever]
%D
%D \MyNamespacea\quad
%D \MyNamespaceb\quad
%D \MyNamespacec\quad
%D \MyNamespaced\quad
%D crap is \ifdefined\MyNamespacecrap\else un\fi defined
%D \stopbuffer
%D
%D \enablecheckparameters
%D
%D \setvalidparameterkeys[MyTest][a,b,c,d] \getbuffer \par
%D \addvalidparameterkeys[MyTest][crap] \getbuffer \par
\unprotect
\registerctxluafile{mult-chk}{}
\protected\def\setvalidparameterkeys{\dodoubleargument\mult_checkers_set_valid_parameter_keys}
\protected\def\addvalidparameterkeys{\dodoubleargument\mult_checkers_add_valid_parameter_keys}
\def\mult_checkers_set_valid_parameter_keys[#1][#2]{\clf_setvalidinterfacekeys{#1}{#2}}
\def\mult_checkers_add_valid_parameter_keys[#1][#2]{\clf_addvalidinterfacekeys{#1}{#2}}
\def\mult_checkers_get_checked_parameters_yes[#1]#2[#3]#4[#5%
{\if\noexpand#5]%
\expandafter\gobblethreearguments
\else
\let\setsomevalue\dosetvalue % used at the lua end
\expandafter\mult_checkers_get_checked_parameters_yes_indeed
\fi{#1}{#3}#5}
\def\mult_checkers_get_checked_parameters_yes_indeed#1#2#3]%
{\clf_getcheckedinterfaceparameters{#1}{#2}{\detokenize{#3}}}
\def\mult_checkers_get_checked_parameters_nop[#1]#2[#3]#4[#5%
{\if\noexpand#5]%
\expandafter\gobbletwoarguments
\else
\let\setsomevalue\dosetvalue % used at the lua end
\expandafter\mult_checkers_get_checked_parameters_nop_indeed
\fi{#3}#5}
\def\mult_checkers_get_checked_parameters_nop_indeed#1#2]% needs checking with adapted syst-aux.mkiv
{\def\syst_helpers_get_parameters_assign{\syst_helpers_get_parameters_assign_indeed#1}% will change
\syst_helpers_process_comma_item#2,],^^^^0004}
\protected\def\disablecheckparameters{\let\getcheckedparameters\mult_checkers_get_checked_parameters_nop}
\protected\def\enablecheckparameters {\let\getcheckedparameters\mult_checkers_get_checked_parameters_yes}
\disablecheckparameters
\protect \endinput
\starttext
\testfeatureonce{10000}{\getcheckedparameters[test][xx][a=b,c= d, e = f]} % 0.20 seconds
\enablecheckparameters
\testfeatureonce{10000}{\getcheckedparameters[test][xx][a=b,c= d, e = f]} % 0.35 seconds
\getcheckedparameters[test][xx][a=a]
\getcheckedparameters[test][xx][b= b]
\getcheckedparameters[test][xx][c = c]
\getcheckedparameters[test][xx][d = d d , e = e ,f = f ]
\getcheckedparameters[test][xx][g={oeps {oeps}}]
\getcheckedparameters[test][xx][crap=whatever]
\startlines
[a:\getvalue{xxa}][a]
[b:\getvalue{xxb}][b]
[c:\getvalue{xxc}][c]
[d:\getvalue{xxd}][d d ]
[e:\getvalue{xxe}][e ]
[f:\getvalue{xxf}][f ]
[g:\getvalue{xxg}][\detokenize\expandafter{\xxg}]
\stoplines
\setvalidparameterkeys[test][crap]
\getcheckedparameters[test][xx][crap=whatever]
\stoptext
|