-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from NordSecurity/kristupas/lowercase-numeric-…
…types Lowercase the numeric types
- Loading branch information
Showing
22 changed files
with
278 additions
and
32 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
dotnet-tests/UniffiCS.binding_tests/TestCustomTypesBuiltin.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* 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/. */ | ||
|
||
using System; | ||
using uniffi.custom_types_builtin; | ||
|
||
public class TestCustomTypesBuiltin { | ||
[Fact] | ||
public void CustomTypesWork() { | ||
var demo = CustomTypesBuiltinMethods.GetCustomTypesBuiltin(); | ||
AssertDemo(demo); | ||
|
||
demo = CustomTypesBuiltinMethods.ReturnCustomTypesBuiltin(demo); | ||
AssertDemo(demo); | ||
} | ||
|
||
void AssertDemo(CustomTypesBuiltin demo) { | ||
Assert.Equal("Hello, world!", demo.@string); | ||
Assert.True(demo.boolean); | ||
Assert.Equal(SByte.MaxValue, demo.int8); | ||
Assert.Equal(Int16.MaxValue, demo.int16); | ||
Assert.Equal(Int32.MaxValue, demo.int32); | ||
Assert.Equal(Int64.MaxValue, demo.int64); | ||
Assert.Equal(Byte.MaxValue, demo.uint8); | ||
Assert.Equal(UInt16.MaxValue, demo.uint16); | ||
Assert.Equal(UInt32.MaxValue, demo.uint32); | ||
Assert.Equal(UInt64.MaxValue, demo.uint64); | ||
Assert.Equal(Single.MaxValue, demo.@float); | ||
Assert.Equal(Double.MaxValue, demo.@double); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
name = "uniffi-cs-custom-types-builtin" | ||
version = "1.0.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[lib] | ||
crate-type = ["lib", "cdylib"] | ||
name = "uniffi_cs_custom_types_builtin" | ||
|
||
[dependencies] | ||
once_cell = "1.12" | ||
paste = "1.0" | ||
thiserror = "1.0" | ||
uniffi = {path = "../../3rd-party/uniffi-rs/uniffi", features=["build"]} | ||
uniffi_macros = {path = "../../3rd-party/uniffi-rs/uniffi_macros"} | ||
|
||
[build-dependencies] | ||
uniffi = {path = "../../3rd-party/uniffi-rs/uniffi", features=["bindgen-tests"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* 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/custom-types-builtin.udl").unwrap(); | ||
} |
71 changes: 71 additions & 0 deletions
71
fixtures/custom-types-builtin/src/custom-types-builtin.udl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* 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/. */ | ||
|
||
// Ensure that builtin types can be used as the underlying type in custom types. | ||
|
||
[Custom] | ||
typedef string MyString; | ||
|
||
// using sequence or record as the underlying type produces broken code | ||
|
||
// [Custom] | ||
// typedef sequence<string> Array; | ||
|
||
// [Custom] | ||
// typedef record<string, string> Table; | ||
|
||
[Custom] | ||
typedef boolean Boolean; | ||
|
||
[Custom] | ||
typedef i8 Int8; | ||
|
||
[Custom] | ||
typedef i16 Int16; | ||
|
||
[Custom] | ||
typedef i32 Int32; | ||
|
||
[Custom] | ||
typedef i64 Int64; | ||
|
||
[Custom] | ||
typedef u8 UInt8; | ||
|
||
[Custom] | ||
typedef u16 UInt16; | ||
|
||
[Custom] | ||
typedef u32 UInt32; | ||
|
||
[Custom] | ||
typedef u64 UInt64; | ||
|
||
[Custom] | ||
typedef float Float; | ||
|
||
[Custom] | ||
typedef double Double; | ||
|
||
dictionary CustomTypesBuiltin { | ||
MyString string; | ||
// Array array; | ||
// Table table; | ||
Boolean boolean; | ||
Int8 int8; | ||
Int16 int16; | ||
Int32 int32; | ||
Int64 int64; | ||
UInt8 uint8; | ||
UInt16 uint16; | ||
UInt32 uint32; | ||
UInt64 uint64; | ||
Float float; | ||
Double double; | ||
}; | ||
|
||
namespace custom_types_builtin { | ||
CustomTypesBuiltin get_custom_types_builtin(); | ||
CustomTypesBuiltin return_custom_types_builtin(CustomTypesBuiltin custom_types); | ||
}; |
Oops, something went wrong.