Skip to content

Commit

Permalink
Remove "implement" feature (#3333)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr authored Oct 30, 2024
1 parent 8a39bcb commit a8e14c7
Show file tree
Hide file tree
Showing 588 changed files with 452,705 additions and 453,197 deletions.
5 changes: 0 additions & 5 deletions crates/libs/bindgen/src/rust/extensions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,3 @@ pub fn gen_mod(_writer: &Writer, namespace: &str) -> TokenStream {
_ => quote!(),
}
}

/// Generates extension code that is subject to the `implement` feature for a specific namespace
pub fn gen_impl(_namespace: &str) -> TokenStream {
TokenStream::new()
}
7 changes: 5 additions & 2 deletions crates/libs/bindgen/src/rust/implements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use super::*;
use metadata::HasAttributes;

pub fn writer(writer: &Writer, def: metadata::TypeDef) -> TokenStream {
if def.kind() != metadata::TypeKind::Interface
|| (!writer.implement && def.has_attribute("ExclusiveToAttribute"))
if !(def.kind() == metadata::TypeKind::Interface
&& (writer.implement || (writer.package && !def.has_attribute("ExclusiveToAttribute"))))
{
return quote! {};
}
Expand Down Expand Up @@ -190,12 +190,15 @@ pub fn writer(writer: &Writer, def: metadata::TypeDef) -> TokenStream {
}
}
#[doc(hidden)]
#[cfg(feature = "std")]
#features
struct #implvtbl_ident<T: #impl_ident> (core::marker::PhantomData<T>);
#[cfg(feature = "std")]
#features
impl<T: #impl_ident> #implvtbl_ident<T> {
const VTABLE: #vtbl_ident = #vtbl_ident::new::<T>();
}
#[cfg(feature = "std")]
#features
impl #type_ident {
pub fn new<'a, T: #impl_ident>(this: &'a T) -> windows_core::ScopedInterface<'a, Self> {
Expand Down
1 change: 1 addition & 0 deletions crates/libs/bindgen/src/rust/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,5 +230,6 @@ fn gen_win_interface(writer: &Writer, def: metadata::TypeDef) -> TokenStream {
has_unknown_base,
));
tokens.combine(&writer.interface_vtbl(def, generics, &constraints, &features));
tokens.combine(&implements::writer(writer, def));
tokens
}
54 changes: 1 addition & 53 deletions crates/libs/bindgen/src/rust/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,26 +113,11 @@ fn gen_package(writer: &Writer) -> Result<()> {

trees.par_iter().try_for_each(|tree| {
let directory = format!("{directory}/{}", tree.namespace.replace('.', "/"));
let mut tokens = namespace(writer, tree);

let tokens_impl = if !writer.sys {
namespace_impl(writer, tree)
} else {
String::new()
};

if !writer.sys && !tokens_impl.is_empty() {
tokens.push_str("#[cfg(feature = \"implement\")]\ncore::include!(\"impl.rs\");\n");
}
let tokens = namespace(writer, tree);

let output = format!("{directory}/mod.rs");
write_to_file(&output, try_format(writer, &tokens))?;

if !writer.sys && !tokens_impl.is_empty() {
let output = format!("{directory}/impl.rs");
write_to_file(&output, try_format(writer, &tokens_impl))?;
}

Ok::<(), Error>(())
})?;

Expand Down Expand Up @@ -248,43 +233,6 @@ fn namespace(writer: &Writer, tree: &Tree) -> String {
}

tokens.combine(&extensions::gen_mod(writer, tree.namespace));

if writer.implement {
tokens.push_str(&namespace_impl(writer, tree));
}

tokens.into_string()
}

fn namespace_impl(writer: &Writer, tree: &Tree) -> String {
let writer = &mut writer.clone();
writer.namespace = tree.namespace;
let mut types = std::collections::BTreeMap::new();

for item in writer.reader.namespace_items(tree.namespace) {
if let metadata::Item::Type(def) = item {
let type_name = def.type_name();
if writer.reader.core_type(type_name).is_some() {
continue;
}
if def.kind() != metadata::TypeKind::Interface {
continue;
}
let tokens = implements::writer(writer, def);

if !tokens.is_empty() {
types.insert(type_name.name(), tokens);
}
}
}

let types = types.values();

let mut tokens = quote! {
#(#types)*
};

tokens.combine(&extensions::gen_impl(tree.namespace));
tokens.into_string()
}

Expand Down
1 change: 0 additions & 1 deletion crates/libs/windows/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ path = "../targets"
default = ["std"]
docs = []
deprecated = []
implement = []
std = ["windows-core/std"]
# generated features
AI = ["Foundation"]
Expand Down
144 changes: 0 additions & 144 deletions crates/libs/windows/src/Windows/AI/MachineLearning/impl.rs

This file was deleted.

Loading

0 comments on commit a8e14c7

Please sign in to comment.