Skip to content

Commit 8c54f68

Browse files
authored
Merge pull request #74 from robotpy/constexpr-fn
support constexpr functions
2 parents d94f100 + 0cb3e93 commit 8c54f68

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

CppHeaderParser/CppHeaderParser.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ def debug_print(fmt, *args):
111111
args = (inspect.currentframe().f_back.f_lineno,) + args
112112
print(fmt % args)
113113

114-
115114
else:
116115

117116
debug_caller_lineno = None
@@ -128,7 +127,6 @@ def trace_print(*args):
128127
sys.stdout.write(" %s" % a)
129128
sys.stdout.write("\n")
130129

131-
132130
else:
133131

134132
def trace_print(*args):
@@ -1470,7 +1468,7 @@ class Resolver(object):
14701468
C_MODIFIERS = "* & const constexpr static mutable".split()
14711469
C_MODIFIERS = set(C_MODIFIERS)
14721470

1473-
C_KEYWORDS = "extern virtual static explicit inline friend".split()
1471+
C_KEYWORDS = "extern virtual static explicit inline friend constexpr".split()
14741472
C_KEYWORDS = set(C_KEYWORDS)
14751473

14761474
SubTypedefs = {} # TODO deprecate?

test/test_CppHeaderParser.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2999,6 +2999,21 @@ def test_fn(self):
29992999
self.assertEqual(p["defaultValue"], "0.02")
30003000

30013001

3002+
class ConstExprFn_TestCase(unittest.TestCase):
3003+
def setUp(self):
3004+
self.cppHeader = CppHeaderParser.CppHeader(
3005+
"""
3006+
constexpr int overloaded_constexpr(int a, int b, int c) { return a + b + c; }
3007+
""",
3008+
"string",
3009+
)
3010+
3011+
def test_fn(self):
3012+
m = self.cppHeader.functions[0]
3013+
self.assertEqual(m["constexpr"], True)
3014+
self.assertEqual(m["rtnType"], "int")
3015+
3016+
30023017
class DefaultEnum_TestCase(unittest.TestCase):
30033018
def setUp(self):
30043019
self.cppHeader = CppHeaderParser.CppHeader(

0 commit comments

Comments
 (0)