Hi LuaTeX team,

I recently tried to interact with pdf_link_state whatsits from Lua and
the current situation is a bit odd: If `n` is a pdf_link_state node,
then `n.value` can be assigned to set the parmeter of the pdf_link_state
node, but reading `n.value` results in nil. When using node.direct,
neither getfield nor setfield for on the `value` field. Assuming that
this is just an oversight I attach a patch to at all `value` to all the
usual getters and setters.

Best,
Marcel
From 4d3d9155efb2f8edfe32c8421542865b33b7a26d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcel=20Fabian=20Kr=C3=BCger?= <t...@2krueger.de>
Date: Tue, 17 Jun 2025 21:44:16 +0200
Subject: [PATCH] Fully expose pdf_link_state whatsits in Lua

---
 source/texk/web2c/luatexdir/lua/lnodelib.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/source/texk/web2c/luatexdir/lua/lnodelib.c 
b/source/texk/web2c/luatexdir/lua/lnodelib.c
index 75ede22ee..8ab740214 100644
--- a/source/texk/web2c/luatexdir/lua/lnodelib.c
+++ b/source/texk/web2c/luatexdir/lua/lnodelib.c
@@ -1703,6 +1703,8 @@ static int lua_nodelib_direct_getdata(lua_State * L)
                 get_special_direct_value(L, n);
             } else if (s == write_node) {
                 get_write_direct_data(L, n);
+            } else if (s == pdf_link_state_node) {
+                lua_pushinteger(L, pdf_link_state(n));
             } else {
                 lua_pushnil(L);
             }
@@ -1744,6 +1746,8 @@ static int lua_nodelib_direct_setdata(lua_State * L) /* 
data and value */
                 set_special_direct_value(L, n, 2);
             } else if (s == write_node) {
                 set_write_direct_value(L,n,2);
+            } else if (s == pdf_link_state_node) {
+                pdf_link_state(n) = (halfword) lua_tointeger(L, 2);
             }
         }
     }
@@ -4550,6 +4554,12 @@ static void lua_nodelib_getfield_whatsit(lua_State * L, 
int n, const char *s)
         } else {
             lua_pushnil(L);
         }
+    } else if (t == pdf_link_state_node) {
+        if (lua_key_eq(s, value)) {
+            lua_pushinteger(L, pdf_link_state(n));
+        } else {
+            lua_pushnil(L);
+        }
     } else if (t == pdf_action_node) {
         if (lua_key_eq(s, action_type)) {
             lua_pushinteger(L, pdf_action_type(n));
@@ -5332,6 +5342,12 @@ static void 
lua_nodelib_direct_getfield_whatsit(lua_State * L, int n, const char
         } else {
             lua_pushnil(L);
         }
+    } else if (t == pdf_link_state_node) {
+        if (lua_key_eq(s, value)) {
+            lua_pushinteger(L, pdf_link_state(n));
+        } else {
+            lua_pushnil(L);
+        }
     } else if (t == pdf_action_node) {
         if (lua_key_eq(s, action_type)) {
             lua_pushinteger(L, pdf_action_type(n));
@@ -7561,6 +7577,12 @@ static int lua_nodelib_direct_setfield_whatsit(lua_State 
* L, int n, const char
         } else {
             return nodelib_cantset(L, n, s);
         }
+    } else if (t == pdf_link_state_node) {
+        if (lua_key_eq(s, value)) {
+            pdf_link_state(n) = (halfword) lua_tointeger(L, 3);
+        } else {
+            return nodelib_cantset(L, n, s);
+        }
     } else if ((t == pdf_end_link_node) || (t == pdf_end_thread_node) || (t == 
save_pos_node) ||
                (t == pdf_save_node)     || (t == pdf_restore_node)) {
         return nodelib_cantset(L, n, s);
-- 
2.50.0

_______________________________________________
dev-luatex mailing list -- dev-luatex@ntg.nl
To unsubscribe send an email to dev-luatex-le...@ntg.nl

Reply via email to