From 93e0251c63af83838a843ed295102384262f840c Mon Sep 17 00:00:00 2001 From: DataTriny Date: Wed, 16 Aug 2023 22:17:08 +0200 Subject: [PATCH] Switch to pyo3 master for now, update enums --- Cargo.lock | 85 +++++++++++-------- bindings/python/Cargo.toml | 2 +- .../python/examples/pygame/hello_world.py | 16 ++-- common/Cargo.toml | 2 +- common/src/lib.rs | 34 ++++---- 5 files changed, 76 insertions(+), 63 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7ba797c50..8825a6972 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -242,7 +242,7 @@ checksum = "3b015a331cc64ebd1774ba119538573603427eaace0a1950c423ab971f903796" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -259,7 +259,7 @@ checksum = "b84f9ebcc6c1f5b8cb160f6990096a5c127f423fcb6e1ccc46c370cbdfb75dfc" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -292,7 +292,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fb4870a32c0eaa17e35bca0e6b16020635157121fb7d45593d242c295bc768" dependencies = [ "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -502,7 +502,7 @@ checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -580,7 +580,7 @@ checksum = "f58dc3c5e468259f19f2d46304a6b28f1c3d034442e14b322d2b850e36f6d5ae" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -591,7 +591,7 @@ checksum = "1940ea32e14d489b401074558be4567f35ca9507c4628b4b3fd6fe6eb2ca7b88" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -737,6 +737,12 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "hermit-abi" version = "0.2.6" @@ -770,9 +776,9 @@ dependencies = [ [[package]] name = "indoc" -version = "1.0.9" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306" +checksum = "2c785eefb63ebd0e33416dfcb8d6da0bf27ce752843a45632a67bf10d4d4b5c4" [[package]] name = "instant" @@ -1055,7 +1061,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1236,8 +1242,7 @@ dependencies = [ [[package]] name = "pyo3" version = "0.19.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e681a6cfdc4adcc93b4d3cf993749a4552018ee0a9b65fc0ccfad74352c72a38" +source = "git+https://github.com/PyO3/pyo3.git#9363491d54a3637fb434b197ae5b2386f0bf5dc9" dependencies = [ "cfg-if", "indoc", @@ -1254,8 +1259,7 @@ dependencies = [ [[package]] name = "pyo3-build-config" version = "0.19.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076c73d0bc438f7a4ef6fdd0c3bb4732149136abd952b110ac93e4edb13a6ba5" +source = "git+https://github.com/PyO3/pyo3.git#9363491d54a3637fb434b197ae5b2386f0bf5dc9" dependencies = [ "once_cell", "target-lexicon", @@ -1264,8 +1268,7 @@ dependencies = [ [[package]] name = "pyo3-ffi" version = "0.19.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e53cee42e77ebe256066ba8aa77eff722b3bb91f3419177cf4cd0f304d3284d9" +source = "git+https://github.com/PyO3/pyo3.git#9363491d54a3637fb434b197ae5b2386f0bf5dc9" dependencies = [ "libc", "pyo3-build-config", @@ -1274,24 +1277,23 @@ dependencies = [ [[package]] name = "pyo3-macros" version = "0.19.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfeb4c99597e136528c6dd7d5e3de5434d1ceaf487436a3f03b2d56b6fc9efd1" +source = "git+https://github.com/PyO3/pyo3.git#9363491d54a3637fb434b197ae5b2386f0bf5dc9" dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn", + "syn 2.0.16", ] [[package]] name = "pyo3-macros-backend" version = "0.19.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "947dc12175c254889edc0c02e399476c2f652b4b9ebd123aa655c224de259536" +source = "git+https://github.com/PyO3/pyo3.git#9363491d54a3637fb434b197ae5b2386f0bf5dc9" dependencies = [ + "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.16", ] [[package]] @@ -1426,7 +1428,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn", + "syn 1.0.109", ] [[package]] @@ -1471,7 +1473,7 @@ checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1482,7 +1484,7 @@ checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1504,7 +1506,7 @@ checksum = "395627de918015623b32e7669714206363a7fc00382bf477e72c1f7533e8eafc" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1594,6 +1596,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "target-lexicon" version = "0.12.11" @@ -1630,7 +1643,7 @@ checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1712,7 +1725,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1754,9 +1767,9 @@ checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "unindent" -version = "0.1.11" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1766d682d402817b5ac4490b3c3002d91dfa0d22812f341609f97b08757359c" +checksum = "0f86d931b9d0b666761dcfcbac3ec5e9daff8a2becfff93a8fce2591ae297b95" [[package]] name = "vec_map" @@ -1803,7 +1816,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-shared", ] @@ -1825,7 +1838,7 @@ checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1960,7 +1973,7 @@ checksum = "5e2ee588991b9e7e6c8338edf3333fbe4da35dc72092643958ebb43f0ab2c49c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1971,7 +1984,7 @@ checksum = "e6fb8df20c9bcaa8ad6ab513f7b40104840c8867d5751126e4df3b08388d0cc7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2233,7 +2246,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn", + "syn 1.0.109", "zvariant_utils", ] @@ -2271,7 +2284,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "zvariant_utils", ] @@ -2283,5 +2296,5 @@ checksum = "53b22993dbc4d128a17a3b6c92f1c63872dd67198537ee728d8b5d7c40640a8b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] diff --git a/bindings/python/Cargo.toml b/bindings/python/Cargo.toml index 101a744ae..250acf429 100644 --- a/bindings/python/Cargo.toml +++ b/bindings/python/Cargo.toml @@ -17,7 +17,7 @@ extension-module = ["pyo3/extension-module"] [dependencies] accesskit = { version = "0.11.2", path = "../../common", features = ["pyo3"] } -pyo3 = { version = "0.19", features = ["abi3-py37", "multiple-pymethods"] } +pyo3 = { git = "https://github.com/PyO3/pyo3.git", features = ["abi3-py37", "multiple-pymethods"] } [target.'cfg(target_os = "windows")'.dependencies] accesskit_windows = { version = "0.14.3", path = "../../platforms/windows" } diff --git a/bindings/python/examples/pygame/hello_world.py b/bindings/python/examples/pygame/hello_world.py index 87f586c24..03db39ad3 100644 --- a/bindings/python/examples/pygame/hello_world.py +++ b/bindings/python/examples/pygame/hello_world.py @@ -25,18 +25,18 @@ def build_button(id, name, classes): - builder = accesskit.NodeBuilder(accesskit.Role.Button) + builder = accesskit.NodeBuilder(accesskit.Role.BUTTON) builder.set_bounds(BUTTON_1_RECT if id == BUTTON_1_ID else BUTTON_2_RECT) builder.set_name(name) - builder.add_action(accesskit.Action.Focus) - builder.set_default_action_verb(accesskit.DefaultActionVerb.Click) + builder.add_action(accesskit.Action.FOCUS) + builder.set_default_action_verb(accesskit.DefaultActionVerb.CLICK) return builder.build(classes) def build_announcement(text, classes): - builder = accesskit.NodeBuilder(accesskit.Role.StaticText) + builder = accesskit.NodeBuilder(accesskit.Role.STATIC_TEXT) builder.set_name(text) - builder.set_live(accesskit.Live.Polite) + builder.set_live(accesskit.Live.POLITE) return builder.build(classes) @@ -85,7 +85,7 @@ def focus(self): return self._focus if self.is_window_focused else None def build_root(self): - builder = accesskit.NodeBuilder(accesskit.Role.Window) + builder = accesskit.NodeBuilder(accesskit.Role.WINDOW) builder.set_children([BUTTON_1_ID, BUTTON_2_ID]) if not self.announcement is None: builder.push_child(ANNOUNCEMENT_ID) @@ -136,10 +136,10 @@ def build_tree_update_for_focus_update(self): def do_action(request): - if request.action in [accesskit.Action.Default, accesskit.Action.Focus]: + if request.action in [accesskit.Action.DEFAULT, accesskit.Action.FOCUS]: args = { "event": SET_FOCUS_MSG - if request.action == accesskit.Action.Focus + if request.action == accesskit.Action.FOCUS else DO_DEFAULT_ACTION_MSG, "target": request.target, } diff --git a/common/Cargo.toml b/common/Cargo.toml index a348eb52b..f15a632bb 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -15,7 +15,7 @@ features = ["schemars", "serde"] [dependencies] enumn = { version = "0.1.6", optional = true } -pyo3 = { version = "0.19", optional = true } +pyo3 = { git = "https://github.com/PyO3/pyo3.git", optional = true } schemars = { version = "0.8.7", optional = true } serde = { version = "1.0", features = ["derive"], optional = true } diff --git a/common/src/lib.rs b/common/src/lib.rs index 5f677359a..12d58131a 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -49,7 +49,7 @@ pub use geometry::{Affine, Point, Rect, Size, Vec2}; #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "schemars", derive(JsonSchema))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit"))] +#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit", rename_all = "SCREAMING_SNAKE_CASE"))] #[repr(u8)] pub enum Role { Unknown, @@ -272,7 +272,7 @@ impl Default for Role { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "schemars", derive(JsonSchema))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit"))] +#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit", rename_all = "SCREAMING_SNAKE_CASE"))] #[repr(u8)] pub enum Action { /// Do the default action for an object, typically this means "click". @@ -444,7 +444,7 @@ impl JsonSchema for Actions { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "schemars", derive(JsonSchema))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit"))] +#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit", rename_all = "SCREAMING_SNAKE_CASE"))] #[repr(u8)] pub enum Orientation { /// E.g. most toolbars and separators. @@ -458,7 +458,7 @@ pub enum Orientation { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "schemars", derive(JsonSchema))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit"))] +#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit", rename_all = "SCREAMING_SNAKE_CASE"))] #[repr(u8)] pub enum NameFrom { /// E.g. [`aria-label`]. @@ -484,7 +484,7 @@ pub enum NameFrom { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "schemars", derive(JsonSchema))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit"))] +#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit", rename_all = "SCREAMING_SNAKE_CASE"))] #[repr(u8)] pub enum DescriptionFrom { AriaDescription, @@ -504,7 +504,7 @@ pub enum DescriptionFrom { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "schemars", derive(JsonSchema))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit"))] +#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit", rename_all = "SCREAMING_SNAKE_CASE"))] #[repr(u8)] pub enum TextDirection { LeftToRight, @@ -522,7 +522,7 @@ pub enum TextDirection { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "schemars", derive(JsonSchema))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit"))] +#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit", rename_all = "SCREAMING_SNAKE_CASE"))] #[repr(u8)] pub enum Invalid { True, @@ -535,7 +535,7 @@ pub enum Invalid { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "schemars", derive(JsonSchema))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit"))] +#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit", rename_all = "SCREAMING_SNAKE_CASE"))] #[repr(u8)] pub enum CheckedState { False, @@ -554,7 +554,7 @@ pub enum CheckedState { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "schemars", derive(JsonSchema))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit"))] +#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit", rename_all = "SCREAMING_SNAKE_CASE"))] #[repr(u8)] pub enum DefaultActionVerb { Click, @@ -577,7 +577,7 @@ pub enum DefaultActionVerb { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "schemars", derive(JsonSchema))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit"))] +#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit", rename_all = "SCREAMING_SNAKE_CASE"))] #[repr(u8)] pub enum SortDirection { Unsorted, @@ -591,7 +591,7 @@ pub enum SortDirection { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "schemars", derive(JsonSchema))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit"))] +#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit", rename_all = "SCREAMING_SNAKE_CASE"))] #[repr(u8)] pub enum AriaCurrent { False, @@ -608,7 +608,7 @@ pub enum AriaCurrent { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "schemars", derive(JsonSchema))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit"))] +#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit", rename_all = "SCREAMING_SNAKE_CASE"))] #[repr(u8)] pub enum Live { Off, @@ -621,7 +621,7 @@ pub enum Live { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "schemars", derive(JsonSchema))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit"))] +#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit", rename_all = "SCREAMING_SNAKE_CASE"))] #[repr(u8)] pub enum HasPopup { True, @@ -637,7 +637,7 @@ pub enum HasPopup { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "schemars", derive(JsonSchema))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit"))] +#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit", rename_all = "SCREAMING_SNAKE_CASE"))] #[repr(u8)] pub enum ListStyle { Circle, @@ -654,7 +654,7 @@ pub enum ListStyle { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "schemars", derive(JsonSchema))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit"))] +#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit", rename_all = "SCREAMING_SNAKE_CASE"))] #[repr(u8)] pub enum TextAlign { Left, @@ -668,7 +668,7 @@ pub enum TextAlign { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "schemars", derive(JsonSchema))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit"))] +#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit", rename_all = "SCREAMING_SNAKE_CASE"))] #[repr(u8)] pub enum VerticalOffset { Subscript, @@ -680,7 +680,7 @@ pub enum VerticalOffset { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "schemars", derive(JsonSchema))] #[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))] -#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit"))] +#[cfg_attr(feature = "pyo3", pyclass(module = "accesskit", rename_all = "SCREAMING_SNAKE_CASE"))] #[repr(u8)] pub enum TextDecoration { Solid,