Skip to content

Commit

Permalink
Rename MethodImplementation's associated types
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Sep 20, 2023
1 parent d7d8120 commit 44fe66b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
2 changes: 2 additions & 0 deletions crates/objc2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
* Relaxed the requirements for receivers in `MethodImplementation`; now,
anything that implements `MessageReceiver` can be used as the receiver of
a method.
* **BREAKING**: Renamed the associated types `Ret` and `Args` on
`MethodImplementation` to `Return` and `Arguments`.

### Deprecated
* Soft deprecated using `msg_send!` without a comma between arguments (i.e.
Expand Down
10 changes: 5 additions & 5 deletions crates/objc2/src/declare/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl ClassBuilder {
/// `-release` used by ARC, will not be present otherwise.
pub fn root<F>(name: &str, intitialize_fn: F) -> Option<Self>
where
F: MethodImplementation<Callee = AnyClass, Args = (), Ret = ()>,
F: MethodImplementation<Callee = AnyClass, Arguments = (), Return = ()>,
{
Self::with_superclass(name, None).map(|mut this| {
unsafe { this.add_class_method(sel!(initialize), intitialize_fn) };
Expand Down Expand Up @@ -274,8 +274,8 @@ impl ClassBuilder {
unsafe {
self.add_method_inner(
sel,
F::Args::ENCODINGS,
&F::Ret::ENCODING_RETURN,
F::Arguments::ENCODINGS,
&F::Return::ENCODING_RETURN,
func.__imp(),
)
}
Expand Down Expand Up @@ -338,8 +338,8 @@ impl ClassBuilder {
unsafe {
self.add_class_method_inner(
sel,
F::Args::ENCODINGS,
&F::Ret::ENCODING_RETURN,
F::Arguments::ENCODINGS,
&F::Return::ENCODING_RETURN,
func.__imp(),
)
}
Expand Down
16 changes: 9 additions & 7 deletions crates/objc2/src/runtime/method_implementation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ mod private {
pub trait MethodImplementation: private::Sealed + Sized {
/// The callee type of the method.
type Callee: ?Sized + RefEncode;
/// The return type of the method.
type Ret: EncodeReturn;

/// The argument types of the method.
type Args: EncodeArguments;
type Arguments: EncodeArguments;

/// The return type of the method.
type Return: EncodeReturn;

#[doc(hidden)]
fn __imp(self) -> Imp;
Expand All @@ -44,8 +46,8 @@ macro_rules! method_impl_inner {
$($t: EncodeArgument,)*
{
type Callee = T::__Inner;
type Ret = R;
type Args = ($($t,)*);
type Arguments = ($($t,)*);
type Return = R;

fn __imp(self) -> Imp {
// SAFETY: Transmuting to an `unsafe` function pointer
Expand All @@ -66,8 +68,8 @@ macro_rules! method_impl_inner {
$($t: EncodeArgument,)*
{
type Callee = T;
type Ret = IdReturnValue;
type Args = ($($t,)*);
type Arguments = ($($t,)*);
type Return = IdReturnValue;

fn __imp(self) -> Imp {
// SAFETY: `Allocated<T>` is the same as `NonNull<T>`, except
Expand Down

0 comments on commit 44fe66b

Please sign in to comment.