Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,16 @@ jobs:
run: cargo clippy -p test_reference
- name: Clippy test_reference_client
run: cargo clippy -p test_reference_client
- name: Clippy test_reference_default
run: cargo clippy -p test_reference_default
- name: Clippy test_reference_custom
run: cargo clippy -p test_reference_custom
- name: Clippy test_reference_float
run: cargo clippy -p test_reference_float
- name: Clippy test_reference_no_deps
run: cargo clippy -p test_reference_no_deps
- name: Clippy test_reference_no_windows
run: cargo clippy -p test_reference_no_windows
- name: Clippy test_reference_windows
run: cargo clippy -p test_reference_windows
- name: Clippy test_registry
run: cargo clippy -p test_registry
- name: Clippy test_registry_default
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/raw-dylib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,16 @@ jobs:
run: cargo test -p test_reference --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_reference_client
run: cargo test -p test_reference_client --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_reference_default
run: cargo test -p test_reference_default --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_reference_custom
run: cargo test -p test_reference_custom --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_reference_float
run: cargo test -p test_reference_float --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_reference_no_deps
run: cargo test -p test_reference_no_deps --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_reference_no_windows
run: cargo test -p test_reference_no_windows --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_reference_windows
run: cargo test -p test_reference_windows --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_registry
run: cargo test -p test_registry --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_registry_default
Expand Down Expand Up @@ -358,14 +364,14 @@ jobs:
run: cargo test -p windows-result --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows-strings
run: cargo test -p windows-strings --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Clean
run: cargo clean
- name: Test windows-sys
run: cargo test -p windows-sys --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows-targets
run: cargo test -p windows-targets --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows-version
run: cargo test -p windows-version --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Clean
run: cargo clean
- name: Test windows_aarch64_gnullvm
run: cargo test -p windows_aarch64_gnullvm --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows_aarch64_msvc
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,16 @@ jobs:
run: cargo test -p test_reference --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_reference_client
run: cargo test -p test_reference_client --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_reference_default
run: cargo test -p test_reference_default --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_reference_custom
run: cargo test -p test_reference_custom --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_reference_float
run: cargo test -p test_reference_float --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_reference_no_deps
run: cargo test -p test_reference_no_deps --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_reference_no_windows
run: cargo test -p test_reference_no_windows --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_reference_windows
run: cargo test -p test_reference_windows --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_registry
run: cargo test -p test_registry --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test test_registry_default
Expand Down Expand Up @@ -355,14 +361,14 @@ jobs:
run: cargo test -p windows-result --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows-strings
run: cargo test -p windows-strings --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Clean
run: cargo clean
- name: Test windows-sys
run: cargo test -p windows-sys --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows-targets
run: cargo test -p windows-targets --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows-version
run: cargo test -p windows-version --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Clean
run: cargo clean
- name: Test windows_aarch64_gnullvm
run: cargo test -p windows_aarch64_gnullvm --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows_aarch64_msvc
Expand Down
13 changes: 8 additions & 5 deletions crates/libs/bindgen/src/references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ impl Default for ReferenceStage {

impl ReferenceStage {
#[track_caller]
pub fn parse(arg: &str) -> Self {
pub fn parse(mut arg: &str) -> Self {
if arg == "windows" {
arg = "windows,skip-root,Windows"
}

let arg: Vec<_> = arg.split(',').collect();

if arg.len() != 3 {
Expand Down Expand Up @@ -60,7 +64,7 @@ impl ReferenceStyle {
#[derive(Debug)]
pub struct Reference {
pub name: String, // crate name like "windows"
pub types: TypeMap, // what this reference provides
pub filter: Filter, // what this reference provides
pub style: ReferenceStyle, // how to generate the type path
}

Expand All @@ -74,12 +78,11 @@ impl References {
.into_iter()
.map(|stage| {
let filter = Filter::new(reader, &[&stage.path], &[]);
let types = TypeMap::filter(reader, &filter, &References::default());

Reference {
name: stage.name,
style: stage.style,
types,
filter,
}
})
.collect(),
Expand All @@ -89,6 +92,6 @@ impl References {
pub fn contains(&self, name: TypeName) -> Option<&Reference> {
self.0
.iter()
.find(|reference| reference.types.contains_key(&name))
.find(|reference| reference.filter.includes_type_name(name))
}
}
67 changes: 59 additions & 8 deletions crates/tests/bindgen/src/reference_dependent_flat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,62 @@

pub mod Windows {
pub mod Foundation {
windows_core::imp::define_interface!(
IClosable,
IClosable_Vtbl,
0x30d5a829_7fa4_4026_83bb_d75bae4ea99e
);
impl windows_core::RuntimeType for IClosable {
const SIGNATURE: windows_core::imp::ConstBuffer =
windows_core::imp::ConstBuffer::for_interface::<Self>();
}
windows_core::imp::interface_hierarchy!(
IClosable,
windows_core::IUnknown,
windows_core::IInspectable
);
impl IClosable {
pub fn Close(&self) -> windows_core::Result<()> {
let this = self;
unsafe {
(windows_core::Interface::vtable(this).Close)(windows_core::Interface::as_raw(
this,
))
.ok()
}
}
}
impl windows_core::RuntimeName for IClosable {
const NAME: &'static str = "Windows.Foundation.IClosable";
}
pub trait IClosable_Impl: windows_core::IUnknownImpl {
fn Close(&self) -> windows_core::Result<()>;
}
impl IClosable_Vtbl {
pub const fn new<Identity: IClosable_Impl, const OFFSET: isize>() -> Self {
unsafe extern "system" fn Close<Identity: IClosable_Impl, const OFFSET: isize>(
this: *mut core::ffi::c_void,
) -> windows_core::HRESULT {
unsafe {
let this: &Identity =
&*((this as *const *const ()).offset(OFFSET) as *const Identity);
IClosable_Impl::Close(this).into()
}
}
Self {
base__: windows_core::IInspectable_Vtbl::new::<Identity, IClosable, OFFSET>(),
Close: Close::<Identity, OFFSET>,
}
}
pub fn matches(iid: &windows_core::GUID) -> bool {
iid == &<IClosable as windows_core::Interface>::IID
}
}
#[repr(C)]
pub struct IClosable_Vtbl {
pub base__: windows_core::IInspectable_Vtbl,
pub Close: unsafe extern "system" fn(*mut core::ffi::c_void) -> windows_core::HRESULT,
}
windows_core::imp::define_interface!(
IMemoryBuffer,
IMemoryBuffer_Vtbl,
Expand All @@ -22,10 +78,7 @@ pub mod Windows {
windows_core::IUnknown,
windows_core::IInspectable
);
windows_core::imp::required_hierarchy!(
IMemoryBuffer,
crate::reference_dependency_flat::IClosable
);
windows_core::imp::required_hierarchy!(IMemoryBuffer, IClosable);
impl IMemoryBuffer {
pub fn CreateReference(
&self,
Expand All @@ -42,9 +95,7 @@ pub mod Windows {
}
}
pub fn Close(&self) -> windows_core::Result<()> {
let this = &windows_core::Interface::cast::<
crate::reference_dependency_flat::IClosable,
>(self)?;
let this = &windows_core::Interface::cast::<IClosable>(self)?;
unsafe {
(windows_core::Interface::vtable(this).Close)(windows_core::Interface::as_raw(
this,
Expand All @@ -56,7 +107,7 @@ pub mod Windows {
impl windows_core::RuntimeName for IMemoryBuffer {
const NAME: &'static str = "Windows.Foundation.IMemoryBuffer";
}
pub trait IMemoryBuffer_Impl: crate::reference_dependency_flat::IClosable_Impl {
pub trait IMemoryBuffer_Impl: IClosable_Impl {
fn CreateReference(
&self,
) -> windows_core::Result<crate::reference_dependency_flat::IMemoryBufferReference>;
Expand Down
69 changes: 59 additions & 10 deletions crates/tests/bindgen/src/reference_dependent_full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,62 @@

pub mod Windows {
pub mod Foundation {
windows_core::imp::define_interface!(
IClosable,
IClosable_Vtbl,
0x30d5a829_7fa4_4026_83bb_d75bae4ea99e
);
impl windows_core::RuntimeType for IClosable {
const SIGNATURE: windows_core::imp::ConstBuffer =
windows_core::imp::ConstBuffer::for_interface::<Self>();
}
windows_core::imp::interface_hierarchy!(
IClosable,
windows_core::IUnknown,
windows_core::IInspectable
);
impl IClosable {
pub fn Close(&self) -> windows_core::Result<()> {
let this = self;
unsafe {
(windows_core::Interface::vtable(this).Close)(windows_core::Interface::as_raw(
this,
))
.ok()
}
}
}
impl windows_core::RuntimeName for IClosable {
const NAME: &'static str = "Windows.Foundation.IClosable";
}
pub trait IClosable_Impl: windows_core::IUnknownImpl {
fn Close(&self) -> windows_core::Result<()>;
}
impl IClosable_Vtbl {
pub const fn new<Identity: IClosable_Impl, const OFFSET: isize>() -> Self {
unsafe extern "system" fn Close<Identity: IClosable_Impl, const OFFSET: isize>(
this: *mut core::ffi::c_void,
) -> windows_core::HRESULT {
unsafe {
let this: &Identity =
&*((this as *const *const ()).offset(OFFSET) as *const Identity);
IClosable_Impl::Close(this).into()
}
}
Self {
base__: windows_core::IInspectable_Vtbl::new::<Identity, IClosable, OFFSET>(),
Close: Close::<Identity, OFFSET>,
}
}
pub fn matches(iid: &windows_core::GUID) -> bool {
iid == &<IClosable as windows_core::Interface>::IID
}
}
#[repr(C)]
pub struct IClosable_Vtbl {
pub base__: windows_core::IInspectable_Vtbl,
pub Close: unsafe extern "system" fn(*mut core::ffi::c_void) -> windows_core::HRESULT,
}
windows_core::imp::define_interface!(
IMemoryBuffer,
IMemoryBuffer_Vtbl,
Expand All @@ -22,10 +78,7 @@ pub mod Windows {
windows_core::IUnknown,
windows_core::IInspectable
);
windows_core::imp::required_hierarchy!(
IMemoryBuffer,
crate::reference_dependency_full::Windows::Foundation::IClosable
);
windows_core::imp::required_hierarchy!(IMemoryBuffer, IClosable);
impl IMemoryBuffer {
pub fn CreateReference(
&self,
Expand All @@ -43,9 +96,7 @@ pub mod Windows {
}
}
pub fn Close(&self) -> windows_core::Result<()> {
let this = &windows_core::Interface::cast::<
crate::reference_dependency_full::Windows::Foundation::IClosable,
>(self)?;
let this = &windows_core::Interface::cast::<IClosable>(self)?;
unsafe {
(windows_core::Interface::vtable(this).Close)(windows_core::Interface::as_raw(
this,
Expand All @@ -57,9 +108,7 @@ pub mod Windows {
impl windows_core::RuntimeName for IMemoryBuffer {
const NAME: &'static str = "Windows.Foundation.IMemoryBuffer";
}
pub trait IMemoryBuffer_Impl:
crate::reference_dependency_full::Windows::Foundation::IClosable_Impl
{
pub trait IMemoryBuffer_Impl: IClosable_Impl {
fn CreateReference(
&self,
) -> windows_core::Result<
Expand Down
Loading