Skip to content

Commit

Permalink
Comment cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Jul 16, 2022
1 parent f19719b commit ac378d4
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions objc2-foundation/src/declare_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ macro_rules! __inner_declare_class {
/// impl MyCustomObject {
/// pub fn new(foo: u8) -> Id<Self, Owned> {
/// let cls = Self::class();
/// unsafe { msg_send_id![msg_send_id![cls, alloc], initWithFoo: foo,].unwrap() }
/// unsafe { msg_send_id![msg_send_id![cls, alloc], initWithFoo: foo].unwrap() }
/// }
///
/// pub fn get_foo(&self) -> u8 {
Expand Down Expand Up @@ -594,6 +594,7 @@ macro_rules! __inner_declare_class {
/// #import <Foundation/Foundation.h>
///
/// @interface MyCustomObject: NSObject <NSCopying> {
/// // Public ivar
/// int bar;
/// }
///
Expand All @@ -605,7 +606,7 @@ macro_rules! __inner_declare_class {
///
///
/// @implementation MyCustomObject {
/// // Private
/// // Private ivar
/// uint8_t foo;
/// }
///
Expand All @@ -626,6 +627,8 @@ macro_rules! __inner_declare_class {
/// return YES;
/// }
///
/// // NSCopying
///
/// - (id)copyWithZone:(NSZone *)_zone {
/// MyCustomObject* obj = [[MyCustomObject alloc] initWithFoo: self->foo];
/// obj->bar = self->bar;
Expand Down Expand Up @@ -667,10 +670,11 @@ macro_rules! declare_class {
// SAFETY: Upheld by caller
unsafe $v struct $name<>: $inherits, $($inheritance_rest,)* $crate::objc2::runtime::Object {
// SAFETY:
// - The ivars are in a type used as an Objective-C object
// - The ivars are in a type used as an Objective-C object.
// - The instance variable is defined in the exact same manner
// in `create_class`.
// in `class` below.
// - Rust prevents having two fields with the same name.
// - Caller upholds that the ivars are properly initialized.
$($ivar_v $ivar: $crate::objc2::declare::Ivar<$ivar>,)*
}
}
Expand Down Expand Up @@ -701,12 +705,13 @@ macro_rules! declare_class {
)*

$(
// Implement protocols
// Implement protocol if any specified
$(
let err_str = concat!("could not find protocol ", stringify!($protocol));
builder.add_protocol(Protocol::get(stringify!($protocol)).expect(err_str));
)?

// Implement methods
// SAFETY: Upheld by caller
unsafe {
$crate::__inner_declare_class! {
Expand Down

0 comments on commit ac378d4

Please sign in to comment.