Index: src/OFXMLParser.h ================================================================== --- src/OFXMLParser.h +++ src/OFXMLParser.h @@ -22,23 +22,10 @@ @class OFArray; @class OFMutableArray; @class OFDataArray; @class OFStream; -#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS) -typedef void (^of_xml_parser_processing_instructions_block_t)( - OFXMLParser *parser, OFString *pi); -typedef void (^of_xml_parser_element_start_block_t)(OFXMLParser *parser, - OFString *name, OFString *prefix, OFString *ns, OFArray *attributes); -typedef void (^of_xml_parser_element_end_block_t)(OFXMLParser *parser, - OFString *name, OFString *prefix, OFString *ns); -typedef void (^of_xml_parser_string_block_t)(OFXMLParser *parser, - OFString *string); -typedef OFString* (^of_xml_parser_unknown_entity_block_t)(OFXMLParser *parser, - OFString *entity); -#endif - /** * \brief A protocol that needs to be implemented by delegates for OFXMLParser. */ #ifndef OF_XML_PARSER_M @protocol OFXMLParserDelegate @@ -168,20 +155,10 @@ OFMutableArray *attributes; OFString *attributeName; OFString *attributePrefix; char delimiter; OFMutableArray *previous; -#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS) - of_xml_parser_processing_instructions_block_t - processingInstructionsHandler; - of_xml_parser_element_start_block_t elementStartHandler; - of_xml_parser_element_end_block_t elementEndHandler; - of_xml_parser_string_block_t charactersHandler; - of_xml_parser_string_block_t CDATAHandler; - of_xml_parser_string_block_t commentHandler; - of_xml_parser_unknown_entity_block_t unknownEntityHandler; -#endif size_t level; BOOL acceptProlog; size_t lineNumber; BOOL lastCarriageReturn; BOOL finishedParsing; @@ -188,20 +165,10 @@ of_string_encoding_t encoding; } #ifdef OF_HAVE_PROPERTIES @property (retain) id delegate; -# ifdef OF_HAVE_BLOCKS -@property (retain) of_xml_parser_processing_instructions_block_t - processingInstructionsHandler; -@property (retain) of_xml_parser_element_start_block_t elementStartHandler; -@property (retain) of_xml_parser_element_end_block_t elementEndHandler; -@property (retain) of_xml_parser_string_block_t charactersHandler; -@property (retain) of_xml_parser_string_block_t CDATAHandler; -@property (retain) of_xml_parser_string_block_t commentHandler; -@property (retain) of_xml_parser_unknown_entity_block_t unknownEntityHandler; -# endif #endif /** * \return A new, autoreleased OFXMLParser */ @@ -217,97 +184,10 @@ * * \param delegate The delegate to use */ - (void)setDelegate: (id )delegate; -#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS) -/** - * \return The processing instructions handler - */ -- (of_xml_parser_processing_instructions_block_t)processingInstructionsHandler; - -/** - * Sets the processing instructions handler. - * - * \param block A processing instructions handler - */ -- (void)setProcessingInstructionsHandler: - (of_xml_parser_processing_instructions_block_t)block; - -/** - * \return The element start handler - */ -- (of_xml_parser_element_start_block_t)elementStartHandler; - -/** - * Sets the element start handler. - * - * \param block An element start handler - */ -- (void)setElementStartHandler: (of_xml_parser_element_start_block_t)block; - -/** - * \return The element end handler - */ -- (of_xml_parser_element_end_block_t)elementEndHandler; - -/** - * Sets the element end handler. - * - * \param block An element end handler - */ -- (void)setElementEndHandler: (of_xml_parser_element_end_block_t)block; - -/** - * \return The characters handler - */ -- (of_xml_parser_string_block_t)charactersHandler; - -/** - * Sets the characters handler. - * - * \param block A characters handler - */ -- (void)setCharactersHandler: (of_xml_parser_string_block_t)block; - -/** - * \return The CDATA handler - */ -- (of_xml_parser_string_block_t)CDATAHandler; - -/** - * Sets the CDATA handler. - * - * \param block A CDATA handler - */ -- (void)setCDATAHandler: (of_xml_parser_string_block_t)block; - -/** - * \return The comment handler - */ -- (of_xml_parser_string_block_t)commentHandler; - -/** - * Sets the comment handler. - * - * \param block A comment handler - */ -- (void)setCommentHandler: (of_xml_parser_string_block_t)block; - -/** - * \return The unknown entity handler - */ -- (of_xml_parser_unknown_entity_block_t)unknownEntityHandler; - -/** - * Sets the unknown entity handler. - * - * \param block An unknown entity handler - */ -- (void)setUnknownEntityHandler: (of_xml_parser_unknown_entity_block_t)block; -#endif - /** * Parses a buffer with the specified size. * * \param buffer The buffer to parse * \param length The length of the buffer Index: src/OFXMLParser.m ================================================================== --- src/OFXMLParser.m +++ src/OFXMLParser.m @@ -126,16 +126,10 @@ [attribute->ns release]; attribute->ns = [attributeNS retain]; } @implementation OFXMLParser -#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS) -@synthesize processingInstructionsHandler, elementStartHandler; -@synthesize elementEndHandler, charactersHandler, CDATAHandler, commentHandler; -@synthesize unknownEntityHandler; -#endif - + (void)initialize { size_t i; const SEL selectors_[] = { @@ -217,18 +211,10 @@ [namespaces release]; [attributes release]; [attributeName release]; [attributePrefix release]; [previous release]; -#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS) - [elementStartHandler release]; - [elementEndHandler release]; - [charactersHandler release]; - [CDATAHandler release]; - [commentHandler release]; - [unknownEntityHandler release]; -#endif [super dealloc]; } - (id )delegate @@ -332,17 +318,12 @@ OFAutoreleasePool *pool; pool = [[OFAutoreleasePool alloc] init]; characters = transform_string(cache, 0, YES, self); -#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS) - if (charactersHandler != NULL) - charactersHandler(self, characters); - else -#endif - [delegate parser: self - foundCharacters: characters]; + [delegate parser: self + foundCharacters: characters]; [pool release]; } [cache removeNItems: [cache count]]; @@ -563,31 +544,21 @@ [OFUnboundNamespaceException newWithClass: isa prefix: prefix]; pool2 = [[OFAutoreleasePool alloc] init]; -#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS) - if (elementStartHandler != NULL) - elementStartHandler(self, name, prefix, ns, nil); - else -#endif - [delegate parser: self - didStartElement: name - withPrefix: prefix - namespace: ns - attributes: nil]; + [delegate parser: self + didStartElement: name + withPrefix: prefix + namespace: ns + attributes: nil]; if (buffer[*i] == '/') { -#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS) - if (elementEndHandler != NULL) - elementEndHandler(self, name, prefix, ns); - else -#endif - [delegate parser: self - didEndElement: name - withPrefix: prefix - namespace: ns]; + [delegate parser: self + didEndElement: name + withPrefix: prefix + namespace: ns]; if ([previous count] == 0) finishedParsing = YES; } else [previous addObject: cacheString]; @@ -664,19 +635,14 @@ ns = namespace_for_prefix(prefix, namespaces); if (prefix != nil && ns == nil) @throw [OFUnboundNamespaceException newWithClass: isa prefix: prefix]; -#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS) - if (elementEndHandler != NULL) - elementEndHandler(self, name, prefix, ns); - else -#endif - [delegate parser: self - didEndElement: name - withPrefix: prefix - namespace: ns]; + [delegate parser: self + didEndElement: name + withPrefix: prefix + namespace: ns]; [pool release]; [namespaces removeLastObject]; [name release]; @@ -727,31 +693,21 @@ resolve_attribute_namespace(attributesCArray[j], namespaces, isa); pool = [[OFAutoreleasePool alloc] init]; -#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS) - if (elementStartHandler != NULL) - elementStartHandler(self, name, prefix, ns, attributes); - else -#endif - [delegate parser: self - didStartElement: name - withPrefix: prefix - namespace: ns - attributes: attributes]; + [delegate parser: self + didStartElement: name + withPrefix: prefix + namespace: ns + attributes: attributes]; if (buffer[*i] == '/') { -#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS) - if (elementEndHandler != NULL) - elementEndHandler(self, name, prefix, ns); - else -#endif - [delegate parser: self - didEndElement: name - withPrefix: prefix - namespace: ns]; + [delegate parser: self + didEndElement: name + withPrefix: prefix + namespace: ns]; if ([previous count] == 0) finishedParsing = YES; [namespaces removeLastObject]; @@ -984,17 +940,12 @@ pool = [[OFAutoreleasePool alloc] init]; cache_append(cache, buffer + *last, encoding, *i - *last); CDATA = transform_string(cache, 2, NO, nil); -#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS) - if (CDATAHandler != NULL) - CDATAHandler(self, CDATA); - else -#endif - [delegate parser: self - foundCDATA: CDATA]; + [delegate parser: self + foundCDATA: CDATA]; [pool release]; [cache removeNItems: [cache count]]; @@ -1043,17 +994,12 @@ pool = [[OFAutoreleasePool alloc] init]; cache_append(cache, buffer + *last, encoding, *i - *last); comment = transform_string(cache, 2, NO, nil); -#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS) - if (commentHandler != NULL) - commentHandler(self, comment); - else -#endif - [delegate parser: self - foundComment: comment]; + [delegate parser: self + foundComment: comment]; [pool release]; [cache removeNItems: [cache count]]; @@ -1096,15 +1042,10 @@ } - (OFString*)string: (OFString*)string containsUnknownEntityNamed: (OFString*)entity { -#if defined(OF_HAVE_PROPERTIES) && defined(OF_HAVE_BLOCKS) - if (unknownEntityHandler != NULL) - return unknownEntityHandler(self, entity); -#endif - return [delegate parser: self foundUnknownEntityNamed: entity]; } @end