texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Thu, 3 Oct 2024 14:01:42 -0400 (EDT)

branch: master
commit 51744f4b1aa996312d5b8656ea8ce4056353f04b
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Aug 7 17:55:19 2024 +0200

    * tp/Texinfo/XS/main/utils.c (initialize_options_list),
    tp/Texinfo/XS/convert/get_converter_perl_info.c
    (get_converter_info_from_sv): add.  Use in get_converter_info_from_sv.
    
    * tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_initialize_sv),
    tp/Texinfo/XS/main/utils.c
    (html_fill_button_directions_specification_list),
    tp/Texinfo/XS/main/get_perl_info.c
    (html_fill_button_sv_specification_list),
    tp/maintain/regenerate_C_options_info.pl: rename html_fill_options as
    html_fill_sv_options.  Split html_fill_button_specification_list in
    two, with html_fill_button_sv_specification_list for direction filled
    with information from Perl data, and
    html_fill_button_directions_specification_list for directions filled
    from strings set in buttons generated in C.  Generate automatically
    html_fill_options_directions to call
    html_fill_button_directions_specification_list.  Call both
    html_fill_sv_options and html_fill_options_directions in ConvertXS.xs
    html_converter_initialize_sv.
---
 ChangeLog                                       | 22 +++++++++
 tp/Texinfo/XS/convert/ConvertXS.xs              |  5 ++-
 tp/Texinfo/XS/convert/get_converter_perl_info.c |  6 +--
 tp/Texinfo/XS/main/get_perl_info.c              | 41 +++++------------
 tp/Texinfo/XS/main/utils.c                      | 59 +++++++++++++++++++++++++
 tp/Texinfo/XS/main/utils.h                      |  4 ++
 tp/maintain/regenerate_C_options_info.pl        | 21 ++++++++-
 7 files changed, 120 insertions(+), 38 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e2236701c8..ba909a855e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2024-08-07  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/utils.c (initialize_options_list),
+       tp/Texinfo/XS/convert/get_converter_perl_info.c
+       (get_converter_info_from_sv): add.  Use in get_converter_info_from_sv.
+
+       * tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_initialize_sv),
+       tp/Texinfo/XS/main/utils.c
+       (html_fill_button_directions_specification_list),
+       tp/Texinfo/XS/main/get_perl_info.c
+       (html_fill_button_sv_specification_list),
+       tp/maintain/regenerate_C_options_info.pl: rename html_fill_options as
+       html_fill_sv_options.  Split html_fill_button_specification_list in
+       two, with html_fill_button_sv_specification_list for direction filled
+       with information from Perl data, and
+       html_fill_button_directions_specification_list for directions filled
+       from strings set in buttons generated in C.  Generate automatically
+       html_fill_options_directions to call
+       html_fill_button_directions_specification_list.  Call both
+       html_fill_sv_options and html_fill_options_directions in ConvertXS.xs
+       html_converter_initialize_sv.
+
 2024-08-06  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/convert_html.c (html_free_converter),
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 745654aed1..abe92036bb 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -642,7 +642,10 @@ html_converter_initialize_sv (SV *converter_in, SV 
*default_formatting_reference
    /* at that point, the format specific informations, in particular the
       direction names is available, such that the directions can be set
       in customization variables needing them (icons, buttons). */
-        html_fill_options (self->conf, self);
+   /* fill options using information in associated Perl data */
+        html_fill_sv_options (self->conf, self);
+   /* fill options with C only information not associated with Perl data */
+        html_fill_options_directions (self->conf, self);
 
 # do nothing as everything is already set in C
 SV *
diff --git a/tp/Texinfo/XS/convert/get_converter_perl_info.c 
b/tp/Texinfo/XS/convert/get_converter_perl_info.c
index 0ebe7979e5..ff31573156 100644
--- a/tp/Texinfo/XS/convert/get_converter_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_converter_perl_info.c
@@ -213,10 +213,8 @@ get_converter_info_from_sv (SV *conf_sv, const char *class,
       if (!hv_number)
         return 0;
 
-      /* FIXME move to Pure C */
-      initialization_info->conf.list
-        = (OPTION *) malloc (sizeof (OPTION) * hv_number);
-      memset (initialization_info->conf.list, 0, sizeof (OPTION) * hv_number);
+      initialize_options_list (&initialization_info->conf, hv_number);
+      initialization_info->conf.number = 0;
 
       for (i = 0; i < hv_number; i++)
         {
diff --git a/tp/Texinfo/XS/main/get_perl_info.c 
b/tp/Texinfo/XS/main/get_perl_info.c
index 488161215f..4f6010b856 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -824,7 +824,7 @@ const char *html_button_function_type_string[] = {
 
 /* set directions.  To be called after direction names have been collected */
 void
-html_fill_button_specification_list (const CONVERTER *converter,
+html_fill_button_sv_specification_list (const CONVERTER *converter,
                                      BUTTON_SPECIFICATION_LIST *result)
 {
   size_t i;
@@ -836,9 +836,9 @@ html_fill_button_specification_list (const CONVERTER 
*converter,
 
       if (button->type == BST_direction_info)
         {
-          const char *direction_name = 0;
           if (button->sv)
             {
+              const char *direction_name;
               AV *button_spec_info_av = (AV *) SvRV((SV *)button->sv);
               SV **direction_sv = av_fetch (button_spec_info_av, 0, 0);
 
@@ -851,42 +851,21 @@ html_fill_button_specification_list (const CONVERTER 
*converter,
                 }
 
               direction_name = SvPVutf8_nolen (*direction_sv);
+
+              if (direction_name)
+                button->b.button_info->direction
+                 = html_get_direction_index (converter, direction_name);
             }
-          else if (button->b.button_info->direction < 0)
-            direction_name = button->direction_string;
-
-          if (direction_name)
-            button->b.button_info->direction
-              = html_get_direction_index (converter, direction_name);
-        /* this happens in test with redefined special unit direction
-          if (button->b.button_info->direction < 0)
-            {
-              fprintf (stderr,
-                  "BUG: still unknown button %zu array direction: %d: %s\n",
-                     i, button->b.button_info->direction, direction_name);
-            }
-         */
         }
       else if (button->type == BST_direction)
         {
-          const char *direction_name = 0;
           if (button->sv)
             {
-              direction_name = SvPVutf8_nolen (button->sv);
+              const char *direction_name = SvPVutf8_nolen (button->sv);
+              if (direction_name)
+                button->b.direction = html_get_direction_index (converter,
+                                                              direction_name);
             }
-          else if (button->b.direction < 0)
-            {
-              direction_name = button->direction_string;
-            }
-          if (direction_name)
-            button->b.direction = html_get_direction_index (converter,
-                                                          direction_name);
-        /* this would happen in test with redefined special unit direction
-          if (button->b.direction < 0)
-            fprintf (stderr,
-                     "BUG: still unknown button %zu string direction: %s\n",
-                     i, direction_name);
-         */
         }
     }
 }
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index 7f8c1b5579..6795e9f907 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -38,6 +38,8 @@
 #include "global_commands_types.h"
 #include "option_types.h"
 #include "options_types.h"
+/* for CL_* */
+#include "document_types.h"
 #include "converter_types.h"
 #include "types_data.h"
 #include "tree.h"
@@ -2035,6 +2037,14 @@ copy_options_list_options (OPTIONS *options, OPTION 
**sorted_options,
     }
 }
 
+void
+initialize_options_list (OPTIONS_LIST *options_list, size_t number)
+{
+  options_list->number = number;
+  options_list->list = (OPTION *) malloc (sizeof (OPTION) * number);
+  memset (options_list->list, 0, sizeof (OPTION) * number);
+}
+
 void
 free_options_list (OPTIONS_LIST *options_list)
 {
@@ -2048,6 +2058,55 @@ free_options_list (OPTIONS_LIST *options_list)
   free (options_list->list);
 }
 
+void
+html_fill_button_directions_specification_list (const CONVERTER *converter,
+                                              BUTTON_SPECIFICATION_LIST 
*result)
+{
+  size_t i;
+
+  for (i = 0; i < result->number; i++)
+    {
+      BUTTON_SPECIFICATION *button = &result->list[i];
+
+      if (button->type == BST_direction_info)
+        {
+          const char *direction_name = 0;
+
+          if (button->b.button_info->direction < 0)
+            direction_name = button->direction_string;
+
+          if (direction_name)
+            button->b.button_info->direction
+              = html_get_direction_index (converter, direction_name);
+        /* this happens in test with redefined special unit direction
+          if (button->b.button_info->direction < 0)
+            {
+              fprintf (stderr,
+                  "BUG: still unknown button %zu array direction: %d: %s\n",
+                     i, button->b.button_info->direction, direction_name);
+            }
+         */
+        }
+      else if (button->type == BST_direction)
+        {
+          const char *direction_name = 0;
+          if (button->b.direction < 0)
+            {
+              direction_name = button->direction_string;
+            }
+          if (direction_name)
+            button->b.direction = html_get_direction_index (converter,
+                                                          direction_name);
+        /* this would happen in test with redefined special unit direction
+          if (button->b.direction < 0)
+            fprintf (stderr,
+                     "BUG: still unknown button %zu string direction: %s\n",
+                     i, direction_name);
+         */
+        }
+    }
+}
+
 
 /* constructors in particular called from files including perl headers */
 
diff --git a/tp/Texinfo/XS/main/utils.h b/tp/Texinfo/XS/main/utils.h
index ebda6a147a..edd845d02c 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -211,10 +211,14 @@ OPTION **setup_sortable_options (OPTIONS *options);
 void clear_options (OPTIONS *options);
 void free_options (OPTIONS *options);
 void copy_options (OPTIONS *destination, const OPTIONS *source);
+void html_fill_options_directions (OPTIONS *options, const CONVERTER 
*converter);
 
 void copy_options_list_options (OPTIONS *options, OPTION **sorted_options,
                                 OPTIONS_LIST *options_list, int 
set_configured);
+void initialize_options_list (OPTIONS_LIST *options_list, size_t number);
 void free_options_list (OPTIONS_LIST *options_list);
+void html_fill_button_directions_specification_list (const CONVERTER 
*converter,
+                                              BUTTON_SPECIFICATION_LIST 
*buttons);
 
 OPTIONS *new_options (void);
 OPTION **setup_sorted_options (OPTIONS *options);
diff --git a/tp/maintain/regenerate_C_options_info.pl 
b/tp/maintain/regenerate_C_options_info.pl
index 4c44df4dd1..9a9131c5bd 100755
--- a/tp/maintain/regenerate_C_options_info.pl
+++ b/tp/maintain/regenerate_C_options_info.pl
@@ -308,6 +308,23 @@ print CODE "
     }
 }\n\n";
 
+print CODE 'void
+html_fill_options_directions (OPTIONS *options, const CONVERTER *converter)
+{
+';
+foreach my $category (sort(keys(%option_categories))) {
+  foreach my $option_info (@{$option_categories{$category}}) {
+    my ($option, $value, $type) = @$option_info;
+    if ($type eq 'buttons') {
+      print CODE "  if (options->$option.o.buttons)\n"
+                ."    html_fill_button_directions_specification_list 
(converter, options->$option.o.buttons);\n\n";
+    }
+  }
+}
+print CODE '}
+
+';
+
 # table of defaults for options corresponding to commands
 print CODE "COMMAND_OPTION_DEFAULT command_option_default_table[] = {\n";
 
@@ -537,7 +554,7 @@ print GET '  else
 ';
 
 print GET 'void
-html_fill_options (OPTIONS *options, const CONVERTER *converter)
+html_fill_sv_options (OPTIONS *options, const CONVERTER *converter)
 {
 ';
 foreach my $category (sort(keys(%option_categories))) {
@@ -545,7 +562,7 @@ foreach my $category (sort(keys(%option_categories))) {
     my ($option, $value, $type) = @$option_info;
     if ($type eq 'buttons') {
       print GET "  if (options->$option.o.buttons)\n"
-                ."    html_fill_button_specification_list (converter, 
options->$option.o.buttons);\n\n";
+                ."    html_fill_button_sv_specification_list (converter, 
options->$option.o.buttons);\n\n";
     } elsif ($type eq 'icons') {
       print GET "  if (options->$option.o.icons)\n"
                 ."    html_fill_direction_icons (converter, 
options->$option.o.icons);\n\n";



reply via email to

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