Skip to content

Commit 4aef05d

Browse files
authored
fix: Eliminate the dependency on paste (#528)
1 parent 5328b23 commit 4aef05d

File tree

4 files changed

+53
-67
lines changed

4 files changed

+53
-67
lines changed

Cargo.lock

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

platforms/android/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,3 @@ accesskit_consumer = { version = "0.27.0", path = "../../consumer" }
2020
jni = "0.21.1"
2121
log = "0.4.17"
2222
once_cell = "1.17.1"
23-
paste = "1.0.12"

platforms/windows/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ targets = []
1919
accesskit = { version = "0.18.0", path = "../../common" }
2020
accesskit_consumer = { version = "0.27.0", path = "../../consumer" }
2121
hashbrown = { version = "0.15", default-features = false, features = ["default-hasher"] }
22-
paste = "1.0"
2322
static_assertions = "1.1.0"
2423
windows-core = "0.58.0"
2524

platforms/windows/src/node.rs

Lines changed: 53 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use accesskit::{
1515
Toggled,
1616
};
1717
use accesskit_consumer::{FilterResult, Node, TreeState};
18-
use paste::paste;
1918
use std::sync::{atomic::Ordering, Arc, Weak};
2019
use windows::{
2120
core::*,
@@ -811,11 +810,11 @@ impl IRawElementProviderFragmentRoot_Impl for PlatformNode_Impl {
811810
}
812811

813812
macro_rules! properties {
814-
($(($base_id:ident, $m:ident)),+) => {
813+
($(($id:ident, $m:ident)),+) => {
815814
impl NodeWrapper<'_> {
816815
fn get_property_value(&self, property_id: UIA_PROPERTY_ID) -> Variant {
817816
match property_id {
818-
$(paste! { [< UIA_ $base_id PropertyId>] } => {
817+
$($id => {
819818
self.$m().into()
820819
})*
821820
_ => Variant::empty()
@@ -834,7 +833,7 @@ macro_rules! properties {
834833
self.enqueue_property_change(
835834
queue,
836835
element,
837-
paste! { [<UIA_ $base_id PropertyId>] },
836+
$id,
838837
old_value.into(),
839838
new_value.into(),
840839
);
@@ -846,8 +845,8 @@ macro_rules! properties {
846845
}
847846

848847
macro_rules! patterns {
849-
($(($base_pattern_id:ident, $is_supported:ident, (
850-
$(($base_property_id:ident, $getter:ident, $com_type:ident)),*
848+
($(($pattern_id:ident, $provider_interface:ident, $provider_interface_impl:ident, $is_supported:ident, (
849+
$(($property_id:ident, $com_getter:ident, $getter:ident, $com_type:ident)),*
851850
), (
852851
$($extra_trait_method:item),*
853852
))),+) => {
@@ -856,11 +855,10 @@ macro_rules! patterns {
856855
self.resolve(|node| {
857856
let wrapper = NodeWrapper(&node);
858857
match pattern_id {
859-
$(paste! { [< UIA_ $base_pattern_id PatternId>] } => {
858+
$($pattern_id => {
860859
if wrapper.$is_supported() {
861860
// SAFETY: We know we're running inside a full COM implementation.
862-
let intermediate: paste! { [< I $base_pattern_id Provider>] } =
863-
unsafe { self.cast() }?;
861+
let intermediate: $provider_interface = unsafe { self.cast() }?;
864862
return intermediate.cast();
865863
}
866864
})*
@@ -885,7 +883,7 @@ macro_rules! patterns {
885883
self.enqueue_property_change(
886884
queue,
887885
element,
888-
paste! { [<UIA_ $base_pattern_id $base_property_id PropertyId>] },
886+
$property_id,
889887
old_value.into(),
890888
new_value.into(),
891889
);
@@ -894,58 +892,56 @@ macro_rules! patterns {
894892
})*
895893
}
896894
}
897-
paste! {
898-
$(#[allow(non_snake_case)]
899-
impl [< I $base_pattern_id Provider_Impl>] for PlatformNode_Impl {
900-
$(fn $base_property_id(&self) -> Result<$com_type> {
901-
self.resolve(|node| {
902-
let wrapper = NodeWrapper(&node);
903-
Ok(wrapper.$getter().into())
904-
})
905-
})*
906-
$($extra_trait_method)*
895+
$(#[allow(non_snake_case)]
896+
impl $provider_interface_impl for PlatformNode_Impl {
897+
$(fn $com_getter(&self) -> Result<$com_type> {
898+
self.resolve(|node| {
899+
let wrapper = NodeWrapper(&node);
900+
Ok(wrapper.$getter().into())
901+
})
907902
})*
908-
}
903+
$($extra_trait_method)*
904+
})*
909905
};
910906
}
911907

912908
properties! {
913-
(ControlType, control_type),
914-
(LocalizedControlType, localized_control_type),
915-
(Name, name),
916-
(FullDescription, description),
917-
(HelpText, placeholder),
918-
(IsContentElement, is_content_element),
919-
(IsControlElement, is_content_element),
920-
(IsEnabled, is_enabled),
921-
(IsKeyboardFocusable, is_focusable),
922-
(HasKeyboardFocus, is_focused),
923-
(LiveSetting, live_setting),
924-
(AutomationId, automation_id),
925-
(ClassName, class_name),
926-
(Orientation, orientation),
927-
(IsRequiredForForm, is_required),
928-
(IsPassword, is_password),
929-
(PositionInSet, position_in_set),
930-
(SizeOfSet, size_of_set)
909+
(UIA_ControlTypePropertyId, control_type),
910+
(UIA_LocalizedControlTypePropertyId, localized_control_type),
911+
(UIA_NamePropertyId, name),
912+
(UIA_FullDescriptionPropertyId, description),
913+
(UIA_HelpTextPropertyId, placeholder),
914+
(UIA_IsContentElementPropertyId, is_content_element),
915+
(UIA_IsControlElementPropertyId, is_content_element),
916+
(UIA_IsEnabledPropertyId, is_enabled),
917+
(UIA_IsKeyboardFocusablePropertyId, is_focusable),
918+
(UIA_HasKeyboardFocusPropertyId, is_focused),
919+
(UIA_LiveSettingPropertyId, live_setting),
920+
(UIA_AutomationIdPropertyId, automation_id),
921+
(UIA_ClassNamePropertyId, class_name),
922+
(UIA_OrientationPropertyId, orientation),
923+
(UIA_IsRequiredForFormPropertyId, is_required),
924+
(UIA_IsPasswordPropertyId, is_password),
925+
(UIA_PositionInSetPropertyId, position_in_set),
926+
(UIA_SizeOfSetPropertyId, size_of_set)
931927
}
932928

933929
patterns! {
934-
(Toggle, is_toggle_pattern_supported, (
935-
(ToggleState, toggle_state, ToggleState)
930+
(UIA_TogglePatternId, IToggleProvider, IToggleProvider_Impl, is_toggle_pattern_supported, (
931+
(UIA_ToggleToggleStatePropertyId, ToggleState, toggle_state, ToggleState)
936932
), (
937933
fn Toggle(&self) -> Result<()> {
938934
self.click()
939935
}
940936
)),
941-
(Invoke, is_invoke_pattern_supported, (), (
937+
(UIA_InvokePatternId, IInvokeProvider, IInvokeProvider_Impl, is_invoke_pattern_supported, (), (
942938
fn Invoke(&self) -> Result<()> {
943939
self.click()
944940
}
945941
)),
946-
(Value, is_value_pattern_supported, (
947-
(Value, value, BSTR),
948-
(IsReadOnly, is_read_only, BOOL)
942+
(UIA_ValuePatternId, IValueProvider, IValueProvider_Impl, is_value_pattern_supported, (
943+
(UIA_ValueValuePropertyId, Value, value, BSTR),
944+
(UIA_ValueIsReadOnlyPropertyId, IsReadOnly, is_read_only, BOOL)
949945
), (
950946
fn SetValue(&self, value: &PCWSTR) -> Result<()> {
951947
self.do_action(|| {
@@ -954,21 +950,21 @@ patterns! {
954950
})
955951
}
956952
)),
957-
(RangeValue, is_range_value_pattern_supported, (
958-
(Value, numeric_value, f64),
959-
(IsReadOnly, is_read_only, BOOL),
960-
(Minimum, min_numeric_value, f64),
961-
(Maximum, max_numeric_value, f64),
962-
(SmallChange, numeric_value_step, f64),
963-
(LargeChange, numeric_value_jump, f64)
953+
(UIA_RangeValuePatternId, IRangeValueProvider, IRangeValueProvider_Impl, is_range_value_pattern_supported, (
954+
(UIA_RangeValueValuePropertyId, Value, numeric_value, f64),
955+
(UIA_RangeValueIsReadOnlyPropertyId, IsReadOnly, is_read_only, BOOL),
956+
(UIA_RangeValueMinimumPropertyId, Minimum, min_numeric_value, f64),
957+
(UIA_RangeValueMaximumPropertyId, Maximum, max_numeric_value, f64),
958+
(UIA_RangeValueSmallChangePropertyId, SmallChange, numeric_value_step, f64),
959+
(UIA_RangeValueLargeChangePropertyId, LargeChange, numeric_value_jump, f64)
964960
), (
965961
fn SetValue(&self, value: f64) -> Result<()> {
966962
self.do_action(|| {
967963
(Action::SetValue, Some(ActionData::NumericValue(value)))
968964
})
969965
}
970966
)),
971-
(SelectionItem, is_selection_item_pattern_supported, (), (
967+
(UIA_SelectionItemPatternId, ISelectionItemProvider, ISelectionItemProvider_Impl, is_selection_item_pattern_supported, (), (
972968
fn IsSelected(&self) -> Result<BOOL> {
973969
self.resolve(|node| {
974970
let wrapper = NodeWrapper(&node);
@@ -998,9 +994,9 @@ patterns! {
998994
})
999995
}
1000996
)),
1001-
(Selection, is_selection_pattern_supported, (
1002-
(CanSelectMultiple, is_multiselectable, BOOL),
1003-
(IsSelectionRequired, is_required, BOOL)
997+
(UIA_SelectionPatternId, ISelectionProvider, ISelectionProvider_Impl, is_selection_pattern_supported, (
998+
(UIA_SelectionCanSelectMultiplePropertyId, CanSelectMultiple, is_multiselectable, BOOL),
999+
(UIA_SelectionIsSelectionRequiredPropertyId, IsSelectionRequired, is_required, BOOL)
10041000
), (
10051001
fn GetSelection(&self) -> Result<*mut SAFEARRAY> {
10061002
self.resolve(|node| {
@@ -1015,7 +1011,7 @@ patterns! {
10151011
})
10161012
}
10171013
)),
1018-
(Text, is_text_pattern_supported, (), (
1014+
(UIA_TextPatternId, ITextProvider, ITextProvider_Impl, is_text_pattern_supported, (), (
10191015
fn GetSelection(&self) -> Result<*mut SAFEARRAY> {
10201016
self.resolve_for_text_pattern(|node| {
10211017
if let Some(range) = node.text_selection() {

0 commit comments

Comments
 (0)