Revert ABI breakage

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34410 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2012-01-04 09:20:32 +00:00
parent 47571e082d
commit 3f6bf1fbba
8 changed files with 75 additions and 78 deletions

View file

@ -1,3 +1,15 @@
2012-01-04 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSXMLDocument.m:
* Source/NSXMLNode.m:
* Source/NSXMLElement.m:
* Headers/Foundation/NSXMLDocument.h:
* Headers/Foundation/NSXMLNode.h:
* Headers/Foundation/NSXMLDTD.h:
* Headers/Foundation/NSXMLElement.h:
Revert latest changes to restore scheme for preventing ABI breakage
and supporting both fragile and non-fragile ABIs..
2012-01-04 Fred Kiefer <FredKiefer@gmx.de> 2012-01-04 Fred Kiefer <FredKiefer@gmx.de>
* Headers/Foundation/NSXMLDocument.h, * Headers/Foundation/NSXMLDocument.h,

View file

@ -46,7 +46,7 @@ extern "C" {
//NSString *_name; //NSString *_name;
NSString *_publicID; NSString *_publicID;
NSString *_systemID; NSString *_systemID;
//NSArray *_children; NSArray *_children;
BOOL _childrenHaveMutated; BOOL _childrenHaveMutated;
BOOL _modified; BOOL _modified;
NSMutableDictionary *_entities; NSMutableDictionary *_entities;

View file

@ -79,9 +79,11 @@ typedef NSUInteger NSXMLDocumentContentKind;
NSString *_encoding; NSString *_encoding;
NSString *_version; NSString *_version;
NSXMLDTD *_docType; NSXMLDTD *_docType;
NSArray *_children;
BOOL _childrenHaveMutated;
BOOL _standalone; BOOL _standalone;
NSXMLElement *_rootElement; NSXMLElement *_rootElement;
//NSString *_URI; NSString *_URI;
NSString *_MIMEType; NSString *_MIMEType;
NSUInteger _fidelityMask; NSUInteger _fidelityMask;
NSXMLDocumentContentKind _contentKind; NSXMLDocumentContentKind _contentKind;

View file

@ -43,6 +43,8 @@ extern "C" {
@protected @protected
NSMutableDictionary *_attributes; NSMutableDictionary *_attributes;
NSMutableArray *_namespaces; NSMutableArray *_namespaces;
NSMutableArray *_children;
BOOL _childrenHaveMutated;
NSInteger _prefixIndex; NSInteger _prefixIndex;
#endif #endif
} }

View file

@ -80,20 +80,29 @@ typedef NSUInteger NSXMLNodeKind;
*/ */
@interface NSXMLNode : NSObject <NSCopying> @interface NSXMLNode : NSObject <NSCopying>
{ {
#if GS_EXPOSE(NSXMLNode)
@protected @protected
void *_handle; void *_handle;
NSXMLNodeKind _kind; NSXMLNodeKind _kind;
NSXMLNode *_parent; NSXMLNode *_parent;
NSUInteger _index; NSUInteger _index;
id _objectValue; id _objectValue;
NSString *_stringValue; NSString *_stringValue;
NSString *_name; NSString *_name;
NSString *_URI; NSString *_URI;
NSMutableArray *_children; #endif
NSUInteger _childCount; #if GS_NONFRAGILE
NSXMLNode *_previousSibling; # if defined(GS_NSXMLNode_IVARS)
NSXMLNode *_nextSibling; @public GS_NSXMLNode_IVARS
NSUInteger _options; # endif
#else
/* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/
@private id _internal GS_UNUSED_IVAR;
#endif
} }
/** /**

View file

@ -43,6 +43,7 @@
RELEASE(_encoding); RELEASE(_encoding);
RELEASE(_version); RELEASE(_version);
RELEASE(_docType); RELEASE(_docType);
RELEASE(_children);
RELEASE(_URI); RELEASE(_URI);
RELEASE(_MIMEType); RELEASE(_MIMEType);
RELEASE(_elementStack); RELEASE(_elementStack);
@ -89,16 +90,13 @@
if (parser != nil) if (parser != nil)
{ {
_standalone = YES; _standalone = YES;
_children = [[NSMutableArray alloc] initWithCapacity: 10];
_elementStack = [[NSMutableArray alloc] initWithCapacity: 10]; _elementStack = [[NSMutableArray alloc] initWithCapacity: 10];
ASSIGN(_xmlData, data); ASSIGN(_xmlData, data);
[parser setDelegate: self]; [parser setDelegate: self];
[parser parse]; [parser parse];
RELEASE(parser); RELEASE(parser);
} }
else
{
return nil;
}
} }
return self; return self;
} }
@ -112,13 +110,9 @@
element, element,
self]; self];
} }
self = [self init]; self = [self initWithData: nil options: 0 error: 0];
if (self != nil) if (self != nil)
{ {
_standalone = YES;
_children = [[NSMutableArray alloc] initWithCapacity: 10];
_elementStack = [[NSMutableArray alloc] initWithCapacity: 10];
[self setRootElement: (NSXMLNode*)element]; [self setRootElement: (NSXMLNode*)element];
} }
return self; return self;
@ -205,7 +199,7 @@
{ {
[child setParent: self]; [child setParent: self];
[(NSMutableArray *)_children insertObject: child atIndex: index]; [(NSMutableArray *)_children insertObject: child atIndex: index];
// _childrenHaveMutated = YES; _childrenHaveMutated = YES;
} }
- (void) insertChildren: (NSArray*)children atIndex: (NSUInteger)index - (void) insertChildren: (NSArray*)children atIndex: (NSUInteger)index
@ -221,8 +215,8 @@
- (void) removeChildAtIndex: (NSUInteger)index - (void) removeChildAtIndex: (NSUInteger)index
{ {
[_children removeObjectAtIndex: index]; [(NSMutableArray *)_children removeObjectAtIndex: index];
// _childrenHaveMutated = YES; _childrenHaveMutated = YES;
} }
- (void) setChildren: (NSArray*)children - (void) setChildren: (NSArray*)children
@ -288,26 +282,6 @@
return NO; return NO;
} }
- (NSString *) XMLStringWithOptions: (NSUInteger)options
{
NSMutableString *string = [NSMutableString string];
NSEnumerator *en = [_children objectEnumerator];
id obj = nil;
[string appendString: @"<?xml version=\"1.0\""];
if(_standalone == YES)
{
[string appendString: @" standalone=\"yes\""];
}
[string appendString: @"?>\n"];
while((obj = [en nextObject]) != nil)
{
[string appendString: [obj XMLStringWithOptions: options]];
}
return string;
}
@end @end
@implementation NSXMLDocument (NSXMLParserDelegate) @implementation NSXMLDocument (NSXMLParserDelegate)
@ -318,11 +292,9 @@
qualifiedName: (NSString *)qualifiedName qualifiedName: (NSString *)qualifiedName
attributes: (NSDictionary *)attributeDict attributes: (NSDictionary *)attributeDict
{ {
NSXMLElement *lastElement = [_elementStack lastObject];
NSXMLElement *currentElement = NSXMLElement *currentElement =
[[NSXMLElement alloc] initWithName: elementName]; [[NSXMLElement alloc] initWithName: elementName];
[lastElement addChild: currentElement];
[_elementStack addObject: currentElement]; [_elementStack addObject: currentElement];
if (_rootElement == nil) if (_rootElement == nil)
{ {

View file

@ -32,6 +32,7 @@
{ {
[_attributes release]; [_attributes release];
[_namespaces release]; [_namespaces release];
[_children release];
[super dealloc]; [super dealloc];
} }
@ -104,15 +105,7 @@
- (void) setAttributesAsDictionary: (NSDictionary*)attributes - (void) setAttributesAsDictionary: (NSDictionary*)attributes
{ {
NSString *key = nil; ASSIGN(_attributes, [attributes mutableCopy]);
NSEnumerator *en = [attributes keyEnumerator];
while((key = [en nextObject]) != nil)
{
NSXMLNode *attribute = [NSXMLNode attributeWithName: key
stringValue: [attributes objectForKey: key]];
[self addAttribute: attribute];
}
} }
- (NSArray*) attributes - (NSArray*) attributes
@ -198,14 +191,13 @@
- (void) setChildren: (NSArray*)children - (void) setChildren: (NSArray*)children
{ {
ASSIGN(_children, [children mutableCopy]); ASSIGN(_children, [children mutableCopy]);
// _childrenHaveMutated = YES; _childrenHaveMutated = YES;
} }
- (void) addChild: (NSXMLNode*)child - (void) addChild: (NSXMLNode*)child
{ {
[child setParent: self];
[_children addObject: child]; [_children addObject: child];
// _childrenHaveMutated = YES; _childrenHaveMutated = YES;
} }
- (void) replaceChildAtIndex: (NSUInteger)index withNode: (NSXMLNode*)node - (void) replaceChildAtIndex: (NSUInteger)index withNode: (NSXMLNode*)node

View file

@ -36,7 +36,17 @@
* performance quite a bit. So we cache the siblings and update them when the * performance quite a bit. So we cache the siblings and update them when the
* nodes are changed. * nodes are changed.
*/ */
#define GS_NSXMLNode_IVARS \
NSMutableArray *children; \
NSUInteger childCount; \
NSXMLNode *previousSibling; \
NSXMLNode *nextSibling; \
NSUInteger options;
#define GSInternal NSXMLNodeInternal
#include "GSInternal.h"
@class NSXMLNode;
GS_PRIVATE_INTERNAL(NSXMLNode)
#import "NSXMLPrivate.h" #import "NSXMLPrivate.h"
@ -201,17 +211,17 @@
- (NSXMLNode*) childAtIndex: (NSUInteger)index - (NSXMLNode*) childAtIndex: (NSUInteger)index
{ {
return [_children objectAtIndex: index]; return [internal->children objectAtIndex: index];
} }
- (NSUInteger) childCount - (NSUInteger) childCount
{ {
return _childCount; return internal->childCount;
} }
- (NSArray*)children - (NSArray*)children
{ {
return _children; return internal->children;
} }
- (id) copyWithZone: (NSZone*)zone - (id) copyWithZone: (NSZone*)zone
@ -222,8 +232,8 @@
- (void) dealloc - (void) dealloc
{ {
[self detach]; [self detach];
[_children release]; [internal->children release];
[_URI release]; GS_DESTROY_INTERNAL(NSXMLNode);
[_objectValue release]; [_objectValue release];
[_stringValue release]; [_stringValue release];
[super dealloc]; [super dealloc];
@ -262,9 +272,7 @@
return nil; return nil;
} }
// GS_CREATE_INTERNAL(NSXMLNode) GS_CREATE_INTERNAL(NSXMLNode)
_children = [[NSMutableArray alloc] initWithCapacity: 10];
_childCount = 0;
/* /*
* We find the correct subclass for specific node kinds: * We find the correct subclass for specific node kinds:
@ -317,8 +325,8 @@
*/ */
_kind = kind; _kind = kind;
_options = theOptions; internal->options = theOptions;
_children = [NSMutableArray new]; internal->children = [NSMutableArray new];
return self; return self;
} }
@ -356,14 +364,14 @@
NSXMLNode *candidate = nil; NSXMLNode *candidate = nil;
/* Node walking is a depth-first thingy. Hence, we consider children first: */ /* Node walking is a depth-first thingy. Hence, we consider children first: */
if (0 != _childCount) if (0 != internal->childCount)
{ {
NSUInteger theIndex = 0; NSUInteger theIndex = 0;
if (NO == forward) if (NO == forward)
{ {
theIndex = (_childCount) - 1; theIndex = (internal->childCount) - 1;
} }
candidate = [_children objectAtIndex: theIndex]; candidate = [internal->children objectAtIndex: theIndex];
} }
/* If there are no children, we move on to siblings: */ /* If there are no children, we move on to siblings: */
@ -371,11 +379,11 @@
{ {
if (forward) if (forward)
{ {
candidate = _nextSibling; candidate = internal->nextSibling;
} }
else else
{ {
candidate = _previousSibling; candidate = internal->previousSibling;
} }
} }
@ -417,7 +425,7 @@
- (NSXMLNode*) nextSibling - (NSXMLNode*) nextSibling
{ {
return _nextSibling; return internal->nextSibling;
} }
- (id) objectValue - (id) objectValue
@ -442,7 +450,7 @@
- (NSXMLNode*) previousSibling - (NSXMLNode*) previousSibling
{ {
return _previousSibling; return internal->previousSibling;
} }