-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
279 additions
and
7 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[package] | ||
name = "test_encoding_cstr" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[lib] | ||
path = "lib.rs" | ||
|
||
[dependencies] | ||
objc2-encode = { path = "../../../objc2-encode", default-features = false } | ||
|
||
[features] | ||
default = ["apple", "std"] | ||
std = ["objc2-encode/std"] | ||
|
||
# Runtime | ||
apple = [] | ||
gnustep-1-7 = [] | ||
gnustep-1-8 = ["gnustep-1-7"] | ||
gnustep-1-9 = ["gnustep-1-8"] | ||
gnustep-2-0 = ["gnustep-1-9"] | ||
gnustep-2-1 = ["gnustep-2-0"] | ||
|
||
# Hack | ||
assembly-features = ["std"] |
13 changes: 13 additions & 0 deletions
13
test-assembly/crates/test_encoding_cstr/expected/apple-aarch64.s
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,13 @@ | ||
.section __TEXT,__text,regular,pure_instructions | ||
.section __TEXT,__const | ||
l_anon.a88231c846af3b75605317c1ca346ede.0: | ||
.asciz "c\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" | ||
|
||
.section __DATA,__const | ||
.globl _ENC | ||
.p2align 3 | ||
_ENC: | ||
.quad l_anon.a88231c846af3b75605317c1ca346ede.0 | ||
.asciz "\002\000\000\000\000\000\000" | ||
|
||
.subsections_via_symbols |
14 changes: 14 additions & 0 deletions
14
test-assembly/crates/test_encoding_cstr/expected/apple-armv7.s
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,14 @@ | ||
.section __TEXT,__text,regular,pure_instructions | ||
.syntax unified | ||
.section __TEXT,__const | ||
l_anon.a88231c846af3b75605317c1ca346ede.0: | ||
.asciz "c\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" | ||
|
||
.section __DATA,__const | ||
.globl _ENC | ||
.p2align 2 | ||
_ENC: | ||
.long l_anon.a88231c846af3b75605317c1ca346ede.0 | ||
.asciz "\002\000\000" | ||
|
||
.subsections_via_symbols |
14 changes: 14 additions & 0 deletions
14
test-assembly/crates/test_encoding_cstr/expected/apple-armv7s.s
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,14 @@ | ||
.section __TEXT,__text,regular,pure_instructions | ||
.syntax unified | ||
.section __TEXT,__const | ||
l_anon.a88231c846af3b75605317c1ca346ede.0: | ||
.asciz "c\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" | ||
|
||
.section __DATA,__const | ||
.globl _ENC | ||
.p2align 2 | ||
_ENC: | ||
.long l_anon.a88231c846af3b75605317c1ca346ede.0 | ||
.asciz "\002\000\000" | ||
|
||
.subsections_via_symbols |
14 changes: 14 additions & 0 deletions
14
test-assembly/crates/test_encoding_cstr/expected/apple-x86.s
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,14 @@ | ||
.section __TEXT,__text,regular,pure_instructions | ||
.intel_syntax noprefix | ||
.section __TEXT,__const | ||
l_anon.a88231c846af3b75605317c1ca346ede.0: | ||
.asciz "c\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" | ||
|
||
.section __DATA,__const | ||
.globl _ENC | ||
.p2align 2 | ||
_ENC: | ||
.long l_anon.a88231c846af3b75605317c1ca346ede.0 | ||
.asciz "\002\000\000" | ||
|
||
.subsections_via_symbols |
14 changes: 14 additions & 0 deletions
14
test-assembly/crates/test_encoding_cstr/expected/apple-x86_64.s
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,14 @@ | ||
.section __TEXT,__text,regular,pure_instructions | ||
.intel_syntax noprefix | ||
.section __TEXT,__const | ||
l_anon.a88231c846af3b75605317c1ca346ede.0: | ||
.asciz "c\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" | ||
|
||
.section __DATA,__const | ||
.globl _ENC | ||
.p2align 3 | ||
_ENC: | ||
.quad l_anon.a88231c846af3b75605317c1ca346ede.0 | ||
.asciz "\002\000\000\000\000\000\000" | ||
|
||
.subsections_via_symbols |
18 changes: 18 additions & 0 deletions
18
test-assembly/crates/test_encoding_cstr/expected/gnustep-x86.s
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,18 @@ | ||
.text | ||
.intel_syntax noprefix | ||
.type .Lanon.a88231c846af3b75605317c1ca346ede.0,@object | ||
.section .rodata..Lanon.a88231c846af3b75605317c1ca346ede.0,"a",@progbits | ||
.Lanon.a88231c846af3b75605317c1ca346ede.0: | ||
.asciz "c\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" | ||
.size .Lanon.a88231c846af3b75605317c1ca346ede.0, 128 | ||
|
||
.type ENC,@object | ||
.section .data.rel.ro.ENC,"aw",@progbits | ||
.globl ENC | ||
.p2align 2 | ||
ENC: | ||
.long .Lanon.a88231c846af3b75605317c1ca346ede.0 | ||
.asciz "\002\000\000" | ||
.size ENC, 8 | ||
|
||
.section ".note.GNU-stack","",@progbits |
18 changes: 18 additions & 0 deletions
18
test-assembly/crates/test_encoding_cstr/expected/gnustep-x86_64.s
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,18 @@ | ||
.text | ||
.intel_syntax noprefix | ||
.type .Lanon.a88231c846af3b75605317c1ca346ede.0,@object | ||
.section .rodata..Lanon.a88231c846af3b75605317c1ca346ede.0,"a",@progbits | ||
.Lanon.a88231c846af3b75605317c1ca346ede.0: | ||
.asciz "c\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" | ||
.size .Lanon.a88231c846af3b75605317c1ca346ede.0, 128 | ||
|
||
.type ENC,@object | ||
.section .data.rel.ro.ENC,"aw",@progbits | ||
.globl ENC | ||
.p2align 3 | ||
ENC: | ||
.quad .Lanon.a88231c846af3b75605317c1ca346ede.0 | ||
.asciz "\002\000\000\000\000\000\000" | ||
.size ENC, 16 | ||
|
||
.section ".note.GNU-stack","",@progbits |
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 @@ | ||
//! Test that the encoding string that we output is not full length. | ||
use std::ffi::CStr; | ||
|
||
use objc2_encode::Encode; | ||
|
||
#[no_mangle] | ||
static ENC: &CStr = i8::ENCODING_CSTR; |
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,15 @@ | ||
//! Test that compilation fails when the struct name is invalid. | ||
//! | ||
//! Ideally, this should be tested by `trybuild`, but it doesn't work at the | ||
//! moment (`cargo check` doesn't catch the error). | ||
use objc2::{Encode, Encoding}; | ||
|
||
struct X; | ||
|
||
unsafe impl Encode for X { | ||
const ENCODING: Encoding<'static> = Encoding::Struct("-", &[]); | ||
} | ||
|
||
fn main() { | ||
let _ = X::ENCODING_CSTR; | ||
} |
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,17 @@ | ||
//! Test that compilation fails when the encoding is too long. | ||
//! | ||
//! Ideally, this should be tested by `trybuild`, but it doesn't work at the | ||
//! moment (`cargo check` doesn't catch the error). | ||
use objc2::{Encode, Encoding}; | ||
|
||
struct X; | ||
|
||
const S: &str = unsafe { std::str::from_utf8_unchecked(&[b'a'; 1020]) }; | ||
|
||
unsafe impl Encode for X { | ||
const ENCODING: Encoding<'static> = Encoding::Struct(S, &[]); | ||
} | ||
|
||
fn main() { | ||
let _ = X::ENCODING_CSTR; | ||
} |
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