Skip to content

Commit 6d107ee

Browse files
committed
Change syntax to allow for comments and other meta tags
1 parent bde6eab commit 6d107ee

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

objc2-foundation/src/macros.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ macro_rules! __def_fn {
295295
// some of that specialization though!
296296
{} => {};
297297
{
298-
#[sel($($sel:tt)+)]
299298
$(#[$m:meta])*
299+
#sel!($($sel:tt)+)
300300
$v:vis fn $name:ident(
301301
$(&$self:ident)?
302302
$(&mut $mut_self:ident)?
@@ -329,8 +329,8 @@ macro_rules! __def_fn {
329329
}
330330
};
331331
{
332-
#[sel($($sel:tt)+)]
333332
$(#[$m:meta])*
333+
#sel!($($sel:tt)+)
334334
$v:vis fn $name:ident(
335335
$(&$self:ident)?
336336
$(&mut $mut_self:ident)?
@@ -363,8 +363,8 @@ macro_rules! __def_fn {
363363
}
364364
};
365365
{
366-
#[sel($($sel:tt)+)]
367366
$(#[$m:meta])*
367+
#sel!($($sel:tt)+)
368368
$v:vis fn $name:ident(
369369
$(&$self:ident)?
370370
$(&mut $mut_self:ident)?
@@ -397,8 +397,8 @@ macro_rules! __def_fn {
397397
}
398398
};
399399
{
400-
#[sel($($sel:tt)+)]
401400
$(#[$m:meta])*
401+
#sel!($($sel:tt)+)
402402
$v:vis fn $name:ident(
403403
$(&$self:ident)?
404404
$(&mut $mut_self:ident)?

objc2-foundation/src/mutable_string.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ extern_class! {
1414
/// See [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmutablestring?language=objc).
1515
#[derive(PartialEq, Eq, Hash)]
1616
unsafe pub struct NSMutableString: NSString, NSObject;
17+
18+
unsafe impl {
19+
/// Construct an empty [`NSMutableString`].
20+
#sel!(new)
21+
pub fn new() -> Id<Self, Owned>;
22+
}
1723
}
1824

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

2329
/// Creating mutable strings.
2430
impl NSMutableString {
25-
unsafe_def_fn! {
26-
/// Construct an empty [`NSMutableString`].
27-
pub fn new -> Owned;
28-
}
29-
3031
/// Creates a new [`NSMutableString`] by copying the given string slice.
3132
#[doc(alias = "initWithBytes:length:encoding:")]
3233
#[allow(clippy::should_implement_trait)] // Not really sure of a better name

objc2-foundation/src/object.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ __inner_extern_class! {
1111
unsafe pub struct NSObject<>: Object {}
1212

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

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

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

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

27-
#[sel(isKindOfClass:)]
27+
#sel!(isKindOfClass:)
2828
pub fn is_kind_of(&self, cls: &Class) -> bool;
2929
}
3030
}

0 commit comments

Comments
 (0)