This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @implementation Foo | |
| - (id) foo | |
| { | |
| return [self bar]; | |
| } | |
| - (id) bar | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #undef MIN | |
| #define MIN__(A,B,C) ({ __typeof__(A) __a##C = (A); __typeof__(B) __b##C = (B); __a##C < __b##C ? __a##C : __b##C; }) | |
| #define MIN_(A,B,C) MIN__(A,B,C) | |
| #define MIN(A,B) MIN_(A,B,__COUNTER__) | |
| #undef MAX | |
| #define MAX__(A,B,C) ({ __typeof__(A) __a##C = (A); __typeof__(B) __b##C = (B); __a##C < __b##C ? __b##C : __a##C; }) | |
| #define MAX_(A,B,C) MAX__(A,B,C) | |
| #define MAX(A,B) MAX_(A,B,__COUNTER__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Expansion of JATExpandLiteral(@"foo: {foo}; bar: {bar}; baz: {baz}", foo, bar, baz) | |
| JAT_DoExpandTemplateUsingMacroKeysAndValues(@"foo: {foo}; bar: {bar}; baz: {baz}", (JATNameArray){ @"foo", @"bar", @"baz", ((void*)0) }, (JATParameterArray){ JATCastParameter(foo), JATCastParameter(bar), JATCastParameter(baz), ((void*)0) }, 3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import <Foundation/Foundation.h> | |
| #import <objc/runtime.h> | |
| @interface Test: NSObject | |
| @end | |
| @interface Test (Dynamic) | |
| - (void)foo:(float)x :(float)y; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static OSStatus | |
| SSLVerifySignedServerKeyExchange(SSLContext *ctx, bool isRsa, SSLBuffer signedParams, | |
| uint8_t *signature, UInt16 signatureLen) | |
| { | |
| SSLBuffer hashCtx; | |
| hashCtx.date = 0; | |
| OSStatus err = SSLVerifySignedServerKeyExchangeInner(ctx, isRsa, signedParams, signature, signatureLen, &hashCtx); | |
| SSLFreeBuffer(hashCtx); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import <Foundation/Foundation.h> | |
| #define JADictionaryOfVariableBindings(...) \ | |
| [NSDictionary dictionaryWithObjects:(const id []){ __VA_ARGS__ } \ | |
| forKeys:(const NSString *[]){ JATEMPLATE_MAP(JATEMPLATE_NAME_FROM_ARG, __VA_ARGS__) } \ | |
| count:JATEMPLATE_ARGUMENT_COUNT(__VA_ARGS__)] | |
| #define JATEMPLATE_NAME_FROM_ARG(ITEM) @#ITEM | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| // Because the real thing crashes | |
| enum Result { | |
| case Value(Any) | |
| case Error(NSError?) | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef format_h | |
| #define format_h | |
| #define reset "0" | |
| #define bold "1" | |
| #define red "31" | |
| #define format(first, ...) \ | |
| "\e[" first join_format_codes(__VA_ARGS__) "m" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct ifparams { | |
| #if __has_feature(objc_arc) | |
| __unsafe_unretained | |
| #endif | |
| dispatch_block_t then, otherwise; | |
| }; | |
| static inline void iff(bool condition, struct ifparams params) { | |
| ((condition?params.then:params.otherwise)?:^{})(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extern "C" { | |
| // This is global, but you can call it what you like | |
| inline void MyPrefixedCFShow(const void *object) { | |
| // Redeclared system function is local scope and counts as extern "C" | |
| extern void CFShow(const void * object); | |
| CFShow(object); | |
| } | |
| } | |
| class DumbThing { |