Keep annotations on fields

This commit is contained in:
Vadim Petrochenkov
2020-10-27 01:39:15 +03:00
committed by Emilio Cobos Álvarez
parent 62e51b5e33
commit dc12952e19
4 changed files with 10 additions and 1 deletions
+1
View File
@@ -112,6 +112,7 @@ impl EnumVariant {
None => i.to_string(),
},
ty,
annotations: AnnotationSet::load(&field.attrs)?,
documentation: Documentation::load(&field.attrs),
});
}
+4 -1
View File
@@ -2,13 +2,14 @@ use std::io::Write;
use crate::bindgen::cdecl;
use crate::bindgen::config::Config;
use crate::bindgen::ir::{Documentation, Path, Type};
use crate::bindgen::ir::{AnnotationSet, Documentation, Path, Type};
use crate::bindgen::writer::{Source, SourceWriter};
#[derive(Debug, Clone)]
pub struct Field {
pub name: String,
pub ty: Type,
pub annotations: AnnotationSet,
pub documentation: Documentation,
}
@@ -17,6 +18,7 @@ impl Field {
Field {
name,
ty,
annotations: AnnotationSet::new(),
documentation: Documentation::none(),
}
}
@@ -31,6 +33,7 @@ impl Field {
.ok_or_else(|| "field is missing identifier".to_string())?
.to_string(),
ty,
annotations: AnnotationSet::load(&field.attrs)?,
documentation: Documentation::load(&field.attrs),
})
} else {
+2
View File
@@ -88,6 +88,7 @@ impl Struct {
out.push(Field {
name: format!("{}", current),
ty,
annotations: AnnotationSet::load(&field.attrs)?,
documentation: Documentation::load(&field.attrs),
});
current += 1;
@@ -190,6 +191,7 @@ impl Struct {
.map(|field| Field {
name: field.name.clone(),
ty: field.ty.specialize(mappings),
annotations: field.annotations.clone(),
documentation: field.documentation.clone(),
})
.collect(),
+3
View File
@@ -180,6 +180,7 @@ impl Item for Union {
overriden_fields.push(Field {
name: o[i].clone(),
ty: field.ty.clone(),
annotations: field.annotations.clone(),
documentation: field.documentation.clone(),
});
}
@@ -195,6 +196,7 @@ impl Item for Union {
.apply(&field.name, IdentifierType::StructMember)
.into_owned(),
ty: field.ty.clone(),
annotations: field.annotations.clone(),
documentation: field.documentation.clone(),
})
.collect();
@@ -254,6 +256,7 @@ impl Item for Union {
.map(|field| Field {
name: field.name.clone(),
ty: field.ty.specialize(&mappings),
annotations: field.annotations.clone(),
documentation: field.documentation.clone(),
})
.collect(),