summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/lua/lpdflib.c
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2016-03-11 12:12:57 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2016-03-11 12:12:57 +0000
commitb6607d1a70f236fc9f671ce2621978a410e649b1 (patch)
tree57ad797c7a6b132d736a9f15d00eec5e6ebd2a13 /Build/source/texk/web2c/luatexdir/lua/lpdflib.c
parent7cd1d4e0b78e2897415639c5ac54d796c6cb626e (diff)
web2c/luatexdir: sync with the upstream
git-svn-id: svn://tug.org/texlive/trunk@39996 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/lua/lpdflib.c')
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lpdflib.c111
1 files changed, 30 insertions, 81 deletions
diff --git a/Build/source/texk/web2c/luatexdir/lua/lpdflib.c b/Build/source/texk/web2c/luatexdir/lua/lpdflib.c
index 210bc41a7cc..29bfba6baf3 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lpdflib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lpdflib.c
@@ -506,44 +506,20 @@ static int l_registerannot(lua_State * L)
return 0;
}
-static int l_get_pdf_value(lua_State * L, int key)
-{
- lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(pdf_data));
- lua_gettable(L, LUA_REGISTRYINDEX);
- /* [table] */
- lua_rawgeti(L, LUA_REGISTRYINDEX, key);
- /* [table] [key] */
- lua_rawget(L,-2);
+#define l_get_pdf_value(key) \
+ lua_get_metatablelua(pdf_data); \
+ lua_key_rawgeti(key); \
return 1;
-}
-static int l_get_pageresources(lua_State * L) {
- return l_get_pdf_value(L,lua_key_index(pageresources));
-}
-static int l_get_pageattributes(lua_State * L) {
- return l_get_pdf_value(L,lua_key_index(pageattributes));
-}
-static int l_get_pagesattributes(lua_State * L) {
- return l_get_pdf_value(L,lua_key_index(pagesattributes));
-}
-static int l_get_catalog(lua_State * L) {
- return l_get_pdf_value(L,lua_key_index(catalog));
-}
-static int l_get_info(lua_State * L) {
- return l_get_pdf_value(L,lua_key_index(info));
-}
-static int l_get_names(lua_State * L) {
- return l_get_pdf_value(L,lua_key_index(names));
-}
-static int l_get_trailer(lua_State * L) {
- return l_get_pdf_value(L,lua_key_index(trailer));
-}
-static int l_get_xformresources(lua_State * L) {
- return l_get_pdf_value(L,lua_key_index(xformresources));
-}
-static int l_get_xformattributes(lua_State * L) {
- return l_get_pdf_value(L,lua_key_index(xformattributes));
-}
+static int l_get_pageresources (lua_State * L) { l_get_pdf_value(pageresources); }
+static int l_get_pageattributes (lua_State * L) { l_get_pdf_value(pageattributes); }
+static int l_get_pagesattributes(lua_State * L) { l_get_pdf_value(pagesattributes); }
+static int l_get_catalog (lua_State * L) { l_get_pdf_value(catalog); }
+static int l_get_info (lua_State * L) { l_get_pdf_value(info); }
+static int l_get_names (lua_State * L) { l_get_pdf_value(names); }
+static int l_get_trailer (lua_State * L) { l_get_pdf_value(trailer); }
+static int l_get_xformresources (lua_State * L) { l_get_pdf_value(xformresources); }
+static int l_get_xformattributes(lua_State * L) { l_get_pdf_value(xformattributes); }
# define valid_pdf_key ( \
lua_key_eq(s,catalog) || \
@@ -571,8 +547,7 @@ static int getpdf(lua_State * L)
lua_pushinteger(L, static_pdf->posstruct->pos.v);
return 1;
} else if (valid_pdf_key) {
- lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(pdf_data));
- lua_gettable(L, LUA_REGISTRYINDEX);
+ lua_get_metatablelua(pdf_data);
/* [pdf table] [key] [pdf.data table] */
lua_replace(L, -3);
/* [pdf.data table] [key] */
@@ -583,49 +558,24 @@ static int getpdf(lua_State * L)
return 0;
}
-static int l_set_pdf_value(lua_State * L, int key)
-{
- if (lua_type(L,-1) == LUA_TSTRING) {
- /* [value] */
- lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(pdf_data));
- lua_gettable(L, LUA_REGISTRYINDEX);
- /* [value] [table] */
- lua_rawgeti(L, LUA_REGISTRYINDEX, key);
- /* [value] [table] [key] */
- lua_pushvalue(L, -3);
- /* [table] [key] [value] */
- lua_rawset(L,-3);
- }
+#define l_set_pdf_value(key) \
+ if (lua_type(L,-1) == LUA_TSTRING) { \
+ lua_get_metatablelua(pdf_data); \
+ lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(key)); \
+ lua_pushvalue(L, -3); \
+ lua_rawset(L,-3); \
+ } \
return 0;
-}
-static int l_set_pageresources(lua_State * L) {
- return l_set_pdf_value(L,lua_key_index(pageresources));
-}
-static int l_set_pageattributes(lua_State * L) {
- return l_set_pdf_value(L,lua_key_index(pageattributes));
-}
-static int l_set_pagesattributes(lua_State * L) {
- return l_set_pdf_value(L,lua_key_index(pagesattributes));
-}
-static int l_set_catalog(lua_State * L) {
- return l_set_pdf_value(L,lua_key_index(catalog));
-}
-static int l_set_info(lua_State * L) {
- return l_set_pdf_value(L,lua_key_index(info));
-}
-static int l_set_names(lua_State * L) {
- return l_set_pdf_value(L,lua_key_index(names));
-}
-static int l_set_trailer(lua_State * L) {
- return l_set_pdf_value(L,lua_key_index(trailer));
-}
-static int l_set_xformresources(lua_State * L) {
- return l_set_pdf_value(L,lua_key_index(xformresources));
-}
-static int l_set_xformattributes(lua_State * L) {
- return l_set_pdf_value(L,lua_key_index(xformattributes));
-}
+static int l_set_pageresources (lua_State * L) { l_set_pdf_value(pageresources); }
+static int l_set_pageattributes (lua_State * L) { l_set_pdf_value(pageattributes); }
+static int l_set_pagesattributes(lua_State * L) { l_set_pdf_value(pagesattributes); }
+static int l_set_catalog (lua_State * L) { l_set_pdf_value(catalog); }
+static int l_set_info (lua_State * L) { l_set_pdf_value(info); }
+static int l_set_names (lua_State * L) { l_set_pdf_value(names); }
+static int l_set_trailer (lua_State * L) { l_set_pdf_value(trailer); }
+static int l_set_xformresources (lua_State * L) { l_set_pdf_value(xformresources); }
+static int l_set_xformattributes(lua_State * L) { l_set_pdf_value(xformattributes); }
static int setpdf(lua_State * L)
{
@@ -637,8 +587,7 @@ static int setpdf(lua_State * L)
if (lua_type(L, -2) == LUA_TSTRING) {
s = lua_tostring(L, -1);
if (valid_pdf_key) {
- lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(pdf_data));
- lua_gettable(L, LUA_REGISTRYINDEX);
+ lua_get_metatablelua(pdf_data);
/* [pdf table] [key] [value] [pdf.data table] */
lua_replace(L, -4);
/* [pdf.data table] [key] [value] */