texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Convert/Converter.pm (%XS_overrides,


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Convert/Converter.pm (%XS_overrides, get_conf, set_conf): (force_conf), tp/Texinfo/XS/convert/ConvertXS.xs (set_conf, get_conf) (force_conf): directly override get_conf, set_conf and force_conf. Remove _XS_get_conf, _XS_set_conf and _XS_force_conf.
Date: Sat, 05 Oct 2024 05:16:21 -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 7c30294238 * tp/Texinfo/Convert/Converter.pm (%XS_overrides, get_conf, 
set_conf): (force_conf), tp/Texinfo/XS/convert/ConvertXS.xs (set_conf, 
get_conf) (force_conf): directly override get_conf, set_conf and force_conf. 
Remove _XS_get_conf, _XS_set_conf and _XS_force_conf.
7c30294238 is described below

commit 7c3029423864fe72e53977651af256203d74f5ea
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Aug 24 21:20:09 2024 +0200

    * tp/Texinfo/Convert/Converter.pm (%XS_overrides, get_conf, set_conf):
    (force_conf), tp/Texinfo/XS/convert/ConvertXS.xs (set_conf, get_conf)
    (force_conf): directly override get_conf, set_conf and force_conf.
    Remove _XS_get_conf, _XS_set_conf and _XS_force_conf.
    
    * tp/Texinfo/XS/convert/ConvertXS.xs (set_conf, get_conf, force_conf),
    tp/Texinfo/XS/main/DocumentXS.xs (document_get_conf),
    tp/Texinfo/XS/main/build_perl_info.c
    (latex_build_options_for_convert_to_latex_math),
    tp/Texinfo/XS/main/get_perl_info.c: inline and remove set_sv_conf,
    force_sv_conf and build_sv_option_from_name.
---
 ChangeLog                            | 14 +++++++++
 tp/Texinfo/Convert/Converter.pm      | 54 ++++++++-------------------------
 tp/Texinfo/XS/convert/ConvertXS.xs   | 58 ++++++++++++++++++++++++++++--------
 tp/Texinfo/XS/main/DocumentXS.xs     | 11 +++++--
 tp/Texinfo/XS/main/build_perl_info.c | 34 +++++++--------------
 tp/Texinfo/XS/main/build_perl_info.h |  3 +-
 tp/Texinfo/XS/main/get_perl_info.c   | 25 ----------------
 tp/Texinfo/XS/main/get_perl_info.h   |  2 --
 8 files changed, 92 insertions(+), 109 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f2ead0fef8..888122b0ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2024-08-24  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/Converter.pm (%XS_overrides, get_conf, set_conf):
+       (force_conf), tp/Texinfo/XS/convert/ConvertXS.xs (set_conf, get_conf)
+       (force_conf): directly override get_conf, set_conf and force_conf.
+       Remove _XS_get_conf, _XS_set_conf and _XS_force_conf.
+
+       * tp/Texinfo/XS/convert/ConvertXS.xs (set_conf, get_conf, force_conf),
+       tp/Texinfo/XS/main/DocumentXS.xs (document_get_conf),
+       tp/Texinfo/XS/main/build_perl_info.c
+       (latex_build_options_for_convert_to_latex_math),
+       tp/Texinfo/XS/main/get_perl_info.c: inline and remove set_sv_conf,
+       force_sv_conf and build_sv_option_from_name.
+
 2024-10-05  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/format_html.c (html_convert_heading_command):
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index ef5bde7e00..b11000c27d 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -70,19 +70,17 @@ my $XS_convert = Texinfo::XSLoader::XS_convert_enabled();
 our $module_loaded = 0;
 
 my %XS_overrides = (
-  # XS only called if there is an associated XS converter
-  "Texinfo::Convert::Converter::_XS_set_conf"
-   => "Texinfo::Convert::ConvertXS::set_conf",
-  "Texinfo::Convert::Converter::_XS_force_conf"
-   => "Texinfo::Convert::ConvertXS::force_conf",
-  "Texinfo::Convert::Converter::_XS_get_conf"
-   => "Texinfo::Convert::ConvertXS::get_conf",
-
   # fully overriden for all the converters
   "Texinfo::Convert::Converter::_generic_converter_init",
    => "Texinfo::Convert::ConvertXS::generic_converter_init",
   "Texinfo::Convert::Converter::set_document"
    => "Texinfo::Convert::ConvertXS::converter_set_document",
+  "Texinfo::Convert::Converter::set_conf"
+   => "Texinfo::Convert::ConvertXS::set_conf",
+  "Texinfo::Convert::Converter::force_conf"
+   => "Texinfo::Convert::ConvertXS::force_conf",
+  "Texinfo::Convert::Converter::get_conf"
+   => "Texinfo::Convert::ConvertXS::get_conf",
   "Texinfo::Convert::Converter::get_converter_errors"
    => "Texinfo::Convert::ConvertXS::get_converter_errors",
   "Texinfo::Convert::Converter::converter_line_error"
@@ -543,63 +541,37 @@ sub get_converter_errors($)
 # Implementation of the customization API that is used in many
 # Texinfo modules
 
-# Those functions are not overriden when XS is used as it is possible
-# that some converters do not use XS.
-
-sub _XS_get_conf($$)
-{
-}
-
 sub get_conf($$)
 {
   my $self = shift;
   my $conf = shift;
+
   if (!Texinfo::Common::valid_customization_option($conf)) {
     confess("CBUG: unknown option $conf\n");
     #return undef;
   }
-
-  # Check that the package was loaded as we should only use perl if not.
-  if ($self->{'converter_descriptor'} and $XS_convert
-      and $Texinfo::Convert::ConvertXS::XS_package) {
-    my $result = _XS_get_conf($self, $conf);
-    return $result;
-  }
-
   return $self->{'conf'}->{$conf};
 }
 
-sub _XS_set_conf($$$)
-{
-}
-
 sub set_conf($$$)
 {
   my $self = shift;
   my $conf = shift;
   my $value = shift;
+
   if (!Texinfo::Common::valid_customization_option($conf)) {
     die "BUG: set_conf: unknown option $conf\n";
     return undef;
   }
+
   if ($self->{'configured'}->{$conf}) {
     return 0;
   } else {
-    my $set = 1;
-    if ($self->{'converter_descriptor'} and $XS_convert) {
-      $set = _XS_set_conf($self, $conf, $value);
-    }
-    if ($set) {
-      $self->{'conf'}->{$conf} = $value;
-    }
-    return $set;
+    $self->{'conf'}->{$conf} = $value;
+    return 1;
   }
 }
 
-sub _XS_force_conf($$$)
-{
-}
-
 sub force_conf($$$)
 {
   my $self = shift;
@@ -609,9 +581,7 @@ sub force_conf($$$)
     die "BUG: force_conf: unknown option $conf\n";
     return undef;
   }
-  if ($self->{'converter_descriptor'} and $XS_convert) {
-    _XS_force_conf($self, $conf, $value);
-  }
+
   $self->{'conf'}->{$conf} = $value;
   return 1;
 }
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index d4613d1730..d310b17fac 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -246,31 +246,55 @@ converter_set_document (SV *converter_in, SV *document_in)
         call_common_set_output_perl_encoding (self);
 
 int
-set_conf (SV *converter_in, conf, SV *value)
-        const char *conf = (char *)SvPVbyte_nolen($arg);
+set_conf (SV *converter_in, option_name, SV *value)
+        const char *option_name = (char *)SvPVbyte_nolen($arg);
       PREINIT:
         CONVERTER *self;
         int status = 0;
       CODE:
-        /* Calling code checks 'converter_descriptor' is set */
-        self = get_sv_converter (converter_in, 0);
+        self = get_sv_converter (converter_in, "set_conf");
         if (self)
-          status = set_sv_conf (self, conf, value);
+          {
+            int get_sv_status;
+            OPTION *option
+              = find_option_string (self->sorted_options, option_name);
+
+            if (!option)
+              croak_nocontext ("BUG: set_conf: unknown option %s\n",
+                               option_name);
+
+            get_sv_status = get_sv_option (option, value, 0, self->conf, self);
+            if (get_sv_status == 0)
+              status = 1;
+          }
         RETVAL = status;
     OUTPUT:
         RETVAL
 
 int
-force_conf (SV *converter_in, conf, SV *value)
-        const char *conf = (char *)SvPVbyte_nolen($arg);
+force_conf (SV *converter_in, option_name, SV *value)
+        const char *option_name = (char *)SvPVbyte_nolen($arg);
       PREINIT:
         CONVERTER *self;
+        int status = 0;
       CODE:
-        /* Calling code checks 'converter_descriptor' is set */
-        self = get_sv_converter (converter_in, 0);
+        self = get_sv_converter (converter_in, "force_conf");
         if (self)
-          force_sv_conf (self, conf, value);
-        RETVAL = 1;
+          {
+            int get_sv_status;
+            OPTION *option
+              = find_option_string (self->sorted_options, option_name);
+
+            if (!option)
+              croak_nocontext ("BUG: force_conf: unknown option %s\n",
+                               option_name);
+
+            /* only possible error would be a type error */
+            get_sv_status = get_sv_option (option, value, 1, self->conf, self);
+            if (get_sv_status == 0)
+              status = 1;
+          }
+        RETVAL = status;
     OUTPUT:
         RETVAL
 
@@ -282,8 +306,16 @@ get_conf (SV *converter_in, option_name)
       CODE:
         self = get_sv_converter (converter_in, 0);
         if (self && self->sorted_options)
-          RETVAL = build_sv_option_from_name (self->sorted_options, self,
-                                              option_name);
+          {
+            const OPTION *option
+             = find_option_string (self->sorted_options, option_name);
+
+            if (!option)
+              /* in Perl confess is called, we do not bother here */
+              croak_nocontext ("CBUG: unknown option %s\n", option_name);
+
+            RETVAL = build_sv_option (option, self);
+          }
         else
           RETVAL = newSV (0);
     OUTPUT:
diff --git a/tp/Texinfo/XS/main/DocumentXS.xs b/tp/Texinfo/XS/main/DocumentXS.xs
index 07cc283099..1b7f5e563f 100644
--- a/tp/Texinfo/XS/main/DocumentXS.xs
+++ b/tp/Texinfo/XS/main/DocumentXS.xs
@@ -33,6 +33,7 @@
 #include "extra.h"
 /* for non_perl_* */
 #include "utils.h"
+#include "customization_options.h"
 /* for clear_error_message_list */
 #include "errors.h"
 #include "document.h"
@@ -173,8 +174,14 @@ document_get_conf (SV *document_in, option_name)
       document = get_sv_document_document (document_in,
                                            "document_get_conf");
       if (document && document->sorted_options)
-        RETVAL = build_sv_option_from_name (document->sorted_options,
-                                            0, option_name);
+        {
+          const OPTION *option
+            = find_option_string (document->sorted_options, option_name);
+          if (option)
+            RETVAL = build_sv_option (option, 0);
+          else
+            RETVAL = newSV (0);
+        }
       else
         RETVAL = newSV (0);
   OUTPUT:
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index a96100a9bb..0fe1987809 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -3001,7 +3001,7 @@ html_build_direction_icons (const CONVERTER *converter,
   return newRV_noinc ((SV *)icons_hv);
 }
 
-static SV *
+SV *
 build_sv_option (const OPTION *option, CONVERTER *converter)
 {
   dTHX;
@@ -3060,23 +3060,6 @@ build_sv_option (const OPTION *option, CONVERTER 
*converter)
   return newSV (0);
 }
 
-SV *
-build_sv_option_from_name (OPTION **sorted_options, CONVERTER *converter,
-                           const char *option_name)
-{
-  dTHX;
-
-  const OPTION *option
-   = find_option_string (sorted_options, option_name);
-
-  if (option)
-    {
-      SV *result = build_sv_option (option, converter);
-      return result;
-    }
-  return newSV (0);
-}
-
 /* not much used, as in general the options are only stored in C and
    accessed through the API and built when accessed through a converter.
    This is only used when there is no converter, when a function is called with
@@ -3444,11 +3427,16 @@ latex_build_options_for_convert_to_latex_math 
(CONVERTER *converter)
   for (i = 0; latex_math_options[i]; i++)
     {
       const char *option_name = latex_math_options[i];
-      SV *option_sv = build_sv_option_from_name (converter->sorted_options,
-                                                 converter, option_name);
-      SvREFCNT_inc (option_sv);
-      hv_store (options_latex_math_hv, option_name,
-                strlen (option_name), option_sv, 0);
+      const OPTION *option = find_option_string (converter->sorted_options,
+                                                 option_name);
+      /* no testing if option is NULL, we know that latex_math_options exist */
+      SV *option_sv = build_sv_option (option, converter);
+      if (SvOK (option_sv))
+        {
+          SvREFCNT_inc (option_sv);
+          hv_store (options_latex_math_hv, option_name,
+                    strlen (option_name), option_sv, 0);
+        }
     }
 
   return options_latex_math_hv;
diff --git a/tp/Texinfo/XS/main/build_perl_info.h 
b/tp/Texinfo/XS/main/build_perl_info.h
index 1de3c58fc6..b2cc9623a5 100644
--- a/tp/Texinfo/XS/main/build_perl_info.h
+++ b/tp/Texinfo/XS/main/build_perl_info.h
@@ -90,8 +90,7 @@ SV *html_build_direction_icons (const CONVERTER *converter,
                             const DIRECTION_ICON_LIST *direction_icons);
 SV *html_build_buttons_specification (CONVERTER *converter,
                                       BUTTON_SPECIFICATION_LIST *buttons);
-SV * build_sv_option_from_name (OPTION **sorted_options, CONVERTER *converter,
-                                const char *option_name);
+SV *build_sv_option (const OPTION *option, CONVERTER *converter);
 SV *build_sv_options_from_options_list (const OPTIONS_LIST *options_list,
                                         CONVERTER *converter);
 
diff --git a/tp/Texinfo/XS/main/get_perl_info.c 
b/tp/Texinfo/XS/main/get_perl_info.c
index 6cd46fa228..f946a00e01 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -824,31 +824,6 @@ get_sv_index_entries_sorted_by_letter (INDEX_LIST 
*indices_info,
   return indices_entries_by_letter;
 }
 
-int
-set_sv_conf (CONVERTER *converter, const char *conf, SV *value)
-{
-  if (converter->conf)
-    {
-      int status = get_sorted_options_key_sv_option (converter->conf,
-                       converter->sorted_options, conf, value, 0, converter);
-      if (status == 0)
-        return 1;
-    }
-   /* Too early to have options set
-  else
-    fprintf (stderr, "HHH no converter conf %s\n", conf);
-    */
-  return 0;
-}
-
-void
-force_sv_conf (CONVERTER *converter, const char *conf, SV *value)
-{
-  if (converter->conf)
-    get_sorted_options_key_sv_option (converter->conf,
-                       converter->sorted_options, conf, value, 1, converter);
-}
-
 /* output format specific */
 
 /* should be consistent with enum button_function_type */
diff --git a/tp/Texinfo/XS/main/get_perl_info.h 
b/tp/Texinfo/XS/main/get_perl_info.h
index 8df8a2e95d..c863665467 100644
--- a/tp/Texinfo/XS/main/get_perl_info.h
+++ b/tp/Texinfo/XS/main/get_perl_info.h
@@ -47,8 +47,6 @@ void get_line_message (CONVERTER *self, enum error_type type, 
int continuation,
                        SV *error_location_info, const char *message);
 OPTIONS *init_copy_sv_options (SV *sv_in, CONVERTER *converter, int force,
                                OPTION ***sorted_options_out);
-int set_sv_conf (CONVERTER *converter, const char *conf, SV *value);
-void force_sv_conf (CONVERTER *converter, const char *conf, SV *value);
 
 INDEX_ENTRY *find_index_entry_sv (const SV *index_entry_sv,
                      INDEX_LIST *indices_info,



reply via email to

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