@@ -5,18 +5,18 @@ use crate::ir::layout::Layout;
5
5
use proc_macro2:: { Ident , Span , TokenStream } ;
6
6
use quote:: TokenStreamExt ;
7
7
8
- pub ( crate ) mod attributes {
8
+ pub mod attributes {
9
9
use proc_macro2:: { Ident , Span , TokenStream } ;
10
10
use std:: str:: FromStr ;
11
11
12
- pub ( crate ) fn repr ( which : & str ) -> TokenStream {
12
+ pub fn repr ( which : & str ) -> TokenStream {
13
13
let which = Ident :: new ( which, Span :: call_site ( ) ) ;
14
14
quote ! {
15
15
#[ repr( #which ) ]
16
16
}
17
17
}
18
18
19
- pub ( crate ) fn repr_list ( which_ones : & [ & str ] ) -> TokenStream {
19
+ pub fn repr_list ( which_ones : & [ & str ] ) -> TokenStream {
20
20
let which_ones = which_ones
21
21
. iter ( )
22
22
. cloned ( )
@@ -26,7 +26,7 @@ pub(crate) mod attributes {
26
26
}
27
27
}
28
28
29
- pub ( crate ) fn derives ( which_ones : & [ & str ] ) -> TokenStream {
29
+ pub fn derives ( which_ones : & [ & str ] ) -> TokenStream {
30
30
let which_ones = which_ones
31
31
. iter ( )
32
32
. cloned ( )
@@ -36,33 +36,33 @@ pub(crate) mod attributes {
36
36
}
37
37
}
38
38
39
- pub ( crate ) fn inline ( ) -> TokenStream {
39
+ pub fn inline ( ) -> TokenStream {
40
40
quote ! {
41
41
#[ inline]
42
42
}
43
43
}
44
44
45
- pub ( crate ) fn must_use ( ) -> TokenStream {
45
+ pub fn must_use ( ) -> TokenStream {
46
46
quote ! {
47
47
#[ must_use]
48
48
}
49
49
}
50
50
51
- pub ( crate ) fn non_exhaustive ( ) -> TokenStream {
51
+ pub fn non_exhaustive ( ) -> TokenStream {
52
52
quote ! {
53
53
#[ non_exhaustive]
54
54
}
55
55
}
56
56
57
- pub ( crate ) fn doc ( comment : String ) -> TokenStream {
57
+ pub fn doc ( comment : String ) -> TokenStream {
58
58
if comment. is_empty ( ) {
59
59
quote ! ( )
60
60
} else {
61
61
quote ! ( #[ doc = #comment] )
62
62
}
63
63
}
64
64
65
- pub ( crate ) fn link_name ( name : & str ) -> TokenStream {
65
+ pub fn link_name ( name : & str ) -> TokenStream {
66
66
// LLVM mangles the name by default but it's already mangled.
67
67
// Prefixing the name with \u{1} should tell LLVM to not mangle it.
68
68
let name = format ! ( "\u{1} {}" , name) ;
@@ -74,7 +74,7 @@ pub(crate) mod attributes {
74
74
75
75
/// Generates a proper type for a field or type with a given `Layout`, that is,
76
76
/// a type with the correct size and alignment restrictions.
77
- pub ( crate ) fn blob ( ctx : & BindgenContext , layout : Layout ) -> TokenStream {
77
+ pub fn blob ( ctx : & BindgenContext , layout : Layout ) -> TokenStream {
78
78
let opaque = layout. opaque ( ) ;
79
79
80
80
// FIXME(emilio, #412): We fall back to byte alignment, but there are
@@ -105,7 +105,7 @@ pub(crate) fn blob(ctx: &BindgenContext, layout: Layout) -> TokenStream {
105
105
}
106
106
107
107
/// Integer type of the same size as the given `Layout`.
108
- pub ( crate ) fn integer_type (
108
+ pub fn integer_type (
109
109
ctx : & BindgenContext ,
110
110
layout : Layout ,
111
111
) -> Option < TokenStream > {
@@ -115,10 +115,7 @@ pub(crate) fn integer_type(
115
115
}
116
116
117
117
/// Generates a bitfield allocation unit type for a type with the given `Layout`.
118
- pub ( crate ) fn bitfield_unit (
119
- ctx : & BindgenContext ,
120
- layout : Layout ,
121
- ) -> TokenStream {
118
+ pub fn bitfield_unit ( ctx : & BindgenContext , layout : Layout ) -> TokenStream {
122
119
let mut tokens = quote ! { } ;
123
120
124
121
if ctx. options ( ) . enable_cxx_namespaces {
@@ -133,15 +130,15 @@ pub(crate) fn bitfield_unit(
133
130
tokens
134
131
}
135
132
136
- pub ( crate ) mod ast_ty {
133
+ pub mod ast_ty {
137
134
use crate :: ir:: context:: BindgenContext ;
138
135
use crate :: ir:: function:: FunctionSig ;
139
136
use crate :: ir:: layout:: Layout ;
140
137
use crate :: ir:: ty:: FloatKind ;
141
138
use proc_macro2:: { self , TokenStream } ;
142
139
use std:: str:: FromStr ;
143
140
144
- pub ( crate ) fn c_void ( ctx : & BindgenContext ) -> TokenStream {
141
+ pub fn c_void ( ctx : & BindgenContext ) -> TokenStream {
145
142
// ctypes_prefix takes precedence
146
143
match ctx. options ( ) . ctypes_prefix {
147
144
Some ( ref prefix) => {
@@ -162,7 +159,7 @@ pub(crate) mod ast_ty {
162
159
}
163
160
}
164
161
165
- pub ( crate ) fn raw_type ( ctx : & BindgenContext , name : & str ) -> TokenStream {
162
+ pub fn raw_type ( ctx : & BindgenContext , name : & str ) -> TokenStream {
166
163
let ident = ctx. rust_ident_raw ( name) ;
167
164
match ctx. options ( ) . ctypes_prefix {
168
165
Some ( ref prefix) => {
@@ -187,7 +184,7 @@ pub(crate) mod ast_ty {
187
184
}
188
185
}
189
186
190
- pub ( crate ) fn float_kind_rust_type (
187
+ pub fn float_kind_rust_type (
191
188
ctx : & BindgenContext ,
192
189
fk : FloatKind ,
193
190
layout : Option < Layout > ,
@@ -232,36 +229,33 @@ pub(crate) mod ast_ty {
232
229
}
233
230
}
234
231
235
- pub ( crate ) fn int_expr ( val : i64 ) -> TokenStream {
232
+ pub fn int_expr ( val : i64 ) -> TokenStream {
236
233
// Don't use quote! { #val } because that adds the type suffix.
237
234
let val = proc_macro2:: Literal :: i64_unsuffixed ( val) ;
238
235
quote ! ( #val)
239
236
}
240
237
241
- pub ( crate ) fn uint_expr ( val : u64 ) -> TokenStream {
238
+ pub fn uint_expr ( val : u64 ) -> TokenStream {
242
239
// Don't use quote! { #val } because that adds the type suffix.
243
240
let val = proc_macro2:: Literal :: u64_unsuffixed ( val) ;
244
241
quote ! ( #val)
245
242
}
246
243
247
- pub ( crate ) fn byte_array_expr ( bytes : & [ u8 ] ) -> TokenStream {
244
+ pub fn byte_array_expr ( bytes : & [ u8 ] ) -> TokenStream {
248
245
let mut bytes: Vec < _ > = bytes. to_vec ( ) ;
249
246
bytes. push ( 0 ) ;
250
247
quote ! { [ #( #bytes) , * ] }
251
248
}
252
249
253
- pub ( crate ) fn cstr_expr ( mut string : String ) -> TokenStream {
250
+ pub fn cstr_expr ( mut string : String ) -> TokenStream {
254
251
string. push ( '\0' ) ;
255
252
let b = proc_macro2:: Literal :: byte_string ( string. as_bytes ( ) ) ;
256
253
quote ! {
257
254
#b
258
255
}
259
256
}
260
257
261
- pub ( crate ) fn float_expr (
262
- ctx : & BindgenContext ,
263
- f : f64 ,
264
- ) -> Result < TokenStream , ( ) > {
258
+ pub fn float_expr ( ctx : & BindgenContext , f : f64 ) -> Result < TokenStream , ( ) > {
265
259
if f. is_finite ( ) {
266
260
let val = proc_macro2:: Literal :: f64_unsuffixed ( f) ;
267
261
@@ -292,7 +286,7 @@ pub(crate) mod ast_ty {
292
286
Err ( ( ) )
293
287
}
294
288
295
- pub ( crate ) fn arguments_from_signature (
289
+ pub fn arguments_from_signature (
296
290
signature : & FunctionSig ,
297
291
ctx : & BindgenContext ,
298
292
) -> Vec < TokenStream > {
0 commit comments