From 1a85fb0780c473acaed7495c87c45d05a3cba009 Mon Sep 17 00:00:00 2001 From: Richard Frith-MacDonald Date: Thu, 5 Jan 2012 18:55:17 +0000 Subject: [PATCH] Minor intiialisation tweaks to match OSX git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34423 72102866-910b-0410-8b05-ffd578937521 --- Source/NSXMLDTD.m | 5 +++++ Source/NSXMLDocument.m | 51 +++++++++++++++++++++++++++--------------- Source/NSXMLElement.m | 29 ++++++++++++++---------- 3 files changed, 55 insertions(+), 30 deletions(-) diff --git a/Source/NSXMLDTD.m b/Source/NSXMLDTD.m index 5329310cf..06217af9b 100644 --- a/Source/NSXMLDTD.m +++ b/Source/NSXMLDTD.m @@ -77,6 +77,11 @@ GS_PRIVATE_INTERNAL(NSXMLDTD) return nil; } +- (id) init +{ + return [self initWithKind: NSXMLDTDKind options: 0]; +} + - (id) initWithContentsOfURL: (NSURL*)url options: (NSUInteger)mask error: (NSError**)error diff --git a/Source/NSXMLDocument.m b/Source/NSXMLDocument.m index 50f90a620..9ff22616a 100644 --- a/Source/NSXMLDocument.m +++ b/Source/NSXMLDocument.m @@ -72,6 +72,11 @@ GS_PRIVATE_INTERNAL(NSXMLDocument) return internal->docType; } +- (id) init +{ + return [self initWithKind: NSXMLDocumentKind options: 0]; +} + - (id) initWithContentsOfURL: (NSURL*)url options: (NSUInteger)mask error: (NSError**)error @@ -90,27 +95,37 @@ GS_PRIVATE_INTERNAL(NSXMLDocument) options: (NSUInteger)mask error: (NSError**)error { + if (NO == [data isKindOfClass: [NSData class]]) + { + DESTROY(self); + if (nil == data) + { + [NSException raise: NSInternalInconsistencyException + format: @"[NSXMLDocument-%@] nil argument", + NSStringFromSelector(_cmd)]; + } + [NSException raise: NSInternalInconsistencyException + format: @"[NSXMLDocument-%@] invalid argument", + NSStringFromSelector(_cmd)]; + } GS_CREATE_INTERNAL(NSXMLDocument) if ((self = [super initWithKind: NSXMLDocumentKind options: 0]) != nil) { - if (nil != data) - { - NSXMLParser *parser = [[NSXMLParser alloc] initWithData: data]; + NSXMLParser *parser = [[NSXMLParser alloc] initWithData: data]; - if (nil == parser) - { - DESTROY(self); - } - else - { - internal->standalone = YES; - internal->elementStack - = [[NSMutableArray alloc] initWithCapacity: 10]; - ASSIGN(internal->xmlData, data); - [parser setDelegate: self]; - [parser parse]; - RELEASE(parser); - } + if (nil == parser) + { + DESTROY(self); + } + else + { + internal->standalone = YES; + internal->elementStack + = [[NSMutableArray alloc] initWithCapacity: 10]; + ASSIGN(internal->xmlData, data); + [parser setDelegate: self]; + [parser parse]; + RELEASE(parser); } } return self; @@ -137,7 +152,7 @@ GS_PRIVATE_INTERNAL(NSXMLDocument) element, self]; } - self = [self initWithData: nil options: 0 error: 0]; + self = [self initWithKind: NSXMLDocumentKind options: 0]; if (self != nil) { [self setRootElement: (NSXMLNode*)element]; diff --git a/Source/NSXMLElement.m b/Source/NSXMLElement.m index 038408df3..7291cccb0 100644 --- a/Source/NSXMLElement.m +++ b/Source/NSXMLElement.m @@ -42,11 +42,28 @@ GS_PRIVATE_INTERNAL(NSXMLElement) [super dealloc]; } +- (id) init +{ + return [self initWithKind: NSXMLElementKind options: 0]; +} + - (id) initWithName: (NSString*)name { return [self initWithName: name URI: nil]; } +- (id) initWithKind: (NSXMLNodeKind)kind options: (NSUInteger)theOptions +{ + if (NSXMLElementKind == kind) + { + /* Create holder for internal instance variables so that we'll have + * all our ivars available rather than just those of the superclass. + */ + GS_CREATE_INTERNAL(NSXMLElement) + } + return [super initWithKind: kind options: theOptions]; +} + - (id) initWithName: (NSString*)name URI: (NSString*)URI { /* Create holder for internal instance variables so that we'll have @@ -71,18 +88,6 @@ GS_PRIVATE_INTERNAL(NSXMLElement) return nil; } -- (id) initWithKind: (NSXMLNodeKind)kind options: (NSUInteger)theOptions -{ - if (NSXMLElementKind == kind) - { - /* Create holder for internal instance variables so that we'll have - * all our ivars available rather than just those of the superclass. - */ - GS_CREATE_INTERNAL(NSXMLElement) - } - return [super initWithKind: kind options: theOptions]; -} - - (id) initWithXMLString: (NSString*)string error: (NSError**)error { [self notImplemented: _cmd];