[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sat, 2 Dec 2023 10:49:49 -0500 (EST) |
branch: master
commit 9605c89d926eba41215405f7acd67f5f1ae6d2c7
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Dec 1 15:45:38 2023 +0100
* tp/Texinfo/XS/convert/convert_html.c (COMMAND_INTERNAL_CONVERSION)
(COMMAND_INTERNAL_OPEN, TYPE_INTERNAL_OPEN, types_internal_open_table)
(commands_internal_conversion_table, commands_internal_open_table)
(command_open_external, type_open_external)
(register_type_open_function, register_command_open_function)
(html_converter_initialize, convert_to_html_internal),
tp/Texinfo/XS/main/converter_types.h (TYPE_OPEN_FUNCTION)
(COMMAND_OPEN_FUNCTION, CONVERTER): add type_open_function and
command_open_function to converter structure and functions to register
command_open_external (renamed from command_open) and
type_open_external (renamed from type_open). Use the function
references in conversion. Add commands_internal_conversion_table,
commands_internal_open_table and types_internal_open_table to list
functions in C replacing perl functions if the default perl function
is used.
---
ChangeLog | 18 ++++
tp/Texinfo/XS/convert/convert_html.c | 158 ++++++++++++++++++++++++++++++-----
tp/Texinfo/XS/main/converter_types.h | 24 ++++++
3 files changed, 181 insertions(+), 19 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0072c575a0..76cf22da9b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2023-12-01 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/convert/convert_html.c (COMMAND_INTERNAL_CONVERSION)
+ (COMMAND_INTERNAL_OPEN, TYPE_INTERNAL_OPEN, types_internal_open_table)
+ (commands_internal_conversion_table, commands_internal_open_table)
+ (command_open_external, type_open_external)
+ (register_type_open_function, register_command_open_function)
+ (html_converter_initialize, convert_to_html_internal),
+ tp/Texinfo/XS/main/converter_types.h (TYPE_OPEN_FUNCTION)
+ (COMMAND_OPEN_FUNCTION, CONVERTER): add type_open_function and
+ command_open_function to converter structure and functions to register
+ command_open_external (renamed from command_open) and
+ type_open_external (renamed from type_open). Use the function
+ references in conversion. Add commands_internal_conversion_table,
+ commands_internal_open_table and types_internal_open_table to list
+ functions in C replacing perl functions if the default perl function
+ is used.
+
2023-11-30 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/convert/convert_html.c
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index ed69426cce..7694dec5d7 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -64,6 +64,21 @@ typedef struct CMD_VARIETY {
char *variety;
} CMD_VARIETY;
+typedef struct COMMAND_INTERNAL_CONVERSION {
+ enum command_id cmd;
+ void (* command_conversion) (struct CONVERTER *self,
+ const enum command_id cmd,
+ const ELEMENT *element,
+ const HTML_ARGS_FORMATTED *args_formatted,
+ const char *content, TEXT *result);
+} COMMAND_INTERNAL_CONVERSION;
+
+typedef struct COMMAND_INTERNAL_OPEN {
+ enum command_id cmd;
+ void (* command_open) (CONVERTER *self, const enum command_id cmd,
+ const ELEMENT *element, TEXT *result);
+} COMMAND_INTERNAL_OPEN;
+
typedef struct TYPE_INTERNAL_CONVERSION {
enum element_type type;
void (* type_conversion) (CONVERTER *self, const enum element_type type,
@@ -71,6 +86,12 @@ typedef struct TYPE_INTERNAL_CONVERSION {
TEXT *result);
} TYPE_INTERNAL_CONVERSION;
+typedef struct TYPE_INTERNAL_OPEN {
+ enum element_type type;
+ void (* type_open) (CONVERTER *self, const enum element_type type,
+ const ELEMENT *element, TEXT *result);
+} TYPE_INTERNAL_OPEN;
+
typedef struct OUTPUT_UNIT_INTERNAL_CONVERSION {
enum output_unit_type type;
void (* output_unit_conversion) (CONVERTER *self,
@@ -3904,6 +3925,20 @@ convert_row_type (CONVERTER *self, const enum
element_type type,
}
+/* associate command to the C function implementing the conversion */
+static COMMAND_INTERNAL_CONVERSION commands_internal_conversion_table[] = {
+ {0, 0},
+};
+
+/* associate command to the C function implementing the opening */
+static COMMAND_INTERNAL_OPEN commands_internal_open_table[] = {
+ /*
+ {CM_quotation, &open_quotation_command},
+ {CM_small_quotation, &open_quotation_command},
+ */
+ {0, 0},
+};
+
/* associate type to the C function implementing the conversion */
static TYPE_INTERNAL_CONVERSION types_internal_conversion_table[] = {
{ET_table_term, &convert_table_term_type},
@@ -3912,10 +3947,20 @@ static TYPE_INTERNAL_CONVERSION
types_internal_conversion_table[] = {
{0, 0},
};
-void convert_unit_type (CONVERTER *self,
- const enum output_unit_type unit_type,
- const OUTPUT_UNIT *output_unit, const char *content,
- TEXT *result)
+/* associate type to the C function implementing the opening */
+static TYPE_INTERNAL_OPEN types_internal_open_table[] = {
+ /*
+ {ET_paragraph, &open_inline_container_type},
+ {ET_preformatted, &open_inline_container_type},
+ */
+ {0, 0},
+};
+
+
+void
+convert_unit_type (CONVERTER *self, const enum output_unit_type unit_type,
+ const OUTPUT_UNIT *output_unit, const char *content,
+ TEXT *result)
{
STRING_LIST *closed_strings;
ELEMENT *unit_command;
@@ -4134,11 +4179,9 @@ command_conversion_external (CONVERTER *self, const enum
command_id cmd,
}
static void
-command_open (CONVERTER *self, const enum command_id cmd,
- const ELEMENT *element, TEXT *result)
+command_open_external (CONVERTER *self, const enum command_id cmd,
+ const ELEMENT *element, TEXT *result)
{
- /* TODO call a C function if status is FRS_status_default_set
- maybe putting function references in an array */
if (self->commands_open[cmd].status > 0)
call_commands_open (self, cmd, element, result);
}
@@ -4157,11 +4200,9 @@ type_conversion_external (CONVERTER *self, const enum
element_type type,
}
static void
-type_open (CONVERTER *self, enum element_type type, const ELEMENT *element,
- TEXT *result)
+type_open_external (CONVERTER *self, enum element_type type,
+ const ELEMENT *element, TEXT *result)
{
- /* TODO call a C function if status is FRS_status_default_set
- maybe putting function references in an array */
if (self->types_open[type].status > 0)
call_types_open (self, type, element, result);
}
@@ -4292,6 +4333,22 @@ register_type_conversion_function
(TYPE_CONVERSION_FUNCTION *result,
}
}
+void
+register_type_open_function (TYPE_OPEN_FUNCTION *result,
+ enum element_type type,
+ FORMATTING_REFERENCE *formatting_reference)
+{
+ if (formatting_reference->status > 0)
+ {
+ result->status = formatting_reference->status;
+ if (formatting_reference->status != FRS_status_ignored)
+ {
+ result->type_open = &type_open_external;
+ result->formatting_reference = formatting_reference;
+ }
+ }
+}
+
void
register_command_conversion_function (COMMAND_CONVERSION_FUNCTION *result,
enum command_id cmd,
@@ -4308,6 +4365,22 @@ register_command_conversion_function
(COMMAND_CONVERSION_FUNCTION *result,
}
}
+void
+register_command_open_function (COMMAND_OPEN_FUNCTION *result,
+ enum command_id cmd,
+ FORMATTING_REFERENCE *formatting_reference)
+{
+ if (formatting_reference->status > 0)
+ {
+ result->status = formatting_reference->status;
+ if (formatting_reference->status != FRS_status_ignored)
+ {
+ result->command_open = &command_open_external;
+ result->formatting_reference = formatting_reference;
+ }
+ }
+}
+
void
register_output_unit_conversion_function
(OUTPUT_UNIT_CONVERSION_FUNCTION *result,
@@ -4433,6 +4506,8 @@ html_converter_initialize (CONVERTER *self)
{
register_type_conversion_function (&self->type_conversion_function[i],
i, &self->types_conversion[i]);
+ register_type_open_function (&self->type_open_function[i],
+ i, &self->types_open[i]);
register_type_conversion_function (
&self->css_string_type_conversion_function[i], i,
&self->css_string_types_conversion[i]);
@@ -4452,16 +4527,59 @@ html_converter_initialize (CONVERTER *self)
}
}
+ for (i = 0; types_internal_open_table[i].type_open; i++)
+ {
+ enum element_type type = types_internal_open_table[i].type;
+ TYPE_OPEN_FUNCTION *type_open = &self->type_open_function[type];
+ if (type_open->status == FRS_status_default_set)
+ {
+ type_open->formatting_reference = 0;
+ type_open->status = FRS_status_internal;
+ type_open->type_open
+ = types_internal_open_table[i].type_open;
+ }
+ }
+
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]);
register_command_conversion_function (
&self->css_string_command_conversion_function[i], i,
&self->css_string_commands_conversion[i]);
}
+ for (i = 0; commands_internal_conversion_table[i].command_conversion; i++)
+ {
+ enum command_id cmd = commands_internal_conversion_table[i].cmd;
+ COMMAND_CONVERSION_FUNCTION *command_conversion
+ = &self->command_conversion_function[cmd];
+ if (command_conversion->status == FRS_status_default_set)
+ {
+ command_conversion->formatting_reference = 0;
+ command_conversion->status = FRS_status_internal;
+ command_conversion->command_conversion
+ = commands_internal_conversion_table[i].command_conversion;
+ }
+ }
+
+ for (i = 0; commands_internal_open_table[i].command_open; i++)
+ {
+ enum command_id cmd = commands_internal_open_table[i].cmd;
+ COMMAND_OPEN_FUNCTION *command_open = &self->command_open_function[cmd];
+ if (command_open->status == FRS_status_default_set)
+ {
+ command_open->formatting_reference = 0;
+ command_open->status = FRS_status_internal;
+ command_open->command_open
+ = commands_internal_open_table[i].command_open;
+ }
+ }
+
for (i = 0; i < OU_special_unit+1; i++)
{
register_output_unit_conversion_function
@@ -4774,7 +4892,7 @@ html_free_converter (CONVERTER *self)
free (self->associated_inline_content.list);
- destroy_associated_info (&self->shared_conversion_state.integers);
+ destroy_associated_info (&self->shared_conversion_state.integers);
free (self->no_arg_formatted_cmd_translated.list);
free (self->reset_target_commands.list);
@@ -5546,9 +5664,10 @@ convert_to_html_internal (CONVERTER *self, const ELEMENT
*element,
int convert_to_latex
= html_open_command_update_context (self, data_cmd);
- if (self->commands_open[cmd].status)
+ if (self->command_open_function[cmd].command_open)
{
- command_open (self, data_cmd, element, result);
+ (*self->command_open_function[cmd].command_open)
+ (self, data_cmd, element, result);
}
text_init (&content_formatted);
@@ -5858,7 +5977,9 @@ convert_to_html_internal (CONVERTER *self, const ELEMENT
*element,
html_open_type_update_context(self, type);
- type_open (self, type, element, &type_result);
+ if (self->type_open_function[type].type_open)
+ (*self->type_open_function[type].type_open)
+ (self, type, element, &type_result);
text_init (&content_formatted);
@@ -5945,10 +6066,9 @@ convert_to_html_internal (CONVERTER *self, const ELEMENT
*element,
{
(*self->current_types_conversion_function[0].type_conversion)
(self, 0, element, "", result);
- goto out;
}
- else
- goto out;
+
+ goto out;
}
debug_str = print_element_debug (element, 0);
fprintf (stderr, "DEBUG: HERE!(%p:%s)\n", element, debug_str);
diff --git a/tp/Texinfo/XS/main/converter_types.h
b/tp/Texinfo/XS/main/converter_types.h
index d9f4beaaba..97f4882588 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -445,6 +445,17 @@ typedef struct TYPE_CONVERSION_FUNCTION {
TEXT *text);
} TYPE_CONVERSION_FUNCTION;
+typedef struct TYPE_OPEN_FUNCTION {
+ enum formatting_reference_status status;
+ /* points to the perl formatting reference if it is used for
+ conversion */
+ FORMATTING_REFERENCE *formatting_reference;
+ /* the function used for conversion, either a function that calls
+ the perl function in formatting_reference, or another C function */
+ void (* type_open) (struct CONVERTER *self, const enum element_type type,
+ const ELEMENT *element, TEXT *text);
+} TYPE_OPEN_FUNCTION;
+
typedef struct HTML_ARG_FORMATTED {
const ELEMENT *tree;
char *formatted[AFT_type_raw+1];
@@ -469,6 +480,17 @@ typedef struct COMMAND_CONVERSION_FUNCTION {
const char *content, TEXT *result);
} COMMAND_CONVERSION_FUNCTION;
+typedef struct COMMAND_OPEN_FUNCTION {
+ enum formatting_reference_status status;
+ /* points to the perl formatting reference if it is used for
+ conversion */
+ FORMATTING_REFERENCE *formatting_reference;
+ /* the function used for conversion, either a function that calls
+ the perl function in formatting_reference, or another C function */
+ void (* command_open) (struct CONVERTER *self, const enum command_id cmd,
+ const ELEMENT *element, TEXT *result);
+} COMMAND_OPEN_FUNCTION;
+
typedef struct OUTPUT_UNIT_CONVERSION_FUNCTION {
enum formatting_reference_status status;
/* points to the perl formatting reference if it is used for
@@ -593,7 +615,9 @@ typedef struct CONVERTER {
char **special_unit_info[SUI_type_heading+1];
TYPE_CONVERSION_FUNCTION type_conversion_function[TXI_TREE_TYPES_NUMBER];
TYPE_CONVERSION_FUNCTION
css_string_type_conversion_function[TXI_TREE_TYPES_NUMBER];
+ TYPE_OPEN_FUNCTION type_open_function[TXI_TREE_TYPES_NUMBER];
COMMAND_CONVERSION_FUNCTION
command_conversion_function[BUILTIN_CMD_NUMBER];
+ COMMAND_OPEN_FUNCTION command_open_function[BUILTIN_CMD_NUMBER];
COMMAND_CONVERSION_FUNCTION
css_string_command_conversion_function[BUILTIN_CMD_NUMBER];
OUTPUT_UNIT_CONVERSION_FUNCTION
output_unit_conversion_function[OU_special_unit+1];
SPECIAL_UNIT_BODY_FORMATTING *special_unit_body_formatting;