From 05ceabed32d6e0a67578b3679fbc69381a0fdffc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 1 Dec 2022 15:40:58 +0200 Subject: Move inline file inclusion after header file epilogue This makes a difference if the epilogue defines something (e.g., a custom type) that must be defined (rather than just declared) in the inline file. --- xsd/xsd/cxx/tree/generator.cxx | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'xsd/xsd/cxx/tree') diff --git a/xsd/xsd/cxx/tree/generator.cxx b/xsd/xsd/cxx/tree/generator.cxx index 5601f4e..3233248 100644 --- a/xsd/xsd/cxx/tree/generator.cxx +++ b/xsd/xsd/cxx/tree/generator.cxx @@ -928,19 +928,16 @@ namespace CXX } } - if (inline_) - { - hxx << "#ifndef XSD_DONT_INCLUDE_INLINE" << endl - << "#include " << ctx.process_include_path (ixx_name) << endl - << "#endif // XSD_DONT_INCLUDE_INLINE" << endl - << endl; - } - hxx << "#include " << endl << endl; // Copy epilogue. // + // Note that it goes before the inline file in case it defines + // something (such as a custom type) which is needed by this file. + // And if something in the epilogue needs something from the inline + // file, then it should be the inline rather than header epilogue. + // hxx << "// Begin epilogue." << endl << "//" << endl; @@ -951,6 +948,14 @@ namespace CXX << "// End epilogue." << endl << endl; + if (inline_) + { + hxx << "#ifndef XSD_DONT_INCLUDE_INLINE" << endl + << "#include " << ctx.process_include_path (ixx_name) << endl + << "#endif // XSD_DONT_INCLUDE_INLINE" << endl + << endl; + } + hxx << "#endif // " << guard << endl; if (show_sloc) @@ -999,6 +1004,9 @@ namespace CXX << "// End prologue." << endl << endl; + ixx << "#include " << endl + << endl; + // Generate. // { @@ -1006,6 +1014,9 @@ namespace CXX generate_tree_inline (ctx, 1, 0); } + ixx << "#include " << endl + << endl; + // Copy epilogue. // ixx << "// Begin epilogue." << endl -- cgit v1.1