From: Hironori Kitagawa Date: Sat, 20 Aug 2022 10:51:38 +0000 (+0900) Subject: use tex.getnest() X-Git-Tag: 20221002.0~9^2~11 X-Git-Url: http://git.osdn.net/view?p=luatex-ja%2Fluatexja.git;a=commitdiff_plain;h=1e0cf129cf1768e5dd982ccf43af8ca9e6701659 use tex.getnest() --- diff --git a/src/ltj-direction.lua b/src/ltj-direction.lua index c564f87..2796d88 100644 --- a/src/ltj-direction.lua +++ b/src/ltj-direction.lua @@ -44,6 +44,7 @@ local id_whatsit = node.id 'whatsit' local sid_save = node.subtype 'pdf_save' local sid_user = node.subtype 'user_defined' +local getnest = tex.getnest local tex_nest = tex.nest local tex_getcount = tex.getcount local ensure_tex_attr = ltjb.ensure_tex_attr @@ -110,7 +111,7 @@ do end function get_dir_count() for i=tex_nest.ptr, 1, -1 do - local h = tex_nest[i].head.next + local h = getnest(i).head.next if h then local t = get_dir_count_inner(h) if t~=0 then return t end @@ -120,7 +121,7 @@ do end function get_adjust_dir_count() for i=tex_nest.ptr, 1, -1 do - local v = tex_nest[i] + local v = getnest(i) local h, m = v.head.next, v.mode if abs(m)== ltjs.vmode and h then local t = get_dir_count_inner(h) @@ -174,21 +175,20 @@ do local node_next_node, node_tail_node = node.next, node.tail local insert_after_node = node.insert_after function luatexja.direction.set_list_direction_hook(v) - local lv = tex_nest.ptr -- must be >= 1 if not v then v = get_dir_count() - if abs(tex_nest[lv-1].mode) == ltjs.mmode and v == dir_tate then + if abs(getnest(tex_nest.ptr-1).mode) == ltjs.mmode and v == dir_tate then v = dir_utod end elseif v=='adj' then v = get_adjust_dir_count() end - local h = tex_nest[lv].head + local h = getnest().head local hn = node.next(h) hn = (hn and hn.id==id_local) and hn or h local w = to_node(dir_pool[v]()) insert_after_node(h, hn, w) - tex_nest[lv].tail = node_tail_node(w) + getnest().tail = node_tail_node(w) ensure_tex_attr(attr_icflag, 0) ensure_tex_attr(attr_dir, 0) end @@ -197,13 +197,13 @@ do local lv = tex_nest.ptr if not v then v,name = get_dir_count(), nil - if lv>=1 and abs(tex_nest[lv-1].mode) == ltjs.mmode and v == dir_tate then + if lv>=1 and abs(getnest(lv-1).mode) == ltjs.mmode and v == dir_tate then v = dir_utod end elseif v=='adj' then v,name = get_adjust_dir_count(), nil end - local current_nest = tex_nest[lv] + local current_nest = getnest() if tex.currentgrouptype==6 then ltjb.package_error( 'luatexja', @@ -723,9 +723,9 @@ do local id_glue = node.id 'glue' local function lastbox_hook() start_time_measure 'box_primitive_hook' - local bn = tex_nest[tex_nest.ptr].tail + local bn = getnest().tail if bn then - local b, head = to_direct(bn), to_direct(tex_nest[tex_nest.ptr].head) + local b, head = to_direct(bn), to_direct(getnest().head) local bid = getid(b) if bid==id_hlist or bid==id_vlist then local p = getlist(b) @@ -740,7 +740,7 @@ do if box_dir>= dir_node_auto then -- unwrap dir_node local p = node_prev(b) local dummy1, dummy2, nb = unwrap_dir_node(b, nil, box_dir) - setnext(p, nb); tex_nest[tex_nest.ptr].tail = to_node(nb) + setnext(p, nb); getnest().tail = to_node(nb) setnext(b, nil); setlist(b, nil) node_free(b); b = nb end @@ -941,7 +941,7 @@ do function luatexja.direction.check_adjust_direction() start_time_measure 'box_primitive_hook' local list_dir = get_adjust_dir_count() - local a = tex_nest[tex_nest.ptr].tail + local a = getnest().tail local ad = to_direct(a) if a and getid(ad)==id_adjust then local adj_dir = get_box_dir(ad) @@ -964,7 +964,7 @@ do function luatexja.direction.populate_insertion_dir_whatsit() start_time_measure 'box_primitive_hook' local list_dir = get_dir_count() - local a = tex_nest[tex_nest.ptr].tail + local a = getnest().tail local ad = to_direct(a) if (not a) or getid(ad)~=id_ins then a = node.tail(tex.lists.page_head); ad = to_direct(a) diff --git a/src/ltj-jfmglue.lua b/src/ltj-jfmglue.lua index c74e2c3..30ed118 100644 --- a/src/ltj-jfmglue.lua +++ b/src/ltj-jfmglue.lua @@ -1380,7 +1380,7 @@ do local attr_yablshift = luatexbase.attributes['ltj@yablshift'] local attr_tablshift = luatexbase.attributes['ltj@tablshift'] local getcount, abs, scan_keyword = tex.getcount, math.abs, token.scan_keyword - local tex_nest = tex.nest + local getnest = tex.getnest local tex_getattr = tex.getattribute local get_current_jfont do @@ -1398,7 +1398,7 @@ do -- * (X)KANJI_SKIP(_JFM): その場で値が決まっている -- * PROCESSED_BEGIN_FLAG + (X)KANJI_SKIP: 段落終了時に決める local function insert_k_skip_common(ind, name, ica, icb) - if abs(tex_nest[tex_nest.ptr].mode) ~= ltjs.hmode then return end + if abs(getnest().mode) ~= ltjs.hmode then return end local g = node_new(id_glue); set_attr(g, attr_icflag, SPECIAL_JAGLUE) local is_late = scan_keyword("late") if not is_late then diff --git a/src/ltj-jfont.lua b/src/ltj-jfont.lua index 8f382cd..6511a48 100644 --- a/src/ltj-jfont.lua +++ b/src/ltj-jfont.lua @@ -1015,12 +1015,12 @@ do local is_ucs_in_japanese_char = ltjc.is_ucs_in_japanese_char_direct local ensure_tex_attr = ltjb.ensure_tex_attr local node_write = node.direct.write - local fonts, tex_nest = font.fonts, tex.nest + local fonts, getnest = font.fonts, tex.getnest local new_ic_kern = function(g) return node_new(id_kern,3) end local dir_tate = luatexja.dir_table.dir_tate -- EXT: italic correction function luatexja.jfont.append_italic() - local p = to_direct(tex_nest[tex_nest.ptr].tail) + local p = to_direct(getnest().tail) local TEMP = node_new(id_kern) if p and getid(p)==id_glyph then if is_ucs_in_japanese_char(p) then diff --git a/src/ltj-lineskip.lua b/src/ltj-lineskip.lua index 65a2d81..010e4df 100644 --- a/src/ltj-lineskip.lua +++ b/src/ltj-lineskip.lua @@ -83,7 +83,7 @@ local make_dir_whatsit = luatexja.direction.make_dir_whatsit local get_dir_count = luatexja.direction.get_dir_count local getwhd = node.direct.getwhd local setnext = node.direct.setnext -local tex_nest = tex.nest +local getnest = tex.getnest local function dir_adjust_append_vlist(b, loc, prev, mirrored) local old_b = to_direct(b) @@ -94,7 +94,7 @@ local function dir_adjust_append_vlist(b, loc, prev, mirrored) local bw = texget('baselineskip', false) local normal = bw - prev - (mirrored and dp or ht) local lmin, adj = nil, 0 - local tail = to_direct(tex_nest[tex_nest.ptr].tail) + local tail = to_direct(getnest().tail) if p_dummy~=ltj_profiler then while tail and (id_glue<=getid(tail)) and (getid(tail)<=id_penalty) do tail = node_prev(tail) diff --git a/src/ltj-stack.lua b/src/ltj-stack.lua index 5b15f26..e25dbc0 100644 --- a/src/ltj-stack.lua +++ b/src/ltj-stack.lua @@ -3,7 +3,7 @@ -- luatexbase.provides_module({ name = 'luatexja.stack', - date = '2022-08-17', + date = '2022-08-20', description = 'LuaTeX-ja stack system', }) luatexja.stack = {} @@ -20,7 +20,7 @@ local STCK = luatexja.userid_table.STCK local fastcopy = table.fastcopy local setcount, getcount = tex.setcount, tex.getcount local scan_int, scan_keyword = token.scan_int, token.scan_keyword -local tex_nest = tex.nest +local getnest = tex.getnest ltjs.hmode = 0 -- dummy local charprop_stack_table={} @@ -42,7 +42,7 @@ local function get_stack_level() charprop_stack_table[i] = fastcopy(charprop_stack_table[i-1]) setcount('ltj@@stack', i) if gd~=0 then tex.globaldefs = gd end - if tex_nest[tex_nest.ptr].mode == -ltjs.hmode then -- rest. hmode のみ + if getnest().mode == -ltjs.hmode then -- rest. hmode のみ local g = node_new(id_whatsit, sid_user) g.user_id=STCK; g.type=100; g.value=j; node.write(g) end diff --git a/src/luatexja-core.sty b/src/luatexja-core.sty index 2e9b10d..60e2835 100644 --- a/src/luatexja-core.sty +++ b/src/luatexja-core.sty @@ -303,12 +303,12 @@ \setbox\z@\hbox{% \directlua{% This value depends on the version of LuaTeX. - luatexja.stack.hmode = -tex.nest[tex.nest.ptr].mode + luatexja.stack.hmode = -tex.getnest().mode }% } \setbox\z@\vbox{% \directlua{% This value depends on the version of LuaTeX. - luatexja.stack.vmode = -tex.nest[tex.nest.ptr].mode + luatexja.stack.vmode = -tex.getnest().mode }% } \setbox\z@\box\voidb@x @@ -631,7 +631,7 @@ \setbox\z@\hbox{% \primitive\everymath{}% $\directlua{% This value depends on the version of LuaTeX. - luatexja.stack.mmode = -tex.nest[tex.nest.ptr].mode + luatexja.stack.mmode = -tex.getnest().mode }$% } \setbox\z@\box\voidb@x diff --git a/src/luatexja.lua b/src/luatexja.lua index 395a5eb..f6f9622 100644 --- a/src/luatexja.lua +++ b/src/luatexja.lua @@ -250,7 +250,7 @@ do end, direction = function() local v = ltjd.get_dir_count() - if math.abs(tex.nest[tex.nest.ptr].mode) == ltjs.mmode and v == dir_table.dir_tate then + if math.abs(tex.getnest().mode) == ltjs.mmode and v == dir_table.dir_tate then v = dir_table.dir_utod end return v @@ -378,13 +378,14 @@ end -- lastnodechar do + local getnest = tex.getnest local id_glyph = node.id('glyph') function luatexja.pltx_composite_last_node_char() - local n = tex.nest[tex.nest.ptr].tail + local n = getnest() local r = '-1' if n then if n.id==id_glyph then - while n.componetns and n.subtype and n.subtype%4 >= 2 do + while n.components and n.subtype and n.subtype%4 >= 2 do n = node.tail(n) end r = tostring(n.char)