Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Arlie Davis committed Jun 17, 2024
1 parent 6faaa9d commit 768b91e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 19 deletions.
29 changes: 16 additions & 13 deletions crates/libs/bindgen/src/rust/extensions/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
use super::*;

/// Helper function for `gen_mod` and `gen_impl`.
///
/// This function generates an `include!(...)` that points into the
/// `src/includes` directory for the `windows` and `windows-sys`
/// crates. This is no longer needed, but is preserved in case it is
/// needed again in the future.
#[allow(dead_code)]
fn include_ext(relative_path: &str) -> TokenStream {
quote! {
core::include!(
Expand All @@ -17,19 +24,15 @@ fn include_ext(relative_path: &str) -> TokenStream {
/// This function allows us to inject code into modules generated by bindgen.
/// This feature is no longer needed but is preserved in case it is needed
/// again in the future.
pub fn gen_mod(writer: &Writer, namespace: &str) -> TokenStream {
if writer.sys {
return quote!();
}

match namespace {
_ => quote!(),
}
pub fn gen_mod(_writer: &Writer, _namespace: &str) -> TokenStream {
TokenStream::new()
}

pub fn gen_impl(namespace: &str) -> TokenStream {
match namespace {
"Windows.Foundation.Collections" => include_ext("Foundation/Collections.rs"),
_ => quote!(),
}
/// Generates implementation extension code for a specific namespace
///
/// This function allows us to inject code into modules generated by bindgen.
/// This feature is no longer needed but is preserved in case it is needed
/// again in the future.
pub fn gen_impl(_namespace: &str) -> TokenStream {
TokenStream::new()
}
Original file line number Diff line number Diff line change
Expand Up @@ -828,4 +828,3 @@ impl<T: windows_core::RuntimeType + 'static> IVectorView_Vtbl<T> {
iid == &<IVectorView<T> as windows_core::Interface>::IID
}
}
core::include!(core::concat!(core::env!("CARGO_MANIFEST_DIR"), "/src/includes/", "Foundation/Collections.rs"));
15 changes: 13 additions & 2 deletions crates/libs/windows/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@
//!
//! This module contains code that extends the functionality of the bindings generated by `bindgen`.
//! It adds inherent impls, trait impls, etc.
//!
//! This module's visibility is `pub(crate)`, not `pub`, because the `extensions` module path is
//! not intended to be directly visible to user code. Associated functions defined within this
//! module tree use the visibility of the types they are associated with, and so the visibility
//! of this module tree does not constrain the visibility of the associated functions. Similarly,
//! trait impls _themselves_ do not have visibility; their visibility is defined by the types and
//! traits used in the trait impl definition.
//!
//! If it becomes necessary to re-export definitions (types, etc.) defined in this module tree,
//! then the right thing to do is to change the visibility (along those module paths) to `pub(crate)`
//! and then to use `pub` for the specific items that will be re-exported.
#[cfg(feature = "Foundation")]
pub mod Foundation;
mod Foundation;
#[cfg(feature = "Win32")]
pub mod Win32;
mod Win32;
1 change: 0 additions & 1 deletion crates/libs/windows/src/includes/Foundation/Collections.rs

This file was deleted.

3 changes: 1 addition & 2 deletions crates/libs/windows/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ extern crate self as windows;

pub use windows_core as core;

#[doc(hidden)]
pub mod extensions;
mod extensions;

include!("Windows/mod.rs");

0 comments on commit 768b91e

Please sign in to comment.