Updated to swift 4.2

This commit is contained in:
iko 2019-05-25 02:26:42 +03:00
parent bed66a5c2f
commit 88b21444a7
7 changed files with 51 additions and 30 deletions

View File

@ -161,13 +161,13 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0830;
LastUpgradeCheck = 1010;
ORGANIZATIONNAME = "Vinicius Vendramini";
TargetAttributes = {
242686831C63B72A00D62456 = {
CreatedOnToolsVersion = 7.2;
DevelopmentTeam = 8J63JZYYHZ;
LastSwiftMigration = 0830;
LastSwiftMigration = 1010;
};
};
};
@ -293,14 +293,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
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_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@ -328,6 +336,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
@ -340,14 +349,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
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_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@ -368,6 +385,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
@ -383,7 +401,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = vinivendra.PixelImage;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
@ -397,7 +416,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = vinivendra.PixelImage;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Release;
};

View File

@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

View File

@ -14,7 +14,8 @@ func interpolateSquareEaseOut<T: Numeric>(_ linear: T) -> T {
}
func interpolateSmooth<T: Numeric>(_ linear: T) -> T {
return ((linear) * (linear) * (linear) * ((linear) * ((linear) * 6 - 15) + 10))
let cube = (linear) * (linear) * (linear)
return (cube * ((linear) * ((linear) * 6 - 15) + 10))
}
func createStringKeyframes(_ bounces: Int = 2, elasticity: Double = 1.1, bounceSpeed: Double) -> [(time: Double, position: Double)] {

View File

@ -8,8 +8,8 @@ class MTLContext {
init(device: MTLDevice = MTLCreateSystemDefaultDevice()!) {
self.device = device
self.library = device.newDefaultLibrary()!
self.commandQueue = device.makeCommandQueue()
self.library = device.makeDefaultLibrary()!
self.commandQueue = device.makeCommandQueue()!
}
}

View File

@ -49,11 +49,11 @@ import ChameleonFramework
let texture1 =
context.device.makeTexture(descriptor: textureDescriptor)
activeComputeContext = MTLComputeContext(size: targetView.size,
texture: texture1)
texture: texture1!)
let texture2 =
context.device.makeTexture(descriptor: textureDescriptor)
idleComputeContext = MTLComputeContext(size: targetView.size,
texture: texture2)
texture: texture2!)
}
internal func updateTargetView() {
@ -111,19 +111,19 @@ import ChameleonFramework
// Send commands to metal and render
let commandBuffer = context.commandQueue.makeCommandBuffer()
let commandEncoder = commandBuffer.makeComputeCommandEncoder()
commandEncoder.setComputePipelineState(pipeline)
commandEncoder.setTexture(computeContext.texture, at: 0)
let commandEncoder = commandBuffer!.makeComputeCommandEncoder()
commandEncoder!.setComputePipelineState(pipeline)
commandEncoder!.setTexture(computeContext.texture, index: 0)
let metaballInfoBuffer = metaballBuffer()
commandEncoder.setBuffer(metaballInfoBuffer, offset: 0, at: 0)
commandEncoder!.setBuffer(metaballInfoBuffer, offset: 0, index: 0)
let edgesBuffer = metaballEdgesBuffer()
commandEncoder.setBuffer(edgesBuffer, offset: 0, at: 1)
commandEncoder.dispatchThreadgroups(threadGroups,
commandEncoder!.setBuffer(edgesBuffer, offset: 0, index: 1)
commandEncoder!.dispatchThreadgroups(threadGroups,
threadsPerThreadgroup: threadGroupCounts)
commandEncoder.endEncoding()
commandEncoder!.endEncoding()
commandBuffer.commit()
commandBuffer.waitUntilCompleted()
commandBuffer!.commit()
commandBuffer!.waitUntilCompleted()
} catch _ {
assertionFailure()
}
@ -186,7 +186,7 @@ import ChameleonFramework
length: bufferLength,
options: MTLResourceOptions())
return buffer
return buffer!
}
internal func metaballBuffer() -> MTLBuffer {
@ -228,6 +228,6 @@ import ChameleonFramework
length: bufferLength,
options: MTLResourceOptions())
return buffer
return buffer!
}
}

View File

@ -7,10 +7,10 @@ protocol DoubleValuable {
protocol Numeric: DoubleValuable, Comparable,
ExpressibleByIntegerLiteral {
@warn_unused_result func / (lhs: Self, rhs: Self) -> Self
@warn_unused_result func - (lhs: Self, rhs: Self) -> Self
@warn_unused_result func + (lhs: Self, rhs: Self) -> Self
@warn_unused_result func * (lhs: Self, rhs: Self) -> Self
static func / (lhs: Self, rhs: Self) -> Self
static func - (lhs: Self, rhs: Self) -> Self
static func + (lhs: Self, rhs: Self) -> Self
static func * (lhs: Self, rhs: Self) -> Self
}
protocol FastNumeric: Numeric {}

View File

@ -80,7 +80,7 @@ class ViewController: UIViewController, MetaballDataSource {
delay(4) {
for i in 1...5 {
UIView.animate(withDuration: 1.0, delay: 0,
options: UIViewAnimationOptions(),
options: UIView.AnimationOptions(),
animations: { () -> Void in
let sine = sin(Double(i) * 2 * .pi / 5)
let cosine = cos(Double(i) * 2 * .pi / 5)
@ -98,7 +98,7 @@ class ViewController: UIViewController, MetaballDataSource {
UIView.animate(withDuration: 1.0, delay: 0,
usingSpringWithDamping: 0.5,
initialSpringVelocity: 0,
options: UIViewAnimationOptions(),
options: UIView.AnimationOptions(),
animations: { () -> Void in
let sine = sin(Double(i) * 2 * .pi / 5)
let cosine = cos(Double(i) * 2 * .pi / 5)
@ -136,7 +136,7 @@ class ViewController: UIViewController, MetaballDataSource {
repeats: true)
}
func animateMetaball(withTimer timer: Timer) {
@objc func animateMetaball(withTimer timer: Timer) {
guard let userInfo = timer.userInfo as? VertexAnimationParameters else {
preconditionFailure()
}
@ -174,7 +174,7 @@ class ViewController: UIViewController, MetaballDataSource {
repeats: true)
}
func animateEdge(withTimer timer: Timer) {
@objc func animateEdge(withTimer timer: Timer) {
guard let userInfo = timer.userInfo as? EdgeAnimationParameters else {
preconditionFailure()
}
@ -199,7 +199,7 @@ class ViewController: UIViewController, MetaballDataSource {
renderer.state = .running
}
func handlePan(_ recognizer: UIPanGestureRecognizer) {
@objc func handlePan(_ recognizer: UIPanGestureRecognizer) {
let location = recognizer.location(in: metaballView)
if selectedMetaball == nil {