use zerodds_lang_cst::Language;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum ConstructKind {
Module,
Primitive,
Fixed,
StringType,
Sequence,
Array,
Map,
Structure,
Union,
Enumeration,
Bitmask,
Bitset,
Alias,
Valuetype,
ValueBox,
Native,
Any,
ValueBase,
ObjectRef,
AnnotationType,
Const,
Interface,
Exception,
}
impl ConstructKind {
pub const ALL: [Self; 23] = [
Self::Module,
Self::Primitive,
Self::Fixed,
Self::StringType,
Self::Sequence,
Self::Array,
Self::Map,
Self::Structure,
Self::Union,
Self::Enumeration,
Self::Bitmask,
Self::Bitset,
Self::Alias,
Self::Valuetype,
Self::ValueBox,
Self::Native,
Self::Any,
Self::ValueBase,
Self::ObjectRef,
Self::AnnotationType,
Self::Const,
Self::Interface,
Self::Exception,
];
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Module => "module",
Self::Primitive => "primitive",
Self::Fixed => "fixed",
Self::StringType => "string",
Self::Sequence => "sequence",
Self::Array => "array",
Self::Map => "map",
Self::Structure => "struct",
Self::Union => "union",
Self::Enumeration => "enum",
Self::Bitmask => "bitmask",
Self::Bitset => "bitset",
Self::Alias => "typedef",
Self::Valuetype => "valuetype",
Self::ValueBox => "valuebox",
Self::Native => "native",
Self::Any => "any",
Self::ValueBase => "valuebase",
Self::ObjectRef => "object reference",
Self::AnnotationType => "annotation type",
Self::Const => "const",
Self::Interface => "interface",
Self::Exception => "exception",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Coverage {
Rule(&'static str),
Uncovered(&'static str),
}
impl Coverage {
#[must_use]
pub const fn is_covered(self) -> bool {
matches!(self, Self::Rule(_))
}
#[must_use]
pub const fn reason(self) -> &'static str {
match self {
Self::Rule(name) | Self::Uncovered(name) => name,
}
}
}
#[must_use]
#[allow(clippy::too_many_lines)]
pub const fn coverage_of(construct: ConstructKind, language: Language) -> Coverage {
use ConstructKind as C;
use Language as L;
match (construct, language) {
(C::Structure, L::Rust) => Coverage::Rule("struct-to-struct"),
(C::Enumeration, L::Rust) => Coverage::Rule("enum-to-enum"),
(C::Alias, L::Rust) => Coverage::Rule("alias-to-type-alias"),
(C::Union, L::Rust) => Coverage::Rule("union-to-enum"),
(C::Bitmask, L::Rust) => Coverage::Rule("bitmask-to-struct"),
(C::Bitset, L::Rust) => Coverage::Rule("bitset-to-struct"),
(C::Valuetype, L::Rust) => Coverage::Rule("valuetype-to-struct"),
(C::Module, L::Rust) => Coverage::Rule("module-to-mod"),
(C::Const, L::Rust) => Coverage::Rule("const-to-const"),
(C::Exception, L::Rust) => Coverage::Rule("exception-to-struct"),
(C::Interface, L::Rust) => Coverage::Rule("interface-to-trait"),
(C::Native, L::Rust) => Coverage::Rule("native-to-alias"),
(C::Primitive | C::Sequence | C::Array | C::StringType | C::Map | C::Fixed, L::Rust) => {
Coverage::Rule("member-to-field")
}
(C::ValueBox, L::Rust) => Coverage::Rule("member-to-field"),
(C::ObjectRef, L::Rust) => Coverage::Uncovered("object references belong to the RPC arc"),
(C::Any, L::Rust) => {
Coverage::Uncovered("`any` carries its type at run time; the CORBA arc owns it")
}
(C::ValueBase, L::Rust) => Coverage::Uncovered(
"which valuetype arrives is a run-time question; the CORBA arc owns it",
),
(C::AnnotationType, L::Rust) => {
Coverage::Uncovered("no Rust equivalent; nothing is emitted")
}
(C::Module, L::C) => Coverage::Rule("module-to-prefix"),
(C::Structure, L::C) => Coverage::Rule("struct-to-struct"),
(C::Enumeration, L::C) => Coverage::Rule("enum-to-enum"),
(C::Alias, L::C) => Coverage::Rule("alias-to-typedef"),
(C::Union, L::C) => Coverage::Rule("union-to-union"),
(C::Bitmask, L::C) => Coverage::Rule("bitmask-to-enum"),
(C::Bitset, L::C) => Coverage::Rule("bitset-to-struct"),
(C::Valuetype, L::C) => Coverage::Rule("valuetype-to-struct"),
(C::Const, L::C) => Coverage::Rule("const-to-const"),
(C::Exception, L::C) => Coverage::Rule("exception-to-struct"),
(C::Native, L::C) => Coverage::Rule("native-to-typedef"),
(
C::Primitive | C::Sequence | C::Array | C::StringType | C::Map | C::Fixed | C::ValueBox,
L::C,
) => Coverage::Rule("member-to-member"),
(C::ObjectRef, L::C) => Coverage::Uncovered("object references belong to the RPC arc"),
(C::Any, L::C) => {
Coverage::Uncovered("`any` carries its type at run time; the CORBA arc owns it")
}
(C::ValueBase, L::C) => Coverage::Uncovered(
"which valuetype arrives is a run-time question; the CORBA arc owns it",
),
(C::AnnotationType, L::C) => Coverage::Uncovered("no C equivalent; nothing is emitted"),
(C::Interface, L::C) => {
Coverage::Uncovered("the C CST has no function-pointer type to declare one with")
}
(C::Module, L::Cpp) => Coverage::Uncovered("module-to-namespace, not yet written"),
(C::Module, L::Java) => Coverage::Uncovered("module-to-package, not yet written"),
(
C::Primitive
| C::Fixed
| C::StringType
| C::Sequence
| C::Array
| C::Map
| C::Structure
| C::Union
| C::Enumeration
| C::Bitmask
| C::Bitset
| C::Alias
| C::Valuetype
| C::ValueBox
| C::Native
| C::Any
| C::ValueBase
| C::ObjectRef
| C::AnnotationType
| C::Const
| C::Interface
| C::Exception,
L::Cpp | L::Java,
) => Coverage::Uncovered("catalogue not yet written for this language"),
(C::Structure, L::CSharp) => Coverage::Rule("struct-to-class"),
(C::Enumeration, L::CSharp) => Coverage::Rule("enum-to-enum"),
(C::Alias, L::CSharp) => Coverage::Rule("alias-to-using"),
(C::Union, L::CSharp) => Coverage::Rule("union-to-class"),
(C::Bitmask, L::CSharp) => Coverage::Rule("bitmask-to-flags-enum"),
(C::Bitset, L::CSharp) => Coverage::Rule("bitset-to-class"),
(C::Valuetype, L::CSharp) => Coverage::Rule("valuetype-to-class"),
(C::Module, L::CSharp) => Coverage::Rule("module-to-namespace"),
(C::Const, L::CSharp) => Coverage::Rule("const-to-const"),
(C::Exception, L::CSharp) => Coverage::Rule("exception-to-class"),
(C::Interface, L::CSharp) => Coverage::Rule("interface-to-interface"),
(C::Native, L::CSharp) => Coverage::Rule("native-to-alias"),
(C::Primitive, L::CSharp) => Coverage::Rule("member-to-field"),
(C::StringType, L::CSharp) => Coverage::Rule("member-to-field"),
(C::Sequence, L::CSharp) => Coverage::Rule("member-to-field"),
(C::Array, L::CSharp) => Coverage::Rule("member-to-field"),
(C::Map, L::CSharp) => Coverage::Rule("member-to-field"),
(C::Fixed, L::CSharp) => Coverage::Rule("member-to-field"),
(C::ValueBox, L::CSharp) => Coverage::Rule("member-to-field"),
(C::Any, L::CSharp) => Coverage::Uncovered(
"an `any` needs the dynamic type system, which is the reflective arc",
),
(C::ValueBase, L::CSharp) => {
Coverage::Uncovered("no C# form; a valuetype base is not a declaration of its own")
}
(C::ObjectRef, L::CSharp) => Coverage::Uncovered("object references belong to the RPC arc"),
(C::AnnotationType, L::CSharp) => Coverage::Uncovered("an annotation declares no data"),
(C::Structure, L::Python) => Coverage::Rule("struct-to-dataclass"),
(C::Enumeration, L::Python) => Coverage::Rule("enum-to-intenum"),
(C::Alias, L::Python) => Coverage::Rule("alias-to-comment"),
(C::Union, L::Python) => Coverage::Rule("union-to-dataclass"),
(C::Bitmask, L::Python) => Coverage::Rule("bitmask-to-intflag"),
(C::Bitset, L::Python) => Coverage::Rule("bitset-to-dataclass"),
(C::Valuetype, L::Python) => Coverage::Rule("valuetype-to-dataclass"),
(C::Module, L::Python) => Coverage::Rule("module-to-class"),
(C::Const, L::Python) => Coverage::Rule("const-to-final"),
(C::Exception, L::Python) => Coverage::Rule("exception-to-dataclass"),
(C::Interface, L::Python) => Coverage::Uncovered(
"the rule fires and materialises nothing; an IDL interface has no data form in a types-only column",
),
(C::Native, L::Python) => Coverage::Rule("native-to-comment"),
(C::Primitive, L::Python) => Coverage::Rule("member-to-field"),
(C::StringType, L::Python) => Coverage::Rule("member-to-field"),
(C::Sequence, L::Python) => Coverage::Rule("member-to-field"),
(C::Array, L::Python) => Coverage::Rule("member-to-field"),
(C::Map, L::Python) => Coverage::Rule("member-to-field"),
(C::Fixed, L::Python) => Coverage::Rule("member-to-field"),
(C::ValueBox, L::Python) => Coverage::Rule("member-to-field"),
(C::Any, L::Python) => Coverage::Uncovered(
"an `any` needs the dynamic type system, which is the reflective arc",
),
(C::ValueBase, L::Python) => {
Coverage::Uncovered("no Python form; a valuetype base is not a declaration of its own")
}
(C::ObjectRef, L::Python) => Coverage::Uncovered("object references belong to the RPC arc"),
(C::AnnotationType, L::Python) => Coverage::Uncovered("an annotation declares no data"),
(C::Structure, L::TypeScript) => Coverage::Rule("struct-to-interface"),
(C::Enumeration, L::TypeScript) => Coverage::Rule("enum-to-const-object"),
(C::Alias, L::TypeScript) => Coverage::Rule("alias-to-type-alias"),
(C::Union, L::TypeScript) => Coverage::Rule("union-to-discriminated-union"),
(C::Bitmask, L::TypeScript) => Coverage::Rule("bitmask-to-const-object"),
(C::Bitset, L::TypeScript) => Coverage::Rule("bitset-to-interface"),
(C::Valuetype, L::TypeScript) => Coverage::Rule("valuetype-to-interface"),
(C::Module, L::TypeScript) => Coverage::Rule("module-to-namespace"),
(C::Const, L::TypeScript) => Coverage::Rule("const-to-const"),
(C::Exception, L::TypeScript) => Coverage::Rule("exception-to-interface"),
(C::Interface, L::TypeScript) => Coverage::Rule("interface-to-interface"),
(C::Native, L::TypeScript) => Coverage::Rule("native-to-type-alias"),
(C::Primitive, L::TypeScript) => Coverage::Rule("member-to-property"),
(C::StringType, L::TypeScript) => Coverage::Rule("member-to-property"),
(C::Sequence, L::TypeScript) => Coverage::Rule("member-to-property"),
(C::Array, L::TypeScript) => Coverage::Rule("member-to-property"),
(C::Map, L::TypeScript) => Coverage::Rule("member-to-property"),
(C::Fixed, L::TypeScript) => Coverage::Rule("member-to-property"),
(C::ValueBox, L::TypeScript) => Coverage::Rule("member-to-property"),
(C::Any, L::TypeScript) => Coverage::Uncovered(
"an `any` needs the dynamic type system, which is the reflective arc",
),
(C::ValueBase, L::TypeScript) => Coverage::Uncovered(
"no TypeScript form; a valuetype base is not a declaration of its own",
),
(C::ObjectRef, L::TypeScript) => {
Coverage::Uncovered("object references belong to the RPC arc")
}
(C::AnnotationType, L::TypeScript) => Coverage::Uncovered("an annotation declares no data"),
(C::Module, L::Go) => Coverage::Rule("module-to-prefix"),
(C::Structure, L::Go) => Coverage::Rule("struct-to-struct"),
(C::Enumeration, L::Go) => Coverage::Rule("enum-to-type"),
(C::Alias, L::Go) => Coverage::Rule("alias-to-alias"),
(C::Union, L::Go) => Coverage::Rule("union-to-struct"),
(C::Bitmask, L::Go) => Coverage::Rule("bitmask-to-type"),
(C::Bitset, L::Go) => Coverage::Rule("bitset-to-struct"),
(C::Valuetype, L::Go) => Coverage::Rule("valuetype-to-struct"),
(C::Const, L::Go) => Coverage::Rule("const-to-const"),
(C::Exception, L::Go) => Coverage::Rule("exception-to-struct"),
(C::Native, L::Go) => Coverage::Rule("native-to-alias"),
(C::Interface, L::Go) => Coverage::Rule("interface-to-interface"),
(
C::Primitive | C::Sequence | C::Array | C::StringType | C::Map | C::Fixed | C::ValueBox,
L::Go,
) => Coverage::Rule("member-to-field"),
(C::ObjectRef, L::Go) => Coverage::Uncovered("object references belong to the RPC arc"),
(C::Any, L::Go) => Coverage::Uncovered(
"`any` carries its type at run time; Go's own `any` would compile and \
there would be no wire form behind it",
),
(C::ValueBase, L::Go) => Coverage::Uncovered(
"which valuetype arrives is a run-time question; the CORBA arc owns it",
),
(C::AnnotationType, L::Go) => Coverage::Uncovered("an annotation declares no data"),
(C::Module, L::OCaml) => Coverage::Rule("module-to-prefix"),
(C::Structure, L::OCaml) => Coverage::Rule("struct-to-record"),
(C::Enumeration, L::OCaml) => Coverage::Rule("enum-to-variant"),
(C::Alias, L::OCaml) => Coverage::Rule("alias-to-abbreviation"),
(C::Union, L::OCaml) => Coverage::Rule("union-to-record"),
(C::Bitmask, L::OCaml) => Coverage::Rule("bitmask-to-abbreviation"),
(C::Bitset, L::OCaml) => Coverage::Rule("bitset-to-record"),
(C::Valuetype, L::OCaml) => Coverage::Rule("valuetype-to-record"),
(C::Const, L::OCaml) => Coverage::Rule("const-to-let"),
(C::Exception, L::OCaml) => Coverage::Rule("exception-to-record"),
(C::Native, L::OCaml) => Coverage::Rule("native-to-abbreviation"),
(C::Interface, L::OCaml) => Coverage::Rule("interface-to-class-type"),
(
C::Primitive | C::Sequence | C::Array | C::StringType | C::Map | C::Fixed | C::ValueBox,
L::OCaml,
) => Coverage::Rule("member-to-field"),
(C::ObjectRef, L::OCaml) => Coverage::Uncovered("object references belong to the RPC arc"),
(C::Any, L::OCaml) => {
Coverage::Uncovered("`any` carries its type at run time; the CORBA arc owns it")
}
(C::ValueBase, L::OCaml) => Coverage::Uncovered(
"which valuetype arrives is a run-time question; the CORBA arc owns it",
),
(C::AnnotationType, L::OCaml) => Coverage::Uncovered("an annotation declares no data"),
(C::Module, L::Ada) => Coverage::Rule("module-to-prefix"),
(C::Structure, L::Ada) => Coverage::Rule("struct-to-record"),
(C::Enumeration, L::Ada) => Coverage::Rule("enum-to-type"),
(C::Alias, L::Ada) => Coverage::Rule("alias-to-subtype"),
(C::Union, L::Ada) => Coverage::Rule("union-to-record"),
(C::Bitmask, L::Ada) => Coverage::Rule("bitmask-to-type"),
(C::Bitset, L::Ada) => Coverage::Rule("bitset-to-record"),
(C::Valuetype, L::Ada) => Coverage::Rule("valuetype-to-record"),
(C::Const, L::Ada) => Coverage::Rule("const-to-constant"),
(C::Exception, L::Ada) => Coverage::Rule("exception-to-record"),
(C::Native, L::Ada) => Coverage::Rule("native-to-type"),
(C::Interface, L::Ada) => Coverage::Rule("interface-to-interface"),
(
C::Primitive | C::Sequence | C::Array | C::StringType | C::Map | C::Fixed | C::ValueBox,
L::Ada,
) => Coverage::Rule("member-to-component"),
(C::ObjectRef, L::Ada) => Coverage::Uncovered("object references belong to the RPC arc"),
(C::Any, L::Ada) => {
Coverage::Uncovered("`any` carries its type at run time; the CORBA arc owns it")
}
(C::ValueBase, L::Ada) => Coverage::Uncovered(
"which valuetype arrives is a run-time question; the CORBA arc owns it",
),
(C::AnnotationType, L::Ada) => Coverage::Uncovered("an annotation declares no data"),
(C::Module, L::D) => Coverage::Rule("module-to-prefix"),
(C::Structure, L::D) => Coverage::Rule("struct-to-struct"),
(C::Enumeration, L::D) => Coverage::Rule("enum-to-enum"),
(C::Alias, L::D) => Coverage::Rule("alias-to-alias"),
(C::Union, L::D) => Coverage::Rule("union-to-struct"),
(C::Bitmask, L::D) => Coverage::Rule("bitmask-to-alias"),
(C::Bitset, L::D) => Coverage::Rule("bitset-to-struct"),
(C::Valuetype, L::D) => Coverage::Rule("valuetype-to-struct"),
(C::Const, L::D) => Coverage::Rule("const-to-const"),
(C::Exception, L::D) => Coverage::Rule("exception-to-struct"),
(C::Native, L::D) => Coverage::Rule("native-to-alias"),
(C::Interface, L::D) => Coverage::Rule("interface-to-interface"),
(
C::Primitive | C::Sequence | C::Array | C::StringType | C::Map | C::Fixed | C::ValueBox,
L::D,
) => Coverage::Rule("member-to-field"),
(C::ObjectRef, L::D) => Coverage::Uncovered("object references belong to the RPC arc"),
(C::Any, L::D) => Coverage::Uncovered(
"`any` carries its type at run time; this language has a type that would \
hold it and no wire form behind it",
),
(C::ValueBase, L::D) => Coverage::Uncovered(
"which valuetype arrives is a run-time question; the CORBA arc owns it",
),
(C::AnnotationType, L::D) => Coverage::Uncovered("an annotation declares no data"),
(C::Module, L::Elixir) => Coverage::Rule("module-to-module"),
(C::Structure, L::Elixir) => Coverage::Rule("struct-to-module"),
(C::Enumeration, L::Elixir) => Coverage::Rule("enum-to-module"),
(C::Alias, L::Elixir) => Coverage::Rule("alias-to-type"),
(C::Union, L::Elixir) => Coverage::Rule("union-to-module"),
(C::Bitmask, L::Elixir) => Coverage::Rule("bitmask-to-module"),
(C::Bitset, L::Elixir) => Coverage::Rule("bitset-to-module"),
(C::Valuetype, L::Elixir) => Coverage::Rule("valuetype-to-module"),
(C::Const, L::Elixir) => Coverage::Rule("const-to-function"),
(C::Exception, L::Elixir) => Coverage::Rule("exception-to-module"),
(C::Native, L::Elixir) => Coverage::Rule("native-to-type"),
(C::Interface, L::Elixir) => Coverage::Rule("interface-to-behaviour"),
(
C::Primitive | C::Sequence | C::Array | C::StringType | C::Map | C::Fixed | C::ValueBox,
L::Elixir,
) => Coverage::Rule("member-to-field"),
(C::ObjectRef, L::Elixir) => Coverage::Uncovered("object references belong to the RPC arc"),
(C::Any, L::Elixir) => Coverage::Uncovered(
"`any` carries its type at run time; this language has a type that would \
hold it and no wire form behind it",
),
(C::ValueBase, L::Elixir) => Coverage::Uncovered(
"which valuetype arrives is a run-time question; the CORBA arc owns it",
),
(C::AnnotationType, L::Elixir) => Coverage::Uncovered("an annotation declares no data"),
(C::Module, L::Julia) => Coverage::Rule("module-to-prefix"),
(C::Structure, L::Julia) => Coverage::Rule("struct-to-struct"),
(C::Enumeration, L::Julia) => Coverage::Rule("enum-to-enum"),
(C::Alias, L::Julia) => Coverage::Rule("alias-to-const"),
(C::Union, L::Julia) => Coverage::Rule("union-to-struct"),
(C::Bitmask, L::Julia) => Coverage::Rule("bitmask-to-const"),
(C::Bitset, L::Julia) => Coverage::Rule("bitset-to-struct"),
(C::Valuetype, L::Julia) => Coverage::Rule("valuetype-to-struct"),
(C::Const, L::Julia) => Coverage::Rule("const-to-const"),
(C::Exception, L::Julia) => Coverage::Rule("exception-to-struct"),
(C::Native, L::Julia) => Coverage::Rule("native-to-const"),
(C::Interface, L::Julia) => Coverage::Rule("interface-to-abstract"),
(
C::Primitive | C::Sequence | C::Array | C::StringType | C::Map | C::Fixed | C::ValueBox,
L::Julia,
) => Coverage::Rule("member-to-field"),
(C::ObjectRef, L::Julia) => Coverage::Uncovered("object references belong to the RPC arc"),
(C::Any, L::Julia) => Coverage::Uncovered(
"`any` carries its type at run time; this language has a type that would \
hold it and no wire form behind it",
),
(C::ValueBase, L::Julia) => Coverage::Uncovered(
"which valuetype arrives is a run-time question; the CORBA arc owns it",
),
(C::AnnotationType, L::Julia) => Coverage::Uncovered("an annotation declares no data"),
(C::Module, L::Lua) => Coverage::Rule("module-to-table"),
(C::Structure, L::Lua) => Coverage::Rule("struct-to-table"),
(C::Enumeration, L::Lua) => Coverage::Rule("enum-to-table"),
(C::Alias, L::Lua) => Coverage::Rule("alias-to-entry"),
(C::Union, L::Lua) => Coverage::Rule("union-to-table"),
(C::Bitmask, L::Lua) => Coverage::Rule("bitmask-to-table"),
(C::Bitset, L::Lua) => Coverage::Rule("bitset-to-table"),
(C::Valuetype, L::Lua) => Coverage::Rule("valuetype-to-table"),
(C::Const, L::Lua) => Coverage::Rule("const-to-field"),
(C::Exception, L::Lua) => Coverage::Rule("exception-to-table"),
(C::Native, L::Lua) => Coverage::Rule("native-to-table"),
(C::Interface, L::Lua) => Coverage::Rule("interface-to-table"),
(
C::Primitive | C::Sequence | C::Array | C::StringType | C::Map | C::Fixed | C::ValueBox,
L::Lua,
) => Coverage::Rule("member-to-entry"),
(C::ObjectRef, L::Lua) => Coverage::Uncovered("object references belong to the RPC arc"),
(C::Any, L::Lua) => Coverage::Uncovered(
"`any` carries its type at run time; this language has a type that would \
hold it and no wire form behind it",
),
(C::ValueBase, L::Lua) => Coverage::Uncovered(
"which valuetype arrives is a run-time question; the CORBA arc owns it",
),
(C::AnnotationType, L::Lua) => Coverage::Uncovered("an annotation declares no data"),
(C::Module, L::Nim) => Coverage::Rule("module-to-prefix"),
(C::Structure, L::Nim) => Coverage::Rule("struct-to-object"),
(C::Enumeration, L::Nim) => Coverage::Rule("enum-to-enum"),
(C::Alias, L::Nim) => Coverage::Rule("alias-to-alias"),
(C::Union, L::Nim) => Coverage::Rule("union-to-object"),
(C::Bitmask, L::Nim) => Coverage::Rule("bitmask-to-alias"),
(C::Bitset, L::Nim) => Coverage::Rule("bitset-to-object"),
(C::Valuetype, L::Nim) => Coverage::Rule("valuetype-to-object"),
(C::Const, L::Nim) => Coverage::Rule("const-to-const"),
(C::Exception, L::Nim) => Coverage::Rule("exception-to-object"),
(C::Native, L::Nim) => Coverage::Rule("native-to-alias"),
(C::Interface, L::Nim) => Coverage::Rule("interface-to-object"),
(
C::Primitive | C::Sequence | C::Array | C::StringType | C::Map | C::Fixed | C::ValueBox,
L::Nim,
) => Coverage::Rule("member-to-field"),
(C::ObjectRef, L::Nim) => Coverage::Uncovered("object references belong to the RPC arc"),
(C::Any, L::Nim) => Coverage::Uncovered(
"`any` carries its type at run time; this language has a type that would \
hold it and no wire form behind it",
),
(C::ValueBase, L::Nim) => Coverage::Uncovered(
"which valuetype arrives is a run-time question; the CORBA arc owns it",
),
(C::AnnotationType, L::Nim) => Coverage::Uncovered("an annotation declares no data"),
(C::Module, L::Swift) => Coverage::Rule("module-to-prefix"),
(C::Structure, L::Swift) => Coverage::Rule("struct-to-struct"),
(C::Enumeration, L::Swift) => Coverage::Rule("enum-to-enum"),
(C::Alias, L::Swift) => Coverage::Rule("alias-to-typealias"),
(C::Union, L::Swift) => Coverage::Rule("union-to-struct"),
(C::Bitmask, L::Swift) => Coverage::Rule("bitmask-to-optionset"),
(C::Bitset, L::Swift) => Coverage::Rule("bitset-to-struct"),
(C::Valuetype, L::Swift) => Coverage::Rule("valuetype-to-struct"),
(C::Const, L::Swift) => Coverage::Rule("const-to-let"),
(C::Exception, L::Swift) => Coverage::Rule("exception-to-struct"),
(C::Native, L::Swift) => Coverage::Rule("native-to-typealias"),
(C::Interface, L::Swift) => Coverage::Rule("interface-to-protocol"),
(
C::Primitive | C::Sequence | C::Array | C::StringType | C::Map | C::Fixed | C::ValueBox,
L::Swift,
) => Coverage::Rule("member-to-property"),
(C::ObjectRef, L::Swift) => Coverage::Uncovered("object references belong to the RPC arc"),
(C::Any, L::Swift) => Coverage::Uncovered(
"`any` carries its type at run time; this language has a type that would \
hold it and no wire form behind it",
),
(C::ValueBase, L::Swift) => Coverage::Uncovered(
"which valuetype arrives is a run-time question; the CORBA arc owns it",
),
(C::AnnotationType, L::Swift) => Coverage::Uncovered("an annotation declares no data"),
(C::Module, L::Zig) => Coverage::Rule("module-to-prefix"),
(C::Structure, L::Zig) => Coverage::Rule("struct-to-struct"),
(C::Enumeration, L::Zig) => Coverage::Rule("enum-to-enum"),
(C::Alias, L::Zig) => Coverage::Rule("alias-to-const"),
(C::Union, L::Zig) => Coverage::Rule("union-to-struct"),
(C::Bitmask, L::Zig) => Coverage::Rule("bitmask-to-int"),
(C::Bitset, L::Zig) => Coverage::Rule("bitset-to-struct"),
(C::Valuetype, L::Zig) => Coverage::Rule("valuetype-to-struct"),
(C::Const, L::Zig) => Coverage::Rule("const-to-const"),
(C::Exception, L::Zig) => Coverage::Rule("exception-to-struct"),
(C::Native, L::Zig) => Coverage::Rule("native-to-opaque"),
(C::Interface, L::Zig) => Coverage::Rule("interface-to-struct"),
(
C::Primitive | C::Sequence | C::Array | C::StringType | C::Map | C::Fixed | C::ValueBox,
L::Zig,
) => Coverage::Rule("member-to-field"),
(C::ObjectRef, L::Zig) => Coverage::Uncovered("object references belong to the RPC arc"),
(C::Any, L::Zig) => {
Coverage::Uncovered("`any` carries its type at run time; the CORBA arc owns it")
}
(C::ValueBase, L::Zig) => Coverage::Uncovered(
"which valuetype arrives is a run-time question; the CORBA arc owns it",
),
(C::AnnotationType, L::Zig) => Coverage::Uncovered("an annotation declares no data"),
(C::Module, L::Node) => Coverage::Rule("module-to-flattened-name"),
(C::Structure, L::Node) => Coverage::Rule("struct-to-object-literal"),
(C::Union, L::Node) => Coverage::Rule("union-to-object-literal"),
(C::Enumeration, L::Node) => Coverage::Rule("enum-to-frozen-object"),
(C::Bitmask, L::Node) => Coverage::Rule("bit-to-const"),
(C::Bitset, L::Node) => Coverage::Rule("bitset-to-object-literal"),
(C::Alias, L::Node) => Coverage::Rule("alias-transparent"),
(C::Valuetype, L::Node) => Coverage::Rule("valuetype-to-object-literal"),
(C::Const, L::Node) => Coverage::Rule("const-to-const"),
(
C::Primitive | C::Sequence | C::Array | C::StringType | C::Map | C::Fixed | C::ValueBox,
L::Node,
) => Coverage::Rule("member-to-property"),
(C::Native, L::Node) => Coverage::Uncovered(
"opaque and never a member's type in the corpus; a dynamically-typed \
column has no consumer that would look one up by a declared name",
),
(C::Exception, L::Node) => Coverage::Uncovered(
"an exception is never a struct member's type, only an operation's \
raises clause; nothing here declares a name for one",
),
(C::Interface, L::Node) => Coverage::Uncovered(
"an interface is the RPC arc's and not the wire's, and nothing here \
declares a name for one",
),
(C::ObjectRef, L::Node) => Coverage::Uncovered("object references belong to the RPC arc"),
(C::Any, L::Node) => {
Coverage::Uncovered("`any` carries its type at run time; the CORBA arc owns it")
}
(C::ValueBase, L::Node) => Coverage::Uncovered(
"which valuetype arrives is a run-time question; the CORBA arc owns it",
),
(C::AnnotationType, L::Node) => Coverage::Uncovered("an annotation declares no data"),
(C::Module, L::Ada83) => Coverage::Rule("module-to-prefix"),
(C::Structure, L::Ada83) => Coverage::Rule("struct-to-record"),
(C::Enumeration, L::Ada83) => Coverage::Rule("enum-to-constants"),
(C::Alias, L::Ada83) => Coverage::Rule("alias-to-subtype"),
(C::Union, L::Ada83) => Coverage::Rule("union-to-record"),
(C::Bitmask, L::Ada83) => Coverage::Rule("bitmask-to-type"),
(C::Bitset, L::Ada83) => Coverage::Rule("bitset-to-record"),
(C::Valuetype, L::Ada83) => Coverage::Rule("valuetype-to-record"),
(C::Const, L::Ada83) => Coverage::Rule("const-to-constant"),
(C::Exception, L::Ada83) => Coverage::Rule("exception-to-record"),
(C::Native, L::Ada83) => Coverage::Rule("native-to-type"),
(
C::Primitive | C::Sequence | C::Array | C::StringType | C::Map | C::Fixed | C::ValueBox,
L::Ada83,
) => Coverage::Rule("member-to-component"),
(C::Interface, L::Ada83) => Coverage::Uncovered(
"RM83 has no interface type, no tagged type and no `abstract` primitive \
operation — all three are Ada 95 or Ada 2005 additions — so `ada83_items` \
refuses one by name before any rule of this catalogue is consulted",
),
(C::ObjectRef, L::Ada83) => Coverage::Uncovered("object references belong to the RPC arc"),
(C::Any, L::Ada83) => {
Coverage::Uncovered("`any` carries its type at run time; the CORBA arc owns it")
}
(C::ValueBase, L::Ada83) => Coverage::Uncovered(
"which valuetype arrives is a run-time question; the CORBA arc owns it",
),
(C::AnnotationType, L::Ada83) => Coverage::Uncovered("an annotation declares no data"),
(C::Module, L::FSharp) => Coverage::Rule("module-to-prefix"),
(C::Structure, L::FSharp) => Coverage::Rule("struct-to-class"),
(C::Enumeration, L::FSharp) => Coverage::Rule("enum-to-enum"),
(C::Alias, L::FSharp) => Coverage::Rule("alias-to-abbreviation"),
(C::Union, L::FSharp) => Coverage::Rule("union-to-class"),
(C::Bitmask, L::FSharp) => Coverage::Rule("bitmask-to-int"),
(C::Bitset, L::FSharp) => Coverage::Rule("bitset-to-class"),
(C::Valuetype, L::FSharp) => Coverage::Rule("valuetype-to-class"),
(C::Const, L::FSharp) => Coverage::Rule("const-to-const"),
(C::Exception, L::FSharp) => Coverage::Rule("exception-to-class"),
(C::Interface, L::FSharp) => Coverage::Rule("interface-to-class"),
(C::Native, L::FSharp) => Coverage::Rule("native-to-opaque"),
(
C::Primitive | C::Sequence | C::Array | C::StringType | C::Map | C::Fixed | C::ValueBox,
L::FSharp,
) => Coverage::Rule("member-to-field"),
(C::Any, L::FSharp) => Coverage::Uncovered(
"an `any` needs the dynamic type system, which is the reflective arc",
),
(C::ValueBase, L::FSharp) => {
Coverage::Uncovered("no F# form; a valuetype base is not a declaration of its own")
}
(C::ObjectRef, L::FSharp) => Coverage::Uncovered("object references belong to the RPC arc"),
(C::AnnotationType, L::FSharp) => Coverage::Uncovered("an annotation declares no data"),
(C::Module, L::Kotlin) => Coverage::Rule("module-to-prefix"),
(C::Structure, L::Kotlin) => Coverage::Rule("struct-to-class"),
(C::Enumeration, L::Kotlin) => Coverage::Rule("enum-to-object"),
(C::Alias, L::Kotlin) => Coverage::Rule("alias-to-alias"),
(C::Union, L::Kotlin) => Coverage::Rule("union-to-class"),
(C::Bitmask, L::Kotlin) => Coverage::Rule("bitmask-to-alias"),
(C::Bitset, L::Kotlin) => Coverage::Rule("bitset-to-class"),
(C::Valuetype, L::Kotlin) => Coverage::Rule("valuetype-to-class"),
(C::Const, L::Kotlin) => Coverage::Rule("const-to-const"),
(C::Exception, L::Kotlin) => Coverage::Rule("exception-to-class"),
(C::Interface, L::Kotlin) => Coverage::Rule("interface-to-class"),
(C::Native, L::Kotlin) => Coverage::Rule("native-to-alias"),
(
C::Primitive | C::Sequence | C::Array | C::StringType | C::Map | C::Fixed | C::ValueBox,
L::Kotlin,
) => Coverage::Rule("member-to-property"),
(C::Any, L::Kotlin) => Coverage::Uncovered(
"an `any` needs the dynamic type system, which is the reflective arc",
),
(C::ValueBase, L::Kotlin) => {
Coverage::Uncovered("no Kotlin form; a valuetype base is not a declaration of its own")
}
(C::ObjectRef, L::Kotlin) => Coverage::Uncovered("object references belong to the RPC arc"),
(C::AnnotationType, L::Kotlin) => Coverage::Uncovered("an annotation declares no data"),
}
}
#[must_use]
pub fn covered_count() -> usize {
let mut count = 0;
for construct in ConstructKind::ALL {
for language in Language::ALL {
if coverage_of(construct, language).is_covered() {
count += 1;
}
}
}
count
}
#[must_use]
pub const fn cell_count() -> usize {
ConstructKind::ALL.len() * Language::ALL.len()
}