Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor objc2_encode #412

Merged
merged 5 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions crates/block2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ license = "MIT"
default = ["std", "apple"]

# Currently not possible to turn off, put here for forwards compatibility.
std = ["alloc", "objc2-encode/std", "block-sys/std"]
alloc = ["objc2-encode/alloc", "block-sys/alloc"]
std = ["alloc", "objc2/std", "block-sys/std"]
alloc = ["objc2/alloc", "block-sys/alloc"]

# Runtime selection. Default is `apple`. See `block-sys` for details.
apple = ["block-sys/apple", "objc2-encode/apple"]
compiler-rt = ["block-sys/compiler-rt", "objc2-encode/apple"] # Use Apple's encoding
gnustep-1-7 = ["block-sys/gnustep-1-7", "objc2-encode/gnustep-1-7"]
gnustep-1-8 = ["gnustep-1-7", "block-sys/gnustep-1-8", "objc2-encode/gnustep-1-8"]
gnustep-1-9 = ["gnustep-1-8", "block-sys/gnustep-1-9", "objc2-encode/gnustep-1-9"]
gnustep-2-0 = ["gnustep-1-9", "block-sys/gnustep-2-0", "objc2-encode/gnustep-2-0"]
gnustep-2-1 = ["gnustep-2-0", "block-sys/gnustep-2-1", "objc2-encode/gnustep-2-1"]
apple = ["block-sys/apple", "objc2/apple"]
compiler-rt = ["block-sys/compiler-rt", "objc2/unstable-compiler-rt"] # TODO: fix this
gnustep-1-7 = ["block-sys/gnustep-1-7", "objc2/gnustep-1-7"]
gnustep-1-8 = ["gnustep-1-7", "block-sys/gnustep-1-8", "objc2/gnustep-1-8"]
gnustep-1-9 = ["gnustep-1-8", "block-sys/gnustep-1-9", "objc2/gnustep-1-9"]
gnustep-2-0 = ["gnustep-1-9", "block-sys/gnustep-2-0", "objc2/gnustep-2-0"]
gnustep-2-1 = ["gnustep-2-0", "block-sys/gnustep-2-1", "objc2/gnustep-2-1"]

[dependencies]
objc2-encode = { path = "../objc2-encode", version = "=2.0.0-pre.3", default-features = false }
objc2 = { path = "../objc2", version = "=0.3.0-beta.4", default-features = false }
block-sys = { path = "../block-sys", version = "=0.1.0-beta.2", default-features = false }

[package.metadata.docs.rs]
Expand Down
2 changes: 1 addition & 1 deletion crates/block2/src/block.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use core::marker::PhantomData;
use core::mem;

use objc2_encode::{Encode, EncodeArguments, Encoding, RefEncode};
use objc2::encode::{Encode, EncodeArguments, Encoding, RefEncode};

use crate::ffi;

Expand Down
2 changes: 1 addition & 1 deletion crates/block2/src/concrete_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use core::ops::Deref;
use core::ptr;
use std::os::raw::c_ulong;

use objc2_encode::{Encode, Encoding, RefEncode};
use objc2::encode::{Encode, Encoding, RefEncode};

use crate::{ffi, Block, BlockArguments, RcBlock};

Expand Down
2 changes: 1 addition & 1 deletion crates/block2/src/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use core::ops::Deref;
use core::ptr;
use std::os::raw::c_ulong;

use objc2_encode::Encode;
use objc2::encode::Encode;

use super::{ffi, Block};
use crate::BlockArguments;
Expand Down
2 changes: 1 addition & 1 deletion crates/icrate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ gnustep-2-1 = ["gnustep-2-0", "objc2?/gnustep-2-1", "block2?/gnustep-2-1"]
objective-c = ["objc2"]

# Expose features that requires creating blocks.
block = ["objc2?/block", "block2"]
block = ["block2"]

# For better documentation on docs.rs
unstable-docsrs = []
Expand Down
15 changes: 15 additions & 0 deletions crates/objc2-encode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased - YYYY-MM-DD

### Added
* Made the crate `no_std` compatible.
* Made the crate platform-agnostic.

### Changed
* **BREAKING**: Moved the `Encode`, `RefEncode`, `EncodeArguments`,
`EncodeConvert`, `OptionEncode` to `objc2`.
* **BREAKING**: `Encoding::BitField` now allows omitting the type using an
`Option`.
* **BREAKING**: Changed length field in `Encoding::Array` from `usize` to
`u64` (to be platform-agnostic).

### Fixed
* Fixed `Encoding::BitField` encoding parsing.


## 2.0.0-pre.3 - 2022-12-24

Expand Down
26 changes: 5 additions & 21 deletions crates/objc2-encode/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["Steven Sheldon", "Mads Marquart <[email protected]>"]
edition = "2021"
rust-version = "1.60"

description = "Objective-C type-encodings"
description = "Objective-C type-encoding representation and parsing"
keywords = ["objective-c", "macos", "ios", "encode"]
categories = [
"development-tools::ffi",
Expand All @@ -20,27 +20,11 @@ documentation = "https://docs.rs/objc2-encode/"
license = "MIT"

[features]
default = ["std", "apple"]
default = ["std"]

# Currently not possible to turn off, put here for forwards compatibility.
std = ["alloc", "objc-sys/std"]
alloc = ["objc-sys/alloc"]

# Enables support for the nightly c_unwind feature
unstable-c-unwind = []

# Runtime selection. See `objc-sys` for details.
apple = ["objc-sys/apple"]
gnustep-1-7 = ["objc-sys/gnustep-1-7"]
gnustep-1-8 = ["gnustep-1-7", "objc-sys/gnustep-1-8"]
gnustep-1-9 = ["gnustep-1-8", "objc-sys/gnustep-1-9"]
gnustep-2-0 = ["gnustep-1-9", "objc-sys/gnustep-2-0"]
gnustep-2-1 = ["gnustep-2-0", "objc-sys/gnustep-2-1"]

[dependencies]
# TODO: Remove this dependency when we can select `macabi` targets separately
# from other targets without using a build script
objc-sys = { path = "../objc-sys", version = "=0.2.0-beta.3", default-features = false }
std = ["alloc"]
# Currently not possible to turn off, put here for forwards compatibility
alloc = []

[package.metadata.docs.rs]
default-target = "x86_64-apple-darwin"
Expand Down
7 changes: 2 additions & 5 deletions crates/objc2-encode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@

Objective-C type-encoding in Rust.

This crates provides the equivalent of the Objective-C `@encode` directive,
and functions for comparing these encodings.

Additionally, it provides traits for annotating types that has an Objective-C
encoding.
This crates provides types to parse and compare Objective-C type-encodings
created with the `@encode` directive.

See [the docs](https://docs.rs/objc2-encode/) for a more thorough overview.

Expand Down
Loading