[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Mon, 8 Apr 2024 15:45:48 -0400 (EDT) |
branch: master
commit cd27ea6977202b2b52389bc39a16622e19649530
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Apr 8 16:43:29 2024 +0200
* tp/Texinfo/Common.pm (%XS_overrides), tp/Texinfo/Config.pm
(get_customization_options_hash), tp/Texinfo/Document.pm
(%XS_overrides, register_options, _XS_set_document_options): Replace
register_XS_document_main_configuration by Texinfo::Document
register_options. register_options in turn call
_XS_set_document_options for XS code. Add
get_customization_options_hash based on
register_XS_document_main_configuration, but without the call to
set_document_options, to get the options in one hash, call it from
Texinfo::Document register_options. Remove set_document_options from
Texinfo/Common.pm and remove register_XS_document_main_configuration.
Update callers.
* tp/Texinfo/Document.pm (register_options, options): setup the
'options' Perl document hash value to be the hash obtained from
get_customization_options_hash.
* tp/Texinfo/XS/main/DocumentXS.xs (set_document_options): change the
order of the arguments. Update callers.
---
ChangeLog | 22 ++++++++++++++++++++++
tp/Texinfo/Common.pm | 13 -------------
tp/Texinfo/Config.pm | 14 ++++++--------
tp/Texinfo/Document.pm | 30 ++++++++++++++++++++++++++++++
tp/Texinfo/XS/main/DocumentXS.xs | 2 +-
tp/t/test_utils.pl | 4 ++--
tp/texi2any.pl | 15 ++++++++-------
7 files changed, 69 insertions(+), 31 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 873b58f743..8f07a2fe6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2024-04-08 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Common.pm (%XS_overrides), tp/Texinfo/Config.pm
+ (get_customization_options_hash), tp/Texinfo/Document.pm
+ (%XS_overrides, register_options, _XS_set_document_options): Replace
+ register_XS_document_main_configuration by Texinfo::Document
+ register_options. register_options in turn call
+ _XS_set_document_options for XS code. Add
+ get_customization_options_hash based on
+ register_XS_document_main_configuration, but without the call to
+ set_document_options, to get the options in one hash, call it from
+ Texinfo::Document register_options. Remove set_document_options from
+ Texinfo/Common.pm and remove register_XS_document_main_configuration.
+ Update callers.
+
+ * tp/Texinfo/Document.pm (register_options, options): setup the
+ 'options' Perl document hash value to be the hash obtained from
+ get_customization_options_hash.
+
+ * tp/Texinfo/XS/main/DocumentXS.xs (set_document_options): change the
+ order of the arguments. Update callers.
+
2024-04-08 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Config.pm (GNUT_set_customization_default),
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index ac61374f3f..0c08259bca 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -84,8 +84,6 @@ $VERSION = '7.1dev';
my $XS_structuring = Texinfo::XSLoader::XS_structuring_enabled();
our %XS_overrides = (
- "Texinfo::Common::set_document_options"
- => "Texinfo::DocumentXS::set_document_options",
"Texinfo::Common::copy_tree"
=> "Texinfo::StructTransfXS::copy_tree",
"Texinfo::Common::relate_index_entries_to_table_items_in_tree"
@@ -2591,17 +2589,6 @@ sub get_label_element($)
return undef;
}
-# non-XS does nothing and should not be called in most cases as the
-# caller verifies that there is a document descriptor; XS version
-# registers options in XS document.
-# NOTE It would have been more logical for this function to be in
-# Texinfo::Config, but we do not want to load any XS in Texinfo::Config.
-sub set_document_options($$)
-{
- my $options = shift;
- my $document = shift;
-}
-
# functions used for debugging. May be used in other modules.
# Not documented.
diff --git a/tp/Texinfo/Config.pm b/tp/Texinfo/Config.pm
index 916463f092..6c03691b27 100644
--- a/tp/Texinfo/Config.pm
+++ b/tp/Texinfo/Config.pm
@@ -893,15 +893,13 @@ sub set_conf($$$)
return 1;
}
-# for structuring and tree transformations XS code uses options registered
-# with the document by that function. It is not needed in Perl where
-# get_conf above is used on a separate MainConfig object.
-sub register_XS_document_main_configuration($$)
+# get options in a simple hash. It is not possible to set
+# customization variables afterwards as the information on
+# precedence has been lost, so this should be called when all the
+# options have been definitively set.
+sub get_customization_options_hash($)
{
my $self = shift;
- my $document = shift;
-
- return if (!$document->document_descriptor());
my %options = %{$options_defaults};
foreach my $config ($self, $init_files_options, $cmdline_options) {
@@ -911,7 +909,7 @@ sub register_XS_document_main_configuration($$)
}
#print STDERR "MAIN: ".join('|', sort(keys(%options)))."\n";
- Texinfo::Common::set_document_options(\%options, $document);
+ return \%options;
}
1;
diff --git a/tp/Texinfo/Document.pm b/tp/Texinfo/Document.pm
index 85e67fbb56..d3c0e0b81e 100644
--- a/tp/Texinfo/Document.pm
+++ b/tp/Texinfo/Document.pm
@@ -51,6 +51,8 @@ our %XS_overrides = (
=> "Texinfo::DocumentXS::rebuild_tree",
"Texinfo::Document::tree"
=> "Texinfo::DocumentXS::document_tree",
+ "Texinfo::Document::_XS_set_document_options"
+ => "Texinfo::DocumentXS::set_document_options",
"Texinfo::Document::global_information"
=> "Texinfo::DocumentXS::document_global_information",
"Texinfo::Document::indices_information"
@@ -213,6 +215,34 @@ sub registrar($)
return $self->{'registrar'};
}
+sub _XS_set_document_options($$)
+{
+ my $self;
+ my $document_options;
+}
+
+# $OPTIONS should be a Texinfo::MainConfig object.
+# For options used in structuring.
+sub register_options($$)
+{
+ my $self = shift;
+ my $options = shift;
+
+ my $document_options = $options->get_customization_options_hash();
+
+ if ($self->document_descriptor()) {
+ _XS_set_document_options($self, $document_options);
+ return;
+ }
+ $self->{'options'} = $document_options;
+}
+
+sub options($)
+{
+ my $self = shift;
+ return $self->{'options'};
+}
+
sub merged_indices($)
{
my $self = shift;
diff --git a/tp/Texinfo/XS/main/DocumentXS.xs b/tp/Texinfo/XS/main/DocumentXS.xs
index 7dfc1c114b..04e0a1d37c 100644
--- a/tp/Texinfo/XS/main/DocumentXS.xs
+++ b/tp/Texinfo/XS/main/DocumentXS.xs
@@ -133,7 +133,7 @@ document_errors (SV *document_in)
void
-set_document_options (SV *sv_options_in, SV *document_in)
+set_document_options (SV *document_in, SV *sv_options_in)
PREINIT:
DOCUMENT *document = 0;
CODE:
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 6a53abc120..0a58846fb3 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -1077,8 +1077,8 @@ sub test($$)
}
# Now that all the configuration has been set, associate it with the
- # document XS
- $main_configuration->register_XS_document_main_configuration($document);
+ # document
+ $document->register_options($main_configuration);
if ($tree_transformations{'fill_gaps_in_sectioning'}) {
Texinfo::Transformations::fill_gaps_in_sectioning($tree);
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index ce37e67b57..622eac55db 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1525,13 +1525,14 @@ while(@input_files) {
# a "handle" is returned.
my $tree = $document->tree($XS_structuring);
- # setup a configuration Perl object which defines get_conf and gives the
- # same as get_conf() in the main program. It is used by
+ # setup a configuration Perl object which defines get_conf, use
+ # the main program customization information for which per-document
+ # customization can be set. It is used by
# Structuring/Transformations methods needing access to configuration
# information.
- # OUTPUT_ENCODING_NAME is accessed in set_output_encodings.
- # OUTPUT_PERL_ENCODING is accessed in set_output_encodings and
- # in output_files_open_out for the MACRO_EXPAND file name.
+ # OUTPUT_ENCODING_NAME is set and accessed in set_output_encodings.
+ # OUTPUT_PERL_ENCODING is set and accessed in set_output_encodings and
+ # accessed in output_files_open_out for the MACRO_EXPAND file name.
# The following variables are directly used in Structuring/Transformations:
# novalidate, FORMAT_MENU, CHECK_NORMAL_MENU_STRUCTURE,
# CHECK_MISSING_MENU_ENTRY. And DEBUG.
@@ -1553,8 +1554,8 @@ while(@input_files) {
}
# Now that all the configuration has been set, associate it to the
- # document XS
- $main_configuration->register_XS_document_main_configuration($document);
+ # document
+ $document->register_options($main_configuration);
if (defined(get_conf('MACRO_EXPAND')) and $file_number == 0) {
require Texinfo::Convert::Texinfo;
- master updated (e0c04573b4 -> d8a0a8ad73), Patrice Dumas, 2024/04/08
- [no subject], Patrice Dumas, 2024/04/08
- [no subject], Patrice Dumas, 2024/04/08
- [no subject], Patrice Dumas, 2024/04/08
- [no subject],
Patrice Dumas <=
- [no subject], Patrice Dumas, 2024/04/08
- [no subject], Patrice Dumas, 2024/04/08
- [no subject], Patrice Dumas, 2024/04/08
- [no subject], Patrice Dumas, 2024/04/08