Skip to content

Commit

Permalink
Merge branch 'arc'
Browse files Browse the repository at this point in the history
  • Loading branch information
robbiehanson committed Dec 23, 2011
2 parents 1a8ae62 + 3ecb7c3 commit 8256048
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 259 deletions.
8 changes: 5 additions & 3 deletions KissXML/Categories/NSString+DDXML.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#import "NSString+DDXML.h"

#if ! __has_feature(objc_arc)
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif

@implementation NSString (DDXML)

Expand All @@ -17,12 +20,11 @@ - (NSString *)stringByTrimming
- (NSString *)stringByTrimming
{
NSMutableString *mStr = [self mutableCopy];
CFStringTrimWhitespace((CFMutableStringRef)mStr);
CFStringTrimWhitespace((__bridge CFMutableStringRef)mStr);

NSString *result = [mStr copy];

[mStr release];
return [result autorelease];
return result;
}
#endif

Expand Down
9 changes: 5 additions & 4 deletions KissXML/DDXMLDocument.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#import "DDXMLPrivate.h"
#import "NSString+DDXML.h"

#if ! __has_feature(objc_arc)
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif

/**
* Welcome to KissXML.
*
Expand All @@ -27,7 +31,7 @@ @implementation DDXMLDocument
**/
+ (id)nodeWithDocPrimitive:(xmlDocPtr)doc owner:(DDXMLNode *)owner
{
return [[[DDXMLDocument alloc] initWithDocPrimitive:doc owner:owner] autorelease];
return [[DDXMLDocument alloc] initWithDocPrimitive:doc owner:owner];
}

- (id)initWithDocPrimitive:(xmlDocPtr)doc owner:(DDXMLNode *)inOwner
Expand All @@ -49,7 +53,6 @@ - (id)initWithPrimitive:(xmlKindPtr)kindPtr owner:(DDXMLNode *)inOwner
// Promote initializers which use proper parameter types to enable compiler to catch more mistakes.
NSAssert(NO, @"Use initWithDocPrimitive:owner:");

[self release];
return nil;
}

Expand Down Expand Up @@ -78,7 +81,6 @@ - (id)initWithData:(NSData *)data options:(NSUInteger)mask error:(NSError **)err
{
if (error) *error = [NSError errorWithDomain:@"DDXMLErrorDomain" code:0 userInfo:nil];

[self release];
return nil;
}

Expand All @@ -94,7 +96,6 @@ - (id)initWithData:(NSData *)data options:(NSUInteger)mask error:(NSError **)err
{
if (error) *error = [NSError errorWithDomain:@"DDXMLErrorDomain" code:1 userInfo:nil];

[self release];
return nil;
}

Expand Down
30 changes: 11 additions & 19 deletions KissXML/DDXMLElement.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#import "DDXMLPrivate.h"
#import "NSString+DDXML.h"

#if ! __has_feature(objc_arc)
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
#endif

/**
* Welcome to KissXML.
*
Expand All @@ -27,7 +31,7 @@ @implementation DDXMLElement
**/
+ (id)nodeWithElementPrimitive:(xmlNodePtr)node owner:(DDXMLNode *)owner
{
return [[[DDXMLElement alloc] initWithElementPrimitive:node owner:owner] autorelease];
return [[DDXMLElement alloc] initWithElementPrimitive:node owner:owner];
}

- (id)initWithElementPrimitive:(xmlNodePtr)node owner:(DDXMLNode *)inOwner
Expand All @@ -49,7 +53,6 @@ - (id)initWithPrimitive:(xmlKindPtr)kindPtr owner:(DDXMLNode *)inOwner
// Promote initializers which use proper parameter types to enable compiler to catch more mistakes.
NSAssert(NO, @"Use initWithElementPrimitive:owner:");

[self release];
return nil;
}

Expand All @@ -60,7 +63,6 @@ - (id)initWithName:(NSString *)name
xmlNodePtr node = xmlNewNode(NULL, [name xmlChar]);
if (node == NULL)
{
[self release];
return nil;
}

Expand All @@ -74,7 +76,6 @@ - (id)initWithName:(NSString *)name URI:(NSString *)URI
xmlNodePtr node = xmlNewNode(NULL, [name xmlChar]);
if (node == NULL)
{
[self release];
return nil;
}

Expand All @@ -91,7 +92,6 @@ - (id)initWithName:(NSString *)name stringValue:(NSString *)string
xmlNodePtr node = xmlNewNode(NULL, [name xmlChar]);
if (node == NULL)
{
[self release];
return nil;
}

Expand All @@ -106,16 +106,13 @@ - (id)initWithXMLString:(NSString *)string error:(NSError **)error
DDXMLDocument *doc = [[DDXMLDocument alloc] initWithXMLString:string options:0 error:error];
if (doc == nil)
{
[self release];
return nil;
}

DDXMLElement *result = [doc rootElement];
[result detach];
[doc release];

[self release];
return [result retain];
return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -326,8 +323,7 @@ - (void)addAttribute:(DDXMLNode *)attribute
xmlAddChild((xmlNodePtr)genericPtr, (xmlNodePtr)attribute->genericPtr);

// The attribute is now part of the xml tree heirarchy
[attribute->owner release];
attribute->owner = [self retain];
attribute->owner = self;
}

- (void)removeAttributeForName:(NSString *)name
Expand Down Expand Up @@ -476,8 +472,7 @@ - (void)_addNamespace:(DDXMLNode *)namespace
}

// The namespace is now part of the xml tree heirarchy
[namespace->owner release];
namespace->owner = [self retain];
namespace->owner = self;

if ([namespace isKindOfClass:[DDXMLNamespaceNode class]])
{
Expand Down Expand Up @@ -710,8 +705,7 @@ - (void)addChild:(DDXMLNode *)child
xmlAddChild((xmlNodePtr)genericPtr, (xmlNodePtr)child->genericPtr);

// The node is now part of the xml tree heirarchy
[child->owner release];
child->owner = [self retain];
child->owner = self;
}

- (void)insertChild:(DDXMLNode *)child atIndex:(NSUInteger)index
Expand All @@ -737,8 +731,7 @@ - (void)insertChild:(DDXMLNode *)child atIndex:(NSUInteger)index
{
xmlAddPrevSibling(childNodePtr, (xmlNodePtr)child->genericPtr);

[child->owner release];
child->owner = [self retain];
child->owner = self;

return;
}
Expand All @@ -752,8 +745,7 @@ - (void)insertChild:(DDXMLNode *)child atIndex:(NSUInteger)index
{
xmlAddChild((xmlNodePtr)genericPtr, (xmlNodePtr)child->genericPtr);

[child->owner release];
child->owner = [self retain];
child->owner = self;

return;
}
Expand Down
Loading

0 comments on commit 8256048

Please sign in to comment.