texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: * tp/Texinfo/XS/main/build_perl_info.c (fill_outp


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/main/build_perl_info.c (fill_output_units_descriptor_av): store a the document descriptor along with output_units descriptor in the Perl output units data, as both the document and output units list number in document are needed to retrieve the output units list in C.
Date: Fri, 04 Oct 2024 19:52:31 -0400

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new a63b03b1af * tp/Texinfo/XS/main/build_perl_info.c 
(fill_output_units_descriptor_av): store a the document descriptor along with 
output_units descriptor in the Perl output units data, as both the document and 
output units list number in document are needed to retrieve the output units 
list in C.
a63b03b1af is described below

commit a63b03b1af8a32fb82180e7a034a6b0ebbd764fe
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Aug 17 21:15:02 2024 +0200

    * tp/Texinfo/XS/main/build_perl_info.c
    (fill_output_units_descriptor_av): store a the document descriptor
    along with output_units descriptor in the Perl output units data, as
    both the document and output units list number in document are needed
    to retrieve the output units list in C.
    
    * tp/Texinfo/XS/main/get_perl_info.c (get_sv_output_units_descriptor)
    (get_sv_output_units): add a document out argument in
    get_sv_output_units_descriptor and find the document associated with
    the output units if set.  If the document argument of
    get_sv_output_units is NULL, call get_sv_output_units_descriptor such
    as to find the document.  Update callers.
    
    * tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs
    (split_pages): remove document SV argument, as there is no such
    argument in Perl and get the document from the output units list SV.
    
    * tp/t/test_utils.pl: add comments to explain why descriptors added to
    output units by XS code to retrieve output units descriptor and
    document descriptor do not show up in tests results.
---
 ChangeLog                                          | 23 +++++++++
 .../api_includes/Texinfo-Convert-Converter.texi    |  6 +--
 tp/Texinfo/ManipulateTree.pm                       |  3 +-
 tp/Texinfo/OutputUnits.pm                          |  1 -
 tp/Texinfo/XS/convert/get_html_perl_info.c         |  2 +-
 tp/Texinfo/XS/main/build_perl_info.c               |  4 ++
 tp/Texinfo/XS/main/get_perl_info.c                 | 60 +++++++++++++++++-----
 tp/Texinfo/XS/main/get_perl_info.h                 |  3 +-
 .../XS/structuring_transfo/StructuringTransfoXS.xs | 21 ++++----
 tp/t/test_utils.pl                                 | 25 ++++++---
 10 files changed, 114 insertions(+), 34 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 98d0ad3d20..43ea6cb139 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2024-08-17  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/build_perl_info.c
+       (fill_output_units_descriptor_av): store a the document descriptor
+       along with output_units descriptor in the Perl output units data, as
+       both the document and output units list number in document are needed
+       to retrieve the output units list in C.
+
+       * tp/Texinfo/XS/main/get_perl_info.c (get_sv_output_units_descriptor)
+       (get_sv_output_units): add a document out argument in
+       get_sv_output_units_descriptor and find the document associated with
+       the output units if set.  If the document argument of
+       get_sv_output_units is NULL, call get_sv_output_units_descriptor such
+       as to find the document.  Update callers.
+
+       * tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs
+       (split_pages): remove document SV argument, as there is no such
+       argument in Perl and get the document from the output units list SV.
+
+       * tp/t/test_utils.pl: add comments to explain why descriptors added to
+       output units by XS code to retrieve output units descriptor and
+       document descriptor do not show up in tests results.
+
 2024-08-17  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/get_converter_perl_info.c
diff --git a/doc/tp_api/api_includes/Texinfo-Convert-Converter.texi 
b/doc/tp_api/api_includes/Texinfo-Convert-Converter.texi
index 0490152454..949e1fa35c 100644
--- a/doc/tp_api/api_includes/Texinfo-Convert-Converter.texi
+++ b/doc/tp_api/api_includes/Texinfo-Convert-Converter.texi
@@ -224,13 +224,13 @@ To help with these initializations, the modules 
subclassing @code{Texinfo::Conve
 can define two methods:
 
 @table @asis
-@item \%defaults = $converter->converter_defaults($options)
-@anchor{Texinfo@asis{::}Convert@asis{::}Converter \%defaults = 
$converter->converter_defaults($options)}
+@item \%defaults = $converter_or_class->converter_defaults($options)
+@anchor{Texinfo@asis{::}Convert@asis{::}Converter \%defaults = 
$converter_or_class->converter_defaults($options)}
 @cindex @code{converter_defaults}
 
 The module can provide the reference on a hash with defaults for converter
 customization options.  The @emph{$options} hash reference holds options for 
the
-converter.
+converter.  The function can be called both through a class or a converter.
 
 @item converter_initialize
 @anchor{Texinfo@asis{::}Convert@asis{::}Converter converter_initialize}
diff --git a/tp/Texinfo/ManipulateTree.pm b/tp/Texinfo/ManipulateTree.pm
index 08bb11e9d1..1a2ae7b132 100644
--- a/tp/Texinfo/ManipulateTree.pm
+++ b/tp/Texinfo/ManipulateTree.pm
@@ -93,8 +93,8 @@ sub import {
   goto &Exporter::import;
 }
 
-
 
+
 # copy a Texinfo tree.
 
 # TODO document in POD?
@@ -338,6 +338,7 @@ sub copy_contentsNonXS($;$)
 }
 
 
+
 # Texinfo tree transformations used in main output formats conversion.
 
 sub modify_tree($$;$);
diff --git a/tp/Texinfo/OutputUnits.pm b/tp/Texinfo/OutputUnits.pm
index d82066e96f..e022657e7e 100644
--- a/tp/Texinfo/OutputUnits.pm
+++ b/tp/Texinfo/OutputUnits.pm
@@ -75,7 +75,6 @@ my %XS_convert_overrides = (
   #    => "Texinfo::StructTransfXS::split_by_node");
   #  "Texinfo::OutputUnits::split_by_section"
   #    => "Texinfo::StructTransfXS::split_by_section");
-  # TODO the split_pages XS takes also a document as argument
   #  "Texinfo::OutputUnits::split_pages"
   #    => "Texinfo::StructTransfXS::split_pages"
 );
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c 
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index 2bd4779a85..f9a5cbcc55 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -1641,7 +1641,7 @@ get_output_units_descriptor_converter_sv (SV 
*converter_in)
   if (output_units_sv && SvOK (*output_units_sv))
     output_units_descriptor
         = get_sv_output_units_descriptor (*output_units_sv,
-                     "html_command_id output units");
+                          "html_command_id output units", 0);
 
   return output_units_descriptor;
 }
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index 6942efe181..5518cc4961 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -2409,6 +2409,7 @@ build_sorted_indices_by_letter (
 }
 
 
+
 /* Build Output unit and output units lists to Perl*/
 
 static void
@@ -2622,6 +2623,9 @@ fill_output_units_descriptor_av (const DOCUMENT *document,
   hv_store (output_units->list[0]->hv, "output_units_descriptor",
             strlen ("output_units_descriptor"),
             newSViv ((IV)output_units_descriptor), 0);
+  hv_store (output_units->list[0]->hv, "output_units_document_descriptor",
+            strlen ("output_units_document_descriptor"),
+            newSViv ((IV)document->descriptor), 0);
   return 1;
 }
 
diff --git a/tp/Texinfo/XS/main/get_perl_info.c 
b/tp/Texinfo/XS/main/get_perl_info.c
index 42ed7cf7c4..17d1b9670e 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -162,9 +162,13 @@ get_sv_document_document (SV *document_in, char 
*warn_string)
                                warn_string);
 }
 
-/* caller should ensure that OUTPUT_UNIT_IN is defined */
+/* caller should ensure that OUTPUT_UNIT_IN is defined.
+   If DOCUMENT_OUT is set, find the document associated with the output units
+   too.
+ */
 size_t
-get_sv_output_units_descriptor (SV *output_units_in, char *warn_string)
+get_sv_output_units_descriptor (SV *output_units_in, char *warn_string,
+                                const DOCUMENT **document_out)
 {
   size_t output_units_descriptor = 0;
   AV *av_in;
@@ -174,6 +178,9 @@ get_sv_output_units_descriptor (SV *output_units_in, char 
*warn_string)
 
   dTHX;
 
+  if (document_out)
+    *document_out = 0;
+
   if (!SvOK (output_units_in))
     {
       fprintf (stderr, "get_sv_output_units_descriptor: %s: undef in\n",
@@ -203,6 +210,15 @@ get_sv_output_units_descriptor (SV *output_units_in, char 
*warn_string)
             }
           else if (warn_string)
             fprintf (stderr, "ERROR: %s: no %s\n", warn_string, key);
+
+          if (document_out)
+            {
+              DOCUMENT *document
+               = get_document_or_warn (*first_output_unit_sv,
+                                       "output_units_document_descriptor",
+                                       warn_string);
+              *document_out = document;
+            }
         }
       else
         fprintf (stderr, "BUG: get_sv_output_units: av_fetch failed\n");
@@ -215,17 +231,37 @@ get_sv_output_units_descriptor (SV *output_units_in, char 
*warn_string)
   return output_units_descriptor;
 }
 
-
+/* If DOCUMENT is NULL, it is found using the descriptor associated with
+   the first output unit in SV along with the output_units descriptor.
+   In general, the DOCUMENT is not NULL in current codes call to
+   get_sv_output_units, as previously there was no document descriptor
+   availalble.  In the future, it could make sense to get the document
+   from the output units SV instead. */
 OUTPUT_UNIT_LIST *
-get_sv_output_units (const DOCUMENT *document, SV *output_units_in,
-                     char *warn_string)
+get_sv_output_units (const DOCUMENT *document,
+                     SV *output_units_in, char *warn_string)
 {
   OUTPUT_UNIT_LIST *output_units = 0;
-  size_t output_units_descriptor
-     = get_sv_output_units_descriptor (output_units_in, warn_string);
-  if (output_units_descriptor)
+  const DOCUMENT *document_found = 0;
+  size_t output_units_descriptor = 0;
+
+  if (document)
+    {
+      document_found = document;
+      output_units_descriptor
+        = get_sv_output_units_descriptor (output_units_in, warn_string, 0);
+    }
+  else
+    {
+      output_units_descriptor
+        = get_sv_output_units_descriptor (output_units_in, warn_string,
+                                          &document_found);
+    }
+
+  if (output_units_descriptor && document_found)
     {
-      output_units = retrieve_output_units (document, output_units_descriptor);
+      output_units = retrieve_output_units (document_found,
+                                            output_units_descriptor);
       if (!output_units && warn_string)
         fprintf (stderr, "ERROR: %s: no units %zu\n", warn_string,
                                              output_units_descriptor);
@@ -1365,7 +1401,7 @@ find_subentry_index_command_sv (const DOCUMENT *document, 
HV *element_hv)
 /* find the INDEX_ENTRY associated element matching ELEMENT_HV.
 
    If the index entry was reassociated, the tree element the
-   index entry is reassociated to is not index_entry->entry_element
+   index entry is reassociated with is not index_entry->entry_element
    but index_entry->entry_associated_element.  The original
    tree element that was associated is index_entry->entry_element.
    Depending on the situation one or the other may be looked for
@@ -1375,7 +1411,7 @@ find_subentry_index_command_sv (const DOCUMENT *document, 
HV *element_hv)
    when doing a link to the tree from the index entry.  But it may
    also be the original tree element that is used, for example
    to get the index entry tree element content, for instance
-   when going through the elements associated to indices to setup
+   when going through the elements associated with indices to setup
    index entries sort strings.
  */
 static const ELEMENT *
@@ -1532,7 +1568,7 @@ find_element_from_sv (const CONVERTER *converter, const 
DOCUMENT *document_in,
 
 /* returns the sorted index for a LANGUAGE if found.
    Also returns the hash containing the sorted index languages,
-   associated to KEY in the DOCUMENT_HV, created if it did not exist */
+   associated with KEY in the DOCUMENT_HV, created if it did not exist */
 SV *
 get_language_document_hv_sorted_indices (HV *document_hv, const char *key,
                       const char *language, HV **out_sorted_indices_hv)
diff --git a/tp/Texinfo/XS/main/get_perl_info.h 
b/tp/Texinfo/XS/main/get_perl_info.h
index b90c9cc921..8df8a2e95d 100644
--- a/tp/Texinfo/XS/main/get_perl_info.h
+++ b/tp/Texinfo/XS/main/get_perl_info.h
@@ -31,7 +31,8 @@ int get_sorted_options_key_sv_option (OPTIONS *options, 
OPTION **sorted_options,
 DOCUMENT *get_sv_tree_document (SV *tree_in, char *warn_string);
 DOCUMENT *get_sv_document_document (SV *document_in, char *warn_string);
 
-size_t get_sv_output_units_descriptor (SV *output_units_in, char *warn_string);
+size_t get_sv_output_units_descriptor (SV *output_units_in, char *warn_string,
+                                       const DOCUMENT **document_out);
 OUTPUT_UNIT_LIST *get_sv_output_units (const DOCUMENT *document,
                                        SV *output_units_in,
                                        char *warn_string);
diff --git a/tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs 
b/tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs
index eb984b2db2..e537a45a77 100644
--- a/tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs
+++ b/tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs
@@ -445,22 +445,25 @@ rebuild_output_units (SV *document_in, SV 
*output_units_in)
         if (document)
           {
             output_units_descriptor
-             = get_sv_output_units_descriptor (output_units_in, 0);
+             = get_sv_output_units_descriptor (output_units_in, 0, 0);
             if (output_units_descriptor)
               rebuild_output_units_list (document, output_units_in,
                                          output_units_descriptor);
           }
 
 void
-split_pages (SV *document_in, SV *output_units_in, char *split)
+split_pages (SV *output_units_in, char *split)
     PREINIT:
+        size_t output_units_descriptor = 0;
         const DOCUMENT *document = 0;
-        OUTPUT_UNIT_LIST *output_units = 0;
      CODE:
-        document = get_sv_document_document (document_in,
-                                             "split_pages");
-        output_units = get_sv_output_units (document,
-                                            output_units_in, "split_pages");
-        if (output_units)
-          split_pages (output_units, split);
+        output_units_descriptor
+          = get_sv_output_units_descriptor (output_units_in, "split_pages",
+                                            &document);
 
+        if (output_units_descriptor && document)
+          {
+            OUTPUT_UNIT_LIST *output_units = retrieve_output_units (document,
+                                                    output_units_descriptor);
+            split_pages (output_units, split);
+          }
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 749cc3c6b1..32de3b434e 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -1,20 +1,20 @@
 # t/* test support for the Perl modules.
 #
 # Copyright 2010-2024 Free Software Foundation, Inc.
-# 
+#
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 3 of the License,
 # or (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
-# 
+#
 # Original author: Patrice Dumas <pertusus@free.fr>
 
 use strict;
@@ -324,7 +324,12 @@ my @contents_keys = ('contents', 'args', 'parent', 
'source_info',
   'node_description', 'node_long_description', 'is_target',
   'unit_contents', 'global_command_number',
   # only set with the XS parser
-  'tree_document_descriptor', 'output_units_descriptor');
+  'tree_document_descriptor',
+  # only set with the XS.  Since there is no XS involved for the compared
+  # output units, currently there is no descriptor ending up associated
+  # with output units.
+  #'output_units_descriptor', 'output_units_document_descriptor'
+  );
 my @menus_keys = ('menu_directions', 'menus', 'menu_up_hash');
 # 'section_number' is kept in other results as it may be the only clue
 # to know which section element it is.
@@ -344,7 +349,12 @@ my @avoided_keys_tree = (@sections_keys, @menus_keys, 
@node_keys,
     'associated_unit', 'global_command_number',
     'parent',
     # only set with the XS parser
-    'tree_document_descriptor', 'output_units_descriptor');
+    'tree_document_descriptor',
+    # only set with the XS.  Since there is no XS involved for the compared
+    # output units, currently there is no descriptor ending up associated
+    # with output units.
+    #'output_units_descriptor', 'output_units_document_descriptor'
+   );
 foreach my $avoided_key(@avoided_keys_tree) {
   $avoided_keys_tree{$avoided_key} = 1;
 }
@@ -1419,6 +1429,9 @@ sub test($$)
   # (units_directions has not, though there is an implementation in C),
   # otherwise some information will be missing in the rebuild_output_units
   # output units.
+  # Since there is no XS involved in setting up the output_units compared
+  # with reference, there are no descriptor (allowing to retrieve output units
+  # list and document) associated with the first output unit.
   my $output_units;
   if ($test_split eq 'node') {
     $output_units = Texinfo::OutputUnits::split_by_node($document);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]