mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
0a2cb4df12
The `namespace` property is strictly used just by the cpp generator. Move the code so the `--namespace` option is exclusive to it and removed for all the other generators.
36 lines
855 B
Python
36 lines
855 B
Python
#
|
|
# This file is distributed under the MIT License. See LICENSE.md for details.
|
|
#
|
|
|
|
from typing import Dict
|
|
|
|
from .definition import Definition
|
|
|
|
|
|
class EnumMember:
|
|
def __init__(self, *, name, doc=None):
|
|
self.name = name
|
|
self.doc = doc
|
|
|
|
@staticmethod
|
|
def from_dict(source_dict: Dict):
|
|
return EnumMember(**source_dict)
|
|
|
|
|
|
class EnumDefinition(Definition):
|
|
def __init__(self, *, name, members, doc=None):
|
|
super().__init__(True, name)
|
|
self.doc = doc
|
|
self.autogenerated = False
|
|
|
|
self.members = members
|
|
|
|
@staticmethod
|
|
def from_dict(source_dict: Dict):
|
|
args = {
|
|
"name": source_dict["name"],
|
|
"doc": source_dict.get("doc"),
|
|
"members": [EnumMember.from_dict(d) for d in source_dict["members"]],
|
|
}
|
|
return EnumDefinition(**args)
|