1
+ //! Types and functions related to bindgen annotation comments.
2
+ //!
3
+ //! Users can add annotations in doc comments to types that they would like to
4
+ //! replace other types with, mark as opaque, etc. This module deals with all of
5
+ //! that stuff.
6
+
1
7
use clang;
2
8
9
+ /// What kind of accessor should we provide for a field?
3
10
#[ derive( Copy , PartialEq , Clone , Debug ) ]
4
11
pub enum FieldAccessorKind {
12
+ /// No accessor.
5
13
None ,
14
+ /// Plain accessor.
6
15
Regular ,
16
+ /// Unsafe accessor.
7
17
Unsafe ,
18
+ /// Immutable accessor.
8
19
Immutable ,
9
20
}
10
21
@@ -53,6 +64,8 @@ impl Default for Annotations {
53
64
}
54
65
55
66
impl Annotations {
67
+ /// Construct new annotations for the given cursor and its bindgen comments
68
+ /// (if any).
56
69
pub fn new ( cursor : & clang:: Cursor ) -> Option < Annotations > {
57
70
let mut anno = Annotations :: default ( ) ;
58
71
let mut matched_one = false ;
@@ -65,10 +78,12 @@ impl Annotations {
65
78
}
66
79
}
67
80
81
+ /// Should this type be hidden?
68
82
pub fn hide ( & self ) -> bool {
69
83
self . hide
70
84
}
71
85
86
+ /// Should this type be opaque?
72
87
pub fn opaque ( & self ) -> bool {
73
88
self . opaque
74
89
}
@@ -87,10 +102,10 @@ impl Annotations {
87
102
///
88
103
/// the generated code would look something like:
89
104
///
90
- /// ```c++
105
+ /// ```
91
106
/// /** <div rustbindgen replaces="Bar"></div> */
92
107
/// struct Bar {
93
- /// int x;
108
+ /// x: ::std::os::raw::c_int,
94
109
/// };
95
110
/// ```
96
111
///
@@ -99,14 +114,17 @@ impl Annotations {
99
114
self . use_instead_of . as_ref ( ) . map ( |s| & * * s)
100
115
}
101
116
117
+ /// Should we avoid implementing the `Copy` trait?
102
118
pub fn disallow_copy ( & self ) -> bool {
103
119
self . disallow_copy
104
120
}
105
121
122
+ /// Should the fields be private?
106
123
pub fn private_fields ( & self ) -> Option < bool > {
107
124
self . private_fields
108
125
}
109
126
127
+ /// What kind of accessors should we provide for this type's fields?
110
128
pub fn accessor_kind ( & self ) -> Option < FieldAccessorKind > {
111
129
self . accessor_kind
112
130
}
0 commit comments