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
This commit is contained in:
Richard Frith-MacDonald 2012-01-05 18:55:17 +00:00
parent 545bc0f99c
commit 1a85fb0780
3 changed files with 55 additions and 30 deletions

View file

@ -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

View file

@ -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];

View file

@ -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];