Index: src/OFXMLAttribute.h ================================================================== --- src/OFXMLAttribute.h +++ src/OFXMLAttribute.h @@ -26,11 +26,13 @@ * * @brief A representation of an attribute of an XML element as an object. */ @interface OFXMLAttribute: OFXMLNode { +#if defined(OF_XML_ELEMENT_M) || defined(OF_XML_PARSER_M) @public +#endif OFString *_name, *_Nullable _namespace, *_stringValue; } /*! * @brief The name of the attribute. Index: src/OFXMLElement.m ================================================================== --- src/OFXMLElement.m +++ src/OFXMLElement.m @@ -15,10 +15,12 @@ * file. */ #include "config.h" +#define OF_XML_ELEMENT_M + #include #include #include @@ -189,11 +191,12 @@ - (instancetype)initWithElement: (OFXMLElement *)element { self = [super of_init]; @try { - if (element == nil) + if (element == nil || + ![element isKindOfClass: [OFXMLElement class]]) @throw [OFInvalidArgumentException exception]; _name = [element->_name copy]; _namespace = [element->_namespace copy]; _defaultNamespace = [element->_defaultNamespace copy]; @@ -758,10 +761,13 @@ return [element autorelease]; } - (void)addAttribute: (OFXMLAttribute *)attribute { + if (![attribute isKindOfClass: [OFXMLAttribute class]]) + @throw [OFInvalidArgumentException exception]; + if (_attributes == nil) _attributes = [[OFMutableArray alloc] init]; if ([self attributeForName: attribute->_name namespace: attribute->_namespace] == nil) Index: src/OFXMLParser.m ================================================================== --- src/OFXMLParser.m +++ src/OFXMLParser.m @@ -14,10 +14,12 @@ * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" + +#define OF_XML_PARSER_M #include #import "OFXMLParser.h" #import "OFString.h"