From 59203c63bb777a3bacec32fb8830fba33540e809 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:29 +0200 Subject: Adding upstream version 127.0. Signed-off-by: Daniel Baumann --- .../uniffi-example-arithmetic/.cargo-checksum.json | 1 - .../rust/uniffi-example-arithmetic/Cargo.toml | 42 ---------------------- .../rust/uniffi-example-arithmetic/build.rs | 7 ---- .../uniffi-example-arithmetic/src/arithmetic.udl | 16 --------- .../rust/uniffi-example-arithmetic/src/lib.rs | 34 ------------------ .../tests/bindings/test_arithmetic.kts | 29 --------------- .../tests/bindings/test_arithmetic.py | 37 ------------------- .../tests/bindings/test_arithmetic.rb | 31 ---------------- .../tests/bindings/test_arithmetic.swift | 32 ----------------- .../tests/test_generated_bindings.rs | 6 ---- .../rust/uniffi-example-arithmetic/uniffi.toml | 2 -- 11 files changed, 237 deletions(-) delete mode 100644 third_party/rust/uniffi-example-arithmetic/.cargo-checksum.json delete mode 100644 third_party/rust/uniffi-example-arithmetic/Cargo.toml delete mode 100644 third_party/rust/uniffi-example-arithmetic/build.rs delete mode 100644 third_party/rust/uniffi-example-arithmetic/src/arithmetic.udl delete mode 100644 third_party/rust/uniffi-example-arithmetic/src/lib.rs delete mode 100644 third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.kts delete mode 100644 third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.py delete mode 100644 third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.rb delete mode 100644 third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.swift delete mode 100644 third_party/rust/uniffi-example-arithmetic/tests/test_generated_bindings.rs delete mode 100644 third_party/rust/uniffi-example-arithmetic/uniffi.toml (limited to 'third_party/rust/uniffi-example-arithmetic') diff --git a/third_party/rust/uniffi-example-arithmetic/.cargo-checksum.json b/third_party/rust/uniffi-example-arithmetic/.cargo-checksum.json deleted file mode 100644 index 33a5447821..0000000000 --- a/third_party/rust/uniffi-example-arithmetic/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{"Cargo.toml":"359cffb76e0eac82aeec6a667f7670fa4b88346c2dd7c17febe71731fd6df58b","build.rs":"7d98b49c1d9c868c4199f0417eaa017ab459cdd536e9a29851d5f707941f9ead","src/arithmetic.udl":"8554c6907ece627645f6b896f71430e5412bf19b0ac6becf63eb9a69868d0f7a","src/lib.rs":"c454193443e92d49f997c760f4131192fb66bf213bbac1710c1ebde19e765e5d","tests/bindings/test_arithmetic.kts":"e0e9347755db4e18f70b1b74c2d5a4aa328373015090ed959b46d65c2a205d92","tests/bindings/test_arithmetic.py":"3e41d69e21e96a6830197c760f3b7bddd754edc0c5515b7bd33b79cccb10f941","tests/bindings/test_arithmetic.rb":"ea0fdce0a4c7b557b427db77521da05240cd6e87d60a128ac2307fab3bbbc76d","tests/bindings/test_arithmetic.swift":"455b87d95fc690af9c35f9e43676e9c855dedddd2fc1c9e1cbaa6a02835c2d4c","tests/test_generated_bindings.rs":"26b92d6b3e648f6fadd4182cbdba4f412b73da48a789785fd98cd486b29abf05","uniffi.toml":"a2d4f46fa51dc1be1e8bcdf67ec13223637fc1b6c6437455cf53c2dae065fb45"},"package":null} \ No newline at end of file diff --git a/third_party/rust/uniffi-example-arithmetic/Cargo.toml b/third_party/rust/uniffi-example-arithmetic/Cargo.toml deleted file mode 100644 index 52f08bb9f6..0000000000 --- a/third_party/rust/uniffi-example-arithmetic/Cargo.toml +++ /dev/null @@ -1,42 +0,0 @@ -# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO -# -# When uploading crates to the registry Cargo will automatically -# "normalize" Cargo.toml files for maximal compatibility -# with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies. -# -# If you are reading this file be aware that the original Cargo.toml -# will likely look very different (and much more reasonable). -# See Cargo.toml.orig for the original contents. - -[package] -edition = "2021" -name = "uniffi-example-arithmetic" -version = "0.22.0" -authors = ["Firefox Sync Team "] -publish = false -license = "MPL-2.0" - -[lib] -name = "arithmetical" -crate-type = [ - "lib", - "cdylib", -] - -[dependencies] -thiserror = "1.0" - -[dependencies.uniffi] -version = "0.27" -path = "../../uniffi" - -[dev-dependencies.uniffi] -version = "0.27" -path = "../../uniffi" -features = ["bindgen-tests"] - -[build-dependencies.uniffi] -version = "0.27" -path = "../../uniffi" -features = ["build"] diff --git a/third_party/rust/uniffi-example-arithmetic/build.rs b/third_party/rust/uniffi-example-arithmetic/build.rs deleted file mode 100644 index 303ac22d8d..0000000000 --- a/third_party/rust/uniffi-example-arithmetic/build.rs +++ /dev/null @@ -1,7 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -fn main() { - uniffi::generate_scaffolding("src/arithmetic.udl").unwrap(); -} diff --git a/third_party/rust/uniffi-example-arithmetic/src/arithmetic.udl b/third_party/rust/uniffi-example-arithmetic/src/arithmetic.udl deleted file mode 100644 index 117df4834a..0000000000 --- a/third_party/rust/uniffi-example-arithmetic/src/arithmetic.udl +++ /dev/null @@ -1,16 +0,0 @@ -[Error] -enum ArithmeticError { - "IntegerOverflow", -}; - -namespace arithmetic { - [Throws=ArithmeticError] - u64 add(u64 a, u64 b); - - [Throws=ArithmeticError] - u64 sub(u64 a, u64 b); - - u64 div(u64 dividend, u64 divisor); - - boolean equal(u64 a, u64 b); -}; diff --git a/third_party/rust/uniffi-example-arithmetic/src/lib.rs b/third_party/rust/uniffi-example-arithmetic/src/lib.rs deleted file mode 100644 index 92ab8c072b..0000000000 --- a/third_party/rust/uniffi-example-arithmetic/src/lib.rs +++ /dev/null @@ -1,34 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#[derive(Debug, thiserror::Error)] -pub enum ArithmeticError { - #[error("Integer overflow on an operation with {a} and {b}")] - IntegerOverflow { a: u64, b: u64 }, -} - -fn add(a: u64, b: u64) -> Result { - a.checked_add(b) - .ok_or(ArithmeticError::IntegerOverflow { a, b }) -} - -fn sub(a: u64, b: u64) -> Result { - a.checked_sub(b) - .ok_or(ArithmeticError::IntegerOverflow { a, b }) -} - -fn div(dividend: u64, divisor: u64) -> u64 { - if divisor == 0 { - panic!("Can't divide by zero"); - } - dividend / divisor -} - -fn equal(a: u64, b: u64) -> bool { - a == b -} - -type Result = std::result::Result; - -uniffi::include_scaffolding!("arithmetic"); diff --git a/third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.kts b/third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.kts deleted file mode 100644 index ef11850ae2..0000000000 --- a/third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.kts +++ /dev/null @@ -1,29 +0,0 @@ -import org.mozilla.uniffi.example.arithmetic.*; - -assert(add(2u, 4u) == 6uL) -assert(add(4u, 8u) == 12uL) - -try { - sub(0u, 2u) - throw RuntimeException("Should have thrown a IntegerOverflow exception!") -} catch (e: ArithmeticException) { - // It's okay! -} - -assert(sub(4u, 2u) == 2uL) -assert(sub(8u, 4u) == 4uL) - -assert(div(8u, 4u) == 2uL) - -try { - div(8u, 0u) - throw RuntimeException("Should have panicked when dividing by zero") -} catch (e: InternalException) { - // It's okay! -} - -assert(equal(2u, 2uL)) -assert(equal(4u, 4uL)) - -assert(!equal(2u, 4uL)) -assert(!equal(4u, 8uL)) diff --git a/third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.py b/third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.py deleted file mode 100644 index 0d4e666fbf..0000000000 --- a/third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.py +++ /dev/null @@ -1,37 +0,0 @@ -from arithmetic import * - -try: - add(18446744073709551615, 1) - assert(not("Should have thrown a IntegerOverflow exception!")) -except ArithmeticError.IntegerOverflow: - # It's okay! - pass - -assert add(2, 4) == 6 -assert add(4, 8) == 12 - -try: - sub(0, 1) - assert(not("Should have thrown a IntegerOverflow exception!")) -except ArithmeticError.IntegerOverflow: - # It's okay! - pass - -assert sub(4, 2) == 2 -assert sub(8, 4) == 4 - -assert div(8, 4) == 2 - -try: - div(8, 0) -except InternalError: - # It's okay! - pass -else: - assert(not("Should have panicked when dividing by zero")) - -assert equal(2, 2) -assert equal(4, 4) - -assert not equal(2, 4) -assert not equal(4, 8) diff --git a/third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.rb b/third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.rb deleted file mode 100644 index 6669eb279f..0000000000 --- a/third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -require 'test/unit' -require 'arithmetic' - -include Test::Unit::Assertions - -assert_raise Arithmetic::ArithmeticError::IntegerOverflow do - Arithmetic.add 18_446_744_073_709_551_615, 1 -end - -assert_equal Arithmetic.add(2, 4), 6 -assert_equal Arithmetic.add(4, 8), 12 - -assert_raise Arithmetic::ArithmeticError::IntegerOverflow do - Arithmetic.sub 0, 1 -end - -assert_equal Arithmetic.sub(4, 2), 2 -assert_equal Arithmetic.sub(8, 4), 4 -assert_equal Arithmetic.div(8, 4), 2 - -assert_raise Arithmetic::InternalError do - Arithmetic.div 8, 0 -end - -assert Arithmetic.equal(2, 2) -assert Arithmetic.equal(4, 4) - -assert !Arithmetic.equal(2, 4) -assert !Arithmetic.equal(4, 8) diff --git a/third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.swift b/third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.swift deleted file mode 100644 index a8e34680e4..0000000000 --- a/third_party/rust/uniffi-example-arithmetic/tests/bindings/test_arithmetic.swift +++ /dev/null @@ -1,32 +0,0 @@ -import arithmetic - -do { - let _ = try add(a: 18446744073709551615, b: 1) - fatalError("Should have thrown a IntegerOverflow exception!") -} catch ArithmeticError.IntegerOverflow { - // It's okay! -} - -assert(try! add(a: 2, b: 4) == 6, "add work") -assert(try! add(a: 4, b: 8) == 12, "add work") - -do { - let _ = try sub(a: 0, b: 1) - fatalError("Should have thrown a IntegerOverflow exception!") -} catch ArithmeticError.IntegerOverflow { - // It's okay! -} - -assert(try! sub(a: 4, b: 2) == 2, "sub work") -assert(try! sub(a: 8, b: 4) == 4, "sub work") - -assert(div(dividend: 8, divisor: 4) == 2, "div works") - -// We can't test panicking in Swift because we force unwrap the error in -// `div`, which we can't catch. - -assert(equal(a: 2, b: 2), "equal works") -assert(equal(a: 4, b: 4), "equal works") - -assert(!equal(a: 2, b: 4), "non-equal works") -assert(!equal(a: 4, b: 8), "non-equal works") diff --git a/third_party/rust/uniffi-example-arithmetic/tests/test_generated_bindings.rs b/third_party/rust/uniffi-example-arithmetic/tests/test_generated_bindings.rs deleted file mode 100644 index 168e6e1d4c..0000000000 --- a/third_party/rust/uniffi-example-arithmetic/tests/test_generated_bindings.rs +++ /dev/null @@ -1,6 +0,0 @@ -uniffi::build_foreign_language_testcases!( - "tests/bindings/test_arithmetic.rb", - "tests/bindings/test_arithmetic.py", - "tests/bindings/test_arithmetic.kts", - "tests/bindings/test_arithmetic.swift", -); diff --git a/third_party/rust/uniffi-example-arithmetic/uniffi.toml b/third_party/rust/uniffi-example-arithmetic/uniffi.toml deleted file mode 100644 index 883231dcaa..0000000000 --- a/third_party/rust/uniffi-example-arithmetic/uniffi.toml +++ /dev/null @@ -1,2 +0,0 @@ -[bindings.kotlin] -package_name = "org.mozilla.uniffi.example.arithmetic" -- cgit v1.2.3