Permalink
Browse files

Style cleanup (WIP)

  • Loading branch information...
1 parent 165e574 commit 5005e8e5d8fa114094bb13d87dcda4d494006b38 @schwa schwa committed Jul 12, 2011
Showing with 347 additions and 334 deletions.
  1. +80 −81 Source/CXHTMLDocument.m
  2. +175 −176 Source/CXMLDocument.m
  3. +7 −8 Source/CXMLDocument_PrivateExtensions.m
  4. +67 −63 Source/CXMLElement.m
  5. +18 −6 TouchXML.xcodeproj/project.pbxproj
View
161 Source/CXHTMLDocument.m
@@ -55,110 +55,109 @@ @implementation CXHTMLDocument
// which eliminates the need to resanitize strings extracted from the document
// libXML treats a htmlDocPtr the same as xmlDocPtr
- (id)initWithXHTMLString:(NSString *)inString options:(NSUInteger)inOptions error:(NSError **)outError
-{
-#pragma unused (inOptions)
+ {
+ #pragma unused (inOptions)
if ((self = [super init]) != NULL)
- {
+ {
NSError *theError = NULL;
htmlDocPtr theDoc = htmlParseDoc(BAD_CAST[inString UTF8String], xmlGetCharEncodingName(XML_CHAR_ENCODING_UTF8));
-
if (theDoc != NULL)
- {
-
- // TODO: change code to not depend on XPATH, should be a task simple enough to do
- // alternatively see if we can prevent the HTML parser from adding implied tags
-
- xmlXPathContextPtr xpathContext = xmlXPathNewContext (theDoc);
-
- xmlXPathObjectPtr xpathObject = NULL;
- if (xpathContext)
- xpathObject = xmlXPathEvalExpression (BAD_CAST("/html/body"), xpathContext);
-
- xmlNodePtr bodyNode = NULL;
- if (xpathObject && xpathObject->nodesetval->nodeMax)
- bodyNode = xpathObject->nodesetval->nodeTab[0];
-
- // TODO: Determine if this is sufficient to handle memory in libXML, is the old root removed / deleted, etc
- if (bodyNode)
- xmlDocSetRootElement(theDoc, bodyNode->children);
-
- _node = (xmlNodePtr)theDoc;
- NSAssert(_node->_private == NULL, @"TODO");
- _node->_private = self; // Note. NOT retained (TODO think more about _private usage)
-
- if (xpathObject)
- xmlXPathFreeObject (xpathObject);
-
- if (xpathContext)
- xmlXPathFreeContext (xpathContext);
- }
+ {
+ // TODO: change code to not depend on XPATH, should be a task simple enough to do
+ // alternatively see if we can prevent the HTML parser from adding implied tags
+
+ xmlXPathContextPtr xpathContext = xmlXPathNewContext (theDoc);
+
+ xmlXPathObjectPtr xpathObject = NULL;
+ if (xpathContext)
+ xpathObject = xmlXPathEvalExpression (BAD_CAST("/html/body"), xpathContext);
+
+ xmlNodePtr bodyNode = NULL;
+ if (xpathObject && xpathObject->nodesetval->nodeMax)
+ bodyNode = xpathObject->nodesetval->nodeTab[0];
+
+ // TODO: Determine if this is sufficient to handle memory in libXML, is the old root removed / deleted, etc
+ if (bodyNode)
+ xmlDocSetRootElement(theDoc, bodyNode->children);
+
+ _node = (xmlNodePtr)theDoc;
+ NSAssert(_node->_private == NULL, @"TODO");
+ _node->_private = self; // Note. NOT retained (TODO think more about _private usage)
+
+ if (xpathObject)
+ xmlXPathFreeObject (xpathObject);
+
+ if (xpathContext)
+ xmlXPathFreeContext (xpathContext);
+ }
else
- {
+ {
xmlErrorPtr theLastErrorPtr = xmlGetLastError();
-
NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys:
- theLastErrorPtr ? [NSString stringWithUTF8String:theLastErrorPtr->message] : @"unknown", NSLocalizedDescriptionKey,
- NULL];
+ theLastErrorPtr ? [NSString stringWithUTF8String:theLastErrorPtr->message] : @"unknown", NSLocalizedDescriptionKey,
+ NULL];
theError = [NSError errorWithDomain:@"CXMLErrorDomain" code:1 userInfo:theUserInfo];
xmlResetLastError();
- }
+ }
if (outError)
+ {
*outError = theError;
+ }
if (theError != NULL)
- {
+ {
[self release];
self = NULL;
- }
- }
+ }
+ }
return(self);
-}
+ }
- (id)initWithXHTMLData:(NSData *)inData encoding:(NSStringEncoding)encoding options:(NSUInteger)inOptions error:(NSError **)outError
-{
-#pragma unused (inOptions)
- if ((self = [super init]) != NULL)
- {
- NSError *theError = NULL;
-
- if (theError == NULL)
- {
- xmlDocPtr theDoc = NULL;
- if (inData && inData.length > 0)
- {
- CFStringEncoding cfenc = CFStringConvertNSStringEncodingToEncoding(encoding);
- CFStringRef cfencstr = CFStringConvertEncodingToIANACharSetName(cfenc);
- const char *enc = CFStringGetCStringPtr(cfencstr, 0);
- theDoc = htmlReadMemory([inData bytes], [inData length], NULL, enc, HTML_PARSE_NONET | HTML_PARSE_NOBLANKS | HTML_PARSE_NOWARNING);
- }
-
- if (theDoc != NULL)
- {
- _node = (xmlNodePtr)theDoc;
- _node->_private = self; // Note. NOT retained (TODO think more about _private usage)
- }
- else
- {
- theError = [NSError errorWithDomain:@"CXMLErrorDomain" code:-1 userInfo:NULL];
- }
- }
-
- if (outError)
- *outError = theError;
-
- if (theError != NULL)
- {
- [self release];
- self = NULL;
- }
- }
- return(self);
-}
+ {
+ #pragma unused (inOptions)
+ if ((self = [super init]) != NULL)
+ {
+ NSError *theError = NULL;
+ if (theError == NULL)
+ {
+ xmlDocPtr theDoc = NULL;
+ if (inData && inData.length > 0)
+ {
+ CFStringEncoding cfenc = CFStringConvertNSStringEncodingToEncoding(encoding);
+ CFStringRef cfencstr = CFStringConvertEncodingToIANACharSetName(cfenc);
+ const char *enc = CFStringGetCStringPtr(cfencstr, 0);
+ theDoc = htmlReadMemory([inData bytes], [inData length], NULL, enc, HTML_PARSE_NONET | HTML_PARSE_NOBLANKS | HTML_PARSE_NOWARNING);
+ }
+ if (theDoc != NULL)
+ {
+ _node = (xmlNodePtr)theDoc;
+ _node->_private = self; // Note. NOT retained (TODO think more about _private usage)
+ }
+ else
+ {
+ theError = [NSError errorWithDomain:@"CXMLErrorDomain" code:-1 userInfo:NULL];
+ }
+ }
+
+ if (outError)
+ {
+ *outError = theError;
+ }
+
+ if (theError != NULL)
+ {
+ [self release];
+ self = NULL;
+ }
+ }
+ return(self);
+ }
@end
View
351 Source/CXMLDocument.m
@@ -41,160 +41,160 @@
@implementation CXMLDocument
- (id)initWithXMLString:(NSString *)inString options:(NSUInteger)inOptions error:(NSError **)outError
-{
-#pragma unused (inOptions)
-if ((self = [super init]) != NULL)
- {
- NSError *theError = NULL;
-
- #if TOUCHXMLUSETIDY
- if (inOptions & CXMLDocumentTidyHTML)
- {
- inString = [[CTidy tidy] tidyString:inString inputFormat:TidyFormat_HTML outputFormat:TidyFormat_XHTML diagnostics:NULL error:&theError];
- }
- else if (inOptions & CXMLDocumentTidyXML)
- {
- inString = [[CTidy tidy] tidyString:inString inputFormat:TidyFormat_XML outputFormat:TidyFormat_XML diagnostics:NULL error:&theError];
- }
- #endif
-
- xmlDocPtr theDoc = xmlParseDoc((xmlChar *)[inString UTF8String]);
- if (theDoc != NULL)
- {
- _node = (xmlNodePtr)theDoc;
- NSAssert(_node->_private == NULL, @"TODO");
- _node->_private = self; // Note. NOT retained (TODO think more about _private usage)
- }
- else
- {
- xmlErrorPtr theLastErrorPtr = xmlGetLastError();
-
- NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSString stringWithUTF8String:theLastErrorPtr->message], NSLocalizedDescriptionKey,
- NULL];
-
-
- theError = [NSError errorWithDomain:@"CXMLErrorDomain" code:1 userInfo:theUserInfo];
-
- xmlResetLastError();
- }
-
- if (outError)
- *outError = theError;
-
- if (theError != NULL)
- {
- [self release];
- self = NULL;
- }
- }
-return(self);
-}
+ {
+ #pragma unused (inOptions)
+
+ if ((self = [super init]) != NULL)
+ {
+ NSError *theError = NULL;
+
+ #if TOUCHXMLUSETIDY
+ if (inOptions & CXMLDocumentTidyHTML)
+ {
+ inString = [[CTidy tidy] tidyString:inString inputFormat:TidyFormat_HTML outputFormat:TidyFormat_XHTML diagnostics:NULL error:&theError];
+ }
+ else if (inOptions & CXMLDocumentTidyXML)
+ {
+ inString = [[CTidy tidy] tidyString:inString inputFormat:TidyFormat_XML outputFormat:TidyFormat_XML diagnostics:NULL error:&theError];
+ }
+ #endif
+
+ xmlDocPtr theDoc = xmlParseDoc((xmlChar *)[inString UTF8String]);
+ if (theDoc != NULL)
+ {
+ _node = (xmlNodePtr)theDoc;
+ NSAssert(_node->_private == NULL, @"TODO");
+ _node->_private = self; // Note. NOT retained (TODO think more about _private usage)
+ }
+ else
+ {
+ xmlErrorPtr theLastErrorPtr = xmlGetLastError();
+
+ NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSString stringWithUTF8String:theLastErrorPtr->message], NSLocalizedDescriptionKey,
+ NULL];
+
+
+ theError = [NSError errorWithDomain:@"CXMLErrorDomain" code:1 userInfo:theUserInfo];
+
+ xmlResetLastError();
+ }
+
+ if (outError)
+ *outError = theError;
+
+ if (theError != NULL)
+ {
+ [self release];
+ self = NULL;
+ }
+ }
+ return(self);
+ }
- (id)initWithData:(NSData *)inData options:(NSUInteger)inOptions error:(NSError **)outError
-{
+ {
return [self initWithData:inData encoding:NSUTF8StringEncoding options:inOptions error:outError];
-}
+ }
- (id)initWithData:(NSData *)inData encoding:(NSStringEncoding)encoding options:(NSUInteger)inOptions error:(NSError **)outError
-{
-#pragma unused (inOptions)
-if ((self = [super init]) != NULL)
- {
- NSError *theError = NULL;
-
- #if TOUCHXMLUSETIDY
- if (inOptions & CXMLDocumentTidyHTML)
- {
- inData = [[CTidy tidy] tidyData:inData inputFormat:TidyFormat_HTML outputFormat:TidyFormat_XHTML diagnostics:NULL error:&theError];
- }
- else if (inOptions & CXMLDocumentTidyXML)
- {
- inData = [[CTidy tidy] tidyData:inData inputFormat:TidyFormat_XML outputFormat:TidyFormat_XML diagnostics:NULL error:&theError];
- }
- #endif
-
- if (theError == NULL)
- {
- xmlDocPtr theDoc = NULL;
- if (inData && inData.length > 0)
- {
- CFStringEncoding cfenc = CFStringConvertNSStringEncodingToEncoding(encoding);
- CFStringRef cfencstr = CFStringConvertEncodingToIANACharSetName(cfenc);
- const char *enc = CFStringGetCStringPtr(cfencstr, 0);
- theDoc = xmlReadMemory([inData bytes], [inData length], NULL, enc, XML_PARSE_RECOVER | XML_PARSE_NOWARNING);
- }
-
- if (theDoc != NULL && xmlDocGetRootElement(theDoc) != NULL)
- {
- _node = (xmlNodePtr)theDoc;
- _node->_private = self; // Note. NOT retained (TODO think more about _private usage)
- }
- else
- {
- xmlErrorPtr theLastErrorPtr = xmlGetLastError();
- NSString* message = [NSString stringWithUTF8String:
- (theLastErrorPtr ? theLastErrorPtr->message : "Unknown error")];
- NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys:
- message, NSLocalizedDescriptionKey, NULL];
- theError = [NSError errorWithDomain:@"CXMLErrorDomain" code:1 userInfo:theUserInfo];
-
- xmlResetLastError();
- }
- }
-
- if (outError)
- *outError = theError;
-
- if (theError != NULL)
- {
- [self release];
- self = NULL;
- }
- }
-return(self);
-}
+ {
+ #pragma unused (inOptions)
+ if ((self = [super init]) != NULL)
+ {
+ NSError *theError = NULL;
+
+ #if TOUCHXMLUSETIDY
+ if (inOptions & CXMLDocumentTidyHTML)
+ {
+ inData = [[CTidy tidy] tidyData:inData inputFormat:TidyFormat_HTML outputFormat:TidyFormat_XHTML diagnostics:NULL error:&theError];
+ }
+ else if (inOptions & CXMLDocumentTidyXML)
+ {
+ inData = [[CTidy tidy] tidyData:inData inputFormat:TidyFormat_XML outputFormat:TidyFormat_XML diagnostics:NULL error:&theError];
+ }
+ #endif
+
+ if (theError == NULL)
+ {
+ xmlDocPtr theDoc = NULL;
+ if (inData && inData.length > 0)
+ {
+ CFStringEncoding cfenc = CFStringConvertNSStringEncodingToEncoding(encoding);
+ CFStringRef cfencstr = CFStringConvertEncodingToIANACharSetName(cfenc);
+ const char *enc = CFStringGetCStringPtr(cfencstr, 0);
+ theDoc = xmlReadMemory([inData bytes], [inData length], NULL, enc, XML_PARSE_RECOVER | XML_PARSE_NOWARNING);
+ }
+
+ if (theDoc != NULL && xmlDocGetRootElement(theDoc) != NULL)
+ {
+ _node = (xmlNodePtr)theDoc;
+ _node->_private = self; // Note. NOT retained (TODO think more about _private usage)
+ }
+ else
+ {
+ xmlErrorPtr theLastErrorPtr = xmlGetLastError();
+ NSString* message = [NSString stringWithUTF8String:
+ (theLastErrorPtr ? theLastErrorPtr->message : "Unknown error")];
+ NSDictionary *theUserInfo = [NSDictionary dictionaryWithObjectsAndKeys:
+ message, NSLocalizedDescriptionKey, NULL];
+ theError = [NSError errorWithDomain:@"CXMLErrorDomain" code:1 userInfo:theUserInfo];
+
+ xmlResetLastError();
+ }
+ }
+
+ if (outError)
+ *outError = theError;
+
+ if (theError != NULL)
+ {
+ [self release];
+ self = NULL;
+ }
+ }
+ return(self);
+ }
- (id)initWithContentsOfURL:(NSURL *)inURL options:(NSUInteger)inOptions error:(NSError **)outError
-{
+ {
return [self initWithContentsOfURL:inURL encoding:NSUTF8StringEncoding options:inOptions error:outError];
-}
+ }
- (id)initWithContentsOfURL:(NSURL *)inURL encoding:(NSStringEncoding)encoding options:(NSUInteger)inOptions error:(NSError **)outError
-{
-if (outError)
- *outError = NULL;
-
-NSData *theData = [NSData dataWithContentsOfURL:inURL options:NSUncachedRead error:outError];
-if (theData)
- {
- self = [self initWithData:theData encoding:encoding options:inOptions error:outError];
- }
-else
- {
- self = NULL;
- }
-
-return(self);
-}
-
+ {
+ if (outError)
+ *outError = NULL;
+
+ NSData *theData = [NSData dataWithContentsOfURL:inURL options:NSUncachedRead error:outError];
+ if (theData)
+ {
+ self = [self initWithData:theData encoding:encoding options:inOptions error:outError];
+ }
+ else
+ {
+ self = NULL;
+ }
+
+ return(self);
+ }
- (void)dealloc
-{
-// Fix for #35 http://code.google.com/p/touchcode/issues/detail?id=35 -- clear up the node objects first (inside a pool so I _know_ they're cleared) and then freeing the document
+ {
+ // Fix for #35 http://code.google.com/p/touchcode/issues/detail?id=35 -- clear up the node objects first (inside a pool so I _know_ they're cleared) and then freeing the document
-NSAutoreleasePool *thePool = [[NSAutoreleasePool alloc] init];
+ NSAutoreleasePool *thePool = [[NSAutoreleasePool alloc] init];
-[nodePool release];
-nodePool = NULL;
+ [nodePool release];
+ nodePool = NULL;
-[thePool release];
-//
-xmlFreeDoc((xmlDocPtr)_node);
-_node = NULL;
-//
-[super dealloc];
-}
+ [thePool release];
+ //
+ xmlFreeDoc((xmlDocPtr)_node);
+ _node = NULL;
+ //
+ [super dealloc];
+ }
//- (NSString *)characterEncoding;
//- (NSString *)version;
@@ -204,56 +204,55 @@ - (void)dealloc
//- (CXMLDTD *)DTD;
- (CXMLElement *)rootElement
-{
-xmlNodePtr theLibXMLNode = xmlDocGetRootElement((xmlDocPtr)_node);
-
-return([CXMLNode nodeWithLibXMLNode:theLibXMLNode freeOnDealloc:NO]);
-}
+ {
+ xmlNodePtr theLibXMLNode = xmlDocGetRootElement((xmlDocPtr)_node);
+ return([CXMLNode nodeWithLibXMLNode:theLibXMLNode freeOnDealloc:NO]);
+ }
- (NSData *)XMLData
-{
-return([self XMLDataWithOptions:0]);
-}
+ {
+ return([self XMLDataWithOptions:0]);
+ }
- (NSData *)XMLDataWithOptions:(NSUInteger)options
-{
-#pragma unused (options)
-xmlChar *theBuffer = NULL;
-int theBufferSize = 0;
-xmlDocDumpMemory((xmlDocPtr)self->_node, &theBuffer, &theBufferSize);
+ {
+ #pragma unused (options)
+ xmlChar *theBuffer = NULL;
+ int theBufferSize = 0;
+ xmlDocDumpMemory((xmlDocPtr)self->_node, &theBuffer, &theBufferSize);
-NSData *theData = [NSData dataWithBytes:theBuffer length:theBufferSize];
+ NSData *theData = [NSData dataWithBytes:theBuffer length:theBufferSize];
-xmlFree(theBuffer);
+ xmlFree(theBuffer);
-return(theData);
-}
+ return(theData);
+ }
//- (id)objectByApplyingXSLT:(NSData *)xslt arguments:(NSDictionary *)arguments error:(NSError **)error;
//- (id)objectByApplyingXSLTString:(NSString *)xslt arguments:(NSDictionary *)arguments error:(NSError **)error;
//- (id)objectByApplyingXSLTAtURL:(NSURL *)xsltURL arguments:(NSDictionary *)argument error:(NSError **)error;
- (id)XMLStringWithOptions:(NSUInteger)options
-{
-CXMLElement *theRoot = [self rootElement];
-NSMutableString *xmlString = [NSMutableString string];
-[xmlString appendString:[theRoot XMLStringWithOptions:options]];
-return xmlString;
-}
+ {
+ CXMLElement *theRoot = [self rootElement];
+ NSMutableString *xmlString = [NSMutableString string];
+ [xmlString appendString:[theRoot XMLStringWithOptions:options]];
+ return xmlString;
+ }
- (NSString *)description
-{
-NSAssert(_node != NULL, @"TODO");
-
-NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p [%p]> ", NSStringFromClass([self class]), self, self->_node];
-xmlChar *xmlbuff;
-int buffersize;
-
-xmlDocDumpFormatMemory((xmlDocPtr)(self->_node), &xmlbuff, &buffersize, 1);
-NSString *dump = [[[NSString alloc] initWithBytes:xmlbuff length:buffersize encoding:NSUTF8StringEncoding] autorelease];
-xmlFree(xmlbuff);
-
-[result appendString:dump];
-return result;
-}
+ {
+ NSAssert(_node != NULL, @"TODO");
+
+ NSMutableString *result = [NSMutableString stringWithFormat:@"<%@ %p [%p]> ", NSStringFromClass([self class]), self, self->_node];
+ xmlChar *xmlbuff;
+ int buffersize;
+
+ xmlDocDumpFormatMemory((xmlDocPtr)(self->_node), &xmlbuff, &buffersize, 1);
+ NSString *dump = [[[NSString alloc] initWithBytes:xmlbuff length:buffersize encoding:NSUTF8StringEncoding] autorelease];
+ xmlFree(xmlbuff);
+
+ [result appendString:dump];
+ return result;
+ }
@end
View
15 Source/CXMLDocument_PrivateExtensions.m
@@ -41,13 +41,12 @@ - (id)initWithLibXmlParserContext:(xmlParserCtxtPtr)inContext options:(NSUIntege
*/
- (NSMutableSet *)nodePool
-{
-if (nodePool == NULL)
- {
- nodePool = [[NSMutableSet alloc] init];
- }
-return(nodePool);
-}
-
+ {
+ if (nodePool == NULL)
+ {
+ nodePool = [[NSMutableSet alloc] init];
+ }
+ return(nodePool);
+ }
@end
View
130 Source/CXMLElement.m
@@ -36,66 +36,68 @@
@implementation CXMLElement
- (NSArray *)elementsForName:(NSString *)name
-{
-NSMutableArray *theElements = [NSMutableArray array];
+ {
+ NSMutableArray *theElements = [NSMutableArray array];
-// TODO -- native xml api?
-const xmlChar *theName = (const xmlChar *)[name UTF8String];
+ // TODO -- native xml api?
+ const xmlChar *theName = (const xmlChar *)[name UTF8String];
-xmlNodePtr theCurrentNode = _node->children;
-while (theCurrentNode != NULL)
- {
- if (theCurrentNode->type == XML_ELEMENT_NODE && xmlStrcmp(theName, theCurrentNode->name) == 0)
- {
- CXMLNode *theNode = [CXMLNode nodeWithLibXMLNode:(xmlNodePtr)theCurrentNode freeOnDealloc:NO];
- [theElements addObject:theNode];
- }
- theCurrentNode = theCurrentNode->next;
- }
-return(theElements);
-}
+ xmlNodePtr theCurrentNode = _node->children;
+ while (theCurrentNode != NULL)
+ {
+ if (theCurrentNode->type == XML_ELEMENT_NODE && xmlStrcmp(theName, theCurrentNode->name) == 0)
+ {
+ CXMLNode *theNode = [CXMLNode nodeWithLibXMLNode:(xmlNodePtr)theCurrentNode freeOnDealloc:NO];
+ [theElements addObject:theNode];
+ }
+ theCurrentNode = theCurrentNode->next;
+ }
+ return(theElements);
+ }
- (NSArray *)elementsForLocalName:(NSString *)localName URI:(NSString *)URI
-{
+ {
if (URI == nil || [URI length] == 0)
+ {
return [self elementsForName:localName];
+ }
NSMutableArray *theElements = [NSMutableArray array];
const xmlChar *theLocalName = (const xmlChar *)[localName UTF8String];
const xmlChar *theNamespaceName = (const xmlChar *)[URI UTF8String];
xmlNodePtr theCurrentNode = _node->children;
while (theCurrentNode != NULL)
- {
+ {
if (theCurrentNode->type == XML_ELEMENT_NODE
&& xmlStrcmp(theLocalName, theCurrentNode->name) == 0
&& theCurrentNode->ns
&& xmlStrcmp(theNamespaceName, theCurrentNode->ns->href) == 0)
- {
+ {
CXMLNode *theNode = [CXMLNode nodeWithLibXMLNode:(xmlNodePtr)theCurrentNode freeOnDealloc:NO];
[theElements addObject:theNode];
- }
+ }
theCurrentNode = theCurrentNode->next;
- }
+ }
return theElements;
-}
+ }
- (NSArray *)attributes
-{
-NSMutableArray *theAttributes = [NSMutableArray array];
-xmlAttrPtr theCurrentNode = _node->properties;
-while (theCurrentNode != NULL)
- {
- CXMLNode *theAttribute = [CXMLNode nodeWithLibXMLNode:(xmlNodePtr)theCurrentNode freeOnDealloc:NO];
- [theAttributes addObject:theAttribute];
- theCurrentNode = theCurrentNode->next;
- }
-return(theAttributes);
-}
+ {
+ NSMutableArray *theAttributes = [NSMutableArray array];
+ xmlAttrPtr theCurrentNode = _node->properties;
+ while (theCurrentNode != NULL)
+ {
+ CXMLNode *theAttribute = [CXMLNode nodeWithLibXMLNode:(xmlNodePtr)theCurrentNode freeOnDealloc:NO];
+ [theAttributes addObject:theAttribute];
+ theCurrentNode = theCurrentNode->next;
+ }
+ return(theAttributes);
+ }
- (CXMLNode *)attributeForName:(NSString *)name
-{
+ {
// TODO -- look for native libxml2 function for finding a named attribute (like xmlGetProp)
NSRange split = [name rangeOfString:@":"];
@@ -104,93 +106,95 @@ - (CXMLNode *)attributeForName:(NSString *)name
xmlChar *thePrefix = NULL;
if (split.length > 0)
- {
+ {
theLocalName = (xmlChar *)[[name substringFromIndex:split.location + 1] UTF8String];
thePrefix = (xmlChar *)[[name substringToIndex:split.location] UTF8String];
- }
+ }
else
- {
+ {
theLocalName = (xmlChar *)[name UTF8String];
- }
+ }
xmlAttrPtr theCurrentNode = _node->properties;
while (theCurrentNode != NULL)
- {
+ {
if (xmlStrcmp(theLocalName, theCurrentNode->name) == 0)
- {
+ {
if (thePrefix == NULL || (theCurrentNode->ns
- && theCurrentNode->ns->prefix
- && xmlStrcmp(thePrefix, theCurrentNode->ns->prefix) == 0))
- {
+ && theCurrentNode->ns->prefix
+ && xmlStrcmp(thePrefix, theCurrentNode->ns->prefix) == 0))
+ {
CXMLNode *theAttribute = [CXMLNode nodeWithLibXMLNode:(xmlNodePtr)theCurrentNode freeOnDealloc:NO];
return(theAttribute);
- }
- }
+ }
+ }
theCurrentNode = theCurrentNode->next;
- }
+ }
return(NULL);
-}
+ }
- (CXMLNode *)attributeForLocalName:(NSString *)localName URI:(NSString *)URI
-{
+ {
if (URI == nil)
+ {
return [self attributeForName:localName];
+ }
// TODO -- look for native libxml2 function for finding a named attribute (like xmlGetProp)
const xmlChar *theLocalName = (const xmlChar *)[localName UTF8String];
const xmlChar *theNamespaceName = (const xmlChar *)[URI UTF8String];
xmlAttrPtr theCurrentNode = _node->properties;
while (theCurrentNode != NULL)
- {
+ {
if (theCurrentNode->ns && theCurrentNode->ns->href &&
xmlStrcmp(theLocalName, theCurrentNode->name) == 0 &&
xmlStrcmp(theNamespaceName, theCurrentNode->ns->href) == 0)
- {
+ {
CXMLNode *theAttribute = [CXMLNode nodeWithLibXMLNode:(xmlNodePtr)theCurrentNode freeOnDealloc:NO];
return(theAttribute);
- }
+ }
theCurrentNode = theCurrentNode->next;
- }
+ }
return(NULL);
-}
+ }
- (NSArray *)namespaces
-{
+ {
NSMutableArray *theNamespaces = [[[NSMutableArray alloc] init] autorelease];
xmlNsPtr theCurrentNamespace = _node->nsDef;
while (theCurrentNamespace != NULL)
- {
+ {
NSString *thePrefix = theCurrentNamespace->prefix ? [NSString stringWithUTF8String:(const char *)theCurrentNamespace->prefix] : @"";
NSString *theURI = [NSString stringWithUTF8String:(const char *)theCurrentNamespace->href];
CXMLNamespaceNode *theNode = [[CXMLNamespaceNode alloc] initWithPrefix:thePrefix URI:theURI parentElement:self];
[theNamespaces addObject:theNode];
[theNode release];
theCurrentNamespace = theCurrentNamespace->next;
- }
+ }
return theNamespaces;
-}
+ }
- (CXMLNode *)namespaceForPrefix:(NSString *)name
-{
+ {
const xmlChar *thePrefix = (const xmlChar *)[name UTF8String];
xmlNsPtr theCurrentNamespace = _node->nsDef;
while (theCurrentNamespace != NULL)
- {
+ {
if (xmlStrcmp(theCurrentNamespace->prefix, thePrefix) == 0)
- {
+ {
NSString *thePrefixString = theCurrentNamespace->prefix ? [NSString stringWithUTF8String:(const char *)theCurrentNamespace->prefix] : @"";
NSString *theURI = [NSString stringWithUTF8String:(const char *)theCurrentNamespace->href];
return [[[CXMLNamespaceNode alloc] initWithPrefix:thePrefixString URI:theURI parentElement:self] autorelease];
- }
+ }
theCurrentNamespace = theCurrentNamespace->next;
- }
+ }
return nil;
-}
+ }
- (CXMLNode *)resolveNamespaceForName:(NSString *)name
{
View
24 TouchXML.xcodeproj/project.pbxproj
@@ -534,6 +534,7 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = (
/usr/include/tidy,
/usr/include/libxml2,
@@ -557,6 +558,7 @@
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = (
/usr/include/tidy,
/usr/include/libxml2,
@@ -579,6 +581,7 @@
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h";
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = (
/usr/include/tidy,
/usr/include/libxml2,
@@ -597,7 +600,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ ARCHS = "$(ARCHS_STANDARD_64_BIT)";
"CODE_SIGN_IDENTITY[sdk=aspen*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_GENERATE_TEST_COVERAGE_FILES = YES;
@@ -606,6 +609,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-lgcov";
+ RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = "";
};
name = Coverage;
@@ -624,13 +628,14 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ ARCHS = "$(ARCHS_STANDARD_64_BIT)";
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Foundation.framework/Headers/Foundation.h";
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = (
/usr/include/tidy,
/usr/include/libxml2,
@@ -658,6 +663,7 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Foundation.framework/Headers/Foundation.h";
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = (
/usr/include/tidy,
/usr/include/libxml2,
@@ -677,13 +683,14 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ ARCHS = "$(ARCHS_STANDARD_64_BIT)";
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Foundation.framework/Headers/Foundation.h";
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = (
/usr/include/tidy,
/usr/include/libxml2,
@@ -701,12 +708,13 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ ARCHS = "$(ARCHS_STANDARD_64_BIT)";
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Foundation.framework/Headers/Foundation.h";
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = (
/usr/include/tidy,
/usr/include/libxml2,
@@ -735,6 +743,7 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Foundation.framework/Headers/Foundation.h";
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = (
/usr/include/tidy,
/usr/include/libxml2,
@@ -763,6 +772,7 @@
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Foundation.framework/Headers/Foundation.h";
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = (
/usr/include/tidy,
/usr/include/libxml2,
@@ -803,20 +813,22 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ ARCHS = "$(ARCHS_STANDARD_64_BIT)";
"CODE_SIGN_IDENTITY[sdk=aspen*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH = YES;
+ RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = "";
};
name = Debug;
};
C01FCF5008A954540054247B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+ ARCHS = "$(ARCHS_STANDARD_64_BIT)";
+ RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = "";
};
name = Release;

0 comments on commit 5005e8e

Please sign in to comment.