From 24f75aa481aa98aa0ed52e71493c9ca4e63122ea Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 3 Dec 2022 01:10:28 +0000 Subject: [PATCH] Fix parsing of unconventional Doxygen post comments for enum items. Closes #1715 --- CHANGES.current | 4 ++ Examples/test-suite/doxygen_misc_constructs.i | 25 +++++++++++- .../java/doxygen_misc_constructs_runme.java | 38 ++++++++++++++++++- Source/CParse/parser.y | 11 ++++++ 4 files changed, 76 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index c251bb66d..5fc73eb15 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.2.0 (in progress) =========================== +2022-12-03: wsfulton + #1715 Fix syntax error parsing of unconventionally placed Doxygen post + comments for enum items. + 2022-12-02: wsfulton #624 #1021 Improved template template parameters support. Previously, specifying more than one simple template template parameter resulted in a parse error. Now diff --git a/Examples/test-suite/doxygen_misc_constructs.i b/Examples/test-suite/doxygen_misc_constructs.i index 9cf95de39..e77edc7fb 100644 --- a/Examples/test-suite/doxygen_misc_constructs.i +++ b/Examples/test-suite/doxygen_misc_constructs.i @@ -95,13 +95,36 @@ class ClassWithNestedEnum { public: /** - * Enum description. + * ENested description. */ typedef enum {ONE, ///< desc of one TWO, ///< desc of two THREE ///< desc of three } ENested; + /** + * ENestedOdd description. + */ + typedef enum {ODD_ONE ///< desc of odd_one + ,ODD_TWO ///< desc of odd_two + ,ODD_THREE ///< desc of odd_three + } ENestedOdd; + + /** + * ENestedOddPartial1 description. + */ + typedef enum {ODD_PARTIAL1_ONE + ,ODD_PARTIAL1_TWO ///< desc of odd_partial1_two + ,ODD_PARTIAL1_THREE ///< desc of odd_partial1_three + } ENestedOddPartial1; + + /** + * ENestedOddPartial3 description. + */ + typedef enum {ODD_PARTIAL3_ONE ///< desc of odd_partial3_one + ,ODD_PARTIAL3_TWO ///< desc of odd_partial3_two + ,ODD_PARTIAL3_THREE + } ENestedOddPartial3; }; /// @return This is a bad place for this tag, but it should be ignored. diff --git a/Examples/test-suite/java/doxygen_misc_constructs_runme.java b/Examples/test-suite/java/doxygen_misc_constructs_runme.java index cae2b2192..9d629579f 100644 --- a/Examples/test-suite/java/doxygen_misc_constructs_runme.java +++ b/Examples/test-suite/java/doxygen_misc_constructs_runme.java @@ -97,7 +97,7 @@ public class doxygen_misc_constructs_runme { "\n"); wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENested", - " Enum description.\n" + + " ENested description.\n" + "\n"); wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENested.ONE", @@ -109,6 +109,42 @@ public class doxygen_misc_constructs_runme { wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENested.THREE", " desc of three\n"); + wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENestedOdd", + " ENestedOdd description.\n" + + "\n"); + + wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENestedOdd.ODD_ONE", + " desc of odd_one\n"); + + wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENestedOdd.ODD_TWO", + " desc of odd_two\n"); + + wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENestedOdd.ODD_THREE", + " desc of odd_three\n"); + + wantedComments.put("doxygen_misc_constructs.StructWithReturnComment", + " @return This is a bad place for this tag, but it should be ignored."); + + wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENestedOddPartial1", + " ENestedOddPartial1 description.\n" + + "\n"); + + wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENestedOddPartial1.ODD_PARTIAL1_THREE", + " desc of odd_partial1_three\n"); + + wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENestedOddPartial1.ODD_PARTIAL1_TWO", + " desc of odd_partial1_two\n"); + + wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENestedOddPartial3", + " ENestedOddPartial3 description.\n" + + "\n"); + + wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENestedOddPartial3.ODD_PARTIAL3_ONE", + " desc of odd_partial3_one\n"); + + wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENestedOddPartial3.ODD_PARTIAL3_TWO", + " desc of odd_partial3_two\n"); + wantedComments.put("doxygen_misc_constructs.StructWithReturnComment", " @return This is a bad place for this tag, but it should be ignored."); diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index b3216bbc7..178c8893d 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -6489,6 +6489,17 @@ enumlist : enumlist_item { } $$ = $1; } + | enumlist_item DOXYGENPOSTSTRING COMMA enumlist { + if ($4) { + set_nextSibling($1, $4); + Setattr($1,"_last",Getattr($4,"_last")); + Setattr($4,"_last",NULL); + } else { + Setattr($1,"_last",$1); + } + set_comment($1, $2); + $$ = $1; + } | enumlist_item COMMA DOXYGENPOSTSTRING enumlist { if ($4) { set_nextSibling($1, $4);