From 1db96aaa078fe3e9c347e8a8724911cde88e20f9 Mon Sep 17 00:00:00 2001 From: Horcrux Date: Sun, 22 Jan 2017 19:45:50 +0800 Subject: [PATCH] Fix warnings --- ios/Elements/RNSVGGroup.m | 4 ---- ios/Elements/RNSVGUse.m | 2 +- ios/RNSVGNode.m | 4 ++-- ios/Text/RNSVGText.m | 3 ++- ios/Text/RNSVGTextPath.m | 2 +- ios/Utils/RCTConvert+RNSVG.h | 4 +--- ios/Utils/RCTConvert+RNSVG.m | 4 ++-- ios/Utils/RNSVGPathParser.m | 42 +++++++++++++++++------------------- 8 files changed, 29 insertions(+), 36 deletions(-) diff --git a/ios/Elements/RNSVGGroup.m b/ios/Elements/RNSVGGroup.m index deac7514..b4406df0 100644 --- a/ios/Elements/RNSVGGroup.m +++ b/ios/Elements/RNSVGGroup.m @@ -27,10 +27,6 @@ [node mergeProperties:self]; [node renderTo:context]; - if ([node isKindOfClass: [RNSVGRenderable class]]) { - RNSVGRenderable *renderable = node; - } - return YES; }]; } diff --git a/ios/Elements/RNSVGUse.m b/ios/Elements/RNSVGUse.m index 349fdd53..8a38847c 100644 --- a/ios/Elements/RNSVGUse.m +++ b/ios/Elements/RNSVGUse.m @@ -31,7 +31,7 @@ [template mergeProperties:self]; if ([template class] == [RNSVGSymbol class]) { - RNSVGSymbol *symbol = template; + RNSVGSymbol *symbol = (RNSVGSymbol*)template; [symbol renderSymbolTo:context width:[self relativeOnWidth:self.width] height:[self relativeOnWidth:self.height]]; } else { [template renderTo:context]; diff --git a/ios/RNSVGNode.m b/ios/RNSVGNode.m index 4e2a3ad3..854d5044 100644 --- a/ios/RNSVGNode.m +++ b/ios/RNSVGNode.m @@ -14,7 +14,7 @@ { BOOL _transparent; CGPathRef _cachedClipPath; - UIView *_svgView; + RNSVGSvgView *_svgView; } - (instancetype)init @@ -227,7 +227,7 @@ // abstract } -- (void)traverseSubviews:(BOOL (^)(RNSVGNode *node))block +- (void)traverseSubviews:(BOOL (^)(__kindof RNSVGNode *node))block { for (RNSVGNode *node in self.subviews) { if ([node isKindOfClass:[RNSVGNode class]]) { diff --git a/ios/Text/RNSVGText.m b/ios/Text/RNSVGText.m index 66b7f22f..115cf9ae 100644 --- a/ios/Text/RNSVGText.m +++ b/ios/Text/RNSVGText.m @@ -97,6 +97,7 @@ case kRNSVGTextAnchorEnd: x = -width; break; + default: ; } return CGAffineTransformMakeTranslation(x, 0); @@ -125,7 +126,7 @@ //todo: throw exception here break; } - _textRoot = [_textRoot superview]; + _textRoot = (RNSVGText*)[_textRoot superview]; } } diff --git a/ios/Text/RNSVGTextPath.m b/ios/Text/RNSVGTextPath.m index d3717812..d5bea26f 100644 --- a/ios/Text/RNSVGTextPath.m +++ b/ios/Text/RNSVGTextPath.m @@ -27,7 +27,7 @@ return nil; } - RNSVGPath *path = template; + RNSVGPath *path = (RNSVGPath *)template; CGFloat startOffset = [self relativeOnWidth:self.startOffset]; return [[RNSVGBezierTransformer alloc] initWithBezierCurvesAndStartOffset:[path getBezierCurves] startOffset:startOffset]; diff --git a/ios/Utils/RCTConvert+RNSVG.h b/ios/Utils/RCTConvert+RNSVG.h index 6072e224..a180e720 100644 --- a/ios/Utils/RCTConvert+RNSVG.h +++ b/ios/Utils/RCTConvert+RNSVG.h @@ -21,14 +21,12 @@ @interface RCTConvert (RNSVG) + (RNSVGTextAnchor)RNSVGTextAnchor:(id)json; -+ (RNSVGPathParser *)CGPath:(NSString *)d; -+ (CTTextAlignment)CTTextAlignment:(id)json; + (RNSVGCGFCRule)RNSVGCGFCRule:(id)json; + (RNSVGVBMOS)RNSVGVBMOS:(id)json; + (RNSVGCGFloatArray)RNSVGCGFloatArray:(id)json; + (RNSVGBrush *)RNSVGBrush:(id)json; - ++ (RNSVGPathParser *)CGPath:(NSString *)d; + (CGRect)CGRect:(id)json offset:(NSUInteger)offset; + (CGColorRef)CGColor:(id)json offset:(NSUInteger)offset; + (CGGradientRef)CGGradient:(id)json offset:(NSUInteger)offset; diff --git a/ios/Utils/RCTConvert+RNSVG.m b/ios/Utils/RCTConvert+RNSVG.m index 32afb846..2bc56773 100644 --- a/ios/Utils/RCTConvert+RNSVG.m +++ b/ios/Utils/RCTConvert+RNSVG.m @@ -171,7 +171,8 @@ RCT_ENUM_CONVERTER(RNSVGTextAnchor, (@{ RNSVGCGFloatArray colorsAndOffsets = [self RNSVGCGFloatArray:arr]; size_t stops = colorsAndOffsets.count / 5; CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB(); - + + CGGradientRef gradient = CGGradientCreateWithColorComponents( rgb, colorsAndOffsets.array, @@ -179,7 +180,6 @@ RCT_ENUM_CONVERTER(RNSVGTextAnchor, (@{ stops ); - CGColorSpaceRelease(rgb); free(colorsAndOffsets.array); return (CGGradientRef)CFAutorelease(gradient); diff --git a/ios/Utils/RNSVGPathParser.m b/ios/Utils/RNSVGPathParser.m index 3866ddb8..5479bc5b 100644 --- a/ios/Utils/RNSVGPathParser.m +++ b/ios/Utils/RNSVGPathParser.m @@ -10,7 +10,7 @@ #import #import "math.h" -@implementation RNSVGPathParser : NSObject +@implementation RNSVGPathParser { NSString* _d; NSString* _originD; @@ -32,7 +32,7 @@ if (self = [super init]) { NSRegularExpression* decimalRegularExpression = [[NSRegularExpression alloc] initWithPattern:@"(\\.\\d+)(?=\\-?\\.)" options:0 error:nil]; _originD = d; - _d = [decimalRegularExpression stringByReplacingMatchesInString:d options:0 range:NSMakeRange(0, [d length]) withTemplate:@"$1\,"]; + _d = [decimalRegularExpression stringByReplacingMatchesInString:d options:0 range:NSMakeRange(0, [d length]) withTemplate:@"$1,"]; _pathRegularExpression = [[NSRegularExpression alloc] initWithPattern:@"[a-df-z]|[\\-+]?(?:[\\d.]e[\\-+]?|[^\\s\\-+,a-z])+" options:NSRegularExpressionCaseInsensitive error:nil]; } return self; @@ -148,12 +148,12 @@ return ![value isEqualToString:@"0"]; } -- (void)move:(CGPathRef)path x:(float)x y:(float)y +- (void)move:(CGMutablePathRef)path x:(float)x y:(float)y { [self moveTo:path x:x + _penX y:y + _penY]; } -- (void)moveTo:(CGPathRef)path x:(float)x y:(float)y +- (void)moveTo:(CGMutablePathRef)path x:(float)x y:(float)y { _pivotX = _penX = x; _pivotY = _penY = y; @@ -163,14 +163,12 @@ [_bezierCurves addObject: @[_lastStartPoint]]; } -- (void)line:(CGPathRef)path x:(float)x y:(float)y +- (void)line:(CGMutablePathRef)path x:(float)x y:(float)y { [self lineTo:path x:x + _penX y:y + _penY]; } -- (void)lineTo:(CGPathRef)path x:(float)x y:(float)y{ - NSValue * source = [NSValue valueWithCGPoint:CGPointMake(_pivotX, _pivotY)]; - +- (void)lineTo:(CGMutablePathRef)path x:(float)x y:(float)y{ [self setPenDown]; _pivotX = _penX = x; _pivotY = _penY = y; @@ -180,7 +178,7 @@ [_bezierCurves addObject: @[destination, destination, destination]]; } -- (void)curve:(CGPathRef)path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y ex:(float)ex ey:(float)ey +- (void)curve:(CGMutablePathRef)path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y ex:(float)ex ey:(float)ey { [self curveTo:path c1x:c1x + _penX c1y:c1y + _penY @@ -190,14 +188,14 @@ ey:ey + _penY]; } -- (void)curveTo:(CGPathRef)path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y ex:(float)ex ey:(float)ey +- (void)curveTo:(CGMutablePathRef)path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y ex:(float)ex ey:(float)ey { _pivotX = c2x; _pivotY = c2y; [self curveToPoint:path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y ex:(float)ex ey:(float)ey]; } -- (void)curveToPoint:(CGPathRef)path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y ex:(float)ex ey:(float)ey +- (void)curveToPoint:(CGMutablePathRef)path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y ex:(float)ex ey:(float)ey { [self setPenDown]; _penX = ex; @@ -211,12 +209,12 @@ ]]; } -- (void)smoothCurve:(CGPathRef)path c1x:(float)c1x c1y:(float)c1y ex:(float)ex ey:(float)ey +- (void)smoothCurve:(CGMutablePathRef)path c1x:(float)c1x c1y:(float)c1y ex:(float)ex ey:(float)ey { [self smoothCurveTo:path c1x:c1x + _penX c1y:c1y + _penY ex:ex + _penX ey:ey + _penY]; } -- (void)smoothCurveTo:(CGPathRef)path c1x:(float)c1x c1y:(float)c1y ex:(float)ex ey:(float)ey +- (void)smoothCurveTo:(CGMutablePathRef)path c1x:(float)c1x c1y:(float)c1y ex:(float)ex ey:(float)ey { float c2x = c1x; float c2y = c1y; @@ -227,12 +225,12 @@ [self curveToPoint:path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y ex:(float)ex ey:(float)ey]; } -- (void)quadraticBezierCurve:(CGPathRef)path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y +- (void)quadraticBezierCurve:(CGMutablePathRef)path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y { [self quadraticBezierCurveTo:path c1x:(float)c1x + _penX c1y:(float)c1y + _penY c2x:(float)c2x + _penX c2y:(float)c2y + _penY]; } -- (void)quadraticBezierCurveTo:(CGPathRef)path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y +- (void)quadraticBezierCurveTo:(CGMutablePathRef)path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y { _pivotX = c1x; _pivotY = c1y; @@ -245,12 +243,12 @@ [self curveToPoint:path c1x:(float)c1x c1y:(float)c1y c2x:(float)c2x c2y:(float)c2y ex:(float)ex ey:(float)ey]; } -- (void)smoothQuadraticBezierCurve:(CGPathRef)path c1x:(float)c1x c1y:(float)c1y +- (void)smoothQuadraticBezierCurve:(CGMutablePathRef)path c1x:(float)c1x c1y:(float)c1y { [self smoothQuadraticBezierCurveTo:path c1x:c1x + _penX c1y:c1y + _penY]; } -- (void)smoothQuadraticBezierCurveTo:(CGPathRef)path c1x:(float)c1x c1y:(float)c1y +- (void)smoothQuadraticBezierCurveTo:(CGMutablePathRef)path c1x:(float)c1x c1y:(float)c1y { float c2x = c1x; float c2y = c1y; @@ -259,12 +257,12 @@ [self quadraticBezierCurveTo:path c1x:c1x c1y:c1y c2x:c2x c2y:c2y]; } -- (void)arc:(CGPathRef)path rx:(float)rx ry:(float)ry rotation:(float)rotation outer:(BOOL)outer clockwise:(BOOL)clockwise x:(float)x y:(float)y +- (void)arc:(CGMutablePathRef)path rx:(float)rx ry:(float)ry rotation:(float)rotation outer:(BOOL)outer clockwise:(BOOL)clockwise x:(float)x y:(float)y { [self arcTo:path rx:rx ry:ry rotation:rotation outer:outer clockwise:clockwise x:x + _penX y:y + _penY]; } -- (void)arcTo:(CGPathRef)path rx:(float)rx ry:(float)ry rotation:(float)rotation outer:(BOOL)outer clockwise:(BOOL)clockwise x:(float)x y:(float)y +- (void)arcTo:(CGMutablePathRef)path rx:(float)rx ry:(float)ry rotation:(float)rotation outer:(BOOL)outer clockwise:(BOOL)clockwise x:(float)x y:(float)y { float tX = _penX; float tY = _penY; @@ -332,7 +330,7 @@ [self arcToBezier:path cx:cx cy:cy rx:rx ry:ry sa:sa ea:ea clockwise:clockwise rad:rad]; } -- (void)arcToBezier:(CGPathRef)path cx:(float)cx cy:(float)cy rx:(float)rx ry:(float)ry sa:(float)sa ea:(float)ea clockwise:(BOOL)clockwise rad:(float)rad +- (void)arcToBezier:(CGMutablePathRef)path cx:(float)cx cy:(float)cy rx:(float)rx ry:(float)ry sa:(float)sa ea:(float)ea clockwise:(BOOL)clockwise rad:(float)rad { // Inverse Rotation + Scale Transform float cosed = cosf(rad); @@ -350,7 +348,7 @@ arc -= M_PI * 2; } - int n = ceilf(fabsf(arc / (M_PI / 2))); + int n = ceilf(fabsf(arc / ((float)M_PI / 2))); float step = arc / n; float k = (4.0f / 3.0f) * tanf(step / 4); @@ -380,7 +378,7 @@ } } -- (void)close:(CGPathRef)path +- (void)close:(CGMutablePathRef)path { if (_penDownSet) { _penX = _penDownX;