texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/convert/converter.c (converter_fo


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/convert/converter.c (converter_format_data) (converter_output, converter_convert), tp/Texinfo/XS/convert/converter.h (CONVERTER_FORMAT_DATA), tp/Texinfo/XS/convert/texinfo.c (txi_converter_output) (txi_converter_convert): add converter_output and converter_convert fields to CONVERTER_FORMAT_DATA and converter_output and converter_convert to dispatch conversion. Use it for HTML. Replace txi_html_convert and txi_html_output in texinfo.c by txi_converter_convert and txi_conv [...]
Date: Sat, 19 Oct 2024 08:50:09 -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 6ace0161a5 * tp/Texinfo/XS/convert/converter.c (converter_format_data) 
(converter_output, converter_convert), tp/Texinfo/XS/convert/converter.h 
(CONVERTER_FORMAT_DATA), tp/Texinfo/XS/convert/texinfo.c (txi_converter_output) 
(txi_converter_convert): add converter_output and converter_convert fields to 
CONVERTER_FORMAT_DATA and converter_output and converter_convert to dispatch 
conversion.  Use it for HTML.  Replace txi_html_convert and txi_html_output in 
texinfo.c by txi_converter [...]
6ace0161a5 is described below

commit 6ace0161a5d9e0fac8470ed891e53c98e97a4142
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Oct 19 14:50:04 2024 +0200

    * tp/Texinfo/XS/convert/converter.c (converter_format_data)
    (converter_output, converter_convert),
    tp/Texinfo/XS/convert/converter.h (CONVERTER_FORMAT_DATA),
    tp/Texinfo/XS/convert/texinfo.c (txi_converter_output)
    (txi_converter_convert): add converter_output and converter_convert
    fields to CONVERTER_FORMAT_DATA and converter_output and
    converter_convert to dispatch conversion.  Use it for HTML.  Replace
    txi_html_convert and txi_html_output in texinfo.c by
    txi_converter_convert and txi_converter_output that call
    converter_output and converter_convert.
    
    * tp/Texinfo/XS/teximakehtml.c: call txi_converter_output.
---
 ChangeLog                         | 15 +++++++++++++
 tp/Texinfo/XS/convert/converter.c | 44 +++++++++++++++++++++++++++++++++++----
 tp/Texinfo/XS/convert/converter.h | 10 +++++++++
 tp/Texinfo/XS/convert/texinfo.c   | 30 +++++++++++---------------
 tp/Texinfo/XS/convert/texinfo.h   |  3 ++-
 tp/Texinfo/XS/teximakehtml.c      |  2 +-
 6 files changed, 80 insertions(+), 24 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index de54eecde5..622be38c67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2024-10-19  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/converter.c (converter_format_data)
+       (converter_output, converter_convert),
+       tp/Texinfo/XS/convert/converter.h (CONVERTER_FORMAT_DATA),
+       tp/Texinfo/XS/convert/texinfo.c (txi_converter_output)
+       (txi_converter_convert): add converter_output and converter_convert
+       fields to CONVERTER_FORMAT_DATA and converter_output and
+       converter_convert to dispatch conversion.  Use it for HTML.  Replace
+       txi_html_convert and txi_html_output in texinfo.c by
+       txi_converter_convert and txi_converter_output that call
+       converter_output and converter_convert.
+
+       * tp/Texinfo/XS/teximakehtml.c: call txi_converter_output.
+
 2024-10-19  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/Makefile.am: remove specification of teximakehtml_LINK
diff --git a/tp/Texinfo/XS/convert/converter.c 
b/tp/Texinfo/XS/convert/converter.c
index fcf4699804..7ca8187f69 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -67,8 +67,8 @@
    Same purpose as inherited methods in Texinfo::Convert::Converter */
 CONVERTER_FORMAT_DATA converter_format_data[] = {
   {"html", "Texinfo::Convert::HTML", &html_converter_defaults,
-   &html_converter_initialize, &html_reset_converter,
-   &html_free_converter},
+   &html_converter_initialize, &html_output, &html_convert,
+   &html_reset_converter, &html_free_converter},
 };
 
 /* associate lower case no brace accent command to the upper case
@@ -249,8 +249,8 @@ init_generic_converter (CONVERTER *self)
 }
 
 /* descriptor starts at 1, 0 is not found or an error */
-/* flags set low-level implementation choices, currently using Perl hash
-   map or (slower) string lists */
+/* flags set low-level implementation choices, currently hash map
+   implementation */
 size_t
 new_converter (enum converter_format format, unsigned long flags)
 {
@@ -508,6 +508,42 @@ converter_set_document (CONVERTER *converter, DOCUMENT 
*document)
     = copy_converter_options_for_convert_text (converter);
 }
 
+char *
+converter_output (CONVERTER *self, DOCUMENT *document)
+{
+  enum converter_format converter_format = self->format;
+
+  if (converter_format != COF_none
+      && converter_format_data[converter_format].converter_output)
+    {
+      char *result;
+      char * (* format_converter_output) (CONVERTER *self,
+                                          DOCUMENT *document)
+        = converter_format_data[converter_format].converter_output;
+      result = format_converter_output (self, document);
+      return result;
+    }
+  return 0;
+}
+
+char *
+converter_convert (CONVERTER *self, DOCUMENT *document)
+{
+  enum converter_format converter_format = self->format;
+
+  if (converter_format != COF_none
+      && converter_format_data[converter_format].converter_convert)
+    {
+      char *result;
+      char * (* format_converter_convert) (CONVERTER *self,
+                                          DOCUMENT *document)
+        = converter_format_data[converter_format].converter_convert;
+      result = format_converter_convert (self, document);
+      return result;
+    }
+  return 0;
+}
+
 
 
 /* result to be freed */
diff --git a/tp/Texinfo/XS/convert/converter.h 
b/tp/Texinfo/XS/convert/converter.h
index 199a586397..797a2c444a 100644
--- a/tp/Texinfo/XS/convert/converter.h
+++ b/tp/Texinfo/XS/convert/converter.h
@@ -97,6 +97,13 @@ typedef struct CONVERTER_FORMAT_DATA {
        (* converter_defaults) (enum converter_format format,
                                CONVERTER_INITIALIZATION_INFO *conf);
     void (* converter_initialize) (CONVERTER *self);
+    char * (* converter_output) (CONVERTER *converter, DOCUMENT *document);
+    char * (* converter_convert) (CONVERTER *converter, DOCUMENT *document);
+    /* API to be determined, in HTML there is a debugging explanation
+       argument
+    char *(* converter_convert_tree) (CONVERTER *converter,
+                                      const ELEMENT *tree);
+     */
     void (* converter_reset) (CONVERTER *self);
     void (* converter_free) (CONVERTER *self);
 } CONVERTER_FORMAT_DATA;
@@ -147,6 +154,9 @@ void destroy_converter_initialization_info (
 
 void converter_set_document (CONVERTER *converter, DOCUMENT *document);
 
+char *converter_output (CONVERTER *self, DOCUMENT *document);
+char *converter_convert (CONVERTER *self, DOCUMENT *document);
+
 void reset_converter (CONVERTER *converter);
 void destroy_converter (CONVERTER *converter);
 
diff --git a/tp/Texinfo/XS/convert/texinfo.c b/tp/Texinfo/XS/convert/texinfo.c
index de01e510f1..1af366a44d 100644
--- a/tp/Texinfo/XS/convert/texinfo.c
+++ b/tp/Texinfo/XS/convert/texinfo.c
@@ -366,33 +366,27 @@ txi_converter_setup (const char *format_str,
   return self;
 }
 
-
-
-/* formats conversion */
+/* high level interface, possibly hiding some details of the data */
 
-/* similar to Texinfo::Convert::HTML->output */
-char *
-txi_html_output (CONVERTER *converter, DOCUMENT *document)
+DOCUMENT *
+txi_parse_texi_file (const char *input_file_path, int *status)
 {
-  return html_output (converter, document);
+  size_t document_descriptor = parse_file (input_file_path, status);
+  return retrieve_document (document_descriptor);
 }
 
-/* similar to Texinfo::Convert::HTML->convert */
+/* similar to Texinfo::Convert::XXX->output */
 char *
-txi_html_convert (CONVERTER *converter, DOCUMENT *document)
+txi_converter_output (CONVERTER *converter, DOCUMENT *document)
 {
-  return html_convert (converter, document);
+  return converter_output (converter, document);
 }
 
-
-
-/* high level interface, possibly hiding some details of the data */
-
-DOCUMENT *
-txi_parse_texi_file (const char *input_file_path, int *status)
+/* similar to Texinfo::Convert::XXX->convert */
+char *
+txi_converter_convert (CONVERTER *converter, DOCUMENT *document)
 {
-  size_t document_descriptor = parse_file (input_file_path, status);
-  return retrieve_document (document_descriptor);
+  return converter_convert (converter, document);
 }
 
 void
diff --git a/tp/Texinfo/XS/convert/texinfo.h b/tp/Texinfo/XS/convert/texinfo.h
index db443da9ae..a92767a0ae 100644
--- a/tp/Texinfo/XS/convert/texinfo.h
+++ b/tp/Texinfo/XS/convert/texinfo.h
@@ -47,7 +47,8 @@ CONVERTER *txi_converter_setup (const char *converter_format,
                      OPTIONS_LIST *customizations,
                      unsigned long converter_flags);
 
-char *txi_html_output (CONVERTER *converter, DOCUMENT *document);
+char *txi_converter_output (CONVERTER *converter, DOCUMENT *document);
+char *txi_converter_convert (CONVERTER *converter, DOCUMENT *document);
 
 size_t txi_handle_parser_error_messages (DOCUMENT *document, int no_warn,
                                        int use_filename,
diff --git a/tp/Texinfo/XS/teximakehtml.c b/tp/Texinfo/XS/teximakehtml.c
index 22d4e83d1d..3db3273ec4 100644
--- a/tp/Texinfo/XS/teximakehtml.c
+++ b/tp/Texinfo/XS/teximakehtml.c
@@ -323,7 +323,7 @@ main (int argc, char *argv[])
   /* conversion */
   /* return value can be NULL in case of errors or an empty string, but
      not anything else as parse_file is used with a file */
-  result = txi_html_output (converter, document);
+  result = txi_converter_output (converter, document);
   free (result);
 
   errors_nr



reply via email to

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