Skip to content

Commit

Permalink
Rename objc2_sys -> objc-sys
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Nov 2, 2021
1 parent 7f7e1ac commit 1aefd19
Show file tree
Hide file tree
Showing 38 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
members = [
"block-sys",
"block2",
"objc-sys",
"objc2",
"objc2_encode",
"objc2_foundation",
"objc2_sys",
"objc2_test_utils",
]
exclude = ["objc2/tests-ios"]
4 changes: 2 additions & 2 deletions block-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ apple = []
compiler-rt = []

# Link to GNUStep's libobjc2 (which contains the block implementation)
gnustep-1-7 = ["objc2_sys"]
gnustep-1-7 = ["objc-sys"]
gnustep-1-8 = ["gnustep-1-7"]
gnustep-1-9 = ["gnustep-1-8"]
gnustep-2-0 = ["gnustep-1-9"]
Expand All @@ -47,4 +47,4 @@ winobjc = ["gnustep-1-8"]
objfw = []

[dependencies]
objc2_sys = { path = "../objc2_sys", optional = true }
objc-sys = { path = "../objc-sys", optional = true }
2 changes: 1 addition & 1 deletion block-sys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ package.

GNUStep is a bit odd, because it bundles blocks support into its Objective-C
runtime. This means we have to link to `libobjc`, and this is done by
depending on the `objc2_sys` crate. A bit unorthodox, yes, but it works.
depending on the `objc-sys` crate. A bit unorthodox, yes, but it works.

Sources:
- [`Block.h`](https://github.com/gnustep/libobjc2/blob/v2.1/objc/blocks_runtime.h)
Expand Down
2 changes: 1 addition & 1 deletion block-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn main() {
println!("cargo:rustc-link-lib=dylib=BlocksRuntime");
}
(false, false, true, false) => {
// Don't link to anything; objc2_sys already does that for us!
// Don't link to anything; objc-sys already does that for us!

// Add GNUStep compability headers to make `#include <Block.h>`
// work (on newer GNUStep versions these headers are present)
Expand Down
4 changes: 2 additions & 2 deletions block-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

// Ensure linkage actually happens
#[cfg(feature = "gnustep-1-7")]
extern crate objc2_sys;
extern crate objc_sys as _;

#[cfg(doctest)]
#[doc = include_str!("../README.md")]
Expand All @@ -33,7 +33,7 @@ pub struct Class {
// The size of this is unknown
_priv: [u8; 0],

/// See objc2_sys::OpaqueData
/// See objc_sys::OpaqueData
_opaque: PhantomData<(UnsafeCell<*const ()>, PhantomPinned)>,
}

Expand Down
4 changes: 2 additions & 2 deletions objc2_sys/Cargo.toml → objc-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "objc2_sys"
name = "objc-sys"
version = "0.0.0" # Remember to update html_root_url in lib.rs
authors = ["Mads Marquart <[email protected]>"]
edition = "2018"
Expand All @@ -12,7 +12,7 @@ categories = [
"os::macos-apis",
]
repository = "https://github.com/madsmtm/objc2"
documentation = "https://docs.rs/objc2_sys/"
documentation = "https://docs.rs/objc-sys/"
license = "MIT"

exclude = [
Expand Down
6 changes: 3 additions & 3 deletions objc2_sys/README.md → objc-sys/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# `objc2_sys`
# `objc-sys`

[![Latest version](https://badgen.net/crates/v/objc2_sys)](https://crates.io/crates/objc2_sys)
[![Latest version](https://badgen.net/crates/v/objc-sys)](https://crates.io/crates/objc-sys)
[![License](https://badgen.net/badge/license/MIT/blue)](../LICENSE.txt)
[![Documentation](https://docs.rs/objc2_sys/badge.svg)](https://docs.rs/objc2_sys/)
[![Documentation](https://docs.rs/objc-sys/badge.svg)](https://docs.rs/objc-sys/)
[![Apple CI](https://github.com/madsmtm/objc2/actions/workflows/apple.yml/badge.svg)](https://github.com/madsmtm/objc2/actions/workflows/apple.yml)
[![GNUStep CI](https://github.com/madsmtm/objc2/actions/workflows/gnustep.yml/badge.svg)](https://github.com/madsmtm/objc2/actions/workflows/gnustep.yml)

Expand Down
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.
2 changes: 1 addition & 1 deletion objc2_sys/src/lib.rs → objc-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#![allow(clippy::upper_case_acronyms)]
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
#![doc(html_root_url = "https://docs.rs/objc2_sys/0.0.0")]
#![doc(html_root_url = "https://docs.rs/objc-sys/0.0.0")]

// TODO: Replace `extern "C"` with `extern "C-unwind"` where applicable.
// See https://rust-lang.github.io/rfcs/2945-c-unwind-abi.html.
Expand Down
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.
2 changes: 1 addition & 1 deletion objc2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ unstable_autoreleasesafe = []

[dependencies]
malloc_buf = "1.0"
objc2_sys = { path = "../objc2_sys" }
objc-sys = { path = "../objc-sys" }
objc2_encode = { path = "../objc2_encode" }

[build-dependencies]
Expand Down
18 changes: 9 additions & 9 deletions objc2/src/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::fmt;

/// The Objective-C `BOOL` type.
///
/// This is a thin wrapper-type over [`objc2_sys::BOOL`]. It is intended that
/// This is a thin wrapper-type over [`objc_sys::BOOL`]. It is intended that
/// you convert this into a Rust [`bool`] with the [`Bool::is_false`] or
/// [`Bool::is_true`] methods as soon as possible.
///
Expand All @@ -30,35 +30,35 @@ use core::fmt;
// And it is not immediately clear for users which one was chosen.
#[derive(Copy, Clone, Default)]
pub struct Bool {
value: objc2_sys::BOOL,
value: objc_sys::BOOL,
}

impl Bool {
/// The equivalent of [`true`] for Objective-C's `BOOL` type.
pub const YES: Self = Self::from_raw(objc2_sys::YES);
pub const YES: Self = Self::from_raw(objc_sys::YES);

/// The equivalent of [`false`] for Objective-C's `BOOL` type.
pub const NO: Self = Self::from_raw(objc2_sys::NO);
pub const NO: Self = Self::from_raw(objc_sys::NO);

/// Creates an Objective-C boolean from a Rust boolean.
#[inline]
pub const fn new(value: bool) -> Self {
// true as u8 => 1
// false as u8 => 0
let value = value as objc2_sys::BOOL;
let value = value as objc_sys::BOOL;
Self { value }
}

/// Creates this from a boolean value received from a raw Objective-C API.
#[inline]
pub const fn from_raw(value: objc2_sys::BOOL) -> Self {
pub const fn from_raw(value: objc_sys::BOOL) -> Self {
Self { value }
}

/// Retrieves the inner [`objc2_sys`] boolean type, to be used in raw
/// Retrieves the inner [`objc_sys`] boolean type, to be used in raw
/// Objective-C APIs.
#[inline]
pub const fn as_raw(self) -> objc2_sys::BOOL {
pub const fn as_raw(self) -> objc_sys::BOOL {
self.value
}

Expand Down Expand Up @@ -101,7 +101,7 @@ impl fmt::Debug for Bool {

// SAFETY: `Bool` is `repr(transparent)`.
unsafe impl Encode for Bool {
const ENCODING: Encoding<'static> = objc2_sys::BOOL::ENCODING;
const ENCODING: Encoding<'static> = objc_sys::BOOL::ENCODING;
}

// Note that we shouldn't delegate to `BOOL`'s `ENCODING_REF` since `BOOL` is
Expand Down
2 changes: 1 addition & 1 deletion objc2/src/exception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::os::raw::c_uchar;
use crate::rc::{Id, Shared};
use crate::runtime::Object;

use objc2_sys::{objc_exception_throw, objc_object};
use objc_sys::{objc_exception_throw, objc_object};

extern "C" {
fn rust_objc_try_catch_exception(
Expand Down
2 changes: 1 addition & 1 deletion objc2/src/message/apple/arm.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::mem;
use objc2_sys::{objc_msgSend, objc_msgSendSuper, objc_msgSendSuper_stret, objc_msgSend_stret};
use objc_sys::{objc_msgSend, objc_msgSendSuper, objc_msgSendSuper_stret, objc_msgSend_stret};

use super::MsgSendFn;
use crate::runtime::Imp;
Expand Down
2 changes: 1 addition & 1 deletion objc2/src/message/apple/arm64.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use objc2_sys::{objc_msgSend, objc_msgSendSuper};
use objc_sys::{objc_msgSend, objc_msgSendSuper};

use super::MsgSendFn;
use crate::runtime::Imp;
Expand Down
2 changes: 1 addition & 1 deletion objc2/src/message/apple/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use objc2_sys::objc_super;
use objc_sys::objc_super;

use super::{conditional_try, Encode, MessageArguments, MessageError};
use crate::runtime::{Class, Imp, Object, Sel};
Expand Down
2 changes: 1 addition & 1 deletion objc2/src/message/apple/x86.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::mem;
use objc2_sys::{
use objc_sys::{
objc_msgSend, objc_msgSendSuper, objc_msgSendSuper_stret, objc_msgSend_fpret,
objc_msgSend_stret,
};
Expand Down
2 changes: 1 addition & 1 deletion objc2/src/message/apple/x86_64.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::mem;
use objc2_sys::{objc_msgSend, objc_msgSendSuper, objc_msgSendSuper_stret, objc_msgSend_stret};
use objc_sys::{objc_msgSend, objc_msgSendSuper, objc_msgSendSuper_stret, objc_msgSend_stret};

use super::MsgSendFn;
use crate::runtime::Imp;
Expand Down
2 changes: 1 addition & 1 deletion objc2/src/message/gnustep.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::mem;
use objc2_sys::{objc_msg_lookup, objc_msg_lookup_super, objc_super};
use objc_sys::{objc_msg_lookup, objc_msg_lookup_super, objc_super};

use super::{conditional_try, Encode, MessageArguments, MessageError};
use crate::runtime::{Class, Object, Sel};
Expand Down
10 changes: 5 additions & 5 deletions objc2/src/rc/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ impl<T: Message, O: Ownership> Id<T, O> {
#[doc(alias = "objc_retain")]
#[cfg_attr(debug_assertions, inline)]
pub unsafe fn retain(ptr: NonNull<T>) -> Id<T, O> {
let ptr = ptr.as_ptr() as *mut objc2_sys::objc_object;
let ptr = ptr.as_ptr() as *mut objc_sys::objc_object;
// SAFETY: The caller upholds that the pointer is valid
let res = unsafe { objc2_sys::objc_retain(ptr) };
let res = unsafe { objc_sys::objc_retain(ptr) };
debug_assert_eq!(res, ptr, "objc_retain did not return the same pointer");
// SAFETY: Non-null upheld by the caller, and `objc_retain` always
// returns the same pointer, see:
Expand All @@ -226,12 +226,12 @@ impl<T: Message, O: Ownership> Id<T, O> {
// retained objects it is hard to imagine a case where the inner type
// has a method with the same name.

let ptr = ManuallyDrop::new(self).ptr.as_ptr() as *mut objc2_sys::objc_object;
let ptr = ManuallyDrop::new(self).ptr.as_ptr() as *mut objc_sys::objc_object;
// SAFETY: The `ptr` is guaranteed to be valid and have at least one
// retain count.
// And because of the ManuallyDrop, we don't call the Drop
// implementation, so the object won't also be released there.
let res = unsafe { objc2_sys::objc_autorelease(ptr) };
let res = unsafe { objc_sys::objc_autorelease(ptr) };
debug_assert_eq!(res, ptr, "objc_autorelease did not return the same pointer");
res as *mut T
}
Expand Down Expand Up @@ -351,7 +351,7 @@ impl<T, O: Ownership> Drop for Id<T, O> {

// SAFETY: The `ptr` is guaranteed to be valid and have at least one
// retain count
unsafe { objc2_sys::objc_release(self.ptr.as_ptr() as *mut _) };
unsafe { objc_sys::objc_release(self.ptr.as_ptr() as *mut _) };
}
}

Expand Down
10 changes: 5 additions & 5 deletions objc2/src/rc/weak_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl<T: Message> WeakId<T> {
unsafe fn new_inner(obj: *mut T) -> Self {
let inner = Box::new(UnsafeCell::new(ptr::null_mut()));
// SAFETY: `ptr` will never move, and the caller verifies `obj`
let _ = unsafe { objc2_sys::objc_initWeak(inner.get() as _, obj as _) };
let _ = unsafe { objc_sys::objc_initWeak(inner.get() as _, obj as _) };
Self {
inner,
item: PhantomData,
Expand All @@ -62,8 +62,8 @@ impl<T: Message> WeakId<T> {
#[doc(alias = "objc_loadWeakRetained")]
#[inline]
pub fn load(&self) -> Option<Id<T, Shared>> {
let ptr: *mut *mut objc2_sys::objc_object = self.inner.get() as _;
let obj = unsafe { objc2_sys::objc_loadWeakRetained(ptr) } as *mut T;
let ptr: *mut *mut objc_sys::objc_object = self.inner.get() as _;
let obj = unsafe { objc_sys::objc_loadWeakRetained(ptr) } as *mut T;
NonNull::new(obj).map(|obj| unsafe { Id::new(obj) })
}
}
Expand All @@ -72,7 +72,7 @@ impl<T> Drop for WeakId<T> {
/// Drops the `WeakId` pointer.
#[doc(alias = "objc_destroyWeak")]
fn drop(&mut self) {
unsafe { objc2_sys::objc_destroyWeak(self.inner.get() as _) }
unsafe { objc_sys::objc_destroyWeak(self.inner.get() as _) }
}
}

Expand All @@ -81,7 +81,7 @@ impl<T> Clone for WeakId<T> {
#[doc(alias = "objc_copyWeak")]
fn clone(&self) -> Self {
let ptr = Box::new(UnsafeCell::new(ptr::null_mut()));
unsafe { objc2_sys::objc_copyWeak(ptr.get() as _, self.inner.get() as _) };
unsafe { objc_sys::objc_copyWeak(ptr.get() as _, self.inner.get() as _) };
Self {
inner: ptr,
item: PhantomData,
Expand Down
Loading

0 comments on commit 1aefd19

Please sign in to comment.