diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-01-12 17:15:07 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-01-12 17:15:07 +0100 |
commit | 8d8d528d2ad52599f11250cfc567fea4f37f2a8b (patch) | |
tree | 94286bc131ef7d994f9432febaf03fe23d10eef8 /tex/context/base/mkiv/luat-cod.mkiv | |
parent | f5aed2e51223c36c84c5f25a6cad238b2af59087 (diff) | |
download | context-8d8d528d2ad52599f11250cfc567fea4f37f2a8b.tar.gz |
2016-01-12 16:26:00
Diffstat (limited to 'tex/context/base/mkiv/luat-cod.mkiv')
-rw-r--r-- | tex/context/base/mkiv/luat-cod.mkiv | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/luat-cod.mkiv b/tex/context/base/mkiv/luat-cod.mkiv new file mode 100644 index 000000000..9ce6161c3 --- /dev/null +++ b/tex/context/base/mkiv/luat-cod.mkiv @@ -0,0 +1,79 @@ +%D \module +%D [ file=luat-cod, +%D version=2005.05.26, +%D title=\CONTEXT\ Lua Macros, +%D subtitle=Code, +%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 Lua Macros / Code} + +\unprotect + +%D We cannot use the following due to the fact that existing usage +%D demanded duplicating hashes. +%D +%D \starttyping +%D \def\expanded#1{\normalexpanded{\noexpand#1}} % ## mess +%D \stoptyping + +\newif\ifproductionrun + +%D Originally we compiled the \LUA\ files externally and loaded +%D then at runtime, but when the amount grew, we realized that +%D we needed away to store them in the format, which is what +%D bytecode arrays do. And so the following is obsolete: +%D +%D \starttyping +%D \setnewconstant\ctxluaembeddingmode \plusone +%D +%D 0 = external compilation and loading +%D 1 = runtime compilation and embedding +%D \stoptyping +%D +%D Allocation of \LUA\ engines has changed too. The original idea +%D was to have multiple \LUA\ instances and it worked that way for +%D several years. Hoewver in practice we used only one engine because +%D scripts need to share data anyway. So eventually \LUATEX\ got only +%D one instance. Because each call is reentrant there is not much +%D danger for crashes. +%D +%D Most code here has changed after version 0.60 as part of adaption to +%D new functionality. We no longer support the hooks for initializing +%D code as this can be done at the \LUA\ end. + +% we can drop the \zerocount as it's default + +\let\ctxdirectlua \directlua +\let\ctxlatelua \latelua +\def\ctxsprint #1{\directlua{tex.sprint(tex.ctxcatcodes,#1)}} % saves tokens +\def\ctxwrite #1{\directlua{tex.write(#1)}} % saves tokens +\def\ctxcommand #1{\directlua{commands.#1}} % saves tokens +\def\ctxdirectcommand#1{\directlua{commands.#1}} % saves tokens +\def\ctxlatecommand #1{\latelua {commands.#1}} % saves tokens +\def\ctxreport #1{\directlua{logs.writer[[#1]]}} + +%D Take your choice \unknown + +\let\ctxlua \ctxdirectlua +\let\luacode \ctxdirectlua +\let\lateluacode \ctxlatelua +\let\directluacode\ctxdirectlua + +%D Reporting the version of \LUA\ that we use is done as follows: + +\edef\luaversion{\ctxwrite{_VERSION}} + +\def\registerctxluafile#1#2{\ctxlua{lua.registercode("#1","#2")}} +\def\ctxloadluafile #1{\ctxlua{lua.registercode("#1")}} + +\registerctxluafile{luat-cod}{1.001} + +% \everydump\expandafter{\the\everydump\ctxlua{lua.finalize()}} + +\protect \endinput |