Files
Giacomo Vercesi 0a2cb4df12 TTG: move namespace to the cpp generator
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.
2025-06-25 15:40:13 +02:00

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)