gbranden pushed a commit to branch master in repository groff. commit c0811ebb9a92d675a9ca91d3dea5d7a9e2e62e8d Author: G. Branden Robinson <g.branden.robin...@gmail.com> AuthorDate: Tue Mar 4 01:38:27 2025 -0600
[troff]: Implement recursive node dumping (8c/9). Derive class `zero_width_node` from struct `container_node`. * src/roff/troff/node.h (class zero_width_node): Do it. Drop pointer-to-node member variable and declaration of destructor. * src/roff/troff/node.cpp (zero_width_node::~zero_width_node): Drop; our base class handles destruction of contained node(s). (zero_width_node::zero_width_node): Migrate constructors to use new base class. Changes `pline` request output as follows. -{"type": "zero_width_node", "diversion level": 0, "is_special_node": false}, +{"type": "zero_width_node", "diversion level": 0, "is_special_node": false, "contents": [{"type": "dummy_node", "diversion level": 0, "is_special_node": false}, {"type": "glyph_node", "diversion level": 0, "is_special_node": false, "character": "a"}, {"type": "glyph_node", "diversion level": 0, "is_special_node": false, "character": "b"}, {"type": "glyph_node", "diversion level": 0, "is_special_node": false, "character": "c"}, {"type": "hmotion_node", "diversion level": 0, "is_specia [...] --- ChangeLog | 12 ++++++++++++ src/roff/troff/node.cpp | 9 ++------- src/roff/troff/node.h | 5 +---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 19178b721..7094d2080 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2025-03-04 G. Branden Robinson <g.branden.robin...@gmail.com> + + [troff]: Derive class `zero_width_node` from struct + `container_node`. + + * src/roff/troff/node.h (class zero_width_node): Do it. Drop + pointer-to-node member variable and declaration of destructor. + * src/roff/troff/node.cpp (zero_width_node::~zero_width_node): + Drop; our base class handles destruction of contained node(s). + (zero_width_node::zero_width_node): Migrate constructors to use + new base class. + 2025-03-03 G. Branden Robinson <g.branden.robin...@gmail.com> [troff]: Derive class `vline_node` from struct `container_node`. diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp index 2080d5066..58c89e97d 100644 --- a/src/roff/troff/node.cpp +++ b/src/roff/troff/node.cpp @@ -3264,20 +3264,15 @@ hunits vline_node::width() } zero_width_node::zero_width_node(node *nd, statem *s, int divlevel) -: node(0 /* nullptr */, s, divlevel), nodes(nd) +: container_node(0 /* nullptr */, s, divlevel, nd) { } zero_width_node::zero_width_node(node *nd) -: nodes(nd) +: container_node(nd) { } -zero_width_node::~zero_width_node() -{ - delete_node_list(nodes); -} - node *zero_width_node::copy() { return new zero_width_node(copy_node_list(nodes), state, diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h index 2bfc3b01e..ec7c7e9bc 100644 --- a/src/roff/troff/node.h +++ b/src/roff/troff/node.h @@ -486,13 +486,10 @@ public: hyphenation_type get_hyphenation_type(); }; -// TODO: Derive from abstract class `container_node`. -class zero_width_node : public node { - node *nodes; +class zero_width_node : public container_node { public: zero_width_node(node *); zero_width_node(node *, statem *, int); - ~zero_width_node(); node *copy(); void tprint(troff_output_file *); void ascii_print(ascii_output_file *); _______________________________________________ groff-commit mailing list groff-commit@gnu.org https://lists.gnu.org/mailman/listinfo/groff-commit