Skip to content

Commit

Permalink
Merge branch 'master' into rafael/index-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
riverar committed Feb 13, 2025
2 parents 5989069 + c9177f7 commit c2d28bc
Show file tree
Hide file tree
Showing 282 changed files with 7,006 additions and 12,487 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ jobs:
run: cargo clippy -p windows
- name: Clippy windows-bindgen
run: cargo clippy -p windows-bindgen
- name: Clippy windows-collections
run: cargo clippy -p windows-collections
- name: Clippy windows-core
run: cargo clippy -p windows-core
- name: Clippy windows-implement
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/msrv-windows-collections.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: windows-collections

on:
pull_request:
paths-ignore:
- '.github/ISSUE_TEMPLATE/**'
- 'web/**'
push:
paths-ignore:
- '.github/ISSUE_TEMPLATE/**'
- 'web/**'
branches:
- master

jobs:
check:
strategy:
matrix:
rust: [1.74.0, stable, nightly]
runs-on:
- windows-2022
- ubuntu-22.04
runs-on: ${{ matrix.runs-on }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Prepare
run: rustup update --no-self-update ${{ matrix.rust }} && rustup default ${{ matrix.rust }}
- name: Check
run: cargo check -p windows-collections --all-features
- name: Check Default Features
run: cargo check -p windows-collections
2 changes: 2 additions & 0 deletions .github/workflows/no-default-features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
run: cargo check -p windows --no-default-features
- name: Check windows-bindgen
run: cargo check -p windows-bindgen --no-default-features
- name: Check windows-collections
run: cargo check -p windows-collections --no-default-features
- name: Check windows-core
run: cargo check -p windows-core --no-default-features
- name: Check windows-implement
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/raw-dylib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ jobs:
run: cargo test -p windows --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows-bindgen
run: cargo test -p windows-bindgen --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows-collections
run: cargo test -p windows-collections --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows-core
run: cargo test -p windows-core --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows-implement
Expand All @@ -362,10 +364,10 @@ jobs:
run: cargo test -p windows_aarch64_msvc --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows_i686_gnu
run: cargo test -p windows_i686_gnu --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows_i686_gnullvm
run: cargo test -p windows_i686_gnullvm --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Clean
run: cargo clean
- name: Test windows_i686_gnullvm
run: cargo test -p windows_i686_gnullvm --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows_i686_msvc
run: cargo test -p windows_i686_msvc --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows_x86_64_gnu
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ jobs:
run: cargo test -p windows --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows-bindgen
run: cargo test -p windows-bindgen --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows-collections
run: cargo test -p windows-collections --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows-core
run: cargo test -p windows-core --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows-implement
Expand All @@ -359,10 +361,10 @@ jobs:
run: cargo test -p windows_aarch64_msvc --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows_i686_gnu
run: cargo test -p windows_i686_gnu --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows_i686_gnullvm
run: cargo test -p windows_i686_gnullvm --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Clean
run: cargo clean
- name: Test windows_i686_gnullvm
run: cargo test -p windows_i686_gnullvm --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows_i686_msvc
run: cargo test -p windows_i686_msvc --target ${{ matrix.target }} ${{ matrix.etc }}
- name: Test windows_x86_64_gnu
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ unexpected_cfgs = { level = "warn", check-cfg = ['cfg(windows_raw_dylib, windows
cppwinrt = { path = "crates/libs/cppwinrt" }
windows = { path = "crates/libs/windows" }
windows-bindgen = { path = "crates/libs/bindgen" }
windows-collections = { path = "crates/libs/collections" }
windows-core = { path = "crates/libs/core" }
windows-link = { path = "crates/libs/link" }
windows-registry = { path = "crates/libs/registry" }
windows-result = { path = "crates/libs/result" }
windows-strings = { path = "crates/libs/strings" }
windows-sys = { path = "crates/libs/sys" }
windows-targets = { path = "crates/libs/targets" }
windows-link = { path = "crates/libs/link" }
windows-version = { path = "crates/libs/version" }
helpers = { path = "crates/libs/helpers" }
7 changes: 2 additions & 5 deletions crates/libs/bindgen/src/tables/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@ impl Attribute {
}

pub fn name(&self) -> &'static str {
let AttributeType::MemberRef(ctor) = self.ty();
let MemberRefParent::TypeRef(ty) = ctor.parent();
ty.name()
self.ty().parent().name()
}

pub fn args(&self) -> Vec<(&'static str, Value)> {
let AttributeType::MemberRef(member) = self.ty();
let mut sig = member.blob(2);
let mut sig = self.ty().signature();
let mut values = self.blob(2);
let prolog = values.read_u16();
std::debug_assert_eq!(prolog, 1);
Expand Down
4 changes: 4 additions & 0 deletions crates/libs/bindgen/src/tables/method_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ impl MethodDef {
self.list(5)
}

pub fn parent(&self) -> MemberRefParent {
MemberRefParent::TypeDef(self.file().parent(5, *self))
}

pub fn impl_map(&self) -> Option<ImplMap> {
self.file()
.equal_range(1, MemberForwarded::MethodDef(*self).encode())
Expand Down
8 changes: 5 additions & 3 deletions crates/libs/bindgen/src/type_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl TypeMap {
ty.combine(&mut item_dependencies);
}

if item_dependencies.excluded(filter) {
if item_dependencies.excluded(filter, references) {
continue;
}

Expand Down Expand Up @@ -101,7 +101,9 @@ impl TypeMap {
})
}

fn excluded(&self, filter: &Filter) -> bool {
self.0.iter().any(|(tn, _)| filter.excludes_type_name(*tn))
fn excluded(&self, filter: &Filter, references: &References) -> bool {
self.0
.iter()
.any(|(tn, _)| filter.excludes_type_name(*tn) && references.contains(*tn).is_none())
}
}
4 changes: 2 additions & 2 deletions crates/libs/bindgen/src/types/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Class {
return (Cfg::default(), quote! {});
}

let cfg = Cfg::new(self.def, &self.dependencies());
let cfg = Cfg::new(self.def, &self.dependencies(), writer);
let tokens = cfg.write(writer, false);
(cfg, tokens)
}
Expand Down Expand Up @@ -90,7 +90,7 @@ impl Class {
let interface_type = interface.write_name(writer);

let cfg = if writer.config.package {
class_cfg.difference(interface.def, &interface.dependencies()).write(writer, false)
class_cfg.difference(interface.def, &interface.dependencies(), writer).write(writer, false)
} else {
quote! {}
};
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/bindgen/src/types/cpp_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl CppConst {
return quote! {};
}

Cfg::new(self.field, &self.dependencies()).write(writer, false)
Cfg::new(self.field, &self.dependencies(), writer).write(writer, false)
}

pub fn write(&self, writer: &Writer) -> TokenStream {
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/bindgen/src/types/cpp_delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl CppDelegate {
return quote! {};
}

Cfg::new(self.def, &self.dependencies()).write(writer, false)
Cfg::new(self.def, &self.dependencies(), writer).write(writer, false)
}

pub fn write(&self, writer: &Writer) -> TokenStream {
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/bindgen/src/types/cpp_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl CppFn {
return quote! {};
}

Cfg::new(self.method, &self.dependencies()).write(writer, false)
Cfg::new(self.method, &self.dependencies(), writer).write(writer, false)
}

pub fn write(&self, writer: &Writer) -> TokenStream {
Expand Down
6 changes: 3 additions & 3 deletions crates/libs/bindgen/src/types/cpp_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl CppInterface {
return (Cfg::default(), quote! {});
}

let cfg = Cfg::new(self.def, &self.dependencies());
let cfg = Cfg::new(self.def, &self.dependencies(), writer);
let tokens = cfg.write(writer, false);
(cfg, tokens)
}
Expand Down Expand Up @@ -83,7 +83,7 @@ impl CppInterface {

let methods = methods.iter().map(|method| match method {
CppMethodOrName::Method(method) => {
let method_cfg = class_cfg.difference(method.def, &method.dependencies);
let method_cfg = class_cfg.difference(method.def, &method.dependencies, writer);
let yes = method_cfg.write(writer, false);

let name = names.add(method.def);
Expand Down Expand Up @@ -238,7 +238,7 @@ impl CppInterface {
}
});

Cfg::new(self.def, &dependencies).write(writer, false)
Cfg::new(self.def, &dependencies, writer).write(writer, false)
} else {
quote! {}
};
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/bindgen/src/types/cpp_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl CppMethod {
}

parent
.difference(self.def, &self.dependencies)
.difference(self.def, &self.dependencies, writer)
.write(writer, not)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/libs/bindgen/src/types/cpp_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl CppStruct {
return quote! {};
}

Cfg::new(self.def, &self.dependencies()).write(writer, false)
Cfg::new(self.def, &self.dependencies(), writer).write(writer, false)
}

pub fn write(&self, writer: &Writer) -> TokenStream {
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/bindgen/src/types/delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ impl Delegate {
return quote! {};
}

Cfg::new(self.def, &self.dependencies()).write(writer, false)
Cfg::new(self.def, &self.dependencies(), writer).write(writer, false)
}

pub fn write(&self, writer: &Writer) -> TokenStream {
Expand Down
6 changes: 3 additions & 3 deletions crates/libs/bindgen/src/types/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl Interface {
return (Cfg::default(), quote! {});
}

let cfg = Cfg::new(self.def, &self.dependencies());
let cfg = Cfg::new(self.def, &self.dependencies(), writer);
let tokens = cfg.write(writer, false);
(cfg, tokens)
}
Expand Down Expand Up @@ -102,7 +102,7 @@ impl Interface {
let name = virtual_names.add(method.def);
let vtbl = method.write_abi(writer, false);

let method_cfg = class_cfg.difference(method.def, &method.dependencies);
let method_cfg = class_cfg.difference(method.def, &method.dependencies, writer);
let yes = method_cfg.write(writer, false);

if yes.is_empty() {
Expand Down Expand Up @@ -352,7 +352,7 @@ impl Interface {
.iter()
.for_each(|interface| combine(interface, &mut dependencies, writer));

Cfg::new(self.def, &dependencies).write(writer, false)
Cfg::new(self.def, &dependencies, writer).write(writer, false)
} else {
quote! {}
};
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/bindgen/src/types/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl Method {
}

parent
.difference(self.def, &self.dependencies)
.difference(self.def, &self.dependencies, writer)
.write(writer, not)
}

Expand Down
27 changes: 27 additions & 0 deletions crates/libs/bindgen/src/winmd/codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,26 @@ macro_rules! code {
}

code! { AttributeType(3)
(MethodDef, 2)
(MemberRef, 3)
}

impl AttributeType {
pub fn parent(&self) -> MemberRefParent {
match self {
Self::MethodDef(row) => row.parent(),
Self::MemberRef(row) => row.parent(),
}
}

pub fn signature(&self) -> Blob {
match self {
Self::MethodDef(row) => row.blob(4),
Self::MemberRef(row) => row.blob(2),
}
}
}

code! { HasAttribute(5)
(MethodDef, 0)
(Field, 1)
Expand All @@ -62,9 +79,19 @@ code! { MemberForwarded(1)
}

code! { MemberRefParent(3)
(TypeDef, 0)
(TypeRef, 1)
}

impl MemberRefParent {
pub fn name(&self) -> &'static str {
match self {
Self::TypeDef(row) => row.name(),
Self::TypeRef(row) => row.name(),
}
}
}

code! { TypeDefOrRef(2)
(TypeDef, 0)
(TypeRef, 1)
Expand Down
13 changes: 13 additions & 0 deletions crates/libs/bindgen/src/winmd/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,19 @@ impl File {
RowIterator::new(self, first..last)
}

pub(crate) fn parent<P: AsRow, C: AsRow>(&'static self, column: usize, child: C) -> P {
P::from_row(Row::new(
self,
self.upper_bound_of(
P::TABLE,
0,
self.tables[P::TABLE].len,
column,
child.index() + 1,
) - 1,
))
}

fn lower_bound_of(
&self,
table: usize,
Expand Down
23 changes: 18 additions & 5 deletions crates/libs/bindgen/src/writer/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,31 @@ pub struct Cfg {
}

impl Cfg {
pub fn new<R: HasAttributes>(row: R, dependencies: &TypeMap) -> Self {
let features: BTreeSet<&'static str> =
dependencies.keys().map(|tn| tn.namespace()).collect();
pub fn new<R: HasAttributes>(row: R, dependencies: &TypeMap, writer: &Writer) -> Self {
let features: BTreeSet<&'static str> = dependencies
.keys()
.filter_map(|tn| {
if writer.config.types.contains_key(tn) {
Some(tn.namespace())
} else {
None
}
})
.collect();

Self {
features,
deprecated: row.has_attribute("DeprecatedAttribute"),
}
}

pub fn difference<R: HasAttributes>(&self, row: R, dependencies: &TypeMap) -> Self {
let mut difference = Self::new(row, dependencies);
pub fn difference<R: HasAttributes>(
&self,
row: R,
dependencies: &TypeMap,
writer: &Writer,
) -> Self {
let mut difference = Self::new(row, dependencies, writer);

for feature in &self.features {
difference.features.remove(feature);
Expand Down
Loading

0 comments on commit c2d28bc

Please sign in to comment.