summaryrefslogtreecommitdiff
path: root/src/fontloader/misc/fontloader-basics.tex
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2015-06-13 00:40:45 +0200
committerPhilipp Gesang <phg@phi-gamma.net>2015-06-13 00:40:45 +0200
commit90f398e1c9d2896b2d30d0b66f9c8a88255511a8 (patch)
tree88459ad0c6986a6648c969726081248cd5c8d74e /src/fontloader/misc/fontloader-basics.tex
parentc4c4901173b0f4284534db1b6a3cfe865b05e15c (diff)
parentb271e253b40cd0af97f6d50f0461f87ad1ed5314 (diff)
downloadluaotfload-90f398e1c9d2896b2d30d0b66f9c8a88255511a8.tar.gz
Merge pull request #274 from phi-gamma/master
pull in current state of affairs
Diffstat (limited to 'src/fontloader/misc/fontloader-basics.tex')
-rw-r--r--src/fontloader/misc/fontloader-basics.tex70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/fontloader/misc/fontloader-basics.tex b/src/fontloader/misc/fontloader-basics.tex
index abe4989..1180c68 100644
--- a/src/fontloader/misc/fontloader-basics.tex
+++ b/src/fontloader/misc/fontloader-basics.tex
@@ -20,4 +20,74 @@
{\global\advance\lastallocatedattribute 1
\attributedef#1\lastallocatedattribute}
+% maybe we will have luatex-basics.lua some day for instance when more
+% (pdf) primitives have moved to macros)
+
+\directlua {
+
+ gadgets = gadgets or { } % reserved namespace
+
+ gadgets.functions = { }
+ local registered = {}
+
+ function gadgets.functions.reverve()
+ local numb = newtoken.scan_int()
+ local name = newtoken.scan_string()
+ local okay = string.gsub(name,"[\string\\ ]","")
+ registered[okay] = numb
+ texio.write_nl("reserving lua function '"..okay.."' with number "..numb)
+ end
+
+ function gadgets.functions.register(name,f)
+ local okay = string.gsub(name,"[\string\\ ]","")
+ local numb = registered[okay]
+ if numb then
+ texio.write_nl("registering lua function '"..okay.."' with number "..numb)
+ lua.get_functions_table()[numb] = f
+ else
+ texio.write_nl("lua function '"..okay.."' is not reserved")
+ end
+ end
+
+}
+
+\newcount\lastallocatedluafunction
+
+\def\newluafunction#1%
+ {\ifdefined#1\else
+ \global\advance\lastallocatedluafunction 1
+ \global\chardef#1\lastallocatedluafunction
+ \directlua{gadgets.functions.reserve()}#1{\detokenize{#1}}%
+ \fi}
+
+% an example of usage (if we ever support it it will go to the plain gadgets module):
+%
+% \directlua {
+%
+% local cct = nil
+% local chr = nil
+%
+% gadgets.functions.register("UcharcatLuaOne",function()
+% chr = newtoken.scan_int()
+% cct = tex.getcatcode(chr)
+% tex.setcatcode(chr,newtoken.scan_int())
+% tex.sprint(unicode.utf8.char(chr))
+% end)
+%
+% gadgets.functions.register("UcharcatLuaTwo",function()
+% tex.setcatcode(chr,cct)
+% end)
+%
+% }
+%
+% \def\Ucharcat
+% {\expandafter\expandafter\expandafter\luafunction
+% \expandafter\expandafter\expandafter\UcharcatLuaTwo
+% \luafunction\UcharcatLuaOne}
+%
+% A:\the\catcode65:\Ucharcat 65 11:A:\the\catcode65\par
+% A:\the\catcode65:\Ucharcat 65 5:A:\the\catcode65\par
+% A:\the\catcode65:\Ucharcat 65 11:A:\the\catcode65\par
+
+
\endinput