diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /toolkit/components/uniffi-fixtures/rondpoint | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | toolkit/components/uniffi-fixtures/rondpoint/Cargo.toml | 20 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/rondpoint/build.rs (renamed from third_party/rust/uniffi-example-rondpoint/build.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/rondpoint/src/lib.rs (renamed from third_party/rust/uniffi-example-rondpoint/src/lib.rs) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/rondpoint/src/rondpoint.udl (renamed from third_party/rust/uniffi-example-rondpoint/src/rondpoint.udl) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.kts (renamed from third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.kts) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.py (renamed from third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.py) | 75 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.rb (renamed from third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.rb) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.swift (renamed from third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.swift) | 0 | ||||
-rw-r--r-- | toolkit/components/uniffi-fixtures/rondpoint/tests/test_generated_bindings.rs (renamed from third_party/rust/uniffi-example-rondpoint/tests/test_generated_bindings.rs) | 0 |
9 files changed, 76 insertions, 19 deletions
diff --git a/toolkit/components/uniffi-fixtures/rondpoint/Cargo.toml b/toolkit/components/uniffi-fixtures/rondpoint/Cargo.toml new file mode 100644 index 0000000000..1d0be84785 --- /dev/null +++ b/toolkit/components/uniffi-fixtures/rondpoint/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "uniffi-example-rondpoint" +edition = "2021" +version = "0.22.0" +authors = ["Firefox Sync Team <sync-team@mozilla.com>"] +license = "MPL-2.0" +publish = false + +[lib] +crate-type = ["lib", "cdylib"] +name = "uniffi_rondpoint" + +[dependencies] +uniffi = { workspace = true } + +[build-dependencies] +uniffi = { workspace = true, features = ["build"] } + +[dev-dependencies] +uniffi = { workspace = true, features = ["bindgen-tests"] } diff --git a/third_party/rust/uniffi-example-rondpoint/build.rs b/toolkit/components/uniffi-fixtures/rondpoint/build.rs index f830879d09..f830879d09 100644 --- a/third_party/rust/uniffi-example-rondpoint/build.rs +++ b/toolkit/components/uniffi-fixtures/rondpoint/build.rs diff --git a/third_party/rust/uniffi-example-rondpoint/src/lib.rs b/toolkit/components/uniffi-fixtures/rondpoint/src/lib.rs index 3f2233ddaa..3f2233ddaa 100644 --- a/third_party/rust/uniffi-example-rondpoint/src/lib.rs +++ b/toolkit/components/uniffi-fixtures/rondpoint/src/lib.rs diff --git a/third_party/rust/uniffi-example-rondpoint/src/rondpoint.udl b/toolkit/components/uniffi-fixtures/rondpoint/src/rondpoint.udl index 7c8261d74e..7c8261d74e 100644 --- a/third_party/rust/uniffi-example-rondpoint/src/rondpoint.udl +++ b/toolkit/components/uniffi-fixtures/rondpoint/src/rondpoint.udl diff --git a/third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.kts b/toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.kts index cc5ddf2a86..cc5ddf2a86 100644 --- a/third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.kts +++ b/toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.kts diff --git a/third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.py b/toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.py index 0b47c0fa5a..df3e3fab18 100644 --- a/third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.py +++ b/toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.py @@ -1,18 +1,37 @@ -import sys import ctypes -from rondpoint import * +import sys -dico = Dictionnaire(un=Enumeration.DEUX, deux=True, petit_nombre=0, gros_nombre=123456789) +from rondpoint import ( + Dictionnaire, + Enumeration, + EnumerationAvecDonnees, + Retourneur, + Stringifier, + copie_carte, + copie_dictionnaire, + copie_enumeration, + copie_enumerations, + switcheroo, +) + +dico = Dictionnaire( + un=Enumeration.DEUX, deux=True, petit_nombre=0, gros_nombre=123456789 +) copyDico = copie_dictionnaire(dico) assert dico == copyDico assert copie_enumeration(Enumeration.DEUX) == Enumeration.DEUX -assert copie_enumerations([Enumeration.UN, Enumeration.DEUX]) == [Enumeration.UN, Enumeration.DEUX] -assert copie_carte({ - "0": EnumerationAvecDonnees.ZERO(), - "1": EnumerationAvecDonnees.UN(1), - "2": EnumerationAvecDonnees.DEUX(2, "deux"), -}) == { +assert copie_enumerations([Enumeration.UN, Enumeration.DEUX]) == [ + Enumeration.UN, + Enumeration.DEUX, +] +assert copie_carte( + { + "0": EnumerationAvecDonnees.ZERO(), + "1": EnumerationAvecDonnees.UN(1), + "2": EnumerationAvecDonnees.DEUX(2, "deux"), + } +) == { "0": EnumerationAvecDonnees.ZERO(), "1": EnumerationAvecDonnees.UN(1), "2": EnumerationAvecDonnees.DEUX(2, "deux"), @@ -30,11 +49,13 @@ assert EnumerationAvecDonnees.UN(1) != EnumerationAvecDonnees.UN(2) # lowering from rust and lifting into python. rt = Retourneur() + def affirmAllerRetour(vals, identique): for v in vals: id_v = identique(v) assert id_v == v, f"Round-trip failure: {v} => {id_v}" + MIN_I8 = -1 * 2**7 MAX_I8 = 2**7 - 1 MIN_I16 = -1 * 2**15 @@ -65,21 +86,29 @@ affirmAllerRetour([0x00000000, 0x12345678, 0xFFFFFFFF], rt.identique_u32) # Longs affirmAllerRetour([MIN_I64, -1, 0, 1, MAX_I64], rt.identique_i64) -affirmAllerRetour([0x0000000000000000, 0x1234567890ABCDEF, 0xFFFFFFFFFFFFFFFF], rt.identique_u64) +affirmAllerRetour( + [0x0000000000000000, 0x1234567890ABCDEF, 0xFFFFFFFFFFFFFFFF], rt.identique_u64 +) # Floats affirmAllerRetour([0.0, 0.5, 0.25, 1.0, F32_ONE_THIRD], rt.identique_float) # Doubles affirmAllerRetour( - [0.0, 0.5, 0.25, 1.0, 1.0 / 3, sys.float_info.max, sys.float_info.min], - rt.identique_double + [0.0, 0.5, 0.25, 1.0, 1.0 / 3, sys.float_info.max, sys.float_info.min], + rt.identique_double, ) # Strings affirmAllerRetour( - ["", "abc", "été", "ښي لاس ته لوستلو لوستل", "😻emoji 👨👧👦multi-emoji, 🇨🇭a flag, a canal, panama"], - rt.identique_string + [ + "", + "abc", + "été", + "ښي لاس ته لوستلو لوستل", + "😻emoji 👨👧👦multi-emoji, 🇨🇭a flag, a canal, panama", + ], + rt.identique_string, ) # Test one way across the FFI. @@ -97,11 +126,13 @@ affirmAllerRetour( # together, we've shown the correctness of the return leg. st = Stringifier() + def affirmEnchaine(vals, toString, rustyStringify=lambda v: str(v).lower()): for v in vals: str_v = toString(v) assert rustyStringify(v) == str_v, f"String compare error {v} => {str_v}" + # Test the efficacy of the string transport from rust. If this fails, but everything else # works, then things are very weird. wellKnown = st.well_known_string("python") @@ -124,7 +155,10 @@ affirmEnchaine([0x00000000, 0x12345678, 0xFFFFFFFF], st.to_string_u32) # Longs affirmEnchaine([MIN_I64, -1, 0, 1, MAX_I64], st.to_string_i64) -affirmEnchaine([0x0000000000000000, 0x1234567890ABCDEF, 0xFFFFFFFFFFFFFFFF], st.to_string_u64) +affirmEnchaine( + [0x0000000000000000, 0x1234567890ABCDEF, 0xFFFFFFFFFFFFFFFF], st.to_string_u64 +) + # Floats def rustyFloatToStr(v): @@ -134,13 +168,16 @@ def rustyFloatToStr(v): return str(int(v)) return str(v) + affirmEnchaine([0.0, 0.5, 0.25, 1.0], st.to_string_float, rustyFloatToStr) -assert st.to_string_float(F32_ONE_THIRD) == "0.33333334" # annoyingly different string repr +assert ( + st.to_string_float(F32_ONE_THIRD) == "0.33333334" +) # annoyingly different string repr # Doubles # TODO: float_info.max/float_info.min don't stringify-roundtrip properly yet, TBD. affirmEnchaine( - [0.0, 0.5, 0.25, 1.0, 1.0 / 3], - st.to_string_double, - rustyFloatToStr, + [0.0, 0.5, 0.25, 1.0, 1.0 / 3], + st.to_string_double, + rustyFloatToStr, ) diff --git a/third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.rb b/toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.rb index faa4062019..faa4062019 100644 --- a/third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.rb +++ b/toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.rb diff --git a/third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.swift b/toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.swift index d9f47058ed..d9f47058ed 100644 --- a/third_party/rust/uniffi-example-rondpoint/tests/bindings/test_rondpoint.swift +++ b/toolkit/components/uniffi-fixtures/rondpoint/tests/bindings/test_rondpoint.swift diff --git a/third_party/rust/uniffi-example-rondpoint/tests/test_generated_bindings.rs b/toolkit/components/uniffi-fixtures/rondpoint/tests/test_generated_bindings.rs index d337374334..d337374334 100644 --- a/third_party/rust/uniffi-example-rondpoint/tests/test_generated_bindings.rs +++ b/toolkit/components/uniffi-fixtures/rondpoint/tests/test_generated_bindings.rs |