use zerodds_ast_core::NodeKindTag;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum NodeKind {
Module,
Type,
Member,
Case,
Enumerator,
BitValue,
Bitfield,
Const,
ConstExpr,
Interface,
Operation,
Param,
Attribute,
Exception,
AnnotationDef,
AnnotationMember,
Domain,
Topic,
QosProfile,
Participant,
Endpoint,
Library,
}
impl NodeKind {
pub const ALL: [Self; 22] = [
Self::Module,
Self::Type,
Self::Member,
Self::Case,
Self::Enumerator,
Self::BitValue,
Self::Bitfield,
Self::Const,
Self::ConstExpr,
Self::Interface,
Self::Operation,
Self::Param,
Self::Attribute,
Self::Exception,
Self::AnnotationDef,
Self::AnnotationMember,
Self::Domain,
Self::Topic,
Self::QosProfile,
Self::Participant,
Self::Endpoint,
Self::Library,
];
#[must_use]
pub const fn tag(self) -> NodeKindTag {
NodeKindTag(match self {
Self::Module => 1,
Self::Type => 2,
Self::Member => 3,
Self::Case => 4,
Self::Enumerator => 5,
Self::BitValue => 6,
Self::Bitfield => 7,
Self::Const => 8,
Self::ConstExpr => 9,
Self::Interface => 10,
Self::Operation => 11,
Self::Param => 12,
Self::Attribute => 13,
Self::Exception => 14,
Self::AnnotationDef => 15,
Self::AnnotationMember => 16,
Self::Domain => 17,
Self::Topic => 18,
Self::QosProfile => 19,
Self::Participant => 20,
Self::Endpoint => 21,
Self::Library => 22,
})
}
#[must_use]
pub const fn from_tag(tag: NodeKindTag) -> Option<Self> {
Some(match tag.0 {
1 => Self::Module,
2 => Self::Type,
3 => Self::Member,
4 => Self::Case,
5 => Self::Enumerator,
6 => Self::BitValue,
7 => Self::Bitfield,
8 => Self::Const,
9 => Self::ConstExpr,
10 => Self::Interface,
11 => Self::Operation,
12 => Self::Param,
13 => Self::Attribute,
14 => Self::Exception,
15 => Self::AnnotationDef,
16 => Self::AnnotationMember,
17 => Self::Domain,
18 => Self::Topic,
19 => Self::QosProfile,
20 => Self::Participant,
21 => Self::Endpoint,
22 => Self::Library,
_ => return None,
})
}
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Module => "module",
Self::Type => "type",
Self::Member => "member",
Self::Case => "case",
Self::Enumerator => "enumerator",
Self::BitValue => "bit value",
Self::Bitfield => "bitfield",
Self::Const => "constant",
Self::ConstExpr => "constant expression",
Self::Interface => "interface",
Self::Operation => "operation",
Self::Param => "parameter",
Self::Attribute => "attribute",
Self::Exception => "exception",
Self::AnnotationDef => "annotation",
Self::AnnotationMember => "annotation member",
Self::Domain => "domain",
Self::Topic => "topic",
Self::QosProfile => "QoS profile",
Self::Participant => "participant",
Self::Endpoint => "endpoint",
Self::Library => "library",
}
}
}