diff options
Diffstat (limited to 'tex/context/base/java-ini.tex')
-rw-r--r-- | tex/context/base/java-ini.tex | 104 |
1 files changed, 67 insertions, 37 deletions
diff --git a/tex/context/base/java-ini.tex b/tex/context/base/java-ini.tex index 34e9e6a71..885292578 100644 --- a/tex/context/base/java-ini.tex +++ b/tex/context/base/java-ini.tex @@ -8,16 +8,21 @@ %D copyright={PRAGMA / Hans Hagen \& Ton Otten}] %C %C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See licen-en.pdf for +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. \writestatus{loading}{Context JavaScript Macros / Initialization} +% BUG: preamble zonder used/used en split + % JavaScript support is under development. In the near future % a slightly different model will be used. The JScode stuff % will probably become just auto function inclusion and the % JS_* things will disappear. First I have to find a way to % deal with global variables so the 'uses' thing will remain. + +% ook p{ref} +% documentation should be corrected to JS( % Also, obeylines will be supported. @@ -46,6 +51,12 @@ 2: unbekannte Preamble -- \stopmessages +\startmessages czech library: javascript + title: javascript + 1: nacita se soubor skriptu -- + 2: neznama preambule -- +\stopmessages + %D \TEX\ is not the right tool to check the \JAVA\ code; the %D most we can do is reporting some passed variables: @@ -232,8 +243,9 @@ \def\docommando##1% {\doifundefinedelse{\r!java\r!java##1} {\showmessage{\m!javascript}{2}{##1}} - {\doglobal\increment\currentJSpreamble - \doglobal\addtocommalist{##1}\allJSpreambles}}% + {\useJSpreamblenow{##1}}}% +% {\doglobal\increment\currentJSpreamble +% \doglobal\addtocommalist{##1}\allJSpreambles}}% \def\do##1##2% {\xdef\JScode{\ifdirectJScode#1(\JScode)\else\JScode##2\fi}% %\xdef\JScode{JS\string_N=\the\scratchcounter;\JScode}% @@ -327,30 +339,58 @@ \newcounter\nofJSpreambles \newcounter\currentJSpreamble -\long\gdef\startJSpreamble#1 #2 - {\doifelse{#2}{used} - {\def\next{\dostartJSpreamble{#1} }} - {\def\next{\dostartJSpreamble{#1} now #2 }}% +\long\def\startJSpreamble#1 #2 % + {\bgroup % we need to restore the catcodes + \popendofline % just in case it happens while reading lists + \doifelse{#2}{used} + {\def\next{\dostartJSpreamble#1 }} + {\def\next{\dostartJSpreamble#1 now #2 }}% \next} - + \long\def\dostartJSpreamble#1 #2 #3\stopJSpreamble% - {\bgroup - \processaction + {\processaction [#2] [ later=>\chardef\JSstatus=0, now=>\chardef\JSstatus=1, \s!default=>\chardef\JSstatus=2, \s!unknown=>\chardef\JSstatus=2]% - \presetJSfunctions #3function ()\end% - \ifcase\JSstatus - \long\setgvalue{\r!java\r!java#1}{#3}% - \else - \long\setgvalue{\r!java\r!java#1}{#3}% - \doglobal\increment\currentJSpreamble - \doglobal\addtocommalist{#1}\allJSpreambles + \presetJSfunctions #3function ()\end + \long\setgvalue{\r!java\r!java#1}{#3}% + \ifcase\JSstatus \else + \useJSpreamblenow{#1}% \fi \egroup} +%D \macros +%D {setJSpreamble, addtoJSpreamble} +%D +%D In addition to the previous preamble definitions, we can +%D set a preamble \citeer {in||line} and add tokens to a +%D preamble. + +\def\setJSpreamble#1#2% + {\doifundefined{\r!java\r!java#1} + {\setgvalue{\r!java\r!java#1}{#2;}% + \doglobal\increment\currentJSpreamble + \doglobal\addtocommalist{#1}\allJSpreambles}} + +\def\addtoJSpreamble#1#2% + {\doifdefinedelse{\r!java\r!java#1} + {\edef\!!stringa{\r!java\r!java#1}% + \edef\!!stringb{\csname\!!stringa\endcsname}% + \@EA\setgvalue\@EA\!!stringa\@EA{\!!stringb #2;}} + {\setJSpreamble{#1}{#2}}} + +%D \macros +%D {useJSpreamblenow} +%D +%D The next macro can be used to force inclusion of postponed +%D \JAVASCRIPT\ preambles. + +\def\useJSpreamblenow#1% + {\doglobal\increment\currentJSpreamble + \doglobal\addtocommalist{#1}\allJSpreambles} + %D Because we want to check for valid calls, we preload the %D functions. This means that we can call them directly as %D well as indirectly when defined by \type {\startJScode} etc. @@ -390,18 +430,6 @@ \egroup \fi} -%\def\flushJSpreamble% -% {\iflocation\ifx\allJSpreambles\empty\else -% \bgroup -% \presetJSpreamble -% \expanded{\doflushJSpreamble{\allJSpreambles}}% -% \global\let\flushJSpreamble=\relax -% \global\let\allJSpreambles=\empty -% \egroup -% \fi\fi} -% -%\prependtoks \flushJSpreamble \to \everylastshipout - \def\flushJSpreamble% {\iflocation\ifx\allJSpreambles\empty\else \ifcase\nofJSpreambles\else\ifnum\nofJSpreambles=\currentJSpreamble @@ -539,7 +567,7 @@ %D The magic 500 in the next hack prevents the input stack from %D overflowing when large scripts are sanitized. -\beginTEX +%\beginTEX \def\dododoPSsanitizeJScode% {\ifcase\JSisTEX\ifcase\JScomment @@ -560,13 +588,15 @@ \aftergroup\sanitizedJScode \let\next=}} -\endTEX - -\beginETEX \aftergroup - -\let\dododoPSsanitizeJScode\relax - -\endETEX +%\endTEX +% +% Why is \aftergroup not doing what I expect? +% +% \beginETEX \aftergroup +% +% \let\dododoPSsanitizeJScode\relax +% +% \endETEX %D The macro \type{\doPSsanitizeJScode} converts its argument %D into the macro \type{\sanitizedJScode}, thereby prefixing |