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 08:03:37 -0400 (EDT)

branch: master
commit ccb80834d55d63ad0c2ef67af367c9bda3e1f25d
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Aug 5 09:09:44 2024 +0200

    * tp/Texinfo/XS/convert/ConvertXS.xs (get_conf): rename conf argument
    as option_name.
    
    * tp/Texinfo/XS/main/get_perl_info.c
    (html_button_function_type_string): rename button_function_type_string
    as html_button_function_type_string and make it extern.
    
    * tp/Texinfo/XS/convert/converter_options.c (new_button_specification)
    (new_basic_buttons, new_link_buttons),
    tp/Texinfo/XS/main/get_perl_info.c
    (html_fill_button_specification_list),
    tp/Texinfo/XS/main/option_types.h (BUTTON_SPECIFICATION): add
    direction_string to BUTTON_SPECIFICATION for pure C buttons to hold a
    directions string if the direction index is not already known when the
    button specification is setup, for special units direction whose names
    are not known early.  In html_fill_button_specification_list, use the
    direction_string is there is no Perl data and the direction index is
    negative.  Add an argument to new_button_specification and set it in
    new_basic_buttons and new_link_buttons for Contents and About.
    
    * tp/Texinfo/XS/main/build_perl_info.c (html_build_button): add to
    build a Perl button specification from a 'pure' C button structure
    BUTTON_SPECIFICATION.  This is a partial implementation for
    BST_direction and BST_direction_info + BIT_function.  This function can
    only be called for default buttons for now, so we do not need to
    handle other types of buttons.
    
    * tp/Texinfo/XS/main/build_perl_info.c
    (html_build_buttons_specification): add to build a Perl buttons
    specifications list from a 'pure' C BUTTON_SPECIFICATION_LIST.
    
    * tp/Texinfo/XS/main/build_perl_info.c (build_sv_option),
    tp/Texinfo/XS/convert/call_html_perl_function.c
    (call_formatting_function_format_navigation_panel)
    (call_formatting_function_format_navigation_header): call
    html_build_buttons_specification if there is no Perl data for a
    buttons specification list.
    
    * tp/Texinfo/XS/convert/converter_options.c (new_basic_buttons): add
    an argument to add an about button only if set.  Update callers to set
    only for headers buttons specifications.
    
    * tp/Texinfo/XS/convert/converter_options.c
    (set_option_buttons_specification)
    (set_html_default_buttons_specifications): add
    set_html_default_buttons_specifications to set buttons customization
    options with texi2any default buttons.
    
    * tp/Texinfo/XS/convert/converter_options.c (t2h_special_units_names)
    (enum T2H_special_unit_directions, T2H_SECTION_BUTTONS, T2H_TOP_BUTTONS)
    (T2H_MISC_BUTTONS, T2H_CHAPTER_BUTTONS, T2H_SECTION_FOOTER_BUTTONS)
    (new_texi2html_buttons_specifications): function and data to setup
    buttons in the texi2html way.
    
    * tp/Texinfo/XS/convert/converter_options.c
    (set_texi2html_default_buttons_specifications): add to set buttons
    customization options with texi2html buttons.
    
    * tp/Texinfo/XS/convert/converter.h (CONVERTER_FORMAT_DATA),
    tp/Texinfo/XS/convert/converter.c (set_converter_init_information):
    add converter_defaults function pointer to CONVERTER_FORMAT_DATA to
    call to initialize a converter for a specific format.  Get it and call
    it in set_converter_init_information, with the user configuration
    information structure as argument.
    
    * tp/Texinfo/XS/convert/converter.c (converter_format_data),
    tp/Texinfo/XS/convert/converter_options.c (html_converter_defaults):
    add a converter_defaults function for HTML converter format that sets
    customization options using converters_defaults.c function and
    buttons, both for default and with TEXI2HTML set.
    
    * tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_defaults): return
    undef, all the HTML customization default setup is done in C now.
---
 ChangeLog                                       |  76 ++++++++
 tp/Texinfo/XS/convert/ConvertXS.xs              |  17 +-
 tp/Texinfo/XS/convert/call_html_perl_function.c |   6 +
 tp/Texinfo/XS/convert/converter.c               |  12 +-
 tp/Texinfo/XS/convert/converter.h               |   2 +
 tp/Texinfo/XS/convert/converter_options.c       | 236 +++++++++++++++++++++---
 tp/Texinfo/XS/convert/converter_options.h       |   2 +
 tp/Texinfo/XS/main/build_perl_info.c            | 189 +++++++++++++++----
 tp/Texinfo/XS/main/build_perl_info.h            |   6 +-
 tp/Texinfo/XS/main/get_perl_info.c              |  50 +++--
 tp/Texinfo/XS/main/get_perl_info.h              |   2 +
 tp/Texinfo/XS/main/option_types.h               |   4 +
 12 files changed, 514 insertions(+), 88 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e5c096d934..d2cd381833 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,82 @@
        * tp/Texinfo/XS/Makefile.am (libtexinfo_convert_la_SOURCES): really
        add converter_options.c.
 
+2024-08-04  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/ConvertXS.xs (get_conf): rename conf argument
+       as option_name.
+
+       * tp/Texinfo/XS/main/get_perl_info.c
+       (html_button_function_type_string): rename button_function_type_string
+       as html_button_function_type_string and make it extern.
+
+       * tp/Texinfo/XS/convert/converter_options.c (new_button_specification)
+       (new_basic_buttons, new_link_buttons),
+       tp/Texinfo/XS/main/get_perl_info.c
+       (html_fill_button_specification_list),
+       tp/Texinfo/XS/main/option_types.h (BUTTON_SPECIFICATION): add
+       direction_string to BUTTON_SPECIFICATION for pure C buttons to hold a
+       directions string if the direction index is not already known when the
+       button specification is setup, for special units direction whose names
+       are not known early.  In html_fill_button_specification_list, use the
+       direction_string is there is no Perl data and the direction index is
+       negative.  Add an argument to new_button_specification and set it in
+       new_basic_buttons and new_link_buttons for Contents and About.
+
+       * tp/Texinfo/XS/main/build_perl_info.c (html_build_button): add to
+       build a Perl button specification from a 'pure' C button structure
+       BUTTON_SPECIFICATION.  This is a partial implementation for
+       BST_direction and BST_direction_info + BIT_function.  This function can
+       only be called for default buttons for now, so we do not need to
+       handle other types of buttons.
+
+       * tp/Texinfo/XS/main/build_perl_info.c
+       (html_build_buttons_specification): add to build a Perl buttons
+       specifications list from a 'pure' C BUTTON_SPECIFICATION_LIST.
+
+       * tp/Texinfo/XS/main/build_perl_info.c (build_sv_option),
+       tp/Texinfo/XS/convert/call_html_perl_function.c
+       (call_formatting_function_format_navigation_panel)
+       (call_formatting_function_format_navigation_header): call
+       html_build_buttons_specification if there is no Perl data for a
+       buttons specification list.
+
+       * tp/Texinfo/XS/convert/converter_options.c (new_basic_buttons): add
+       an argument to add an about button only if set.  Update callers to set
+       only for headers buttons specifications.
+
+       * tp/Texinfo/XS/convert/converter_options.c
+       (set_option_buttons_specification)
+       (set_html_default_buttons_specifications): add
+       set_html_default_buttons_specifications to set buttons customization
+       options with texi2any default buttons.
+
+       * tp/Texinfo/XS/convert/converter_options.c (t2h_special_units_names)
+       (enum T2H_special_unit_directions, T2H_SECTION_BUTTONS, T2H_TOP_BUTTONS)
+       (T2H_MISC_BUTTONS, T2H_CHAPTER_BUTTONS, T2H_SECTION_FOOTER_BUTTONS)
+       (new_texi2html_buttons_specifications): function and data to setup
+       buttons in the texi2html way.
+
+       * tp/Texinfo/XS/convert/converter_options.c
+       (set_texi2html_default_buttons_specifications): add to set buttons
+       customization options with texi2html buttons.
+
+       * tp/Texinfo/XS/convert/converter.h (CONVERTER_FORMAT_DATA),
+       tp/Texinfo/XS/convert/converter.c (set_converter_init_information):
+       add converter_defaults function pointer to CONVERTER_FORMAT_DATA to
+       call to initialize a converter for a specific format.  Get it and call
+       it in set_converter_init_information, with the user configuration
+       information structure as argument.
+
+       * tp/Texinfo/XS/convert/converter.c (converter_format_data),
+       tp/Texinfo/XS/convert/converter_options.c (html_converter_defaults):
+       add a converter_defaults function for HTML converter format that sets
+       customization options using converters_defaults.c function and
+       buttons, both for default and with TEXI2HTML set.
+
+       * tp/Texinfo/XS/convert/ConvertXS.xs (html_converter_defaults): return
+       undef, all the HTML customization default setup is done in C now.
+
 2024-08-04  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/Makefile.am (libtexinfo_convert_la_SOURCES),
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index acc0d17da2..aa0a534023 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -160,14 +160,14 @@ force_conf (SV *converter_in, conf, SV *value)
          RETVAL
 
 SV *
-get_conf (SV *converter_in, conf)
-         const char *conf = (char *)SvPVbyte_nolen($arg);
+get_conf (SV *converter_in, option_name)
+         const char *option_name = (char *)SvPVbyte_nolen($arg);
       PREINIT:
          CONVERTER *self;
       CODE:
          self = get_sv_converter (converter_in, 0);
          if (self)
-           RETVAL = get_sv_conf (self, conf);
+           RETVAL = get_sv_conf (self, option_name);
          else
            RETVAL = newSV (0);
     OUTPUT:
@@ -636,8 +636,17 @@ 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);
+        html_fill_options (self->conf, self);
 
+SV *
+html_converter_defaults (SV *converter_in, SV *conf_sv)
+      PREINIT:
+        HV *format_defaults_hv;
+      CODE:
+        format_defaults_hv = newHV ();
+        RETVAL = newRV_noinc ((SV *) format_defaults_hv);
+    OUTPUT:
+        RETVAL
 
 void
 html_conversion_initialization (SV *converter_in, const char *context, SV 
*document_in=0)
diff --git a/tp/Texinfo/XS/convert/call_html_perl_function.c 
b/tp/Texinfo/XS/convert/call_html_perl_function.c
index eb2ff2e1c2..93551cac90 100644
--- a/tp/Texinfo/XS/convert/call_html_perl_function.c
+++ b/tp/Texinfo/XS/convert/call_html_perl_function.c
@@ -1316,6 +1316,9 @@ call_formatting_function_format_navigation_panel 
(CONVERTER *self,
 
   build_tree_to_build (&self->tree_to_build);
 
+  if (!buttons->av)
+    html_build_buttons_specification (self, buttons);
+
   dSP;
 
   ENTER;
@@ -1373,6 +1376,9 @@ call_formatting_function_format_navigation_header 
(CONVERTER *self,
 
   build_tree_to_build (&self->tree_to_build);
 
+  if (!buttons->av)
+    html_build_buttons_specification (self, buttons);
+
   dSP;
 
   ENTER;
diff --git a/tp/Texinfo/XS/convert/converter.c 
b/tp/Texinfo/XS/convert/converter.c
index f6c37db236..ac29d2cb48 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -56,11 +56,12 @@
 #include "unicode.h"
 #include "manipulate_indices.h"
 #include "document.h"
+#include "converter_options.h"
 #include "call_perl_function.h"
 #include "converter.h"
 
 CONVERTER_FORMAT_DATA converter_format_data[] = {
-  {"html", "Texinfo::Convert::HTML", },
+  {"html", "Texinfo::Convert::HTML", &html_converter_defaults},
 };
 
 /* associate lower case no brace accent command to the upper case
@@ -278,6 +279,15 @@ set_converter_init_information (CONVERTER *converter,
 {
   apply_converter_info (converter, format_defaults, 0);
 
+  if (converter_format != COF_none
+      && converter_format_data[converter_format].converter_defaults)
+    {
+      void (* converter_defaults) (CONVERTER *self,
+                 CONVERTER_INITIALIZATION_INFO *conf)
+        = converter_format_data[converter_format].converter_defaults;
+      converter_defaults (converter, user_conf);
+    }
+
   apply_converter_info (converter, user_conf, 1);
 
   /* in Perl sets converter_init_conf, but in C we use only one
diff --git a/tp/Texinfo/XS/convert/converter.h 
b/tp/Texinfo/XS/convert/converter.h
index 48893a3b18..a5062cb365 100644
--- a/tp/Texinfo/XS/convert/converter.h
+++ b/tp/Texinfo/XS/convert/converter.h
@@ -98,6 +98,8 @@ typedef struct PATHS_INFORMATION {
 typedef struct CONVERTER_FORMAT_DATA {
     const char *output_format;
     const char *perl_converter_class;
+    void (* converter_defaults) (CONVERTER *self,
+                               CONVERTER_INITIALIZATION_INFO *conf);
 } CONVERTER_FORMAT_DATA;
 
 extern enum command_id no_brace_command_accent_upper_case[][2];
diff --git a/tp/Texinfo/XS/convert/converter_options.c 
b/tp/Texinfo/XS/convert/converter_options.c
index f81f57b6d9..0fb73d70c7 100644
--- a/tp/Texinfo/XS/convert/converter_options.c
+++ b/tp/Texinfo/XS/convert/converter_options.c
@@ -4,7 +4,7 @@
    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
@@ -21,19 +21,24 @@
 #include "tree_types.h"
 #include "option_types.h"
 #include "converter_types.h"
+#include "converters_defaults.h"
 #include "utils.h"
 
+/* code for converters options setting.  Not with format specific converter
+   code, since this code is called from generic converter code. */
 
 /* create button specification */
 void
 new_button_specification (BUTTON_SPECIFICATION *button,
                           enum button_specification_type type,
                           enum button_information_type info_type,
-                          int direction, const char *string,
+                          int direction, const char *direction_string,
+                          const char *string,
                           enum button_function_type function_type,
                           enum html_text_type text_type)
 {
   button->type = type;
+  button->direction_string = direction_string;
 
   if (type == BST_string)
     {
@@ -89,29 +94,41 @@ new_button_specification_list (size_t buttons_nr)
 /* BFT_type_panel_directions */
 BUTTON_SPECIFICATION_LIST *
 new_basic_buttons (const CONVERTER *self,
-                   enum button_function_type function_type)
+                   enum button_function_type function_type,
+                   int with_about)
 {
-  BUTTON_SPECIFICATION_LIST *result = new_button_specification_list (7);
+  BUTTON_SPECIFICATION_LIST *result;
+  int buttons_nr = 6;
+
+  if (with_about)
+    buttons_nr++;
+
+  result = new_button_specification_list (buttons_nr);
+  /* this function is called too early for special units direction
+     indices to be known, therefore we register direction string name
+     for such directions, directions are set afterwards.
   int contents_direction = html_get_direction_index (self, "Contents");
   int about_direction = html_get_direction_index (self, "About");
+   */
 
   new_button_specification (&result->list[0], BST_direction_info,
-                            BIT_function, D_direction_Next, 0,
+                            BIT_function, D_direction_Next, 0, 0,
                             function_type, 0);
   new_button_specification (&result->list[1], BST_direction_info,
-                            BIT_function, D_direction_Prev, 0,
+                            BIT_function, D_direction_Prev, 0, 0,
                             function_type, 0);
   new_button_specification (&result->list[2], BST_direction_info,
-                            BIT_function, D_direction_Up, 0,
+                            BIT_function, D_direction_Up, 0, 0,
                             function_type, 0);
-  new_button_specification (&result->list[3], BST_direction,
-                            0, D_direction_Space, 0, 0, 0);
-  new_button_specification (&result->list[4], BST_direction,
-                            0, contents_direction, 0, 0, 0);
-  new_button_specification (&result->list[5], BST_direction,
-                            0, D_direction_Index, 0, 0, 0);
-  new_button_specification (&result->list[6], BST_direction,
-                            0, about_direction, 0, 0, 0);
+  new_button_specification (&result->list[3], BST_direction, 0,
+                            D_direction_Space, 0, 0, 0, 0);
+  new_button_specification (&result->list[4], BST_direction, 0,
+                            -1, "Contents", 0, 0, 0);
+  new_button_specification (&result->list[5], BST_direction, 0,
+                            D_direction_Index, 0, 0, 0, 0);
+  if (with_about)
+    new_button_specification (&result->list[6], BST_direction,
+                              0, -1, "About", 0, 0, 0);
   return result;
 }
 
@@ -119,40 +136,205 @@ BUTTON_SPECIFICATION_LIST *
 new_link_buttons (const CONVERTER *self)
 {
   BUTTON_SPECIFICATION_LIST *result = new_button_specification_list (7);
+  /* this function is called too early for special units direction
+     indices to be known, therefore we register direction string name
+     for such directions, directions are set afterwards.
   int contents_direction = html_get_direction_index (self, "Contents");
   int about_direction = html_get_direction_index (self, "About");
+   */
   new_button_specification (&result->list[0], BST_direction,
-                            0, D_direction_Top, 0, 0, 0);
+                            0, D_direction_Top, 0, 0, 0, 0);
   new_button_specification (&result->list[1], BST_direction,
-                            0, D_direction_Index, 0, 0, 0);
+                            0, D_direction_Index, 0, 0, 0, 0);
   new_button_specification (&result->list[2], BST_direction,
-                            0, contents_direction, 0, 0, 0);
+                            0, -1, "Contents", 0, 0, 0);
   new_button_specification (&result->list[3], BST_direction,
-                            0, about_direction, 0, 0, 0);
+                            0, -1, "About", 0, 0, 0);
   new_button_specification (&result->list[4], BST_direction,
-                            0, D_direction_NodeUp, 0, 0, 0);
+                            0, D_direction_NodeUp, 0, 0, 0, 0);
   new_button_specification (&result->list[5], BST_direction,
-                            0, D_direction_NodeNext, 0, 0, 0);
+                            0, D_direction_NodeNext, 0, 0, 0, 0);
   new_button_specification (&result->list[6], BST_direction,
-                            0, D_direction_NodePrev, 0, 0, 0);
+                            0, D_direction_NodePrev, 0, 0, 0, 0);
   return result;
 }
 
 BUTTON_SPECIFICATION_LIST *
 new_section_buttons (const CONVERTER *self)
 {
-  return new_basic_buttons (self, BFT_type_panel_directions);
+  return new_basic_buttons (self, BFT_type_panel_directions, 1);
 }
 
 BUTTON_SPECIFICATION_LIST *
 new_section_footer_buttons (const CONVERTER *self)
 {
-  return new_basic_buttons (self, BFT_type_panel_section_footer);
+  return new_basic_buttons (self, BFT_type_panel_section_footer, 0);
 }
 
 
 
-/*
+/* TEXI2HTML buttons */
+enum T2H_special_unit_directions {
+    T2H_D_About = -3,
+    T2H_D_Contents,
+};
+
+static const char *t2h_special_units_names[] = {
+    "Contents",
+    "About",
+};
+
+/* same as NODE_FOOTER_BUTTONS */
+static const int T2H_SECTION_BUTTONS[] = {
+ D_direction_FastBack, D_direction_Back, D_direction_Up, D_direction_Forward,
+ D_direction_FastForward,
+ D_direction_Space, D_direction_Space, D_direction_Space, D_direction_Space,
+ D_direction_Top, T2H_D_Contents, D_direction_Index, T2H_D_About,
+ -1
+};
+
+/* same as TOP_FOOTER_BUTTONS */
+static const int T2H_TOP_BUTTONS[] = {
+ D_direction_Back, D_direction_Forward, D_direction_Space,
+ T2H_D_Contents, D_direction_Index, T2H_D_About,
+ -1
+};
+
+static const int T2H_MISC_BUTTONS[] = {
+ D_direction_Top, T2H_D_Contents, D_direction_Index, T2H_D_About,
+ -1
+};
+
+/* same as CHAPTER_FOOTER_BUTTONS */
+static const int T2H_CHAPTER_BUTTONS[] = {
+ D_direction_FastBack, D_direction_FastForward, D_direction_Space,
+ D_direction_Space, D_direction_Space, D_direction_Space, D_direction_Space,
+ D_direction_Top, T2H_D_Contents, D_direction_Index, T2H_D_About,
+ -1
+};
+
+static const int T2H_SECTION_FOOTER_BUTTONS[] = {
+ D_direction_FastBack, D_direction_FirstInFileBack, D_direction_FirstInFileUp,
+ D_direction_Forward, D_direction_FastForward,
+ -1
+};
+
+
+static BUTTON_SPECIFICATION_LIST *
+new_texi2html_buttons_specifications (CONVERTER *self, const int* directions)
+{
+  int buttons_nr = 0;
+  int i;
+  BUTTON_SPECIFICATION_LIST *result;
+
+  for (buttons_nr = 0; directions[buttons_nr] != -1; buttons_nr++) {};
+
+  result = new_button_specification_list (buttons_nr);
+
+  for (i = 0; i < buttons_nr; i++)
+    {
+      int direction = directions[i];
+      const char *direction_string = 0;
+      if (direction < 0)
+        {
+          int name_idx = -direction - 2;
+          direction_string = t2h_special_units_names[name_idx];
+        }
+      new_button_specification (&result->list[i], BST_direction,
+                        0, direction, direction_string, 0, 0, 0);
+    }
+  return result;
+}
+
+
+
+static void
+set_option_buttons_specification (OPTION *option,
+                                 BUTTON_SPECIFICATION_LIST *buttons)
+{
+  if (option->o.buttons)
+    html_free_button_specification_list (option->o.buttons);
+  option->o.buttons = buttons;
+}
+
+static void
+set_html_default_buttons_specifications (CONVERTER *self)
+{
+  OPTIONS *options = self->conf;
+  set_option_buttons_specification (&options->SECTION_BUTTONS,
+                                    new_section_buttons (self));
+  set_option_buttons_specification (&options->SECTION_FOOTER_BUTTONS,
+                                    new_section_footer_buttons (self));
+  set_option_buttons_specification (&options->LINKS_BUTTONS,
+                                    new_link_buttons (self));
+  set_option_buttons_specification (&options->NODE_FOOTER_BUTTONS,
+                  new_basic_buttons (self, BFT_type_panel_node_footer, 0));
+  set_option_buttons_specification (&options->CHAPTER_BUTTONS,
+                                    new_section_buttons (self));
+  set_option_buttons_specification (&options->MISC_BUTTONS,
+                                    new_section_buttons (self));
+  set_option_buttons_specification (&options->TOP_BUTTONS,
+                                    new_section_buttons (self));
+  set_option_buttons_specification (&options->CHAPTER_FOOTER_BUTTONS,
+                                    new_section_footer_buttons (self));
+  set_option_buttons_specification (&options->TOP_FOOTER_BUTTONS,
+                                    new_section_footer_buttons (self));
+}
+
+static void
+set_texi2html_default_buttons_specifications (CONVERTER *self)
+{
+  OPTIONS *options = self->conf;
+  set_option_buttons_specification (&options->SECTION_BUTTONS,
+        new_texi2html_buttons_specifications (self, T2H_SECTION_BUTTONS));
+
+  set_option_buttons_specification (&options->TOP_BUTTONS,
+        new_texi2html_buttons_specifications (self, T2H_TOP_BUTTONS));
+
+  set_option_buttons_specification (&options->TOP_FOOTER_BUTTONS,
+        new_texi2html_buttons_specifications (self, T2H_TOP_BUTTONS));
+
+  set_option_buttons_specification (&options->MISC_BUTTONS,
+        new_texi2html_buttons_specifications (self, T2H_MISC_BUTTONS));
+
+  set_option_buttons_specification (&options->CHAPTER_BUTTONS,
+        new_texi2html_buttons_specifications (self, T2H_CHAPTER_BUTTONS));
+
+  set_option_buttons_specification (&options->SECTION_FOOTER_BUTTONS,
+    new_texi2html_buttons_specifications (self, T2H_SECTION_FOOTER_BUTTONS));
+
+  set_option_buttons_specification (&options->CHAPTER_FOOTER_BUTTONS,
+        new_texi2html_buttons_specifications (self, T2H_CHAPTER_BUTTONS));
+
+  set_option_buttons_specification (&options->NODE_FOOTER_BUTTONS,
+        new_texi2html_buttons_specifications (self, T2H_SECTION_BUTTONS));
+}
+
 void
-html_converter_defaults (CONVERTER *self
- */
+html_converter_defaults (CONVERTER *self,
+                         CONVERTER_INITIALIZATION_INFO *conf)
+{
+  set_html_regular_options_defaults (self->conf);
+  set_html_default_buttons_specifications (self);
+
+  if (conf)
+    {
+      size_t t2h_conf_number = self->conf->TEXI2HTML.number;
+      size_t i;
+
+      for (i = 0; i < conf->conf.number; i++)
+        {
+          OPTION *option = &conf->conf.list[i];
+          if (option->number == t2h_conf_number)
+            {
+              if (option->o.integer >= 0)
+                {
+                  set_texi2html_regular_options_defaults (self->conf);
+                  set_texi2html_default_buttons_specifications (self);
+                  return;
+                }
+              break;
+            }
+        }
+    }
+}
diff --git a/tp/Texinfo/XS/convert/converter_options.h 
b/tp/Texinfo/XS/convert/converter_options.h
index aa682e7696..32a8da0360 100644
--- a/tp/Texinfo/XS/convert/converter_options.h
+++ b/tp/Texinfo/XS/convert/converter_options.h
@@ -12,4 +12,6 @@ BUTTON_SPECIFICATION_LIST *new_link_buttons (const CONVERTER 
*self);
 BUTTON_SPECIFICATION_LIST *new_section_buttons (const CONVERTER *self);
 BUTTON_SPECIFICATION_LIST *new_section_footer_buttons (const CONVERTER *self);
 
+void html_converter_defaults (CONVERTER *self,
+                              CONVERTER_INITIALIZATION_INFO *format_defaults);
 #endif
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index f739cdcf29..d1adcec4d1 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -60,6 +60,7 @@
 #include "output_unit.h"
 /* for TEXT_OPTIONS */
 #include "convert_to_text.h"
+/* also button_function_type_string */
 #include "get_perl_info.h"
 #include "build_perl_info.h"
 
@@ -2414,8 +2415,150 @@ pass_document_to_converter_sv (const CONVERTER 
*converter,
     }
 }
 
+/* build a Perl button data from pure C button structure.
+   This is a partial implementation.
+   This function can only be called for default buttons for now, so we do
+   not need to handle other types of buttons.  We could handle possibly
+   more: BST_string and BST_direction_info with
+     BIT_string, BIT_selected_direction_information_type and
+     BIT_href_direction_information_type.
+   Other need Perl info */
 SV *
-build_sv_option (const OPTION *option, const CONVERTER *converter)
+html_build_button (const CONVERTER *converter, BUTTON_SPECIFICATION *button,
+                   int *user_function_number)
+{
+  dTHX;
+
+  *user_function_number = 0;
+
+  switch (button->type)
+    {
+      const char *direction_name;
+      case BST_direction:
+        if (button->b.direction < 0)
+          direction_name = button->direction_string;
+        else
+          direction_name
+            = converter->direction_unit_direction_name[button->b.direction];
+        return newSVpv_utf8 (direction_name, 0);
+        break;
+
+      case BST_direction_info:
+        {
+          BUTTON_SPECIFICATION_INFO *button_spec = button->b.button_info;
+          AV *button_spec_info_av;
+
+          if (button_spec->direction < 0)
+            direction_name = button->direction_string;
+          else
+            direction_name
+            = converter->direction_unit_direction_name[button_spec->direction];
+
+          if (button_spec->type == BIT_function)
+            {
+              /* contains a leading :: */
+              const char *sub_name = html_button_function_type_string[
+                                      button_spec->bi.button_function.type];
+              if (sub_name)
+                {
+                  char *cv_name;
+                  CV *button_function_cv;
+
+                  xasprintf (&cv_name, "Texinfo::Convert::HTML%s", sub_name);
+                  button_function_cv = get_cv (cv_name, 0);
+                  if (!button_function_cv)
+                    fprintf (stderr, "BUG: %s: not found\n", cv_name);
+
+                  free (cv_name);
+
+                  button_spec_info_av = newAV ();
+                  av_push (button_spec_info_av,
+                           newSVpv_utf8 (direction_name, 0));
+              /* not sure that the _inc leads to the same number of references
+                 than with Pure perl defined buttons, but it is needed
+                 as tested  */
+                  av_push (button_spec_info_av,
+                           newRV_inc ((SV *) button_function_cv));
+                  return newRV_inc ((SV *) button_spec_info_av);
+                }
+            }
+        }
+        break;
+
+      default:
+        break;
+    }
+  return newSV (0);
+}
+
+SV *
+html_build_buttons_specification (CONVERTER *converter,
+                                  BUTTON_SPECIFICATION_LIST *buttons)
+{
+  AV *buttons_av;
+  size_t i;
+
+  dTHX;
+
+  buttons_av = newAV ();
+
+  buttons->av = buttons_av;
+
+  for (i = 0; i < buttons->number; i++)
+    {
+      int user_function_number;
+      BUTTON_SPECIFICATION *button = &buttons->list[i];
+
+      SV *button_sv = html_build_button (converter, button,
+                                         &user_function_number);
+      buttons->BIT_user_function_number += user_function_number;
+
+      converter->external_references_number += user_function_number;
+
+      button->sv = button_sv;
+
+      /* retain a reference in C */
+      SvREFCNT_inc (button->sv);
+
+      av_push (buttons_av, button_sv);
+    }
+
+  /* add a refcount to retain one in C */
+  return newRV_inc ((SV *)buttons_av);
+}
+
+SV *
+html_build_direction_icons (const CONVERTER *converter,
+                            const DIRECTION_ICON_LIST *direction_icons)
+{
+  HV *icons_hv;
+  int i;
+
+  dTHX;
+
+  if (!direction_icons)
+    return newSV (0);
+
+  if (!converter || !converter->direction_unit_direction_name)
+    return newSV (0);
+
+  icons_hv = newHV ();
+
+  for (i = 0; converter->direction_unit_direction_name[i]; i++)
+    {
+      if (direction_icons->list[i])
+        {
+          const char *direction_name
+            = converter->direction_unit_direction_name[i];
+          hv_store (icons_hv, direction_name, strlen (direction_name),
+                    newSVpv_utf8 (direction_icons->list[i], 0), 0);
+        }
+    }
+  return newRV_noinc ((SV *)icons_hv);
+}
+
+SV *
+build_sv_option (const OPTION *option, CONVERTER *converter)
 {
   dTHX;
 
@@ -2455,8 +2598,12 @@ build_sv_option (const OPTION *option, const CONVERTER 
*converter)
         break;
 
       case GOT_buttons:
-        if (!option->o.buttons) return newSV (0);
-        return newRV_inc ((SV *) option->o.buttons->av);
+        if (option->o.buttons)
+          {
+            if (!option->o.buttons->av)
+              html_build_buttons_specification (converter, option->o.buttons);
+            return newRV_inc ((SV *) option->o.buttons->av);
+          }
         break;
 
       case GOT_icons:
@@ -2464,13 +2611,13 @@ build_sv_option (const OPTION *option, const CONVERTER 
*converter)
         break;
 
       default:
-        return newSV (0);
         break;
     }
+  return newSV (0);
 }
 
 SV *
-get_sv_conf (const CONVERTER *converter, const char *option_name)
+get_sv_conf (CONVERTER *converter, const char *option_name)
 {
   dTHX;
 
@@ -3143,36 +3290,6 @@ build_sorted_indices_by_letter (
   return indices_hv;
 }
 
-SV *
-html_build_direction_icons (const CONVERTER *converter,
-                            const DIRECTION_ICON_LIST *direction_icons)
-{
-  HV *icons_hv;
-  int i;
-
-  dTHX;
-
-  if (!direction_icons)
-    return newSV (0);
-
-  if (!converter || !converter->direction_unit_direction_name)
-    return newSV (0);
-
-  icons_hv = newHV ();
-
-  for (i = 0; converter->direction_unit_direction_name[i]; i++)
-    {
-      if (direction_icons->list[i])
-        {
-          const char *direction_name
-            = converter->direction_unit_direction_name[i];
-          hv_store (icons_hv, direction_name, strlen (direction_name),
-                    newSVpv_utf8 (direction_icons->list[i], 0), 0);
-        }
-    }
-  return newRV_noinc ((SV *)icons_hv);
-}
-
 void
 build_tree_to_build (ELEMENT_LIST *tree_to_build)
 {
@@ -3192,7 +3309,7 @@ static const char *latex_math_options[] = {
 };
 
 HV *
-latex_build_options_for_convert_to_latex_math (const CONVERTER *converter)
+latex_build_options_for_convert_to_latex_math (CONVERTER *converter)
 {
   HV *options_latex_math_hv;
   int i;
diff --git a/tp/Texinfo/XS/main/build_perl_info.h 
b/tp/Texinfo/XS/main/build_perl_info.h
index ae41199f6a..bb8b9069ca 100644
--- a/tp/Texinfo/XS/main/build_perl_info.h
+++ b/tp/Texinfo/XS/main/build_perl_info.h
@@ -23,7 +23,7 @@ char *perl_only_strndup (const char *s, size_t n);
 int init (int texinfo_uninstalled, SV *pkgdatadir_sv, SV *builddir_sv,
           SV *top_srcdir_sv);
 
-SV *build_sv_option (const OPTION *option, const CONVERTER *converter);
+SV *build_sv_option (const OPTION *option, CONVERTER *converter);
 
 /* in call_perl_function.c, but declared here to avoid pulling in Perl
    headers in call_perl_function.h */
@@ -97,7 +97,7 @@ SV *html_build_direction_icons (const CONVERTER *converter,
 void pass_document_to_converter_sv (const CONVERTER *converter,
                                     SV *converter_sv, SV *document_in);
 
-SV *get_sv_conf (const CONVERTER *converter, const char *option_name);
+SV *get_sv_conf (CONVERTER *converter, const char *option_name);
 
 HV *build_expanded_formats (const EXPANDED_FORMAT *expanded_formats);
 HV *build_translated_commands (const TRANSLATED_COMMAND *translated_commands);
@@ -107,7 +107,7 @@ void pass_generic_converter_to_converter_sv (SV 
*converter_sv,
 
 SV *build_convert_text_options (struct TEXT_OPTIONS *text_options);
 
-HV *latex_build_options_for_convert_to_latex_math (const CONVERTER *converter);
+HV *latex_build_options_for_convert_to_latex_math (CONVERTER *converter);
 
 void build_tree_to_build (ELEMENT_LIST *tree_to_build);
 
diff --git a/tp/Texinfo/XS/main/get_perl_info.c 
b/tp/Texinfo/XS/main/get_perl_info.c
index a1100b268d..488161215f 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -814,7 +814,7 @@ force_sv_conf (CONVERTER *converter, const char *conf, SV 
*value)
 /* output format specific */
 
 /* should be consistent with enum button_function_type */
-static const char *button_function_type_string[] = {
+const char *html_button_function_type_string[] = {
   0,
   "::_default_panel_button_dynamic_direction_section_footer",
   "::_default_panel_button_dynamic_direction_node_footer",
@@ -836,21 +836,28 @@ html_fill_button_specification_list (const CONVERTER 
*converter,
 
       if (button->type == BST_direction_info)
         {
-          AV *button_spec_info_av = (AV *) SvRV((SV *)button->sv);
-          SV **direction_sv = av_fetch (button_spec_info_av, 0, 0);
-          const char *direction_name;
-
-          if (!direction_sv || !SvOK (*direction_sv))
+          const char *direction_name = 0;
+          if (button->sv)
             {
-              fprintf (stderr,
-                       "ERROR: missing direction in button %zu array\n",
-                       i);
-              continue;
+              AV *button_spec_info_av = (AV *) SvRV((SV *)button->sv);
+              SV **direction_sv = av_fetch (button_spec_info_av, 0, 0);
+
+              if (!direction_sv || !SvOK (*direction_sv))
+                {
+                  fprintf (stderr,
+                           "ERROR: missing direction in button %zu array\n",
+                           i);
+                  continue;
+                }
+
+              direction_name = SvPVutf8_nolen (*direction_sv);
             }
+          else if (button->b.button_info->direction < 0)
+            direction_name = button->direction_string;
 
-          direction_name = SvPVutf8_nolen (*direction_sv);
-          button->b.button_info->direction
-            = html_get_direction_index (converter, direction_name);
+          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)
             {
@@ -862,8 +869,17 @@ html_fill_button_specification_list (const CONVERTER 
*converter,
         }
       else if (button->type == BST_direction)
         {
-          const char *direction_name = SvPVutf8_nolen (button->sv);
-          button->b.direction = html_get_direction_index (converter,
+          const char *direction_name = 0;
+          if (button->sv)
+            {
+              direction_name = SvPVutf8_nolen (button->sv);
+            }
+          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)
@@ -995,9 +1011,9 @@ html_get_button_specification_list (const CONVERTER 
*converter,
                       button_fun_name
                        = SvPV_nolen (cv_name ((CV *) SvRV 
(*button_spec_info_type),
                                               0, 0));
-                      for (j = 1; button_function_type_string[j]; j++)
+                      for (j = 1; html_button_function_type_string[j]; j++)
                         if (strstr (button_fun_name,
-                                    button_function_type_string[j]))
+                                    html_button_function_type_string[j]))
                           {
                             button_fun_type = j;
                             break;
diff --git a/tp/Texinfo/XS/main/get_perl_info.h 
b/tp/Texinfo/XS/main/get_perl_info.h
index 6bd06f1287..ca2a1c8cea 100644
--- a/tp/Texinfo/XS/main/get_perl_info.h
+++ b/tp/Texinfo/XS/main/get_perl_info.h
@@ -15,6 +15,8 @@
 /* in options_get_perl.c */
 void html_fill_options (OPTIONS *options, const CONVERTER *converter);
 
+extern const char *html_button_function_type_string[];
+
 int get_sv_option (OPTION *option, SV *value, int force,
                    OPTIONS *options, const CONVERTER *converter);
 
diff --git a/tp/Texinfo/XS/main/option_types.h 
b/tp/Texinfo/XS/main/option_types.h
index 4955962d1d..b2c0e8af31 100644
--- a/tp/Texinfo/XS/main/option_types.h
+++ b/tp/Texinfo/XS/main/option_types.h
@@ -116,6 +116,10 @@ typedef struct BUTTON_SPECIFICATION {
     void *sv; /* reference to perl data that can be used instead of
                  the C data */
 
+    /* case of a pure C button, use this information to hold unresolved
+       direction name at option creation time for either buttons
+       specification info direction or button specification direction */
+    const char *direction_string;
     enum button_specification_type type;
     union {
      /* both global and relative directions index */



reply via email to

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