@@ -177,6 +177,25 @@ pub enum TypeInfo<'a> {
177177 Structure ( & ' a StructureDef < ' a > ) ,
178178 /// An untagged union
179179 Union ( & ' a UnionDef < ' a > ) ,
180+ /// A named, transparent, extern type
181+ Extern {
182+ /// The name of the type
183+ ///
184+ /// Since this is all we have, it's what used
185+ /// to disambiguate between them.
186+ name : & ' static str
187+ } ,
188+ /// A 'magic' type, with a user-defined meaning
189+ ///
190+ /// This allows extensions to the type system
191+ Magic {
192+ /// The id of the magic type,
193+ /// giving more information about how its implemented
194+ /// and what it actually means.
195+ id : & ' static & ' static str ,
196+ /// Extra information (if any)
197+ extra : Option < & ' a TypeInfo < ' a > > ,
198+ }
180199}
181200/*
182201 * HACK: Implement AsmType as `NullTrace`
@@ -240,7 +259,9 @@ impl<'tp> TypeInfo<'tp> {
240259 #[ cfg( feature = "builtins" ) ]
241260 Str => size_of :: < AsmStr > ( ) ,
242261 Structure ( ref def) => def. size ,
243- Union ( ref def) => def. size
262+ Union ( ref def) => def. size ,
263+ // Provide a dummy value
264+ TypeInfo :: Magic { .. } | TypeInfo :: Extern { .. } => 0xFFFF_FFFF
244265 }
245266 }
246267 /// The alignment of the type, matching `std::mem::align_of`
@@ -250,6 +271,7 @@ impl<'tp> TypeInfo<'tp> {
250271 TypeInfo :: Unit => align_of :: < ( ) > ( ) ,
251272 #[ cfg( feature = "never" ) ]
252273 TypeInfo :: Never => align_of :: < !> ( ) ,
274+ TypeInfo :: Magic { .. } | TypeInfo :: Extern { .. } => 0 ,
253275 TypeInfo :: Bool => align_of :: < bool > ( ) ,
254276 TypeInfo :: Integer { size : IntSize :: Byte , signed : false } => align_of :: < u8 > ( ) ,
255277 TypeInfo :: Integer { size : IntSize :: Short , signed : false } => align_of :: < u16 > ( ) ,
@@ -286,6 +308,9 @@ impl<'a> Display for TypeInfo<'a> {
286308 TypeInfo :: Pointer => f. write_str ( "*mut void" ) ,
287309 TypeInfo :: Structure ( ref def) => f. write_str ( def. name ) ,
288310 TypeInfo :: Union ( ref def) => f. write_str ( def. name ) ,
311+ TypeInfo :: Extern { name } => write ! ( f, "extern {}" , name) ,
312+ TypeInfo :: Magic { id, extra : None } => write ! ( f, "magic::{}" , id) ,
313+ TypeInfo :: Magic { id, extra : Some ( extra) } => write ! ( f, "magic::{}<{}>" , id, extra)
289314 }
290315 }
291316}
0 commit comments