OSDN Git Service

more use of \luadef
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Wed, 1 Apr 2020 01:29:40 +0000 (10:29 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Wed, 1 Apr 2020 01:29:40 +0000 (10:29 +0900)
src/luatexja-core.sty
src/luatexja.lua
src/patches/lltjfont.sty
src/patches/lltjp-unicode-math.sty

index d870df0..daab9b1 100644 (file)
   {\ltj@@getparam@two{#1}}%
   {\ltj@@getparam@one{#1}}%
 }
-\def\ltj@@getparam@one#1{%
-  \directlua{luatexja.ext_get_parameter_unary('#1')}%
-}%
+\newluafunction\ltj@@getparam@one@inner
+\directlua{
+  local t = lua.get_functions_table()
+  t[\the\ltj@@getparam@one@inner] = luatexja.ext_get_parameter_unary
+}
+\luadef\ltj@@getparam@one\ltj@@getparam@one@inner
 \def\ltj@@getparam@two#1#2{%
   \directlua{luatexja.ext_get_parameter_binary('#1', \ltj@safe@num@or{nil}{#2})}%
 }
     end
   end
 }
-\protected\def\ltj@alljachar{\luafunction\ltj@alljachar@inner}
+\protected\luadef\ltj@alljachar\ltj@alljachar@inner
 \protected\def\ltj@allalchar{\relax
     \csname ltj@kcat0\endcsname="7FFFFFFF %"
     \csname ltj@kcat1\endcsname="7FFFFFFF %"
 
 %%%% insert
 \let\orig@insert=\insert
+\newluafunction\ltj@@lua@populate@insertwhatsit@inner
+\directlua{
+  local t = lua.get_functions_table()
+  t[\the\ltj@@lua@populate@insertwhatsit@inner]
+    = luatexja.direction.populate_insertion_dir_whatsit
+}
+\luadef\ltj@@lua@populate@insertwhatsit\ltj@@lua@populate@insertwhatsit@inner
 \protected\def\insert{\begingroup\afterassignment\ltj@@insert@A\ltj@tempcnta}
 \protected\def\ltj@@insert@A{\orig@insert\ltj@tempcnta\bgroup
   \aftergroup\ltj@@insert@B\let\ltj@@next}
-\protected\def\ltj@@insert@B{\directlua{luatexja.direction.populate_insertion_dir_whatsit()}\endgroup}
+\protected\def\ltj@@insert@B{\ltj@@lua@populate@insertwhatsit\endgroup}
 
 %%%% vadjust
 \let\ltj@@orig@vadjust=\vadjust
   \newluafunction\ltj@@box@dirhook
   \directlua{
     local t, ltjd = lua.get_functions_table(), luatexja.direction
-    t[\the\ltj@@box@dirhook] 
+    t[\the\ltj@@box@dirhook]
       = function() ltjd.set_list_direction_hook() end
   }
   \PushPreHook{hbox}{\luafunction\ltj@@box@dirhook\aftergroup\ltj@@reset@badness}
 \AtBeginShipout{\directlua{luatexja.direction.finalize()}}
 
 %%%% \raise, \lower, \moveleft, \moveright
+\newluafunction\ltj@@lua@raisebox@inner
+\directlua{
+  local t = lua.get_functions_table()
+  t[\the\ltj@@lua@raisebox@inner]=luatexja.direction.raise_box
+}
+\protected\luadef\ltj@@lua@raisebox\ltj@@lua@raisebox@inner
 \let\ltj@@orig@raise=\raise
 \let\ltj@@orig@lower=\lower
 \protected\def\raise{\ltj@reset@globaldefs\afterassignment\ltj@@raise\ltj@tempdima}
 \protected\def\ltj@@raise{%
   \ltj@restore@globaldefs
   \edef\ltj@@raise@a{%
-    \noexpand\directlua{luatexja.direction.raise_box()}%
-    \ltj@@orig@raise\the\ltj@tempdima\noexpand\box\ltj@afbox
+    \ltj@@lua@raisebox\ltj@@orig@raise\the\ltj@tempdima\noexpand\box\ltj@afbox
   }\ltj@afterbox\ltj@@raise@a}
 \let\ltj@@orig@moveleft=\moveleft
 \let\ltj@@orig@moveright=\moveright
 \protected\def\ltj@@moveleft{%
   \ltj@restore@globaldefs
   \edef\ltj@@moveleft@a{%
-    \noexpand\directlua{luatexja.direction.raise_box()}%
-    \ltj@@orig@moveleft\the\ltj@tempdima\noexpand\box\ltj@afbox
+    \ltj@@lua@raisebox\ltj@@orig@moveleft\the\ltj@tempdima\noexpand\box\ltj@afbox
   }\ltj@afterbox\ltj@@moveleft@a}
 
 %%%%\vsplit
 \let\ltj@@orig@vcenter=\vcenter
 \protected\def\vcenter{\ltj@afterbox\ltj@@vcenter\vbox}
 \protected\def\ltj@@vcenter{%
-  \directlua{luatexja.direction.raise_box()}%
-  \ltj@@orig@vcenter{\box\ltj@afbox}%
+  \ltj@@lua@raisebox\ltj@@orig@vcenter{\box\ltj@afbox}%
 }
 
 %%%% \unhbox and \unvbox
+\newluafunction\ltj@@lua@unboxcheckdir@inner
+\directlua{
+  local t = lua.get_functions_table()
+  t[\the\ltj@@lua@unboxcheckdir@inner]=luatexja.direction.unbox_check_dir
+}
+\luadef\ltj@@lua@unboxcheckdir\ltj@@lua@unboxcheckdir@inner
 \long\def \@gobbletwo #1#2{}
 \let\ltj@@orig@unhbox=\unhbox
 \let\ltj@@orig@unvbox=\unvbox
 \protected\def\unhbox{\ltj@reset@globaldefs\afterassignment\ltj@@unhbox\ltj@tempcnta}
 \protected\def\unvbox{\ltj@reset@globaldefs\afterassignment\ltj@@unvbox\ltj@tempcnta}
 \protected\def\ltj@@unhbox{%
-  \directlua{luatexja.direction.unbox_check_dir()}%
-  \ltj@@orig@unhbox\ltj@tempcnta}
+  \ltj@@lua@unboxcheckdir\ltj@@orig@unhbox\ltj@tempcnta}
 \protected\def\ltj@@unvbox{%
-  \directlua{luatexja.direction.unbox_check_dir()}%
-  \ltj@@orig@unvbox\ltj@tempcnta}
+  \ltj@@lua@unboxcheckdir\ltj@@orig@unvbox\ltj@tempcnta}
 \let\ltj@@orig@unhcopy=\unhcopy
 \let\ltj@@orig@unvcopy=\unvcopy
 \protected\def\unhcopy{\ltj@reset@globaldefs\afterassignment\ltj@@unhcopy\ltj@tempcnta}
index 767659a..df1b57d 100644 (file)
@@ -232,7 +232,9 @@ do
    }
 
    local unary_pars = luatexja.unary_pars
-   function luatexja.ext_get_parameter_unary(k)
+   local scan_arg = token.scan_argument
+   function luatexja.ext_get_parameter_unary()
+      local k= scan_arg()
       if unary_pars[k] then
         tex.write(tostring(unary_pars[k](tex.getcount('ltj@@stack'))))
       end
@@ -289,9 +291,9 @@ do
       end,
    }
    local binary_pars = luatexja.binary_pars
-
+   local scan_arg, scan_int = token.scan_argument, token.scan_int
    binary_pars.alxspmode = binary_pars.jaxspmode
-   function luatexja.ext_get_parameter_binary(k,c)
+   function luatexja.ext_get_parameter_binary(k, c)
       if binary_pars[k] then
         tex.write(tostring(binary_pars[k](c,tex.getcount('ltj@@stack'))))
       end
index a218bbe..59684f5 100644 (file)
 \def\use@mathgroup#1#2{\relax\ifmmode
   \math@bgroup
     \expandafter\ifx\csname M@\f@encoding\endcsname#1\else
-    #1\fi\ltj@tempcnta=#2 \expandafter\ltj@@mathJapaneseFonts\string#1\relax%
+    #1\fi\ltj@tempcnta=#2
+       \expandafter\ltj@@mathJapaneseFonts\string#1/\relax%
     \ifin@\jfam#2\relax\else\mathgroup#2\relax\fi
   \expandafter\math@egroup\fi}%
 
index d8c4055..79ba8cb 100644 (file)
 \unless\ifltj@disablejfam
 \cs_set:Npn \use@mathgroup #1 #2
 {
-  %\typeout{UM <#1><#2>}
   \mode_if_math:T % <- not sure
    {
     \math@bgroup
       \cs_if_eq:cNF {M@\f@encoding} #1 {#1}
       \__um_switchto_literal:
-      \ltj@tempcnta=#2 \expandafter\ltj@@mathJapaneseFonts\string#1\relax%
+      \ltj@tempcnta=#2 \expandafter\ltj@@mathJapaneseFonts\string#1/\relax%
       \ifin@ \jfam #2 \relax \else \mathgroup #2 \relax \fi
     \math@egroup
    }