texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Mon, 6 Nov 2023 08:43:54 -0500 (EST)

branch: master
commit 1b12deb06fd9a49d4337e4d55add6c9498f5ec3b
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Nov 6 14:43:42 2023 +0100

    * tp/Texinfo/Convert/HTML.pm (_prepare_units_directions_files)
    (output, _html_set_pages_files): return files_source_info as a
    reference on a hash instead of a hash.
    
    * tp/Texinfo/Convert/HTML.pm (_prepare_units_directions_files),
    tp/Texinfo/XS/convert/ConvertXS.xs
    (html_prepare_units_directions_files),
    tp/Texinfo/XS/main/build_perl_info.c
    (build_html_elements_in_file_count, pass_html_elements_in_file_count)
    (pass_output_unit_files): set elements_in_file_count, filenames,
    file_counters and out_filepaths on pperl converter from C/XS in
    _prepare_units_directions_files.
---
 ChangeLog                            | 15 +++++++++++
 tp/Texinfo/Convert/HTML.pm           | 26 +++++++------------
 tp/Texinfo/XS/convert/ConvertXS.xs   | 27 ++++++-------------
 tp/Texinfo/XS/main/build_perl_info.c | 50 +++++++++++++++++++++++++++++++++---
 tp/Texinfo/XS/main/build_perl_info.h |  9 +++----
 5 files changed, 83 insertions(+), 44 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fdb7727109..0e1d526bcb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2023-11-06  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm (_prepare_units_directions_files)
+       (output, _html_set_pages_files): return files_source_info as a
+       reference on a hash instead of a hash.
+
+       * tp/Texinfo/Convert/HTML.pm (_prepare_units_directions_files),
+       tp/Texinfo/XS/convert/ConvertXS.xs
+       (html_prepare_units_directions_files),
+       tp/Texinfo/XS/main/build_perl_info.c
+       (build_html_elements_in_file_count, pass_html_elements_in_file_count)
+       (pass_output_unit_files): set elements_in_file_count, filenames,
+       file_counters and out_filepaths on pperl converter from C/XS in
+       _prepare_units_directions_files.
+
 2023-11-06  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/build_perl_info.c
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 5708791048..2fd33b5a35 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -9380,7 +9380,7 @@ sub _html_set_pages_files($$$$$$$$$)
     }
   }
 
-  return %files_source_info;
+  return \%files_source_info;
 }
 
 sub _XS_prepare_conversion_units($;$)
@@ -9467,20 +9467,12 @@ sub _prepare_units_directions_files($$$$$$$$)
   my $document_name = shift;
 
   if ($self->{'converter_descriptor'} and $XS_convert) {
-    my ($XS_files_source_info,
-        $elements_in_file_count, $filenames,
-        $file_counters, $out_filepaths)
+    my $XS_files_source_info
       = _XS_prepare_units_directions_files($self,
            $output_units, $special_units, $associated_special_units,
            $output_file, $destination_directory,
            $output_filename, $document_name);
-    $self->{'elements_in_file_count'} = $elements_in_file_count;
-
-    $self->{'filenames'} = $filenames;
-    $self->{'file_counters'} = $file_counters;
-    $self->{'out_filepaths'} = $out_filepaths;
-
-    return %$XS_files_source_info;
+    return $XS_files_source_info;
   }
 
   $self->_prepare_output_units_global_targets($output_units, $special_units,
@@ -9490,9 +9482,9 @@ sub _prepare_units_directions_files($$$$$$$$)
 
   # determine file names associated with the different pages, and setup
   # the counters for special element pages.
-  my %files_source_info;
+  my $files_source_info;
   if ($output_file ne '') {
-    %files_source_info =
+    $files_source_info =
       $self->_html_set_pages_files($output_units, $special_units,
                     $associated_special_units, $output_file,
                     $destination_directory, $output_filename, $document_name);
@@ -9521,7 +9513,7 @@ sub _prepare_units_directions_files($$$$$$$$)
     }
   }
 
-  return %files_source_info;
+  return $files_source_info;
 }
 
 sub _register_special_unit($$)
@@ -11787,7 +11779,7 @@ sub output($$)
   # setup untranslated strings
   $self->_translate_names();
 
-  my %files_source_info
+  my $files_source_info
     = $self->_prepare_units_directions_files($output_units, $special_units,
                 $associated_special_units,
                 $output_file, $destination_directory, $output_filename,
@@ -11995,7 +11987,7 @@ sub output($$)
                                                    => $label_contents}),
                $redirection_filename),
             $target_element->{'source_info'});
-          my $file_source = $files_source_info{$redirection_filename};
+          my $file_source = $files_source_info->{$redirection_filename};
           my $file_info_type = $file_source->{'file_info_type'};
           if ($file_info_type eq 'special_file'
               or $file_info_type eq 'stand_in_file') {
@@ -12063,7 +12055,7 @@ sub output($$)
           next;
         }
         $redirection_filenames{$redirection_filename} = $target_element;
-        $files_source_info{$redirection_filename}
+        $files_source_info->{$redirection_filename}
           = {'file_info_type' => 'redirection',
              'file_info_element' => $target_element,
              'file_info_path' => undef,
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 6b33d80161..4a60c8ed46 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -273,7 +273,7 @@ html_prepare_conversion_units (SV *converter_in, ...)
          PUSHs(sv_2mortal(special_units_sv));
          PUSHs(sv_2mortal(associated_special_units_sv));
 
-void
+SV *
 html_prepare_units_directions_files (SV *converter_in, SV *output_units_in, SV 
*special_units_in, SV *associated_special_units_in, output_file, 
destination_directory, output_filename, document_name)
          char *output_file = (char *)SvPVutf8_nolen($arg);
          char *destination_directory = (char *)SvPVutf8_nolen($arg);
@@ -286,12 +286,7 @@ html_prepare_units_directions_files (SV *converter_in, SV 
*output_units_in, SV *
          int associated_special_units_descriptor = 0;
          FILE_SOURCE_INFO_LIST *files_source_info = 0;
          SV *files_source_info_sv;
-         SV *elements_in_file_count_sv;
-
-         SV *filenames_sv;
-         SV *file_counters_sv;
-         SV *out_filepaths_sv;
-   PPCODE:
+     CODE:
          /* add warn string? */
          self = get_sv_converter (converter_in, 0);
          if (SvOK (output_units_in))
@@ -322,21 +317,15 @@ html_prepare_units_directions_files (SV *converter_in, SV 
*output_units_in, SV *
          pass_html_global_units_directions (converter_in,
                                             self->global_units_directions,
                                             
self->special_units_direction_name);
-         elements_in_file_count_sv
-           = build_html_elements_in_file_count (&self->output_unit_files);
+         pass_html_elements_in_file_count (converter_in,
+                                           &self->output_unit_files);
 
          /* file names API */
-         filenames_sv = build_filenames (&self->output_unit_files);
-         file_counters_sv = build_file_counters (&self->output_unit_files);
-         out_filepaths_sv = build_out_filepaths (&self->output_unit_files);
-
-         EXTEND(SP, 5);
-         PUSHs(sv_2mortal(files_source_info_sv));
-         PUSHs(sv_2mortal(elements_in_file_count_sv));
+         pass_output_unit_files (converter_in, &self->output_unit_files);
 
-         PUSHs(sv_2mortal(filenames_sv));
-         PUSHs(sv_2mortal(file_counters_sv));
-         PUSHs(sv_2mortal(out_filepaths_sv));
+         RETVAL = files_source_info_sv;
+    OUTPUT:
+         RETVAL
 
 void
 html_prepare_output_units_global_targets (SV *converter_in, SV 
*output_units_in, SV *special_units_in, SV *associated_special_units_in)
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index 7c773f78d7..ba84769c08 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -1791,10 +1791,11 @@ pass_html_global_units_directions (SV *converter_sv,
 {
   HV *global_units_directions_hv;
   SV *global_units_directions_sv;
+  HV *converter_hv;
 
   dTHX;
 
-  HV *converter_hv = (HV *) SvRV (converter_sv);
+  converter_hv = (HV *) SvRV (converter_sv);
 
   global_units_directions_hv
     = build_html_global_units_directions (global_units_directions,
@@ -1809,7 +1810,7 @@ pass_html_global_units_directions (SV *converter_sv,
             strlen ("global_units_directions"), global_units_directions_sv, 0);
 }
 
-SV *
+HV *
 build_html_elements_in_file_count (
                  FILE_NAME_PATH_COUNTER_LIST *output_unit_files)
 {
@@ -1834,7 +1835,26 @@ build_html_elements_in_file_count (
         }
     }
 
-  return newRV_noinc ((SV *) hv);
+  return hv;
+}
+
+void
+pass_html_elements_in_file_count (SV *converter_sv,
+                   FILE_NAME_PATH_COUNTER_LIST *output_unit_files)
+{
+  HV *elements_in_file_count_hv;
+  HV *converter_hv;
+
+  dTHX;
+
+  converter_hv = (HV *) SvRV (converter_sv);
+
+  elements_in_file_count_hv
+   = build_html_elements_in_file_count (output_unit_files);
+
+  hv_store (converter_hv, "elements_in_file_count",
+            strlen ("elements_in_file_count"),
+            newRV_noinc ((SV *) elements_in_file_count_hv), 0);
 }
 
 SV *
@@ -1917,6 +1937,30 @@ build_out_filepaths (FILE_NAME_PATH_COUNTER_LIST 
*output_unit_files)
   return newRV_noinc ((SV *) hv);
 }
 
+void
+pass_output_unit_files (SV *converter_sv,
+                        FILE_NAME_PATH_COUNTER_LIST *output_unit_files)
+{
+  SV *filenames_sv;
+  SV *file_counters_sv;
+  SV *out_filepaths_sv;
+
+  dTHX;
+
+  HV *converter_hv = (HV *) SvRV (converter_sv);
+
+
+  filenames_sv = build_filenames (output_unit_files);
+  file_counters_sv = build_file_counters (output_unit_files);
+  out_filepaths_sv = build_out_filepaths (output_unit_files);
+
+#define STORE(key) hv_store (converter_hv, #key, strlen (#key), key##_sv, 0)
+  STORE(filenames);
+  STORE (file_counters);
+  STORE (out_filepaths);
+#undef STORE
+}
+
 void
 build_html_translated_names (HV *hv, CONVERTER *converter)
 {
diff --git a/tp/Texinfo/XS/main/build_perl_info.h 
b/tp/Texinfo/XS/main/build_perl_info.h
index 3f822844f0..520859059a 100644
--- a/tp/Texinfo/XS/main/build_perl_info.h
+++ b/tp/Texinfo/XS/main/build_perl_info.h
@@ -37,6 +37,9 @@ SV *build_output_units_list (size_t output_units_descriptor);
 void rebuild_output_units_list (SV *output_units_sv,
                                 size_t output_units_descriptor);
 
+void pass_output_unit_files (SV *converter_sv,
+                        FILE_NAME_PATH_COUNTER_LIST *output_unit_files);
+
 void pass_html_element_targets (SV *converter_sv,
                                 HTML_TARGET_LIST *html_targets);
 void pass_html_special_targets (SV *converter_sv,
@@ -50,13 +53,9 @@ SV *build_html_files_source_info (FILE_SOURCE_INFO_LIST 
*files_source_info);
 void pass_html_global_units_directions (SV *converter_sv,
                        OUTPUT_UNIT **global_units_directions,
                        SPECIAL_UNIT_DIRECTION **special_units_direction_name);
-SV *build_html_elements_in_file_count (
+void pass_html_elements_in_file_count (SV *converter_sv,
                    FILE_NAME_PATH_COUNTER_LIST *output_unit_files);
 
-SV *build_filenames (FILE_NAME_PATH_COUNTER_LIST *output_unit_files);
-SV *build_file_counters (FILE_NAME_PATH_COUNTER_LIST *output_unit_files);
-SV *build_out_filepaths (FILE_NAME_PATH_COUNTER_LIST *output_unit_files);
-
 HV *build_html_document_context (HTML_DOCUMENT_CONTEXT *document_context);
 
 SV *build_html_formatting_state (CONVERTER *converter, unsigned long flags);



reply via email to

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