diff --git a/.rive_head b/.rive_head index 94eae1c0..eef20928 100644 --- a/.rive_head +++ b/.rive_head @@ -1 +1 @@ -52913023ba59036aa8f96685f1df5d9173551f72 +e52e9fff2973ce63a689e9d11ea283214109ca18 diff --git a/Source/Renderer/CDNFileAssetLoader.mm b/Source/Renderer/CDNFileAssetLoader.mm index 0f1ddd09..d72dbf10 100644 --- a/Source/Renderer/CDNFileAssetLoader.mm +++ b/Source/Renderer/CDNFileAssetLoader.mm @@ -18,16 +18,19 @@ - (bool)loadContentsWithAsset:(RiveFileAsset*)asset andFactory:(RiveFactory*)factory { // TODO: Error handling - // TODO: Track tasks, so we can cancel them if we garbage collect the asset loader + // TODO: Track tasks, so we can cancel them if we garbage collect the asset + // loader if ([[asset cdnUuid] length] > 0) { - NSURL* URL = [NSURL - URLWithString:[NSString - stringWithFormat:@"%@/%@", [asset cdnBaseUrl], [asset cdnUuid]]]; + NSURL* URL = + [NSURL URLWithString:[NSString stringWithFormat:@"%@/%@", + [asset cdnBaseUrl], + [asset cdnUuid]]]; NSURLSessionTask* task = [[NSURLSession sharedSession] downloadTaskWithURL:URL - completionHandler:^(NSURL* location, NSURLResponse* response, NSError* error) { + completionHandler:^( + NSURL* location, NSURLResponse* response, NSError* error) { if (!error) { // Load the data into the reader @@ -39,14 +42,15 @@ - (bool)loadContentsWithAsset:(RiveFileAsset*)asset } else if ([asset isKindOfClass:[RiveImageAsset class]]) { - [(RiveImageAsset*)asset renderImage:[factory decodeImage:data]]; + [(RiveImageAsset*)asset + renderImage:[factory decodeImage:data]]; } } }]; // Kick off the http download - // QUESTION: Do we need to tie this into the RiveFile so we can wait for these loads to be - // completed? + // QUESTION: Do we need to tie this into the RiveFile so we can wait for + // these loads to be completed? [task resume]; return true; } @@ -79,7 +83,9 @@ - (bool)loadContentsWithAsset:(RiveFileAsset*)asset { for (RiveFileAssetLoader* loader in loaders) { - if ([loader loadContentsWithAsset:asset andData:data andFactory:factory]) + if ([loader loadContentsWithAsset:asset + andData:data + andFactory:factory]) { return true; } diff --git a/Source/Renderer/CoreGraphicsRenderer.mm b/Source/Renderer/CoreGraphicsRenderer.mm index cbf3f119..3d1b47f2 100644 --- a/Source/Renderer/CoreGraphicsRenderer.mm +++ b/Source/Renderer/CoreGraphicsRenderer.mm @@ -188,10 +188,12 @@ path = CGPathCreateMutable(); } -void CoreGraphicsRenderPath::addRenderPath(RenderPath* path, const Mat2D& transform) +void CoreGraphicsRenderPath::addRenderPath(RenderPath* path, + const Mat2D& transform) { // NSLog(@" --- RenderPath::addPath"); - CGMutablePathRef pathToAdd = reinterpret_cast(path)->getPath(); + CGMutablePathRef pathToAdd = + reinterpret_cast(path)->getPath(); CGAffineTransform affineTransform = CGAffineTransformMake(transform.xx(), transform.xy(), transform.yx(), @@ -224,10 +226,11 @@ CGPathAddLineToPoint(path, NULL, x, y); } -void CoreGraphicsRenderPath::cubicTo(float ox, float oy, float ix, float iy, float x, float y) +void CoreGraphicsRenderPath::cubicTo( + float ox, float oy, float ix, float iy, float x, float y) { - // NSLog(@" --- call to RenderPath::cubicTo %.1f, %.1f, %.1f, %.1f, %.1f, %.1f, ", ox, oy, - // ix, iy, x, y); + // NSLog(@" --- call to RenderPath::cubicTo %.1f, %.1f, %.1f, %.1f, %.1f, + // %.1f, ", ox, oy, ix, iy, x, y); CGPathAddCurveToPoint(path, NULL, ox, oy, ix, iy, x, y); } @@ -254,9 +257,12 @@ void CoreGraphicsRenderer::drawPath(RenderPath* path, RenderPaint* paint) { - // NSLog(@" --- Renderer::drawPath path for type %d", rivePaint->paintStyle); - CoreGraphicsRenderPaint* rivePaint = reinterpret_cast(paint); - CoreGraphicsRenderPath* rivePath = reinterpret_cast(path); + // NSLog(@" --- Renderer::drawPath path for type %d", + // rivePaint->paintStyle); + CoreGraphicsRenderPaint* rivePaint = + reinterpret_cast(paint); + CoreGraphicsRenderPath* rivePath = + reinterpret_cast(path); // Apply the stroke join if (rivePaint->strokeJoin != CoreGraphicsStrokeJoin::None) @@ -381,8 +387,8 @@ // Draw gradient if (rivePaint->gradientType != CoreGraphicsGradient::None) { - // If the path is a stroke, then convert the path to a stroked path to prevent the gradient - // from filling the path + // If the path is a stroke, then convert the path to a stroked path to + // prevent the gradient from filling the path if (rivePaint->paintStyle == CoreGraphicsPaintStyle::Stroke) { CGContextSetLineWidth(ctx, rivePaint->paintThickness); @@ -395,8 +401,11 @@ if (rivePaint->gradientType == CoreGraphicsGradient::Linear) { - CGContextDrawLinearGradient( - ctx, rivePaint->gradient, rivePaint->gradientStart, rivePaint->gradientEnd, 0x3); + CGContextDrawLinearGradient(ctx, + rivePaint->gradient, + rivePaint->gradientStart, + rivePaint->gradientEnd, + 0x3); } else if (rivePaint->gradientType == CoreGraphicsGradient::Radial) { @@ -429,7 +438,8 @@ void CoreGraphicsRenderer::clipPath(RenderPath* path) { // NSLog(@" --- Renderer::clipPath %@", clipPath); - const CGPath* clipPath = reinterpret_cast(path)->getPath(); + const CGPath* clipPath = + reinterpret_cast(path)->getPath(); CGContextAddPath(ctx, clipPath); if (!CGContextIsPathEmpty(ctx)) CGContextClip(ctx); diff --git a/Source/Renderer/FileAssetLoaderAdapter.mm b/Source/Renderer/FileAssetLoaderAdapter.mm index f53a245b..309e14be 100644 --- a/Source/Renderer/FileAssetLoaderAdapter.mm +++ b/Source/Renderer/FileAssetLoaderAdapter.mm @@ -13,7 +13,8 @@ NS_ASSUME_NONNULL_BEGIN -rive::FileAssetLoaderAdapter::FileAssetLoaderAdapter(RiveFileAssetLoader* myLoader) +rive::FileAssetLoaderAdapter::FileAssetLoaderAdapter( + RiveFileAssetLoader* myLoader) { loader = myLoader; } @@ -26,21 +27,27 @@ RiveFactory* myFactory = [[RiveFactory alloc] initWithFactory:factory]; if (asset.is()) { - RiveFontAsset* fontAsset = - [[RiveFontAsset alloc] initWithFileAsset:asset.as()]; - return [loader loadContentsWithAsset:fontAsset andData:data andFactory:myFactory]; + RiveFontAsset* fontAsset = [[RiveFontAsset alloc] + initWithFileAsset:asset.as()]; + return [loader loadContentsWithAsset:fontAsset + andData:data + andFactory:myFactory]; } else if (asset.is()) { - RiveImageAsset* imageAsset = - [[RiveImageAsset alloc] initWithFileAsset:asset.as()]; - return [loader loadContentsWithAsset:imageAsset andData:data andFactory:myFactory]; + RiveImageAsset* imageAsset = [[RiveImageAsset alloc] + initWithFileAsset:asset.as()]; + return [loader loadContentsWithAsset:imageAsset + andData:data + andFactory:myFactory]; } else if (asset.is()) { - RiveAudioAsset* audioAsset = - [[RiveAudioAsset alloc] initWithFileAsset:asset.as()]; - return [loader loadContentsWithAsset:audioAsset andData:data andFactory:myFactory]; + RiveAudioAsset* audioAsset = [[RiveAudioAsset alloc] + initWithFileAsset:asset.as()]; + return [loader loadContentsWithAsset:audioAsset + andData:data + andFactory:myFactory]; } return false; } diff --git a/Source/Renderer/LayerState.mm b/Source/Renderer/LayerState.mm index 364ff8bb..d070e5a0 100644 --- a/Source/Renderer/LayerState.mm +++ b/Source/Renderer/LayerState.mm @@ -92,7 +92,8 @@ - (NSString*)name if (animation == nil) { - return [NSString stringWithCString:"Unknown" encoding:[NSString defaultCStringEncoding]]; + return [NSString stringWithCString:"Unknown" + encoding:[NSString defaultCStringEncoding]]; } return [NSString stringWithCString:animation->name().c_str() encoding:[NSString defaultCStringEncoding]]; diff --git a/Source/Renderer/RenderContextManager.mm b/Source/Renderer/RenderContextManager.mm index 34895944..691f4c9b 100644 --- a/Source/Renderer/RenderContextManager.mm +++ b/Source/Renderer/RenderContextManager.mm @@ -25,7 +25,8 @@ @implementation RenderContext return nil; } -- (void)endFrame:(MTKView*)view withCompletion:(_Nullable MTLCommandBufferHandler)completionHandler; +- (void)endFrame:(MTKView*)view + withCompletion:(_Nullable MTLCommandBufferHandler)completionHandler; {} @end @@ -45,7 +46,8 @@ @implementation RiveRendererContext rive::rcp _renderTarget; } -static std::unique_ptr make_pls_context_native(id gpu) +static std::unique_ptr make_pls_context_native( + id gpu) { return rive::gpu::RenderContextMetalImpl::MakeContext( gpu, rive::gpu::RenderContextMetalImpl::ContextOptions()); @@ -53,8 +55,8 @@ @implementation RiveRendererContext - (instancetype)init { - // Make a single static RenderContext, since it is also the factory and any objects it - // creates may outlive this 'RiveContext' instance. + // Make a single static RenderContext, since it is also the factory and any + // objects it creates may outlive this 'RiveContext' instance. static id s_plsGPU = MTLCreateSystemDefaultDevice(); static std::unique_ptr s_renderContext = make_pls_context_native(s_plsGPU); @@ -71,8 +73,8 @@ - (instancetype)init - (void)dealloc { - // Once nobody is referencing a RiveContext anymore, release the global RenderContext's GPU - // resource. + // Once nobody is referencing a RiveContext anymore, release the global + // RenderContext's GPU resource. _renderContext->releaseResources(); } @@ -100,12 +102,16 @@ - (void)dealloc return nullptr; } - if (_renderTarget == nullptr || _renderTarget->width() != view.drawableSize.width || + if (_renderTarget == nullptr || + _renderTarget->width() != view.drawableSize.width || _renderTarget->height() != view.drawableSize.height) { _renderTarget = - _renderContext->static_impl_cast()->makeRenderTarget( - view.colorPixelFormat, view.drawableSize.width, view.drawableSize.height); + _renderContext + ->static_impl_cast() + ->makeRenderTarget(view.colorPixelFormat, + view.drawableSize.width, + view.drawableSize.height); } _renderTarget->setTargetTexture(surface.texture); @@ -118,7 +124,8 @@ - (void)dealloc return _renderer.get(); } -- (void)endFrame:(MTKView*)view withCompletion:(_Nullable MTLCommandBufferHandler)completionHandler; +- (void)endFrame:(MTKView*)view + withCompletion:(_Nullable MTLCommandBufferHandler)completionHandler; { id flushCommandBuffer = [self.metalQueue commandBuffer]; _renderContext->flush({ @@ -186,10 +193,12 @@ - (instancetype)init switch (view.colorPixelFormat) { case MTLPixelFormatBGRA8Unorm: - cgBitmapInfo = kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst; + cgBitmapInfo = + kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst; break; case MTLPixelFormatRGBA8Unorm: - cgBitmapInfo = kCGBitmapByteOrder32Big | kCGImageAlphaPremultipliedLast; + cgBitmapInfo = + kCGBitmapByteOrder32Big | kCGImageAlphaPremultipliedLast; break; default: NSLog(@"error: unsupported colorPixelFormat on MTKView"); @@ -205,39 +214,46 @@ - (instancetype)init } _currentBufferIdx = (_currentBufferIdx + 1) % kBufferRingSize; - size_t bufferSize = _renderTargetTexture.height * _renderTargetTexture.width * 4; + size_t bufferSize = + _renderTargetTexture.height * _renderTargetTexture.width * 4; if (_buffers[_currentBufferIdx] == nil || _buffers[_currentBufferIdx].allocatedSize != bufferSize) { _buffers[_currentBufferIdx] = - [self.metalDevice newBufferWithLength:bufferSize options:MTLResourceStorageModeShared]; + [self.metalDevice newBufferWithLength:bufferSize + options:MTLResourceStorageModeShared]; } AutoCF colorSpace = CGColorSpaceCreateDeviceRGB(); - _cgContext = AutoCF(CGBitmapContextCreate(_buffers[_currentBufferIdx].contents, - _renderTargetTexture.width, - _renderTargetTexture.height, - 8, - _renderTargetTexture.width * 4, - colorSpace, - cgBitmapInfo)); + _cgContext = + AutoCF(CGBitmapContextCreate(_buffers[_currentBufferIdx].contents, + _renderTargetTexture.width, + _renderTargetTexture.height, + 8, + _renderTargetTexture.width * 4, + colorSpace, + cgBitmapInfo)); _renderer = std::make_unique( _cgContext, _renderTargetTexture.width, _renderTargetTexture.height); return _renderer.get(); } -- (void)endFrame:(MTKView*)view withCompletion:(_Nullable MTLCommandBufferHandler)completionHandler; +- (void)endFrame:(MTKView*)view + withCompletion:(_Nullable MTLCommandBufferHandler)completionHandler; { if (_cgContext != nil) { id commandBuffer = [self.metalQueue commandBuffer]; - id blitEncoder = [commandBuffer blitCommandEncoder]; + id blitEncoder = + [commandBuffer blitCommandEncoder]; [blitEncoder copyFromBuffer:_buffers[_currentBufferIdx] sourceOffset:0 sourceBytesPerRow:_renderTargetTexture.width * 4 - sourceBytesPerImage:_renderTargetTexture.height * _renderTargetTexture.width * 4 - sourceSize:MTLSizeMake( - _renderTargetTexture.width, _renderTargetTexture.height, 1) + sourceBytesPerImage:_renderTargetTexture.height * + _renderTargetTexture.width * 4 + sourceSize:MTLSizeMake(_renderTargetTexture.width, + _renderTargetTexture.height, + 1) toTexture:_renderTargetTexture destinationSlice:0 destinationLevel:0 @@ -295,8 +311,8 @@ - (RenderContext*)getDefaultContext - (RenderContext*)getRiveRendererContext { - // Convert our weak reference to strong before trying to work with it. A weak pointer is liable - // to be released out from under us at any moment. + // Convert our weak reference to strong before trying to work with it. A + // weak pointer is liable to be released out from under us at any moment. // https://stackoverflow.com/questions/15674320/understanding-weak-reference RiveRendererContext* strongPtr = _riveRendererContextWeakPtr; if (strongPtr == nil) @@ -309,8 +325,8 @@ - (RenderContext*)getRiveRendererContext - (RenderContext*)getCGRendererContext { - // Convert our weak reference to strong before trying to work with it. A weak pointer is liable - // to be released out from under us at any moment. + // Convert our weak reference to strong before trying to work with it. A + // weak pointer is liable to be released out from under us at any moment. // https://stackoverflow.com/questions/15674320/understanding-weak-reference CGRendererContext* strongPtr = _cgContextWeakPtr; if (strongPtr == nil) @@ -323,17 +339,20 @@ - (RenderContext*)getCGRendererContext - (RiveFactory*)getDefaultFactory { - return [[RiveFactory alloc] initWithFactory:[[self getDefaultContext] factory]]; + return [[RiveFactory alloc] + initWithFactory:[[self getDefaultContext] factory]]; } - (RiveFactory*)getRiveRendererFactory { - return [[RiveFactory alloc] initWithFactory:[[self getRiveRendererContext] factory]]; + return [[RiveFactory alloc] + initWithFactory:[[self getRiveRendererContext] factory]]; } - (RiveFactory*)getCGFactory { - return [[RiveFactory alloc] initWithFactory:[[self getCGRendererContext] factory]]; + return [[RiveFactory alloc] + initWithFactory:[[self getCGRendererContext] factory]]; } @end diff --git a/Source/Renderer/RiveArtboard.mm b/Source/Renderer/RiveArtboard.mm index 2d92a3c8..aa9ec02e 100644 --- a/Source/Renderer/RiveArtboard.mm +++ b/Source/Renderer/RiveArtboard.mm @@ -33,7 +33,8 @@ @implementation RiveArtboard // MARK: LifeCycle -- (instancetype)initWithArtboard:(std::unique_ptr)riveArtboard +- (instancetype)initWithArtboard: + (std::unique_ptr)riveArtboard { if (self = [super init]) { @@ -87,7 +88,8 @@ - (NSInteger)animationCount return _artboardInstance->animationCount(); } -- (RiveLinearAnimationInstance*)animationFromIndex:(NSInteger)index error:(NSError**)error +- (RiveLinearAnimationInstance*)animationFromIndex:(NSInteger)index + error:(NSError**)error { if (index < 0 || index >= [self animationCount]) { @@ -96,7 +98,8 @@ - (RiveLinearAnimationInstance*)animationFromIndex:(NSInteger)index error:(NSErr code:RiveNoAnimationFound userInfo:@{ NSLocalizedDescriptionKey : [NSString - stringWithFormat:@"No Animation found at index %ld.", (long)index], + stringWithFormat:@"No Animation found at index %ld.", + (long)index], @"name" : @"NoAnimationFound" }]; return nil; @@ -105,7 +108,8 @@ - (RiveLinearAnimationInstance*)animationFromIndex:(NSInteger)index error:(NSErr initWithAnimation:_artboardInstance->animationAt(index)]; } -- (RiveLinearAnimationInstance*)animationFromName:(NSString*)name error:(NSError**)error +- (RiveLinearAnimationInstance*)animationFromName:(NSString*)name + error:(NSError**)error { std::string stdName = std::string([name UTF8String]); auto animation = _artboardInstance->animationNamed(stdName); @@ -115,13 +119,15 @@ - (RiveLinearAnimationInstance*)animationFromName:(NSString*)name error:(NSError errorWithDomain:RiveErrorDomain code:RiveNoAnimationFound userInfo:@{ - NSLocalizedDescriptionKey : - [NSString stringWithFormat:@"No Animation found with name %@.", name], + NSLocalizedDescriptionKey : [NSString + stringWithFormat:@"No Animation found with name %@.", + name], @"name" : @"NoAnimationFound" }]; return nil; } - return [[RiveLinearAnimationInstance alloc] initWithAnimation:std::move(animation)]; + return [[RiveLinearAnimationInstance alloc] + initWithAnimation:std::move(animation)]; } - (NSArray*)animationNames @@ -129,7 +135,8 @@ - (NSArray*)animationNames NSMutableArray* animationNames = [NSMutableArray array]; for (NSUInteger i = 0; i < [self animationCount]; i++) { - RiveLinearAnimationInstance* animation = [self animationFromIndex:i error:nil]; + RiveLinearAnimationInstance* animation = [self animationFromIndex:i + error:nil]; if (animation != nil) { [animationNames addObject:[animation name]]; @@ -145,18 +152,21 @@ - (NSInteger)stateMachineCount } /// Returns a state machine at the given index, or null if the index is invalid -- (RiveStateMachineInstance*)stateMachineFromIndex:(NSInteger)index error:(NSError**)error +- (RiveStateMachineInstance*)stateMachineFromIndex:(NSInteger)index + error:(NSError**)error { if (index < 0 || index >= [self stateMachineCount]) { - *error = [NSError - errorWithDomain:RiveErrorDomain - code:RiveNoStateMachineFound - userInfo:@{ - NSLocalizedDescriptionKey : [NSString - stringWithFormat:@"No State Machine found at index %ld.", (long)index], - @"name" : @"NoStateMachineFound" - }]; + *error = + [NSError errorWithDomain:RiveErrorDomain + code:RiveNoStateMachineFound + userInfo:@{ + NSLocalizedDescriptionKey : [NSString + stringWithFormat: + @"No State Machine found at index %ld.", + (long)index], + @"name" : @"NoStateMachineFound" + }]; return nil; } return [[RiveStateMachineInstance alloc] @@ -164,23 +174,26 @@ - (RiveStateMachineInstance*)stateMachineFromIndex:(NSInteger)index error:(NSErr } /// Returns a state machine with the given name, or null if none exists -- (RiveStateMachineInstance*)stateMachineFromName:(NSString*)name error:(NSError**)error +- (RiveStateMachineInstance*)stateMachineFromName:(NSString*)name + error:(NSError**)error { std::string stdName = std::string([name UTF8String]); auto machine = _artboardInstance->stateMachineNamed(stdName); if (machine == nullptr) { - *error = - [NSError errorWithDomain:RiveErrorDomain - code:RiveNoStateMachineFound - userInfo:@{ - NSLocalizedDescriptionKey : [NSString - stringWithFormat:@"No State Machine found with name %@.", name], - @"name" : @"NoStateMachineFound" - }]; + *error = [NSError + errorWithDomain:RiveErrorDomain + code:RiveNoStateMachineFound + userInfo:@{ + NSLocalizedDescriptionKey : [NSString + stringWithFormat: + @"No State Machine found with name %@.", name], + @"name" : @"NoStateMachineFound" + }]; return nil; } - return [[RiveStateMachineInstance alloc] initWithStateMachine:std::move(machine)]; + return [[RiveStateMachineInstance alloc] + initWithStateMachine:std::move(machine)]; } - (RiveStateMachineInstance*)defaultStateMachine @@ -188,12 +201,15 @@ - (RiveStateMachineInstance*)defaultStateMachine auto machine = _artboardInstance->defaultStateMachine(); if (machine == nullptr) { - // *error = [NSError errorWithDomain:RiveErrorDomain code:RiveNoStateMachineFound - // userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat: @"No default - // State Machine found."], @"name": @"NoStateMachineFound"}]; + // *error = [NSError errorWithDomain:RiveErrorDomain + // code:RiveNoStateMachineFound + // userInfo:@{NSLocalizedDescriptionKey: [NSString + // stringWithFormat: @"No default State Machine found."], + // @"name": @"NoStateMachineFound"}]; return nil; } - return [[RiveStateMachineInstance alloc] initWithStateMachine:std::move(machine)]; + return [[RiveStateMachineInstance alloc] + initWithStateMachine:std::move(machine)]; } - (NSArray*)stateMachineNames @@ -201,7 +217,8 @@ - (NSArray*)stateMachineNames NSMutableArray* stateMachineNames = [NSMutableArray array]; for (NSUInteger i = 0; i < [self stateMachineCount]; i++) { - RiveStateMachineInstance* stateMachine = [self stateMachineFromIndex:i error:nil]; + RiveStateMachineInstance* stateMachine = + [self stateMachineFromIndex:i error:nil]; if (stateMachine != nil) { [stateMachineNames addObject:[stateMachine name]]; @@ -223,7 +240,8 @@ - (void)draw:(RiveRenderer*)renderer - (NSString*)name { std::string str = _artboardInstance->name(); - return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]]; + return [NSString stringWithCString:str.c_str() + encoding:[NSString defaultCStringEncoding]]; } - (CGRect)bounds @@ -238,7 +256,8 @@ - (RiveTextValueRun*)textRun:(NSString*)name auto riveTextRun = _artboardInstance->find(stdName); if (riveTextRun != nullptr) { - return [[RiveTextValueRun alloc] initWithTextValueRun:std::move(riveTextRun)]; + return [[RiveTextValueRun alloc] + initWithTextValueRun:std::move(riveTextRun)]; } return nullptr; } @@ -252,11 +271,13 @@ - (RiveTextValueRun*)textRun:(NSString*)name path:(NSString*)path const std::string stdName = std::string([name UTF8String]); const std::string stdPath = std::string([path UTF8String]); - // Can we update the cpp library to handle empty paths / default to parent if nullptr? + // Can we update the cpp library to handle empty paths / default to parent + // if nullptr? auto riveTextRun = _artboardInstance->getTextRun(stdName, stdPath); if (riveTextRun != nullptr) { - return [[RiveTextValueRun alloc] initWithTextValueRun:std::move(riveTextRun)]; + return [[RiveTextValueRun alloc] + initWithTextValueRun:std::move(riveTextRun)]; } return nullptr; } @@ -265,7 +286,8 @@ - (RiveSMIBool*)getBool:(NSString*)name path:(NSString*)path { // Create a unique dictionary name for nested artboards + booleans; // this lets us use one dictionary for the three different types - NSString* dictName = [NSString stringWithFormat:@"%@%s%@%s", path, "_", name, "_boo"]; + NSString* dictName = + [NSString stringWithFormat:@"%@%s%@%s", path, "_", name, "_boo"]; // Check if the input is already instanced if ([_inputs objectForKey:dictName] != nil) { @@ -290,7 +312,8 @@ - (RiveSMITrigger*)getTrigger:(NSString*)name path:(NSString*)path { // Create a unique dictionary name for nested artboards + triggers; // this lets us use one dictionary for the three different types - NSString* dictName = [NSString stringWithFormat:@"%@%s%@%s", path, "_", name, "_trg"]; + NSString* dictName = + [NSString stringWithFormat:@"%@%s%@%s", path, "_", name, "_trg"]; // Check if the input is already instanced if ([_inputs objectForKey:dictName] != nil) { @@ -315,7 +338,8 @@ - (RiveSMINumber*)getNumber:(NSString*)name path:(NSString*)path { // Create a unique dictionary name for nested artboards + numbers; // this lets us use one dictionary for the three different types - NSString* dictName = [NSString stringWithFormat:@"%@%s%@%s", path, "_", name, "_num"]; + NSString* dictName = + [NSString stringWithFormat:@"%@%s%@%s", path, "_", name, "_num"]; // Check if the input is already instanced if ([_inputs objectForKey:dictName] != nil) { diff --git a/Source/Renderer/RiveEvent.mm b/Source/Renderer/RiveEvent.mm index 5e071ffb..579ebac4 100644 --- a/Source/Renderer/RiveEvent.mm +++ b/Source/Renderer/RiveEvent.mm @@ -23,7 +23,8 @@ @implementation RiveEvent return instance; } -- (instancetype)initWithRiveEvent:(const rive::Event*)riveEvent delay:(float)delay +- (instancetype)initWithRiveEvent:(const rive::Event*)riveEvent + delay:(float)delay { if (self = [super init]) { @@ -40,7 +41,8 @@ - (instancetype)initWithRiveEvent:(const rive::Event*)riveEvent delay:(float)del - (NSString*)name { std::string str = ((const rive::Event*)instance)->name(); - return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]]; + return [NSString stringWithCString:str.c_str() + encoding:[NSString defaultCStringEncoding]]; } - (NSInteger)type @@ -56,7 +58,8 @@ - (float)delay - (NSDictionary*)properties { bool hasCustomProperties = false; - NSMutableDictionary* customProperties = [NSMutableDictionary dictionary]; + NSMutableDictionary* customProperties = + [NSMutableDictionary dictionary]; for (auto child : ((const rive::Event*)instance)->children()) { if (child->is()) @@ -64,32 +67,36 @@ - (float)delay std::string eventName = child->name(); if (!eventName.empty()) { - NSString* convertedName = - [NSString stringWithCString:eventName.c_str() - encoding:[NSString defaultCStringEncoding]]; + NSString* convertedName = [NSString + stringWithCString:eventName.c_str() + encoding:[NSString defaultCStringEncoding]]; switch (child->coreType()) { case rive::CustomPropertyBoolean::typeKey: { bool customBoolValue = - child->as()->propertyValue(); + child->as() + ->propertyValue(); customProperties[convertedName] = @(customBoolValue); break; } case rive::CustomPropertyString::typeKey: { std::string customStringValue = - child->as()->propertyValue(); - NSString* convertedStringValue = - [NSString stringWithCString:customStringValue.c_str() - encoding:[NSString defaultCStringEncoding]]; + child->as() + ->propertyValue(); + NSString* convertedStringValue = [NSString + stringWithCString:customStringValue.c_str() + encoding:[NSString + defaultCStringEncoding]]; customProperties[convertedName] = convertedStringValue; break; } case rive::CustomPropertyNumber::typeKey: { float customNumValue = - child->as()->propertyValue(); + child->as() + ->propertyValue(); customProperties[convertedName] = @(customNumValue); break; } @@ -119,12 +126,14 @@ @implementation RiveOpenUrlEvent - (NSString*)url { std::string str = ((const rive::OpenUrlEvent*)[self getInstance])->url(); - return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]]; + return [NSString stringWithCString:str.c_str() + encoding:[NSString defaultCStringEncoding]]; } - (NSString*)target { - uint32_t targetValue = ((const rive::OpenUrlEvent*)[self getInstance])->targetValue(); + uint32_t targetValue = + ((const rive::OpenUrlEvent*)[self getInstance])->targetValue(); std::string targetString; switch (targetValue) { diff --git a/Source/Renderer/RiveFactory.mm b/Source/Renderer/RiveFactory.mm index a69d2210..90aed9c4 100644 --- a/Source/Renderer/RiveFactory.mm +++ b/Source/Renderer/RiveFactory.mm @@ -37,7 +37,8 @@ return HBFont::FromSystem((void*)ctFont, weight, width); } -static rive::rcp findFallbackFont(rive::Span missing) +static rive::rcp findFallbackFont( + rive::Span missing) { // For each descriptor… for (id fallback in RiveFont.fallbackFonts) @@ -57,7 +58,8 @@ @implementation RiveFont { - rive::rcp instance; // note: we do NOT own this, so don't delete it + rive::rcp + instance; // note: we do NOT own this, so don't delete it } + (void)load @@ -95,7 +97,8 @@ - (instancetype)initWithFont:(rive::rcp)font return _fallbackFonts; } -+ (void)setFallbackFonts:(nonnull NSArray>*)fallbackFonts ++ (void)setFallbackFonts: + (nonnull NSArray>*)fallbackFonts { _fallbackFonts = [fallbackFonts copy]; } @@ -104,7 +107,8 @@ + (void)setFallbackFonts:(nonnull NSArray>*)fallbac @implementation RiveRenderImage { - rive::rcp instance; // note: we do NOT own this, so don't delete it + rive::rcp + instance; // note: we do NOT own this, so don't delete it } - (instancetype)initWithImage:(rive::rcp)image { @@ -127,7 +131,8 @@ - (instancetype)initWithImage:(rive::rcp)image @implementation RiveAudio { - rive::rcp instance; // note: we do NOT own this, so don't delete it + rive::rcp + instance; // note: we do NOT own this, so don't delete it } - (instancetype)initWithAudio:(rive::rcp)audio { @@ -174,14 +179,16 @@ - (RiveRenderImage*)decodeImage:(nonnull NSData*)data { UInt8* bytes = (UInt8*)[data bytes]; return [[RiveRenderImage alloc] - initWithImage:instance->decodeImage(rive::Span(bytes, [data length]))]; + initWithImage:instance->decodeImage( + rive::Span(bytes, [data length]))]; } - (RiveFont*)decodeFont:(nonnull NSData*)data { UInt8* bytes = (UInt8*)[data bytes]; return [[RiveFont alloc] - initWithFont:instance->decodeFont(rive::Span(bytes, [data length]))]; + initWithFont:instance->decodeFont( + rive::Span(bytes, [data length]))]; } #if TARGET_OS_IPHONE @@ -200,7 +207,8 @@ - (RiveAudio*)decodeAudio:(nonnull NSData*)data { UInt8* bytes = (UInt8*)[data bytes]; return [[RiveAudio alloc] - initWithAudio:instance->decodeAudio(rive::Span(bytes, [data length]))]; + initWithAudio:instance->decodeAudio( + rive::Span(bytes, [data length]))]; } @end diff --git a/Source/Renderer/RiveFile.mm b/Source/Renderer/RiveFile.mm index e0139c8d..320e6f99 100644 --- a/Source/Renderer/RiveFile.mm +++ b/Source/Renderer/RiveFile.mm @@ -33,7 +33,9 @@ + (uint)minorVersion return UInt8(rive::File::minorVersion); } -- (nullable instancetype)initWithByteArray:(NSArray*)array loadCdn:(bool)cdn error:(NSError**)error +- (nullable instancetype)initWithByteArray:(NSArray*)array + loadCdn:(bool)cdn + error:(NSError**)error { if (self = [super init]) { @@ -42,10 +44,14 @@ - (nullable instancetype)initWithByteArray:(NSArray*)array loadCdn:(bool)cdn err { bytes = (UInt8*)calloc(array.count, sizeof(UInt64)); - [array enumerateObjectsUsingBlock:^(NSNumber* number, NSUInteger index, BOOL* stop) { + [array enumerateObjectsUsingBlock:^( + NSNumber* number, NSUInteger index, BOOL* stop) { bytes[index] = number.unsignedIntValue; }]; - BOOL ok = [self import:bytes byteLength:array.count loadCdn:cdn error:error]; + BOOL ok = [self import:bytes + byteLength:array.count + loadCdn:cdn + error:error]; if (!ok) { return nil; @@ -74,7 +80,8 @@ - (nullable instancetype)initWithByteArray:(NSArray*)array { bytes = (UInt8*)calloc(array.count, sizeof(UInt64)); - [array enumerateObjectsUsingBlock:^(NSNumber* number, NSUInteger index, BOOL* stop) { + [array enumerateObjectsUsingBlock:^( + NSNumber* number, NSUInteger index, BOOL* stop) { bytes[index] = number.unsignedIntValue; }]; BOOL ok = [self import:bytes @@ -139,10 +146,15 @@ - (nullable instancetype)initWithBytes:(UInt8*)bytes return nil; } -- (nullable instancetype)initWithData:(NSData*)data loadCdn:(bool)cdn error:(NSError**)error +- (nullable instancetype)initWithData:(NSData*)data + loadCdn:(bool)cdn + error:(NSError**)error { UInt8* bytes = (UInt8*)[data bytes]; - return [self initWithBytes:bytes byteLength:data.length loadCdn:cdn error:error]; + return [self initWithBytes:bytes + byteLength:data.length + loadCdn:cdn + error:error]; } - (nullable instancetype)initWithData:(NSData*)data loadCdn:(bool)cdn @@ -165,10 +177,11 @@ - (nullable instancetype)initWithResource:(NSString*)resourceName loadCdn:(bool)cdn error:(NSError**)error { - // QUESTION: good ideas on how we can combine a few of these into following the same path - // better? + // QUESTION: good ideas on how we can combine a few of these into following + // the same path better? // there's a lot of copy pasta here. - NSString* filepath = [[NSBundle mainBundle] pathForResource:resourceName ofType:extension]; + NSString* filepath = [[NSBundle mainBundle] pathForResource:resourceName + ofType:extension]; NSURL* fileUrl = [NSURL fileURLWithPath:filepath]; NSData* fileData = [NSData dataWithContentsOfURL:fileUrl]; @@ -176,19 +189,24 @@ - (nullable instancetype)initWithResource:(NSString*)resourceName } /* - * Creates a RiveFile from a binary resource, and assumes the resource extension is '.riv' + * Creates a RiveFile from a binary resource, and assumes the resource extension + * is '.riv' */ - (nullable instancetype)initWithResource:(NSString*)resourceName loadCdn:(bool)cdn error:(NSError**)error { - return [self initWithResource:resourceName withExtension:@"riv" loadCdn:cdn error:error]; + return [self initWithResource:resourceName + withExtension:@"riv" + loadCdn:cdn + error:error]; } -- (nullable instancetype)initWithResource:(nonnull NSString*)resourceName - loadCdn:(bool)cdn - customAssetLoader:(nonnull LoadAsset)customAssetLoader - error:(NSError* __autoreleasing _Nullable* _Nullable)error +- (nullable instancetype) + initWithResource:(nonnull NSString*)resourceName + loadCdn:(bool)cdn + customAssetLoader:(nonnull LoadAsset)customAssetLoader + error:(NSError* __autoreleasing _Nullable* _Nullable)error { return [self initWithResource:resourceName withExtension:@"riv" @@ -197,16 +215,21 @@ - (nullable instancetype)initWithResource:(nonnull NSString*)resourceName error:error]; } -- (nullable instancetype)initWithResource:(nonnull NSString*)resourceName - withExtension:(nonnull NSString*)extension - loadCdn:(bool)cdn - customAssetLoader:(nonnull LoadAsset)customAssetLoader - error:(NSError* __autoreleasing _Nullable* _Nullable)error +- (nullable instancetype) + initWithResource:(nonnull NSString*)resourceName + withExtension:(nonnull NSString*)extension + loadCdn:(bool)cdn + customAssetLoader:(nonnull LoadAsset)customAssetLoader + error:(NSError* __autoreleasing _Nullable* _Nullable)error { - NSString* filepath = [[NSBundle mainBundle] pathForResource:resourceName ofType:extension]; + NSString* filepath = [[NSBundle mainBundle] pathForResource:resourceName + ofType:extension]; NSURL* fileUrl = [NSURL fileURLWithPath:filepath]; NSData* fileData = [NSData dataWithContentsOfURL:fileUrl]; - return [self initWithData:fileData loadCdn:cdn customAssetLoader:customAssetLoader error:error]; + return [self initWithData:fileData + loadCdn:cdn + customAssetLoader:customAssetLoader + error:error]; } /* @@ -218,7 +241,8 @@ - (nullable instancetype)initWithHttpUrl:(NSString*)url { return [self initWithHttpUrl:url loadCdn:loadCdn - customAssetLoader:^bool(RiveFileAsset* asset, NSData* data, RiveFactory* factory) { + customAssetLoader:^bool( + RiveFileAsset* asset, NSData* data, RiveFactory* factory) { return false; } withDelegate:delegate]; @@ -236,16 +260,19 @@ - (nullable instancetype)initWithHttpUrl:(nonnull NSString*)url // Set up the http download task NSURL* URL = [NSURL URLWithString:url]; - // TODO: we are still adding 8MB of memory when we load our first http url. + // TODO: we are still adding 8MB of memory when we load our first http + // url. NSURLSessionTask* task = [[NSURLSession sharedSession] downloadTaskWithURL:URL - completionHandler:^(NSURL* location, NSURLResponse* response, NSError* error) { + completionHandler:^( + NSURL* location, NSURLResponse* response, NSError* error) { if (!error) { // Load the data into the reader NSData* data = [NSData dataWithContentsOfURL:location]; UInt8* bytes = (UInt8*)[data bytes]; - // TODO: Do something with this error the proper way with delegates. + // TODO: Do something with this error the proper way with + // delegates. NSError* error = nil; [self import:bytes byteLength:[data length] @@ -256,7 +283,8 @@ - (nullable instancetype)initWithHttpUrl:(nonnull NSString*)url dispatch_async(dispatch_get_main_queue(), ^{ if ([[NSThread currentThread] isMainThread]) { - if ([self.delegate respondsToSelector:@selector(riveFileDidLoad:error:)]) + if ([self.delegate respondsToSelector:@selector + (riveFileDidLoad:error:)]) { NSError* error = nil; [self.delegate riveFileDidLoad:self error:&error]; @@ -274,12 +302,16 @@ - (nullable instancetype)initWithHttpUrl:(nonnull NSString*)url return nil; } -- (BOOL)import:(UInt8*)bytes byteLength:(UInt64)length loadCdn:(bool)loadCdn error:(NSError**)error +- (BOOL)import:(UInt8*)bytes + byteLength:(UInt64)length + loadCdn:(bool)loadCdn + error:(NSError**)error { return [self import:bytes byteLength:length loadCdn:loadCdn - customAssetLoader:^bool(RiveFileAsset* asset, NSData* data, RiveFactory* factory) { + customAssetLoader:^bool( + RiveFileAsset* asset, NSData* data, RiveFactory* factory) { return false; } error:error]; @@ -291,11 +323,13 @@ - (BOOL)import:(UInt8*)bytes error:(NSError**)error { rive::ImportResult result; - RenderContext* renderContext = [[RenderContextManager shared] getDefaultContext]; + RenderContext* renderContext = + [[RenderContextManager shared] getDefaultContext]; assert(renderContext); rive::Factory* factory = [renderContext factory]; - FallbackFileAssetLoader* fallbackLoader = [[FallbackFileAssetLoader alloc] init]; + FallbackFileAssetLoader* fallbackLoader = + [[FallbackFileAssetLoader alloc] init]; CustomFileAssetLoader* customAssetLoader = [[CustomFileAssetLoader alloc] initWithLoader:custom]; @@ -309,7 +343,8 @@ - (BOOL)import:(UInt8*)bytes fileAssetLoader = new rive::FileAssetLoaderAdapter(fallbackLoader); - auto file = rive::File::import(rive::Span(bytes, length), factory, &result, fileAssetLoader); + auto file = rive::File::import( + rive::Span(bytes, length), factory, &result, fileAssetLoader); if (result == rive::ImportResult::success) { riveFile = std::move(file); @@ -319,27 +354,29 @@ - (BOOL)import:(UInt8*)bytes switch (result) { case rive::ImportResult::unsupportedVersion: - *error = - [NSError errorWithDomain:RiveErrorDomain - code:RiveUnsupportedVersion - userInfo:@{ - NSLocalizedDescriptionKey : @"Unsupported Rive File Version", - @"name" : @"UnsupportedVersion" - }]; - break; - case rive::ImportResult::malformed: *error = [NSError errorWithDomain:RiveErrorDomain - code:RiveMalformedFile + code:RiveUnsupportedVersion userInfo:@{ - NSLocalizedDescriptionKey : @"Malformed Rive File.", - @"name" : @"Malformed" + NSLocalizedDescriptionKey : + @"Unsupported Rive File Version", + @"name" : @"UnsupportedVersion" }]; break; + case rive::ImportResult::malformed: + *error = [NSError + errorWithDomain:RiveErrorDomain + code:RiveMalformedFile + userInfo:@{ + NSLocalizedDescriptionKey : @"Malformed Rive File.", + @"name" : @"Malformed" + }]; + break; default: *error = [NSError errorWithDomain:RiveErrorDomain code:RiveUnknownError userInfo:@{ - NSLocalizedDescriptionKey : @"Unknown error loading file.", + NSLocalizedDescriptionKey : + @"Unknown error loading file.", @"name" : @"Unknown" }]; break; @@ -352,12 +389,13 @@ - (RiveArtboard*)artboard:(NSError**)error auto artboard = riveFile->artboardDefault(); if (artboard == nullptr) { - *error = [NSError errorWithDomain:RiveErrorDomain - code:RiveNoArtboardsFound - userInfo:@{ - NSLocalizedDescriptionKey : @"No Artboards Found.", - @"name" : @"NoArtboardsFound" - }]; + *error = [NSError + errorWithDomain:RiveErrorDomain + code:RiveNoArtboardsFound + userInfo:@{ + NSLocalizedDescriptionKey : @"No Artboards Found.", + @"name" : @"NoArtboardsFound" + }]; return nil; } else @@ -381,7 +419,8 @@ - (RiveArtboard*)artboardFromIndex:(NSInteger)index error:(NSError**)error code:RiveNoArtboardFound userInfo:@{ NSLocalizedDescriptionKey : [NSString - stringWithFormat:@"No Artboard Found at index %ld.", (long)index], + stringWithFormat:@"No Artboard Found at index %ld.", + (long)index], @"name" : @"NoArtboardFound" }]; return nil; @@ -395,13 +434,15 @@ - (RiveArtboard*)artboardFromName:(NSString*)name error:(NSError**)error auto artboard = riveFile->artboardNamed(stdName); if (artboard == nullptr) { - *error = [NSError errorWithDomain:RiveErrorDomain - code:RiveNoArtboardFound - userInfo:@{ - NSLocalizedDescriptionKey : [NSString - stringWithFormat:@"No Artboard Found with name %@.", name], - @"name" : @"NoArtboardFound" - }]; + *error = [NSError + errorWithDomain:RiveErrorDomain + code:RiveNoArtboardFound + userInfo:@{ + NSLocalizedDescriptionKey : [NSString + stringWithFormat:@"No Artboard Found with name %@.", + name], + @"name" : @"NoArtboardFound" + }]; return nil; } else diff --git a/Source/Renderer/RiveFileAsset.mm b/Source/Renderer/RiveFileAsset.mm index 01b930b0..72513ec3 100644 --- a/Source/Renderer/RiveFileAsset.mm +++ b/Source/Renderer/RiveFileAsset.mm @@ -35,37 +35,43 @@ - (instancetype)initWithFileAsset:(const rive::FileAsset*)fileAsset - (nonnull NSString*)cdnBaseUrl { std::string str = instance->cdnBaseUrl(); - return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]]; + return [NSString stringWithCString:str.c_str() + encoding:[NSString defaultCStringEncoding]]; } - (nonnull NSString*)cdnUuid { std::string str = instance->cdnUuidStr(); - return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]]; + return [NSString stringWithCString:str.c_str() + encoding:[NSString defaultCStringEncoding]]; } - (nonnull NSString*)fileExtension { std::string str = instance->fileExtension(); - return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]]; + return [NSString stringWithCString:str.c_str() + encoding:[NSString defaultCStringEncoding]]; } - (nonnull NSString*)name { std::string str = instance->name(); - return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]]; + return [NSString stringWithCString:str.c_str() + encoding:[NSString defaultCStringEncoding]]; } - (nonnull NSString*)uniqueFilename { std::string str = instance->uniqueFilename(); - return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]]; + return [NSString stringWithCString:str.c_str() + encoding:[NSString defaultCStringEncoding]]; } - (nonnull NSString*)uniqueName { std::string str = instance->uniqueName(); - return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]]; + return [NSString stringWithCString:str.c_str() + encoding:[NSString defaultCStringEncoding]]; } @end diff --git a/Source/Renderer/RiveLinearAnimationInstance.mm b/Source/Renderer/RiveLinearAnimationInstance.mm index 578d3106..80829762 100644 --- a/Source/Renderer/RiveLinearAnimationInstance.mm +++ b/Source/Renderer/RiveLinearAnimationInstance.mm @@ -22,7 +22,8 @@ @implementation RiveLinearAnimationInstance // MARK: Lifecycle -- (instancetype)initWithAnimation:(std::unique_ptr)anim +- (instancetype)initWithAnimation: + (std::unique_ptr)anim { if (self = [super init]) { @@ -111,7 +112,8 @@ - (bool)didLoop - (NSString*)name { std::string str = instance->name(); - return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]]; + return [NSString stringWithCString:str.c_str() + encoding:[NSString defaultCStringEncoding]]; } - (NSInteger)fps diff --git a/Source/Renderer/RiveSMIInput.mm b/Source/Renderer/RiveSMIInput.mm index f7a7d574..51a3263b 100644 --- a/Source/Renderer/RiveSMIInput.mm +++ b/Source/Renderer/RiveSMIInput.mm @@ -14,7 +14,8 @@ */ @implementation RiveSMIInput { - const rive::SMIInput* instance; // note: we do NOT own this, so don't delete it + const rive::SMIInput* + instance; // note: we do NOT own this, so don't delete it } - (const rive::SMIInput*)getInstance @@ -54,7 +55,8 @@ - (bool)isNumber - (NSString*)name { std::string str = ((const rive::SMIInput*)instance)->name(); - return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]]; + return [NSString stringWithCString:str.c_str() + encoding:[NSString defaultCStringEncoding]]; } @end diff --git a/Source/Renderer/RiveStateMachineInstance.mm b/Source/Renderer/RiveStateMachineInstance.mm index e3fd1aee..786b69a5 100644 --- a/Source/Renderer/RiveStateMachineInstance.mm +++ b/Source/Renderer/RiveStateMachineInstance.mm @@ -51,7 +51,8 @@ @implementation RiveStateMachineInstance // MARK: Lifecycle // Creates a new RiveStateMachineInstance from a cpp StateMachine -- (instancetype)initWithStateMachine:(std::unique_ptr)stateMachine +- (instancetype)initWithStateMachine: + (std::unique_ptr)stateMachine { if (self = [super init]) { @@ -181,7 +182,8 @@ - (RiveSMINumber*)getNumber:(NSString*)name - (NSString*)name { std::string str = instance->name(); - return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]]; + return [NSString stringWithCString:str.c_str() + encoding:[NSString defaultCStringEncoding]]; } - (NSInteger)inputCount @@ -189,7 +191,8 @@ - (NSInteger)inputCount return instance->inputCount(); } -- (RiveSMIInput*)_convertInput:(const rive::SMIInput*)input error:(NSError**)error +- (RiveSMIInput*)_convertInput:(const rive::SMIInput*)input + error:(NSError**)error { if (input->input()->is()) { @@ -208,7 +211,8 @@ - (RiveSMIInput*)_convertInput:(const rive::SMIInput*)input error:(NSError**)err *error = [NSError errorWithDomain:RiveErrorDomain code:RiveUnknownStateMachineInput userInfo:@{ - NSLocalizedDescriptionKey : @"Unknown State Machine Input", + NSLocalizedDescriptionKey : + @"Unknown State Machine Input", @"name" : @"UnknownStateMachineInput" }]; return nil; @@ -224,8 +228,9 @@ - (RiveSMIInput*)inputFromIndex:(NSInteger)index error:(NSError**)error errorWithDomain:RiveErrorDomain code:RiveNoStateMachineInputFound userInfo:@{ - NSLocalizedDescriptionKey : - [NSString stringWithFormat:@"No Input found at index %ld.", (long)index], + NSLocalizedDescriptionKey : [NSString + stringWithFormat:@"No Input found at index %ld.", + (long)index], @"name" : @"NoStateMachineInputFound" }]; return nil; @@ -256,7 +261,8 @@ - (RiveSMIInput*)inputFromName:(NSString*)name error:(NSError**)error code:RiveNoStateMachineInputFound userInfo:@{ NSLocalizedDescriptionKey : [NSString - stringWithFormat:@"No State Machine Input found with name %@.", name], + stringWithFormat: + @"No State Machine Input found with name %@.", name], @"name" : @"NoStateMachineInputFound" }]; return nil; @@ -343,14 +349,16 @@ - (RiveLayerState*)stateChangedFromIndex:(NSInteger)index error:(NSError**)error const rive::LayerState* layerState = instance->stateChangedByIndex(index); if (layerState == nullptr) { - *error = [NSError - errorWithDomain:RiveErrorDomain - code:RiveNoStateChangeFound - userInfo:@{ - NSLocalizedDescriptionKey : [NSString - stringWithFormat:@"No State Changed found at index %ld.", (long)index], - @"name" : @"NoStateChangeFound" - }]; + *error = + [NSError errorWithDomain:RiveErrorDomain + code:RiveNoStateChangeFound + userInfo:@{ + NSLocalizedDescriptionKey : [NSString + stringWithFormat: + @"No State Changed found at index %ld.", + (long)index], + @"name" : @"NoStateChangeFound" + }]; return nil; } else diff --git a/Source/Renderer/RiveTextValueRun.mm b/Source/Renderer/RiveTextValueRun.mm index c76d1de1..e6114028 100644 --- a/Source/Renderer/RiveTextValueRun.mm +++ b/Source/Renderer/RiveTextValueRun.mm @@ -13,7 +13,8 @@ */ @implementation RiveTextValueRun { - const rive::TextValueRun* instance; // note: we do NOT own this, so don't delete it + const rive::TextValueRun* + instance; // note: we do NOT own this, so don't delete it } - (const rive::TextValueRun*)getInstance @@ -44,7 +45,8 @@ - (void)setText:(NSString*)textValue - (NSString*)text { std::string str = ((const rive::TextValueRun*)instance)->text(); - return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]]; + return [NSString stringWithCString:str.c_str() + encoding:[NSString defaultCStringEncoding]]; } @end diff --git a/Source/Renderer/include/CDNFileAssetLoader.h b/Source/Renderer/include/CDNFileAssetLoader.h index 09b2800a..d78ca252 100644 --- a/Source/Renderer/include/CDNFileAssetLoader.h +++ b/Source/Renderer/include/CDNFileAssetLoader.h @@ -20,7 +20,9 @@ - (void)addLoader:(RiveFileAssetLoader*)loader; @end -typedef bool (^LoadAsset)(RiveFileAsset* asset, NSData* data, RiveFactory* factory); +typedef bool (^LoadAsset)(RiveFileAsset* asset, + NSData* data, + RiveFactory* factory); @interface CustomFileAssetLoader : RiveFileAssetLoader @property(nonatomic, copy) LoadAsset loadAsset; diff --git a/Source/Renderer/include/CoreGraphicsRenderer.hpp b/Source/Renderer/include/CoreGraphicsRenderer.hpp index 0c6478d9..e19f9f7f 100644 --- a/Source/Renderer/include/CoreGraphicsRenderer.hpp +++ b/Source/Renderer/include/CoreGraphicsRenderer.hpp @@ -144,7 +144,8 @@ class CoreGraphicsRenderPath : public RenderPath void fillRule(FillRule value) override; void moveTo(float x, float y) override; void lineTo(float x, float y) override; - void cubicTo(float ox, float oy, float ix, float iy, float x, float y) override; + void cubicTo(float ox, float oy, float ix, float iy, float x, float y) + override; void close() override; }; diff --git a/Source/Renderer/include/RenderContext.h b/Source/Renderer/include/RenderContext.h index e060310f..a850c4bb 100644 --- a/Source/Renderer/include/RenderContext.h +++ b/Source/Renderer/include/RenderContext.h @@ -20,8 +20,8 @@ NS_ASSUME_NONNULL_BEGIN @class MTKView; -/// RenderContext knows how to set up a backend-specific render context (e.g., CG, Rive, ...), -/// and provides a rive::Factory and rive::Renderer for it. +/// RenderContext knows how to set up a backend-specific render context (e.g., +/// CG, Rive, ...), and provides a rive::Factory and rive::Renderer for it. @interface RenderContext : NSObject @property(strong) id metalDevice; @property(strong) id metalQueue; @@ -29,7 +29,8 @@ NS_ASSUME_NONNULL_BEGIN @property BOOL framebufferOnly; - (rive::Factory*)factory; - (rive::Renderer*)beginFrame:(MTKView*)view; -- (void)endFrame:(MTKView*)view withCompletion:(_Nullable MTLCommandBufferHandler)completionHandler; +- (void)endFrame:(MTKView*)view + withCompletion:(_Nullable MTLCommandBufferHandler)completionHandler; @end NS_ASSUME_NONNULL_END diff --git a/Source/Renderer/include/RenderContextManager.h b/Source/Renderer/include/RenderContextManager.h index d3ad3768..ddae4ba1 100644 --- a/Source/Renderer/include/RenderContextManager.h +++ b/Source/Renderer/include/RenderContextManager.h @@ -14,9 +14,10 @@ typedef NS_ENUM(NSInteger, RendererType) { riveRenderer, cgRenderer }; @class RenderContext; @class RiveFactory; -/// The RenderContextManager is used to allow us to share contexts (e.g., Skia, CG, Rive, ...), -/// while there are active view(s). It has weak refs to its render contexts, which means that when -/// no more RiveRenderViews require these, they can be freed. +/// The RenderContextManager is used to allow us to share contexts (e.g., Skia, +/// CG, Rive, ...), while there are active view(s). It has weak refs to its +/// render contexts, which means that when no more RiveRenderViews require +/// these, they can be freed. @interface RenderContextManager : NSObject @property RendererType defaultRenderer; + (RenderContextManager*)shared; diff --git a/Source/Renderer/include/Rive.h b/Source/Renderer/include/Rive.h index 26603af2..3b1ce4ec 100644 --- a/Source/Renderer/include/Rive.h +++ b/Source/Renderer/include/Rive.h @@ -46,7 +46,15 @@ typedef NS_ENUM(NSInteger, RiveDirection) { /* * Fits */ -typedef NS_ENUM(NSInteger, RiveFit) { fill, contain, cover, fitHeight, fitWidth, scaleDown, noFit }; +typedef NS_ENUM(NSInteger, RiveFit) { + fill, + contain, + cover, + fitHeight, + fitWidth, + scaleDown, + noFit +}; /* * Alignments @@ -93,7 +101,9 @@ typedef NS_ENUM(NSInteger, RiveErrorCode) { @end -typedef bool (^LoadAsset)(RiveFileAsset* asset, NSData* data, RiveFactory* factory); +typedef bool (^LoadAsset)(RiveFileAsset* asset, + NSData* data, + RiveFactory* factory); NS_ASSUME_NONNULL_END diff --git a/Source/Renderer/include/RiveArtboard.h b/Source/Renderer/include/RiveArtboard.h index de0b0a3d..8aefba09 100644 --- a/Source/Renderer/include/RiveArtboard.h +++ b/Source/Renderer/include/RiveArtboard.h @@ -36,13 +36,15 @@ NS_ASSUME_NONNULL_BEGIN - (NSArray*)animationNames; - (RiveLinearAnimationInstance* __nullable)animationFromIndex:(NSInteger)index error:(NSError**)error; -- (RiveLinearAnimationInstance* __nullable)animationFromName:(NSString*)name error:(NSError**)error; +- (RiveLinearAnimationInstance* __nullable)animationFromName:(NSString*)name + error:(NSError**)error; - (NSInteger)stateMachineCount; - (NSArray*)stateMachineNames; - (RiveStateMachineInstance* __nullable)stateMachineFromIndex:(NSInteger)index error:(NSError**)error; -- (RiveStateMachineInstance* __nullable)stateMachineFromName:(NSString*)name error:(NSError**)error; +- (RiveStateMachineInstance* __nullable)stateMachineFromName:(NSString*)name + error:(NSError**)error; - (RiveStateMachineInstance* __nullable)defaultStateMachine; - (RiveTextValueRun* __nullable)textRun:(NSString*)name; diff --git a/Source/Renderer/include/RiveEvent.h b/Source/Renderer/include/RiveEvent.h index 6189960d..fb26cfe3 100644 --- a/Source/Renderer/include/RiveEvent.h +++ b/Source/Renderer/include/RiveEvent.h @@ -25,8 +25,8 @@ NS_ASSUME_NONNULL_BEGIN - (NSString*)name; /// Type of the RiveEvent - (NSInteger)type; -/// Delay in seconds since the Event was actually fired (applicable in cases of Events fired off -/// from timeline animations) +/// Delay in seconds since the Event was actually fired (applicable in cases of +/// Events fired off from timeline animations) - (float)delay; /// Dictionary of custom properties set on any event - (NSDictionary*)properties; diff --git a/Source/Renderer/include/RiveFactory.h b/Source/Renderer/include/RiveFactory.h index ccfa4cf1..7658068d 100644 --- a/Source/Renderer/include/RiveFactory.h +++ b/Source/Renderer/include/RiveFactory.h @@ -22,11 +22,13 @@ NS_ASSUME_NONNULL_BEGIN @protocol RiveFallbackFontProvider; @interface RiveFont : NSObject -/// An array of font descriptors to attempt to use when text being rendererd by Rive uses a font -/// that is missing a glyph. The fonts will be tried in the order in which they are added to the -/// array. -/// - Note: If unset, the default fallback is a default system font, with regular font weight. -@property(class, copy, nonnull) NSArray>* fallbackFonts; +/// An array of font descriptors to attempt to use when text being rendererd by +/// Rive uses a font that is missing a glyph. The fonts will be tried in the +/// order in which they are added to the array. +/// - Note: If unset, the default fallback is a default system font, with +/// regular font weight. +@property(class, copy, nonnull) + NSArray>* fallbackFonts; @end @interface RiveRenderImage : NSObject diff --git a/Source/Renderer/include/RiveFile.h b/Source/Renderer/include/RiveFile.h index 0a800afe..6c4781e8 100644 --- a/Source/Renderer/include/RiveFile.h +++ b/Source/Renderer/include/RiveFile.h @@ -17,7 +17,9 @@ NS_ASSUME_NONNULL_BEGIN @protocol RiveFileDelegate; @class RiveFileAsset; @class RiveFactory; -typedef bool (^LoadAsset)(RiveFileAsset* asset, NSData* data, RiveFactory* factory); +typedef bool (^LoadAsset)(RiveFileAsset* asset, + NSData* data, + RiveFactory* factory); /* * RiveFile @@ -34,7 +36,9 @@ typedef bool (^LoadAsset)(RiveFileAsset* asset, NSData* data, RiveFactory* facto @property(weak) id delegate; /// Used to manage url sessions Rive, this is to enable testing. -- (nullable instancetype)initWithByteArray:(NSArray*)bytes loadCdn:(bool)cdn error:(NSError**)error; +- (nullable instancetype)initWithByteArray:(NSArray*)bytes + loadCdn:(bool)cdn + error:(NSError**)error; - (nullable instancetype)initWithByteArray:(NSArray*)bytes loadCdn:(bool)cdn customAssetLoader:(LoadAsset)customAssetLoader @@ -50,7 +54,9 @@ typedef bool (^LoadAsset)(RiveFileAsset* asset, NSData* data, RiveFactory* facto customAssetLoader:(LoadAsset)customAssetLoader error:(NSError**)error; -- (nullable instancetype)initWithData:(NSData*)bytes loadCdn:(bool)cdn error:(NSError**)error; +- (nullable instancetype)initWithData:(NSData*)bytes + loadCdn:(bool)cdn + error:(NSError**)error; - (nullable instancetype)initWithData:(NSData*)bytes loadCdn:(bool)cdn customAssetLoader:(LoadAsset)customAssetLoader @@ -89,10 +95,12 @@ typedef bool (^LoadAsset)(RiveFileAsset* asset, NSData* data, RiveFactory* facto - (NSInteger)artboardCount; /// Returns the artboard by its index -- (RiveArtboard* __nullable)artboardFromIndex:(NSInteger)index error:(NSError**)error; +- (RiveArtboard* __nullable)artboardFromIndex:(NSInteger)index + error:(NSError**)error; /// Returns the artboard by its name -- (RiveArtboard* __nullable)artboardFromName:(NSString*)name error:(NSError**)error; +- (RiveArtboard* __nullable)artboardFromName:(NSString*)name + error:(NSError**)error; /// Returns the names of all artboards in the file. - (NSArray*)artboardNames; diff --git a/Source/Renderer/include/RivePrivateHeaders.h b/Source/Renderer/include/RivePrivateHeaders.h index 684bf7bc..1fe356a2 100644 --- a/Source/Renderer/include/RivePrivateHeaders.h +++ b/Source/Renderer/include/RivePrivateHeaders.h @@ -49,7 +49,8 @@ * RiveStateMachineInstance interface */ @interface RiveStateMachineInstance () -- (instancetype)initWithStateMachine:(std::unique_ptr)stateMachine; +- (instancetype)initWithStateMachine: + (std::unique_ptr)stateMachine; @end /* @@ -81,21 +82,24 @@ * RiveEvent interface */ @interface RiveEvent () -- (instancetype)initWithRiveEvent:(const rive::Event*)riveEvent delay:(float)delay; +- (instancetype)initWithRiveEvent:(const rive::Event*)riveEvent + delay:(float)delay; @end /* * RiveTextValueRun interface */ @interface RiveTextValueRun () -- (instancetype)initWithTextValueRun:(const rive::TextValueRun*)riveTextValueRun; +- (instancetype)initWithTextValueRun: + (const rive::TextValueRun*)riveTextValueRun; @end /* * RiveLinearAnimationInstance interface */ @interface RiveLinearAnimationInstance () -- (instancetype)initWithAnimation:(std::unique_ptr)riveAnimation; +- (instancetype)initWithAnimation: + (std::unique_ptr)riveAnimation; @end /* @@ -103,7 +107,8 @@ */ @interface RiveArtboard () - (rive::ArtboardInstance*)artboardInstance; -- (instancetype)initWithArtboard:(std::unique_ptr)riveArtboard; +- (instancetype)initWithArtboard: + (std::unique_ptr)riveArtboard; @end /* diff --git a/Source/Renderer/include/RiveStateMachineInstance.h b/Source/Renderer/include/RiveStateMachineInstance.h index 9806800a..072c6400 100644 --- a/Source/Renderer/include/RiveStateMachineInstance.h +++ b/Source/Renderer/include/RiveStateMachineInstance.h @@ -36,10 +36,13 @@ typedef NS_ENUM(NSInteger, RiveHitResult) { none, hit, hitOpaque }; - (NSArray*)inputNames; - (NSInteger)inputCount; - (NSInteger)layerCount; -- (RiveSMIInput* __nullable)inputFromIndex:(NSInteger)index error:(NSError**)error; -- (RiveSMIInput* __nullable)inputFromName:(NSString*)name error:(NSError**)error; +- (RiveSMIInput* __nullable)inputFromIndex:(NSInteger)index + error:(NSError**)error; +- (RiveSMIInput* __nullable)inputFromName:(NSString*)name + error:(NSError**)error; - (NSInteger)stateChangedCount; -- (RiveLayerState* __nullable)stateChangedFromIndex:(NSInteger)index error:(NSError**)error; +- (RiveLayerState* __nullable)stateChangedFromIndex:(NSInteger)index + error:(NSError**)error; - (NSArray*)stateChanges; /// Returns number of reported events on the state machine since the last frame - (NSInteger)reportedEventCount; @@ -49,23 +52,28 @@ typedef NS_ENUM(NSInteger, RiveHitResult) { none, hit, hitOpaque }; // MARK: Touch /// Tells this StateMachineInstance that a user began touching the artboard -/// @param touchLocation A CGPoint in the coordinate space of the animating artboard +/// @param touchLocation A CGPoint in the coordinate space of the animating +/// artboard /// @return The RiveHitResult of a touch beginning at the provided location. - (RiveHitResult)touchBeganAtLocation:(CGPoint)touchLocation; /// Tells this StateMachineInstance that a touch moved on the artboard -/// @param touchLocation A CGPoint in the coordinate space of the animating artboard +/// @param touchLocation A CGPoint in the coordinate space of the animating +/// artboard /// @return The RiveHitResult of a touch moving at the provided location. - (RiveHitResult)touchMovedAtLocation:(CGPoint)touchLocation; /// Tells this StateMachineInstance that a user finished touching the artboard -/// @param touchLocation A CGPoint in the coordinate space of the animating artboard +/// @param touchLocation A CGPoint in the coordinate space of the animating +/// artboard /// @return The RiveHitResult of a touch ending at the provided location. - (RiveHitResult)touchEndedAtLocation:(CGPoint)touchLocation; /// Tells this StateMachineInstance that a user cancelled touching the artboard -/// @param touchLocation A CGPoint in the coordinate space of the animating artboard -/// @return The RiveHitResult of a touch being cancelled at the provided location. +/// @param touchLocation A CGPoint in the coordinate space of the animating +/// artboard +/// @return The RiveHitResult of a touch being cancelled at the provided +/// location. - (RiveHitResult)touchCancelledAtLocation:(CGPoint)touchLocation; // MARK: Debug diff --git a/Source/Renderer/rive_renderer_view.mm b/Source/Renderer/rive_renderer_view.mm index a8f578df..b2eeccd9 100644 --- a/Source/Renderer/rive_renderer_view.mm +++ b/Source/Renderer/rive_renderer_view.mm @@ -12,7 +12,8 @@ #import "RivePrivateHeaders.h" #import #import -// We manually need to provide this as our build-time config isn't shared with xcode. +// We manually need to provide this as our build-time config isn't shared with +// xcode. #define WITH_RIVE_AUDIO #include "rive/audio/audio_engine.hpp" @@ -43,23 +44,27 @@ - (void)didEnterForeground:(NSNotification*)notification - (instancetype)initWithCoder:(NSCoder*)decoder { #if TARGET_OS_IPHONE - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(didEnterBackground:) - name:UIApplicationDidEnterBackgroundNotification - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(didEnterForeground:) - name:UIApplicationWillEnterForegroundNotification - object:nil]; + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(didEnterBackground:) + name:UIApplicationDidEnterBackgroundNotification + object:nil]; + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(didEnterForeground:) + name:UIApplicationWillEnterForegroundNotification + object:nil]; #else - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(didEnterBackground:) - name:NSApplicationDidResignActiveNotification - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(didEnterForeground:) - name:NSApplicationWillBecomeActiveNotification - object:nil]; + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(didEnterBackground:) + name:NSApplicationDidResignActiveNotification + object:nil]; + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(didEnterForeground:) + name:NSApplicationWillBecomeActiveNotification + object:nil]; #endif self = [super initWithCoder:decoder]; @@ -78,28 +83,33 @@ - (instancetype)initWithCoder:(NSCoder*)decoder - (instancetype)initWithFrame:(CGRect)frameRect { #if TARGET_OS_IPHONE - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(didEnterBackground:) - name:UIApplicationDidEnterBackgroundNotification - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(didEnterForeground:) - name:UIApplicationWillEnterForegroundNotification - object:nil]; + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(didEnterBackground:) + name:UIApplicationDidEnterBackgroundNotification + object:nil]; + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(didEnterForeground:) + name:UIApplicationWillEnterForegroundNotification + object:nil]; #else - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(didEnterBackground:) - name:NSApplicationDidResignActiveNotification - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(didEnterForeground:) - name:NSApplicationWillBecomeActiveNotification - object:nil]; + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(didEnterBackground:) + name:NSApplicationDidResignActiveNotification + object:nil]; + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(didEnterForeground:) + name:NSApplicationWillBecomeActiveNotification + object:nil]; #endif _renderContext = [[RenderContextManager shared] getDefaultContext]; assert(_renderContext); - auto value = [super initWithFrame:frameRect device:_renderContext.metalDevice]; + auto value = [super initWithFrame:frameRect + device:_renderContext.metalDevice]; [self setDepthStencilPixelFormat:_renderContext.depthStencilPixelFormat]; [self setColorPixelFormat:MTLPixelFormatBGRA8Unorm]; @@ -141,7 +151,12 @@ - (void)restore _renderer->restore(); } -- (void)transform:(float)xx xy:(float)xy yx:(float)yx yy:(float)yy tx:(float)tx ty:(float)ty +- (void)transform:(float)xx + xy:(float)xy + yx:(float)yx + yy:(float)yy + tx:(float)tx + ty:(float)ty { assert(_renderer != nil); _renderer->transform(rive::Mat2D{xx, xy, yx, yy, tx, ty}); @@ -163,7 +178,8 @@ - (bool)isPaused return true; } -- (void)drawInRect:(CGRect)rect withCompletion:(_Nullable MTLCommandBufferHandler)completionHandler +- (void)drawInRect:(CGRect)rect + withCompletion:(_Nullable MTLCommandBufferHandler)completionHandler { if (CGRectGetWidth(rect) == 0 || CGRectGetHeight(rect) == 0) { @@ -285,7 +301,8 @@ - (CGPoint)artboardLocationFromTouchLocation:(CGPoint)touchLocation auto riveFit = [self riveFit:fit]; auto riveAlignment = [self riveAlignment:alignment]; - rive::Mat2D forward = rive::computeAlignment(riveFit, riveAlignment, frame, content); + rive::Mat2D forward = + rive::computeAlignment(riveFit, riveAlignment, frame, content); rive::Mat2D inverse = forward.invertOrIdentity(); rive::Vec2D frameLocation(touchLocation.x, touchLocation.y); diff --git a/Source/Utils/RiveRuntime.h b/Source/Utils/RiveRuntime.h index bc7100b2..8692f52d 100644 --- a/Source/Utils/RiveRuntime.h +++ b/Source/Utils/RiveRuntime.h @@ -14,8 +14,8 @@ FOUNDATION_EXPORT double RiveRuntimeVersionNumber; //! Project version string for RiveRuntime. FOUNDATION_EXPORT const unsigned char RiveRuntimeVersionString[]; -// In this header, you should import all the public headers of your framework using statements like -// #import +// In this header, you should import all the public headers of your framework +// using statements like #import #import #import #import diff --git a/Tests/OutOfBandAssetTest.mm b/Tests/OutOfBandAssetTest.mm index c07e7962..ad3bd45d 100644 --- a/Tests/OutOfBandAssetTest.mm +++ b/Tests/OutOfBandAssetTest.mm @@ -28,7 +28,8 @@ - (void)testHostedAssetsProvideCallbacks RiveFile* file = [[RiveFile alloc] initWithData:data loadCdn:false - customAssetLoader:^bool(RiveFileAsset* asset, NSData* data, RiveFactory* factory) { + customAssetLoader:^bool( + RiveFileAsset* asset, NSData* data, RiveFactory* factory) { if ([asset isKindOfClass:[RiveImageAsset class]]) { image = (RiveImageAsset*)asset; @@ -52,8 +53,10 @@ - (void)testHostedAssetsProvideCallbacks XCTAssertEqualObjects([image uniqueName], @"image-49934"); XCTAssertEqualObjects([image uniqueFilename], @"image-49934.png"); XCTAssertEqualObjects([image fileExtension], @"png"); - XCTAssertEqualObjects([image cdnBaseUrl], @"https://public.uat.rive.app/cdn/uuid"); - XCTAssertEqualObjects([image cdnUuid], @"eadb7ed8-6d71-4b6c-bbc2-f0f5e9c5dd92"); + XCTAssertEqualObjects([image cdnBaseUrl], + @"https://public.uat.rive.app/cdn/uuid"); + XCTAssertEqualObjects([image cdnUuid], + @"eadb7ed8-6d71-4b6c-bbc2-f0f5e9c5dd92"); XCTAssertNotNil(font); XCTAssertEqual(fontData.length, 0); @@ -61,8 +64,10 @@ - (void)testHostedAssetsProvideCallbacks XCTAssertEqualObjects([font uniqueName], @"Inter-45562"); XCTAssertEqualObjects([font uniqueFilename], @"Inter-45562.ttf"); XCTAssertEqualObjects([font fileExtension], @"ttf"); - XCTAssertEqualObjects([font cdnBaseUrl], @"https://public.uat.rive.app/cdn/uuid"); - XCTAssertEqualObjects([font cdnUuid], @"60ad5ede-993c-4e03-9a80-e56888b2cff3"); + XCTAssertEqualObjects([font cdnBaseUrl], + @"https://public.uat.rive.app/cdn/uuid"); + XCTAssertEqualObjects([font cdnUuid], + @"60ad5ede-993c-4e03-9a80-e56888b2cff3"); } - (void)testAudioAssetCallbacks @@ -78,7 +83,8 @@ - (void)testAudioAssetCallbacks RiveFile* file = [[RiveFile alloc] initWithData:data loadCdn:false - customAssetLoader:^bool(RiveFileAsset* asset, NSData* data, RiveFactory* factory) { + customAssetLoader:^bool( + RiveFileAsset* asset, NSData* data, RiveFactory* factory) { if ([asset isKindOfClass:[RiveAudioAsset class]]) { if (data.length > 0) @@ -104,8 +110,10 @@ - (void)testAudioAssetCallbacks XCTAssertEqualObjects([hosted uniqueName], @"hosted-55368"); XCTAssertEqualObjects([hosted uniqueFilename], @"hosted-55368.wav"); XCTAssertEqualObjects([hosted fileExtension], @"wav"); - XCTAssertEqualObjects([hosted cdnBaseUrl], @"https://public.uat.rive.app/cdn/uuid"); - XCTAssertEqualObjects([hosted cdnUuid], @"79b65f1e-94ea-4191-b5ad-b3d5495b6343"); + XCTAssertEqualObjects([hosted cdnBaseUrl], + @"https://public.uat.rive.app/cdn/uuid"); + XCTAssertEqualObjects([hosted cdnUuid], + @"79b65f1e-94ea-4191-b5ad-b3d5495b6343"); XCTAssertNotNil(embedded); XCTAssertEqual(embeddedData.length, 26095); @@ -114,7 +122,8 @@ - (void)testAudioAssetCallbacks XCTAssertEqualObjects([embedded uniqueName], @"embedded-0"); XCTAssertEqualObjects([embedded uniqueFilename], @"embedded-0.wav"); XCTAssertEqualObjects([embedded fileExtension], @"wav"); - XCTAssertEqualObjects([embedded cdnBaseUrl], @"https://public.rive.app/cdn/uuid"); + XCTAssertEqualObjects([embedded cdnBaseUrl], + @"https://public.rive.app/cdn/uuid"); XCTAssertEqualObjects([embedded cdnUuid], @""); } @@ -130,7 +139,8 @@ - (void)testImageTypesCallbacks RiveFile* file = [[RiveFile alloc] initWithData:data loadCdn:false - customAssetLoader:^bool(RiveFileAsset* asset, NSData* data, RiveFactory* factory) { + customAssetLoader:^bool( + RiveFileAsset* asset, NSData* data, RiveFactory* factory) { if ([asset isKindOfClass:[RiveImageAsset class]]) { @@ -176,7 +186,8 @@ - (void)testEmbeddedAssetsProvideData RiveFile* file = [[RiveFile alloc] initWithData:data loadCdn:false - customAssetLoader:^bool(RiveFileAsset* asset, NSData* data, RiveFactory* factory) { + customAssetLoader:^bool( + RiveFileAsset* asset, NSData* data, RiveFactory* factory) { if ([asset isKindOfClass:[RiveImageAsset class]]) { image = (RiveImageAsset*)asset; @@ -200,7 +211,8 @@ - (void)testEmbeddedAssetsProvideData XCTAssertEqualObjects([image name], @"1x1.png"); XCTAssertEqualObjects([image uniqueFilename], @"1x1-49935.png"); XCTAssertEqualObjects([image fileExtension], @"png"); - XCTAssertEqualObjects([image cdnBaseUrl], @"https://public.rive.app/cdn/uuid"); + XCTAssertEqualObjects([image cdnBaseUrl], + @"https://public.rive.app/cdn/uuid"); XCTAssertEqualObjects([image cdnUuid], @""); XCTAssertNotNil(font); @@ -209,7 +221,8 @@ - (void)testEmbeddedAssetsProvideData XCTAssertEqualObjects([font name], @"Inter"); XCTAssertEqualObjects([font uniqueFilename], @"Inter-45562.ttf"); XCTAssertEqualObjects([font fileExtension], @"ttf"); - XCTAssertEqualObjects([font cdnBaseUrl], @"https://public.rive.app/cdn/uuid"); + XCTAssertEqualObjects([font cdnBaseUrl], + @"https://public.rive.app/cdn/uuid"); XCTAssertEqualObjects([font cdnUuid], @""); } @@ -222,7 +235,8 @@ - (void)testReferencedImageAssetReturnsSize RiveFile* file = [[RiveFile alloc] initWithData:data loadCdn:false - customAssetLoader:^bool(RiveFileAsset* asset, NSData* data, RiveFactory* factory) { + customAssetLoader:^bool( + RiveFileAsset* asset, NSData* data, RiveFactory* factory) { if ([asset isKindOfClass:[RiveImageAsset class]]) { image = (RiveImageAsset*)asset; diff --git a/Tests/RiveAnimationConfigurationsTest.mm b/Tests/RiveAnimationConfigurationsTest.mm index cdf051fd..cdcd2bdb 100644 --- a/Tests/RiveAnimationConfigurationsTest.mm +++ b/Tests/RiveAnimationConfigurationsTest.mm @@ -24,7 +24,8 @@ - (void)testLoop RiveFile* file = [Util loadTestFile:@"animationconfigurations" error:nil]; RiveArtboard* artboard = [file artboard:nil]; - RiveLinearAnimationInstance* animation = [artboard animationFromName:@"loop" error:nil]; + RiveLinearAnimationInstance* animation = [artboard animationFromName:@"loop" + error:nil]; XCTAssertEqual([animation loop], RiveLoop::loop); } @@ -37,7 +38,8 @@ - (void)testPingPong RiveFile* file = [Util loadTestFile:@"animationconfigurations" error:nil]; RiveArtboard* artboard = [file artboard:nil]; - RiveLinearAnimationInstance* animation = [artboard animationFromName:@"pingpong" error:nil]; + RiveLinearAnimationInstance* animation = + [artboard animationFromName:@"pingpong" error:nil]; XCTAssertEqual([animation loop], RiveLoop::pingPong); } @@ -50,7 +52,8 @@ - (void)testOneShot RiveFile* file = [Util loadTestFile:@"animationconfigurations" error:nil]; RiveArtboard* artboard = [file artboard:nil]; - RiveLinearAnimationInstance* animation = [artboard animationFromName:@"oneshot" error:nil]; + RiveLinearAnimationInstance* animation = + [artboard animationFromName:@"oneshot" error:nil]; XCTAssertEqual([animation loop], RiveLoop::oneShot); } @@ -63,7 +66,8 @@ - (void)testDuration1sec60fps RiveFile* file = [Util loadTestFile:@"animationconfigurations" error:nil]; RiveArtboard* artboard = [file artboard:nil]; - RiveLinearAnimationInstance* animation = [artboard animationFromName:@"1sec60fps" error:nil]; + RiveLinearAnimationInstance* animation = + [artboard animationFromName:@"1sec60fps" error:nil]; XCTAssertEqual([animation duration], 60); XCTAssertEqual([animation effectiveDuration], 60); @@ -87,7 +91,8 @@ - (void)testDuration1sec120fps RiveFile* file = [Util loadTestFile:@"animationconfigurations" error:nil]; RiveArtboard* artboard = [file artboard:nil]; - RiveLinearAnimationInstance* animation = [artboard animationFromName:@"1sec120fps" error:nil]; + RiveLinearAnimationInstance* animation = + [artboard animationFromName:@"1sec120fps" error:nil]; XCTAssertEqual([animation duration], 120); XCTAssertEqual([animation effectiveDuration], 120); @@ -104,8 +109,8 @@ - (void)testDuration1sec60fpsf30f50 RiveFile* file = [Util loadTestFile:@"animationconfigurations" error:nil]; RiveArtboard* artboard = [file artboard:nil]; - RiveLinearAnimationInstance* animation = [artboard animationFromName:@"1sec60fps_f30f50" - error:nil]; + RiveLinearAnimationInstance* animation = + [artboard animationFromName:@"1sec60fps_f30f50" error:nil]; XCTAssertEqual([animation duration], 60); XCTAssertEqual([animation effectiveDuration], 20); @@ -118,7 +123,8 @@ - (void)testDuration1sec60fpsf30f50 // seconds = duation / fps = 20/60 const float secs = 20.0 / 60.0; - XCTAssertEqualWithAccuracy([animation effectiveDurationInSeconds], secs, accuracy); + XCTAssertEqualWithAccuracy( + [animation effectiveDurationInSeconds], secs, accuracy); // time = effectiveDuration / fps = 50/60 const float time = 50.0 / 60.0; @@ -133,8 +139,8 @@ - (void)testDuration1sec120fpsf50f80 RiveFile* file = [Util loadTestFile:@"animationconfigurations" error:nil]; RiveArtboard* artboard = [file artboard:nil]; - RiveLinearAnimationInstance* animation = [artboard animationFromName:@"1sec120fps_f50f80" - error:nil]; + RiveLinearAnimationInstance* animation = + [artboard animationFromName:@"1sec120fps_f50f80" error:nil]; XCTAssertEqual([animation duration], 120); XCTAssertEqual([animation effectiveDuration], 30); diff --git a/Tests/RiveAnimationLoadTest.mm b/Tests/RiveAnimationLoadTest.mm index b3a703b3..fac8f119 100644 --- a/Tests/RiveAnimationLoadTest.mm +++ b/Tests/RiveAnimationLoadTest.mm @@ -25,7 +25,8 @@ - (void)testAnimationFirstAnimation RiveFile* file = [Util loadTestFile:@"multipleartboards" error:&error]; RiveArtboard* artboard = [file artboardFromName:@"artboard1" error:&error]; - RiveLinearAnimationInstance* animationByIndex = [artboard animationFromIndex:0 error:&error]; + RiveLinearAnimationInstance* animationByIndex = + [artboard animationFromIndex:0 error:&error]; XCTAssertNil(error); RiveLinearAnimationInstance* animationByName = @@ -47,7 +48,8 @@ - (void)testAnimationSecondAnimation RiveFile* file = [Util loadTestFile:@"multipleartboards" error:&error]; RiveArtboard* artboard = [file artboardFromName:@"artboard2" error:&error]; - RiveLinearAnimationInstance* animationByIndex = [artboard animationFromIndex:0 error:&error]; + RiveLinearAnimationInstance* animationByIndex = + [artboard animationFromIndex:0 error:&error]; XCTAssertNil(error); RiveLinearAnimationInstance* animationByName = [artboard animationFromName:@"artboard2animation1" error:&error]; @@ -55,16 +57,18 @@ - (void)testAnimationSecondAnimation XCTAssertTrue([animationByName.name isEqualToString:animationByIndex.name]); - RiveLinearAnimationInstance* animation2ByIndex = [artboard animationFromIndex:1 error:&error]; + RiveLinearAnimationInstance* animation2ByIndex = + [artboard animationFromIndex:1 error:&error]; XCTAssertNil(error); RiveLinearAnimationInstance* animation2ByName = [artboard animationFromName:@"artboard2animation2" error:&error]; XCTAssertNil(error); - XCTAssertTrue([animation2ByIndex.name isEqualToString:animation2ByName.name]); + XCTAssertTrue( + [animation2ByIndex.name isEqualToString:animation2ByName.name]); - NSArray* target = - [NSArray arrayWithObjects:@"artboard2animation1", @"artboard2animation2", nil]; + NSArray* target = [NSArray + arrayWithObjects:@"artboard2animation1", @"artboard2animation2", nil]; XCTAssertTrue([[artboard animationNames] isEqualToArray:target]); } @@ -90,12 +94,14 @@ - (void)testArtboardAnimationAtIndexDoesntExist RiveArtboard* artboard = [file artboard:nil]; NSError* error = nil; - RiveLinearAnimationInstance* animation = [artboard animationFromIndex:0 error:&error]; + RiveLinearAnimationInstance* animation = + [artboard animationFromIndex:0 error:&error]; XCTAssertNil(animation); XCTAssertNotNil(error); XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime"); - XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"NoAnimationFound"); + XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], + @"NoAnimationFound"); XCTAssertEqual([error code], 201); } @@ -108,12 +114,14 @@ - (void)testArtboardAnimationWithNameDoesntExist RiveArtboard* artboard = [file artboard:nil]; NSError* error = nil; - RiveLinearAnimationInstance* animation = [artboard animationFromName:@"boo" error:&error]; + RiveLinearAnimationInstance* animation = + [artboard animationFromName:@"boo" error:&error]; XCTAssertNil(animation); XCTAssertNotNil(error); XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime"); - XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"NoAnimationFound"); + XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], + @"NoAnimationFound"); XCTAssertEqual([error code], 201); } diff --git a/Tests/RiveArtboardLoadTest.mm b/Tests/RiveArtboardLoadTest.mm index d6f37b06..41524c11 100644 --- a/Tests/RiveArtboardLoadTest.mm +++ b/Tests/RiveArtboardLoadTest.mm @@ -30,7 +30,8 @@ - (void)testLoadArtboard XCTAssertEqual([[file artboardFromIndex:0 error:nil] name], [[file artboardFromName:@"artboard2" error:nil] name]); - NSArray* target = [NSArray arrayWithObjects:@"artboard2", @"artboard1", nil]; + NSArray* target = + [NSArray arrayWithObjects:@"artboard2", @"artboard1", nil]; XCTAssertTrue([[file artboardNames] isEqualToArray:target]); } @@ -59,7 +60,8 @@ - (void)testNoArtboardAccessFirst XCTAssertNotNil(error); XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime"); XCTAssertEqual([error code], 100); - XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"NoArtboardsFound"); + XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], + @"NoArtboardsFound"); } /* @@ -76,7 +78,8 @@ - (void)testNoArtboardAccessFromIndex XCTAssertNotNil(error); XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime"); XCTAssertEqual([error code], 101); - XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"NoArtboardFound"); + XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], + @"NoArtboardFound"); } /* @@ -93,7 +96,8 @@ - (void)testNoArtboardAccessFromName XCTAssertNotNil(error); XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime"); XCTAssertEqual([error code], 101); - XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"NoArtboardFound"); + XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], + @"NoArtboardFound"); } /* @@ -120,7 +124,8 @@ - (void)testGettingTextRunValue { RiveFile* file = [Util loadTestFile:@"testtext" error:nil]; NSError* error = nil; - RiveArtboard* artboard = [file artboardFromName:@"New Artboard" error:&error]; + RiveArtboard* artboard = [file artboardFromName:@"New Artboard" + error:&error]; RiveTextValueRun* textRun = [artboard textRun:@"MyRun"]; XCTAssertTrue([[textRun text] isEqualToString:@"Hello there"]); @@ -133,7 +138,8 @@ - (void)testSettingTextRunValue { RiveFile* file = [Util loadTestFile:@"testtext" error:nil]; NSError* error = nil; - RiveArtboard* artboard = [file artboardFromName:@"New Artboard" error:&error]; + RiveArtboard* artboard = [file artboardFromName:@"New Artboard" + error:&error]; RiveTextValueRun* textRun = [artboard textRun:@"MyRun"]; XCTAssertTrue([[textRun text] isEqualToString:@"Hello there"]); [textRun setText:@"Hello text"]; @@ -166,7 +172,8 @@ - (void)testCatchingErrorOnBadTextRun { RiveFile* file = [Util loadTestFile:@"testtext" error:nil]; NSError* error = nil; - RiveArtboard* artboard = [file artboardFromName:@"New Artboard" error:&error]; + RiveArtboard* artboard = [file artboardFromName:@"New Artboard" + error:&error]; RiveTextValueRun* textRun = [artboard textRun:@"BADRUN"]; XCTAssertNil(textRun); } diff --git a/Tests/RiveFileLoadTest.mm b/Tests/RiveFileLoadTest.mm index b70f1aaf..f76fa0ed 100644 --- a/Tests/RiveFileLoadTest.mm +++ b/Tests/RiveFileLoadTest.mm @@ -42,7 +42,8 @@ - (void)testLoadFormat6 XCTAssertNil(file); XCTAssertNotNil(error); XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime"); - XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"UnsupportedVersion"); + XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], + @"UnsupportedVersion"); XCTAssertEqual([error code], 500); } @@ -64,7 +65,8 @@ - (void)testLoadFluxWithPLS { if ([[RenderContextManager shared] getRiveRendererContext] != nil) { - [[RenderContextManager shared] setDefaultRenderer:RendererType::riveRenderer]; + [[RenderContextManager shared] + setDefaultRenderer:RendererType::riveRenderer]; } NSError* error = nil; RiveFile* file = [Util loadTestFile:@"flux_capacitor" error:&error]; diff --git a/Tests/RiveRuntimeTests.mm b/Tests/RiveRuntimeTests.mm index c97de881..b6717b8d 100644 --- a/Tests/RiveRuntimeTests.mm +++ b/Tests/RiveRuntimeTests.mm @@ -16,91 +16,114 @@ @interface RiveRuntimeTests : XCTestCase @implementation RiveRuntimeTests -UInt8 brokenRiveFileBytes[] = {0x05, 0x25, 0x31, 0x31, 0x31, 0xFF, 0x00, 0x1F, 0x37, 0x0B, - 0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x00, 0x7A, 0x43, 0x00}; +UInt8 brokenRiveFileBytes[] = {0x05, 0x25, 0x31, 0x31, 0x31, 0xFF, 0x00, + 0x1F, 0x37, 0x0B, 0x41, 0x6E, 0x69, 0x6D, + 0x61, 0x74, 0x00, 0x7A, 0x43, 0x00}; UInt8 pingPongRiveFileBytes[] = { - 0x52, 0x49, 0x56, 0x45, 0x07, 0x00, 0x8B, 0x94, 0x02, 0x00, 0x17, 0x00, 0x01, 0x07, 0x00, 0x00, - 0xFA, 0x43, 0x08, 0x00, 0x00, 0xFA, 0x43, 0x04, 0x0C, 0x4E, 0x65, 0x77, 0x20, 0x41, 0x72, 0x74, - 0x62, 0x6F, 0x61, 0x72, 0x64, 0x00, 0x03, 0x05, 0x00, 0x0D, 0x00, 0x00, 0x7A, 0x43, 0x0E, 0x00, - 0x00, 0x7A, 0x43, 0x00, 0x07, 0x05, 0x01, 0x14, 0xEA, 0xA3, 0xC7, 0x42, 0x15, 0xEA, 0xA3, 0xC7, - 0x42, 0x00, 0x14, 0x05, 0x01, 0x00, 0x12, 0x05, 0x03, 0x00, 0x14, 0x05, 0x00, 0x00, 0x12, 0x05, - 0x05, 0x25, 0x31, 0x31, 0x31, 0xFF, 0x00, 0x1F, 0x37, 0x0B, 0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74, - 0x69, 0x6F, 0x6E, 0x20, 0x31, 0x39, 0x0A, 0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35, 0x0D, 0x00, - 0x1E, 0x44, 0x01, 0x46, 0xE8, 0xA3, 0x47, 0x42, 0x00, 0x1E, 0x43, 0x0A, 0x44, 0x01, 0x46, 0x83, - 0x0B, 0xE1, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x00, 0x00, 0x7A, 0x43, + 0x52, 0x49, 0x56, 0x45, 0x07, 0x00, 0x8B, 0x94, 0x02, 0x00, 0x17, 0x00, + 0x01, 0x07, 0x00, 0x00, 0xFA, 0x43, 0x08, 0x00, 0x00, 0xFA, 0x43, 0x04, + 0x0C, 0x4E, 0x65, 0x77, 0x20, 0x41, 0x72, 0x74, 0x62, 0x6F, 0x61, 0x72, + 0x64, 0x00, 0x03, 0x05, 0x00, 0x0D, 0x00, 0x00, 0x7A, 0x43, 0x0E, 0x00, + 0x00, 0x7A, 0x43, 0x00, 0x07, 0x05, 0x01, 0x14, 0xEA, 0xA3, 0xC7, 0x42, + 0x15, 0xEA, 0xA3, 0xC7, 0x42, 0x00, 0x14, 0x05, 0x01, 0x00, 0x12, 0x05, + 0x03, 0x00, 0x14, 0x05, 0x00, 0x00, 0x12, 0x05, 0x05, 0x25, 0x31, 0x31, + 0x31, 0xFF, 0x00, 0x1F, 0x37, 0x0B, 0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74, + 0x69, 0x6F, 0x6E, 0x20, 0x31, 0x39, 0x0A, 0x00, 0x19, 0x33, 0x01, 0x00, + 0x1A, 0x35, 0x0D, 0x00, 0x1E, 0x44, 0x01, 0x46, 0xE8, 0xA3, 0x47, 0x42, + 0x00, 0x1E, 0x43, 0x0A, 0x44, 0x01, 0x46, 0x83, 0x0B, 0xE1, 0x43, 0x00, + 0x1A, 0x35, 0x0E, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x00, 0x00, 0x7A, 0x43, 0x00, 0x1E, 0x43, 0x0A, 0x44, 0x01, 0x46, 0x00, 0x00, 0x7A, 0x43, 0x00}; UInt8 stateMachineFileBytes[] = { - 0x52, 0x49, 0x56, 0x45, 0x07, 0x00, 0xE1, 0x20, 0x00, 0x17, 0x00, 0x01, 0x04, 0x0A, 0x4D, 0x79, - 0x41, 0x72, 0x74, 0x62, 0x6F, 0x61, 0x72, 0x64, 0x07, 0x00, 0x00, 0xFA, 0x43, 0x08, 0x00, 0x00, - 0xFA, 0x43, 0x09, 0x00, 0x00, 0xBE, 0xC2, 0x0A, 0x00, 0x00, 0xD2, 0xC2, 0x00, 0x03, 0x04, 0x0B, - 0x4D, 0x79, 0x52, 0x65, 0x63, 0x74, 0x61, 0x6E, 0x67, 0x6C, 0x65, 0x05, 0x00, 0x0D, 0x78, 0x55, - 0x48, 0x42, 0x0E, 0x78, 0x55, 0x48, 0x42, 0x00, 0x07, 0x04, 0x0F, 0x4D, 0x79, 0x52, 0x65, 0x63, - 0x74, 0x61, 0x6E, 0x67, 0x6C, 0x65, 0x50, 0x61, 0x74, 0x68, 0x05, 0x01, 0x14, 0x7A, 0x55, 0xC8, - 0x42, 0x15, 0x7A, 0x55, 0xC8, 0x42, 0x00, 0x12, 0x05, 0x05, 0x00, 0x12, 0x05, 0x06, 0x25, 0x31, - 0x31, 0x31, 0xFF, 0x00, 0x14, 0x05, 0x01, 0x00, 0x14, 0x04, 0x0A, 0x42, 0x61, 0x63, 0x6B, 0x67, - 0x72, 0x6F, 0x75, 0x6E, 0x64, 0x05, 0x00, 0x00, 0x1F, 0x37, 0x19, 0x57, 0x6F, 0x72, 0x6B, 0x41, - 0x72, 0x65, 0x61, 0x50, 0x69, 0x6E, 0x67, 0x50, 0x6F, 0x6E, 0x67, 0x41, 0x6E, 0x69, 0x6D, 0x61, - 0x74, 0x69, 0x6F, 0x6E, 0x3B, 0x02, 0x3C, 0x0F, 0x3D, 0x2E, 0x3E, 0x01, 0x00, 0x19, 0x33, 0x01, - 0x00, 0x1A, 0x35, 0x0D, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, - 0x14, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x28, 0x44, 0x01, 0x46, 0x51, - 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A, - 0x35, 0x0E, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x14, 0x44, - 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x28, 0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, - 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46, 0x78, 0x55, 0x48, 0x42, 0x00, 0x1F, 0x37, 0x18, - 0x57, 0x6F, 0x72, 0x6B, 0x41, 0x72, 0x65, 0x61, 0x4C, 0x6F, 0x6F, 0x70, 0x69, 0x6E, 0x67, 0x41, - 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x3B, 0x01, 0x3C, 0x0F, 0x3D, 0x2D, 0x3E, 0x01, - 0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35, 0x0D, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, - 0x42, 0x00, 0x1E, 0x43, 0x14, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x28, - 0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46, 0x51, 0xF5, - 0xE0, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, - 0x1E, 0x43, 0x14, 0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x28, 0x44, 0x01, - 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46, 0x78, 0x55, 0x48, 0x42, - 0x00, 0x1F, 0x37, 0x18, 0x57, 0x6F, 0x72, 0x6B, 0x41, 0x72, 0x65, 0x61, 0x4F, 0x6E, 0x65, 0x53, - 0x68, 0x6F, 0x74, 0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x3C, 0x0F, 0x3D, 0x2D, - 0x3E, 0x01, 0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35, 0x0D, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, - 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x14, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, - 0x43, 0x28, 0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46, - 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, - 0x42, 0x00, 0x1E, 0x43, 0x14, 0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x28, - 0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46, 0x78, 0x55, - 0x48, 0x42, 0x00, 0x1F, 0x37, 0x11, 0x50, 0x69, 0x6E, 0x67, 0x50, 0x6F, 0x6E, 0x67, 0x41, 0x6E, - 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x3B, 0x02, 0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35, - 0x0D, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, - 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55, - 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1F, 0x37, - 0x10, 0x4F, 0x6E, 0x65, 0x53, 0x68, 0x6F, 0x74, 0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F, - 0x6E, 0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35, 0x0D, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55, - 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A, 0x35, - 0x0E, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, - 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1F, 0x37, 0x10, 0x4C, 0x6F, 0x6F, 0x70, 0x69, 0x6E, 0x67, - 0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x3B, 0x01, 0x00, 0x19, 0x33, 0x01, 0x00, - 0x1A, 0x35, 0x0D, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x78, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C, - 0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00, 0x1E, 0x44, 0x01, 0x46, - 0x78, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x45, 0x04, 0x46, 0x51, 0xF5, 0xE0, - 0x43, 0x00, 0x35, 0x37, 0x0C, 0x53, 0x74, 0x61, 0x74, 0x65, 0x4D, 0x61, 0x63, 0x68, 0x69, 0x6E, - 0x65, 0x00, 0x38, 0x8A, 0x01, 0x05, 0x4D, 0x79, 0x4E, 0x75, 0x6D, 0x00, 0x3B, 0x8A, 0x01, 0x06, - 0x4D, 0x79, 0x42, 0x6F, 0x6F, 0x6C, 0x00, 0x3A, 0x8A, 0x01, 0x06, 0x4D, 0x79, 0x54, 0x72, 0x69, - 0x67, 0x00, 0x39, 0x8A, 0x01, 0x07, 0x4C, 0x61, 0x79, 0x65, 0x72, 0x20, 0x31, 0x00, 0x3E, 0x00, - 0x3D, 0x95, 0x01, 0x05, 0x00, 0x41, 0x97, 0x01, 0x04, 0x00, 0x44, 0x9B, 0x01, 0x02, 0x00, 0x40, - 0x00, 0x3F, 0x00, 0x41, 0x97, 0x01, 0x01, 0x00, 0x3D, 0x95, 0x01, 0x03, 0x00, 0x41, 0x97, 0x01, - 0x02, 0x00, 0x47, 0x9B, 0x01, 0x01, 0x00, 0x01, 0x04, 0x09, 0x41, 0x72, 0x74, 0x62, 0x6F, 0x61, - 0x72, 0x64, 0x32, 0x07, 0x00, 0x80, 0x8C, 0x43, 0x08, 0x00, 0x80, 0x8C, 0x43, 0x09, 0x00, 0x80, - 0xE9, 0xC3, 0x0A, 0x00, 0x00, 0x5B, 0x43, 0x00, 0x12, 0x05, 0x02, 0x25, 0x31, 0x31, 0x31, 0xFF, - 0x00, 0x14, 0x05, 0x00, 0x00, 0x1F, 0x37, 0x0B, 0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F, + 0x52, 0x49, 0x56, 0x45, 0x07, 0x00, 0xE1, 0x20, 0x00, 0x17, 0x00, 0x01, + 0x04, 0x0A, 0x4D, 0x79, 0x41, 0x72, 0x74, 0x62, 0x6F, 0x61, 0x72, 0x64, + 0x07, 0x00, 0x00, 0xFA, 0x43, 0x08, 0x00, 0x00, 0xFA, 0x43, 0x09, 0x00, + 0x00, 0xBE, 0xC2, 0x0A, 0x00, 0x00, 0xD2, 0xC2, 0x00, 0x03, 0x04, 0x0B, + 0x4D, 0x79, 0x52, 0x65, 0x63, 0x74, 0x61, 0x6E, 0x67, 0x6C, 0x65, 0x05, + 0x00, 0x0D, 0x78, 0x55, 0x48, 0x42, 0x0E, 0x78, 0x55, 0x48, 0x42, 0x00, + 0x07, 0x04, 0x0F, 0x4D, 0x79, 0x52, 0x65, 0x63, 0x74, 0x61, 0x6E, 0x67, + 0x6C, 0x65, 0x50, 0x61, 0x74, 0x68, 0x05, 0x01, 0x14, 0x7A, 0x55, 0xC8, + 0x42, 0x15, 0x7A, 0x55, 0xC8, 0x42, 0x00, 0x12, 0x05, 0x05, 0x00, 0x12, + 0x05, 0x06, 0x25, 0x31, 0x31, 0x31, 0xFF, 0x00, 0x14, 0x05, 0x01, 0x00, + 0x14, 0x04, 0x0A, 0x42, 0x61, 0x63, 0x6B, 0x67, 0x72, 0x6F, 0x75, 0x6E, + 0x64, 0x05, 0x00, 0x00, 0x1F, 0x37, 0x19, 0x57, 0x6F, 0x72, 0x6B, 0x41, + 0x72, 0x65, 0x61, 0x50, 0x69, 0x6E, 0x67, 0x50, 0x6F, 0x6E, 0x67, 0x41, + 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x3B, 0x02, 0x3C, 0x0F, + 0x3D, 0x2E, 0x3E, 0x01, 0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35, 0x0D, + 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, + 0x14, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x28, + 0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, + 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00, 0x1E, + 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x14, 0x44, + 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x28, 0x44, 0x01, + 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46, + 0x78, 0x55, 0x48, 0x42, 0x00, 0x1F, 0x37, 0x18, 0x57, 0x6F, 0x72, 0x6B, + 0x41, 0x72, 0x65, 0x61, 0x4C, 0x6F, 0x6F, 0x70, 0x69, 0x6E, 0x67, 0x41, + 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x3B, 0x01, 0x3C, 0x0F, + 0x3D, 0x2D, 0x3E, 0x01, 0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35, 0x0D, + 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, + 0x14, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x28, + 0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, + 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00, 0x1E, + 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x14, 0x44, + 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x28, 0x44, 0x01, + 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46, + 0x78, 0x55, 0x48, 0x42, 0x00, 0x1F, 0x37, 0x18, 0x57, 0x6F, 0x72, 0x6B, + 0x41, 0x72, 0x65, 0x61, 0x4F, 0x6E, 0x65, 0x53, 0x68, 0x6F, 0x74, 0x41, + 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x3C, 0x0F, 0x3D, 0x2D, + 0x3E, 0x01, 0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35, 0x0D, 0x00, 0x1E, + 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x14, 0x44, + 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x28, 0x44, 0x01, + 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46, + 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00, 0x1E, 0x44, 0x01, + 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x14, 0x44, 0x01, 0x46, + 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x28, 0x44, 0x01, 0x46, 0x51, + 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46, 0x78, 0x55, + 0x48, 0x42, 0x00, 0x1F, 0x37, 0x11, 0x50, 0x69, 0x6E, 0x67, 0x50, 0x6F, + 0x6E, 0x67, 0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x3B, + 0x02, 0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35, 0x0D, 0x00, 0x1E, 0x44, + 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, + 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00, 0x1E, 0x44, + 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, + 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1F, 0x37, 0x10, 0x4F, 0x6E, 0x65, + 0x53, 0x68, 0x6F, 0x74, 0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F, + 0x6E, 0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35, 0x0D, 0x00, 0x1E, 0x44, + 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, + 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00, 0x1E, 0x44, + 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, + 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1F, 0x37, 0x10, 0x4C, 0x6F, 0x6F, + 0x70, 0x69, 0x6E, 0x67, 0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F, + 0x6E, 0x3B, 0x01, 0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35, 0x0D, 0x00, + 0x1E, 0x44, 0x01, 0x46, 0x78, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C, + 0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00, + 0x1E, 0x44, 0x01, 0x46, 0x78, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C, + 0x44, 0x01, 0x45, 0x04, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x35, 0x37, + 0x0C, 0x53, 0x74, 0x61, 0x74, 0x65, 0x4D, 0x61, 0x63, 0x68, 0x69, 0x6E, + 0x65, 0x00, 0x38, 0x8A, 0x01, 0x05, 0x4D, 0x79, 0x4E, 0x75, 0x6D, 0x00, + 0x3B, 0x8A, 0x01, 0x06, 0x4D, 0x79, 0x42, 0x6F, 0x6F, 0x6C, 0x00, 0x3A, + 0x8A, 0x01, 0x06, 0x4D, 0x79, 0x54, 0x72, 0x69, 0x67, 0x00, 0x39, 0x8A, + 0x01, 0x07, 0x4C, 0x61, 0x79, 0x65, 0x72, 0x20, 0x31, 0x00, 0x3E, 0x00, + 0x3D, 0x95, 0x01, 0x05, 0x00, 0x41, 0x97, 0x01, 0x04, 0x00, 0x44, 0x9B, + 0x01, 0x02, 0x00, 0x40, 0x00, 0x3F, 0x00, 0x41, 0x97, 0x01, 0x01, 0x00, + 0x3D, 0x95, 0x01, 0x03, 0x00, 0x41, 0x97, 0x01, 0x02, 0x00, 0x47, 0x9B, + 0x01, 0x01, 0x00, 0x01, 0x04, 0x09, 0x41, 0x72, 0x74, 0x62, 0x6F, 0x61, + 0x72, 0x64, 0x32, 0x07, 0x00, 0x80, 0x8C, 0x43, 0x08, 0x00, 0x80, 0x8C, + 0x43, 0x09, 0x00, 0x80, 0xE9, 0xC3, 0x0A, 0x00, 0x00, 0x5B, 0x43, 0x00, + 0x12, 0x05, 0x02, 0x25, 0x31, 0x31, 0x31, 0xFF, 0x00, 0x14, 0x05, 0x00, + 0x00, 0x1F, 0x37, 0x0B, 0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x31, 0x00}; - (void)setUp { - // Put setup code here. This method is called before the invocation of each test method in the - // class. + // Put setup code here. This method is called before the invocation of each + // test method in the class. } - (void)tearDown { - // Put teardown code here. This method is called after the invocation of each test method in the - // class. + // Put teardown code here. This method is called after the invocation of + // each test method in the class. } /* @@ -199,7 +222,8 @@ - (void)testRetrieveFirstAnimation XCTAssert(artboard != NULL); XCTAssert([artboard animationCount] == 1); - RiveLinearAnimationInstance* animation = [artboard animationFromIndex:0 error:nil]; + RiveLinearAnimationInstance* animation = [artboard animationFromIndex:0 + error:nil]; XCTAssert(animation != NULL); XCTAssert([animation.name isEqual:@"Animation 1"]); } @@ -215,7 +239,8 @@ - (void)testRetrieveAnimationByIndex error:nil]; RiveArtboard* artboard = [file artboard:nil]; - RiveLinearAnimationInstance* animation = [artboard animationFromIndex:0 error:nil]; + RiveLinearAnimationInstance* animation = [artboard animationFromIndex:0 + error:nil]; XCTAssert(animation != NULL); XCTAssert([[animation name] isEqual:@"Animation 1"]); } @@ -232,8 +257,8 @@ - (void)testRetrieveAnimationByName RiveArtboard* artboard = [file artboard:nil]; NSError* error = nil; - RiveLinearAnimationInstance* animation = [artboard animationFromName:@"Animation 1" - error:&error]; + RiveLinearAnimationInstance* animation = + [artboard animationFromName:@"Animation 1" error:&error]; XCTAssert(animation != NULL); XCTAssert([animation.name isEqual:@"Animation 1"]); } @@ -252,7 +277,8 @@ - (void)testRetrieveFirstStateMachine XCTAssert(artboard != NULL); XCTAssert([artboard stateMachineCount] == 1); - RiveStateMachineInstance* machine = [artboard stateMachineFromIndex:0 error:nil]; + RiveStateMachineInstance* machine = [artboard stateMachineFromIndex:0 + error:nil]; XCTAssert(machine != NULL); XCTAssert([machine.name isEqual:@"StateMachine"]); } @@ -271,7 +297,8 @@ - (void)testRetrieveStateMachineByIndex XCTAssert(artboard != NULL); XCTAssert([artboard stateMachineCount] == 1); - RiveStateMachineInstance* machine = [artboard stateMachineFromIndex:0 error:nil]; + RiveStateMachineInstance* machine = [artboard stateMachineFromIndex:0 + error:nil]; XCTAssert(machine != NULL); XCTAssert([machine.name isEqual:@"StateMachine"]); @@ -280,14 +307,16 @@ - (void)testRetrieveStateMachineByIndex XCTAssertNil(machine); XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime"); XCTAssertEqual([error code], 301); - XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"NoStateMachineFound"); + XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], + @"NoStateMachineFound"); error = nil; machine = [artboard stateMachineFromIndex:-1 error:&error]; XCTAssertNil(machine); XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime"); XCTAssertEqual([error code], 301); - XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"NoStateMachineFound"); + XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], + @"NoStateMachineFound"); } /* @@ -302,7 +331,8 @@ - (void)testRetrieveStateMachineByName XCTAssert(file != NULL); RiveArtboard* artboard = [file artboard:nil]; XCTAssert(artboard != NULL); - RiveStateMachineInstance* machine = [artboard stateMachineFromName:@"StateMachine" error:nil]; + RiveStateMachineInstance* machine = + [artboard stateMachineFromName:@"StateMachine" error:nil]; XCTAssert(machine != NULL); NSError* error = nil; @@ -310,7 +340,8 @@ - (void)testRetrieveStateMachineByName XCTAssertNil(machine); XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime"); XCTAssertEqual([error code], 301); - XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"NoStateMachineFound"); + XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], + @"NoStateMachineFound"); } /* @@ -324,9 +355,11 @@ - (void)testCreateStateMachineInstance error:nil]; RiveArtboard* artboard = [file artboard:nil]; - RiveStateMachineInstance* machine = [artboard stateMachineFromIndex:0 error:nil]; + RiveStateMachineInstance* machine = [artboard stateMachineFromIndex:0 + error:nil]; XCTAssert(machine != NULL); - RiveStateMachineInstance* instance = [[RiveStateMachineInstance alloc] init]; + RiveStateMachineInstance* instance = + [[RiveStateMachineInstance alloc] init]; XCTAssert(instance != NULL); } diff --git a/Tests/RiveStateMachineConfigurationTest.mm b/Tests/RiveStateMachineConfigurationTest.mm index 912afe8d..7ef892b0 100644 --- a/Tests/RiveStateMachineConfigurationTest.mm +++ b/Tests/RiveStateMachineConfigurationTest.mm @@ -21,10 +21,11 @@ @implementation RiveStateMachineConfigurationTest */ - (void)testNothing { - RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil]; + RiveFile* file = [Util loadTestFile:@"state_machine_configurations" + error:nil]; - RiveStateMachineInstance* stateMachine = [[file artboard:nil] stateMachineFromName:@"nothing" - error:nil]; + RiveStateMachineInstance* stateMachine = + [[file artboard:nil] stateMachineFromName:@"nothing" error:nil]; XCTAssertEqual([stateMachine inputCount], 0); XCTAssertEqual([stateMachine layerCount], 0); @@ -35,10 +36,11 @@ - (void)testNothing */ - (void)testOneLayer { - RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil]; + RiveFile* file = [Util loadTestFile:@"state_machine_configurations" + error:nil]; - RiveStateMachineInstance* stateMachine = [[file artboard:nil] stateMachineFromName:@"one_layer" - error:nil]; + RiveStateMachineInstance* stateMachine = + [[file artboard:nil] stateMachineFromName:@"one_layer" error:nil]; XCTAssertEqual([stateMachine inputCount], 0); XCTAssertEqual([stateMachine layerCount], 1); @@ -49,10 +51,11 @@ - (void)testOneLayer */ - (void)testTwoLayers { - RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil]; + RiveFile* file = [Util loadTestFile:@"state_machine_configurations" + error:nil]; - RiveStateMachineInstance* stateMachine = [[file artboard:nil] stateMachineFromName:@"two_layers" - error:nil]; + RiveStateMachineInstance* stateMachine = + [[file artboard:nil] stateMachineFromName:@"two_layers" error:nil]; XCTAssertEqual([stateMachine inputCount], 0); XCTAssertEqual([stateMachine layerCount], 2); @@ -63,7 +66,8 @@ - (void)testTwoLayers */ - (void)testNumberInput { - RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil]; + RiveFile* file = [Util loadTestFile:@"state_machine_configurations" + error:nil]; RiveStateMachineInstance* stateMachine = [[file artboard:nil] stateMachineFromName:@"number_input" error:nil]; @@ -77,8 +81,8 @@ - (void)testNumberInput XCTAssertEqual([input isTrigger], 0); XCTAssertEqual([input isNumber], 1); XCTAssertTrue([[input name] isEqualToString:@"Number 1"]); - XCTAssertTrue([[[stateMachine inputFromName:@"Number 1" - error:nil] name] isEqualToString:@"Number 1"]); + XCTAssertTrue([[[stateMachine inputFromName:@"Number 1" error:nil] name] + isEqualToString:@"Number 1"]); } /* @@ -86,7 +90,8 @@ - (void)testNumberInput */ - (void)testBooleanInput { - RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil]; + RiveFile* file = [Util loadTestFile:@"state_machine_configurations" + error:nil]; RiveStateMachineInstance* stateMachine = [[file artboard:nil] stateMachineFromName:@"boolean_input" error:nil]; @@ -100,8 +105,8 @@ - (void)testBooleanInput XCTAssertEqual([input isTrigger], 0); XCTAssertEqual([input isNumber], 0); XCTAssertTrue([[input name] isEqualToString:@"Boolean 1"]); - XCTAssertTrue([[[stateMachine inputFromName:@"Boolean 1" - error:nil] name] isEqualToString:@"Boolean 1"]); + XCTAssertTrue([[[stateMachine inputFromName:@"Boolean 1" error:nil] name] + isEqualToString:@"Boolean 1"]); } /* @@ -109,7 +114,8 @@ - (void)testBooleanInput */ - (void)testTriggerInput { - RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil]; + RiveFile* file = [Util loadTestFile:@"state_machine_configurations" + error:nil]; RiveStateMachineInstance* stateMachine = [[file artboard:nil] stateMachineFromName:@"trigger_input" error:nil]; @@ -123,8 +129,8 @@ - (void)testTriggerInput XCTAssertEqual([input isTrigger], 1); XCTAssertEqual([input isNumber], 0); XCTAssertTrue([[input name] isEqualToString:@"Trigger 1"]); - XCTAssertTrue([[[stateMachine inputFromName:@"Trigger 1" - error:nil] name] isEqualToString:@"Trigger 1"]); + XCTAssertTrue([[[stateMachine inputFromName:@"Trigger 1" error:nil] name] + isEqualToString:@"Trigger 1"]); } /* @@ -132,48 +138,72 @@ - (void)testTriggerInput */ - (void)testMixedInput { - RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil]; + RiveFile* file = [Util loadTestFile:@"state_machine_configurations" + error:nil]; - RiveStateMachineInstance* stateMachine = [[file artboard:nil] stateMachineFromName:@"mixed" - error:nil]; + RiveStateMachineInstance* stateMachine = + [[file artboard:nil] stateMachineFromName:@"mixed" error:nil]; XCTAssertEqual([stateMachine inputCount], 6); XCTAssertEqual([stateMachine layerCount], 4); - NSArray* target = [NSArray - arrayWithObjects:@"zero", @"off", @"trigger", @"two_point_two", @"on", @"three", nil]; + NSArray* target = [NSArray arrayWithObjects:@"zero", + @"off", + @"trigger", + @"two_point_two", + @"on", + @"three", + nil]; XCTAssertTrue([[stateMachine inputNames] isEqualToArray:target]); - XCTAssertEqual([[stateMachine inputFromName:@"zero" error:nil] isNumber], true); - XCTAssertEqual([[stateMachine inputFromName:@"off" error:nil] isBoolean], true); - XCTAssertEqual([[stateMachine inputFromName:@"trigger" error:nil] isTrigger], true); - XCTAssertEqual([[stateMachine inputFromName:@"two_point_two" error:nil] isNumber], true); - XCTAssertEqual([[stateMachine inputFromName:@"on" error:nil] isBoolean], true); - XCTAssertEqual([[stateMachine inputFromName:@"three" error:nil] isNumber], true); - + XCTAssertEqual([[stateMachine inputFromName:@"zero" error:nil] isNumber], + true); + XCTAssertEqual([[stateMachine inputFromName:@"off" error:nil] isBoolean], + true); XCTAssertEqual( - [[stateMachine inputFromName:@"zero" error:nil] isKindOfClass:[RiveSMINumber class]], true); - XCTAssertEqual([(RiveSMINumber*)[stateMachine inputFromName:@"zero" error:nil] value], 0); + [[stateMachine inputFromName:@"trigger" error:nil] isTrigger], true); XCTAssertEqual([[stateMachine inputFromName:@"two_point_two" - error:nil] isKindOfClass:[RiveSMINumber class]], + error:nil] isNumber], + true); + XCTAssertEqual([[stateMachine inputFromName:@"on" error:nil] isBoolean], true); - XCTAssertEqual([(RiveSMINumber*)[stateMachine inputFromName:@"two_point_two" error:nil] value], + XCTAssertEqual([[stateMachine inputFromName:@"three" error:nil] isNumber], + true); + + XCTAssertEqual([[stateMachine inputFromName:@"zero" error:nil] + isKindOfClass:[RiveSMINumber class]], + true); + XCTAssertEqual([(RiveSMINumber*)[stateMachine inputFromName:@"zero" + error:nil] value], + 0); + XCTAssertEqual([[stateMachine inputFromName:@"two_point_two" error:nil] + isKindOfClass:[RiveSMINumber class]], + true); + XCTAssertEqual([(RiveSMINumber*)[stateMachine inputFromName:@"two_point_two" + error:nil] value], (float)2.2); - XCTAssertEqual([[stateMachine inputFromName:@"three" - error:nil] isKindOfClass:[RiveSMINumber class]], + XCTAssertEqual([[stateMachine inputFromName:@"three" error:nil] + isKindOfClass:[RiveSMINumber class]], true); - XCTAssertEqual([(RiveSMINumber*)[stateMachine inputFromName:@"three" error:nil] value], + XCTAssertEqual([(RiveSMINumber*)[stateMachine inputFromName:@"three" + error:nil] value], (float)3); - XCTAssertEqual([[stateMachine inputFromName:@"on" error:nil] isKindOfClass:[RiveSMIBool class]], + XCTAssertEqual([[stateMachine inputFromName:@"on" error:nil] + isKindOfClass:[RiveSMIBool class]], true); - XCTAssertEqual([(RiveSMIBool*)[stateMachine inputFromName:@"on" error:nil] value], true); - XCTAssertEqual( - [[stateMachine inputFromName:@"off" error:nil] isKindOfClass:[RiveSMIBool class]], true); - XCTAssertEqual([(RiveSMIBool*)[stateMachine inputFromName:@"off" error:nil] value], false); + XCTAssertEqual([(RiveSMIBool*)[stateMachine inputFromName:@"on" + error:nil] value], + true); + XCTAssertEqual([[stateMachine inputFromName:@"off" error:nil] + isKindOfClass:[RiveSMIBool class]], + true); + XCTAssertEqual([(RiveSMIBool*)[stateMachine inputFromName:@"off" + error:nil] value], + false); - XCTAssertEqual([[stateMachine inputFromName:@"trigger" - error:nil] isKindOfClass:[RiveSMITrigger class]], + XCTAssertEqual([[stateMachine inputFromName:@"trigger" error:nil] + isKindOfClass:[RiveSMITrigger class]], true); } diff --git a/Tests/RiveStateMachineLoadTest.mm b/Tests/RiveStateMachineLoadTest.mm index 9e71d467..7322ae93 100644 --- a/Tests/RiveStateMachineLoadTest.mm +++ b/Tests/RiveStateMachineLoadTest.mm @@ -25,7 +25,8 @@ - (void)testStateMachineFirstStateMachine RiveFile* file = [Util loadTestFile:@"multipleartboards" error:&error]; RiveArtboard* artboard = [file artboardFromName:@"artboard1" error:&error]; - RiveStateMachineInstance* animationByIndex = [artboard stateMachineFromIndex:0 error:&error]; + RiveStateMachineInstance* animationByIndex = + [artboard stateMachineFromIndex:0 error:&error]; XCTAssertNil(error); RiveStateMachineInstance* animationByName = [artboard stateMachineFromName:@"artboard1stateMachine1" error:&error]; @@ -46,7 +47,8 @@ - (void)testStateMachineSecondStateMachine RiveFile* file = [Util loadTestFile:@"multipleartboards" error:&error]; RiveArtboard* artboard = [file artboardFromName:@"artboard2" error:&error]; - RiveStateMachineInstance* animationByIndex = [artboard stateMachineFromIndex:0 error:&error]; + RiveStateMachineInstance* animationByIndex = + [artboard stateMachineFromIndex:0 error:&error]; XCTAssertNil(error); RiveStateMachineInstance* animationByName = [artboard stateMachineFromName:@"artboard2stateMachine1" error:&error]; @@ -54,16 +56,18 @@ - (void)testStateMachineSecondStateMachine XCTAssertTrue([animationByName.name isEqualToString:animationByIndex.name]); - RiveStateMachineInstance* animation2ByIndex = [artboard stateMachineFromIndex:1 error:&error]; + RiveStateMachineInstance* animation2ByIndex = + [artboard stateMachineFromIndex:1 error:&error]; XCTAssertNil(error); RiveStateMachineInstance* animation2ByName = [artboard stateMachineFromName:@"artboard2stateMachine2" error:&error]; XCTAssertNil(error); - XCTAssertTrue([animation2ByIndex.name isEqualToString:animation2ByName.name]); + XCTAssertTrue( + [animation2ByIndex.name isEqualToString:animation2ByName.name]); - NSArray* target = - [NSArray arrayWithObjects:@"artboard2animation1", @"artboard2animation2", nil]; + NSArray* target = [NSArray + arrayWithObjects:@"artboard2animation1", @"artboard2animation2", nil]; XCTAssertTrue([[artboard animationNames] isEqualToArray:target]); } @@ -89,11 +93,13 @@ - (void)testArtboardStateMachineAtIndexDoesntExist RiveArtboard* artboard = [file artboard:nil]; NSError* error = nil; - RiveStateMachineInstance* stateMachine = [artboard stateMachineFromIndex:0 error:&error]; + RiveStateMachineInstance* stateMachine = + [artboard stateMachineFromIndex:0 error:&error]; XCTAssertNil(stateMachine); XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime"); - XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"NoStateMachineFound"); + XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], + @"NoStateMachineFound"); XCTAssertEqual([error code], 301); } @@ -106,10 +112,12 @@ - (void)testArtboardStateMachineWithNameDoesntExist RiveArtboard* artboard = [file artboard:nil]; NSError* error = nil; - RiveStateMachineInstance* stateMachine = [artboard stateMachineFromName:@"boo" error:&error]; + RiveStateMachineInstance* stateMachine = + [artboard stateMachineFromName:@"boo" error:&error]; XCTAssertNil(stateMachine); XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime"); - XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"NoStateMachineFound"); + XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], + @"NoStateMachineFound"); XCTAssertEqual([error code], 301); } diff --git a/Tests/StateMachineInstanceTest.mm b/Tests/StateMachineInstanceTest.mm index 887d7167..f3ed51b5 100644 --- a/Tests/StateMachineInstanceTest.mm +++ b/Tests/StateMachineInstanceTest.mm @@ -21,11 +21,12 @@ @implementation RiveStateMachineInstanceTest */ - (void)testNothing { - RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil]; + RiveFile* file = [Util loadTestFile:@"state_machine_configurations" + error:nil]; RiveArtboard* artboard = [file artboard:nil]; - RiveStateMachineInstance* stateMachineInstance = [artboard stateMachineFromName:@"nothing" - error:nil]; + RiveStateMachineInstance* stateMachineInstance = + [artboard stateMachineFromName:@"nothing" error:nil]; XCTAssertEqual([stateMachineInstance inputCount], 0); } @@ -35,11 +36,12 @@ - (void)testNothing */ - (void)testNumberInput { - RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil]; + RiveFile* file = [Util loadTestFile:@"state_machine_configurations" + error:nil]; RiveArtboard* artboard = [file artboard:nil]; - RiveStateMachineInstance* stateMachineInstance = [artboard stateMachineFromName:@"number_input" - error:nil]; + RiveStateMachineInstance* stateMachineInstance = + [artboard stateMachineFromName:@"number_input" error:nil]; XCTAssertEqual([stateMachineInstance inputCount], 1); @@ -49,8 +51,8 @@ - (void)testNumberInput XCTAssertEqual([input isTrigger], 0); XCTAssertEqual([input isNumber], 1); XCTAssertTrue([[input name] isEqualToString:@"Number 1"]); - XCTAssertTrue([[[stateMachineInstance inputFromName:@"Number 1" - error:nil] name] isEqualToString:@"Number 1"]); + XCTAssertTrue([[[stateMachineInstance inputFromName:@"Number 1" error:nil] + name] isEqualToString:@"Number 1"]); [(RiveSMINumber*)input setValue:15]; XCTAssertEqual([(RiveSMINumber*)input value], 15); @@ -61,11 +63,12 @@ - (void)testNumberInput */ - (void)testBooleanInput { - RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil]; + RiveFile* file = [Util loadTestFile:@"state_machine_configurations" + error:nil]; RiveArtboard* artboard = [file artboard:nil]; - RiveStateMachineInstance* stateMachineInstance = [artboard stateMachineFromName:@"boolean_input" - error:nil]; + RiveStateMachineInstance* stateMachineInstance = + [artboard stateMachineFromName:@"boolean_input" error:nil]; XCTAssertEqual([stateMachineInstance inputCount], 1); @@ -75,8 +78,8 @@ - (void)testBooleanInput XCTAssertEqual([input isTrigger], 0); XCTAssertEqual([input isNumber], 0); XCTAssertTrue([[input name] isEqualToString:@"Boolean 1"]); - XCTAssertTrue([[[stateMachineInstance inputFromName:@"Boolean 1" - error:nil] name] isEqualToString:@"Boolean 1"]); + XCTAssertTrue([[[stateMachineInstance inputFromName:@"Boolean 1" error:nil] + name] isEqualToString:@"Boolean 1"]); [(RiveSMIBool*)input setValue:false]; XCTAssertEqual([(RiveSMIBool*)input value], false); @@ -90,11 +93,12 @@ - (void)testBooleanInput */ - (void)testTriggerInput { - RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil]; + RiveFile* file = [Util loadTestFile:@"state_machine_configurations" + error:nil]; RiveArtboard* artboard = [file artboard:nil]; - RiveStateMachineInstance* stateMachineInstance = [artboard stateMachineFromName:@"trigger_input" - error:nil]; + RiveStateMachineInstance* stateMachineInstance = + [artboard stateMachineFromName:@"trigger_input" error:nil]; XCTAssertEqual([stateMachineInstance inputCount], 1); @@ -104,8 +108,8 @@ - (void)testTriggerInput XCTAssertEqual([input isTrigger], 1); XCTAssertEqual([input isNumber], 0); XCTAssertTrue([[input name] isEqualToString:@"Trigger 1"]); - XCTAssertTrue([[[stateMachineInstance inputFromName:@"Trigger 1" - error:nil] name] isEqualToString:@"Trigger 1"]); + XCTAssertTrue([[[stateMachineInstance inputFromName:@"Trigger 1" error:nil] + name] isEqualToString:@"Trigger 1"]); [(RiveSMITrigger*)input fire]; } @@ -115,56 +119,82 @@ - (void)testTriggerInput */ - (void)testMixedInput { - RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil]; + RiveFile* file = [Util loadTestFile:@"state_machine_configurations" + error:nil]; RiveArtboard* artboard = [file artboard:nil]; - RiveStateMachineInstance* stateMachineInstance = [artboard stateMachineFromName:@"mixed" - error:nil]; + RiveStateMachineInstance* stateMachineInstance = + [artboard stateMachineFromName:@"mixed" error:nil]; XCTAssertEqual([stateMachineInstance inputCount], 6); - NSArray* target = [NSArray - arrayWithObjects:@"zero", @"off", @"trigger", @"two_point_two", @"on", @"three", nil]; + NSArray* target = [NSArray arrayWithObjects:@"zero", + @"off", + @"trigger", + @"two_point_two", + @"on", + @"three", + nil]; XCTAssertTrue([[stateMachineInstance inputNames] isEqualToArray:target]); - XCTAssertEqual([[stateMachineInstance inputFromName:@"zero" error:nil] isNumber], true); - XCTAssertEqual([[stateMachineInstance inputFromName:@"off" error:nil] isBoolean], true); - XCTAssertEqual([[stateMachineInstance inputFromName:@"trigger" error:nil] isTrigger], true); - XCTAssertEqual([[stateMachineInstance inputFromName:@"two_point_two" error:nil] isNumber], - true); - XCTAssertEqual([[stateMachineInstance inputFromName:@"on" error:nil] isBoolean], true); - XCTAssertEqual([[stateMachineInstance inputFromName:@"three" error:nil] isNumber], true); - XCTAssertEqual([[stateMachineInstance inputFromName:@"zero" - error:nil] isKindOfClass:[RiveSMINumber class]], + error:nil] isNumber], + true); + XCTAssertEqual([[stateMachineInstance inputFromName:@"off" + error:nil] isBoolean], + true); + XCTAssertEqual([[stateMachineInstance inputFromName:@"trigger" + error:nil] isTrigger], true); - XCTAssertEqual([(RiveSMINumber*)[stateMachineInstance inputFromName:@"zero" error:nil] value], - 0); XCTAssertEqual([[stateMachineInstance inputFromName:@"two_point_two" - error:nil] isKindOfClass:[RiveSMINumber class]], + error:nil] isNumber], true); - XCTAssertEqual([(RiveSMINumber*)[stateMachineInstance inputFromName:@"two_point_two" - error:nil] value], - (float)2.2); + XCTAssertEqual( + [[stateMachineInstance inputFromName:@"on" error:nil] isBoolean], true); XCTAssertEqual([[stateMachineInstance inputFromName:@"three" - error:nil] isKindOfClass:[RiveSMINumber class]], + error:nil] isNumber], true); - XCTAssertEqual([(RiveSMINumber*)[stateMachineInstance inputFromName:@"three" error:nil] value], - (float)3); - XCTAssertEqual([[stateMachineInstance inputFromName:@"on" - error:nil] isKindOfClass:[RiveSMIBool class]], + XCTAssertEqual([[stateMachineInstance inputFromName:@"zero" error:nil] + isKindOfClass:[RiveSMINumber class]], true); - XCTAssertEqual([(RiveSMIBool*)[stateMachineInstance inputFromName:@"on" error:nil] value], + XCTAssertEqual( + [(RiveSMINumber*)[stateMachineInstance inputFromName:@"zero" + error:nil] value], + 0); + XCTAssertEqual([[stateMachineInstance inputFromName:@"two_point_two" + error:nil] + isKindOfClass:[RiveSMINumber class]], true); - XCTAssertEqual([[stateMachineInstance inputFromName:@"off" - error:nil] isKindOfClass:[RiveSMIBool class]], + XCTAssertEqual( + [(RiveSMINumber*)[stateMachineInstance inputFromName:@"two_point_two" + error:nil] value], + (float)2.2); + XCTAssertEqual([[stateMachineInstance inputFromName:@"three" error:nil] + isKindOfClass:[RiveSMINumber class]], true); - XCTAssertEqual([(RiveSMIBool*)[stateMachineInstance inputFromName:@"off" error:nil] value], - false); + XCTAssertEqual( + [(RiveSMINumber*)[stateMachineInstance inputFromName:@"three" + error:nil] value], + (float)3); - XCTAssertEqual([[stateMachineInstance inputFromName:@"trigger" - error:nil] isKindOfClass:[RiveSMITrigger class]], + XCTAssertEqual([[stateMachineInstance inputFromName:@"on" error:nil] + isKindOfClass:[RiveSMIBool class]], + true); + XCTAssertEqual( + [(RiveSMIBool*)[stateMachineInstance inputFromName:@"on" + error:nil] value], + true); + XCTAssertEqual([[stateMachineInstance inputFromName:@"off" error:nil] + isKindOfClass:[RiveSMIBool class]], + true); + XCTAssertEqual( + [(RiveSMIBool*)[stateMachineInstance inputFromName:@"off" + error:nil] value], + false); + + XCTAssertEqual([[stateMachineInstance inputFromName:@"trigger" error:nil] + isKindOfClass:[RiveSMITrigger class]], true); } diff --git a/Tests/util.mm b/Tests/util.mm index c857fd66..20763b6b 100644 --- a/Tests/util.mm +++ b/Tests/util.mm @@ -24,12 +24,16 @@ + (NSData*)loadTestData:(NSString*)name + (RiveFile*)loadTestFile:(NSString*)name error:(NSError**)error { NSData* nsData = [self loadTestData:name]; - RiveFile* file = [[RiveFile alloc] initWithData:nsData loadCdn:false error:error]; + RiveFile* file = [[RiveFile alloc] initWithData:nsData + loadCdn:false + error:error]; return file; } @end -typedef void (^CompletionHandler)(NSURL* location, NSURLResponse* response, NSError* error); +typedef void (^CompletionHandler)(NSURL* location, + NSURLResponse* response, + NSError* error); @implementation TestSessionDownloadTask {} @@ -52,7 +56,8 @@ - (instancetype)init } - (NSURLSessionDownloadTask*)downloadTaskWithURL:(NSURL*)url - completionHandler:(CompletionHandler)completionHandler + completionHandler: + (CompletionHandler)completionHandler { [urls addObject:url]; return [[TestSessionDownloadTask alloc] init]; diff --git a/submodules/rive-runtime b/submodules/rive-runtime index 71fd5c47..163f1bee 160000 --- a/submodules/rive-runtime +++ b/submodules/rive-runtime @@ -1 +1 @@ -Subproject commit 71fd5c47b021a98560df0b10b060e24a5303eb18 +Subproject commit 163f1beef36d4c34aac23821e771516514f85d13