Skip to content

Commit

Permalink
odb codegen: adds support for C++ enum classes
Browse files Browse the repository at this point in the history
Signed-off-by: Felipe Garay <[email protected]>
  • Loading branch information
fgaray committed Dec 15, 2023
1 parent 41f53d4 commit c52e2b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/odb/include/odb/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -7634,7 +7634,7 @@ class dbScanChain : public dbObject
class dbScanInst : public dbObject
{
public:
enum SCAN_INST_TYPE
enum class SCAN_INST_TYPE
{
OneBit,
ShiftRegister,
Expand Down
1 change: 1 addition & 0 deletions src/odb/src/codeGenerator/schema/scan/dbScanInst.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
{
"name": "SCAN_INST_TYPE",
"public": true,
"class": true,
"values": [
"OneBit",
"ShiftRegister",
Expand Down
6 changes: 5 additions & 1 deletion src/odb/src/codeGenerator/templates/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ class {{klass.name}} : public dbObject
{% endfor %}
{% for _enum in klass.enums %}
{% if _enum.public %}
enum {{ _enum.name }}{% if "type" in _enum %} :{{ _enum.type }}{% endif %}
{% if _enum.class %}
enum class {{ _enum.name }}{% if "type" in _enum %} :{{ _enum.type }}{% endif %}
{% else %}
enum {{ _enum.name }}{% if "type" in _enum %} :{{ _enum.type }}{% endif %}
{% endif %}
{
{% for value in _enum["values"]%}
{% if not loop.first %},{%endif%}{{value}}
Expand Down

0 comments on commit c52e2b9

Please sign in to comment.