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, 11 Mar 2024 19:02:18 -0400 (EDT)

branch: master
commit da0f0faaa112d4c0778387b49425bde175c38f81
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Mar 12 00:02:04 2024 +0100

    Count Perl functions used
    
    * tp/Texinfo/XS/convert/convert_html.c
    (register_type_conversion_function, register_type_open_function)
    (register_command_conversion_function, register_command_open_function)
    (register_output_unit_conversion_function)
    (register_special_unit_body_formatting_function)
    (html_converter_initialize): register_* return 1 if a function was
    registered.  Setup counters of perl functions registerd and not
    replaced by C functions.
    
    * tp/Texinfo/XS/main/get_perl_info.c
    (html_get_button_specification_list),
    tp/Texinfo/XS/main/option_types.h (BUTTON_SPECIFICATION_LIST),
    tp/maintain/regenerate_C_options_info.pl: add and set counters of the
    number of functions used in buttons for directions, of type
    BIT_function, that are not default functions.  Count for a
    BUTTON_SPECIFICATION_LIST and for all BUTTON_SPECIFICATION_LIST
    OPTIONS.
---
 ChangeLog                                | 22 +++++++
 tp/Texinfo/XS/convert/convert_html.c     | 99 ++++++++++++++++++++++++++------
 tp/Texinfo/XS/main/get_perl_info.c       |  6 +-
 tp/Texinfo/XS/main/option_types.h        |  3 +
 tp/maintain/regenerate_C_options_info.pl | 13 ++++-
 5 files changed, 123 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fc25df9786..87888261a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2024-03-11  Patrice Dumas  <pertusus@free.fr>
+
+       Count Perl functions used
+
+       * tp/Texinfo/XS/convert/convert_html.c
+       (register_type_conversion_function, register_type_open_function)
+       (register_command_conversion_function, register_command_open_function)
+       (register_output_unit_conversion_function)
+       (register_special_unit_body_formatting_function)
+       (html_converter_initialize): register_* return 1 if a function was
+       registered.  Setup counters of perl functions registerd and not
+       replaced by C functions.
+
+       * tp/Texinfo/XS/main/get_perl_info.c
+       (html_get_button_specification_list),
+       tp/Texinfo/XS/main/option_types.h (BUTTON_SPECIFICATION_LIST),
+       tp/maintain/regenerate_C_options_info.pl: add and set counters of the
+       number of functions used in buttons for directions, of type
+       BIT_function, that are not default functions.  Count for a
+       BUTTON_SPECIFICATION_LIST and for all BUTTON_SPECIFICATION_LIST
+       OPTIONS.
+
 2024-03-11  Patrice Dumas  <pertusus@free.fr>
 
        * tp/t/test_utils.pl (test): collect
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 651dae0ff9..57847b3c28 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -16020,7 +16020,7 @@ html_format_init (void)
   html_commands_data[CM_float].flags |= HF_composition_context;
 }
 
-void
+static int
 register_type_conversion_function (TYPE_CONVERSION_FUNCTION *result,
                                    enum element_type type,
                                    FORMATTING_REFERENCE *formatting_reference)
@@ -16032,11 +16032,13 @@ register_type_conversion_function 
(TYPE_CONVERSION_FUNCTION *result,
         {
           result->type_conversion = &type_conversion_external;
           result->formatting_reference = formatting_reference;
+          return 1;
         }
     }
+  return 0;
 }
 
-void
+static int
 register_type_open_function (TYPE_OPEN_FUNCTION *result,
                              enum element_type type,
                              FORMATTING_REFERENCE *formatting_reference)
@@ -16048,11 +16050,13 @@ register_type_open_function (TYPE_OPEN_FUNCTION 
*result,
         {
           result->type_open = &type_open_external;
           result->formatting_reference = formatting_reference;
+          return 1;
         }
     }
+  return 0;
 }
 
-void
+static int
 register_command_conversion_function (COMMAND_CONVERSION_FUNCTION *result,
                          enum command_id cmd,
                          FORMATTING_REFERENCE *formatting_reference)
@@ -16064,11 +16068,13 @@ register_command_conversion_function 
(COMMAND_CONVERSION_FUNCTION *result,
         {
           result->command_conversion = &command_conversion_external;
           result->formatting_reference = formatting_reference;
+          return 1;
         }
     }
+  return 0;
 }
 
-void
+static int
 register_command_open_function (COMMAND_OPEN_FUNCTION *result,
                                 enum command_id cmd,
                                 FORMATTING_REFERENCE *formatting_reference)
@@ -16080,11 +16086,13 @@ register_command_open_function (COMMAND_OPEN_FUNCTION 
*result,
         {
           result->command_open = &command_open_external;
           result->formatting_reference = formatting_reference;
+          return 1;
         }
     }
+  return 0;
 }
 
-void
+static int
 register_output_unit_conversion_function
                                   (OUTPUT_UNIT_CONVERSION_FUNCTION *result,
                                    enum output_unit_type type,
@@ -16097,11 +16105,13 @@ register_output_unit_conversion_function
         {
           result->output_unit_conversion = &output_unit_conversion_external;
           result->formatting_reference = formatting_reference;
+          return 1;
         }
     }
+  return 0;
 }
 
-void
+static int
 register_special_unit_body_formatting_function
                                   (SPECIAL_UNIT_BODY_FORMATTING *result,
                                    const char *special_unit_variety,
@@ -16115,8 +16125,10 @@ register_special_unit_body_formatting_function
           result->special_unit_body_formatting
                = &special_unit_body_formatting_external;
           result->formatting_reference = formatting_reference;
+          return 1;
         }
     }
+  return 0;
 }
 
 /* these constructors/initialization allow to use malloc from this
@@ -16239,6 +16251,16 @@ html_converter_initialize (CONVERTER *self)
 {
   int i;
   int nr_special_units;
+
+  /* counters of external formatting functions */
+  int external_special_unit_body_formatting_function = 0;
+  int external_output_unit_conversion_function = 0;
+  int external_command_conversion_function = 0;
+  int external_command_open_function = 0;
+  int external_type_conversion_function = 0;
+  int external_type_open_function = 0;
+  int external_formatting_function = 0;
+
   /* initialization needing some information from perl */
 
   nr_special_units = self->special_unit_varieties.number;
@@ -16297,10 +16319,15 @@ html_converter_initialize (CONVERTER *self)
 
   for (i = 0; i < TXI_TREE_TYPES_NUMBER; i++)
     {
-      register_type_conversion_function (&self->type_conversion_function[i],
+      int status = register_type_conversion_function (
+                                        &self->type_conversion_function[i],
                                         i, &self->types_conversion[i]);
-      register_type_open_function (&self->type_open_function[i],
+      external_type_conversion_function += status;
+
+      status = register_type_open_function (&self->type_open_function[i],
                                    i, &self->types_open[i]);
+      external_type_open_function += status;
+
       register_type_conversion_function (
              &self->css_string_type_conversion_function[i], i,
              &self->css_string_types_conversion[i]);
@@ -16308,12 +16335,16 @@ html_converter_initialize (CONVERTER *self)
 
   for (i = 0; i < BUILTIN_CMD_NUMBER; i++)
     {
-      register_command_conversion_function (
-           &self->command_conversion_function[i],
-           i, &self->commands_conversion[i]);
-      register_command_open_function (
-           &self->command_open_function[i],
-           i, &self->commands_open[i]);
+      int status = register_command_conversion_function (
+                            &self->command_conversion_function[i],
+                            i, &self->commands_conversion[i]);
+      external_command_conversion_function += status;
+
+      status = register_command_open_function (
+                            &self->command_open_function[i],
+                            i, &self->commands_open[i]);
+      external_command_open_function += status;
+
       register_command_conversion_function (
             &self->css_string_command_conversion_function[i], i,
              &self->css_string_commands_conversion[i]);
@@ -16321,9 +16352,10 @@ html_converter_initialize (CONVERTER *self)
 
   for (i = 0; i < OU_special_unit+1; i++)
     {
-      register_output_unit_conversion_function
+      int status = register_output_unit_conversion_function
                                   (&self->output_unit_conversion_function[i],
                                         i, &self->output_units_conversion[i]);
+      external_output_unit_conversion_function += status;
     }
 
   self->special_unit_body_formatting = (SPECIAL_UNIT_BODY_FORMATTING *)
@@ -16331,9 +16363,10 @@ html_converter_initialize (CONVERTER *self)
 
   for (i = 0; i < nr_special_units; i++)
     {
-      register_special_unit_body_formatting_function
+      int status = register_special_unit_body_formatting_function
                                   (&self->special_unit_body_formatting[i],
           self->special_unit_varieties.list[i], &self->special_unit_body[i]);
+      external_special_unit_body_formatting_function += status;
     }
 
   qsort (self->htmlxref.list, self->htmlxref.number,
@@ -16344,7 +16377,18 @@ html_converter_initialize (CONVERTER *self)
     {
       for (i = 0; i < FR_format_translate_message+1; i++)
         if (self->formatting_references[i].status == FRS_status_default_set)
-          self->formatting_references[i].status = FRS_status_customization_set;
+          {
+            self->formatting_references[i].status
+                                   = FRS_status_customization_set;
+            external_formatting_function++;
+          }
+    }
+  else
+    { /* count the functions implemented in perl */
+      for (i = 0; i < FR_format_translate_message+1; i++)
+        if (self->formatting_references[i].status
+                  == FRS_status_customization_set)
+          external_formatting_function++;
     }
 
   /* remaining of the file is for the replacement of call to external
@@ -16366,6 +16410,7 @@ html_converter_initialize (CONVERTER *self)
           type_conversion->status = FRS_status_internal;
           type_conversion->type_conversion
               = types_internal_conversion_table[i].type_conversion;
+          external_type_conversion_function--;
         }
       css_string_type_conversion->formatting_reference = 0;
       css_string_type_conversion->status = FRS_status_internal;
@@ -16387,6 +16432,7 @@ html_converter_initialize (CONVERTER *self)
           type_open->status = FRS_status_internal;
           type_open->type_open
               = types_internal_open_table[i].type_open;
+          external_type_open_function--;
         }
     }
 
@@ -16403,6 +16449,7 @@ html_converter_initialize (CONVERTER *self)
           command_conversion->status = FRS_status_internal;
           command_conversion->command_conversion
               = commands_internal_conversion_table[i].command_conversion;
+          external_command_conversion_function--;
         }
       css_string_command_conversion->formatting_reference = 0;
       css_string_command_conversion->status = FRS_status_internal;
@@ -16426,6 +16473,7 @@ html_converter_initialize (CONVERTER *self)
               command_conversion->status = FRS_status_internal;
               command_conversion->command_conversion
                 = &convert_no_arg_command;
+              external_command_conversion_function--;
             }
 
           css_string_command_conversion->formatting_reference = 0;
@@ -16451,6 +16499,7 @@ html_converter_initialize (CONVERTER *self)
               command_conversion->status = FRS_status_internal;
               command_conversion->command_conversion
                 = &convert_accent_command;
+              external_command_conversion_function--;
             }
           css_string_command_conversion->formatting_reference = 0;
           css_string_command_conversion->status = FRS_status_internal;
@@ -16478,6 +16527,7 @@ html_converter_initialize (CONVERTER *self)
               command_conversion->status = FRS_status_internal;
               command_conversion->command_conversion
                 = &convert_style_command;
+              external_command_conversion_function--;
             }
 
           css_string_command_conversion->formatting_reference = 0;
@@ -16504,6 +16554,7 @@ html_converter_initialize (CONVERTER *self)
               command_conversion->status = FRS_status_internal;
               command_conversion->command_conversion
                 = &convert_preformatted_command;
+              external_command_conversion_function--;
             }
 
           css_string_command_conversion->formatting_reference = 0;
@@ -16529,6 +16580,7 @@ html_converter_initialize (CONVERTER *self)
               command_conversion->status = FRS_status_internal;
               command_conversion->command_conversion
                 = &convert_def_command;
+              external_command_conversion_function--;
             }
 
           css_string_command_conversion->formatting_reference = 0;
@@ -16548,6 +16600,7 @@ html_converter_initialize (CONVERTER *self)
           command_open->status = FRS_status_internal;
           command_open->command_open
               = commands_internal_open_table[i].command_open;
+          external_command_open_function--;
         }
     }
 
@@ -16564,6 +16617,7 @@ html_converter_initialize (CONVERTER *self)
           output_unit_conversion->status = FRS_status_internal;
           output_unit_conversion->output_unit_conversion
            = output_units_internal_conversion_table[i].output_unit_conversion;
+          external_output_unit_conversion_function--;
         }
     }
 
@@ -16586,9 +16640,20 @@ html_converter_initialize (CONVERTER *self)
               body_formatting->status = FRS_status_internal;
               body_formatting->special_unit_body_formatting
                 = internal_conversion->special_unit_body_formatting;
+              external_special_unit_body_formatting_function--;
             }
         }
     }
+   /*
+  fprintf (stderr, "sbf %d ouc %d cc %d co %d tc %d to %d f %d\n",
+           external_special_unit_body_formatting_function,
+           external_output_unit_conversion_function,
+           external_command_conversion_function,
+           external_command_open_function,
+           external_type_conversion_function,
+           external_type_open_function,
+           external_formatting_function);
+    */
 }
 
 /* called in the end of html_converter_prepare_output_sv, just before
diff --git a/tp/Texinfo/XS/main/get_perl_info.c 
b/tp/Texinfo/XS/main/get_perl_info.c
index f7e3abd959..fc3fba9521 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -1055,6 +1055,7 @@ html_get_button_specification_list (const CONVERTER 
*converter,
 
   buttons_nr = av_top_index (buttons_av) +1;
 
+  result->BIT_user_function_number = 0;
   result->number = (size_t) buttons_nr;
   result->list = (BUTTON_SPECIFICATION *)
     malloc (result->number * sizeof (BUTTON_SPECIFICATION));
@@ -1114,7 +1115,10 @@ html_get_button_specification_list (const CONVERTER 
*converter,
                             button_fun_type = j;
                             break;
                           }
-                      button_spec->button_function.type = button_fun_type;
+                      if (button_fun_type)
+                        button_spec->button_function.type = button_fun_type;
+                      else
+                        result->BIT_user_function_number++;
                     }
                   else
                     {
diff --git a/tp/Texinfo/XS/main/option_types.h 
b/tp/Texinfo/XS/main/option_types.h
index 46533205c8..6fd10e7225 100644
--- a/tp/Texinfo/XS/main/option_types.h
+++ b/tp/Texinfo/XS/main/option_types.h
@@ -129,6 +129,9 @@ typedef struct BUTTON_SPECIFICATION_LIST {
     void *av; /* reference to perl data that can be used instead of
                  the list */
     size_t number;
+    /* number of BIT_function button_information_type functions that
+       are user-defined and not functions defined by default */
+    size_t BIT_user_function_number;
     BUTTON_SPECIFICATION *list;
 } BUTTON_SPECIFICATION_LIST;
 
diff --git a/tp/maintain/regenerate_C_options_info.pl 
b/tp/maintain/regenerate_C_options_info.pl
index f7dc5cc63f..c3d4dbe4e2 100755
--- a/tp/maintain/regenerate_C_options_info.pl
+++ b/tp/maintain/regenerate_C_options_info.pl
@@ -113,6 +113,7 @@ print HEADER "#undef PACKAGE_URL\n";
 print HEADER "#undef PACKAGE_VERSION\n\n";
 
 print HEADER "typedef struct OPTIONS {\n";
+print HEADER "    size_t BIT_user_function_number;\n";
 
 foreach my $category (sort(keys(%option_categories))) {
   print HEADER "\n/* ${category} */\n\n";
@@ -141,12 +142,13 @@ print CODE '#include "converter_types.h"'."\n";
 print CODE '#include "utils.h"'."\n\n";
 
 print CODE "void\ninitialize_options (OPTIONS *options)\n{\n";
+print CODE "  options->BIT_user_function_number = 0;\n";
 
 foreach my $category (sort(keys(%option_categories))) {
   print CODE "\n/* ${category} */\n\n";
   foreach my $option_info (@{$option_categories{$category}}) {
     my ($option, $value, $type) = @$option_info;
-    print CODE " initialize_option (&options->$option, GO_$type);\n";
+    print CODE "  initialize_option (&options->$option, GO_$type);\n";
   }
 }
 print CODE "};\n\n";
@@ -162,6 +164,7 @@ foreach my $category (sort(keys(%option_categories))) {
 print CODE "};\n\n";
 
 print CODE "void\nclear_options (OPTIONS *options)\n{\n";
+print CODE "  options->BIT_user_function_number = 0;\n";
 foreach my $category (sort(keys(%option_categories))) {
   print CODE "\n/* ${category} */\n\n";
   foreach my $option_info (@{$option_categories{$category}}) {
@@ -332,8 +335,14 @@ foreach my $category (sort(keys(%option_categories))) {
       add_svav_to_string_list (value, options->$option.strlist, 
$dir_string_arg);
     }\n";
     } elsif ($type eq 'buttons') {
-      print GET "      html_free_button_specification_list 
(options->$option.buttons);
+      print GET "      if (options->$option.buttons)
+        {
+          options->BIT_user_function_number -= 
options->$option.buttons->BIT_user_function_number;
+          html_free_button_specification_list (options->$option.buttons);
+        }
+
       options->$option.buttons = html_get_button_specification_list 
(converter, value);
+      options->BIT_user_function_number += 
options->$option.buttons->BIT_user_function_number;
     }\n";
     } elsif ($type eq 'icons') {
       print GET "      html_free_direction_icons (options->$option.icons);



reply via email to

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