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:53 -0500 (EST)

branch: master
commit c33be61801f4297ba1f6a5ff9ed6bc9eb2ba0810
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Nov 6 13:51:29 2023 +0100

    * tp/Texinfo/XS/main/build_perl_info.c
    (pass_html_global_units_directions): rename from
    set_html_global_units_directions.  Update callers.
    
    * tp/Texinfo/Convert/HTML.pm (_prepare_conversion_units),
    tp/Texinfo/XS/convert/ConvertXS.xs (html_prepare_conversion_units),
    tp/Texinfo/XS/main/build_perl_info.c (build_html_element_targets)
    (pass_html_element_targets, build_html_special_targets)
    (build_html_special_targets, pass_html_special_targets)
    (build_html_seen_ids, pass_html_seen_ids): set targets,
    special_targets, seen_ids and document_units from C/XS in
    _prepare_conversion_units.
---
 ChangeLog                            | 15 ++++++++
 tp/Texinfo/Convert/HTML.pm           |  8 +---
 tp/Texinfo/XS/convert/ConvertXS.xs   | 42 ++++++++++-----------
 tp/Texinfo/XS/main/build_perl_info.c | 73 ++++++++++++++++++++++++++++++------
 tp/Texinfo/XS/main/build_perl_info.h | 10 +++--
 5 files changed, 104 insertions(+), 44 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d94cc2129b..fdb7727109 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2023-11-06  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/build_perl_info.c
+       (pass_html_global_units_directions): rename from
+       set_html_global_units_directions.  Update callers.
+
+       * tp/Texinfo/Convert/HTML.pm (_prepare_conversion_units),
+       tp/Texinfo/XS/convert/ConvertXS.xs (html_prepare_conversion_units),
+       tp/Texinfo/XS/main/build_perl_info.c (build_html_element_targets)
+       (pass_html_element_targets, build_html_special_targets)
+       (build_html_special_targets, pass_html_special_targets)
+       (build_html_seen_ids, pass_html_seen_ids): set targets,
+       special_targets, seen_ids and document_units from C/XS in
+       _prepare_conversion_units.
+
 2023-11-06  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Convert/HTML.pm (_prepare_units_directions_files)
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 2ba64155c0..5708791048 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -9402,15 +9402,9 @@ sub _prepare_conversion_units($$$)
   my ($output_units, $special_units, $associated_special_units);
 
   if ($self->{'converter_descriptor'} and $XS_convert) {
-    my ($targets, $special_targets, $seen_ids);
-    ($output_units, $special_units, $associated_special_units,
-     $targets, $special_targets, $seen_ids)
+    ($output_units, $special_units, $associated_special_units)
       = _XS_prepare_conversion_units($self,
                                      $document_name);
-    $self->{'targets'} = $targets;
-    $self->{'special_targets'} = $special_targets;
-    $self->{'seen_ids'} = $seen_ids;
-    $self->{'document_units'} = $output_units;
     return ($output_units, $special_units, $associated_special_units);
   }
 
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index f392f8f8b2..6b33d80161 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -153,11 +153,11 @@ html_new_document_context (SV *converter_in, char 
*context_name, ...)
            {
              HV *document_context_hv;
              HTML_DOCUMENT_CONTEXT *document_context;
-             HV *converter_hv = (HV *) SvRV (converter_in); 
+             HV *converter_hv = (HV *) SvRV (converter_in);
              SV **document_context_sv = hv_fetch (converter_hv,
                    "document_context", strlen("document_context"), 0);
              AV *document_context_av = (AV *) SvRV (*document_context_sv);
-             /* should not be needed as we are calling from perl 
+             /* should not be needed as we are calling from perl
              if (self->modified_state)
                {
                  build_html_formatting_state (self, self->modified_state);
@@ -188,11 +188,11 @@ html_pop_document_context (SV *converter_in)
          self = get_sv_converter (converter_in, "html_new_document_context");
          if (self)
            {
-             HV *converter_hv = (HV *) SvRV (converter_in); 
+             HV *converter_hv = (HV *) SvRV (converter_in);
              SV **document_context_sv = hv_fetch (converter_hv,
                    "document_context", strlen("document_context"), 0);
              AV *document_context_av = (AV *) SvRV (*document_context_sv);
-             /* should not be needed as we are calling from perl 
+             /* should not be needed as we are calling from perl
              if (self->modified_state)
                {
                  build_html_formatting_state (self, self->modified_state);
@@ -226,6 +226,7 @@ void
 html_prepare_conversion_units (SV *converter_in, ...)
       PROTOTYPE: $;$
       PREINIT:
+         HV *converter_hv;
          char *document_name = 0;
          CONVERTER *self;
          int output_units_descriptor = 0;
@@ -234,9 +235,7 @@ html_prepare_conversion_units (SV *converter_in, ...)
          SV *output_units_sv;
          SV *special_units_sv;
          SV *associated_special_units_sv;
-         SV *targets_sv;
-         SV *special_targets_sv;
-         SV *seen_ids_sv;
+         HV *output_units_hv;
       PPCODE:
          if (items > 1 && SvOK(ST(1)))
            document_name = SvPVutf8_nolen (ST(1));
@@ -252,26 +251,27 @@ html_prepare_conversion_units (SV *converter_in, ...)
          associated_special_units_sv
            = build_output_units_list (associated_special_units_descriptor);
 
+         converter_hv = (HV *) SvRV (converter_in);
+         output_units_hv = (HV *) SvRV (output_units_sv);
+         hv_store (converter_hv, "document_units", strlen ("document_units"),
+                   newRV_inc ((SV *) output_units_hv), 0);
+
          /* calls perl customization functions, so need to be done after
             build_output_units_list calls to be able to retrieve perl units */
          html_prepare_conversion_units_targets (self, document_name,
               output_units_descriptor, special_units_descriptor,
               associated_special_units_descriptor);
 
-         targets_sv = build_html_element_targets (self->html_targets);
-         special_targets_sv
-           = build_html_special_targets (self->html_special_targets);
-         seen_ids_sv = build_html_seen_ids (self->seen_ids);
+         pass_html_element_targets (converter_in, self->html_targets);
+         pass_html_special_targets (converter_in, self->html_special_targets);
+         pass_html_seen_ids (converter_in, self->seen_ids);
 
          pass_converter_errors (self->error_messages, self->hv);
 
-         EXTEND(SP, 6);
+         EXTEND(SP, 3);
          PUSHs(sv_2mortal(output_units_sv));
          PUSHs(sv_2mortal(special_units_sv));
          PUSHs(sv_2mortal(associated_special_units_sv));
-         PUSHs(sv_2mortal(targets_sv));
-         PUSHs(sv_2mortal(special_targets_sv));
-         PUSHs(sv_2mortal(seen_ids_sv));
 
 void
 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)
@@ -319,9 +319,9 @@ html_prepare_units_directions_files (SV *converter_in, SV 
*output_units_in, SV *
 
          files_source_info_sv
            = build_html_files_source_info (files_source_info);
-         set_html_global_units_directions (converter_in,
-                                           self->global_units_directions,
-                                           self->special_units_direction_name);
+         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);
 
@@ -370,9 +370,9 @@ html_prepare_output_units_global_targets (SV *converter_in, 
SV *output_units_in,
          rebuild_output_units_list (associated_special_units_in,
                                     associated_special_units_descriptor);
 
-         set_html_global_units_directions (converter_in,
-                                           self->global_units_directions,
-                                           self->special_units_direction_name);
+         pass_html_global_units_directions (converter_in,
+                                            self->global_units_directions,
+                                            
self->special_units_direction_name);
 
 
 void
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index 324019b631..7c773f78d7 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -1462,7 +1462,7 @@ build_output_units_list (size_t output_units_descriptor)
   return newRV_noinc ((SV *) av_output_units);
 }
 
-SV *
+HV *
 build_html_element_targets (HTML_TARGET_LIST *html_targets)
 {
   HV *hv;
@@ -1473,7 +1473,7 @@ build_html_element_targets (HTML_TARGET_LIST 
*html_targets)
   hv = newHV ();
 
   if (!html_targets || html_targets->number <= 0)
-    return newRV_noinc ((SV *) hv);
+    return hv;
 
 #define STORE(key, sv) hv_store (html_target_hv, key, strlen (key), sv, 0)
   for (i = 0; i < html_targets->number; i++)
@@ -1487,7 +1487,7 @@ build_html_element_targets (HTML_TARGET_LIST 
*html_targets)
       if (!html_target->element->hv)
         {
           fprintf (stderr, "BUG: No hv for target '%s'\n", 
html_target->target);
-          return newSV(0);
+          fatal ("No hv for target");
         }
 
       element_sv = newRV_inc ((SV *) html_target->element->hv);
@@ -1514,14 +1514,30 @@ build_html_element_targets (HTML_TARGET_LIST 
*html_targets)
               newSVpv_utf8 (html_target->shortcontents_target, 0));
     }
 #undef STORE
-  return newRV_noinc ((SV *) hv);
+  return hv;
 }
 
-SV *
+void
+pass_html_element_targets (SV *converter_sv, HTML_TARGET_LIST *html_targets)
+{
+  HV *targets_hv;
+  HV *hv;
+
+  dTHX;
+
+  hv = (HV *) SvRV (converter_sv);
+
+  targets_hv = build_html_element_targets (html_targets);
+
+  hv_store (hv, "targets", strlen ("targets"),
+            newRV_noinc ((SV *) targets_hv), 0);
+}
+
+HV *
 build_html_special_targets (HTML_TARGET_LIST **html_special_targets)
 {
   HV *hv;
-  SV *html_special_target_sv;
+  HV *html_special_target_hv;
 
   dTHX;
 
@@ -1530,15 +1546,32 @@ build_html_special_targets (HTML_TARGET_LIST 
**html_special_targets)
   /* could be generalized if needed */
 
   HTML_TARGET_LIST *html_special_target = 
html_special_targets[ST_footnote_location];
-  html_special_target_sv = build_html_element_targets (html_special_target);
+  html_special_target_hv = build_html_element_targets (html_special_target);
 
   hv_store (hv, "footnote_location", strlen ("footnote_location"),
-            html_special_target_sv, 0);
+            newRV_noinc ((SV *) html_special_target_hv), 0);
 
-  return newRV_noinc ((SV *) hv);
+  return hv;
 }
 
-SV *
+void
+pass_html_special_targets (SV *converter_sv,
+                          HTML_TARGET_LIST **html_special_targets)
+{
+  HV *special_targets_hv;
+  HV *hv;
+
+  dTHX;
+
+  hv = (HV *) SvRV (converter_sv);
+
+  special_targets_hv = build_html_special_targets (html_special_targets);
+
+  hv_store (hv, "special_targets", strlen ("special_targets"),
+            newRV_noinc ((SV *) special_targets_hv), 0);
+}
+
+HV *
 build_html_seen_ids (STRING_LIST *seen_ids)
 {
   HV *hv;
@@ -1558,7 +1591,23 @@ build_html_seen_ids (STRING_LIST *seen_ids)
         }
     }
 
-  return newRV_noinc ((SV *) hv);
+  return hv;
+}
+
+void
+pass_html_seen_ids (SV *converter_sv, STRING_LIST *seen_ids)
+{
+  HV *seen_ids_hv;
+  HV *hv;
+
+  dTHX;
+
+  hv = (HV *) SvRV (converter_sv);
+
+  seen_ids_hv = build_html_seen_ids (seen_ids);
+
+  hv_store (hv, "seen_ids", strlen ("seen_ids"),
+            newRV_noinc ((SV *) seen_ids_hv), 0);
 }
 
 /* implements Texinfo::Report::add_formatted_message */
@@ -1736,7 +1785,7 @@ build_html_global_units_directions (OUTPUT_UNIT 
**global_units_directions,
 }
 
 void
-set_html_global_units_directions (SV *converter_sv,
+pass_html_global_units_directions (SV *converter_sv,
                        OUTPUT_UNIT **global_units_directions,
                        SPECIAL_UNIT_DIRECTION **special_units_direction_name)
 {
diff --git a/tp/Texinfo/XS/main/build_perl_info.h 
b/tp/Texinfo/XS/main/build_perl_info.h
index ee20e646ec..3f822844f0 100644
--- a/tp/Texinfo/XS/main/build_perl_info.h
+++ b/tp/Texinfo/XS/main/build_perl_info.h
@@ -37,15 +37,17 @@ SV *build_output_units_list (size_t 
output_units_descriptor);
 void rebuild_output_units_list (SV *output_units_sv,
                                 size_t output_units_descriptor);
 
-SV *build_html_element_targets (HTML_TARGET_LIST *html_targets);
-SV *build_html_special_targets (HTML_TARGET_LIST **html_special_targets);
-SV *build_html_seen_ids (STRING_LIST *seen_ids);
+void pass_html_element_targets (SV *converter_sv,
+                                HTML_TARGET_LIST *html_targets);
+void pass_html_special_targets (SV *converter_sv,
+                                HTML_TARGET_LIST **html_special_targets);
+void pass_html_seen_ids (SV *converter_sv, STRING_LIST *seen_ids);
 
 void pass_converter_errors (ERROR_MESSAGE_LIST *error_messages,
                             HV *converter_hv);
 
 SV *build_html_files_source_info (FILE_SOURCE_INFO_LIST *files_source_info);
-void set_html_global_units_directions (SV *converter_sv,
+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 (



reply via email to

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