diff --git a/Swift VectorBoolean.xcodeproj/project.pbxproj b/Swift VectorBoolean.xcodeproj/project.pbxproj index bae5bae..550c4b5 100644 --- a/Swift VectorBoolean.xcodeproj/project.pbxproj +++ b/Swift VectorBoolean.xcodeproj/project.pbxproj @@ -336,7 +336,7 @@ attributes = { LastSwiftMigration = 0700; LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0910; + LastUpgradeCheck = 1140; ORGANIZATIONNAME = "Starside Softworks"; TargetAttributes = { 6356E1771B4CD83A00420351 = { @@ -360,7 +360,7 @@ }; buildConfigurationList = 6356E1731B4CD83A00420351 /* Build configuration list for PBXProject "Swift VectorBoolean" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -508,6 +508,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -516,12 +517,14 @@ 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; @@ -549,12 +552,12 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0.1; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -563,6 +566,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -571,12 +575,14 @@ 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; @@ -597,11 +603,11 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.4; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0.1; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -691,7 +697,6 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 3.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -717,7 +722,6 @@ PRODUCT_BUNDLE_IDENTIFIER = com.moke.VectorBoolean; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; diff --git a/Swift VectorBoolean/AppDelegate.swift b/Swift VectorBoolean/AppDelegate.swift index 6aad9df..01f7941 100644 --- a/Swift VectorBoolean/AppDelegate.swift +++ b/Swift VectorBoolean/AppDelegate.swift @@ -10,37 +10,13 @@ import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { - - var window: UIWindow? - - - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { - // Override point for customization after application launch. - return true - } - - func applicationWillResignActive(_ application: UIApplication) { - // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. - } - - func applicationDidEnterBackground(_ application: UIApplication) { - // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. - // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. - } - - func applicationWillEnterForeground(_ application: UIApplication) { - // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. - } - - func applicationDidBecomeActive(_ application: UIApplication) { - // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. - } - - func applicationWillTerminate(_ application: UIApplication) { - // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. - } - - + + var window: UIWindow? + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { + return true + } + + } diff --git a/Swift VectorBoolean/OptionsViewController.swift b/Swift VectorBoolean/OptionsViewController.swift index 0c00719..51cb633 100644 --- a/Swift VectorBoolean/OptionsViewController.swift +++ b/Swift VectorBoolean/OptionsViewController.swift @@ -60,7 +60,7 @@ class OptionsViewController: UIViewController { } } - func dismissVC() { + @objc func dismissVC() { self.dismiss(animated: true) { self.primeVC?.popClosed() } diff --git a/Swift VectorBoolean/ShapesTableViewController.swift b/Swift VectorBoolean/ShapesTableViewController.swift index 64d65a0..75c05c5 100644 --- a/Swift VectorBoolean/ShapesTableViewController.swift +++ b/Swift VectorBoolean/ShapesTableViewController.swift @@ -9,89 +9,89 @@ import UIKit class ShapesTableViewController: UITableViewController { - - var shapeData : TestShapeData? - var primeVC : ViewController? - var currentSelection : Int = 0 - - override func viewDidLoad() { - super.viewDidLoad() - - let wantCancelButtonOnPhone = true - // NOTE: The cancel button makes it easier to dismiss the list. - - if wantCancelButtonOnPhone && UI_USER_INTERFACE_IDIOM() != .pad { - navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Cancel", - style: .plain, - target: self, - action: #selector(ShapesTableViewController.dismissVC)) + + var shapeData : TestShapeData? + var primeVC : ViewController? + var currentSelection : Int = 0 + + override func viewDidLoad() { + super.viewDidLoad() + + let wantCancelButtonOnPhone = true + // NOTE: The cancel button makes it easier to dismiss the list. + + if wantCancelButtonOnPhone && UI_USER_INTERFACE_IDIOM() != .pad { + navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Cancel", + style: .plain, + target: self, + action: #selector(ShapesTableViewController.dismissVC)) + } + + // Uncomment the following line to preserve selection between presentations + self.clearsSelectionOnViewWillAppear = false + + // Uncomment the following line to display an Edit button in the navigation bar for this view controller. + // self.navigationItem.rightBarButtonItem = self.editButtonItem() } - - // Uncomment the following line to preserve selection between presentations - self.clearsSelectionOnViewWillAppear = false - - // Uncomment the following line to display an Edit button in the navigation bar for this view controller. - // self.navigationItem.rightBarButtonItem = self.editButtonItem() - } - - override func viewWillAppear(_ animated: Bool) { - tableView.selectRow(at: IndexPath(item: currentSelection, section: 0), animated: true, scrollPosition: UITableViewScrollPosition.middle) - } - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. - } - - - func dismissVC() { - self.dismiss(animated: true) { - self.primeVC?.popClosed() + + override func viewWillAppear(_ animated: Bool) { + tableView.selectRow(at: IndexPath(item: currentSelection, section: 0), animated: true, scrollPosition: .middle) } - } - - // MARK: - Table view data source - - override func numberOfSections(in tableView: UITableView) -> Int { - return 1 - } - - override func tableView(_ _tableView: UITableView, titleForHeaderInSection section: Int) -> String? { - return nil - } - - override func tableView(_ _tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - if let shapeData = shapeData { - return shapeData.count + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. } - return 19 - } - - override func tableView (_ _tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - - let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "testShapeCell") - if let shapeData = shapeData { - let testShape = shapeData.shapes[indexPath.row] - cell.textLabel!.text = testShape.label - } else { - cell.textLabel!.text = "Broken \(indexPath.row)" + + + @objc func dismissVC() { + self.dismiss(animated: true) { + self.primeVC?.popClosed() + } } - if indexPath.row == currentSelection { - cell.accessoryType = UITableViewCellAccessoryType.checkmark + + // MARK: - Table view data source + + override func numberOfSections(in tableView: UITableView) -> Int { + return 1 } - return cell - } - - // MARK: Table View Selection - - override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - - if let primeVC = primeVC { - primeVC.currentShapesetIndex = indexPath.row - primeVC.updateCanvas() + + override func tableView(_ _tableView: UITableView, titleForHeaderInSection section: Int) -> String? { + return nil } - - dismissVC() - } - + + override func tableView(_ _tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + if let shapeData = shapeData { + return shapeData.count + } + return 19 + } + + override func tableView (_ _tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + + let cell = UITableViewCell(style: .default, reuseIdentifier: "testShapeCell") + if let shapeData = shapeData { + let testShape = shapeData.shapes[indexPath.row] + cell.textLabel!.text = testShape.label + } else { + cell.textLabel!.text = "Broken \(indexPath.row)" + } + if indexPath.row == currentSelection { + cell.accessoryType = .checkmark + } + return cell + } + + // MARK: Table View Selection + + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + + if let primeVC = primeVC { + primeVC.currentShapesetIndex = indexPath.row + primeVC.updateCanvas() + } + + dismissVC() + } + } diff --git a/Swift VectorBoolean/VectorBoolean/CGPathBridge/CGPath.swift b/Swift VectorBoolean/VectorBoolean/CGPathBridge/CGPath.swift index 7d6e3e3..c9ab86f 100644 --- a/Swift VectorBoolean/VectorBoolean/CGPathBridge/CGPath.swift +++ b/Swift VectorBoolean/VectorBoolean/CGPathBridge/CGPath.swift @@ -13,7 +13,7 @@ typealias MyPathApplier = @convention(block) (UnsafePointer) -> V // if you don't, you get "fatal error: can't unsafeBitCast between // types of different sizes" at runtime, on Mac OS X at least. -private func myPathApply(_ path: CGPath!, block: MyPathApplier) { +private func myPathApply(_ path: CGPath!, block: @escaping MyPathApplier) { let callback: @convention(c) (UnsafeMutableRawPointer, UnsafePointer) -> Void = { (info, element) in let block = unsafeBitCast(info, to: MyPathApplier.self) block(element) @@ -32,7 +32,7 @@ public enum PathElement { public extension CGPath { - func apply(_ fn: (PathElement) -> Void) { + func apply(_ fn: @escaping (PathElement) -> Void) { myPathApply(self) { element in let points = element.pointee.points switch (element.pointee.type) { @@ -51,7 +51,9 @@ public extension CGPath { case .closeSubpath: fn(.close) - } + @unknown default: + fatalError("unhandled case of PathElement") + } } } } diff --git a/Swift VectorBoolean/VectorBoolean/FBBezierCurve.swift b/Swift VectorBoolean/VectorBoolean/FBBezierCurve.swift index 517a202..3b3feaa 100644 --- a/Swift VectorBoolean/VectorBoolean/FBBezierCurve.swift +++ b/Swift VectorBoolean/VectorBoolean/FBBezierCurve.swift @@ -939,7 +939,7 @@ class FBBezierCurveData { //static void FBBezierCurveDataConvertSelfAndPoint(FBBezierCurveData me, NSPoint point, NSPoint *bezierPoints) func convertSelfAndPoint(_ point: CGPoint) -> [CGPoint] { - var selfPoints: [CGPoint] = [endPoint1, controlPoint1, controlPoint2, endPoint2] + let selfPoints: [CGPoint] = [endPoint1, controlPoint1, controlPoint2, endPoint2] // c[i] in the paper let distanceFromPoint = [ @@ -1453,7 +1453,7 @@ private func pfRefineParameter(_ me: FBBezierCurveData, parameter: Double, point // f'(parameter) = (Q(parameter) - point) * Q''(parameter) + Q'(parameter) * Q'(parameter) // - var bezierPoints: [CGPoint] = [me.endPoint1, me.controlPoint1, me.controlPoint2, me.endPoint2] + let bezierPoints: [CGPoint] = [me.endPoint1, me.controlPoint1, me.controlPoint2, me.endPoint2] // Compute Q(parameter) let qAtParameter = BezierWithPoints(3, bezierPoints: bezierPoints, parameter: parameter, withCurves: false).point