Skip to content

Commit

Permalink
Building YAJL as framework on iOS targeting >= 3.0;
Browse files Browse the repository at this point in the history
Updating GHUnit; Adding NSBundle category
  • Loading branch information
gabriel committed Aug 26, 2010
1 parent 9fd0d81 commit 8ddd6f8
Show file tree
Hide file tree
Showing 56 changed files with 816 additions and 769 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,4 +1,9 @@
== 0.2.20

- Added framework build for iPhone

== 0.2.17

- Updated to use yalj 1.0.9 (iPhone)

== 0.2.16
Expand Down
50 changes: 50 additions & 0 deletions Classes/NSBundle+YAJL.h
@@ -0,0 +1,50 @@
//
// NSBundle+YAJL.h
// YAJL
//
// Created by Gabriel Handford on 7/23/09.
// Copyright 2009. All rights reserved.
//
// 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 USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//

#import "YAJLParser.h"

@interface NSBundle (YAJL)

/*!
Load JSON from bundle.
Throws an YAJLParserException on parse error.
@param resource Resource name with extension, for example, file.json
*/
- (id)yajl_JSONFromResource:(NSString *)resource;

/*!
Load JSON from bundle.
@param resource Resource name with extension, for example, file.json
@param options Parser options
@param error Out error
@result JSON value (NSArray, NSDictionary) or nil if errored
*/
- (id)yajl_JSONFromResource:(NSString *)resource options:(YAJLParserOptions)options error:(NSError **)error;

@end
47 changes: 47 additions & 0 deletions Classes/NSBundle+YAJL.m
@@ -0,0 +1,47 @@
//
// NSBundle+YAJL.m
// YAJL
//
// Created by Gabriel Handford on 7/23/09.
// Copyright 2009. All rights reserved.
//
// 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 USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//

#import "NSBundle+YAJL.h"
#import "GHNSBundle+Utils.h"
#import "NSObject+YAJL.h"

@implementation NSBundle (YAJL)

- (id)yajl_JSONFromResource:(NSString *)resource {
NSError *error = nil;
id JSONValue = [self yajl_JSONFromResource:resource options:YAJLParserOptionsNone error:&error];
if (error) [NSException raise:YAJLParserException format:[error localizedDescription], nil];
return JSONValue;
}

- (id)yajl_JSONFromResource:(NSString *)resource options:(YAJLParserOptions)options error:(NSError **)error {
return [[self gh_loadStringDataFromResource:resource] yajl_JSONWithOptions:YAJLParserOptionsAllowComments error:error];
}

@end
1 change: 0 additions & 1 deletion Classes/NSObject+YAJL.m
Expand Up @@ -76,5 +76,4 @@ - (id)yajl_JSONWithOptions:(YAJLParserOptions)options error:(NSError **)error {
return [root autorelease];
}


@end
1 change: 1 addition & 0 deletions Classes/YAJL.h
Expand Up @@ -31,3 +31,4 @@
#import "YAJLDocument.h"
#import "YAJLGen.h"
#import "NSObject+YAJL.h"
#import "NSBundle+YAJL.h"
4 changes: 2 additions & 2 deletions Classes/YAJLGen.m
Expand Up @@ -28,7 +28,7 @@
//

#import "YAJLGen.h"
#import "YAJL_GTMBase64.h"
#import "GTMBase64.h"

NSString *const YAJLGenInvalidObjectException = @"YAJLGenInvalidObjectException";

Expand Down Expand Up @@ -88,7 +88,7 @@ - (void)object:(id)obj {
if ([obj isKindOfClass:[NSDate class]]) {
[self number:[NSNumber numberWithLongLong:round([obj timeIntervalSince1970] * 1000)]];
} else if ([obj isKindOfClass:[NSData class]]) {
[self string:[YAJL_GTMBase64 stringByEncodingData:obj]];
[self string:[GTMBase64 stringByEncodingData:obj]];
} else if ([obj isKindOfClass:[NSURL class]]) {
[self string:[obj absoluteString]];
} else {
Expand Down
18 changes: 8 additions & 10 deletions ...ne/Libraries/GHUnit/GHUNSObject+Swizzle.h → Classes/YAJLIOS.h
@@ -1,8 +1,8 @@
//
// GHNSObject+Swizzle.h
// GHUnit
// YAJL.h
// YAJL
//
// Created by Gabriel Handford on 4/13/09.
// Created by Gabriel Handford on 7/23/09.
// Copyright 2009. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
Expand All @@ -27,10 +27,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//

@interface NSObject (GHUSwizzle)

+ (void)ghu_swizzleMethod:(SEL)original withMethod:(SEL)alternate;
+ (void)ghu_swizzleClassMethod:(SEL)original withClassMethod:(SEL)alternate;

@end

#import "YAJLParser.h"
#import "YAJLDocument.h"
#import "YAJLGen.h"
#import "NSObject+YAJL.h"
#import "NSBundle+YAJL.h"
32 changes: 32 additions & 0 deletions Libraries/GHKit/GHNSBundle+Utils.h
@@ -0,0 +1,32 @@
//
// GHNSBundle+Utils.h
// GHKit
//
// Created by Gabriel Handford on 4/27/09.
// Copyright 2009. All rights reserved.
//

@interface NSBundle (GHUtils)

/*!
Load data from resource.
@param resource Name of resource
@result NSData
*/
- (NSData *)gh_loadDataFromResource:(NSString *)resource;

/*!
Load string data from resource.
@param resource Name of resource
@result NSString
*/
- (NSString *)gh_loadStringDataFromResource:(NSString *)resource;

/*!
Get URL for resource.
@param resource Name of resource
@result URL to resource
*/
- (NSURL *)gh_URLForResource:(NSString *)resource;

@end
33 changes: 33 additions & 0 deletions Libraries/GHKit/GHNSBundle+Utils.m
@@ -0,0 +1,33 @@
//
// GHNSBundle+Utils.m
// GHKit
//
// Created by Gabriel Handford on 4/27/09.
// Copyright 2009. All rights reserved.
//

#import "GHNSBundle+Utils.h"

@implementation NSBundle (GHUtils)

- (NSData *)gh_loadDataFromResource:(NSString *)resource {
NSParameterAssert(resource);
NSString *resourcePath = [self pathForResource:[resource stringByDeletingPathExtension] ofType:[resource pathExtension]];
if (!resourcePath) [NSException raise:NSInvalidArgumentException format:@"Resource not found: %@", resource];
NSError *error = nil;
NSData *data = [NSData dataWithContentsOfFile:resourcePath options:0 error:&error];
if (error) [NSException raise:NSInvalidArgumentException format:@"Error loading resource at path (%@): %@", resourcePath, error];
return data;
}

- (NSString *)gh_loadStringDataFromResource:(NSString *)resource {
return [[[NSString alloc] initWithData:[self gh_loadDataFromResource:resource] encoding:NSUTF8StringEncoding] autorelease];
}

- (NSURL *)gh_URLForResource:(NSString *)resource {
NSParameterAssert(resource);
NSString *resourcePath = [self pathForResource:[resource stringByDeletingPathExtension] ofType:[resource pathExtension]];
return resourcePath ? [NSURL fileURLWithPath:resourcePath] : nil;
}

@end
Expand Up @@ -41,7 +41,7 @@
/// encoding. You must use the webSafe* methods together, the data does not
/// interop with the RFC methods.
//
@interface YAJL_GTMBase64 : NSObject
@interface GTMBase64 : NSObject

//
// Standard Base64 (RFC) handling
Expand Down
8 changes: 4 additions & 4 deletions Libraries/GTM/YAJL_GTMBase64.m → Libraries/GTM/GTMBase64.m
Expand Up @@ -16,7 +16,7 @@
// the License.
//

#import "YAJL_GTMBase64.h"
#import "GTMBase64.h"

static const char *kBase64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static const char *kWebSafeBase64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
Expand Down Expand Up @@ -212,7 +212,7 @@ GTM_INLINE NSUInteger GuessDecodedLength(NSUInteger srcLen) {
}


@interface YAJL_GTMBase64 (PrivateMethods)
@interface GTMBase64 (PrivateMethods)

+(NSData *)baseEncode:(const void *)bytes
length:(NSUInteger)length
Expand Down Expand Up @@ -241,7 +241,7 @@ +(NSUInteger)baseDecode:(const char *)srcBytes
@end


@implementation YAJL_GTMBase64
@implementation GTMBase64

//
// Standard Base64 (RFC) handling
Expand Down Expand Up @@ -396,7 +396,7 @@ +(NSData *)webSafeDecodeString:(NSString *)string {

@end

@implementation YAJL_GTMBase64 (PrivateMethods)
@implementation GTMBase64 (PrivateMethods)

//
// baseEncode:length:charset:padded:
Expand Down
18 changes: 18 additions & 0 deletions Project-IPhone/Framework.plist
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//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>CFBundleIdentifier</key>
<string>me.rel.yajl</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(YAJL_VERSION)</string>
</dict>
</plist>
16 changes: 0 additions & 16 deletions Project-IPhone/Libraries/GHUnit/Makefile

This file was deleted.

Binary file removed Project-IPhone/Libraries/GHUnit/libGHUnitIPhone4_0.a
Binary file not shown.
1 change: 1 addition & 0 deletions Project-IPhone/Libraries/GHUnitIOS.framework/GHUnitIOS
1 change: 1 addition & 0 deletions Project-IPhone/Libraries/GHUnitIOS.framework/Headers
1 change: 1 addition & 0 deletions Project-IPhone/Libraries/GHUnitIOS.framework/Resources
Binary file not shown.
File renamed without changes.
File renamed without changes.
Expand Up @@ -33,6 +33,15 @@
#import "GHTestMacros.h"
#import "GHTestRunner.h"

#import "GHTest.h"
#import "GHTesting.h"
#import "GHTestOperation.h"
#import "GHTestGroup.h"
#import "GHTest+JUnitXML.h"
#import "GHTestGroup+JUnitXML.h"
#import "NSException+GHTestFailureExceptions.h"
#import "NSValue+GHValueFormatter.h"

#ifdef DEBUG
#define GHUDebug(fmt, ...) do { \
fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@"\n"] UTF8String], stdout); \
Expand Down
@@ -0,0 +1,3 @@

#import "GHUnit.h"
#import "GHUnitIPhoneAppDelegate.h"
@@ -0,0 +1,40 @@
//
// GHUnitIPhoneTableViewDataSource.h
// GHUnitIPhone
//
// Created by Gabriel Handford on 5/5/09.
// Copyright 2009. All rights reserved.
//
// 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 USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//

#import "GHTestViewModel.h"

@interface GHUnitIPhoneTableViewDataSource : GHTestViewModel <UITableViewDataSource> {

}

- (GHTestNode *)nodeForIndexPath:(NSIndexPath *)indexPath;

- (void)setSelectedForAllNodes:(BOOL)selected;

@end

0 comments on commit 8ddd6f8

Please sign in to comment.