[PATCH] Support for C++ comments next to arguments of macro function
Christian Schoenebeck via Doxygen-develop <[email protected]> Sun, 10 Dec 2017 19:10:00 +0100
| Newsgroups | gmane.text.doxygen.devel |
|---|---|
| Message-ID | <4866055.sHPCys7jAo@silver> |
This is a multi-part message in MIME format.
--nextPart72045588.eCTEVr3hjv
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"
Hi,
please consider the attached patch for git, which allows code input like this
to be processed correctly:
#ifndef DECLARE_ENUM
# define DECLARE_ENUM(type, ...) enum type { __VA_ARGS__ }
#endif
DECLARE_ENUM(Foo_t,
foo1 = 0x000000001, ///< First comment.
foo2 = 22, ///< Second comment.
foo3
);
The current general behavior of dropping all new line characters on macro
expansion is preserved. Accordingly those C++ comments are automatically
rewritten as inline C comments instead.
Best regards,
Christian Schoenebeck
--nextPart72045588.eCTEVr3hjv
Content-Disposition: attachment; filename="doxygen_cpp_macro_arg_comment.patch"
Content-Transfer-Encoding: 7Bit
Content-Type: text/x-patch; charset="UTF-8"; name="doxygen_cpp_macro_arg_comment.patch"
From 38a43b4d237fa60395c7814aeffef9d26497d5bd Mon Sep 17 00:00:00 2001
From: Christian Schoenebeck <[email protected]>
Date: Sun, 10 Dec 2017 18:24:47 +0100
Subject: [PATCH] Support for C++ comments next to arguments of macro function
calls.
This allows code input like this to be processed correctly:
#ifndef DECLARE_ENUM
# define DECLARE_ENUM(type, ...) enum type { __VA_ARGS__ }
#endif
DECLARE_ENUM(Foo_t,
foo1 = 0x000000001, ///< First comment.
foo2 = 22, ///< Second comment.
foo3
);
The current general behavior of dropping all new line characters
on macro expansion is preserved. Accordingly those C++ comments
are automatically rewritten as inline C comments instead.
---
src/pre.l | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/pre.l b/src/pre.l
index bf1ec9b6..fd745579 100644
--- a/src/pre.l
+++ b/src/pre.l
@@ -1980,6 +1980,15 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
g_defArgsStr+=yytext;
BEGIN(ArgCopyCComment);
}
+<FindDefineArgs>"//"[^\n\r]* { // C++ comment next to individual preprocessor macro argument ...
+ QCString comment(yytext);
+ // rewrite C++ comment as C comment (so we can drop \n)
+ comment.rawData()[1]='*';
+ if (comment.size() > 2 && comment[2]=='/')
+ comment.rawData()[2]='*';
+ comment+=" */";
+ g_defArgsStr+=comment;
+ }
<FindDefineArgs>\" {
g_defArgsStr+=*yytext;
BEGIN(ReadString);
--
2.11.0
--nextPart72045588.eCTEVr3hjv
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--nextPart72045588.eCTEVr3hjv
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Doxygen-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/doxygen-develop
--nextPart72045588.eCTEVr3hjv--