Thanks to visit codestin.com
Credit goes to github.com

Skip to content

support constexpr functions #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions CppHeaderParser/CppHeaderParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -128,7 +127,6 @@ def trace_print(*args):
sys.stdout.write(" %s" % a)
sys.stdout.write("\n")


else:

def trace_print(*args):
Expand Down Expand Up @@ -1470,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?
Expand Down
15 changes: 15 additions & 0 deletions test/test_CppHeaderParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down