[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Tue, 12 Mar 2024 19:09:28 -0400 (EDT) |
branch: master
commit 4f0fc4fd96c677fd60515980e20f65589b29283f
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Mar 12 19:19:49 2024 +0100
* tp/Texinfo/XS/convert/ConvertXS.xs (html_prepare_conversion_units)
(html_prepare_output_units_global_targets),
tp/Texinfo/XS/convert/convert_html.c (html_get_tree_root_element)
(prepare_special_units, html_prepare_conversion_units)
(set_special_units_targets_files)
(prepare_associated_special_units_targets, html_internal_command_href)
(html_prepare_conversion_units_targets)
(html_prepare_output_units_global_targets)
(html_prepare_units_directions_files),
tp/Texinfo/XS/main/converter_types.h (CONVERTER)
(enum output_units_descriptor_type): add output_units_descriptors
to converter store all types of output units descriptors. Remove
output_units_descriptors. Use that informaton to get output units
descriptors instead of going through Perl.
---
ChangeLog | 17 +++++++++
tp/Texinfo/XS/convert/ConvertXS.xs | 49 ++++++++-----------------
tp/Texinfo/XS/convert/convert_html.c | 70 +++++++++++++-----------------------
tp/Texinfo/XS/convert/convert_html.h | 15 ++------
tp/Texinfo/XS/main/converter_types.h | 8 ++++-
5 files changed, 65 insertions(+), 94 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ea6669a5db..42ff7147a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,23 @@
the example. Move discussion of having at least one @item, index
entries and comments, and blank lines after the example usage.
+2024-03-12 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/convert/ConvertXS.xs (html_prepare_conversion_units)
+ (html_prepare_output_units_global_targets),
+ tp/Texinfo/XS/convert/convert_html.c (html_get_tree_root_element)
+ (prepare_special_units, html_prepare_conversion_units)
+ (set_special_units_targets_files)
+ (prepare_associated_special_units_targets, html_internal_command_href)
+ (html_prepare_conversion_units_targets)
+ (html_prepare_output_units_global_targets)
+ (html_prepare_units_directions_files),
+ tp/Texinfo/XS/main/converter_types.h (CONVERTER)
+ (enum output_units_descriptor_type): add output_units_descriptors
+ to converter store all types of output units descriptors. Remove
+ output_units_descriptors. Use that informaton to get output units
+ descriptors instead of going through Perl.
+
2024-03-12 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/convert/get_html_perl_info.c
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs
b/tp/Texinfo/XS/convert/ConvertXS.xs
index e2de5f49e8..e414292b3e 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -1854,9 +1854,6 @@ html_prepare_conversion_units (SV *converter_in, ...)
HV *converter_hv;
const char *document_name = 0;
CONVERTER *self;
- int output_units_descriptor = 0;
- int special_units_descriptor = 0;
- int associated_special_units_descriptor = 0;
SV *output_units_sv;
SV *special_units_sv;
SV *associated_special_units_sv;
@@ -1875,9 +1872,7 @@ html_prepare_conversion_units (SV *converter_in, ...)
&& !strcasecmp (self->conf->OUTPUT_ENCODING_NAME.string, "utf-8"))
self->use_unicode_text = 1;
- html_prepare_conversion_units (self,
- &output_units_descriptor, &special_units_descriptor,
- &associated_special_units_descriptor);
+ html_prepare_conversion_units (self);
/* need to setup the Perl tree before rebuilding the output units as
they refer to Perl root command elements */
@@ -1890,10 +1885,12 @@ html_prepare_conversion_units (SV *converter_in, ...)
store_texinfo_tree (self->document, document_hv);
}
- output_units_sv = build_output_units_list (output_units_descriptor);
- special_units_sv = build_output_units_list (special_units_descriptor);
- associated_special_units_sv
- = build_output_units_list (associated_special_units_descriptor);
+ output_units_sv = build_output_units_list
+ (self->output_units_descriptors[OUDT_units]);
+ special_units_sv = build_output_units_list
+ (self->output_units_descriptors[OUDT_special_units]);
+ associated_special_units_sv = build_output_units_list
+ (self->output_units_descriptors[OUDT_associated_special_units]);
output_units_hv = (HV *) SvRV (output_units_sv);
hv_store (converter_hv, "document_units", strlen ("document_units"),
@@ -1902,9 +1899,7 @@ html_prepare_conversion_units (SV *converter_in, ...)
/* calls perl customization functions, so need to be done after
build_output_units_list calls to be able to retrieve Perl
output units references */
- html_prepare_conversion_units_targets (self, document_name,
- output_units_descriptor, special_units_descriptor,
- associated_special_units_descriptor);
+ html_prepare_conversion_units_targets (self, document_name);
EXTEND(SP, 3);
PUSHs(sv_2mortal(output_units_sv));
@@ -1969,33 +1964,17 @@ void
html_prepare_output_units_global_targets (SV *converter_in, SV
*output_units_in, SV *special_units_in, SV *associated_special_units_in)
PREINIT:
CONVERTER *self = 0;
- int output_units_descriptor = 0;
- int special_units_descriptor = 0;
- int associated_special_units_descriptor = 0;
CODE:
self = get_sv_converter (converter_in,
"html_prepare_output_units_global_targets");
- if (SvOK (output_units_in))
- output_units_descriptor
- = get_sv_output_units_descriptor (output_units_in,
- "html_prepare_output_units_global_targets output
units");
- if (SvOK (special_units_in))
- special_units_descriptor
- = get_sv_output_units_descriptor (special_units_in,
- "html_prepare_output_units_global_targets special
units");
- if (SvOK (associated_special_units_in))
- associated_special_units_descriptor
- = get_sv_output_units_descriptor (associated_special_units_in,
- "html_prepare_output_units_global_targets associated special
units");
+ html_prepare_output_units_global_targets (self);
- html_prepare_output_units_global_targets (self,
- output_units_descriptor, special_units_descriptor,
- associated_special_units_descriptor);
-
- rebuild_output_units_list (output_units_in, output_units_descriptor);
- rebuild_output_units_list (special_units_in,
special_units_descriptor);
+ rebuild_output_units_list (output_units_in,
+ self->output_units_descriptors[OUDT_units]);
+ rebuild_output_units_list (special_units_in,
+ self->output_units_descriptors[OUDT_special_units]);
rebuild_output_units_list (associated_special_units_in,
- associated_special_units_descriptor);
+ self->output_units_descriptors[OUDT_associated_special_units]);
pass_html_global_units_directions (converter_in,
self->global_units_directions,
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 57847b3c28..a8f8cb6414 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -354,7 +354,7 @@ html_get_tree_root_element (CONVERTER *self, const ELEMENT
*command,
&& builtin_command_data[data_cmd].data == BLOCK_region)
{
const OUTPUT_UNIT_LIST *output_units
- = retrieve_output_units (self->document_units_descriptor);
+ = retrieve_output_units (self->output_units_descriptors[OUDT_units]);
if (data_cmd == CM_copying
&& self->document->global_commands->insertcopying.number > 0)
{
@@ -1416,9 +1416,7 @@ compare_special_units (const void *a, const void *b)
}
void
-prepare_special_units (CONVERTER *self, int output_units_descriptor,
- int *special_units_descriptor_ref,
- int *associated_special_units_descriptor_ref)
+prepare_special_units (CONVERTER *self, int output_units_descriptor)
{
int i;
STRING_LIST *special_unit_varieties = &self->special_unit_varieties;
@@ -1442,8 +1440,8 @@ prepare_special_units (CONVERTER *self, int
output_units_descriptor,
/* for separate special output units */
STRING_LIST *do_special = new_string_list ();
- *special_units_descriptor_ref = special_units_descriptor;
- *associated_special_units_descriptor_ref
+ self->output_units_descriptors[OUDT_special_units] =
special_units_descriptor;
+ self->output_units_descriptors[OUDT_associated_special_units]
= associated_special_units_descriptor;
if (self->document->sections_list
@@ -1674,10 +1672,7 @@ static const enum command_id conf_for_special_units[]
= {CM_footnotestyle, 0};
void
-html_prepare_conversion_units (CONVERTER *self,
- int *output_units_descriptor_ref,
- int *special_units_descriptor_ref,
- int *associated_special_units_descriptor_ref)
+html_prepare_conversion_units (CONVERTER *self)
{
int output_units_descriptor;
@@ -1685,11 +1680,7 @@ html_prepare_conversion_units (CONVERTER *self,
output_units_descriptor = split_by_node (self->document);
else
output_units_descriptor = split_by_section (self->document);
- *output_units_descriptor_ref = output_units_descriptor;
-
- /* Needs to be set early in case it would be needed to find some region
- command associated root command. */
- self->document_units_descriptor = output_units_descriptor;
+ self->output_units_descriptors[OUDT_units] = output_units_descriptor;
/* the presence of contents elements in the document is used in diverse
places, set it once for all here */
@@ -1705,21 +1696,18 @@ html_prepare_conversion_units (CONVERTER *self,
@footnotestyle should only appear in the preamble, and it makes sense
to have something consistent in the whole document for footnotes position.
*/
- prepare_special_units (self, output_units_descriptor,
- special_units_descriptor_ref,
- associated_special_units_descriptor_ref);
+ prepare_special_units (self, output_units_descriptor);
/* reset to the default */
set_global_document_commands (self, CL_before, conf_for_special_units);
}
void
-set_special_units_targets_files (CONVERTER *self, int special_units_descriptor,
- const char *document_name)
+set_special_units_targets_files (CONVERTER *self, const char *document_name)
{
int i;
- OUTPUT_UNIT_LIST *special_units
- = retrieve_output_units (special_units_descriptor);
+ OUTPUT_UNIT_LIST *special_units = retrieve_output_units
+ (self->output_units_descriptors[OUDT_special_units]);
char *extension = "";
if (self->conf->EXTENSION.string)
@@ -1804,11 +1792,10 @@ set_special_units_targets_files (CONVERTER *self, int
special_units_descriptor,
}
static void
-prepare_associated_special_units_targets (CONVERTER *self,
- int associated_special_units_descriptor)
+prepare_associated_special_units_targets (CONVERTER *self)
{
- OUTPUT_UNIT_LIST *associated_special_units
- = retrieve_output_units (associated_special_units_descriptor);
+ OUTPUT_UNIT_LIST *associated_special_units = retrieve_output_units
+ (self->output_units_descriptors[OUDT_associated_special_units]);
if (associated_special_units && associated_special_units->number > 0)
{
@@ -3501,7 +3488,7 @@ html_internal_command_href (CONVERTER *self, const
ELEMENT *command,
as in the test cases. Also for things in @titlepage when
titlepage is not output. */
const OUTPUT_UNIT_LIST *output_units
- = retrieve_output_units (self->document_units_descriptor);
+ = retrieve_output_units (self->output_units_descriptors[OUDT_units]);
if (output_units->list[0]->unit_filename)
{ /* In that case use the first page. */
set_target_filename = (FILE_NUMBER_NAME *)
@@ -5008,20 +4995,15 @@ sort_cmd_targets (CONVERTER *self)
files for document units to be set */
void
html_prepare_conversion_units_targets (CONVERTER *self,
- const char *document_name,
- int output_units_descriptor,
- int special_units_descriptor,
- int associated_special_units_descriptor)
+ const char *document_name)
{
/*
Do that before the other elements, to be sure that special page ids
are registered before elements id are.
*/
- set_special_units_targets_files (self, special_units_descriptor,
- document_name);
+ set_special_units_targets_files (self, document_name);
- prepare_associated_special_units_targets (self,
- associated_special_units_descriptor);
+ prepare_associated_special_units_targets (self);
set_root_commands_targets_node_files (self);
@@ -5036,22 +5018,20 @@ html_prepare_conversion_units_targets (CONVERTER *self,
/* Associate output units to the global targets, First, Last, Top, Index.
and special output units */
void
-html_prepare_output_units_global_targets (CONVERTER *self,
- int output_units_descriptor,
- int special_units_descriptor,
- int
associated_special_units_descriptor)
+html_prepare_output_units_global_targets (CONVERTER *self)
{
int i;
int all_special_units_nr = 0;
int s;
- const OUTPUT_UNIT_LIST *output_units
- = retrieve_output_units (output_units_descriptor);
+ const OUTPUT_UNIT_LIST *output_units = retrieve_output_units
+ (self->output_units_descriptors[OUDT_units]);
const OUTPUT_UNIT *top_output_unit = get_top_unit (self->document,
output_units);
- int special_output_units_lists[2] = {special_units_descriptor,
- associated_special_units_descriptor};
+ int special_output_units_lists[2] = {
+ self->output_units_descriptors[OUDT_special_units],
+ self->output_units_descriptors[OUDT_associated_special_units]};
self->global_units_directions[D_First] = output_units->list[0];
self->global_units_directions[D_Last]
@@ -5787,9 +5767,7 @@ html_prepare_units_directions_files (CONVERTER *self,
OUTPUT_UNIT_LIST *associated_special_units
= retrieve_output_units (associated_special_units_descriptor);
- html_prepare_output_units_global_targets (self, output_units_descriptor,
- special_units_descriptor,
- associated_special_units_descriptor);
+ html_prepare_output_units_global_targets (self);
split_pages (output_units, self->conf->SPLIT.string);
diff --git a/tp/Texinfo/XS/convert/convert_html.h
b/tp/Texinfo/XS/convert/convert_html.h
index 6afd77c90b..50f982f7c8 100644
--- a/tp/Texinfo/XS/convert/convert_html.h
+++ b/tp/Texinfo/XS/convert/convert_html.h
@@ -190,16 +190,10 @@ size_t html_check_htmlxref_already_warned (CONVERTER
*self,
const char *manual_name,
const SOURCE_INFO *source_info);
-void html_prepare_conversion_units (CONVERTER *self,
- int *output_units_descriptor_ref,
- int *special_units_descriptor_ref,
- int
*associated_special_units_descriptor_ref);
+void html_prepare_conversion_units (CONVERTER *self);
void html_prepare_conversion_units_targets (CONVERTER *self,
- const char *document_name,
- int output_units_descriptor,
- int special_units_descriptor,
- int associated_special_units_descriptor);
+ const char *document_name);
FILE_SOURCE_INFO_LIST * html_prepare_units_directions_files (CONVERTER *self,
int output_units_descriptor,
@@ -207,10 +201,7 @@ FILE_SOURCE_INFO_LIST *
html_prepare_units_directions_files (CONVERTER *self,
const char *output_file, const char *destination_directory,
const char *output_filename, const char *document_name);
-void html_prepare_output_units_global_targets (CONVERTER *self,
- int output_units_descriptor,
- int special_units_descriptor,
- int
associated_special_units_descriptor);
+void html_prepare_output_units_global_targets (CONVERTER *self);
void html_translate_names (CONVERTER *self);
diff --git a/tp/Texinfo/XS/main/converter_types.h
b/tp/Texinfo/XS/main/converter_types.h
index dac79a7f71..81ed045f4d 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -35,6 +35,12 @@ enum sv_string_type {
svt_char,
};
+enum output_units_descriptor_type {
+ OUDT_units,
+ OUDT_special_units,
+ OUDT_associated_special_units,
+};
+
enum formatting_reference_status {
FRS_status_none,
FRS_status_default_set, /* default is set, no customization (or
@@ -698,7 +704,6 @@ typedef struct CONVERTER {
STRING_LIST small_strings;
DOCUMENT *document;
- int document_units_descriptor;
struct TEXT_OPTIONS *convert_text_options;
struct TEXT_OPTIONS *convert_index_text_options;
@@ -762,6 +767,7 @@ typedef struct CONVERTER {
const char **direction_unit_direction_name;
/* set for a document */
+ int output_units_descriptors[OUDT_associated_special_units+1];
enum htmlxref_split_type document_htmlxref_split_type;
const OUTPUT_UNIT **global_units_directions;
SPECIAL_UNIT_DIRECTION *special_units_direction_name;