Skip to content

Commit e8aac63

Browse files
author
bors-servo
authored
Auto merge of #155 - fitzgen:doc-ir-mod, r=emilio
Document the `ir` module r? @emilio
2 parents a6088ee + c70baa8 commit e8aac63

14 files changed

+372
-42
lines changed

src/ir/annotations.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
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+
17
use clang;
28

9+
/// What kind of accessor should we provide for a field?
310
#[derive(Copy, PartialEq, Clone, Debug)]
411
pub enum FieldAccessorKind {
12+
/// No accessor.
513
None,
14+
/// Plain accessor.
615
Regular,
16+
/// Unsafe accessor.
717
Unsafe,
18+
/// Immutable accessor.
819
Immutable,
920
}
1021

@@ -53,6 +64,8 @@ impl Default for Annotations {
5364
}
5465

5566
impl Annotations {
67+
/// Construct new annotations for the given cursor and its bindgen comments
68+
/// (if any).
5669
pub fn new(cursor: &clang::Cursor) -> Option<Annotations> {
5770
let mut anno = Annotations::default();
5871
let mut matched_one = false;
@@ -65,10 +78,12 @@ impl Annotations {
6578
}
6679
}
6780

81+
/// Should this type be hidden?
6882
pub fn hide(&self) -> bool {
6983
self.hide
7084
}
7185

86+
/// Should this type be opaque?
7287
pub fn opaque(&self) -> bool {
7388
self.opaque
7489
}
@@ -87,10 +102,10 @@ impl Annotations {
87102
///
88103
/// the generated code would look something like:
89104
///
90-
/// ```c++
105+
/// ```
91106
/// /** <div rustbindgen replaces="Bar"></div> */
92107
/// struct Bar {
93-
/// int x;
108+
/// x: ::std::os::raw::c_int,
94109
/// };
95110
/// ```
96111
///
@@ -99,14 +114,17 @@ impl Annotations {
99114
self.use_instead_of.as_ref().map(|s| &**s)
100115
}
101116

117+
/// Should we avoid implementing the `Copy` trait?
102118
pub fn disallow_copy(&self) -> bool {
103119
self.disallow_copy
104120
}
105121

122+
/// Should the fields be private?
106123
pub fn private_fields(&self) -> Option<bool> {
107124
self.private_fields
108125
}
109126

127+
/// What kind of accessors should we provide for this type's fields?
110128
pub fn accessor_kind(&self) -> Option<FieldAccessorKind> {
111129
self.accessor_kind
112130
}

0 commit comments

Comments
 (0)