Remove uneeded ivars.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/nsxml_using_libxml2@34516 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2012-01-13 22:10:41 +00:00
parent 6983dd6e31
commit db0fefff04
5 changed files with 103 additions and 106 deletions

View file

@ -46,7 +46,6 @@ GS_PRIVATE_INTERNAL(NSXMLDTD)
[internal->entities release];
[internal->elements release];
[internal->notations release];
[internal->attributes release];
[internal->original release];
}
[super dealloc];
@ -117,7 +116,6 @@ GS_PRIVATE_INTERNAL(NSXMLDTD)
- (void) insertChild: (NSXMLNode*)child atIndex: (NSUInteger)index
{
[self notImplemented: _cmd];
internal->childrenHaveMutated = YES;
}
- (void) insertChildren: (NSArray*)children atIndex: (NSUInteger)index
@ -169,13 +167,11 @@ GS_PRIVATE_INTERNAL(NSXMLDTD)
- (void) setPublicID: (NSString*)publicID
{
[self notImplemented: _cmd];
internal->modified = YES;
}
- (void) setSystemID: (NSString*)systemID
{
[self notImplemented: _cmd];
internal->modified = YES;
}
- (NSString*) systemID

View file

@ -51,8 +51,6 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
{
[internal->docType release];
[internal->MIMEType release];
[internal->elementStack release];
[internal->xmlData release];
}
[super dealloc];
}
@ -246,7 +244,12 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
- (void) insertChild: (NSXMLNode*)child atIndex: (NSUInteger)index
{
NSXMLNodeKind kind;
NSXMLNode *next = nil;
xmlNodePtr nextNode = NULL;
xmlNodePtr newNode = NULL;
xmlNodePtr prevNode = NULL;
// Check to make sure this is a valid addition...
NSAssert(nil != child, NSInvalidArgumentException);
NSAssert(index <= [self childCount], NSInvalidArgumentException);
NSAssert(nil == [child parent], NSInvalidArgumentException);
@ -260,14 +263,19 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
NSAssert(NSXMLNamespaceKind != kind, NSInvalidArgumentException);
NSAssert(NSXMLNotationDeclarationKind != kind, NSInvalidArgumentException);
if (nil == internal->children)
{
internal->children = [[NSMutableArray alloc] initWithCapacity: 10];
}
[internal->children insertObject: child
atIndex: index];
// Get all of the nodes...
newNode = ((xmlNodePtr)[child _node]);
next = [self childAtIndex: index];
nextNode = ((xmlNodePtr)[next _node]);
prevNode = nextNode->prev;
// Make all of the links...
prevNode->next = newNode;
newNode->next = nextNode;
newNode->prev = prevNode;
nextNode->prev = newNode;
GSIVar(child, parent) = self;
internal->childCount++;
}
- (void) insertChildren: (NSArray*)children atIndex: (NSUInteger)index
@ -283,50 +291,39 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
- (void) removeChildAtIndex: (NSUInteger)index
{
NSXMLNode *child = [internal->children objectAtIndex: index];
NSXMLNode *child;
xmlNodePtr n;
if (nil != child)
if (index >= [self childCount])
{
if (internal->rootElement == child)
{
internal->rootElement = nil;
}
GSIVar(child, parent) = nil;
[internal->children removeObjectAtIndex: index];
if (0 == --internal->childCount)
{
/* The -children method must return nil if there are no children,
* so we destroy the container.
*/
DESTROY(internal->children);
}
[NSException raise: NSRangeException
format: @"index to large"];
}
child = [[self children] objectAtIndex: index];
n = [child _node];
xmlUnlinkNode(n);
}
- (void) setChildren: (NSArray*)children
{
if (children != internal->children)
{
NSEnumerator *en;
NSXMLNode *child;
[children retain];
while (internal->childCount > 0)
while ([self childCount] > 0)
{
[self removeChildAtIndex:internal->childCount - 1];
[self removeChildAtIndex: [self childCount] - 1];
}
en = [children objectEnumerator];
en = [[self children] objectEnumerator];
while ((child = [en nextObject]) != nil)
{
[self insertChild: child atIndex: internal->childCount];
}
[children release];
[self insertChild: child atIndex: [self childCount]];
}
}
- (void) addChild: (NSXMLNode*)child
{
[self insertChild: child atIndex: internal->childCount];
[self insertChild: child atIndex: [self childCount]];
}
- (void) replaceChildAtIndex: (NSUInteger)index withNode: (NSXMLNode*)node
@ -409,6 +406,7 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
@end
/*
@implementation NSXMLDocument (NSXMLParserDelegate)
- (void) parser: (NSXMLParser *)parser
@ -453,3 +451,4 @@ foundCharacters: (NSString *)string
[currentElement setStringValue: string];
}
@end
*/

View file

@ -41,12 +41,10 @@ GS_PRIVATE_INTERNAL(NSXMLElement)
{
if (GS_EXISTS_INTERNAL && _internal != nil)
{
while (internal->childCount > 0)
while ([self childCount] > 0)
{
[self removeChildAtIndex: internal->childCount - 1];
[self removeChildAtIndex: [self childCount] - 1];
}
[internal->attributes release];
[internal->namespaces release];
}
[super dealloc];
}
@ -152,7 +150,7 @@ GS_PRIVATE_INTERNAL(NSXMLElement)
NSEnumerator *en = [attributes keyEnumerator];
NSString *key;
[internal->attributes removeAllObjects];
// [internal->attributes removeAllObjects];
while ((key = [en nextObject]) != nil)
{
NSString *val = [attributes objectForKey: key];
@ -164,12 +162,14 @@ GS_PRIVATE_INTERNAL(NSXMLElement)
- (NSArray*) attributes
{
return [internal->attributes allValues];
[self notImplemented: _cmd];
return nil; // [internal->attributes allValues];
}
- (NSXMLNode*) attributeForName: (NSString*)name
{
return [internal->attributes objectForKey: name];
[self notImplemented: _cmd];
return nil; // [internal->attributes objectForKey: name];
}
- (NSXMLNode*) attributeForLocalName: (NSString*)localName
@ -205,7 +205,8 @@ GS_PRIVATE_INTERNAL(NSXMLElement)
- (NSArray*) namespaces
{
return internal->namespaces;
[self notImplemented: _cmd];
return nil; // internal->namespaces;
}
- (NSXMLNode*) namespaceForPrefix: (NSString*)name
@ -229,13 +230,16 @@ GS_PRIVATE_INTERNAL(NSXMLElement)
- (void) insertChild: (NSXMLNode*)child atIndex: (NSUInteger)index
{
NSXMLNodeKind kind;
xmlNodePtr node = (xmlNodePtr)(internal->node);
NSXMLNode *next = nil;
xmlNodePtr nextNode = NULL;
xmlNodePtr newNode = NULL;
xmlNodePtr prevNode = NULL;
// Check to make sure this is a valid addition...
NSAssert(nil != child, NSInvalidArgumentException);
NSAssert(index <= internal->childCount, NSInvalidArgumentException);
NSAssert(nil == [child parent], NSInternalInconsistencyException);
NSAssert(index <= [self childCount], NSInvalidArgumentException);
NSAssert(nil == [child parent], NSInvalidArgumentException);
kind = [child kind];
// FIXME ... should we check for valid kinds rather than invalid ones?
NSAssert(NSXMLAttributeKind != kind, NSInvalidArgumentException);
NSAssert(NSXMLDTDKind != kind, NSInvalidArgumentException);
NSAssert(NSXMLDocumentKind != kind, NSInvalidArgumentException);
@ -245,14 +249,19 @@ GS_PRIVATE_INTERNAL(NSXMLElement)
NSAssert(NSXMLNamespaceKind != kind, NSInvalidArgumentException);
NSAssert(NSXMLNotationDeclarationKind != kind, NSInvalidArgumentException);
if (nil == internal->children)
{
internal->children = [[NSMutableArray alloc] initWithCapacity: 10];
}
[internal->children insertObject: child
atIndex: index];
// Get all of the nodes...
newNode = ((xmlNodePtr)[child _node]);
next = [self childAtIndex: index];
nextNode = ((xmlNodePtr)[next _node]);
prevNode = nextNode->prev;
// Make all of the links...
prevNode->next = newNode;
newNode->next = nextNode;
newNode->prev = prevNode;
nextNode->prev = newNode;
GSIVar(child, parent) = self;
internal->childCount++;
}
- (void) insertChildren: (NSArray*)children atIndex: (NSUInteger)index
@ -284,22 +293,17 @@ GS_PRIVATE_INTERNAL(NSXMLElement)
- (void) setChildren: (NSArray*)children
{
if (children != internal->children)
{
NSEnumerator *en;
NSXMLNode *child;
[children retain];
while (internal->childCount > 0)
while ([self childCount] > 0)
{
[self removeChildAtIndex:internal->childCount - 1];
[self removeChildAtIndex: [self childCount] - 1];
}
en = [children objectEnumerator];
en = [[self children] objectEnumerator];
while ((child = [en nextObject]) != nil)
{
[self insertChild: child atIndex: internal->childCount];
}
[children release];
[self insertChild: child atIndex: [self childCount]];
}
}
@ -326,7 +330,7 @@ GS_PRIVATE_INTERNAL(NSXMLElement)
NSEnumerator *en;
id obj;
en = [internal->namespaces objectEnumerator];
en = [[self namespaces] objectEnumerator];
while ((obj = [en nextObject]) != nil)
{
NSXMLNode *ns = [obj copyWithZone: zone];
@ -335,7 +339,7 @@ GS_PRIVATE_INTERNAL(NSXMLElement)
[ns release];
}
en = [internal->attributes objectEnumerator];
en = [[self attributes] objectEnumerator];
while ((obj = [en nextObject]) != nil)
{
NSXMLNode *attr = [obj copyWithZone: zone];
@ -344,7 +348,7 @@ GS_PRIVATE_INTERNAL(NSXMLElement)
[attr release];
}
en = [internal->children objectEnumerator];
en = [[self children] objectEnumerator];
while ((obj = [en nextObject]) != nil)
{
NSXMLNode *child = [obj copyWithZone: zone];

View file

@ -97,8 +97,8 @@ GS_PRIVATE_INTERNAL(NSXMLNode)
{
case(NSXMLAttributeKind):
node = xmlNewProp(NULL,
XMLSTRING([object name]),
XMLSTRING([object stringValue]));
(xmlChar *)XMLSTRING([object name]),
(xmlChar *)XMLSTRING([object stringValue]));
break;
case(NSXMLElementKind):
node = xmlNewNode(NULL,XMLSTRING([object name]));
@ -123,12 +123,14 @@ GS_PRIVATE_INTERNAL(NSXMLNode)
stringValue: (NSString*)stringValue
{
NSXMLNode *n;
xmlAttrPtr node;
xmlAttrPtr node = xmlNewProp(NULL,
XMLSTRING(name),
XMLSTRING(stringValue));
n = [[[self alloc] initWithKind: NSXMLAttributeKind] autorelease];
[n setStringValue: stringValue];
[n setName: name];
[n _setNode: node];
[n _setNode: (void *)node];
return n;
}
@ -366,7 +368,7 @@ GS_PRIVATE_INTERNAL(NSXMLNode)
- (NSUInteger) hash
{
return [internal->name hash];
return [StringFromXMLStringPtr(MY_NODE->name) hash];
}
- (NSUInteger) index
@ -478,7 +480,7 @@ GS_PRIVATE_INTERNAL(NSXMLNode)
}
c = [other children];
if (c != internal->children && NO == [c isEqual: internal->children])
if (c != [self children] && NO == [c isEqual: [self children]])
{
return NO;
}
@ -525,14 +527,14 @@ GS_PRIVATE_INTERNAL(NSXMLNode)
NSXMLNode *candidate = nil;
/* Node walking is a depth-first thingy. Hence, we consider children first: */
if (0 != internal->childCount)
if (0 != [self childCount])
{
NSUInteger theIndex = 0;
if (NO == forward)
{
theIndex = (internal->childCount) - 1;
theIndex = ([self childCount]) - 1;
}
candidate = [internal->children objectAtIndex: theIndex];
candidate = [[self children] objectAtIndex: theIndex];
}
/* If there are no children, we move on to siblings: */
@ -586,7 +588,14 @@ GS_PRIVATE_INTERNAL(NSXMLNode)
- (NSXMLNode*) nextSibling
{
return internal->nextSibling;
xmlNodePtr node = MY_NODE->next;
if(node != NULL)
{
return node->next->_private;
}
return nil;
}
- (id) objectValue
@ -691,7 +700,7 @@ GS_PRIVATE_INTERNAL(NSXMLNode)
- (void) setStringValue: (NSString*)string resolvingEntities: (BOOL)resolve
{
xmlNodePtr node = (xmlNodePtr)(internal->node);
xmlNodePtr node = MY_NODE;
if (resolve == NO)
{
node->content = (xmlChar *)[string UTF8String];
@ -701,7 +710,7 @@ GS_PRIVATE_INTERNAL(NSXMLNode)
// need to actually resolve entities...
node->content = (xmlChar *)[string UTF8String];
}
if (nil == internal->stringValue)
if (nil == string)
{
node->content = (xmlChar *)[@"" UTF8String]; // string value may not be nil
}

View file

@ -132,13 +132,9 @@ StringFromXMLString(const unsigned char *bytes, unsigned length)
*/
#define GS_NSXMLDocument_IVARS SUPERIVARS(GS_NSXMLNode_IVARS) \
NSXMLDTD *docType; \
BOOL childrenHaveMutated; \
NSXMLElement *rootElement; \
NSString *MIMEType; \
NSUInteger fidelityMask; \
NSInteger contentKind; \
NSMutableArray *elementStack; \
NSData *xmlData; \
/* Instance variables for NSXMLDTD with/without the instance
@ -149,8 +145,6 @@ StringFromXMLString(const unsigned char *bytes, unsigned length)
#define GS_NSXMLDTD_IVARS SUPERIVARS(GS_NSXMLNode_IVARS) \
NSString *publicID; \
NSString *systemID; \
BOOL childrenHaveMutated; \
BOOL modified; \
NSMutableDictionary *entities; \
NSMutableDictionary *elements; \
NSMutableDictionary *notations; \
@ -175,12 +169,7 @@ StringFromXMLString(const unsigned char *bytes, unsigned length)
* This macro needs to be defined before the NSXMLElement.h header
* is imported and before GSInternal.h is imported.
*/
#define GS_NSXMLElement_IVARS SUPERIVARS(GS_NSXMLNode_IVARS) \
NSMutableDictionary *attributes; \
NSMutableArray *namespaces; \
BOOL childrenHaveMutated; \
NSInteger prefixIndex; \
#define GS_NSXMLElement_IVARS SUPERIVARS(GS_NSXMLNode_IVARS)
#import "Foundation/NSArray.h"
#import "Foundation/NSData.h"