In the C conversion code, there is a type CONVERTER which represents
the converter object.  It is often passed as the first parameter 'self' to
converter functions, as in tta/C/convert/convert_html.c, which mirrors
the analogous Perl code with the "$self" parameter.

In C, unlike in Perl, all fields of a data structure need to be declared.
The CONVERTER type (defined in tta/C/main/converter_types.h) has quite
a lot of fields, many of which are only relevant for the HTML output format.

I would like to find a way of separating the format specific code from the
converter object, now I am working on adding a new output format to the C
code (Info/plain text).

I'm hoping that you (Patrice), being more familiar with the code, would
have an idea what approaches would be feasible.  Here are ideas off the
top of my head:

* Could there be output-format-specific types like HTML_CONVERTER that
would contain a CONVERTER object (or pointer to the object), that would
only be used in the code for that output format?

* Alternatively, the CONVERTER object could contain a void pointer to
a structure for format-specific data.

* Slightly more complicated, the CONVERTER object could contain a void
pointer to a structure for format-specific data, which itself has a
pointer back to the CONVERTER object.  This would allow conversion back
and forth between the two types with minimal casting, (e.g. CONVERTER and
HTML_CONVERTER) with minimal casting, if that would be required.

* The CONVERTER object could have sub-objects for each output format
(this would be close to what we have already).  I'd prefer to avoid that
if possible.

Any comments or preferences?

Reply via email to