|
1 | 1 | use crate::{alias_map::AliasMap, builder::BindgenOptions, field_map::FieldMap, type_meta::*};
|
2 | 2 | use regex::Regex;
|
3 | 3 | use std::collections::HashSet;
|
4 |
| -use syn::{Abi, ForeignItem, Ident, Item, Meta, MetaNameValue, Pat, ReturnType}; |
| 4 | +use syn::{ForeignItem, Item, Meta, MetaNameValue, Pat, ReturnType}; |
5 | 5 | use crate::type_meta::ExportSymbolNaming::{ExportName, NoMangle};
|
6 | 6 |
|
7 | 7 | enum FnItem {
|
@@ -117,13 +117,13 @@ fn parse_method(item: FnItem, options: &BindgenOptions) -> Option<ExternMethod>
|
117 | 117 |
|
118 | 118 | // check attrs
|
119 | 119 | let mut export_naming = NoMangle;
|
120 |
| - if (!is_foreign_item) { |
| 120 | + if !is_foreign_item { |
121 | 121 | let found = attrs.iter()
|
122 | 122 | .map(|attr| {
|
123 | 123 | let name = &attr.path.segments.last().unwrap().ident;
|
124 |
| - if (name == "no_mangle") { |
| 124 | + if name == "no_mangle" { |
125 | 125 | return Some(NoMangle)
|
126 |
| - } else if (name == "export_name") { |
| 126 | + } else if name == "export_name" { |
127 | 127 | if let Ok(Meta::NameValue(MetaNameValue { lit: syn::Lit::Str(x), .. })) = attr.parse_meta() {
|
128 | 128 | return Some(ExportName(x.value()));
|
129 | 129 | }
|
@@ -342,6 +342,11 @@ pub fn collect_enum(ast: &syn::File, result: &mut Vec<RustEnum>) {
|
342 | 342 | let enum_name = t.ident.to_string();
|
343 | 343 | let mut fields = Vec::new(); // Vec<(String, Option<String>)>
|
344 | 344 |
|
| 345 | + if t.variants.iter().any(|x| !matches!(x.fields, syn::Fields::Unit)) { |
| 346 | + println!("csbindgen can't handle Enum containing any variable with field, so ignore generate, enum_name: {enum_name}"); |
| 347 | + continue; |
| 348 | + } |
| 349 | + |
345 | 350 | for v in &t.variants {
|
346 | 351 | let name = v.ident.to_string();
|
347 | 352 | let mut value = None;
|
|
0 commit comments