Skip to content

Commit

Permalink
Change syntax to allow for comments and other meta tags
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Jul 5, 2022
1 parent bde6eab commit 6d107ee
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
8 changes: 4 additions & 4 deletions objc2-foundation/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ macro_rules! __def_fn {
// some of that specialization though!
{} => {};
{
#[sel($($sel:tt)+)]
$(#[$m:meta])*
#sel!($($sel:tt)+)
$v:vis fn $name:ident(
$(&$self:ident)?
$(&mut $mut_self:ident)?
Expand Down Expand Up @@ -329,8 +329,8 @@ macro_rules! __def_fn {
}
};
{
#[sel($($sel:tt)+)]
$(#[$m:meta])*
#sel!($($sel:tt)+)
$v:vis fn $name:ident(
$(&$self:ident)?
$(&mut $mut_self:ident)?
Expand Down Expand Up @@ -363,8 +363,8 @@ macro_rules! __def_fn {
}
};
{
#[sel($($sel:tt)+)]
$(#[$m:meta])*
#sel!($($sel:tt)+)
$v:vis fn $name:ident(
$(&$self:ident)?
$(&mut $mut_self:ident)?
Expand Down Expand Up @@ -397,8 +397,8 @@ macro_rules! __def_fn {
}
};
{
#[sel($($sel:tt)+)]
$(#[$m:meta])*
#sel!($($sel:tt)+)
$v:vis fn $name:ident(
$(&$self:ident)?
$(&mut $mut_self:ident)?
Expand Down
11 changes: 6 additions & 5 deletions objc2-foundation/src/mutable_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ extern_class! {
/// See [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmutablestring?language=objc).
#[derive(PartialEq, Eq, Hash)]
unsafe pub struct NSMutableString: NSString, NSObject;

unsafe impl {
/// Construct an empty [`NSMutableString`].
#sel!(new)
pub fn new() -> Id<Self, Owned>;
}
}

// TODO: SAFETY
Expand All @@ -22,11 +28,6 @@ unsafe impl Send for NSMutableString {}

/// Creating mutable strings.
impl NSMutableString {
unsafe_def_fn! {
/// Construct an empty [`NSMutableString`].
pub fn new -> Owned;
}

/// Creates a new [`NSMutableString`] by copying the given string slice.
#[doc(alias = "initWithBytes:length:encoding:")]
#[allow(clippy::should_implement_trait)] // Not really sure of a better name
Expand Down
10 changes: 5 additions & 5 deletions objc2-foundation/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ __inner_extern_class! {
unsafe pub struct NSObject<>: Object {}

unsafe impl {
#[sel(new)]
#sel!(new)
pub fn new() -> Id<Self, Owned>;

#[sel(hash)]
#sel!(hash)
pub fn hash_code(&self) -> usize;

#[sel(isEqual:)]
#sel!(isEqual:)
pub fn is_equal(&self, other: &NSObject) -> bool;

// TODO: Verify that description always returns a non-null string
#[sel(description)]
#sel!(description)
pub fn description(&self) -> Id<NSString, Shared>;

#[sel(isKindOfClass:)]
#sel!(isKindOfClass:)
pub fn is_kind_of(&self, cls: &Class) -> bool;
}
}
Expand Down

0 comments on commit 6d107ee

Please sign in to comment.