-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CHANGE] Add MiscMerge directly to project (back in the rentzsch.com …
…svn+trac days it was in its own peer folder).
- Loading branch information
Showing
86 changed files
with
10,520 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>English</string> | ||
<key>CFBundleExecutable</key> | ||
<string>${EXECUTABLE_NAME}</string> | ||
<key>CFBundleName</key> | ||
<string>${PRODUCT_NAME}</string> | ||
<key>CFBundleIconFile</key> | ||
<string></string> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.yourcompany.yourcocoaframework</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundlePackageType</key> | ||
<string>FMWK</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>1.0</string> | ||
<key>NSPrincipalClass</key> | ||
<string></string> | ||
</dict> | ||
</plist> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// KeyValue+MiscMerge.h | ||
// | ||
// Written by Don Yacktman and Carl Lindberg | ||
// | ||
// Copyright 2001-2004 by Don Yacktman and Carl Lindberg. | ||
// All rights reserved. | ||
// | ||
// This notice may not be removed from this source code. | ||
// | ||
// This header is included in the MiscKit by permission from the author | ||
// and its use is governed by the MiscKit license, found in the file | ||
// "License.rtf" in the MiscKit distribution. Please refer to that file | ||
// for a list of all applicable permissions and restrictions. | ||
// | ||
|
||
#import <Foundation/NSObject.h> | ||
|
||
@interface NSObject (MiscMergeHasKey) | ||
|
||
- (BOOL)hasMiscMergeKey:(NSString *)key; | ||
- (BOOL)hasMiscMergeKeyPath:(NSString *)keyPath; | ||
|
||
@end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
// | ||
// KeyValue+MiscMerge.m | ||
// | ||
// Written by Don Yacktman and Carl Lindberg | ||
// | ||
// Copyright 2001-2004 by Don Yacktman and Carl Lindberg. | ||
// All rights reserved. | ||
// | ||
// This notice may not be removed from this source code. | ||
// | ||
// This header is included in the MiscKit by permission from the author | ||
// and its use is governed by the MiscKit license, found in the file | ||
// "License.rtf" in the MiscKit distribution. Please refer to that file | ||
// for a list of all applicable permissions and restrictions. | ||
// | ||
|
||
#import "KeyValue+MiscMerge.h" | ||
#import <Foundation/NSObjCRuntime.h> | ||
#import <Foundation/NSDictionary.h> | ||
#import <Foundation/NSArray.h> | ||
#import <Foundation/NSString.h> | ||
#import <Foundation/NSCharacterSet.h> | ||
#import <stdlib.h> // for NULL os OSX | ||
#if GNU_RUNTIME | ||
#import <objc/objc-api.h> | ||
static Ivar_t class_getInstanceVariable(Class aClass, const char *name); | ||
#else | ||
#import <objc/objc-runtime.h> | ||
#endif | ||
|
||
@interface NSObject (WarningAvoidance) | ||
+ (BOOL)accessInstanceVariablesDirectly; | ||
@end | ||
|
||
@implementation NSObject (MiscMergeHasKey) | ||
|
||
- (BOOL)hasMiscMergeKeyPath:(NSString *)keyPath | ||
{ | ||
static NSCharacterSet *dotSet; | ||
|
||
NSString *key = keyPath; | ||
NSRange dotRange; | ||
|
||
if ( dotSet == nil ) { | ||
dotSet = [[NSCharacterSet characterSetWithRange:NSMakeRange((unsigned int)'.', 1)] retain]; | ||
} | ||
|
||
dotRange = [keyPath rangeOfCharacterFromSet:dotSet]; | ||
|
||
if (dotRange.length > 0) | ||
{ | ||
key = [keyPath substringToIndex:dotRange.location]; | ||
} | ||
|
||
return [self hasMiscMergeKey:key]; | ||
} | ||
|
||
- (BOOL)hasMiscMergeKey:(NSString *)key | ||
{ | ||
SEL keySelector; | ||
|
||
if ([key length] == 0) return NO; | ||
|
||
keySelector = NSSelectorFromString(key); | ||
|
||
return (keySelector != NULL && [self respondsToSelector:keySelector]) || | ||
([[self class] accessInstanceVariablesDirectly] && | ||
class_getInstanceVariable([self class], [key cString])); | ||
} | ||
|
||
@end | ||
|
||
@implementation NSDictionary (MiscMergeHasKey) | ||
|
||
- (BOOL)hasMiscMergeKey:(NSString *)key | ||
{ | ||
return ([self objectForKey:key] != nil)? YES : NO; | ||
} | ||
|
||
@end | ||
|
||
@implementation NSArray (MiscMergeHasKey) | ||
|
||
- (BOOL)hasMiscMergeKey:(NSString *)key | ||
{ | ||
if ([key isEqualToString:@"count"]) return YES; | ||
if ([key hasPrefix:@"@"]) return YES; | ||
if ([self count] == 0) return YES; //Hmm | ||
return [[self objectAtIndex:0] hasMiscMergeKey:key]; | ||
} | ||
|
||
@end | ||
|
||
#if GNU_RUNTIME | ||
|
||
static Ivar_t class_getInstanceVariable(Class aClass, const char *name) | ||
{ | ||
Class currClass; | ||
|
||
if (name == NULL) return NULL; | ||
|
||
for (currClass = aClass; currClass != Nil; currClass = currClass->super_class) | ||
{ | ||
struct objc_ivar_list *ivars = aClass->ivars; | ||
int pos; | ||
|
||
for (pos = 0; pos < ivars->ivar_count; pos++) | ||
{ | ||
Ivar_t currIvar = &(ivars->ivar_list[pos]); | ||
|
||
if (strcmp(currIvar->ivar_name, name) == 0) { | ||
return currIvar; | ||
} | ||
} | ||
} | ||
|
||
return NULL; | ||
} | ||
|
||
#endif GNU_RUNTIME |
Oops, something went wrong.