On Tue, Jun 23, 2026 at 11:51:20PM +0200, Patrice Dumas wrote:
> > 'txi_converter_setup' calls 'converter_converter', defined in
> > C/convert/converter.c.  This then refers to a data array 
> > 'converter_format_data',
> > defined in the same file:
> > 
> >     /* table used to dispatch format specific functions.
> >        Same purpose as inherited methods in Texinfo::Convert::Converter */
> >     /* Should be kept in sync with enum converter_format
> >        and TXI_CONVERSION_FORMAT_NR */
> >     CONVERTER_FORMAT_DATA converter_format_data[] = {
> >       {"html", "Texinfo::Convert::HTML", &html_format_setup, 0,
> >        &html_converter_defaults,
> >        &html_converter_initialize, &html_output, &html_convert,
> >        &html_convert_tree, 0, &html_free_converter, &html_element_cdt_tree},
> >       {"rawtext", "Texinfo::Convert::Text", 0, &rawtext_converter,
> >        0, 0, &rawtext_output,
> >        &rawtext_convert, &rawtext_convert_tree, 0, 0, 0},
> >       {"plaintexinfo", "Texinfo::Convert::PlainTexinfo", 0, 0,
> >        &plaintexinfo_converter_defaults, 0, &plaintexinfo_output,
> >        &plaintexinfo_convert, &plaintexinfo_convert_tree, 0, 0, 0},
> >     };
> > 
> > This appears to have a similar purpose to the array in texi2any.c:
> 
> It is supposed to be a different purpose.  The converter_format_data is
> almost only used to dispatch the different steps of conversion to per
> output format functions.  It is about conversion code.  There is
> information for converters that are fully implemented in C only.

This data structure appears to have an association between output format
and Perl module name.  I found the purpose of the Perl module name very
unclear.

It is used by 'find_perl_converter_class_converter_format' in
C/convert/converter.c.  This in turn is used by 'get_or_create_sv_converter'
in C/convert/get_converter_perl_info.c and 'converter_defaults' in
perl/XSTexinfo/convert/ConvertHTMLXS.xs.  'get_or_create_sv_converter' itself
is only called from perl/XSTexinfo/convert/ConvertHTMLXS.xs and
perl/XSTexinfo/convert/ConvertHTMLXS.xs and
perl/XSTexinfo/convert/ConvertConverterXS.xs.

So following which function calls which (which I do by running grep on
all the files in the source code), it appears this Perl module name is here
for the benefit of these two XS modules.

I can't easily tell whether these are for embedding C in Perl, or embedding
Perl in C (or possibly both).  Hopefully it is for the former only,
because in that case there is a hope that we will be able to delete this
code in the future.  As both are possibilities at present for texi2any,
it's hard to tell which one is relevant for particular parts of the source
code (unless it's stated in source code comments).

When you see a Perl module name in a data structure like the one above,
you assume it would be for loading the (Perl) module, but instead it
seems to be used, as far as I can tell (with the time I've spent trying
to make sense of it), it's used when a converter module object on the
Perl side of the code is implemented with C code, and is used to lookup
which (C) code to use.

Reply via email to