@@ -26,6 +26,8 @@ pub enum MethodKind {
26
26
/// A constructor. We represent it as method for convenience, to avoid code
27
27
/// duplication.
28
28
Constructor ,
29
+ /// A destructor method
30
+ Destructor ,
29
31
/// A static method.
30
32
Static ,
31
33
/// A normal method.
@@ -61,6 +63,11 @@ impl Method {
61
63
self . kind
62
64
}
63
65
66
+ /// Is this a destructor method?
67
+ pub fn is_destructor ( & self ) -> bool {
68
+ self . kind == MethodKind :: Destructor
69
+ }
70
+
64
71
/// Is this a constructor?
65
72
pub fn is_constructor ( & self ) -> bool {
66
73
self . kind == MethodKind :: Constructor
@@ -249,6 +256,9 @@ pub struct CompInfo {
249
256
/// The different constructors this struct or class contains.
250
257
constructors : Vec < ItemId > ,
251
258
259
+ /// The destructor of this type
260
+ destructor : Option < ItemId > ,
261
+
252
262
/// Vector of classes this one inherits from.
253
263
base_members : Vec < Base > ,
254
264
@@ -323,6 +333,7 @@ impl CompInfo {
323
333
template_args : vec ! [ ] ,
324
334
methods : vec ! [ ] ,
325
335
constructors : vec ! [ ] ,
336
+ destructor : None ,
326
337
base_members : vec ! [ ] ,
327
338
ref_template : None ,
328
339
inner_types : vec ! [ ] ,
@@ -468,6 +479,11 @@ impl CompInfo {
468
479
& self . constructors
469
480
}
470
481
482
+ /// Get this type's destructor.
483
+ pub fn destructor ( & self ) -> & Option < ItemId > {
484
+ & self . destructor
485
+ }
486
+
471
487
/// What kind of compound type is this?
472
488
pub fn kind ( & self ) -> CompKind {
473
489
self . kind
@@ -729,8 +745,9 @@ impl CompInfo {
729
745
CXCursor_Constructor => {
730
746
ci. constructors . push ( signature) ;
731
747
}
732
- // TODO(emilio): Bind the destructor?
733
- CXCursor_Destructor => { }
748
+ CXCursor_Destructor => {
749
+ ci. destructor = Some ( signature) ;
750
+ }
734
751
CXCursor_CXXMethod => {
735
752
let is_const = cur. method_is_const ( ) ;
736
753
let method_kind = if is_static {
0 commit comments