From e97f7c91280c69226e06cda72729779054386d47 Mon Sep 17 00:00:00 2001 From: Dustin Spicuzza Date: Sat, 8 Jan 2022 03:25:25 -0500 Subject: [PATCH 1/2] Update black format --- CppHeaderParser/CppHeaderParser.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/CppHeaderParser/CppHeaderParser.py b/CppHeaderParser/CppHeaderParser.py index f142278..159cdb3 100644 --- a/CppHeaderParser/CppHeaderParser.py +++ b/CppHeaderParser/CppHeaderParser.py @@ -111,7 +111,6 @@ def debug_print(fmt, *args): args = (inspect.currentframe().f_back.f_lineno,) + args print(fmt % args) - else: debug_caller_lineno = None @@ -128,7 +127,6 @@ def trace_print(*args): sys.stdout.write(" %s" % a) sys.stdout.write("\n") - else: def trace_print(*args): From 0cb3e932961afd1cc1148d2a49c3231d344a0701 Mon Sep 17 00:00:00 2001 From: Dustin Spicuzza Date: Sat, 8 Jan 2022 03:25:48 -0500 Subject: [PATCH 2/2] Detect constexpr functions --- CppHeaderParser/CppHeaderParser.py | 2 +- test/test_CppHeaderParser.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CppHeaderParser/CppHeaderParser.py b/CppHeaderParser/CppHeaderParser.py index 159cdb3..0d6b76c 100644 --- a/CppHeaderParser/CppHeaderParser.py +++ b/CppHeaderParser/CppHeaderParser.py @@ -1468,7 +1468,7 @@ class Resolver(object): C_MODIFIERS = "* & const constexpr static mutable".split() C_MODIFIERS = set(C_MODIFIERS) - C_KEYWORDS = "extern virtual static explicit inline friend".split() + C_KEYWORDS = "extern virtual static explicit inline friend constexpr".split() C_KEYWORDS = set(C_KEYWORDS) SubTypedefs = {} # TODO deprecate? diff --git a/test/test_CppHeaderParser.py b/test/test_CppHeaderParser.py index c454a32..374658c 100644 --- a/test/test_CppHeaderParser.py +++ b/test/test_CppHeaderParser.py @@ -2999,6 +2999,21 @@ def test_fn(self): self.assertEqual(p["defaultValue"], "0.02") +class ConstExprFn_TestCase(unittest.TestCase): + def setUp(self): + self.cppHeader = CppHeaderParser.CppHeader( + """ +constexpr int overloaded_constexpr(int a, int b, int c) { return a + b + c; } +""", + "string", + ) + + def test_fn(self): + m = self.cppHeader.functions[0] + self.assertEqual(m["constexpr"], True) + self.assertEqual(m["rtnType"], "int") + + class DefaultEnum_TestCase(unittest.TestCase): def setUp(self): self.cppHeader = CppHeaderParser.CppHeader(