diff options
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/lua/luanode.w')
-rw-r--r-- | Build/source/texk/web2c/luatexdir/lua/luanode.w | 112 |
1 files changed, 50 insertions, 62 deletions
diff --git a/Build/source/texk/web2c/luatexdir/lua/luanode.w b/Build/source/texk/web2c/luatexdir/lua/luanode.w index a9da3cb1c34..c1da8f2d1ca 100644 --- a/Build/source/texk/web2c/luatexdir/lua/luanode.w +++ b/Build/source/texk/web2c/luatexdir/lua/luanode.w @@ -18,47 +18,15 @@ % with LuaTeX; if not, see <http://www.gnu.org/licenses/>. /* hh-ls: we make sure that lua never sees prev of head but also that when -nodes are removedor inserted, temp nodes don't interfere */ +nodes are removed or inserted, temp nodes don't interfere */ @ @c - #include "ptexlib.h" #include "lua/luatex-api.h" -/* TO BE REMOVED -static const char *group_code_names[] = { - "", - "simple", - "hbox", - "adjusted_hbox", - "vbox", - "vtop", - "align", - "no_align", - "output", - "math", - "disc", - "insert", - "vcenter", - "math_choice", - "semi_simple", - "math_shift", - "math_left", - "local_box", - "split_off", - "split_keep", - "preamble", - "align_set", - "fin_row" -}; - -const char *pack_type_name[] = { "exactly", "additional" }; -*/ - @ @c -void -lua_node_filter_s(int filterid, int extrainfo) +void lua_node_filter_s(int filterid, int extrainfo) { lua_State *L = Luas; int callback_id = callback_defined(filterid); @@ -82,10 +50,8 @@ lua_node_filter_s(int filterid, int extrainfo) return; } - @ @c -void -lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword * tail_node) +void lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword * tail_node) { halfword ret; int a; @@ -134,8 +100,7 @@ lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword * tail } @ @c -int -lua_linebreak_callback(int is_broken, halfword head_node, halfword * new_head) +int lua_linebreak_callback(int is_broken, halfword head_node, halfword * new_head) { int a; register halfword *p; @@ -160,7 +125,6 @@ lua_linebreak_callback(int is_broken, halfword head_node, halfword * new_head) error(); return ret; } - p = lua_touserdata(L, -1); if (p != NULL) { a = nodelist_from_lua(L); @@ -171,12 +135,48 @@ lua_linebreak_callback(int is_broken, halfword head_node, halfword * new_head) return ret; } - +@ @c +int lua_appendtovlist_callback(halfword box, int location, halfword prev_depth, boolean is_mirrored, halfword * result, int * next_depth, boolean * prev_set) +{ + register halfword *p; + lua_State *L = Luas; + int s_top = lua_gettop(L); + int callback_id = callback_defined(append_to_vlist_filter_callback); + if (box == null || callback_id <= 0) { + lua_settop(L, s_top); + return 0; + } + if (!get_callback(L, callback_id)) { + lua_settop(L, s_top); + return 0; + } + nodelist_to_lua(L, box); + lua_push_string_by_index(L,location); + lua_pushnumber(L, (int) prev_depth); + lua_pushboolean(L, is_mirrored); + if (lua_pcall(L, 4, 2, 0) != 0) { + fprintf(stdout, "error: %s\n", lua_tostring(L, -1)); + lua_settop(L, s_top); + error(); + return 0; + } + if (lua_type(L,-1) == LUA_TNUMBER) { + *next_depth = lua_tonumber(L,-1); + *prev_set = true; + if (lua_type(L, -2) != LUA_TNIL) { + p = check_isnode(L, -2); + *result = *p; + } + } else if (lua_type(L, -1) != LUA_TNIL) { + p = check_isnode(L, -1); + *result = *p; + } + lua_settop(L, s_top); + return 1; +} @ @c -halfword -lua_hpack_filter(halfword head_node, scaled size, int pack_type, int extrainfo, - int pack_direction) +halfword lua_hpack_filter(halfword head_node, scaled size, int pack_type, int extrainfo, int pack_direction) { halfword ret; lua_State *L = Luas; @@ -224,8 +224,7 @@ lua_hpack_filter(halfword head_node, scaled size, int pack_type, int extrainfo, } @ @c -halfword -lua_vpack_filter(halfword head_node, scaled size, int pack_type, scaled maxd, +halfword lua_vpack_filter(halfword head_node, scaled size, int pack_type, scaled maxd, int extrainfo, int pack_direction) { halfword ret; @@ -283,7 +282,6 @@ lua_vpack_filter(halfword head_node, scaled size, int pack_type, scaled maxd, return ret; } - @ This is a quick hack to fix etex's \.{\\lastnodetype} now that there are many more visible node types. TODO: check the eTeX manual for the expected return values. @@ -292,20 +290,12 @@ lua_vpack_filter(halfword head_node, scaled size, int pack_type, scaled maxd, int visible_last_node_type(int n) { int i = type(n); - if (i == whatsit_node && subtype(n) == local_par_node) - return -1; - if (i == glyph_node) { - if (is_ligature(n)) - return 7; /* old ligature value */ - else - return 0; /* old character value */ - } - if (i <= unset_node) { - return i + 1; - } else if (i <= delim_node) { - return 15; /* so-called math nodes */ + if (i != glyph_node) { + return get_etex_code(i); + } else if (is_ligature(n)) { + return 7; /* old ligature value */ } else { - return -1; + return 0; /* old character value */ } } @@ -359,7 +349,6 @@ void copy_user_lua(pointer r, pointer p) } } - @ @c void free_pdf_literal(pointer p) { @@ -389,7 +378,6 @@ void free_user_lua(pointer p) } } - @ @c void show_pdf_literal(pointer p) { |