File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 186
186
* The documentation of the generated ` type ` aliases now matches the comments
187
187
of their ` typedef ` counterparts instead of using the comments of the aliased
188
188
types.
189
+
189
190
## Removed
190
191
* The following deprecated flags were removed: ` --use-msvc-mangling ` ,
191
192
` --rustfmt-bindings ` and ` --size_t-is-usize ` .
192
193
* The ` --no-rustfmt-bindings ` flag was removed in favor of ` --formatter=none ` .
193
194
* The ` Bindings::emit_warnings ` and ` Bindings::warnings ` methods were removed
194
195
in favor of ` --emit-diagnostics ` .
196
+ * Bindgen no longer generates C string constants that cannot be represented as
197
+ byte slices.
195
198
196
199
## Fixed
197
200
Original file line number Diff line number Diff line change @@ -2104,6 +2104,7 @@ pub(crate) fn extract_clang_version() -> String {
2104
2104
#[ derive( Debug ) ]
2105
2105
pub ( crate ) struct EvalResult {
2106
2106
x : CXEvalResult ,
2107
+ ty : Type ,
2107
2108
}
2108
2109
2109
2110
impl EvalResult {
@@ -2131,6 +2132,7 @@ impl EvalResult {
2131
2132
}
2132
2133
Some ( EvalResult {
2133
2134
x : unsafe { clang_Cursor_Evaluate ( cursor. x ) } ,
2135
+ ty : cursor. cur_type ( ) . canonical_type ( ) ,
2134
2136
} )
2135
2137
}
2136
2138
@@ -2177,13 +2179,22 @@ impl EvalResult {
2177
2179
/// Evaluates the expression as a literal string, that may or may not be
2178
2180
/// valid utf-8.
2179
2181
pub ( crate ) fn as_literal_string ( & self ) -> Option < Vec < u8 > > {
2180
- match self . kind ( ) {
2181
- CXEval_StrLiteral => {
2182
+ if self . kind ( ) != CXEval_StrLiteral {
2183
+ return None ;
2184
+ }
2185
+
2186
+ let char_ty = self . ty . pointee_type ( ) . or_else ( || self . ty . elem_type ( ) ) ?;
2187
+ match char_ty. kind ( ) {
2188
+ CXType_Char_S | CXType_SChar | CXType_Char_U | CXType_UChar => {
2182
2189
let ret = unsafe {
2183
2190
CStr :: from_ptr ( clang_EvalResult_getAsStr ( self . x ) )
2184
2191
} ;
2185
2192
Some ( ret. to_bytes ( ) . to_vec ( ) )
2186
2193
}
2194
+ // FIXME: Support generating these.
2195
+ CXType_Char16 => None ,
2196
+ CXType_Char32 => None ,
2197
+ CXType_WChar => None ,
2187
2198
_ => None ,
2188
2199
}
2189
2200
}
You can’t perform that action at this time.
0 commit comments