summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/lua
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2014-12-10 09:22:25 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2014-12-10 09:22:25 +0000
commit70b9e104222eb5ba7a495c6267643c6470fb4667 (patch)
tree6b540c75177a4ec7d7ad0b607542c0f3620b1d3e /Build/source/texk/web2c/luatexdir/lua
parentdb2683e88ae12a32ad6620b4e40218761ea14f41 (diff)
LuaTeX: Sync with https://foundry.supelec.fr/svn/luatex/trunk r5092
git-svn-id: svn://tug.org/texlive/trunk@35779 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/lua')
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c29
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lepdflib.cc777
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/llanglib.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/llfslibext.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lnodelib.c38
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/loslibext.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lpdflib.c7
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lstatslib.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/ltexlib.c46
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luainit.w2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luatex-api.h25
11 files changed, 900 insertions, 32 deletions
diff --git a/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c b/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c
index 160fbe3bde6..f8b4360e56b 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c
@@ -21,7 +21,7 @@
#include "lua/luatex-api.h"
static const char _svn_version[] =
- "$Id: lcallbacklib.c 4956 2014-03-28 12:12:17Z luigi $ $URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/lua/lcallbacklib.c $";
+ "$Id: lcallbacklib.c 5081 2014-11-07 18:38:33Z luigi $ $URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/lua/lcallbacklib.c $";
int callback_count = 0;
int saved_callback_count = 0;
@@ -69,6 +69,7 @@ static const char *const callbacknames[] = {
"finish_pdfpage",
"pre_dump","start_file", "stop_file",
"show_error_message","show_lua_error_hook",
+ "pdf_stream_filter_callback",
NULL
};
@@ -188,6 +189,7 @@ void get_saved_lua_string(int r, const char *name, char **target)
#define CALLBACK_STRNUMBER 's'
#define CALLBACK_STRING 'S'
#define CALLBACK_CHARNUM 'c'
+#define CALLBACK_LSTRING 'L'
int run_saved_callback(int r, const char *name, const char *values, ...)
@@ -265,6 +267,7 @@ int do_run_callback(int special, const char *values, va_list vl)
size_t len;
int narg, nres;
const char *s;
+ lstring *lstr;
char cs;
int *bufloc;
char *ss = NULL;
@@ -288,6 +291,10 @@ int do_run_callback(int special, const char *values, va_list vl)
s = va_arg(vl, char *);
lua_pushstring(L, s);
break;
+ case CALLBACK_LSTRING: /* 'lstring' */
+ lstr = va_arg(vl, lstring *);
+ lua_pushlstring(L, (const char *)lstr->s, lstr->l);
+ break;
case CALLBACK_INTEGER: /* int */
lua_pushnumber(L, va_arg(vl, int));
break;
@@ -420,6 +427,26 @@ int do_run_callback(int special, const char *values, va_list vl)
*va_arg(vl, char **) = ss;
}
break;
+ case CALLBACK_LSTRING: /* lstring */
+ if (!lua_isstring(L, nres)) {
+ if (!lua_isnil(L, nres)) {
+ fprintf(stderr, "Expected a string for (S), not: %s\n",
+ lua_typename(L, lua_type(L, nres)));
+ goto EXIT;
+ }
+ }
+ s = lua_tolstring(L, nres, &len);
+
+ if (s == NULL) /* |len| can be zero */
+ *va_arg(vl, int *) = 0;
+ else {
+ lstring *ret = xmalloc(sizeof(lstring));
+ ret->s = xmalloc((unsigned) (len + 1));
+ (void) memcpy(ret->s, s, (len + 1));
+ ret->l = len;
+ *va_arg(vl, lstring **) = ret;
+ }
+ break;
default:
fprintf(stdout, "invalid return value type");
goto EXIT;
diff --git a/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc b/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc
index 5b4a512a195..1adaa120362 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc
+++ b/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc
@@ -19,11 +19,13 @@
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
static const char _svn_version[] =
- "$Id: lepdflib.cc 4847 2014-03-05 18:13:17Z luigi $ "
+ "$Id: lepdflib.cc 5081 2014-11-07 18:38:33Z luigi $ "
"$URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/lua/lepdflib.cc $";
#include "image/epdf.h"
+
+
// define DEBUG
//**********************************************************************
@@ -65,6 +67,11 @@ static const char *ErrorCodeNames[] = { "None", "OpenFile", "BadCatalog",
#define M_PDFRectangle "epdf.PDFRectangle"
#define M_Ref "epdf.Ref"
#define M_Stream "epdf.Stream"
+#ifdef HAVE_STRUCTTREEROOT_H
+#define M_StructElement "epdf.StructElement"
+#define M_Attribute "epdf.Attribute"
+#define M_TextSpan "epdf.TextSpan"
+#endif
#define M_StructTreeRoot "epdf.StructTreeRoot"
#define M_XRefEntry "epdf.XRefEntry"
#define M_XRef "epdf.XRef"
@@ -97,6 +104,11 @@ new_poppler_userdata(Page);
new_poppler_userdata(PDFRectangle);
new_poppler_userdata(Ref);
new_poppler_userdata(Stream);
+#ifdef HAVE_STRUCTTREEROOT_H
+new_poppler_userdata(StructElement);
+new_poppler_userdata(Attribute);
+new_poppler_userdata(TextSpan);
+#endif
new_poppler_userdata(StructTreeRoot);
new_poppler_userdata(XRef);
@@ -124,6 +136,7 @@ static int l_open_PDFDoc(lua_State * L)
if (d == NULL)
lua_pushnil(L);
else {
+ globalParams = new GlobalParams();
uout = new_PDFDoc_userdata(L);
uout->d = d;
uout->atype = ALLOC_LEPDF;
@@ -147,6 +160,178 @@ static int l_new_Array(lua_State * L)
return 1;
}
+#ifdef HAVE_STRUCTTREEROOT_H
+static int l_new_Attribute(lua_State * L)
+{
+ Attribute::Type t;
+ const char *n;
+ int nlen;
+ udstruct *uobj, *uout;
+
+ if (lua_type(L,1)==LUA_TNUMBER) {
+ uobj = (udstruct *) luaL_checkudata(L, 2, M_Object);
+ if (uobj->pd != NULL && uobj->pd->pc != uobj->pc)
+ pdfdoc_changed_error(L);
+ t = (Attribute::Type) luaL_checkint(L, 1);
+ uout = new_Attribute_userdata(L);
+ uout->d = new Attribute(t, (Object *)uobj->d);
+ uout->atype = ALLOC_LEPDF;
+ uout->pc = uobj->pc;
+ uout->pd = uobj->pd;
+
+ } else if (lua_type(L,1)==LUA_TSTRING) {
+ n = luaL_checkstring(L,1);
+ nlen = luaL_checkint(L,2);
+ uobj = (udstruct *) luaL_checkudata(L, 3, M_Object);
+ if (uobj->pd != NULL && uobj->pd->pc != uobj->pc)
+ pdfdoc_changed_error(L);
+ uout = new_Attribute_userdata(L);
+ uout->d = new Attribute(n, nlen, (Object *)uobj->d);
+ uout->atype = ALLOC_LEPDF;
+ uout->pc = uobj->pc;
+ uout->pd = uobj->pd;
+ } else
+ lua_pushnil(L);
+ return 1;
+}
+
+#define ATTRIBUTE_TYPE_ENTRY(name) \
+ lua_pushstring(L, #name); \
+ lua_pushinteger(L, Attribute::name); \
+ lua_settable(L,-3)
+
+
+#define STRUCTELEMENT_TYPE_ENTRY(name) \
+ lua_pushstring(L, #name); \
+ lua_pushinteger(L, StructElement::name); \
+ lua_settable(L,-3)
+
+
+static int l_Attribute_Type(lua_State * L) {
+ lua_createtable (L, 0, 42);
+ ATTRIBUTE_TYPE_ENTRY(BBox);
+ ATTRIBUTE_TYPE_ENTRY(BackgroundColor);
+ ATTRIBUTE_TYPE_ENTRY(BorderColor);
+ ATTRIBUTE_TYPE_ENTRY(BorderThickness);
+ ATTRIBUTE_TYPE_ENTRY(Color);
+ ATTRIBUTE_TYPE_ENTRY(ColumnGap);
+ ATTRIBUTE_TYPE_ENTRY(ColumnWidths);
+ ATTRIBUTE_TYPE_ENTRY(Desc);
+ ATTRIBUTE_TYPE_ENTRY(Role);
+ ATTRIBUTE_TYPE_ENTRY(TextDecorationColor);
+ ATTRIBUTE_TYPE_ENTRY(TextDecorationThickness);
+ ATTRIBUTE_TYPE_ENTRY(BaselineShift);
+ ATTRIBUTE_TYPE_ENTRY(BlockAlign);
+ ATTRIBUTE_TYPE_ENTRY(BorderStyle);
+ ATTRIBUTE_TYPE_ENTRY(ColSpan);
+ ATTRIBUTE_TYPE_ENTRY(ColumnCount);
+ ATTRIBUTE_TYPE_ENTRY(EndIndent);
+ ATTRIBUTE_TYPE_ENTRY(GlyphOrientationVertical);
+ ATTRIBUTE_TYPE_ENTRY(Headers);
+ ATTRIBUTE_TYPE_ENTRY(Height);
+ ATTRIBUTE_TYPE_ENTRY(InlineAlign);
+ ATTRIBUTE_TYPE_ENTRY(LineHeight);
+ ATTRIBUTE_TYPE_ENTRY(ListNumbering);
+ ATTRIBUTE_TYPE_ENTRY(Padding);
+ ATTRIBUTE_TYPE_ENTRY(Placement);
+ ATTRIBUTE_TYPE_ENTRY(RowSpan);
+ ATTRIBUTE_TYPE_ENTRY(RubyAlign);
+ ATTRIBUTE_TYPE_ENTRY(RubyPosition);
+ ATTRIBUTE_TYPE_ENTRY(Scope);
+ ATTRIBUTE_TYPE_ENTRY(SpaceAfter);
+ ATTRIBUTE_TYPE_ENTRY(SpaceBefore);
+ ATTRIBUTE_TYPE_ENTRY(StartIndent);
+ ATTRIBUTE_TYPE_ENTRY(Summary);
+ ATTRIBUTE_TYPE_ENTRY(TBorderStyle);
+ ATTRIBUTE_TYPE_ENTRY(TPadding);
+ ATTRIBUTE_TYPE_ENTRY(TextAlign);
+ ATTRIBUTE_TYPE_ENTRY(TextDecorationType);
+ ATTRIBUTE_TYPE_ENTRY(TextIndent);
+ ATTRIBUTE_TYPE_ENTRY(Width);
+ ATTRIBUTE_TYPE_ENTRY(WritingMode);
+ ATTRIBUTE_TYPE_ENTRY(Unknown);
+ ATTRIBUTE_TYPE_ENTRY(checked);
+ return 1;
+}
+
+static int l_StructElement_Type(lua_State * L) {
+ lua_createtable (L, 0, 50);
+ STRUCTELEMENT_TYPE_ENTRY(Document);
+ STRUCTELEMENT_TYPE_ENTRY(Part);
+ STRUCTELEMENT_TYPE_ENTRY(Art);
+ STRUCTELEMENT_TYPE_ENTRY(Sect);
+ STRUCTELEMENT_TYPE_ENTRY(Div);
+ STRUCTELEMENT_TYPE_ENTRY(BlockQuote);
+ STRUCTELEMENT_TYPE_ENTRY(Caption);
+ STRUCTELEMENT_TYPE_ENTRY(NonStruct);
+ STRUCTELEMENT_TYPE_ENTRY(Index);
+ STRUCTELEMENT_TYPE_ENTRY(Private);
+ STRUCTELEMENT_TYPE_ENTRY(Span);
+ STRUCTELEMENT_TYPE_ENTRY(Quote);
+ STRUCTELEMENT_TYPE_ENTRY(Note);
+ STRUCTELEMENT_TYPE_ENTRY(Reference);
+ STRUCTELEMENT_TYPE_ENTRY(BibEntry);
+ STRUCTELEMENT_TYPE_ENTRY(Code);
+ STRUCTELEMENT_TYPE_ENTRY(Link);
+ STRUCTELEMENT_TYPE_ENTRY(Annot);
+ STRUCTELEMENT_TYPE_ENTRY(Ruby);
+ STRUCTELEMENT_TYPE_ENTRY(RB);
+ STRUCTELEMENT_TYPE_ENTRY(RT);
+ STRUCTELEMENT_TYPE_ENTRY(RP);
+ STRUCTELEMENT_TYPE_ENTRY(Warichu);
+ STRUCTELEMENT_TYPE_ENTRY(WT);
+ STRUCTELEMENT_TYPE_ENTRY(WP);
+ STRUCTELEMENT_TYPE_ENTRY(P);
+ STRUCTELEMENT_TYPE_ENTRY(H);
+ STRUCTELEMENT_TYPE_ENTRY(H1);
+ STRUCTELEMENT_TYPE_ENTRY(H2);
+ STRUCTELEMENT_TYPE_ENTRY(H3);
+ STRUCTELEMENT_TYPE_ENTRY(H4);
+ STRUCTELEMENT_TYPE_ENTRY(H5);
+ STRUCTELEMENT_TYPE_ENTRY(H6);
+ STRUCTELEMENT_TYPE_ENTRY(L);
+ STRUCTELEMENT_TYPE_ENTRY(LI);
+ STRUCTELEMENT_TYPE_ENTRY(Lbl);
+ STRUCTELEMENT_TYPE_ENTRY(LBody);
+ STRUCTELEMENT_TYPE_ENTRY(Table);
+ STRUCTELEMENT_TYPE_ENTRY(TR);
+ STRUCTELEMENT_TYPE_ENTRY(TH);
+ STRUCTELEMENT_TYPE_ENTRY(TD);
+ STRUCTELEMENT_TYPE_ENTRY(THead);
+ STRUCTELEMENT_TYPE_ENTRY(TFoot);
+ STRUCTELEMENT_TYPE_ENTRY(TBody);
+ STRUCTELEMENT_TYPE_ENTRY(Figure);
+ STRUCTELEMENT_TYPE_ENTRY(Formula);
+ STRUCTELEMENT_TYPE_ENTRY(Form);
+ STRUCTELEMENT_TYPE_ENTRY(TOC);
+ STRUCTELEMENT_TYPE_ENTRY(TOCI);
+ lua_pushstring(L, "Unknown");
+ lua_pushinteger(L, 0);
+ lua_settable(L,-3);
+ return 1;
+}
+
+static int l_AttributeOwner_Type(lua_State * L) {
+ lua_createtable (L, 0, 12);
+ lua_pushstring(L, "XML-1.00"); lua_pushinteger(L, Attribute::XML_1_00); lua_settable(L,-3);
+ lua_pushstring(L, "HTML-3.20"); lua_pushinteger(L, Attribute::HTML_3_20); lua_settable(L,-3);
+ lua_pushstring(L, "HTML-4.01"); lua_pushinteger(L, Attribute::HTML_4_01); lua_settable(L,-3);
+ lua_pushstring(L, "OEB-1.00"); lua_pushinteger(L, Attribute::OEB_1_00); lua_settable(L,-3);
+ lua_pushstring(L, "RTF-1.05"); lua_pushinteger(L, Attribute::RTF_1_05); lua_settable(L,-3);
+ lua_pushstring(L, "CSS-1.00"); lua_pushinteger(L, Attribute::CSS_1_00); lua_settable(L,-3);
+ lua_pushstring(L, "CSS-2.00"); lua_pushinteger(L, Attribute::CSS_2_00); lua_settable(L,-3);
+ lua_pushstring(L, "Layout"); lua_pushinteger(L, Attribute::Layout); lua_settable(L,-3);
+ lua_pushstring(L, "PrintField"); lua_pushinteger(L, Attribute::PrintField); lua_settable(L,-3);
+ lua_pushstring(L, "Table"); lua_pushinteger(L, Attribute::Table); lua_settable(L,-3);
+ lua_pushstring(L, "List"); lua_pushinteger(L, Attribute::List); lua_settable(L,-3);
+ lua_pushstring(L, "UserProperties"); lua_pushinteger(L, Attribute::UserProperties);lua_settable(L,-3);
+ return 1;
+}
+
+
+#endif
+
+
static int l_new_Dict(lua_State * L)
{
udstruct *uxref, *uout;
@@ -188,6 +373,12 @@ static int l_new_PDFRectangle(lua_State * L)
static const struct luaL_Reg epdflib_f[] = {
{"open", l_open_PDFDoc},
{"Array", l_new_Array},
+#ifdef HAVE_STRUCTTREEROOT_H
+ {"Attribute", l_new_Attribute},
+ {"StructElement_Type", l_StructElement_Type},
+ {"Attribute_Type", l_Attribute_Type},
+ {"AttributeOwner_Type",l_AttributeOwner_Type},
+#endif
{"Dict", l_new_Dict},
{"Object", l_new_Object},
{"PDFRectangle", l_new_PDFRectangle},
@@ -242,6 +433,25 @@ static int m_##in##_##function(lua_State * L) \
return 1; \
}
+
+#define m_poppler_get_GUINT(in, function) \
+static int m_##in##_##function(lua_State * L) \
+{ \
+ unsigned int i; \
+ udstruct *uin; \
+ uin = (udstruct *) luaL_checkudata(L, 1, M_##in); \
+ if (uin->pd != NULL && uin->pd->pc != uin->pc) \
+ pdfdoc_changed_error(L); \
+ i = (unsigned int) ((in *) uin->d)->function(); \
+ lua_pushinteger(L, i); \
+ return 1; \
+}
+
+#define m_poppler_get_UINT(in, function) \
+m_poppler_get_GUINT(in, function)
+
+
+
#define m_poppler_get_DOUBLE(in, function) \
static int m_##in##_##function(lua_State * L) \
{ \
@@ -1875,7 +2085,8 @@ static int m_Object__gc(lua_State * L)
printf("\n===== Object GC ===== uin=<%p>\n", uin);
#endif
if (uin->atype == ALLOC_LEPDF) {
- ((Object *) uin->d)->free();
+ // free() seems to collide with the lua gc
+ //((Object *) uin->d)->free();
delete(Object *) uin->d;
}
return 0;
@@ -2532,6 +2743,562 @@ static const struct luaL_Reg Stream_m[] = {
{NULL, NULL} // sentinel
};
+#ifdef HAVE_STRUCTTREEROOT_H
+//**********************************************************************
+// TextSpan
+
+m_poppler_get_GOOSTRING(TextSpan, getText);
+m_poppler__tostring(TextSpan);
+
+static const struct luaL_Reg TextSpan_m[] = {
+ {"getText", m_TextSpan_getText},
+ {"__tostring", m_TextSpan__tostring},
+ {NULL, NULL} // sentinel
+};
+
+
+
+
+//**********************************************************************
+// Attribute
+m_poppler_get_BOOL(Attribute,isOk);
+m_poppler_get_INT(Attribute,getType);
+m_poppler_get_INT(Attribute,getOwner);
+m_poppler_get_GOOSTRING(Attribute,getName);
+
+static int m_Attribute_getTypeName(lua_State * L)
+{
+ udstruct *uin;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_Attribute);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ lua_pushstring(L, ((Attribute *) uin->d)->getTypeName());
+ return 1;
+}
+
+static int m_Attribute_getOwnerName(lua_State * L)
+{
+ udstruct *uin;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_Attribute);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ lua_pushstring(L, ((Attribute *) uin->d)->getOwnerName());
+ return 1;
+}
+
+static int m_Attribute_getValue(lua_State * L)
+{
+ udstruct *uin, *uout;
+ Object *origin;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_Attribute);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ uout = new_Object_userdata(L);
+ uout->d = new Object();
+ origin = (Object *) (((Attribute *) uin->d)->getValue());
+ origin->copy ( ((Object *)uout->d) );
+ uout->atype = ALLOC_LEPDF;
+ uout->pc = uin->pc;
+ uout->pd = uin->pd;
+ return 1;
+}
+
+
+static int m_Attribute_getDefaultValue(lua_State * L)
+{
+ Attribute::Type t;
+ udstruct *uin, *uout;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_Attribute);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ t = (Attribute::Type) luaL_checkint(L, 2);
+ uout = new_Object_userdata(L);
+ uout->d = ((Attribute *)uin->d)->getDefaultValue(t) ;
+ //uout->atype = ALLOC_LEPDF;
+ uout->pc = uin->pc;
+ uout->pd = uin->pd;
+ return 1;
+}
+
+
+m_poppler_get_GUINT(Attribute,getRevision);
+
+static int m_Attribute_setRevision(lua_State * L)
+{
+ Guint i;
+ udstruct *uin;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_Attribute);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ i = (Guint) luaL_checkint(L, 2);
+ ((Attribute *) uin->d)->setRevision(i);
+ return 0;
+}
+
+m_poppler_get_BOOL(Attribute, isHidden);
+
+static int m_Attribute_setHidden(lua_State * L)
+{
+ GBool i;
+ udstruct *uin;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_Attribute);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ i = (GBool) lua_toboolean(L, 2);
+ ((Attribute *) uin->d)->setHidden(i);
+ return 0;
+}
+
+static int m_Attribute_getFormattedValue(lua_State * L)
+{
+ udstruct *uin;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_Attribute);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ lua_pushstring(L, ((Attribute *) uin->d)->getFormattedValue());
+ return 1;
+}
+
+
+static int m_Attribute_setFormattedValue(lua_State * L)
+{
+ const char *c;
+ udstruct *uin;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_Attribute);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ c = luaL_checkstring(L, 2);
+ ((Attribute *) uin->d)->setFormattedValue(c);
+ return 0;
+}
+
+static int m_Attribute__gc(lua_State * L)
+{
+ udstruct *uin;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_Attribute);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+#ifdef DEBUG
+ printf("\n===== Attribute GC ===== uin=<%p>\n", uin);
+#endif
+ if (uin->atype == ALLOC_LEPDF) {
+ delete(Attribute *) uin->d;
+ }
+ return 0;
+}
+
+
+m_poppler__tostring(Attribute);
+
+
+static const struct luaL_Reg Attribute_m[] = {
+ {"isOk",m_Attribute_isOk},
+ {"getType",m_Attribute_getType},
+ {"getOwner",m_Attribute_getOwner},
+ {"getTypeName",m_Attribute_getTypeName},
+ {"getOwnerName",m_Attribute_getOwnerName},
+ {"getValue",m_Attribute_getValue},
+ {"getDefaultValue",m_Attribute_getDefaultValue},
+ {"getName",m_Attribute_getName},
+ {"getRevision",m_Attribute_getRevision},
+ {"setRevision",m_Attribute_setRevision},
+ {"istHidden",m_Attribute_isHidden},
+ {"setHidden",m_Attribute_setHidden},
+ {"getFormattedValue",m_Attribute_getFormattedValue},
+ {"setFormattedValue",m_Attribute_setFormattedValue},
+ {"__gc", m_Attribute__gc},
+ {"__tostring", m_Attribute__tostring},
+ {NULL, NULL} // sentinel
+};
+
+
+
+
+//**********************************************************************
+// StructElement
+
+
+m_poppler_get_INT(StructElement,getType);
+m_poppler_get_BOOL(StructElement,isOk);
+m_poppler_get_BOOL(StructElement,isBlock);
+m_poppler_get_BOOL(StructElement,isInline);
+m_poppler_get_BOOL(StructElement,isGrouping);
+m_poppler_get_BOOL(StructElement,isContent);
+m_poppler_get_BOOL(StructElement,isObjectRef);
+m_poppler_get_BOOL(StructElement,hasPageRef);
+m_poppler_get_INT(StructElement,getMCID);
+m_poppler_get_INT(StructElement, getNumChildren);
+
+m_poppler_get_GUINT(StructElement,getRevision);
+m_poppler_get_UINT(StructElement,getNumAttributes);
+
+m_poppler_get_GOOSTRING(StructElement, getID);
+m_poppler_get_GOOSTRING(StructElement, getLanguage);
+m_poppler_get_GOOSTRING(StructElement, getTitle);
+m_poppler_get_GOOSTRING(StructElement, getExpandedAbbr);
+m_poppler_get_GOOSTRING(StructElement, getAltText);
+m_poppler_get_GOOSTRING(StructElement, getActualText);
+
+m_poppler_get_poppler(StructElement, StructTreeRoot, getStructTreeRoot);
+m_poppler__tostring(StructElement);
+
+
+static int m_StructElement_getObjectRef(lua_State * L)
+{
+ udstruct *uin, *uout;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ uout = new_Ref_userdata(L);
+ uout->d = (Ref *) gmalloc(sizeof(Ref));
+ ((Ref *) uout->d)->num = ((StructElement *) uin->d)->getObjectRef().num;
+ ((Ref *) uout->d)->gen = ((StructElement *) uin->d)->getObjectRef().gen;
+ uout->atype = ALLOC_LEPDF;
+ uout->pc = uin->pc;
+ uout->pd = uin->pd;
+ return 1;
+}
+
+
+static int m_StructElement_getParentRef(lua_State * L)
+{
+ udstruct *uin, *uout;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ uout = new_Ref_userdata(L);
+ uout->d = (Ref *) gmalloc(sizeof(Ref));
+ ((Ref *) uout->d)->num = ((StructElement *) uin->d)->getParentRef().num;
+ ((Ref *) uout->d)->gen = ((StructElement *) uin->d)->getParentRef().gen;
+ uout->atype = ALLOC_LEPDF;
+ uout->pc = uin->pc;
+ uout->pd = uin->pd;
+ return 1;
+}
+
+// Not exactly as the header:
+// Ref = StructElement:getPageRef()
+// Ref is false if the C++ functione return false
+static int m_StructElement_getPageRef(lua_State * L)
+{
+ GBool b;
+ Ref *r;
+ udstruct *uin, *uout;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ r = (Ref *) gmalloc(sizeof(Ref));
+ b = ((StructElement *) uin->d)->getPageRef( *r );
+ if (b) {
+ uout = new_Ref_userdata(L);
+ uout->d = r ;
+ //uout->atype = ALLOC_LEPDF;
+ uout->pc = uin->pc;
+ uout->pd = uin->pd;
+ } else
+ lua_pushboolean(L,0);
+ return 1;
+}
+
+
+
+static int m_StructElement_getTypeName(lua_State * L)
+{
+ udstruct *uin;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ lua_pushstring(L, ((StructElement *) uin->d)->getTypeName());
+ return 1;
+}
+
+
+static int m_StructElement_setRevision(lua_State * L)
+{
+ Guint i;
+ udstruct *uin;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ i = (Guint) luaL_checkint(L, 2);
+ ((StructElement *) uin->d)->setRevision(i);
+ return 0;
+}
+
+static int m_StructElement_getText(lua_State * L)
+{
+ GBool i;
+ GooString *gs;
+ udstruct *uin;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ i = (GBool) lua_toboolean(L, 2);
+ gs = ((StructElement *) uin->d)->getText(i);
+ if (gs != NULL)
+ lua_pushlstring(L, gs->getCString(), gs->getLength());
+ else
+ lua_pushnil(L);
+ return 1;
+}
+
+
+static int m_StructElement_getChild(lua_State * L)
+{
+ StructElement *c;
+ int i;
+ udstruct *uin, *uout;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ i = (int) luaL_checkint(L, 2);
+ c = ((StructElement *) uin->d)->getChild(i-1);
+ if (c != NULL) {
+ uout = new_StructElement_userdata(L);
+ uout->d = c ;
+ //uout->atype = ALLOC_LEPDF;
+ uout->pc = uin->pc;
+ uout->pd = uin->pd;
+ }
+ else
+ lua_pushnil(L);
+ return 1;
+}
+
+
+static int m_StructElement_appendChild(lua_State * L)
+{
+ udstruct *uin, *uin1;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ uin1 = (udstruct *) luaL_checkudata(L, 2, M_StructElement);
+ if (uin1->pd != NULL && uin1->pd->pc != uin1->pc)
+ pdfdoc_changed_error(L);
+ ((StructElement *) uin->d)->appendChild( (StructElement *)uin1->d );
+ return 0;
+}
+
+
+static int m_StructElement_getAttribute(lua_State * L)
+{
+ Attribute *a;
+ int i;
+ udstruct *uin, *uout;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ i = (int) luaL_checkint(L, 2);
+ a = ((StructElement *) uin->d)->getAttribute(i-1);
+ if (a != NULL) {
+ uout = new_Attribute_userdata(L);
+ uout->d = a ;
+ uout->pc = uin->pc;
+ uout->pd = uin->pd;
+ }
+ else
+ lua_pushnil(L);
+ return 1;
+}
+
+
+
+static int m_StructElement_appendAttribute(lua_State * L)
+{
+
+ udstruct *uin, *uin1;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ uin1 = (udstruct *) luaL_checkudata(L, 2, M_Attribute);
+ if (uin1->pd != NULL && uin1->pd->pc != uin1->pc)
+ pdfdoc_changed_error(L);
+ ((StructElement *) uin->d)->appendAttribute( (Attribute *)uin1->d );
+ return 0;
+}
+
+
+static int m_StructElement_findAttribute(lua_State * L)
+{
+ Attribute::Type t;
+ Attribute::Owner o;
+ GBool g;
+ udstruct *uin, *uout;
+ const Attribute *a;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ t = (Attribute::Type) luaL_checkint(L,1);
+ o = (Attribute::Owner) luaL_checkint(L,2);
+ g = (GBool) lua_toboolean(L, 3);
+ a = ((StructElement *) uin->d)->findAttribute(t,g,o);
+
+ if (a!=NULL){
+ uout = new_Attribute_userdata(L);
+ uout->d = new Attribute(a->getType(),a->getValue());
+ uout->atype = ALLOC_LEPDF;
+ uout->pc = uin->pc;
+ uout->pd = uin->pd;
+ } else
+ lua_pushnil(L);
+ return 1;
+}
+
+// This returns a lua table
+static int m_StructElement_getTextSpans(lua_State * L)
+{
+ int i ;
+ udstruct *uin, *uout;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+
+ if ((((StructElement *) uin->d)->getTextSpans()).size()>0) {
+ lua_createtable (L,
+ (int) (((StructElement *) uin->d)->getTextSpans()).size(),
+ 0);
+ for(i=0;i<(int) (((StructElement *) uin->d)->getTextSpans()).size(); i++){
+ uout = new_TextSpan_userdata(L);
+ uout->d = new TextSpan( (((StructElement *) uin->d)->getTextSpans())[i] );
+ uout->atype = ALLOC_LEPDF;
+ uout->pc = uin->pc;
+ uout->pd = uin->pd;
+ lua_rawseti(L,-2,i+1);
+ }
+ } else
+ lua_pushnil(L);
+ return 1;
+}
+
+
+
+static const struct luaL_Reg StructElement_m[] = {
+ {"getTypeName", m_StructElement_getTypeName},
+ {"getType",m_StructElement_getType},
+ {"isOk",m_StructElement_isOk},
+ {"isBlock",m_StructElement_isBlock},
+ {"isInline",m_StructElement_isInline},
+ {"isGrouping",m_StructElement_isGrouping},
+ {"isContent",m_StructElement_isContent},
+ {"isObjectRef",m_StructElement_isObjectRef},
+ {"getMCID",m_StructElement_getMCID},
+ {"getObjectRef",m_StructElement_getObjectRef},
+ {"getParentRef",m_StructElement_getParentRef},
+ {"hasPageRef",m_StructElement_hasPageRef},
+ {"getPageRef",m_StructElement_getPageRef},
+ {"getStructTreeRoot",m_StructElement_getStructTreeRoot},
+ {"getID",m_StructElement_getID},
+ {"getLanguage",m_StructElement_getLanguage},
+ {"getRevision",m_StructElement_getRevision},
+ {"setRevision",m_StructElement_setRevision},
+ {"getTitle",m_StructElement_getTitle},
+ {"getExpandedAbbr",m_StructElement_getExpandedAbbr},
+ {"getNumChildren",m_StructElement_getNumChildren},
+ {"getChild",m_StructElement_getChild},
+ {"appendChild",m_StructElement_appendChild},
+ {"getNumAttributes",m_StructElement_getNumAttributes},
+ {"getAttribute",m_StructElement_getAttribute},
+ {"appendAttribute",m_StructElement_appendAttribute},
+ {"findAttribute",m_StructElement_findAttribute},
+ {"getAltText",m_StructElement_getAltText},
+ {"getActualText",m_StructElement_getActualText},
+ {"getText",m_StructElement_getText},
+ {"getTextSpans",m_StructElement_getTextSpans},
+ {"__tostring", m_StructElement__tostring},
+ {NULL, NULL} // sentinel
+};
+
+
+//**********************************************************************
+// StructTreeRoot
+
+m_poppler_get_INT(StructTreeRoot, getNumChildren);
+m_poppler_get_poppler(StructTreeRoot, PDFDoc, getDoc);
+m_poppler_get_poppler(StructTreeRoot, Dict, getRoleMap);
+m_poppler_get_poppler(StructTreeRoot, Dict, getClassMap);
+m_poppler__tostring(StructTreeRoot);
+
+static int m_StructTreeRoot_getChild(lua_State * L)
+{
+ unsigned int i;
+ udstruct *uin, *uout;
+ StructElement *child ;
+ StructTreeRoot *root ;
+
+ uin = (udstruct *) luaL_checkudata(L, 1, M_StructTreeRoot);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ i = (unsigned) luaL_checkint(L, 2);
+ root = (StructTreeRoot *) uin->d;
+ if (i-1 < root->getNumChildren() ){
+ child = root->getChild(i-1);
+ uout = new_StructElement_userdata(L);
+ uout->d = child;
+ //uout->atype = ALLOC_LEPDF;
+ uout->pc = uin->pc;
+ uout->pd = uin->pd;
+ } else
+ lua_pushnil(L);
+ return 1;
+}
+
+static int m_StructTreeRoot_appendChild(lua_State * L)
+{
+ udstruct *uin, *uin_child, *uout;
+ StructElement *child ;
+ StructTreeRoot *root ;
+ uin = (udstruct *) luaL_checkudata(L, 1, M_StructTreeRoot);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ uin_child = (udstruct *) luaL_checkudata(L, 2, M_StructElement);
+ if (uin_child->pd != NULL && uin_child->pd->pc != uin_child->pc)
+ pdfdoc_changed_error(L);
+ root = (StructTreeRoot *) uin->d;
+ child = (StructElement *) uin_child->d;
+ root->appendChild(child);
+ return 0;
+}
+
+
+static int m_StructTreeRoot_findParentElement(lua_State * L)
+{
+ unsigned int i;
+ udstruct *uin, *uout;
+ const StructElement *parent ;
+ StructTreeRoot *root ;
+
+ uin = (udstruct *) luaL_checkudata(L, 1, M_StructTreeRoot);
+ if (uin->pd != NULL && uin->pd->pc != uin->pc)
+ pdfdoc_changed_error(L);
+ i = (unsigned) luaL_checkint(L, 2);
+ root = (StructTreeRoot *) uin->d;
+ parent = root->findParentElement(i-1);
+ if (parent != NULL) {
+ uout = new_StructElement_userdata(L);
+ uout->d = new StructElement( *parent );
+ uout->atype = ALLOC_LEPDF;
+ uout->pc = uin->pc;
+ uout->pd = uin->pd;
+ } else
+ lua_pushnil(L);
+ return 1;
+}
+
+
+static const struct luaL_Reg StructTreeRoot_m[] = {
+ {"findParentElement", m_StructTreeRoot_findParentElement},
+ {"getDoc",m_StructTreeRoot_getDoc},
+ {"getRoleMap",m_StructTreeRoot_getRoleMap},
+ {"getClassMap",m_StructTreeRoot_getClassMap},
+ {"getNumChildren",m_StructTreeRoot_getNumChildren},
+ {"getChild",m_StructTreeRoot_getChild},
+ {"appendChild",m_StructTreeRoot_appendChild},
+ {"findParentElement",m_StructTreeRoot_findParentElement},
+ {"__tostring", m_StructTreeRoot__tostring},
+ {NULL, NULL} // sentinel
+};
+#endif
+
//**********************************************************************
// XRef
@@ -2667,6 +3434,12 @@ int luaopen_epdf(lua_State * L)
setfuncs_meta(PDFRectangle);
setfuncs_meta(Ref);
setfuncs_meta(Stream);
+#ifdef HAVE_STRUCTTREEROOT_H
+ setfuncs_meta(Attribute);
+ setfuncs_meta(StructElement);
+ setfuncs_meta(StructTreeRoot);
+ setfuncs_meta(TextSpan);
+#endif
setfuncs_meta(XRef);
setfuncs_meta(XRefEntry);
diff --git a/Build/source/texk/web2c/luatexdir/lua/llanglib.c b/Build/source/texk/web2c/luatexdir/lua/llanglib.c
index b0d2efb5333..e0139d677d5 100644
--- a/Build/source/texk/web2c/luatexdir/lua/llanglib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/llanglib.c
@@ -23,7 +23,7 @@
static const char _svn_version[] =
- "$Id: llanglib.c 4524 2012-12-20 15:38:02Z taco $ $URL: https://foundry.supelec.fr/svn/luatex/branches/ex-glyph/source/texk/web2c/luatexdir/lua/llanglib.c $";
+ "$Id: llanglib.c 4524 2012-12-20 15:38:02Z taco $ $URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/lua/llanglib.c $";
#define LANG_METATABLE "luatex.lang"
diff --git a/Build/source/texk/web2c/luatexdir/lua/llfslibext.c b/Build/source/texk/web2c/luatexdir/lua/llfslibext.c
index a72369cb66e..78972b53b18 100644
--- a/Build/source/texk/web2c/luatexdir/lua/llfslibext.c
+++ b/Build/source/texk/web2c/luatexdir/lua/llfslibext.c
@@ -25,7 +25,7 @@
#include <time.h>
static const char _svn_version[] =
- "$Id: llfslibext.c 4421 2012-05-21 15:20:49Z taco $ $URL: https://foundry.supelec.fr/svn/luatex/branches/ex-glyph/source/texk/web2c/luatexdir/lua/llfslibext.c $";
+ "$Id: llfslibext.c 4421 2012-05-21 15:20:49Z taco $ $URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/lua/llfslibext.c $";
#ifdef _WIN32
# include <windows.h>
diff --git a/Build/source/texk/web2c/luatexdir/lua/lnodelib.c b/Build/source/texk/web2c/luatexdir/lua/lnodelib.c
index 4f98dc19526..dfe51e26b69 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lnodelib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lnodelib.c
@@ -96,7 +96,7 @@
*/
static const char _svn_version[] =
- "$Id: lnodelib.c 4956 2014-03-28 12:12:17Z luigi $ "
+ "$Id: lnodelib.c 5091 2014-12-09 15:44:36Z luigi $ "
"$URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/lua/lnodelib.c $";
#include "ptexlib.h"
@@ -1984,14 +1984,18 @@ static int lua_nodelib_end_of_math(lua_State * L)
halfword *n;
halfword t;
if (lua_isnil(L, 1))
- return 1; /* the nil itself */
+ return 0;
n = check_isnode(L, 1);
t = *n;
if (t == null)
- return 1; /* the old userdata */
+ return 0;
+ if (type(t)==math_node && (subtype(t)==1)) {
+ lua_nodelib_push_fast(L, t);
+ return 1;
+ }
while (vlink(t) != null) {
- t = vlink(t); /* skip first node */
- if (t && type(t)==math_node) {
+ t = vlink(t);
+ if (t && (type(t)==math_node) && (subtype(t)==1)) {
lua_nodelib_push_fast(L, t);
return 1;
}
@@ -2005,19 +2009,23 @@ static int lua_nodelib_direct_end_of_math(lua_State * L)
{
halfword n;
n = (halfword) lua_tonumber(L, 1);
- if (n != null) {
- while (vlink(n) != null) {
- n = vlink(n); /* skip first node */
- if (n && type(n)==math_node) {
- lua_pushnumber(L, n);
- return 1;
- }
+ if (n == null)
+ return 0;
+ if ((type(n)==math_node && (subtype(n)==1))) {
+ lua_pushnumber(L, n);
+ return 1;
+ }
+ while (vlink(n) != null) {
+ n = vlink(n);
+ if (n && (type(n)==math_node) && (subtype(n)==1)) {
+ lua_pushnumber(L, n);
+ return 1;
}
}
- lua_pushnil(L);
return 0;
}
+
/* node.has_attribute (gets attribute) */
static int lua_nodelib_has_attribute(lua_State * L)
@@ -4171,7 +4179,7 @@ static int lua_nodelib_has_glyph(lua_State * L)
halfword *a;
halfword h = (halfword) *(check_isnode(L,1)) ;
while (h != null) {
- if (type(h) == glyph_node) {
+ if ( (type(h) == glyph_node) || (type(h) == disc_node)) {
fast_metatable(h);
return 1;
} else {
@@ -4188,7 +4196,7 @@ static int lua_nodelib_direct_has_glyph(lua_State * L)
{
halfword h = (halfword) lua_tonumber(L,1) ;
while (h != null) {
- if (type(h) == glyph_node) {
+ if ((type(h) == glyph_node) || (type(h) == disc_node)) {
nodelib_pushdirect(h);
return 1;
} else {
diff --git a/Build/source/texk/web2c/luatexdir/lua/loslibext.c b/Build/source/texk/web2c/luatexdir/lua/loslibext.c
index 78f1e4803ab..575202b05db 100644
--- a/Build/source/texk/web2c/luatexdir/lua/loslibext.c
+++ b/Build/source/texk/web2c/luatexdir/lua/loslibext.c
@@ -25,7 +25,7 @@
#include <time.h>
static const char _svn_version[] =
- "$Id: loslibext.c 4479 2012-11-07 16:38:55Z taco $ $URL: https://foundry.supelec.fr/svn/luatex/branches/ex-glyph/source/texk/web2c/luatexdir/lua/loslibext.c $";
+ "$Id: loslibext.c 4479 2012-11-07 16:38:55Z taco $ $URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/lua/loslibext.c $";
#if defined(_WIN32) || defined(__NT__)
# define MKDIR(a,b) mkdir(a)
diff --git a/Build/source/texk/web2c/luatexdir/lua/lpdflib.c b/Build/source/texk/web2c/luatexdir/lua/lpdflib.c
index a93f75a2aa0..1762833b037 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lpdflib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lpdflib.c
@@ -18,7 +18,7 @@
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
static const char _svn_version[] =
- "$Id: lpdflib.c 4956 2014-03-28 12:12:17Z luigi $ "
+ "$Id: lpdflib.c 5018 2014-06-06 09:11:09Z taco $ "
"$URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/lua/lpdflib.c $";
#include "ptexlib.h"
@@ -576,8 +576,10 @@ static int getpdf(lua_State * L)
s = lua_tostring(L, -1);
if (lua_key_eq(s,h)) {
lua_pushnumber(L, static_pdf->posstruct->pos.h);
+ return 1;
} else if (lua_key_eq(s,v)) {
lua_pushnumber(L, static_pdf->posstruct->pos.v);
+ return 1;
} else if (
lua_key_eq(s,catalog) || lua_key_eq(s,info) || lua_key_eq(s,trailer) || lua_key_eq(s,names) ||
lua_key_eq(s,pageattributes) || lua_key_eq(s,pagesattributes) || lua_key_eq(s,pageresources)
@@ -587,9 +589,10 @@ static int getpdf(lua_State * L)
/* [pdf table] [key] [pdf.data table] */
lua_replace(L, -3);
/* [pdf.data table] [key] */
+ lua_rawget(L, -2);
+ return 1;
}
}
- lua_rawget(L, -2);
return 0;
}
diff --git a/Build/source/texk/web2c/luatexdir/lua/lstatslib.c b/Build/source/texk/web2c/luatexdir/lua/lstatslib.c
index 2d301d7369f..acf6895dbf3 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lstatslib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lstatslib.c
@@ -18,7 +18,7 @@
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
static const char _svn_version[] =
- "$Id: lstatslib.c 4956 2014-03-28 12:12:17Z luigi $ "
+ "$Id: lstatslib.c 5081 2014-11-07 18:38:33Z luigi $ "
"$URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/lua/lstatslib.c $";
#include "ptexlib.h"
diff --git a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c
index 48c9e6f17ac..df5b4748800 100644
--- a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c
@@ -27,7 +27,7 @@ setter no prev link is created so we can presume that it's not used later on. */
static const char _svn_version[] =
- "$Id: ltexlib.c 4956 2014-03-28 12:12:17Z luigi $ $URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/lua/ltexlib.c $";
+ "$Id: ltexlib.c 5081 2014-11-07 18:38:33Z luigi $ $URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/lua/ltexlib.c $";
#define attribute(A) eqtb[attribute_base+(A)].hh.rh
#define dimen(A) eqtb[scaled_base+(A)].hh.rh
@@ -288,7 +288,7 @@ void luacstring_close(int n)
next = next->next;
if (t==read_spindle.tail) {
read_spindle.tail = NULL; // prevent double-free
- }
+ }
free(t);
}
read_spindle.head = NULL;
@@ -2443,7 +2443,7 @@ static int tex_run_boot(lua_State * L)
/* tex random generators */
static int tex_init_rand(lua_State * L)
-{
+{
int sp;
if (!lua_isnumber(L, 1)) {
luaL_error(L, "argument must be a number");
@@ -2455,7 +2455,7 @@ static int tex_init_rand(lua_State * L)
}
static int tex_unif_rand(lua_State * L)
-{
+{
int sp;
if (!lua_isnumber(L, 1)) {
luaL_error(L, "argument must be a number");
@@ -2467,13 +2467,13 @@ static int tex_unif_rand(lua_State * L)
}
static int tex_norm_rand(lua_State * L)
-{
+{
lua_pushnumber(L, norm_rand());
return 1;
}
/* Same as lua but with tex rng */
-static int lua_math_random (lua_State *L)
+static int lua_math_random (lua_State *L)
{
lua_Number rand_max = 0x7fffffff ;
lua_Number r = unif_rand(rand_max) ;
@@ -2504,6 +2504,39 @@ static int lua_math_random (lua_State *L)
+/* Experimental code can either become permanent or disappear. It is
+undocumented and mostly present in the experimental branch but for
+practical reasons we also have the setup code in the regular binary.
+The experimental_code array is indexed by i with 1<= i <= max_experimental_code,
+position 0 is not used */
+int experimental_code[MAX_EXPERIMENTAL_CODE_SIZE] = { 0 };
+
+
+static int set_experimental_code(lua_State *L)
+{
+ int e, b, i ;
+
+ if (lua_isboolean(L,1)) {
+ e = 0 ;
+ b = lua_toboolean(L,1) ;
+ } else if (lua_isnumber(L,1) && lua_isboolean(L,2)) {
+ e = (int) lua_tonumber(L, 1);
+ b = lua_toboolean(L,2) ;
+ } else {
+ return luaL_error(L, "boolean or number and boolean expected");
+ }
+ if (e==0) {
+ for (i=1;i<=max_experimental_code;i++) {
+ experimental_code[i] = b;
+ }
+ } else if (0<e && e<=max_experimental_code ) {
+ experimental_code[e] = b;
+ } else {
+ return luaL_error(L, "first number out of range");
+ }
+ return 0;
+}
+
static int tex_run_main(lua_State * L)
{
(void) L;
@@ -2609,6 +2642,7 @@ static const struct luaL_Reg texlib[] = {
{"normal_rand", tex_norm_rand},
{"lua_math_randomseed", tex_init_rand}, /* syntactic sugar */
{"lua_math_random", lua_math_random},
+ {"set_experimental_code",set_experimental_code},
{"show_context", tex_show_context},
{NULL, NULL} /* sentinel */
};
diff --git a/Build/source/texk/web2c/luatexdir/lua/luainit.w b/Build/source/texk/web2c/luatexdir/lua/luainit.w
index dbf49093516..11d78503e30 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luainit.w
+++ b/Build/source/texk/web2c/luatexdir/lua/luainit.w
@@ -19,7 +19,7 @@
@ @c
static const char _svn_version[] =
- "$Id: luainit.w 4956 2014-03-28 12:12:17Z luigi $"
+ "$Id: luainit.w 5081 2014-11-07 18:38:33Z luigi $"
"$URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/lua/luainit.w $";
#include "ptexlib.h"
diff --git a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h
index a42b147c301..6e9c5e278e7 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h
+++ b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License along
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
-/* $Id: luatex-api.h 4956 2014-03-28 12:12:17Z luigi $ */
+/* $Id: luatex-api.h 5081 2014-11-07 18:38:33Z luigi $ */
#ifndef LUATEX_API_H
# define LUATEX_API_H 1
@@ -1002,6 +1002,29 @@ init_lua_key_alias(term_and_log,"term and log")
} while(0)
+
+
+#ifdef __MINGW32__
+extern FILE *_cairo_win32_tmpfile( void );
+#define tmpfile() _cairo_win32_tmpfile()
+#endif /* __MINGW32__ */
+
+
+
+/*
+* experimental code (no primitive):
+
+ 0 = all
+ 1 = retain math nodes
+
+*/
+
+#define max_experimental_code 1
+#define MAX_EXPERIMENTAL_CODE_SIZE max_experimental_code+1
+/* to be indexed by i with 1<= i <=max_experimental_code */
+extern int experimental_code[MAX_EXPERIMENTAL_CODE_SIZE] ;
+
+
#endif /* LUATEX_API_H */