texlive[52497] trunk: luatex: different page reshuffle callback.

commits+lscarso at tug.org commits+lscarso at tug.org
Wed Oct 23 12:18:54 CEST 2019


Revision: 52497
          http://tug.org/svn/texlive?view=revision&revision=52497
Author:   lscarso
Date:     2019-10-23 12:18:54 +0200 (Wed, 23 Oct 2019)
Log Message:
-----------
luatex: different page reshuffle callback.  WARNING: DROPPED the   "page_objnum_provider" callback, replaced with "page_order_index". (HH)

Modified Paths:
--------------
    trunk/Build/source/texk/web2c/luatexdir/ChangeLog
    trunk/Build/source/texk/web2c/luatexdir/NEWS
    trunk/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c
    trunk/Build/source/texk/web2c/luatexdir/luatex_svnversion.h
    trunk/Build/source/texk/web2c/luatexdir/luatexcallbackids.h
    trunk/Build/source/texk/web2c/luatexdir/pdf/pdfgen.c
    trunk/Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.c
    trunk/Master/texmf-dist/doc/luatex/base/luatex-callbacks.tex
    trunk/Master/texmf-dist/doc/luatex/base/luatex.pdf

Modified: trunk/Build/source/texk/web2c/luatexdir/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/ChangeLog	2019-10-22 23:53:49 UTC (rev 52496)
+++ trunk/Build/source/texk/web2c/luatexdir/ChangeLog	2019-10-23 10:18:54 UTC (rev 52497)
@@ -1,3 +1,7 @@
+2019-10-22 Luigi Scarso <luigi.scarso at gmail.com>
+    *  *** DROPPED  "page_objnum_provider" callback , replaced with "page_order_index" ***
+
+
 2019-10-18 Luigi Scarso <luigi.scarso at gmail.com>
 	* following https://tug.org/pipermail/tlbuild/2019q3/004553.html
           we have now define(__sparc)

Modified: trunk/Build/source/texk/web2c/luatexdir/NEWS
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/NEWS	2019-10-22 23:53:49 UTC (rev 52496)
+++ trunk/Build/source/texk/web2c/luatexdir/NEWS	2019-10-23 10:18:54 UTC (rev 52497)
@@ -1,12 +1,14 @@
 
 ==============================================================
-LuaTeX 1.11.1 2019-10-18
+LuaTeX 1.11.1 2019-10-22
 ==============================================================
 
 First release of luahbtex / luajithbtex, 
 luatex / luajittex with harfbuzz.
 Small bug fixes, code clean up and a couple of new primitives
-to match eTeX. See ChangeLog and the manual.
+to match eTeX.
+*** DROPPED the   "page_objnum_provider" callback, replaced with "page_order_index". ***
+See ChangeLog and the manual.
 
 
 

Modified: trunk/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c	2019-10-22 23:53:49 UTC (rev 52496)
+++ trunk/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c	2019-10-23 10:18:54 UTC (rev 52497)
@@ -81,7 +81,7 @@
     "finish_synctex",
     "wrapup_run",
     "new_graf",
-    "page_objnum_provider",
+    "page_order_index",
     "make_extensible",
     "process_pdf_image_content",
     NULL

Modified: trunk/Build/source/texk/web2c/luatexdir/luatex_svnversion.h
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/luatex_svnversion.h	2019-10-22 23:53:49 UTC (rev 52496)
+++ trunk/Build/source/texk/web2c/luatexdir/luatex_svnversion.h	2019-10-23 10:18:54 UTC (rev 52497)
@@ -1 +1 @@
-#define luatex_svn_revision 7198
+#define luatex_svn_revision 7208

Modified: trunk/Build/source/texk/web2c/luatexdir/luatexcallbackids.h
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/luatexcallbackids.h	2019-10-22 23:53:49 UTC (rev 52496)
+++ trunk/Build/source/texk/web2c/luatexdir/luatexcallbackids.h	2019-10-23 10:18:54 UTC (rev 52497)
@@ -73,7 +73,7 @@
     finish_synctex_callback,
     wrapup_run_callback,
     new_graf_callback,
-    page_objnum_provider_callback,
+    page_order_index_callback,
     make_extensible_callback,
     process_pdf_image_content_callback,
     total_callbacks,

Modified: trunk/Build/source/texk/web2c/luatexdir/pdf/pdfgen.c
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/pdf/pdfgen.c	2019-10-22 23:53:49 UTC (rev 52496)
+++ trunk/Build/source/texk/web2c/luatexdir/pdf/pdfgen.c	2019-10-23 10:18:54 UTC (rev 52497)
@@ -1777,7 +1777,12 @@
     if (callback_id > 0)
       run_callback(callback_id, "b->",(global_shipping_mode == SHIPPING_PAGE));
     if (global_shipping_mode == SHIPPING_PAGE) {
-        pdf->last_pages = pdf_do_page_divert(pdf, pdf->last_page, 0);
+        int location = 0;
+        int callback_id = callback_defined(page_order_index_callback);
+        if (callback_id) {
+            run_callback(callback_id, "d->d", total_pages, &location);
+        }
+        pdf->last_pages = pdf_do_page_divert(pdf, pdf->last_page, location);
         /*tex  Write out the |/Page| object. */
         pdf_begin_obj(pdf, pdf->last_page, OBJSTM_ALWAYS);
         pdf_begin_dict(pdf);

Modified: trunk/Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.c
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.c	2019-10-22 23:53:49 UTC (rev 52496)
+++ trunk/Build/source/texk/web2c/luatexdir/pdf/pdfpagetree.c	2019-10-23 10:18:54 UTC (rev 52497)
@@ -162,7 +162,7 @@
 
 /*tex Write a |/Pages| object. */
 
-static void write_pages(PDF pdf, pages_entry * p, int parent, int callback_id)
+static void write_pages(PDF pdf, pages_entry * p, int parent)
 {
     int i;
     int pages_attributes ;
@@ -185,19 +185,7 @@
     pdf_add_name(pdf, "Kids");
     pdf_begin_array(pdf);
     for (i = 0; i < p->number_of_kids; i++) {
-        if (callback_id) {
-            /* new */
-            int objnum = (int) p->kids[i];
-            if (obj_type(pdf, objnum) == obj_type_page) {
-                run_callback(callback_id, "d->d", objnum, &objnum);
-                check_obj_exists(pdf, objnum);
-                pdf_add_ref(pdf, (int) objnum);
-            } else {
-                pdf_add_ref(pdf, (int) p->kids[i]);
-            }
-        } else {
-            pdf_add_ref(pdf, (int) p->kids[i]);
-        }
+        pdf_add_ref(pdf, (int) p->kids[i]);
     }
     pdf_end_array(pdf);
     pdf_end_dict(pdf);
@@ -211,12 +199,12 @@
 
 */
 
-static int output_pages_list(PDF pdf, pages_entry * pe, int callback_id)
+static int output_pages_list(PDF pdf, pages_entry * pe)
 {
     pages_entry *p, *q, *r;
     if (pe->next == NULL) {
         /*tex Everything fits into one |pages_entry|. */
-        write_pages(pdf, pe, 0, callback_id);
+        write_pages(pdf, pe, 0);
         return pe->objnum;
     }
     /*tex One level higher needed. */
@@ -228,19 +216,18 @@
         }
         q->kids[q->number_of_kids++] = p->objnum;
         q->number_of_pages += p->number_of_pages;
-        write_pages(pdf, p, q->objnum, callback_id);
+        write_pages(pdf, p, q->objnum);
     }
     /*tex Recurse through next higher level. */
-    return output_pages_list(pdf, r, callback_id);
+    return output_pages_list(pdf, r);
 }
 
 int output_pages_tree(PDF pdf)
 {
-    int callback_id = callback_defined(page_objnum_provider_callback);
     divert_list_entry *d;
     /*tex Concatenate all diversions into diversion 0. */
     pdf_do_page_undivert(0, 0);
     /*tex Get diversion 0. */
     d = get_divert_list(0);
-    return output_pages_list(pdf, d->first, callback_id);
+    return output_pages_list(pdf, d->first);
 }

Modified: trunk/Master/texmf-dist/doc/luatex/base/luatex-callbacks.tex
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/base/luatex-callbacks.tex	2019-10-22 23:53:49 UTC (rev 52496)
+++ trunk/Master/texmf-dist/doc/luatex/base/luatex-callbacks.tex	2019-10-23 10:18:54 UTC (rev 52497)
@@ -1038,7 +1038,7 @@
 This callback is called after the \PDF\ page stream has been assembled and before
 the page object gets finalized.
 
-\subsection{\cbk {page_objnum_provider}}
+\subsection{\cbk {page_order_index}}
 
 \topicindex{callbacks+\PDF\ file}
 
@@ -1046,28 +1046,27 @@
 that determines the order in a \PDF\ file:
 
 \startfunctioncall
-function(objnum)
-  return objnum
+function(pagenumber)
+  return pagenumber
 end
 \stopfunctioncall
 
-We can for instance swap the first and last page:
+Say that we have 12 pages, then we can do this:
 
 \starttyping
-local n = 0
-callback.register("page_objnum_provider",function(objnum)
-    n = n + 1
-    if n == 1 then
-        return pdf.getpageref(tex.count[0])
-    elseif n == tex.count[0] then
-        return pdf.getpageref(1)
-    else
-        return objnum
+callback.register("page_order_index",function(page)
+        if page ==  1 then return 12
+    elseif page ==  2 then return 11
+    elseif page == 11 then return  2
+    elseif page == 12 then return  1
+    else                   return page
     end
 end)
 \stoptyping
 
-When you mess things up \unknown\ don't complain.
+This will swap the first two and last two pages. You need to know the number of
+pages which is a side effect of the implementation. When you mess things up
+\unknown\ don't complain.
 
 \subsection{\cbk {process_pdf_image_content}}
 

Modified: trunk/Master/texmf-dist/doc/luatex/base/luatex.pdf
===================================================================
(Binary files differ)



More information about the tex-live-commits mailing list