From e52a358e8538151423a52b71ed5cca1f0fe1b15b Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Thu, 25 Apr 2024 17:52:32 +0200 Subject: FLUID: Improve usability of Declaration Blocks Decl Blocks can now output code around static code in source and header files. --- fluid/code.cxx | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'fluid/code.cxx') diff --git a/fluid/code.cxx b/fluid/code.cxx index b49951c2e..873b9d789 100644 --- a/fluid/code.cxx +++ b/fluid/code.cxx @@ -682,7 +682,29 @@ bool is_comment_before_class_member(Fl_Type *q) { } /** - Recursively dump code, putting children between the two parts of the parent code. + Recursively write static code and declarations + \param[in] p write this type and all its children + \return pointer to the next sibling + */ +Fl_Type* Fd_Code_Writer::write_static(Fl_Type* p) { + if (write_codeview) p->header_static_start = (int)ftell(header_file); + if (write_codeview) p->code_static_start = (int)ftell(code_file); + p->write_static(*this); + if (write_codeview) p->code_static_end = (int)ftell(code_file); + if (write_codeview) p->header_static_end = (int)ftell(header_file); + + Fl_Type* q; + for (q = p->next; q && q->level > p->level;) { + q = write_static(q); + } + + p->write_static_after(*this); + + return q; +} + +/** + Recursively write code, putting children between the two parts of the parent code. \param[in] p write this type and all its children \return pointer to the next sibling */ @@ -879,18 +901,7 @@ int Fd_Code_Writer::write_code(const char *s, const char *t, bool to_codeview) { } for (Fl_Type* p = first_type; p;) { // write all static data for this & all children first - if (write_codeview) p->header_static_start = (int)ftell(header_file); - if (write_codeview) p->code_static_start = (int)ftell(code_file); - p->write_static(*this); - if (write_codeview) p->code_static_end = (int)ftell(code_file); - if (write_codeview) p->header_static_end = (int)ftell(header_file); - for (Fl_Type* q = p->next; q && q->level > p->level; q = q->next) { - if (write_codeview) q->header_static_start = (int)ftell(header_file); - if (write_codeview) q->code_static_start = (int)ftell(code_file); - q->write_static(*this); - if (write_codeview) q->code_static_end = (int)ftell(code_file); - if (write_codeview) q->header_static_end = (int)ftell(header_file); - } + write_static(p); // then write the nested code: p = write_code(p); } -- cgit v1.2.3