Skip to content

Commit

Permalink
Move VARIANT support to the windows crate (#3282)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr authored Sep 16, 2024
1 parent ddb8c83 commit ff6f56d
Show file tree
Hide file tree
Showing 180 changed files with 20,492 additions and 14,692 deletions.
2 changes: 1 addition & 1 deletion crates/libs/bindgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ where
let output = canonicalize(output)?;

let input = read_input(&input)?;
let reader = metadata::Reader::filter(input, &include, &exclude, &config);
let reader = metadata::Reader::filter(input, &include, &exclude);

match extension(&output) {
"rs" => rust::from_reader(reader, config, &output)?,
Expand Down
8 changes: 1 addition & 7 deletions crates/libs/bindgen/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,6 @@ pub fn type_is_borrowed(ty: &Type) -> bool {
match ty {
Type::TypeDef(row, _) => !type_def_is_blittable(*row),
Type::Name(TypeName::BSTR)
| Type::Name(TypeName::VARIANT)
| Type::Name(TypeName::PROPVARIANT)
| Type::Const(TypeName::PSTR)
| Type::Const(TypeName::PWSTR)
| Type::Object
Expand Down Expand Up @@ -590,8 +588,6 @@ pub fn type_is_blittable(ty: &Type) -> bool {
Type::TypeDef(row, _) => type_def_is_blittable(*row),
Type::String
| Type::Name(TypeName::BSTR)
| Type::Name(TypeName::VARIANT)
| Type::Name(TypeName::PROPVARIANT)
| Type::Object
| Type::Name(TypeName::IUnknown)
| Type::GenericParam(_) => false,
Expand All @@ -606,8 +602,6 @@ fn type_is_copyable(ty: &Type) -> bool {
Type::TypeDef(row, _) => type_def_is_copyable(*row),
Type::String
| Type::Name(TypeName::BSTR)
| Type::Name(TypeName::VARIANT)
| Type::Name(TypeName::PROPVARIANT)
| Type::Object
| Type::Name(TypeName::IUnknown)
| Type::GenericParam(_) => false,
Expand All @@ -623,7 +617,7 @@ pub fn type_def_is_blittable(row: TypeDef) -> bool {
if row.flags().contains(TypeAttributes::WindowsRuntime) {
row.fields().all(|field| field_is_blittable(field, row))
} else {
true
!matches!(row.type_name(), TypeName::VARIANT | TypeName::PROPVARIANT)
}
}
TypeKind::Enum => true,
Expand Down
4 changes: 4 additions & 0 deletions crates/libs/bindgen/src/rust/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ fn gen_clone(
.flags()
.contains(metadata::TypeAttributes::WindowsRuntime)
|| def.class_layout().is_some()
|| matches!(
def.type_name(),
metadata::TypeName::VARIANT | metadata::TypeName::PROPVARIANT
)
{
quote! {}
} else {
Expand Down
14 changes: 0 additions & 14 deletions crates/libs/bindgen/src/rust/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,6 @@ impl Writer {
let crate_name = self.crate_name();
quote! { #crate_name BSTR }
}
metadata::Type::Name(metadata::TypeName::VARIANT) => {
let crate_name = self.crate_name();
quote! { #crate_name VARIANT }
}
metadata::Type::Name(metadata::TypeName::PROPVARIANT) => {
let crate_name = self.crate_name();
quote! { #crate_name PROPVARIANT }
}
metadata::Type::Object => {
if self.sys {
quote! { *mut core::ffi::c_void }
Expand Down Expand Up @@ -271,12 +263,6 @@ impl Writer {
metadata::Type::Name(metadata::TypeName::BSTR) => {
quote! { core::mem::MaybeUninit<windows_core::BSTR> }
}
metadata::Type::Name(metadata::TypeName::VARIANT) => {
quote! { core::mem::MaybeUninit<windows_core::VARIANT> }
}
metadata::Type::Name(metadata::TypeName::PROPVARIANT) => {
quote! { core::mem::MaybeUninit<windows_core::PROPVARIANT> }
}
metadata::Type::Win32Array(kind, len) => {
let name = self.type_abi_name(kind);
let len = Literal::usize_unsuffixed(*len);
Expand Down
Loading

0 comments on commit ff6f56d

Please sign in to comment.