Skip to content

Commit

Permalink
Updates to fix compiler warnings and deprecations.
Browse files Browse the repository at this point in the history
  • Loading branch information
poetmountain committed May 23, 2017
1 parent 0b481d8 commit 9ea62f4
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 1.1.1
Fixes for compiler warnings and deprecations.

#### 1.1.0
Support for Swift 3.0.

Expand Down
2 changes: 1 addition & 1 deletion Classes/EasingTypes/EasingElastic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Foundation
*/
public struct EasingElastic {

static let M_PI2 = M_PI * 2
static let M_PI2 = Double.pi * 2

public static func easeIn() -> EasingUpdateClosure {

Expand Down
6 changes: 3 additions & 3 deletions Classes/EasingTypes/EasingSine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public struct EasingSine {
public static func easeIn() -> EasingUpdateClosure {

func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
let easing_value = -valueRange * cos((elapsedTime / duration) * M_PI_2) + valueRange + startValue
let easing_value = -valueRange * cos((elapsedTime / duration) * MotionUtils.MM_PI_2) + valueRange + startValue

return easing_value
}
Expand All @@ -45,7 +45,7 @@ public struct EasingSine {
public static func easeOut() -> EasingUpdateClosure {

func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
let easing_value = valueRange * sin((elapsedTime / duration) * M_PI_2) + startValue
let easing_value = valueRange * sin((elapsedTime / duration) * MotionUtils.MM_PI_2) + startValue

return easing_value
}
Expand All @@ -56,7 +56,7 @@ public struct EasingSine {
public static func easeInOut() -> EasingUpdateClosure {

func easing (_ elapsedTime: TimeInterval, startValue: Double, valueRange: Double, duration: TimeInterval) -> Double {
var easing_value = (-valueRange * 0.5) * (cos(M_PI * (elapsedTime / duration)) - 1)
var easing_value = (-valueRange * 0.5) * (cos(Double.pi * (elapsedTime / duration)) - 1)
easing_value += startValue

return easing_value
Expand Down
2 changes: 1 addition & 1 deletion Classes/MotionGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ public class MotionGroup: Moveable, MoveableCollection, TempoDriven, MotionUpdat
tempoOverrides.append(!useChildTempo) // use the opposite Boolean value in order to represent which tempos should be overriden by the group

// subscribe to this motion's status updates
motion.updateDelegate = (self as? MotionUpdateDelegate)
motion.updateDelegate = self


return self
Expand Down
18 changes: 12 additions & 6 deletions Classes/MotionMachine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,12 @@ public struct MotionOptions : OptionSet {
/// Represents an infinite number of repeat motion cycles.
public let REPEAT_INFINITE: UInt = 0

/// Utility methods
public struct MotionUtils {

static let MM_PI_2 = Double.pi / 2

}


// MARK: - Utility extensions
Expand All @@ -549,13 +555,13 @@ func ≈≈ (a: Float, b: Float) -> Bool {
let fabs_b = fabs(b)
let diff = fabs(fabs_a - fabs_b)

if (a == 0.0 || b == 0.0 || diff < FLT_MIN) {
if (a == 0.0 || b == 0.0 || diff < Float.leastNormalMagnitude) {
// a or b is zero or both are extremely close to it
// relative error is less meaningful here
return diff < (FLT_EPSILON * FLT_MIN)
return diff < (Float.ulpOfOne * Float.leastNormalMagnitude)
} else {

return (diff / (fabs_a + fabs_b)) < FLT_EPSILON
return (diff / (fabs_a + fabs_b)) < Float.ulpOfOne
}
}

Expand All @@ -569,12 +575,12 @@ func ≈≈ (a: Double, b: Double) -> Bool {
let fabs_b = fabs(b)
let diff = fabs(fabs_a - fabs_b)

if (a == 0.0 || b == 0.0 || diff < DBL_MIN) {
if (a == 0.0 || b == 0.0 || diff < Double.leastNormalMagnitude) {
// a or b is zero or both are extremely close to it
// relative error is less meaningful here
return diff < (DBL_EPSILON * DBL_MIN)
return diff < (Double.ulpOfOne * Double.leastNormalMagnitude)
} else {
return (diff / (fabs_a + fabs_b)) < DBL_EPSILON
return (diff / (fabs_a + fabs_b)) < Double.ulpOfOne
}

}
Expand Down
2 changes: 1 addition & 1 deletion Classes/MotionSequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ public class MotionSequence: Moveable, MoveableCollection, TempoDriven, MotionUp
tempoOverrides.append(!useChildTempo) // use the opposite Boolean value in order to represent which tempos should be overriden by the sequence

// subscribe to this motion's status updates
sequenceStep.updateDelegate = (self as? MotionUpdateDelegate)
sequenceStep.updateDelegate = self


return self
Expand Down
2 changes: 1 addition & 1 deletion Classes/PhysicsMotion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ public class PhysicsMotion: Moveable, Additive, TempoDriven, PropertyDataDelegat
}

if (no_delay_set) {
operationID = MotionSupport.register(additiveMotion: self as! Additive)
operationID = MotionSupport.register(additiveMotion: self as Additive)
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion Examples/MotionExamples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0730;
LastUpgradeCheck = 0830;
ORGANIZATIONNAME = "Poet & Mountain, LLC";
TargetAttributes = {
8BB379D31CFFA17D00A35AFD = {
Expand Down Expand Up @@ -340,8 +340,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
Expand Down Expand Up @@ -386,8 +388,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -406,6 +410,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand Down
2 changes: 1 addition & 1 deletion MotionMachine.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'MotionMachine'
s.version = '1.1.0'
s.version = '1.1.1'
s.license = { :type => 'MIT' }
s.summary = 'An elegant, powerful, and modular animation library for Swift.'
s.description = <<-DESC
Expand Down

0 comments on commit 9ea62f4

Please sign in to comment.