Permalink
Browse files

Renamed the Comment class to SVGComment due to a conflict with the AI…

…FF header.

Changed some ints to NSIntegers.
Create functions NSStringFromCGRect and NSStringFromCGPoint for OS X.
Have the black color in SVGTextElement be a macro that works on OS X and iOS.
Link to the Quartz framework and livxml
  • Loading branch information...
1 parent 8e05632 commit aaeda1402342b2cee041ceb8138c77a8d94d45ae @MaddTheSane committed May 7, 2013
@@ -189,6 +189,8 @@
5540E81017387F2B004029EF /* SVGUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 5540E74F17387F2B004029EF /* SVGUtils.m */; };
5540E81117387F4A004029EF /* NSCharacterSet+SVGKExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 5540E74217387F2B004029EF /* NSCharacterSet+SVGKExtensions.m */; };
5540E814173881BF004029EF /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 5540E816173881BF004029EF /* InfoPlist.strings */; };
+ 5540E818173887BF004029EF /* Quartz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5540E817173887BE004029EF /* Quartz.framework */; };
+ 5540E819173887D9004029EF /* SVGTextElement.m in Sources */ = {isa = PBXBuildFile; fileRef = 5540E71717387F2B004029EF /* SVGTextElement.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -207,8 +209,8 @@
5540E68C17387F2A004029EF /* CDATASection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDATASection.m; sourceTree = "<group>"; };
5540E68D17387F2A004029EF /* CharacterData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CharacterData.h; sourceTree = "<group>"; };
5540E68E17387F2A004029EF /* CharacterData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CharacterData.m; sourceTree = "<group>"; };
- 5540E68F17387F2A004029EF /* Comment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Comment.h; sourceTree = "<group>"; };
- 5540E69017387F2A004029EF /* Comment.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Comment.m; sourceTree = "<group>"; };
+ 5540E68F17387F2A004029EF /* Comment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = Comment.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
+ 5540E69017387F2A004029EF /* Comment.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = Comment.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
5540E69117387F2A004029EF /* CSSPrimitiveValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSPrimitiveValue.h; sourceTree = "<group>"; };
5540E69217387F2A004029EF /* CSSPrimitiveValue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSSPrimitiveValue.m; sourceTree = "<group>"; };
5540E69317387F2A004029EF /* CSSPrimitiveValue_ConfigurablePixelsPerInch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSPrimitiveValue_ConfigurablePixelsPerInch.h; sourceTree = "<group>"; };
@@ -229,8 +231,8 @@
5540E6A217387F2B004029EF /* CSSValueList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSValueList.h; sourceTree = "<group>"; };
5540E6A317387F2B004029EF /* CSSValueList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSSValueList.m; sourceTree = "<group>"; };
5540E6A417387F2B004029EF /* Document+Mutable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Document+Mutable.h"; sourceTree = "<group>"; };
- 5540E6A517387F2B004029EF /* Document.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Document.h; sourceTree = "<group>"; };
- 5540E6A617387F2B004029EF /* Document.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Document.m; sourceTree = "<group>"; };
+ 5540E6A517387F2B004029EF /* Document.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = Document.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
+ 5540E6A617387F2B004029EF /* Document.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = Document.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
5540E6A717387F2B004029EF /* DocumentCSS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentCSS.h; sourceTree = "<group>"; };
5540E6A817387F2B004029EF /* DocumentFragment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentFragment.h; sourceTree = "<group>"; };
5540E6A917387F2B004029EF /* DocumentFragment.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DocumentFragment.m; sourceTree = "<group>"; };
@@ -393,13 +395,15 @@
5540E74E17387F2B004029EF /* SVGUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGUtils.h; sourceTree = "<group>"; };
5540E74F17387F2B004029EF /* SVGUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVGUtils.m; sourceTree = "<group>"; };
5540E815173881BF004029EF /* en */ = {isa = PBXFileReference; lastKnownFileType = file; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+ 5540E817173887BE004029EF /* Quartz.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quartz.framework; path = System/Library/Frameworks/Quartz.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
5540E66817387C9F004029EF /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ 5540E818173887BF004029EF /* Quartz.framework in Frameworks */,
5540E67017387C9F004029EF /* Cocoa.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -427,6 +431,7 @@
5540E66E17387C9F004029EF /* Frameworks */ = {
isa = PBXGroup;
children = (
+ 5540E817173887BE004029EF /* Quartz.framework */,
5540E66F17387C9F004029EF /* Cocoa.framework */,
5540E67117387C9F004029EF /* Other Frameworks */,
);
@@ -1002,6 +1007,7 @@
5540E80E17387F2B004029EF /* SVGKPattern.m in Sources */,
5540E81017387F2B004029EF /* SVGUtils.m in Sources */,
5540E81117387F4A004029EF /* NSCharacterSet+SVGKExtensions.m in Sources */,
+ 5540E819173887D9004029EF /* SVGTextElement.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1088,6 +1094,7 @@
GCC_PREFIX_HEADER = "XCodeProjectData/SVGKit-OSX/SVGKit-Prefix.pch";
HEADER_SEARCH_PATHS = "${SDK_DIR}/usr/include/libxml2";
INFOPLIST_FILE = "XCodeProjectData/SVGKit-OSX/SVGKit-Info.plist";
+ OTHER_LDFLAGS = "-lxml2";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = framework;
};
@@ -1104,6 +1111,7 @@
GCC_PREFIX_HEADER = "XCodeProjectData/SVGKit-OSX/SVGKit-Prefix.pch";
HEADER_SEARCH_PATHS = "${SDK_DIR}/usr/include/libxml2";
INFOPLIST_FILE = "XCodeProjectData/SVGKit-OSX/SVGKit-Info.plist";
+ OTHER_LDFLAGS = "-lxml2";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = framework;
};
@@ -3,15 +3,15 @@
http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1728279322
- interface Comment : CharacterData {
+ interface SVGComment : CharacterData {
};
*/
#import <Foundation/Foundation.h>
#import "CharacterData.h"
-@interface Comment : CharacterData
+@interface SVGComment : CharacterData
- (id)initWithValue:(NSString*) v;
@@ -8,7 +8,7 @@
#import "Comment.h"
-@implementation Comment
@adamgit

adamgit May 10, 2013

Comment has to be called Comment according to the DOM Spec

I feel your pain (C's lack of package-names is ... ugh), but ... If you're going to change it, you almost SHOULD NOT change it to "SVGComment", because "SVG..." is reserved by the SVG Spec (different from DOM spec!)

I'd suggest renaming to "DOMComment" - it's very unlikely another library would try to use something preceded by "DOM".

Alternatively ... if you know a way we can namespace the entire package, without changing the source-file names, we could do that to the main SVGKit project (it would be great if we could avoid this problem in future)

@MaddTheSane

MaddTheSane May 12, 2013

Owner

Truth be told, I'm a little leery of all those Objective-C classes without a prefix header. I did change it back, and I've got a preprocessor hack for the SVGKit framework, but anything including SVGKit's headers still runs into this problem (note my imageRep branch).

+@implementation SVGComment
- (id)initWithValue:(NSString*) v
{
@@ -58,7 +58,7 @@
#import "Node.h"
@class Element;
#import "Element.h"
-@class Comment;
+@class SVGComment;
#import "Comment.h"
@class CDATASection;
#import "CDATASection.h"
@@ -85,7 +85,7 @@
-(Element*) createElement:(NSString*) tagName __attribute__((ns_returns_retained));
-(DocumentFragment*) createDocumentFragment __attribute__((ns_returns_retained));
-(Text*) createTextNode:(NSString*) data __attribute__((ns_returns_retained));
--(Comment*) createComment:(NSString*) data __attribute__((ns_returns_retained));
+-(SVGComment*) createComment:(NSString*) data __attribute__((ns_returns_retained));
-(CDATASection*) createCDATASection:(NSString*) data __attribute__((ns_returns_retained));
-(ProcessingInstruction*) createProcessingInstruction:(NSString*) target data:(NSString*) data __attribute__((ns_returns_retained));
-(Attr*) createAttribute:(NSString*) data __attribute__((ns_returns_retained));
@@ -38,9 +38,9 @@ -(Text*) createTextNode:(NSString*) data
return [[Text alloc] initWithValue:data];
}
--(Comment*) createComment:(NSString*) data
+-(SVGComment*) createComment:(NSString*) data
{
- return [[Comment alloc] initWithValue:data];
+ return [[SVGComment alloc] initWithValue:data];
}
-(CDATASection*) createCDATASection:(NSString*) data
@@ -86,7 +86,7 @@ -(Node*) removeNamedItem:(NSString*) name
-(unsigned long)length
{
- int count = [self.internalDictionary count];
+ NSUInteger count = [self.internalDictionary count];
for( NSDictionary* namespaceDict in self.internalDictionaryOfNamespaces )
{
@@ -209,7 +209,7 @@ -(Node*) replaceChild:(Node*) newChild oldChild:(Node*) oldChild
"If newChild is a DocumentFragment object, oldChild is replaced by all of the DocumentFragment children, which are inserted in the same order. If the newChild is already in the tree, it is first removed."
*/
- int oldIndex = [self.childNodes.internalArray indexOfObject:oldChild];
+ NSInteger oldIndex = [self.childNodes.internalArray indexOfObject:oldChild];
NSAssert( FALSE, @"We should be recursing down the tree to find 'newChild' at any location, and removing it - required by spec - but we have no convenience method for that search, yet" );
@@ -65,7 +65,7 @@ -(SVGElementInstance *)previousSibling
return nil;
else
{
- int indexInParent = [self.parentNode.childNodes.internalArray indexOfObject:self];
+ NSInteger indexInParent = [self.parentNode.childNodes.internalArray indexOfObject:self];
if( indexInParent < 1 )
return nil;
@@ -80,7 +80,7 @@ -(SVGElementInstance *)nextSibling
return nil;
else
{
- int indexInParent = [self.parentNode.childNodes.internalArray indexOfObject:self];
+ NSInteger indexInParent = [self.parentNode.childNodes.internalArray indexOfObject:self];
if( indexInParent >= [self.parentNode.childNodes length] )
return nil;
@@ -8,6 +8,15 @@
#import "SVGTransformable.h"
#import "SVGSVGElement.h"
+#if !TARGET_OS_IPHONE
+
+static inline NSString *NSStringFromCGRect(CGRect theRect)
+{
+ return NSStringFromRect(NSRectFromCGRect(theRect));
+}
+
+#endif
+
@implementation SVGHelperUtilities
@@ -6,6 +6,15 @@
#import "SVGGElement.h"
+#if !TARGET_OS_IPHONE
+
+static inline NSString *NSStringFromCGPoint(CGPoint thepoint)
+{
+ return NSStringFromPoint(NSPointFromCGPoint(thepoint));
+}
+
+#endif
+
@implementation SVGGradientElement
@synthesize stops = _stops;
@@ -45,7 +45,7 @@ - (void)parseData:(NSString *)data
if (command.length > 1) {
// Take only one char (it can happen that multiple commands are consecutive, as "ZM" - so we only want to get the "Z")
- const int tooManyChars = command.length-1;
+ const NSInteger tooManyChars = command.length-1;
command = [command substringToIndex:1];
[dataScanner setScanLocation:([dataScanner scanLocation] - tooManyChars)];
}
@@ -4,6 +4,13 @@
#if TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
+
+#define CGBLACKCOLOR [UIColor blackColor].CGColor
+
+#else
+
+#define CGBLACKCOLOR CGColorGetConstantColor(kCGColorBlack)
+
#endif
#import "SVGElement_ForParser.h" // to resolve Xcode circular dependencies; in long term, parsing SHOULD NOT HAPPEN inside any class whose name starts "SVG" (because those are reserved classes for the SVG Spec)
@@ -135,7 +142,7 @@ - (CALayer *) newLayer
label.fontSize = effectiveFontSize;
label.string = effectiveText;
label.alignmentMode = kCAAlignmentLeft;
- label.foregroundColor = [UIColor blackColor].CGColor;
+ label.foregroundColor = CGBLACKCOLOR;
/** VERY USEFUL when trying to debug text issues:
label.backgroundColor = [UIColor colorWithRed:0.5 green:0 blue:0 alpha:0.5].CGColor;
@@ -142,9 +142,9 @@ - (void) addParserExtension:(NSObject<SVGKParserExtension>*) extension
}
static FILE *desc;
-static int
+static size_t
readPacket(char *mem, int size) {
- int res;
+ size_t res;
res = fread(mem, 1, size, desc);
return(res);
@@ -667,7 +667,7 @@ static void structuredError (void * userData,
for (int i = 0; i < attr_ct * 5; i += 5) {
const char *begin = (const char *) attrs[i + 3];
const char *end = (const char *) attrs[i + 4];
- int vlen = strlen(begin) - strlen(end);
+ long vlen = strlen(begin) - strlen(end);
char val[vlen + 1];
strncpy(val, begin, vlen);

0 comments on commit aaeda14

Please sign in to comment.