3
3
use super :: comp:: CompInfo ;
4
4
use super :: context:: { BindgenContext , ItemId } ;
5
5
use super :: derive:: { CanDeriveCopy , CanDeriveDebug , CanDeriveDefault } ;
6
+ use super :: dot:: DotAttributes ;
6
7
use super :: enum_ty:: Enum ;
7
8
use super :: function:: FunctionSig ;
8
9
use super :: int:: IntKind ;
@@ -12,6 +13,7 @@ use super::objc::ObjCInterface;
12
13
use super :: traversal:: { Trace , Tracer } ;
13
14
use clang:: { self , Cursor } ;
14
15
use parse:: { ClangItemParser , ParseError , ParseResult } ;
16
+ use std:: io;
15
17
use std:: mem;
16
18
17
19
/// Template declaration related methods.
@@ -384,6 +386,61 @@ impl Type {
384
386
}
385
387
}
386
388
389
+ impl DotAttributes for Type {
390
+ fn dot_attributes < W > ( & self , ctx : & BindgenContext , out : & mut W ) -> io:: Result < ( ) >
391
+ where W : io:: Write
392
+ {
393
+ if let Some ( ref layout) = self . layout {
394
+ try!( writeln ! ( out,
395
+ "<tr><td>size</td><td>{}</td></tr>
396
+ <tr><td>align</td><td>{}</td></tr>" ,
397
+ layout. size,
398
+ layout. align) ) ;
399
+ if layout. packed {
400
+ try!( writeln ! ( out, "<tr><td>packed</td><td>true</td></tr>" ) ) ;
401
+ }
402
+ }
403
+
404
+ if self . is_const {
405
+ try!( writeln ! ( out, "<tr><td>const</td><td>true</td></tr>" ) ) ;
406
+ }
407
+
408
+ self . kind . dot_attributes ( ctx, out)
409
+ }
410
+ }
411
+
412
+ impl DotAttributes for TypeKind {
413
+ fn dot_attributes < W > ( & self , _ctx : & BindgenContext , out : & mut W ) -> io:: Result < ( ) >
414
+ where W : io:: Write
415
+ {
416
+ write ! ( out,
417
+ "<tr><td>TypeKind</td><td>{}</td></tr>" ,
418
+ match * self {
419
+ TypeKind :: Void => "Void" ,
420
+ TypeKind :: NullPtr => "NullPtr" ,
421
+ TypeKind :: Comp ( ..) => "Comp" ,
422
+ TypeKind :: Int ( ..) => "Int" ,
423
+ TypeKind :: Float ( ..) => "Float" ,
424
+ TypeKind :: Complex ( ..) => "Complex" ,
425
+ TypeKind :: Alias ( ..) => "Alias" ,
426
+ TypeKind :: TemplateAlias ( ..) => "TemplateAlias" ,
427
+ TypeKind :: Array ( ..) => "Array" ,
428
+ TypeKind :: Function ( ..) => "Function" ,
429
+ TypeKind :: Enum ( ..) => "Enum" ,
430
+ TypeKind :: Pointer ( ..) => "Pointer" ,
431
+ TypeKind :: BlockPointer => "BlockPointer" ,
432
+ TypeKind :: Reference ( ..) => "Reference" ,
433
+ TypeKind :: TemplateInstantiation ( ..) => "TemplateInstantiation" ,
434
+ TypeKind :: ResolvedTypeRef ( ..) => "ResolvedTypeRef" ,
435
+ TypeKind :: Named => "Named" ,
436
+ TypeKind :: ObjCInterface ( ..) => "ObjCInterface" ,
437
+ TypeKind :: UnresolvedTypeRef ( ..) => {
438
+ unreachable!( "there shouldn't be any more of these anymore" )
439
+ }
440
+ } )
441
+ }
442
+ }
443
+
387
444
#[ test]
388
445
fn is_invalid_named_type_valid ( ) {
389
446
let ty = Type :: new ( Some ( "foo" . into ( ) ) , None , TypeKind :: Named , false ) ;
0 commit comments