From b1b93007f0db2e7808f103333d3bb9c72c92d6ce Mon Sep 17 00:00:00 2001 From: gs Date: Tue, 7 Mar 2017 23:57:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86ppx=E7=9A=84?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E5=80=BC=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Features/Annotation/NSObject+annotation.h | 19 +++++++++++++++++++ Hodor/NSObjectAnnotationTestVC.m | 7 ++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Classes/Features/Annotation/NSObject+annotation.h b/Classes/Features/Annotation/NSObject+annotation.h index 9bf22fc..d148838 100644 --- a/Classes/Features/Annotation/NSObject+annotation.h +++ b/Classes/Features/Annotation/NSObject+annotation.h @@ -9,9 +9,28 @@ #import +#define pp_property(object, property) (^{ \ +_Pragma("clang diagnostic push") \ +_Pragma("clang diagnostic ignored \"-Wunreachable-code\"") \ +_Pragma("clang diagnostic ignored \"-Wimplicit-retain-self\"") \ +return ((void)(NO && ((void)object.property, NO)), @#property); \ +_Pragma("clang diagnostic pop") \ +}()) + + +#define pp_class_property(class, property) (^{ \ +_Pragma("clang diagnostic push") \ +_Pragma("clang diagnostic ignored \"-Wunreachable-code\"") \ +_Pragma("clang diagnostic ignored \"-Wimplicit-retain-self\"") \ +return ((void)(NO && ((void)[[class new] property], NO)), @#property); \ +_Pragma("clang diagnostic pop") \ +}()) + + #define ppx(n, ...) \ + (NSArray *)ppx_support_##n\ {\ +pp_class_property(self, n);\ return @[__VA_ARGS__];\ } diff --git a/Hodor/NSObjectAnnotationTestVC.m b/Hodor/NSObjectAnnotationTestVC.m index 1e0ecbe..2cc2e21 100644 --- a/Hodor/NSObjectAnnotationTestVC.m +++ b/Hodor/NSObjectAnnotationTestVC.m @@ -83,13 +83,15 @@ - (void)func1 } -ppx(func2_withb_, @{@"j":@"k"}) +//ppx(func2_withb_, @{@"j":@"k"}) + - (void)func2:(int)a withb:(NSString *)b; { } ppx(func3, @(5)) +//ppx(ffunc3, @(5)) // error + (void)func3 { @@ -105,10 +107,9 @@ - (void)func4 @implementation AnnotationTestObj2 ppx(str2, @"t"); - ppx(func5, @"s"); - (void)func5 { } -@end \ No newline at end of file +@end