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

Move crates into a cargo workspace #1

Merged
merged 490 commits into from
Aug 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
490 commits
Select commit Hold shift + click to select a range
996c5b4
Improve some doc one-line summaries.
SSheldon Mar 16, 2015
0fba652
Remove PartialEq str for Encoding.
SSheldon Mar 16, 2015
49a45b7
Added a StrongPtr struct to remove unsafe_destructor.
SSheldon Mar 17, 2015
edb306b
Added a WeakPtr struct to remove unsafe_destructor.
SSheldon Mar 17, 2015
be89cc2
Make ClassDecl::add_method methods unsafe.
SSheldon Mar 19, 2015
4e51ba4
Added gitignore.
SSheldon Mar 23, 2015
f2d8597
Updated to use objc 0.1.
SSheldon Mar 23, 2015
672d382
Moved code to a src directory.
SSheldon Mar 23, 2015
fcbb30c
Removed owned and shared array traits.
SSheldon Mar 26, 2015
2ebb16b
Updated for Index changes in the latest rust.
SSheldon Mar 26, 2015
e936115
Updated for the trivial_casts lint in the latest rust.
SSheldon Mar 26, 2015
5bac2d8
Updated for the trivial_casts lint in the latest rust.
SSheldon Mar 26, 2015
f668a2c
Removed deprecated Str trait.
SSheldon Mar 27, 2015
1f1155a
Removed as_ref and the core feature.
SSheldon Mar 27, 2015
610a315
Derive Clone on copyable structs for the beta.
SSheldon Apr 4, 2015
f955c5f
Replace uses of PhantomFn with Sized.
SSheldon Apr 4, 2015
30d4af6
Implemented fmt::Pointer for Id.
SSheldon Apr 11, 2015
5cc5091
Updated for the latest rust.
SSheldon Apr 11, 2015
a096de9
Replace objc's Block with the standalone block crate.
SSheldon Apr 17, 2015
affc30b
Removed unnecessary Sized bounds.
SSheldon Apr 18, 2015
80a8c82
Added config for Cargo and gitignore.
SSheldon May 2, 2015
74fae53
Updated objc_id to compile as its own crate.
SSheldon May 2, 2015
c39811f
Added README and some crate documentation.
SSheldon May 2, 2015
18ac034
Added more metadata and bumped to version 0.0.1.
SSheldon May 2, 2015
f01caf8
Replace objc's Id with the standalone objc_id crate.
SSheldon May 2, 2015
0f1d31a
Initial commit.
SSheldon May 6, 2015
055a8b3
Added extern exception functions.
SSheldon May 6, 2015
71ab8b7
Added build script and linked extern functions.
SSheldon May 6, 2015
db0cfe6
Added rust wrappers for throw and try.
SSheldon May 6, 2015
53cd110
Make try safe for unwinding.
SSheldon May 8, 2015
fe3d102
Added documentation.
SSheldon May 16, 2015
38fcb13
Added more metadata and bumped to version 0.0.1.
SSheldon May 16, 2015
c0dcc2c
Update to version 0.1 of the block crate.
SSheldon May 17, 2015
c51b0cd
Don't export object macros.
SSheldon Jun 11, 2015
4b602cb
Removed unsafe from_refs methods.
SSheldon Jun 13, 2015
a004f56
NSValue returns an Encoding, not just a str.
SSheldon Jun 13, 2015
8288312
object_struct! macro actually uses a struct, not enum.
SSheldon Jun 13, 2015
47048ed
Added more metadata and bumped to version 0.0.1.
SSheldon Jun 13, 2015
86c1fc7
Added an Any bound to the Ownership trait.
SSheldon Sep 3, 2015
56469fb
Bumped to version 0.0.2.
SSheldon Sep 3, 2015
f275ef6
Added an Any bound to INSObject.
SSheldon Sep 3, 2015
91790fd
Bumped to version 0.0.2.
SSheldon Sep 3, 2015
54a15a3
Export object_struct and object_impl macros
codesmythe Oct 16, 2015
0b09819
Do not use object_impl! in object_struct! and don't export it
codesmythe Oct 29, 2015
3b6512b
Updated libc dependency to allow 0.2.
SSheldon Nov 6, 2015
5d3524b
Bumped to 0.0.2.
SSheldon Nov 6, 2015
67561e8
Updated libc dependency to allow 0.2.
SSheldon Nov 7, 2015
31dd556
Bumped to version 0.0.3.
SSheldon Nov 7, 2015
e1edf99
Removed libc dependency by using std::os::raw types.
SSheldon Nov 12, 2015
810459b
Removed libc dependency by using std::os::raw types.
SSheldon Nov 12, 2015
2b02714
Replaced c_void in the public API with an opaque Exception type.
SSheldon Nov 12, 2015
88f3a29
Bumped to 0.1.0.
SSheldon Nov 12, 2015
6def4ae
Bumped to version 0.0.4.
SSheldon Dec 9, 2015
ad1eb08
Coerce to a function pointer before transmuting.
SSheldon Mar 20, 2016
5071216
Bumped to 0.1.1.
SSheldon Mar 20, 2016
8e37301
Updated objc dependency to 0.2.
SSheldon Mar 20, 2016
df7809c
Bumped to version 0.1.0.
SSheldon Mar 20, 2016
7e9ce5b
Updated objc dependency to 0.2 and objc_id to 0.1.
SSheldon Mar 20, 2016
913ba54
Bumped to version 0.1.0.
SSheldon Mar 20, 2016
f918819
Fix INSMutableArray::sort_by now that functions are zero-sized.
SSheldon Jun 19, 2016
0c157a5
Bumped to version 0.1.1.
SSheldon Jun 19, 2016
8ae8c07
Tweak some type annotations for better verification.
SSheldon Jun 19, 2016
5ce8e95
Initial commit.
SSheldon Sep 11, 2016
97c5118
Added stub Encoding trait and Int struct.
SSheldon Sep 11, 2016
bdd81ac
Stubbed out Parser.
SSheldon Sep 11, 2016
b3a8a90
Switched Debug to Display.
SSheldon Sep 11, 2016
b4f12e0
Added slightly more realistic parsing.
SSheldon Sep 11, 2016
94a57a1
Added a Pointer encoding struct.
SSheldon Sep 11, 2016
f4affec
WIP pointer parsing
SSheldon Sep 11, 2016
24f9b6f
Simplified BoxedEncodingCompletion
SSheldon Sep 11, 2016
85df2d0
Remove unused import.
SSheldon Jan 7, 2017
cc92447
Implement Display for NSString.
SSheldon Jan 7, 2017
fbc0c91
Added a stub objc-foundation-derive crate.
SSheldon Jan 7, 2017
7d74bf1
Use static linking in derived NSObject.
SSheldon Jan 7, 2017
e3e4ae1
Properly handle generics.
SSheldon Jan 7, 2017
a71a2ea
Implement more traits.
SSheldon Jan 7, 2017
f913f37
Split generation into multiple quotes.
SSheldon Jan 7, 2017
284344a
Require that INSObject be imported.
SSheldon Jan 7, 2017
9266ef3
Update derive now that macros 1.1 is stable on beta.
SSheldon Jan 8, 2017
4943976
Loosen derive dependencies.
SSheldon Jan 8, 2017
7700563
Bumped derive to 0.0.1 and added more metadata.
SSheldon Jan 8, 2017
875bd7c
Big overhaul, add methods to Encoding trait.
SSheldon Feb 6, 2017
1ccbd31
Some madness for handling structs
SSheldon Feb 6, 2017
93d7218
Add a Struct encoding type
SSheldon Feb 6, 2017
ae2d88e
Introduced a poorly named enum that'll do some nice things
SSheldon Feb 6, 2017
6fbfebd
Deref EncodeFoo to Encoding rather than implementing it
SSheldon Feb 7, 2017
550bb30
Introduce Descriptor instead of many as methods
SSheldon Feb 7, 2017
8cbc743
Add an eq method to Descriptor
SSheldon Feb 7, 2017
352444e
Added StrEncoding
SSheldon Feb 7, 2017
8b16088
Added more real parsing for StrEncoding
SSheldon Feb 7, 2017
2f4d069
Trying out a real name for EncodeFoo as AnyEncoding
SSheldon Feb 7, 2017
d7b97e4
Broke out a descriptor module.
SSheldon Feb 8, 2017
f754b64
Broke the remainder of lib.rs into encodings and parse modules
SSheldon Feb 8, 2017
58b9baa
Added public constructors for encodings
SSheldon Feb 8, 2017
ab516bf
Make a Descriptor wrapper struct to hide impl details
SSheldon Feb 8, 2017
e4e1dc0
Remove the rest of the pub mods.
SSheldon Feb 8, 2017
c54f884
Make Struct encoding use AsRef<str>
SSheldon Feb 8, 2017
b4c412b
Completed Display implementation for Primitive.
SSheldon Feb 8, 2017
bd07f1f
Remove is_const from Pointer
SSheldon Feb 9, 2017
409c009
Parsing fields besides primitives now works
SSheldon Feb 9, 2017
9f6ce44
Remove parse function entirely
SSheldon Feb 9, 2017
4997270
Added a test for chomp
SSheldon Feb 9, 2017
b83195a
Extract parsing logic
SSheldon Feb 9, 2017
0c63186
Added an is_valid function
SSheldon Feb 9, 2017
f81f8fc
Added PointerEncoding & StructEncoding traits
SSheldon Feb 12, 2017
35743d0
Make Descriptor generic
SSheldon Feb 12, 2017
2a2e7d8
Rename StrEncoding to StringEncoding
SSheldon Feb 12, 2017
deda458
Nix MaybeOwned
SSheldon Feb 12, 2017
ab3c9e3
Added StrEncoding
SSheldon Feb 12, 2017
ef2730b
Added StrStructEncoding
SSheldon Feb 12, 2017
162273a
Added eq_encoding method to Encoding
SSheldon Feb 12, 2017
20ae920
Switch fmt_all to use the Write trait
SSheldon Feb 12, 2017
2827e31
Added 2 more methods to EncodingTuple
SSheldon Feb 12, 2017
e0bcafc
Implemented a Comparator for EncodingTuples
SSheldon Feb 12, 2017
dbb5bdf
Implemented Encoding for StringEncoding
SSheldon Feb 12, 2017
c26f664
Added a StrFields iterator
SSheldon Feb 12, 2017
fd628dc
Implement FieldsComparator for StrFields
SSheldon Feb 12, 2017
311e9b5
Finally got tests compiling again
SSheldon Feb 12, 2017
9589bb8
Fix bug in Pointer::eq_encoding
SSheldon Feb 12, 2017
daa0f8a
Tweak write_all impl
SSheldon Feb 12, 2017
84bbd5f
Removed fields_eq for an eq_struct method
SSheldon Feb 12, 2017
72eeb38
Stop finding the separator twice in StrStructEncoding
SSheldon Feb 12, 2017
fbb59f9
Bring back ParseResult.
SSheldon Feb 12, 2017
646053f
Get is_valid compiling again
SSheldon Feb 12, 2017
eeeb3bb
Found a cute way to remove StringEncoding
SSheldon Feb 12, 2017
863835f
Swapped StrEncoding constructor names
SSheldon Feb 12, 2017
ddbbd0d
Broke parse module into submodules
SSheldon Feb 12, 2017
260468d
Don't implement sub str encodings using StrEncoding
SSheldon Feb 12, 2017
e63fc83
Publicly expose StrEncoding
SSheldon Feb 13, 2017
aeee7bc
Broke out code related to multiple encodings into a multi mod
SSheldon Feb 13, 2017
9483cab
New names: Encodings and EncodingsComparator
SSheldon Feb 13, 2017
390649d
Implement Encodings via macro
SSheldon Feb 13, 2017
3a4acd7
Implement Encodings up to 12
SSheldon Feb 13, 2017
1296bba
Broke encodings into a bunch of files.
SSheldon Feb 13, 2017
d4403b5
Break the encodings tests up among the submodules.
SSheldon Feb 13, 2017
3048106
Added BitField primitive.
SSheldon Feb 13, 2017
4cf8eaa
Added parsing basics for arrays and unions
SSheldon Feb 13, 2017
af1e840
Added missing primitives
SSheldon Feb 13, 2017
a2b700b
Switch Pointee to Target
SSheldon Feb 14, 2017
1cdf8ad
Split out IndexEncodings from Encodings
SSheldon Feb 14, 2017
7945823
Made StrFields implement Encodings
SSheldon Feb 14, 2017
8fd54ec
Changed StructEncoding to have a Fields type
SSheldon Feb 14, 2017
eb70758
Overhaul again: remove Pointer/StructEncoding traits
SSheldon Feb 14, 2017
791ad0f
Revert ParseResult once again
SSheldon Feb 14, 2017
0483790
Complete implementing Encodings for StrEncoding
SSheldon Feb 14, 2017
15f3e0d
Functional-ify parsing
SSheldon Feb 14, 2017
03ae3e2
Added array and union support to the Encoding trait
SSheldon Feb 15, 2017
63b54de
Added an Array encoding struct.
SSheldon Feb 15, 2017
c4c7e99
Remove StrFieldsIter::eq
SSheldon Feb 15, 2017
29e6abc
Implemented Encodings for [Encoding]
SSheldon Feb 15, 2017
756580d
Finished chomp_primitive
SSheldon Feb 15, 2017
a027149
Better panic messages
SSheldon Feb 15, 2017
781e069
Add validated StrEncoding constructors
SSheldon Feb 15, 2017
2faf2fb
Restructuring in parse
SSheldon Feb 16, 2017
4903374
Derived common traits for all types
SSheldon Feb 16, 2017
7214c50
Strip qualifiers when parsing
SSheldon Feb 16, 2017
a8de5fc
Tweak chomp_nested_delims to use str::find
SSheldon Feb 16, 2017
88a03f7
Added a parse helper method
SSheldon Feb 16, 2017
01a568d
Added StrEncoding support for Unions
SSheldon Feb 16, 2017
c33e638
Added a Union struct
SSheldon Feb 16, 2017
6c0c9b7
Add a real error for invalid StrEncodings
SSheldon Feb 16, 2017
9defa7c
no_std
SSheldon Feb 16, 2017
14554e3
Provide IndexEncodingsComparator via a method
SSheldon Feb 16, 2017
ee70b70
Publicly expose ParseEncodingError.
SSheldon Feb 16, 2017
0cdd315
Copy and adapt the Encode trait from objc
SSheldon Feb 16, 2017
718f575
Realized Never doesn't need to be public
SSheldon Feb 16, 2017
a9731d6
Move Encoding trait to the crate root
SSheldon Feb 16, 2017
6c97c83
Added an Encodings::each method
SSheldon Feb 17, 2017
14c7cdb
Actually the callback should be passed by reference
SSheldon Feb 17, 2017
41520f2
Implemented equality for StrFields using Encodings::each
SSheldon Feb 17, 2017
7de2f23
Implement equality for IndexEncodings using Encodings::each
SSheldon Feb 17, 2017
72910f6
Removed EncodingsComparator and made IndexEncodings private
SSheldon Feb 17, 2017
8543b70
Add a default implementation of Encodings::write_all
SSheldon Feb 17, 2017
3b7ea92
Add the missing s to EncodingsIterateCallback
SSheldon Feb 17, 2017
05f34c6
Wrote some documentation
SSheldon Feb 17, 2017
1c01adc
eq_encoding can actually be provided now
SSheldon Feb 17, 2017
8342048
Added an example of defining a BoxedEncoding
SSheldon Feb 17, 2017
d6e1722
Added a from_str method in the BoxedEncoding example
SSheldon Feb 17, 2017
0c421e2
Make Descriptors copy regardless of their type params
SSheldon Feb 18, 2017
077e5c6
Added Primitive::Block
SSheldon Feb 18, 2017
fd2d020
Rename StrFields as StrEncodings
SSheldon Feb 18, 2017
50c22b9
Make the parse module public
SSheldon Feb 18, 2017
9ed2ba8
Turns out I totally misunderstood arrays from the docs
SSheldon Feb 18, 2017
ca6ef8c
Extract a chomp_number function
SSheldon Feb 18, 2017
8a645b0
Fixed array handling to not expect a ^ separator
SSheldon Feb 18, 2017
323ca5d
No longer return the original string after a failed chomp
SSheldon Feb 18, 2017
2bc8f57
Replace Encoding's fmt::Display requirement with Encoding::write
SSheldon Feb 18, 2017
cdaf5f3
Added a failing test for parsing garbage encodings
SSheldon Feb 19, 2017
389b201
Prevent panic on parsing unicode
SSheldon Feb 19, 2017
9ccac77
Added an example showing composition with CGRect
SSheldon Feb 19, 2017
d0d0480
Documented Encoding and Descriptor
SSheldon Feb 19, 2017
2a74175
Documented parse
SSheldon Feb 19, 2017
ce9e0de
Documented encoding
SSheldon Feb 19, 2017
4e79f38
Added crate-level documentation.
SSheldon Feb 19, 2017
f3921b4
Add a libc dependency to implement Encode for more types
SSheldon Feb 19, 2017
6be3379
Bumped to 0.0.1 and added Cargo metadata.
SSheldon Feb 19, 2017
59c0ba6
Pulled descriptor into its own module.
SSheldon Feb 19, 2017
9955a9e
Moved Primitive writing into descriptor
SSheldon Feb 19, 2017
778bf26
Moved Primitive equality into descriptor
SSheldon Feb 19, 2017
4f70198
Implement PartialEq for encodings
SSheldon Feb 19, 2017
f5338f6
Added a failing test of IndexEncodingsComparator.
SSheldon Feb 19, 2017
a3b98b3
Fix IndexEncodingsComparator
SSheldon Feb 19, 2017
db2e748
Replace ? with try! to support older rustc
SSheldon Feb 20, 2017
1359042
Implement Encode for pointers when references do
SSheldon Feb 20, 2017
d5d8d84
Bring back the Display requirement for Encodings
SSheldon Feb 20, 2017
1e377bf
Bumped to version 0.0.2
SSheldon Feb 20, 2017
e5513f9
Fix Never to compile on 1.14 and 1.16
SSheldon Mar 7, 2017
dfcad8e
Move ?Sized bounds out of where clauses
SSheldon Mar 7, 2017
633b6a6
Add cargo categories and bump to 0.0.3
SSheldon Apr 30, 2017
15f9ebe
Use the new class! macro added to objc
SSheldon Jul 7, 2018
0cfd606
Use StrongPtr and WeakPtr from objc::rc
SSheldon Jul 22, 2018
6527cdf
Bumped to version 0.1.1
SSheldon Jul 22, 2018
1b08f4e
Remove unused fmt_repeat! macro
SSheldon Jul 29, 2018
a7c9f55
Stop using anonymous parameters in trait definitions
SSheldon Mar 24, 2019
e439a64
Switch to using ? from try!
SSheldon Mar 24, 2019
cc87652
Update to Rust 2018 and change lots of use statements
SSheldon Mar 24, 2019
d432555
Change away from deprecated trim_left_matches
SSheldon Mar 24, 2019
3af3b1b
Make encoding constructors const
SSheldon Mar 24, 2019
44e6f60
Try out a completely new design using associated constants
SSheldon Mar 24, 2019
5cd4d15
Get parsing working again on the new design
SSheldon Mar 24, 2019
15313eb
Fix doc examples
SSheldon Mar 24, 2019
f9b9f23
Make the encoding module private
SSheldon Mar 24, 2019
0442e82
Docs tweak for Encoding
SSheldon Mar 24, 2019
5f1993a
Remove unnecessary StrEncodings struct
SSheldon Mar 25, 2019
c6bef53
Implement PartialEq between Encoding and str
SSheldon Mar 25, 2019
033a87b
Make the parse module entirely private
SSheldon Mar 25, 2019
9085cd2
Rename CODE to ENCODING
SSheldon Mar 25, 2019
8e1190a
Slightly better docs
SSheldon Mar 25, 2019
5e81be5
Remove libc dependency
SSheldon Mar 25, 2019
293adf0
Update README
SSheldon Mar 25, 2019
77b7922
Bumped to version 1.0.0
SSheldon Mar 25, 2019
094f541
Remove StrEncoding in favor of a simpler equality check
SSheldon Apr 10, 2019
d4fcd1d
Move parse now that it has no submodules
SSheldon Apr 10, 2019
93f7b04
Turns out ? works with Option, too
SSheldon Apr 12, 2019
aa345a8
chomp_int is technically still used
SSheldon May 5, 2019
70c6d1a
impl Encode for [N; T], where 1 <= N <= 32, T: Encode
burtonageo Oct 7, 2019
21dd781
Bumped to version 1.1.0
SSheldon Oct 16, 2019
c86ad3a
Switch to cc builds
kvark Oct 29, 2019
0f2c404
Loosen some unnecessary impl bounds
SSheldon Jan 19, 2020
7fbdb48
Move `objc` crate to subdirectory
madsmtm Aug 29, 2021
668e315
Merge `objc_exception` from https://github.com/SSheldon/rust-objc-exc…
madsmtm Aug 29, 2021
00fb456
Move `objc_exception` crate to subdirectory
madsmtm Aug 29, 2021
4ac3a9d
Merge `objc_encode` from https://github.com/SSheldon/rust-objc-encode
madsmtm Aug 29, 2021
cc54c2b
Move `objc_encode` crate to subdirectory
madsmtm Aug 29, 2021
542ac19
Merge `objc_id` from https://github.com/SSheldon/rust-objc-id
madsmtm Aug 29, 2021
f629eaa
Move `objc_id` crate to subdirectory
madsmtm Aug 29, 2021
0638bf6
Merge `objc_foundation` from https://github.com/SSheldon/rust-objc-fo…
madsmtm Aug 29, 2021
a4b83e4
Move `objc_foundation` crate to subdirectory
madsmtm Aug 29, 2021
22339ca
Merge gitignores from the different repositories
madsmtm Aug 29, 2021
8fc1393
Create a cargo workspace
madsmtm Aug 29, 2021
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
doc/
target/
Cargo.lock

Expand Down
41 changes: 8 additions & 33 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,33 +1,8 @@
[package]
name = "objc"
version = "0.2.7"
authors = ["Steven Sheldon"]
edition = "2018"

description = "Objective-C Runtime bindings and wrapper for Rust."
keywords = ["objective-c", "osx", "ios", "cocoa", "uikit"]
readme = "README.md"
repository = "http://github.com/SSheldon/rust-objc"
documentation = "http://ssheldon.github.io/rust-objc/objc/"
license = "MIT"

exclude = [
".gitignore",
".travis.yml",
"doc.sh",
"travis_install.sh",
"travis_test.sh",
"tests-ios/**",
]

[features]
exception = ["objc_exception"]
verify_message = []

[dependencies]
malloc_buf = "1.0"
objc-encode = "1.0"

[dependencies.objc_exception]
version = "0.1"
optional = true
[workspace]
members = [
"objc",
"objc_encode",
"objc_exception",
"objc_foundation",
"objc_id",
]
File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions objc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[package]
name = "objc"
version = "0.2.7"
authors = ["Steven Sheldon"]
edition = "2018"

description = "Objective-C Runtime bindings and wrapper for Rust."
keywords = ["objective-c", "osx", "ios", "cocoa", "uikit"]
readme = "README.md"
repository = "http://github.com/SSheldon/rust-objc"
documentation = "http://ssheldon.github.io/rust-objc/objc/"
license = "MIT"

exclude = [
".gitignore",
".travis.yml",
"doc.sh",
"travis_install.sh",
"travis_test.sh",
"tests-ios/**",
]

[features]
exception = ["objc_exception"]
verify_message = []

[dependencies]
malloc_buf = "1.0"
objc-encode = { path = "../objc_encode", version = "1.0" }
objc_exception = { path = "../objc_exception", version = "0.1", optional = true }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions objc_encode/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "objc-encode"
version = "1.1.0"
authors = ["Steven Sheldon"]
edition = "2018"

description = "Objective-C type encoding creation and parsing in Rust."
keywords = ["objective-c", "osx", "ios", "cocoa", "uikit"]
categories = ["development-tools::ffi", "no-std"]
readme = "README.md"
repository = "http://github.com/SSheldon/rust-objc-encode"
documentation = "http://ssheldon.github.io/rust-objc/objc_encode/"
license = "MIT"

exclude = [
".gitignore",
]
38 changes: 38 additions & 0 deletions objc_encode/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Objective-C type encoding creation and parsing in Rust.

The Objective-C compiler encodes types as strings for usage in the runtime.
This crate aims to provide a strongly-typed (rather than stringly-typed) way
to create and describe these type encodings without memory allocation in Rust.

# Implementing Encode

This crate declares an `Encode` trait that can be implemented for types that
the Objective-C compiler can encode. Implementing this trait looks like:

``` rust
unsafe impl Encode for CGPoint {
const ENCODING: Encoding<'static> =
Encoding::Struct("CGPoint", &[CGFloat::ENCODING, CGFLOAT::ENCODING]);
}
```

For an example of how this works with more complex types, like structs
containing structs, see the `core_graphics` example.

# Comparing with encoding strings

An `Encoding` can be compared with an encoding string from the Objective-C
runtime:

``` rust
assert!(&i32::ENCODING == "i");
```

# Generating encoding strings

Every `Encoding` implements `Display` as its string representation.
This can be generated conveniently through the `to_string` method:

``` rust
assert_eq!(i32::ENCODING.to_string(), "i");
```
46 changes: 46 additions & 0 deletions objc_encode/examples/core_graphics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
extern crate objc_encode;

use objc_encode::{Encode, Encoding};

#[cfg(target_pointer_width = "32")]
type CGFloat = f32;

#[cfg(target_pointer_width = "64")]
type CGFloat = f64;

#[repr(C)]
struct CGPoint {
x: CGFloat,
y: CGFloat,
}

unsafe impl Encode for CGPoint {
const ENCODING: Encoding<'static> =
Encoding::Struct("CGPoint", &[CGFloat::ENCODING, CGFloat::ENCODING]);
}

#[repr(C)]
struct CGSize {
width: CGFloat,
height: CGFloat,
}

unsafe impl Encode for CGSize {
const ENCODING: Encoding<'static> =
Encoding::Struct("CGSize", &[CGFloat::ENCODING, CGFloat::ENCODING]);
}

#[repr(C)]
struct CGRect {
origin: CGPoint,
size: CGSize,
}

unsafe impl Encode for CGRect {
const ENCODING: Encoding<'static> =
Encoding::Struct("CGRect", &[CGPoint::ENCODING, CGSize::ENCODING]);
}

fn main() {
println!("{}", CGRect::ENCODING);
}
103 changes: 103 additions & 0 deletions objc_encode/src/encode.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
use core::ffi::c_void;

use crate::Encoding;

/// Types that have an Objective-C type encoding.
///
/// Unsafe because Objective-C will make assumptions about the type (like its
/// size and alignment) from its encoding, so the implementer must verify that
/// the encoding is accurate.
pub unsafe trait Encode {
/// Returns the Objective-C type encoding for Self.
const ENCODING: Encoding<'static>;
}

macro_rules! encode_impls {
($($t:ty : $e:ident,)*) => ($(
unsafe impl Encode for $t {
const ENCODING: Encoding<'static> = Encoding::$e;
}
)*);
}

encode_impls!(
i8: Char,
i16: Short,
i32: Int,
i64: LongLong,
u8: UChar,
u16: UShort,
u32: UInt,
u64: ULongLong,
f32: Float,
f64: Double,
bool: Bool,
(): Void,
*mut i8: String,
*const i8: String,
*mut u8: String,
*const u8: String,
);

unsafe impl Encode for isize {
#[cfg(target_pointer_width = "32")]
const ENCODING: Encoding<'static> = i32::ENCODING;

#[cfg(target_pointer_width = "64")]
const ENCODING: Encoding<'static> = i64::ENCODING;
}

unsafe impl Encode for usize {
#[cfg(target_pointer_width = "32")]
const ENCODING: Encoding<'static> = u32::ENCODING;

#[cfg(target_pointer_width = "64")]
const ENCODING: Encoding<'static> = u64::ENCODING;
}

unsafe impl Encode for *mut c_void {
const ENCODING: Encoding<'static> = Encoding::Pointer(&Encoding::Void);
}

unsafe impl Encode for *const c_void {
const ENCODING: Encoding<'static> = Encoding::Pointer(&Encoding::Void);
}

// TODO: Replace this with a const generics implementation when they stabilise (#44580)
macro_rules! slice_encode_impl {
($($n:literal),* $(,)?) => {
$(
unsafe impl<T: Encode> Encode for [T; $n] {
const ENCODING: Encoding<'static> = Encoding::Array($n, &<T as Encode>::ENCODING);
}
)*
};
}

slice_encode_impl!(
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31, 32
);

/*
External crates cannot implement Encode for pointers or Optionals, but they
*can* implement it for references. rust-lang/rust#25126

As a workaround, we provide implementations for these types that return the
same encoding as references.
*/
unsafe impl<T> Encode for *const T where for<'b> &'b T: Encode {
const ENCODING: Encoding<'static> = <&T>::ENCODING;
}

unsafe impl<T> Encode for *mut T where for<'b> &'b mut T: Encode {
const ENCODING: Encoding<'static> = <&mut T>::ENCODING;
}

unsafe impl<'a, T> Encode for Option<&'a T> where for<'b> &'b T: Encode {
const ENCODING: Encoding<'static> = <&T>::ENCODING;
}

unsafe impl<'a, T> Encode for Option<&'a mut T> where for<'b> &'b mut T: Encode {
const ENCODING: Encoding<'static> = <&mut T>::ENCODING;
}
Loading