@@ -222,6 +222,57 @@ impl PrimitiveType {
222222 }
223223 }
224224
225+ pub fn to_repr_d ( & self , config : & Config ) -> & ' static str {
226+ match * self {
227+ PrimitiveType :: Void => "void" ,
228+ PrimitiveType :: Bool => "bool" ,
229+ PrimitiveType :: Char => "char" ,
230+ PrimitiveType :: SChar => "byte" ,
231+ PrimitiveType :: UChar => "ubyte" ,
232+ // NOTE: It'd be nice to use a char32_t, but:
233+ //
234+ // * uchar.h is not present on mac (see #423).
235+ //
236+ // * char32_t isn't required to be compatible with Rust's char, as
237+ // the C++ spec only requires it to be the same size as
238+ // uint_least32_t, which is _not_ guaranteed to be 4-bytes.
239+ //
240+ PrimitiveType :: Char32 => "uint" ,
241+ PrimitiveType :: Integer {
242+ kind,
243+ signed,
244+ zeroable : _,
245+ } => match ( kind, signed) {
246+ ( IntKind :: Short , true ) => "short" ,
247+ ( IntKind :: Short , false ) => "ushort" ,
248+ ( IntKind :: Int , true ) => "int" ,
249+ ( IntKind :: Int , false ) => "uint" ,
250+ ( IntKind :: Long , true ) => "long" ,
251+ ( IntKind :: Long , false ) => "ulong" ,
252+ ( IntKind :: LongLong , true ) => "long long" ,
253+ ( IntKind :: LongLong , false ) => "ulong long" ,
254+ ( IntKind :: SizeT , true ) => "long" ,
255+ ( IntKind :: SizeT , false ) => "ulong" ,
256+ ( IntKind :: Size , true ) if config. usize_is_size_t => "long" ,
257+ ( IntKind :: Size , false ) if config. usize_is_size_t => "ulong" ,
258+ ( IntKind :: Size , true ) => "long" ,
259+ ( IntKind :: Size , false ) => "ulong" ,
260+ ( IntKind :: B8 , true ) => "byte" ,
261+ ( IntKind :: B8 , false ) => "ubyte" ,
262+ ( IntKind :: B16 , true ) => "short" ,
263+ ( IntKind :: B16 , false ) => "ushort" ,
264+ ( IntKind :: B32 , true ) => "int" ,
265+ ( IntKind :: B32 , false ) => "uint" ,
266+ ( IntKind :: B64 , true ) => "long" ,
267+ ( IntKind :: B64 , false ) => "ulong" ,
268+ } ,
269+ PrimitiveType :: Float => "float" ,
270+ PrimitiveType :: Double => "double" ,
271+ PrimitiveType :: PtrDiffT => "long" ,
272+ PrimitiveType :: VaList => "..." ,
273+ }
274+ }
275+
225276 fn can_cmp_order ( & self ) -> bool {
226277 !matches ! ( * self , PrimitiveType :: Bool )
227278 }
0 commit comments