Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode 11 & Swift 5 modifications #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions Swift VectorBoolean.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0910;
LastUpgradeCheck = 1140;
ORGANIZATIONNAME = "Starside Softworks";
TargetAttributes = {
6356E1771B4CD83A00420351 = {
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
};
Expand Down Expand Up @@ -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 = "";
};
Expand All @@ -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 = "";
};
Expand Down
40 changes: 8 additions & 32 deletions Swift VectorBoolean/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}


}

2 changes: 1 addition & 1 deletion Swift VectorBoolean/OptionsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class OptionsViewController: UIViewController {
}
}

func dismissVC() {
@objc func dismissVC() {
self.dismiss(animated: true) {
self.primeVC?.popClosed()
}
Expand Down
158 changes: 79 additions & 79 deletions Swift VectorBoolean/ShapesTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

}
8 changes: 5 additions & 3 deletions Swift VectorBoolean/VectorBoolean/CGPathBridge/CGPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ typealias MyPathApplier = @convention(block) (UnsafePointer<CGPathElement>) -> 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<CGPathElement>) -> Void = { (info, element) in
let block = unsafeBitCast(info, to: MyPathApplier.self)
block(element)
Expand All @@ -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) {
Expand All @@ -51,7 +51,9 @@ public extension CGPath {

case .closeSubpath:
fn(.close)
}
@unknown default:
fatalError("unhandled case of PathElement")
}
}
}
}
4 changes: 2 additions & 2 deletions Swift VectorBoolean/VectorBoolean/FBBezierCurve.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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
Expand Down