Skip to main content

cpp_primitive

Function cpp_primitive 

Source
pub fn cpp_primitive(kind: PrimitiveKind) -> Type
Expand description

The C++ type an IDL primitive becomes.

Exhaustive, so a primitive added to the model without a C++ spelling is a compile error and not a member that silently takes another’s.

The fixed-width integers are written std::-qualified, not as cpp::Primitive::Int32 and its neighbours, which render the bare int32_t. <cstdint> declares those names in namespace std; the standard leaves it unspecified whether it also declares them at global scope, and a generated header that names the unqualified form is relying on an implementation’s habit. The Primitive variants stay right for a hand-written tree; they are not right for output that has to compile wherever it is sent.

char is one byte and wchar two, which is what the wire form is. XTypes 1.3 §7.5.1.1.1 leaves the C++ spelling of Char16 to the binding, and a fixed-width integer is the only choice that does not depend on the platform’s wchar_t — which is 16 bits on Windows and 32 on Linux.

long double is not routed here: it takes FLOAT128. The Float128 arm below exists so the match is total and answers for a caller that wants the nearest built-in; value_type matches Float128 before it reaches this. A caller that does not is the defect the three-column gate found in the C column.