diff options
Diffstat (limited to 'third_party/rust/uniffi-example-rondpoint/src')
-rw-r--r-- | third_party/rust/uniffi-example-rondpoint/src/lib.rs | 293 | ||||
-rw-r--r-- | third_party/rust/uniffi-example-rondpoint/src/rondpoint.udl | 146 |
2 files changed, 0 insertions, 439 deletions
diff --git a/third_party/rust/uniffi-example-rondpoint/src/lib.rs b/third_party/rust/uniffi-example-rondpoint/src/lib.rs deleted file mode 100644 index 3f2233ddaa..0000000000 --- a/third_party/rust/uniffi-example-rondpoint/src/lib.rs +++ /dev/null @@ -1,293 +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/. */ - -use std::collections::HashMap; - -#[derive(Debug, Clone)] -pub struct Dictionnaire { - un: Enumeration, - deux: bool, - petit_nombre: u8, - gros_nombre: u64, -} - -#[derive(Debug, Clone)] -pub struct DictionnaireNombres { - petit_nombre: u8, - court_nombre: u16, - nombre_simple: u32, - gros_nombre: u64, -} - -#[derive(Debug, Clone)] -pub struct DictionnaireNombresSignes { - petit_nombre: i8, - court_nombre: i16, - nombre_simple: i32, - gros_nombre: i64, -} - -#[derive(Debug, Clone)] -pub enum Enumeration { - Un, - Deux, - Trois, -} - -#[derive(Debug, Clone)] -pub enum EnumerationAvecDonnees { - Zero, - Un { premier: u32 }, - Deux { premier: u32, second: String }, -} - -#[allow(non_camel_case_types)] -#[allow(non_snake_case)] -pub struct minusculeMAJUSCULEDict { - minusculeMAJUSCULEField: bool, -} - -#[allow(non_camel_case_types)] -pub enum minusculeMAJUSCULEEnum { - minusculeMAJUSCULEVariant, -} - -fn copie_enumeration(e: Enumeration) -> Enumeration { - e -} - -fn copie_enumerations(e: Vec<Enumeration>) -> Vec<Enumeration> { - e -} - -fn copie_carte( - e: HashMap<String, EnumerationAvecDonnees>, -) -> HashMap<String, EnumerationAvecDonnees> { - e -} - -fn copie_dictionnaire(d: Dictionnaire) -> Dictionnaire { - d -} - -fn switcheroo(b: bool) -> bool { - !b -} - -// Test that values can traverse both ways across the FFI. -// Even if roundtripping works, it's possible we have -// symmetrical errors that cancel each other out. -#[derive(Debug, Clone)] -struct Retourneur; -impl Retourneur { - fn new() -> Self { - Retourneur - } - fn identique_i8(&self, value: i8) -> i8 { - value - } - fn identique_u8(&self, value: u8) -> u8 { - value - } - fn identique_i16(&self, value: i16) -> i16 { - value - } - fn identique_u16(&self, value: u16) -> u16 { - value - } - fn identique_i32(&self, value: i32) -> i32 { - value - } - fn identique_u32(&self, value: u32) -> u32 { - value - } - fn identique_i64(&self, value: i64) -> i64 { - value - } - fn identique_u64(&self, value: u64) -> u64 { - value - } - fn identique_float(&self, value: f32) -> f32 { - value - } - fn identique_double(&self, value: f64) -> f64 { - value - } - fn identique_boolean(&self, value: bool) -> bool { - value - } - fn identique_string(&self, value: String) -> String { - value - } - fn identique_nombres_signes( - &self, - value: DictionnaireNombresSignes, - ) -> DictionnaireNombresSignes { - value - } - fn identique_nombres(&self, value: DictionnaireNombres) -> DictionnaireNombres { - value - } - fn identique_optionneur_dictionnaire( - &self, - value: OptionneurDictionnaire, - ) -> OptionneurDictionnaire { - value - } -} - -#[derive(Debug, Clone)] -struct Stringifier; - -#[allow(dead_code)] -impl Stringifier { - fn new() -> Self { - Stringifier - } - fn to_string_i8(&self, value: i8) -> String { - value.to_string() - } - fn to_string_u8(&self, value: u8) -> String { - value.to_string() - } - fn to_string_i16(&self, value: i16) -> String { - value.to_string() - } - fn to_string_u16(&self, value: u16) -> String { - value.to_string() - } - fn to_string_i32(&self, value: i32) -> String { - value.to_string() - } - fn to_string_u32(&self, value: u32) -> String { - value.to_string() - } - fn to_string_i64(&self, value: i64) -> String { - value.to_string() - } - fn to_string_u64(&self, value: u64) -> String { - value.to_string() - } - fn to_string_float(&self, value: f32) -> String { - value.to_string() - } - fn to_string_double(&self, value: f64) -> String { - value.to_string() - } - fn to_string_boolean(&self, value: bool) -> String { - value.to_string() - } - fn well_known_string(&self, value: String) -> String { - format!("uniffi 💚 {value}!") - } -} - -#[derive(Debug, Clone)] -struct Optionneur; -impl Optionneur { - fn new() -> Self { - Optionneur - } - fn sinon_string(&self, value: String) -> String { - value - } - fn sinon_null(&self, value: Option<String>) -> Option<String> { - value - } - fn sinon_boolean(&self, value: bool) -> bool { - value - } - fn sinon_sequence(&self, value: Vec<String>) -> Vec<String> { - value - } - - fn sinon_zero(&self, value: Option<i32>) -> Option<i32> { - value - } - - fn sinon_u8_dec(&self, value: u8) -> u8 { - value - } - fn sinon_i8_dec(&self, value: i8) -> i8 { - value - } - fn sinon_u16_dec(&self, value: u16) -> u16 { - value - } - fn sinon_i16_dec(&self, value: i16) -> i16 { - value - } - fn sinon_u32_dec(&self, value: u32) -> u32 { - value - } - fn sinon_i32_dec(&self, value: i32) -> i32 { - value - } - fn sinon_u64_dec(&self, value: u64) -> u64 { - value - } - fn sinon_i64_dec(&self, value: i64) -> i64 { - value - } - - fn sinon_u8_hex(&self, value: u8) -> u8 { - value - } - fn sinon_i8_hex(&self, value: i8) -> i8 { - value - } - fn sinon_u16_hex(&self, value: u16) -> u16 { - value - } - fn sinon_i16_hex(&self, value: i16) -> i16 { - value - } - fn sinon_u32_hex(&self, value: u32) -> u32 { - value - } - fn sinon_i32_hex(&self, value: i32) -> i32 { - value - } - fn sinon_u64_hex(&self, value: u64) -> u64 { - value - } - fn sinon_i64_hex(&self, value: i64) -> i64 { - value - } - - fn sinon_u32_oct(&self, value: u32) -> u32 { - value - } - - fn sinon_f32(&self, value: f32) -> f32 { - value - } - fn sinon_f64(&self, value: f64) -> f64 { - value - } - - fn sinon_enum(&self, value: Enumeration) -> Enumeration { - value - } -} - -pub struct OptionneurDictionnaire { - i8_var: i8, - u8_var: u8, - i16_var: i16, - u16_var: u16, - i32_var: i32, - u32_var: u32, - i64_var: i64, - u64_var: u64, - float_var: f32, - double_var: f64, - boolean_var: bool, - string_var: String, - list_var: Vec<String>, - enumeration_var: Enumeration, - dictionnaire_var: Option<minusculeMAJUSCULEEnum>, -} - -uniffi::include_scaffolding!("rondpoint"); diff --git a/third_party/rust/uniffi-example-rondpoint/src/rondpoint.udl b/third_party/rust/uniffi-example-rondpoint/src/rondpoint.udl deleted file mode 100644 index 7c8261d74e..0000000000 --- a/third_party/rust/uniffi-example-rondpoint/src/rondpoint.udl +++ /dev/null @@ -1,146 +0,0 @@ -namespace rondpoint { - Dictionnaire copie_dictionnaire(Dictionnaire d); - Enumeration copie_enumeration(Enumeration e); - sequence<Enumeration> copie_enumerations(sequence<Enumeration> e); - record<string, EnumerationAvecDonnees> copie_carte(record<string, EnumerationAvecDonnees> c); - boolean switcheroo(boolean b); -}; - -dictionary minusculeMAJUSCULEDict { - boolean minusculeMAJUSCULEField; -}; - -enum minusculeMAJUSCULEEnum { - "minusculeMAJUSCULEVariant", -}; - -enum Enumeration { - "Un", - "Deux", - "Trois", -}; - -[Enum] -interface EnumerationAvecDonnees { - Zero(); - Un(u32 premier); - Deux(u32 premier, string second); -}; - -dictionary Dictionnaire { - Enumeration un; - boolean deux; - u8 petit_nombre; - u64 gros_nombre; -}; - -dictionary DictionnaireNombres { - u8 petit_nombre; - u16 court_nombre; - u32 nombre_simple; - u64 gros_nombre; -}; - -dictionary DictionnaireNombresSignes { - i8 petit_nombre; - i16 court_nombre; - i32 nombre_simple; - i64 gros_nombre; -}; - -interface Retourneur { - constructor(); - i8 identique_i8(i8 value); - u8 identique_u8(u8 value); - i16 identique_i16(i16 value); - u16 identique_u16(u16 value); - i32 identique_i32(i32 value); - u32 identique_u32(u32 value); - i64 identique_i64(i64 value); - u64 identique_u64(u64 value); - float identique_float(float value); - double identique_double(double value); - boolean identique_boolean(boolean value); - string identique_string(string value); - - DictionnaireNombresSignes identique_nombres_signes(DictionnaireNombresSignes value); - DictionnaireNombres identique_nombres(DictionnaireNombres value); - OptionneurDictionnaire identique_optionneur_dictionnaire(OptionneurDictionnaire value); -}; - -interface Stringifier { - constructor(); - string well_known_string(string value); - - string to_string_i8(i8 value); - string to_string_u8(u8 value); - string to_string_i16(i16 value); - string to_string_u16(u16 value); - string to_string_i32(i32 value); - string to_string_u32(u32 value); - string to_string_i64(i64 value); - string to_string_u64(u64 value); - string to_string_float(float value); - string to_string_double(double value); - string to_string_boolean(boolean value); -}; - -interface Optionneur { - constructor(); - boolean sinon_boolean(optional boolean value = false); - string sinon_string(optional string value = "default"); - - sequence<string> sinon_sequence(optional sequence<string> value = []); - - // Either sides of nullable. - string? sinon_null(optional string? value = null); - i32? sinon_zero(optional i32? value = 0); - - // Decimal integers, all 42. - u8 sinon_u8_dec(optional u8 value = 42); - i8 sinon_i8_dec(optional i8 value = -42); - u16 sinon_u16_dec(optional u16 value = 42); - i16 sinon_i16_dec(optional i16 value = 42); - u32 sinon_u32_dec(optional u32 value = 42); - i32 sinon_i32_dec(optional i32 value = 42); - u64 sinon_u64_dec(optional u64 value = 42); - i64 sinon_i64_dec(optional i64 value = 42); - - // Hexadecimal, including negatgives. - u8 sinon_u8_hex(optional u8 value = 0xff); - i8 sinon_i8_hex(optional i8 value = -0x7f); - u16 sinon_u16_hex(optional u16 value = 0xffff); - i16 sinon_i16_hex(optional i16 value = 0x7f); - u32 sinon_u32_hex(optional u32 value = 0xffffffff); - i32 sinon_i32_hex(optional i32 value = 0x7fffffff); - u64 sinon_u64_hex(optional u64 value = 0xffffffffffffffff); - i64 sinon_i64_hex(optional i64 value = 0x7fffffffffffffff); - - // Octal, FWIW. - u32 sinon_u32_oct(optional u32 value = 0755); - - // Floats - f32 sinon_f32(optional f32 value = 42.0); - f64 sinon_f64(optional f64 value = 42.1); - - // Enums, which we have to treat as strings in the UDL frontend. - Enumeration sinon_enum(optional Enumeration value = "Trois"); -}; - -dictionary OptionneurDictionnaire { - i8 i8_var = -8; - u8 u8_var = 8; - i16 i16_var = -0x10; - u16 u16_var = 0x10; - i32 i32_var = -32; - u32 u32_var = 32; - i64 i64_var = -64; - u64 u64_var = 64; - float float_var = 4.0; - double double_var = 8.0; - boolean boolean_var = true; - string string_var = "default"; - sequence<string> list_var = []; - Enumeration enumeration_var = "DEUX"; - minusculeMAJUSCULEEnum? dictionnaire_var = null; -}; |