This file contains 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
enum | |
{ | |
kVKC_Shift = 56, | |
kVKC_Option = 58, | |
kVKC_Control = 59, | |
kVKC_rShift = 60, /* Right-hand modifiers; not implemented */ | |
kVKC_rOption = 61, | |
kVKC_rControl = 62, | |
kVKC_Command = 55, | |
} |
This file contains 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
/* | |
© 2010 Jens Ayton | |
This code may be used freely. | |
*/ | |
uniform float uValue; // Value/brighness component. | |
const float kPi = 3.141592653589793; | |
This file contains 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 handler from an @encode() string parser for a debug printer. | |
#import <objc/runtime.h> // For @encode syntax constants. | |
static void DecodeStruct(const char * const encoding, size_t * const cursor, const void ** const buffer, NSMutableString *string) | |
{ | |
NSCParameterAssert(encoding != NULL && encoding[*cursor] == _C_STRUCT_B && cursor != NULL && buffer != NULL); | |
#if INCLUDE_STRUCT_NAMES |
This file contains 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
// Sketch for multiple return values in Objective-C | |
// Method declaration: | |
- (id, NSError *) someMethod:param; | |
// Desugars to: | |
typedef struct { id a, NSError *b } __someMethodResult; // Obviously gensym/anonymous in real implementation | |
- (__someMethodResult) someMethod:param; | |
// Return type encoding would be "{?=@@}", anonymous struct of two objects. |
This file contains 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
/* | |
Hack to enable the use of block ivars as IBAction targets. Stuffs a bunch | |
of nastiness in NSObject, but transparenty works for classes implemeting | |
actions: create a property of type BlockAction, assign a block to it, | |
and use the property name (with a trailing colon) as the target selector. | |
Did I mention it's a hack? There are two major problems: | |
* Type safety. It assumes any block property will have the correct | |
signature. Can be partially worked around when compiling with Clang, | |
which embeds @encode() strings into blocks, but this is undocumented. |
This file contains 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
Moved to a repo: https://github.com/Ahruman/ClassCrawler |
This file contains 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
#!/usr/bin/python | |
# Nicolas Seriot | |
# 2011-01-06 | |
# http://github.com/nst/objc_dep | |
""" | |
Input: path of an Objective-C project | |
Output: import dependancies Graphviz format |
This file contains 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
// There are exact equivalents for CoreFoundation, if you like typing CFRelease a lot. | |
NSString *path = [[NSBundle mainBundle] builtInPlugInsPath]; // Or privateFrameworksPath, or some other thing. | |
path = [path stringByAppendingPathComponent:@"foo.dylib"]; | |
void *handle = dlopen([path fileSystemRepresentation], flags); |
This file contains 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
/* | |
The desired output of each test case is: | |
<MyException 0xPTR>{ TestName, retain count 1 } created. | |
<MyException 0xPTR>{ TestName, retain count 1 } caught. | |
<MyException 0xPTR>{ TestName, retain count 1 } dealloced. | |
For a fun time, try to predict the actual output for all six test cases! | |
This file contains 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
/* Copyright (c) 2011 Jens Ayton | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
OlderNewer