From 7580c9a6e0c81a9613a9be839195102cbaf419f0 Mon Sep 17 00:00:00 2001 From: Hironori Kitagawa Date: Wed, 24 Aug 2022 06:09:11 +0900 Subject: [PATCH] use node.direct.{g/s}etdata --- src/ltj-adjust.lua | 8 +++++--- src/ltj-base.sty | 2 +- src/ltj-debug.lua | 4 ++-- src/ltj-direction.lua | 39 ++++++++++++++++++--------------------- src/ltj-jfmglue.lua | 29 ++++++++++++++++------------- src/ltj-jfont.lua | 4 ++-- src/ltj-lineskip.lua | 2 -- src/ltj-math.lua | 2 +- src/ltj-otf.lua | 7 ++++--- src/ltj-pretreat.lua | 27 +++++++++++++++------------ src/ltj-rmlgbm.lua | 4 ++-- src/ltj-ruby.lua | 35 ++++++++++++++++++----------------- src/luatexja-core.sty | 2 +- src/luatexja.lua | 32 ++++++++++++++++---------------- 14 files changed, 101 insertions(+), 96 deletions(-) diff --git a/src/ltj-adjust.lua b/src/ltj-adjust.lua index af5c5ca..568e123 100644 --- a/src/ltj-adjust.lua +++ b/src/ltj-adjust.lua @@ -562,13 +562,15 @@ do local sid_user = node.subtype 'user_defined' local node_remove = node.direct.remove local node_write = node.direct.write + local getvalue = node.direct.getdata + local setvalue = node.direct.setdata local GHOST_JACHAR = luatexbase.newuserwhatsitid('ghost of a jachar', 'luatexja') luatexja.userid_table.GHOST_JACHAR = GHOST_JACHAR function ltja.create_ghost_jachar_node(cl) local tn = node_new(id_whatsit, sid_user) setfield(tn, 'user_id', GHOST_JACHAR) setfield(tn, 'type', 100) - setfield(tn, 'value', cl) + setvalue(tn, cl) node_write(tn) end local attr_curjfnt = luatexbase.attributes['ltj@curjfnt'] @@ -585,7 +587,7 @@ do if Np and Np.nuc then return Np elseif Np and getfield(lp, 'user_id') == GHOST_JACHAR then Np.first = lp; Np.nuc = lp; Np.last = lp; Np.class = 0 - if getfield(lp,'value')<2 then + if getvalue(lp)<2 then if Nq and Nq.met then Np.met = Nq.met; else Np.met = get_current_metric(lp) end Np.pre = 0; Np.post = 0; Np.xspc = 3 else Np.met, Np.pre = nil, nil; end @@ -598,7 +600,7 @@ do if not s and getfield(Nq.nuc, 'user_id') == GHOST_JACHAR then local x, y = node_prev(Nq.nuc), Nq.nuc Nq.first, Nq.nuc, Nq.last = x, x, x - if getfield(y,'value')%2==0 then + if getvalue(y)%2==0 then if Np and Nq.met then Nq.met = Np.met; else Nq.met = get_current_metric(y) end Nq.pre = 0; Nq.post = 0; Nq.xspc = 3 else Nq.met, Nq.pre = nil, nil; end diff --git a/src/ltj-base.sty b/src/ltj-base.sty index d46b54a..ba88ec9 100644 --- a/src/ltj-base.sty +++ b/src/ltj-base.sty @@ -20,9 +20,9 @@ %% Registers %\newcount\ltj@tempcnta % defined at luatexja-core.sty +%\newcount\ltj@tempdima % defined at luatexja-core.sty \newcount\ltj@tempcntb \newcount\ltj@tempcntc -\newdimen\ltj@tempdima % \newskip\ltj@tempskipa unused % \newtoks\ltj@temptoks unused diff --git a/src/ltj-debug.lua b/src/ltj-debug.lua index b9ebcae..9122426 100644 --- a/src/ltj-debug.lua +++ b/src/ltj-debug.lua @@ -105,7 +105,7 @@ do end local function print_measure() - stop_time_measure('RUN') + stop_time_measure 'RUN' local temp = {} for i,v in pairs(time_stat) do temp[#temp+1] = { i, v[1], v[2], v[2]/v[1] } @@ -123,7 +123,7 @@ do luatexbase.add_to_callback('stop_run', print_measure, 'luatexja.time_measure', 1) luatexbase.add_to_callback('pre_linebreak_filter', function(p) - start_time_measure('tex_linebreak'); return p + start_time_measure 'tex_linebreak'; return p end, 'measure_tex_linebreak', 20000) end diff --git a/src/ltj-direction.lua b/src/ltj-direction.lua index 1a7364a..5321f23 100644 --- a/src/ltj-direction.lua +++ b/src/ltj-direction.lua @@ -22,10 +22,12 @@ local getsubtype = dnode.getsubtype local getlist = dnode.getlist local getfield = dnode.getfield local getwhd = dnode.getwhd +local getvalue = node.direct.getdata local setfield = dnode.setfield local setwhd = dnode.setwhd local setnext = dnode.setnext local setlist = dnode.setlist +local setvalue = node.direct.setdata local node_new = dnode.new local node_free = dnode.flush_node or dnode.free @@ -614,8 +616,7 @@ local function unwrap_dir_node(b, head, box_dir) end local shift_old, b_dir, wh = nil, get_box_dir(bh, 0) if wh then - dnode.flush_list(getfield(wh, 'value')) - setfield(wh, 'value', nil) + dnode.flush_list(getvalue(wh)); setvalue(wh, nil) end return nh, nb, bh, b_dir end @@ -664,8 +665,7 @@ do -- dir_node としてカプセル化されている local _, dnc = get_box_dir(b, 0) if dnc then -- free all other dir_node - dnode.flush_list(getfield(dnc, 'value')) - setfield(dnc, 'value', nil) + dnode.flush_list(getvalue(dnc)); setvalue(dnc, nil) end set_attr(b, attr_dir, box_dir%dir_math_mod + dir_node_auto) return head, node_next(b), b, true @@ -687,15 +687,14 @@ do end box_dir = box_dir%dir_math_mod local db - local dnh = getfield(dn, 'value') + local dnh = getvalue(dn) for x in traverse(dnh) do if get_attr(x, attr_dir)%dir_math_mod == new_dir then - setfield(dn, 'value', to_node(node_remove(dnh, x))) + setvalue(dn, to_node(node_remove(dnh, x))) db=x; break end end - dnode.flush_list(getfield(dn, 'value')) - setfield(dn, 'value', nil) + dnode.flush_list(getvalue(dn)); setvalue(dn, nil) db = db or create_dir_node(b, box_dir, new_dir, false) local w, h, d = getwhd(b) nh, nb = insert_before(head, b, db), nil @@ -747,8 +746,7 @@ do end local _, wh = get_box_dir(b, 0) -- clean dir_node attached to the box if wh then - dnode.flush_list(getfield(wh, 'value')) - setfield(wh, 'value', nil) + dnode.flush_list(getvalue(wh)); setvalue(wh, nil) end end end @@ -762,25 +760,25 @@ end -- \wd, \ht, \dp の代わり do local getbox, setdimen = tex.getbox, tex.setdimen + local ltj_tempdima = luatexbase.registernumber 'ltj@tempdima' local function get_box_dim_common(key, s, l_dir) -- s: not dir_node. local s_dir, wh = get_box_dir(s, dir_yoko) s_dir = s_dir%dir_math_mod if s_dir ~= l_dir then local not_found = true - for x in traverse(getfield(wh, 'value')) do + for x in traverse(getvalue(wh)) do if l_dir == get_attr(x, attr_dir)%dir_node_auto then - setdimen('ltj@tempdima', getfield(x, key)) + setdimen(ltj_tempdima, getfield(x, key)) not_found = false; break end end if not_found then local w, h, d = getwhd(s) - setdimen('ltj@tempdima', - dir_node_aux[s_dir][l_dir][key](w,h,d)) + setdimen(ltj_tempdima, dir_node_aux[s_dir][l_dir][key](w,h,d)) end else - setdimen('ltj@tempdima', getfield(s, key)) + setdimen(ltj_tempdima, getfield(s, key)) end end local function get_box_dim(key, n) @@ -793,12 +791,12 @@ do if b_dir=3 @@ -688,7 +689,7 @@ local function post_high_hbox(ahead) rs[1], rw = ha, nil; ha = node_next(ha) elseif i==2 then rw = ha - cmp = getfield(getfield(rw, 'value'), 'value').count + cmp = getvalue(getvalue(rw)).count head, ha = node_remove(head, rw) else -- i >= 3 rs[#rs+1] = ha; ha = node_next(ha) @@ -712,8 +713,8 @@ do if Np.nuc then return Np elseif getfield(lp, 'user_id') == RUBY_PRE then Np.first, Np.nuc, Np.last = lp, lp, lp - local lpv = getfield(lp, 'value') - local rst = getfield(lpv, 'value') + local lpv = getvalue(lp) + local rst = getvalue(lpv) local x = node_next(node_next(lpv)) Np.last_char = luatexja.jfmglue.check_box_high(Np, getlist(x), nil) if Nq.id ~=id_pbox_w then @@ -779,8 +780,8 @@ do Np.first = last_glue next_cluster_array[Nq.nuc] = last_glue -- ルビ処理用のグルー end - local nqnv = getfield(Nq.nuc, 'value') - local rst = getfield(nqnv, 'value') + local nqnv = getvalue(Nq.nuc) + local rst = getvalue(nqnv) if Nq.gk then if type(Nq.gk)=="table" then for _,v in ipairs(Nq.gk) do add_gk(rst, 'before_jfmgk', v) end @@ -799,11 +800,11 @@ do end rst.post = p end - Np.prev_ruby = get_attr(getfield(Nq.nuc, 'value'), attr_ruby_id) + Np.prev_ruby = get_attr(getvalue(Nq.nuc), attr_ruby_id) -- 前のクラスタがルビであったことのフラグ else -- 直前が文字以外 - local nqnv = getfield(Nq.nuc, 'value') - local rst = getfield(nqnv, 'value') + local nqnv = getvalue(Nq.nuc) + local rst = getvalue(nqnv) if rst.post < 0 then -- auto rst.post = 0 end @@ -817,7 +818,7 @@ do "luatexja.ruby.np_info_after", 1) local function w (s, Nq, Np) if not s and getfield(Nq.nuc, 'user_id') == RUBY_PRE then - local rst = getfield(getfield(Nq.nuc, 'value'), 'value') + local rst = getvalue(getvalue(Nq.nuc)) if Np.gk then if type(Np.gk)=="table" then for _,v in ipairs(Np.gk) do add_gk(rst, 'after_jfmgk', v) end diff --git a/src/luatexja-core.sty b/src/luatexja-core.sty index b498551..cb14e9e 100644 --- a/src/luatexja-core.sty +++ b/src/luatexja-core.sty @@ -147,7 +147,7 @@ \ltj@curjfnt\m@ne \ltj@curtfnt\m@ne -\newcount\ltj@tempcnta +\newcount\ltj@tempcnta\newdimen\ltj@tempdima \newcount\ltj@@stack \newcount\ltj@@group@level \ltj@@group@level\z@\ltj@@stack\z@ diff --git a/src/luatexja.lua b/src/luatexja.lua index 4c504dc..8134976 100644 --- a/src/luatexja.lua +++ b/src/luatexja.lua @@ -135,7 +135,7 @@ if tex.outputmode==0 then 'Use lua*tex instead dvilua*tex.') end load_module 'rmlgbm'; local ltjr = luatexja.rmlgbm -- must be 1st -if luatexja_debug then load_module('debug') end +if luatexja_debug then load_module 'debug' end load_module 'lotf_aux'; local ltju = luatexja.lotf_aux load_module 'charrange'; local ltjc = luatexja.charrange load_module 'stack'; local ltjs = luatexja.stack @@ -267,7 +267,7 @@ do if unary_pars[k] then texwrite(tostring(unary_pars[k](getcount(cnt_stack)))) end - ltjb.stop_time_measure('get_par') + ltjb.stop_time_measure 'get_par' end end @@ -322,7 +322,7 @@ do if binary_pars[k] then texwrite(tostring(binary_pars[k](c, getcount(cnt_stack)))) end - ltjb.stop_time_measure('get_par') + ltjb.stop_time_measure 'get_par' end end @@ -346,10 +346,10 @@ do ensure_tex_attr(attr_icflag, 0) if gc == 'fin_row' then return head else - start_time_measure('jfmglue') + start_time_measure 'jfmglue' slide(head); local p = ltjj.main(to_direct(head),mode, dir) - stop_time_measure('jfmglue') + stop_time_measure 'jfmglue' return to_node(p) end end @@ -381,7 +381,7 @@ end -- lastnodechar do local getnest = tex.getnest - local id_glyph = node.id('glyph') + local id_glyph = node.id 'glyph' function luatexja.pltx_composite_last_node_char() local n = getnest() local r = '-1' @@ -421,16 +421,16 @@ local node_type = node.type local node_next = node.next local get_attr = node.get_attribute -local id_penalty = node.id('penalty') -local id_glyph = node.id('glyph') -local id_glue = node.id('glue') -local id_kern = node.id('kern') -local id_hlist = node.id('hlist') -local id_vlist = node.id('vlist') -local id_rule = node.id('rule') -local id_math = node.id('math') -local id_whatsit = node.id('whatsit') -local sid_user = node.subtype('user_defined') +local id_penalty = node.id 'penalty' +local id_glyph = node.id 'glyph' +local id_glue = node.id 'glue' +local id_kern = node.id 'kern' +local id_hlist = node.id 'hlist' +local id_vlist = node.id 'vlist' +local id_rule = node.id 'rule' +local id_math = node.id 'math' +local id_whatsit = node.id 'whatsit' +local sid_user = node.subtype 'user_defined' local prefix, inner_depth local utfchar = utf.char -- 2.11.0