Skip to content

Commit

Permalink
Merge pull request #17 from finger563/fix/16-constexpr-readonly
Browse files Browse the repository at this point in the history
Declaration `is_const()` returns true if declared with specifier `constexpr`
  • Loading branch information
pthom authored Aug 25, 2024
2 parents 226992d + c7c62fb commit f2c0b43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/srcmlcpp/cpp_types/decls_types/cpp_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def name_without_modifier_specifier(self) -> str:
return name

def is_const(self) -> bool:
return "const" in self.specifiers
return "const" in self.specifiers or "constexpr" in self.specifiers

def is_static(self) -> bool:
return "static" in self.specifiers
Expand Down
5 changes: 5 additions & 0 deletions src/srcmlcpp/tests/cpp_types/decls_types_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ def test_cpp_type():
assert cpp_type.typenames == ["unsigned", "int"]
assert cpp_type.modifiers == ["*", "*"]

cpp_type = srcmlcpp.srcmlcpp_main.code_to_cpp_type(options, "static constexpr unsigned int")
assert cpp_type.is_const()
assert cpp_type.is_static()
assert cpp_type.typenames == ["unsigned", "int"]

options.functions_api_prefixes = "MY_API"
cpp_type = srcmlcpp.srcmlcpp_main.code_to_cpp_type(options, "MY_API int &&")
assert "MY_API" in cpp_type.specifiers
Expand Down

0 comments on commit f2c0b43

Please sign in to comment.