diff options
author | Hans Hagen <pragma@wxs.nl> | 2009-05-28 11:23:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2009-05-28 11:23:00 +0200 |
commit | 1d3090326210c6e6f7ec5432799ded25b75bba46 (patch) | |
tree | c5921203789ec669e6bccaba4bd56f9c072dc56b /tex/context/base/mult-chk.mkiv | |
parent | 94d83f84758766511c5e324721e39fea6ab71dae (diff) | |
download | context-1d3090326210c6e6f7ec5432799ded25b75bba46.tar.gz |
beta 2009.05.28 11:23
Diffstat (limited to 'tex/context/base/mult-chk.mkiv')
-rw-r--r-- | tex/context/base/mult-chk.mkiv | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/tex/context/base/mult-chk.mkiv b/tex/context/base/mult-chk.mkiv new file mode 100644 index 000000000..7b40bd64a --- /dev/null +++ b/tex/context/base/mult-chk.mkiv @@ -0,0 +1,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] +%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}{1.001} + +\def\setvalidparameterkeys{\dodoubleargument\dosetvalidparameterkeys} +\def\addvalidparameterkeys{\dodoubleargument\doaddvalidparameterkeys} + +\def\dosetvalidparameterkeys[#1][#2]{\ctxlua{interfaces.setvalidkeys("#1",\!!bs#2\!!es)}} +\def\doaddvalidparameterkeys[#1][#2]{\ctxlua{interfaces.addvalidkeys("#1",\!!bs#2\!!es)}} + +\def\getcheckedparametersyes[#1]#2[#3]#4[#5% + {\if\noexpand#5]% + \expandafter\gobblethreearguments + \else + \let\setsomevalue\dosetvalue + \expandafter\dogetcheckedparametersyes + \fi{#1}{#3}#5} + +\def\dogetcheckedparametersyes#1#2#3]% + {\ctxlua{_gcp_("#1","#2",\!!bs\detokenize{#3}\!!es)}} + +\def\getcheckedparametersnop[#1]#2[#3]#4[#5% + {\if\noexpand#5]% + \expandafter\gobbletwoarguments + \else + \let\setsomevalue\dosetvalue + \expandafter\dogetcheckedparametersnop + \fi{#3}#5} + +\def\dogetcheckedparametersnop#1#2]% + {\def\p!dogetparameter{\p!doassign#1}% + \xprocesscommaitem#2,],\@relax@} + +\def\disablecheckparameters{\let\getcheckedparameters\getcheckedparametersnop} +\def\enablecheckparameters {\let\getcheckedparameters\getcheckedparametersyes} + +\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 |