[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Con
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Convert/HTML.pm (converter_initialize): remove encode_converter_document from Texinfo::Convert::Converter and move corresponding code to the end of converter_initialize where XS converter is initialized. |
Date: |
Sun, 05 Nov 2023 17:22:51 -0500 |
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 892c3be2f7 * tp/Texinfo/Convert/Converter.pm,
tp/Texinfo/Convert/HTML.pm (converter_initialize): remove
encode_converter_document from Texinfo::Convert::Converter and move
corresponding code to the end of converter_initialize where XS converter is
initialized.
892c3be2f7 is described below
commit 892c3be2f790ef2559d0869a2979b13418f719bc
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Nov 5 23:22:43 2023 +0100
* tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Convert/HTML.pm
(converter_initialize): remove encode_converter_document from
Texinfo::Convert::Converter and move corresponding code to the end of
converter_initialize where XS converter is initialized.
* tp/Texinfo/Convert/HTML.pm (converter_initialize),
tp/Texinfo/XS/main/get_perl_info.c (html_converter_initialize_sv):
pass directly the converter to html_converter_initialize_sv.
---
ChangeLog | 11 ++++++++
tp/Texinfo/Convert/Converter.pm | 55 --------------------------------------
tp/Texinfo/Convert/HTML.pm | 40 ++++++++++++++++++++++++---
tp/Texinfo/XS/main/get_perl_info.c | 23 +++++++---------
tp/Texinfo/XS/main/get_perl_info.h | 3 ++-
5 files changed, 58 insertions(+), 74 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ebbbcb4738..9a920261f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-11-05 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Convert/HTML.pm
+ (converter_initialize): remove encode_converter_document from
+ Texinfo::Convert::Converter and move corresponding code to the end of
+ converter_initialize where XS converter is initialized.
+
+ * tp/Texinfo/Convert/HTML.pm (converter_initialize),
+ tp/Texinfo/XS/main/get_perl_info.c (html_converter_initialize_sv):
+ pass directly the converter to html_converter_initialize_sv.
+
2023-11-05 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/Converter.pm (encode_converter_document),
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 04538d4dd0..514ac7021b 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -453,61 +453,6 @@ sub output($$)
return undef;
}
-###############################################################
-# XS Interface for a document to be converted.
-# Select to pass to the XS code
-# TODO document?
-# To be called for initialization
-sub encode_converter_document($)
-{
- my $self = shift;
- my $result = {'converter' => $self, # pass full converter to be able to
modify
- # and set converter_descriptor
- 'document_descriptor' => $self->{'document_descriptor'}};
-
- foreach my $variable ('expanded_formats', 'style_commands_formatting',
- 'formatting_function',
- 'types_open', 'types_conversion', 'commands_open', 'commands_conversion',
- 'output_units_conversion', 'code_types', 'pre_class_types',
- 'converter_init_conf', 'translated_commands',
- 'no_arg_commands_formatting') {
- if ($self->{$variable}) {
- $result->{$variable} = $self->{$variable};
- }
- }
-
- if ($self->{'special_unit_info'}) {
- # information that does not need to be translated
- $result->{'special_unit_info'} =
Storable::dclone($self->{'special_unit_info'});
- # information needing translation, simplify the structure to
- # be more like non-translated special_unit_info information
- if ($self->{'translated_special_unit_info'}) {
- foreach my $tree_type (keys(%{$self->{'translated_special_unit_info'}}))
{
- my $type = $self->{'translated_special_unit_info'}->{$tree_type}->[0];
- my $variety_strings
- = $self->{'translated_special_unit_info'}->{$tree_type}->[1];
- # we do not need both tree type and string type to pass to XS,
- # pass only the string type $type and associated varieties information
- $result->{'special_unit_info'}->{$type} = $variety_strings;
- }
- }
-
- # to help the XS code to set arrays of C structures, already prepare
- # a list of special units varieties.
- my %all_special_unit_varieties;
- foreach my $type (keys(%{$result->{'special_unit_info'}})) {
- foreach my $special_unit_variety
- (keys (%{$result->{'special_unit_info'}->{$type}})) {
- $all_special_unit_varieties{$special_unit_variety} = 1;
- }
- }
- $result->{'sorted_special_unit_varieties'}
- = [sort(keys(%all_special_unit_varieties))];
- }
-
- return $result;
-}
-
# FIXME remove, do in XS
sub converter_options_for_output($)
{
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 569b66d58c..a5d1448a1a 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -8490,10 +8490,40 @@ sub converter_initialize($)
$self->force_conf('SPLIT', 'node');
}
- if ($self->{'document_descriptor'}) {
- my $encoded_converter = $self->encode_converter_document();
- #print STDERR "CCI ".\%default_formatting_references."
".\%default_css_string_formatting_references." ".\%default_commands_open." ".
\%default_commands_conversion." ".\%default_types_open."
".\%default_types_conversion." ".\%default_output_units_conversion."\n";
- _XS_converter_initialize($encoded_converter,
+ # XS parser initialization
+ if ($self->{'document_descriptor'} and $XS_convert) {
+ # reformat special_unit_info information passed to XS to simplify
+ # XS code
+ if ($self->{'special_unit_info'}) {
+ # information that does not need to be translated
+ $self->{'simplified_special_unit_info'}
+ = Storable::dclone($self->{'special_unit_info'});
+ # information needing translation, simplify the structure to
+ # be more like non-translated special_unit_info information
+ if ($self->{'translated_special_unit_info'}) {
+ foreach my $tree_type
(keys(%{$self->{'translated_special_unit_info'}})) {
+ my $type =
$self->{'translated_special_unit_info'}->{$tree_type}->[0];
+ my $variety_strings
+ = $self->{'translated_special_unit_info'}->{$tree_type}->[1];
+ # we do not need both tree type and string type to pass to XS,
+ # pass only the string type $type and associated varieties
information
+ $self->{'simplified_special_unit_info'}->{$type} = $variety_strings;
+ }
+ }
+
+ # to help the XS code to set arrays of C structures, already prepare
+ # a list of special units varieties.
+ my %all_special_unit_varieties;
+ foreach my $type (keys(%{$self->{'simplified_special_unit_info'}})) {
+ foreach my $special_unit_variety
+ (keys (%{$self->{'simplified_special_unit_info'}->{$type}})) {
+ $all_special_unit_varieties{$special_unit_variety} = 1;
+ }
+ }
+ $self->{'sorted_special_unit_varieties'}
+ = [sort(keys(%all_special_unit_varieties))];
+ }
+ _XS_converter_initialize($self,
\%default_formatting_references,
\%default_css_string_formatting_references,
\%default_commands_open,
@@ -8503,6 +8533,8 @@ sub converter_initialize($)
\%default_types_conversion,
\%default_css_string_types_conversion,
\%default_output_units_conversion);
+ delete $self->{'sorted_special_unit_varieties'};
+ delete $self->{'simplified_special_unit_info'};
}
return $self;
diff --git a/tp/Texinfo/XS/main/get_perl_info.c
b/tp/Texinfo/XS/main/get_perl_info.c
index ed0278c147..5414aff17d 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -475,7 +475,8 @@ register_formatting_reference_with_default (char
*type_string,
}
int
-html_converter_initialize_sv (SV *sv_in, SV *default_formatting_references,
+html_converter_initialize_sv (SV *converter_sv,
+ SV *default_formatting_references,
SV *default_css_string_formatting_references,
SV *default_commands_open,
SV *default_commands_conversion,
@@ -497,7 +498,6 @@ html_converter_initialize_sv (SV *sv_in, SV
*default_formatting_references,
HV *default_css_string_types_conversion_hv;
HV *default_output_units_conversion_hv;
SV **converter_init_conf_sv;
- SV **converter_sv;
SV **formatting_function_sv;
SV **sorted_special_unit_varieties_sv;
SV **no_arg_commands_formatting_sv;
@@ -521,7 +521,7 @@ html_converter_initialize_sv (SV *sv_in, SV
*default_formatting_references,
dTHX;
- hv_in = (HV *)SvRV (sv_in);
+ hv_in = (HV *)SvRV (converter_sv);
default_formatting_references_hv
= (HV *)SvRV (default_formatting_references);
default_css_string_formatting_references_hv
@@ -529,7 +529,7 @@ html_converter_initialize_sv (SV *sv_in, SV
*default_formatting_references,
/* generic */
- document = get_sv_document_document (sv_in, 0);
+ document = get_sv_document_document (converter_sv, 0);
converter->document = document;
#define FETCH(key) key##_sv = hv_fetch (hv_in, #key, strlen(#key), 0);
@@ -1159,16 +1159,11 @@ html_converter_initialize_sv (SV *sv_in, SV
*default_formatting_references,
converter = retrieve_converter (converter_descriptor);
/* store converter_descriptor in perl converter */
- converter_sv = hv_fetch (hv_in, "converter",
- strlen ("converter"), 0);
- if (converter_sv && SvOK(*converter_sv))
- {
- HV *converter_hv = (HV *)SvRV(*converter_sv);
- hv_store (converter_hv, "converter_descriptor",
- strlen("converter_descriptor"),
- newSViv (converter_descriptor), 0);
- converter->hv = converter_hv;
- }
+ HV *converter_hv = (HV *)SvRV(converter_sv);
+ hv_store (converter_hv, "converter_descriptor",
+ strlen("converter_descriptor"),
+ newSViv (converter_descriptor), 0);
+ converter->hv = converter_hv;
return converter_descriptor;
}
diff --git a/tp/Texinfo/XS/main/get_perl_info.h
b/tp/Texinfo/XS/main/get_perl_info.h
index 8bdea1065b..170ca883e3 100644
--- a/tp/Texinfo/XS/main/get_perl_info.h
+++ b/tp/Texinfo/XS/main/get_perl_info.h
@@ -17,7 +17,8 @@ OPTIONS *copy_sv_options (SV *sv_in);
void set_conf (CONVERTER *converter, const char *conf, SV *value);
TEXT_OPTIONS *copy_sv_options_for_convert_text (SV *sv_in);
-int html_converter_initialize_sv (SV *sv_in, SV *default_formatting_references,
+int html_converter_initialize_sv (SV *converter_sv,
+ SV *default_formatting_references,
SV *default_css_string_formatting_references,
SV *default_commands_open,
SV *default_commands_conversion,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Convert/HTML.pm (converter_initialize): remove encode_converter_document from Texinfo::Convert::Converter and move corresponding code to the end of converter_initialize where XS converter is initialized.,
Patrice Dumas <=