Browse Source

initial operator overload experiment

Jonas Budelmann 11 years ago
commit
afb20a778f

+ 423 - 0
ExpressiveLayout.xcodeproj/project.pbxproj

@@ -0,0 +1,423 @@
+// !$*UTF8*$!
+{
+	archiveVersion = 1;
+	classes = {
+	};
+	objectVersion = 46;
+	objects = {
+
+/* Begin PBXBuildFile section */
+		DDCE87541940224E0015932A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDCE87531940224E0015932A /* AppDelegate.swift */; };
+		DDCE87561940224E0015932A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DDCE87551940224E0015932A /* Images.xcassets */; };
+		DDCE87621940224E0015932A /* ExpressiveLayoutTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDCE87611940224E0015932A /* ExpressiveLayoutTests.swift */; };
+		DDCE876C194022820015932A /* RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDCE876B194022820015932A /* RootViewController.swift */; };
+		DDCE876F194025400015932A /* SingleConstraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDCE876E194025400015932A /* SingleConstraint.swift */; };
+		DDCE8771194025C40015932A /* CompositeConstraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDCE8770194025C40015932A /* CompositeConstraint.swift */; };
+		DDCE8773194026370015932A /* Operators.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDCE8772194026370015932A /* Operators.swift */; };
+		DDCE87751940290A0015932A /* Constraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDCE87741940290A0015932A /* Constraint.swift */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXContainerItemProxy section */
+		DDCE875C1940224E0015932A /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = DDCE87461940224E0015932A /* Project object */;
+			proxyType = 1;
+			remoteGlobalIDString = DDCE874D1940224E0015932A;
+			remoteInfo = ExpressiveLayout;
+		};
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXFileReference section */
+		DDCE874E1940224E0015932A /* ExpressiveLayout.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ExpressiveLayout.app; sourceTree = BUILT_PRODUCTS_DIR; };
+		DDCE87521940224E0015932A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+		DDCE87531940224E0015932A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
+		DDCE87551940224E0015932A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
+		DDCE875B1940224E0015932A /* ExpressiveLayoutTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ExpressiveLayoutTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
+		DDCE87601940224E0015932A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+		DDCE87611940224E0015932A /* ExpressiveLayoutTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExpressiveLayoutTests.swift; sourceTree = "<group>"; };
+		DDCE876B194022820015932A /* RootViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RootViewController.swift; sourceTree = "<group>"; };
+		DDCE876E194025400015932A /* SingleConstraint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SingleConstraint.swift; sourceTree = "<group>"; };
+		DDCE8770194025C40015932A /* CompositeConstraint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CompositeConstraint.swift; sourceTree = "<group>"; };
+		DDCE8772194026370015932A /* Operators.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Operators.swift; sourceTree = "<group>"; };
+		DDCE87741940290A0015932A /* Constraint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constraint.swift; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+		DDCE874B1940224E0015932A /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		DDCE87581940224E0015932A /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+		DDCE87451940224E0015932A = {
+			isa = PBXGroup;
+			children = (
+				DDCE876D1940228D0015932A /* ExpressiveLayout */,
+				DDCE87501940224E0015932A /* Examples */,
+				DDCE875E1940224E0015932A /* ExpressiveLayoutTests */,
+				DDCE874F1940224E0015932A /* Products */,
+			);
+			sourceTree = "<group>";
+		};
+		DDCE874F1940224E0015932A /* Products */ = {
+			isa = PBXGroup;
+			children = (
+				DDCE874E1940224E0015932A /* ExpressiveLayout.app */,
+				DDCE875B1940224E0015932A /* ExpressiveLayoutTests.xctest */,
+			);
+			name = Products;
+			sourceTree = "<group>";
+		};
+		DDCE87501940224E0015932A /* Examples */ = {
+			isa = PBXGroup;
+			children = (
+				DDCE87531940224E0015932A /* AppDelegate.swift */,
+				DDCE876B194022820015932A /* RootViewController.swift */,
+				DDCE87551940224E0015932A /* Images.xcassets */,
+				DDCE87511940224E0015932A /* Supporting Files */,
+			);
+			name = Examples;
+			path = ExpressiveLayout;
+			sourceTree = "<group>";
+		};
+		DDCE87511940224E0015932A /* Supporting Files */ = {
+			isa = PBXGroup;
+			children = (
+				DDCE87521940224E0015932A /* Info.plist */,
+			);
+			name = "Supporting Files";
+			sourceTree = "<group>";
+		};
+		DDCE875E1940224E0015932A /* ExpressiveLayoutTests */ = {
+			isa = PBXGroup;
+			children = (
+				DDCE87611940224E0015932A /* ExpressiveLayoutTests.swift */,
+				DDCE875F1940224E0015932A /* Supporting Files */,
+			);
+			path = ExpressiveLayoutTests;
+			sourceTree = "<group>";
+		};
+		DDCE875F1940224E0015932A /* Supporting Files */ = {
+			isa = PBXGroup;
+			children = (
+				DDCE87601940224E0015932A /* Info.plist */,
+			);
+			name = "Supporting Files";
+			sourceTree = "<group>";
+		};
+		DDCE876D1940228D0015932A /* ExpressiveLayout */ = {
+			isa = PBXGroup;
+			children = (
+				DDCE87741940290A0015932A /* Constraint.swift */,
+				DDCE876E194025400015932A /* SingleConstraint.swift */,
+				DDCE8770194025C40015932A /* CompositeConstraint.swift */,
+				DDCE8772194026370015932A /* Operators.swift */,
+			);
+			path = ExpressiveLayout;
+			sourceTree = "<group>";
+		};
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+		DDCE874D1940224E0015932A /* ExpressiveLayout */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = DDCE87651940224E0015932A /* Build configuration list for PBXNativeTarget "ExpressiveLayout" */;
+			buildPhases = (
+				DDCE874A1940224E0015932A /* Sources */,
+				DDCE874B1940224E0015932A /* Frameworks */,
+				DDCE874C1940224E0015932A /* Resources */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = ExpressiveLayout;
+			productName = ExpressiveLayout;
+			productReference = DDCE874E1940224E0015932A /* ExpressiveLayout.app */;
+			productType = "com.apple.product-type.application";
+		};
+		DDCE875A1940224E0015932A /* ExpressiveLayoutTests */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = DDCE87681940224E0015932A /* Build configuration list for PBXNativeTarget "ExpressiveLayoutTests" */;
+			buildPhases = (
+				DDCE87571940224E0015932A /* Sources */,
+				DDCE87581940224E0015932A /* Frameworks */,
+				DDCE87591940224E0015932A /* Resources */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+				DDCE875D1940224E0015932A /* PBXTargetDependency */,
+			);
+			name = ExpressiveLayoutTests;
+			productName = ExpressiveLayoutTests;
+			productReference = DDCE875B1940224E0015932A /* ExpressiveLayoutTests.xctest */;
+			productType = "com.apple.product-type.bundle.unit-test";
+		};
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+		DDCE87461940224E0015932A /* Project object */ = {
+			isa = PBXProject;
+			attributes = {
+				LastUpgradeCheck = 0600;
+				ORGANIZATIONNAME = "Jonas Budelmann";
+				TargetAttributes = {
+					DDCE874D1940224E0015932A = {
+						CreatedOnToolsVersion = 6.0;
+					};
+					DDCE875A1940224E0015932A = {
+						CreatedOnToolsVersion = 6.0;
+						TestTargetID = DDCE874D1940224E0015932A;
+					};
+				};
+			};
+			buildConfigurationList = DDCE87491940224E0015932A /* Build configuration list for PBXProject "ExpressiveLayout" */;
+			compatibilityVersion = "Xcode 3.2";
+			developmentRegion = English;
+			hasScannedForEncodings = 0;
+			knownRegions = (
+				en,
+			);
+			mainGroup = DDCE87451940224E0015932A;
+			productRefGroup = DDCE874F1940224E0015932A /* Products */;
+			projectDirPath = "";
+			projectRoot = "";
+			targets = (
+				DDCE874D1940224E0015932A /* ExpressiveLayout */,
+				DDCE875A1940224E0015932A /* ExpressiveLayoutTests */,
+			);
+		};
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+		DDCE874C1940224E0015932A /* Resources */ = {
+			isa = PBXResourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				DDCE87561940224E0015932A /* Images.xcassets in Resources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		DDCE87591940224E0015932A /* Resources */ = {
+			isa = PBXResourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+		DDCE874A1940224E0015932A /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				DDCE87751940290A0015932A /* Constraint.swift in Sources */,
+				DDCE8771194025C40015932A /* CompositeConstraint.swift in Sources */,
+				DDCE8773194026370015932A /* Operators.swift in Sources */,
+				DDCE876F194025400015932A /* SingleConstraint.swift in Sources */,
+				DDCE876C194022820015932A /* RootViewController.swift in Sources */,
+				DDCE87541940224E0015932A /* AppDelegate.swift in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+		DDCE87571940224E0015932A /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				DDCE87621940224E0015932A /* ExpressiveLayoutTests.swift in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXTargetDependency section */
+		DDCE875D1940224E0015932A /* PBXTargetDependency */ = {
+			isa = PBXTargetDependency;
+			target = DDCE874D1940224E0015932A /* ExpressiveLayout */;
+			targetProxy = DDCE875C1940224E0015932A /* PBXContainerItemProxy */;
+		};
+/* End PBXTargetDependency section */
+
+/* Begin XCBuildConfiguration section */
+		DDCE87631940224E0015932A /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+				CLANG_CXX_LIBRARY = "libc++";
+				CLANG_ENABLE_MODULES = YES;
+				CLANG_ENABLE_OBJC_ARC = YES;
+				CLANG_WARN_BOOL_CONVERSION = YES;
+				CLANG_WARN_CONSTANT_CONVERSION = YES;
+				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+				CLANG_WARN_EMPTY_BODY = YES;
+				CLANG_WARN_ENUM_CONVERSION = YES;
+				CLANG_WARN_INT_CONVERSION = YES;
+				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+				CLANG_WARN_UNREACHABLE_CODE = YES;
+				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+				COPY_PHASE_STRIP = NO;
+				ENABLE_STRICT_OBJC_MSGSEND = YES;
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					"DEBUG=1",
+					"$(inherited)",
+				);
+				GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+				GCC_WARN_UNDECLARED_SELECTOR = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+				GCC_WARN_UNUSED_FUNCTION = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				IPHONEOS_DEPLOYMENT_TARGET = 8.0;
+				METAL_ENABLE_DEBUG_INFO = YES;
+				ONLY_ACTIVE_ARCH = YES;
+				SDKROOT = iphoneos;
+				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+				TARGETED_DEVICE_FAMILY = "1,2";
+			};
+			name = Debug;
+		};
+		DDCE87641940224E0015932A /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+				CLANG_CXX_LIBRARY = "libc++";
+				CLANG_ENABLE_MODULES = YES;
+				CLANG_ENABLE_OBJC_ARC = YES;
+				CLANG_WARN_BOOL_CONVERSION = YES;
+				CLANG_WARN_CONSTANT_CONVERSION = YES;
+				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+				CLANG_WARN_EMPTY_BODY = YES;
+				CLANG_WARN_ENUM_CONVERSION = YES;
+				CLANG_WARN_INT_CONVERSION = YES;
+				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+				CLANG_WARN_UNREACHABLE_CODE = YES;
+				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+				COPY_PHASE_STRIP = YES;
+				ENABLE_NS_ASSERTIONS = NO;
+				ENABLE_STRICT_OBJC_MSGSEND = YES;
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+				GCC_WARN_UNDECLARED_SELECTOR = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+				GCC_WARN_UNUSED_FUNCTION = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				IPHONEOS_DEPLOYMENT_TARGET = 8.0;
+				METAL_ENABLE_DEBUG_INFO = NO;
+				SDKROOT = iphoneos;
+				TARGETED_DEVICE_FAMILY = "1,2";
+				VALIDATE_PRODUCT = YES;
+			};
+			name = Release;
+		};
+		DDCE87661940224E0015932A /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+				ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
+				INFOPLIST_FILE = ExpressiveLayout/Info.plist;
+				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+				PRODUCT_NAME = "$(TARGET_NAME)";
+			};
+			name = Debug;
+		};
+		DDCE87671940224E0015932A /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+				ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
+				INFOPLIST_FILE = ExpressiveLayout/Info.plist;
+				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+				PRODUCT_NAME = "$(TARGET_NAME)";
+			};
+			name = Release;
+		};
+		DDCE87691940224E0015932A /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/ExpressiveLayout.app/ExpressiveLayout";
+				FRAMEWORK_SEARCH_PATHS = (
+					"$(SDKROOT)/Developer/Library/Frameworks",
+					"$(inherited)",
+				);
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					"DEBUG=1",
+					"$(inherited)",
+				);
+				INFOPLIST_FILE = ExpressiveLayoutTests/Info.plist;
+				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+				METAL_ENABLE_DEBUG_INFO = YES;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				TEST_HOST = "$(BUNDLE_LOADER)";
+			};
+			name = Debug;
+		};
+		DDCE876A1940224E0015932A /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/ExpressiveLayout.app/ExpressiveLayout";
+				FRAMEWORK_SEARCH_PATHS = (
+					"$(SDKROOT)/Developer/Library/Frameworks",
+					"$(inherited)",
+				);
+				INFOPLIST_FILE = ExpressiveLayoutTests/Info.plist;
+				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+				METAL_ENABLE_DEBUG_INFO = NO;
+				PRODUCT_NAME = "$(TARGET_NAME)";
+				TEST_HOST = "$(BUNDLE_LOADER)";
+			};
+			name = Release;
+		};
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+		DDCE87491940224E0015932A /* Build configuration list for PBXProject "ExpressiveLayout" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				DDCE87631940224E0015932A /* Debug */,
+				DDCE87641940224E0015932A /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		DDCE87651940224E0015932A /* Build configuration list for PBXNativeTarget "ExpressiveLayout" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				DDCE87661940224E0015932A /* Debug */,
+				DDCE87671940224E0015932A /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+		};
+		DDCE87681940224E0015932A /* Build configuration list for PBXNativeTarget "ExpressiveLayoutTests" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				DDCE87691940224E0015932A /* Debug */,
+				DDCE876A1940224E0015932A /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+		};
+/* End XCConfigurationList section */
+	};
+	rootObject = DDCE87461940224E0015932A /* Project object */;
+}

+ 7 - 0
ExpressiveLayout.xcodeproj/project.xcworkspace/contents.xcworkspacedata

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+   version = "1.0">
+   <FileRef
+      location = "self:ExpressiveLayout.xcodeproj">
+   </FileRef>
+</Workspace>

+ 28 - 0
ExpressiveLayout/AppDelegate.swift

@@ -0,0 +1,28 @@
+//
+//  AppDelegate.swift
+//  ExpressiveLayout
+//
+//  Created by Jonas Budelmann on 5/06/14.
+//  Copyright (c) 2014 Jonas Budelmann. All rights reserved.
+//
+
+import UIKit
+
+@UIApplicationMain
+class AppDelegate: UIResponder, UIApplicationDelegate {
+                            
+    var window: UIWindow?
+
+    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
+        self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
+        // Override point for customization after application launch.
+        
+        let navigationController = UINavigationController(rootViewController: RootViewController())
+        self.window!.rootViewController = navigationController
+        
+        self.window!.backgroundColor = UIColor.whiteColor()
+        self.window!.makeKeyAndVisible()
+        return true
+    }
+}
+

+ 10 - 0
ExpressiveLayout/CompositeConstraint.swift

@@ -0,0 +1,10 @@
+//
+//  CompositeConstraint.swift
+//  ExpressiveLayout
+//
+//  Created by Jonas Budelmann on 5/06/14.
+//  Copyright (c) 2014 Jonas Budelmann. All rights reserved.
+//
+
+import Foundation
+

+ 14 - 0
ExpressiveLayout/Constraint.swift

@@ -0,0 +1,14 @@
+//
+//  Constraint.swift
+//  ExpressiveLayout
+//
+//  Created by Jonas Budelmann on 5/06/14.
+//  Copyright (c) 2014 Jonas Budelmann. All rights reserved.
+//
+
+import Foundation
+
+protocol Constraint {
+    func add(other: Any) -> Constraint
+    func equalTo(other: Any) -> Constraint
+}

+ 53 - 0
ExpressiveLayout/Images.xcassets/AppIcon.appiconset/Contents.json

@@ -0,0 +1,53 @@
+{
+  "images" : [
+    {
+      "idiom" : "iphone",
+      "size" : "29x29",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "iphone",
+      "size" : "40x40",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "iphone",
+      "size" : "60x60",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "ipad",
+      "size" : "29x29",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "ipad",
+      "size" : "29x29",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "ipad",
+      "size" : "40x40",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "ipad",
+      "size" : "40x40",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "ipad",
+      "size" : "76x76",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "ipad",
+      "size" : "76x76",
+      "scale" : "2x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

+ 51 - 0
ExpressiveLayout/Images.xcassets/LaunchImage.launchimage/Contents.json

@@ -0,0 +1,51 @@
+{
+  "images" : [
+    {
+      "orientation" : "portrait",
+      "idiom" : "iphone",
+      "extent" : "full-screen",
+      "minimum-system-version" : "7.0",
+      "scale" : "2x"
+    },
+    {
+      "orientation" : "portrait",
+      "idiom" : "iphone",
+      "subtype" : "retina4",
+      "extent" : "full-screen",
+      "minimum-system-version" : "7.0",
+      "scale" : "2x"
+    },
+    {
+      "orientation" : "portrait",
+      "idiom" : "ipad",
+      "extent" : "full-screen",
+      "minimum-system-version" : "7.0",
+      "scale" : "1x"
+    },
+    {
+      "orientation" : "landscape",
+      "idiom" : "ipad",
+      "extent" : "full-screen",
+      "minimum-system-version" : "7.0",
+      "scale" : "1x"
+    },
+    {
+      "orientation" : "portrait",
+      "idiom" : "ipad",
+      "extent" : "full-screen",
+      "minimum-system-version" : "7.0",
+      "scale" : "2x"
+    },
+    {
+      "orientation" : "landscape",
+      "idiom" : "ipad",
+      "extent" : "full-screen",
+      "minimum-system-version" : "7.0",
+      "scale" : "2x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

+ 30 - 0
ExpressiveLayout/Info.plist

@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>en</string>
+	<key>CFBundleExecutable</key>
+	<string>${EXECUTABLE_NAME}</string>
+	<key>CFBundleIdentifier</key>
+	<string>com.cloudling.${PRODUCT_NAME:rfc1034identifier}</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>${PRODUCT_NAME}</string>
+	<key>CFBundlePackageType</key>
+	<string>APPL</string>
+	<key>CFBundleShortVersionString</key>
+	<string>1.0</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>1</string>
+	<key>LSRequiresIPhoneOS</key>
+	<true/>
+	<key>UIRequiredDeviceCapabilities</key>
+	<array>
+		<string>armv7</string>
+	</array>
+</dict>
+</plist>

+ 52 - 0
ExpressiveLayout/Operators.swift

@@ -0,0 +1,52 @@
+//
+//  Operators.swift
+//  ExpressiveLayout
+//
+//  Created by Jonas Budelmann on 5/06/14.
+//  Copyright (c) 2014 Jonas Budelmann. All rights reserved.
+//
+
+import UIKit
+
+//TODO spilt into different files
+
+enum ViewLayoutAttribute {
+    case CenterX
+    case CenterY
+    case Left
+    case Right
+    case Top
+    case Bottom
+    case Width
+    case Height
+}
+
+class ViewAttribute {
+    weak var view: UIView?
+    let attribute: ViewLayoutAttribute
+    
+    init(view: UIView, attribute: ViewLayoutAttribute) {
+        self.view = view
+        self.attribute = attribute
+    }
+}
+
+@infix func + (left: Constraint, right: Any) -> Constraint {
+    return left.add(right);
+}
+
+@infix func == (left: Constraint, right: Any) -> Constraint {
+    return left.equalTo(right);
+}
+
+func installConstraints(constraints: Array<Constraint>) {
+    // find common superview
+    // create NSLayoutConstraint
+}
+
+extension UIView {
+    var left: Constraint { return SingleConstraint(view: self, attribute: .Left) }
+    var right: Constraint { return SingleConstraint(view: self, attribute: .Right) }
+    var top: Constraint { return SingleConstraint(view: self, attribute: .Top) }
+    var bottom: Constraint { return SingleConstraint(view: self, attribute: .Bottom) }
+}

+ 74 - 0
ExpressiveLayout/RootViewController.swift

@@ -0,0 +1,74 @@
+//
+//  RootViewController.swift
+//  ExpressiveLayout
+//
+//  Created by Jonas Budelmann on 5/06/14.
+//  Copyright (c) 2014 Jonas Budelmann. All rights reserved.
+//
+
+import UIKit
+
+class RootViewController : UIViewController {
+    
+    override func viewDidLoad() {
+        self.view.backgroundColor = UIColor.whiteColor()
+        
+        let superview = self.view
+        
+        let view1 = UIView()
+        view1.backgroundColor = UIColor.greenColor()
+        view1.layer.borderColor = UIColor.blackColor().CGColor
+        view1.layer.borderWidth = 2
+        superview.addSubview(view1)
+        
+        let view2 = UIView()
+        view2.backgroundColor = UIColor.redColor()
+        view2.layer.borderColor = UIColor.blackColor().CGColor
+        view2.layer.borderWidth = 2
+        superview.addSubview(view2)
+        
+        let view3 = UIView()
+        view3.backgroundColor = UIColor.blueColor()
+        view3.layer.borderColor = UIColor.blackColor().CGColor
+        view3.layer.borderWidth = 2
+        superview.addSubview(view3)
+        
+        var padding = 10;
+        
+        installConstraints([
+            view1.left == superview.left + padding
+        ])
+        
+//        //if you want to use Masonry without the mas_ prefix
+//        //define MAS_SHORTHAND before importing Masonry.h see Masonry iOS Examples-Prefix.pch
+//        [view1 makeConstraints:^(MASConstraintMaker *make) {
+//        make.top.greaterThanOrEqualTo(superview.top).offset(padding);
+//        make.left.equalTo(superview.left).offset(padding);
+//        make.bottom.equalTo(view3.top).offset(-padding);
+//        make.right.equalTo(view2.left).offset(-padding);
+//        make.width.equalTo(view2.width);
+//        
+//        make.height.equalTo(view2.height);
+//        make.height.equalTo(view3.height);
+//        }];
+//        
+//        //with is semantic and option
+//        [view2 mas_makeConstraints:^(MASConstraintMaker *make) {
+//        make.top.equalTo(superview.mas_top).with.offset(padding); //with with
+//        make.left.equalTo(view1.mas_right).offset(padding); //without with
+//        make.bottom.equalTo(view3.mas_top).offset(-padding);
+//        make.right.equalTo(superview.mas_right).offset(-padding);
+//        make.width.equalTo(view1.mas_width);
+//        
+//        make.height.equalTo(@[view1, view3]); //can pass array of views
+//        }];
+//        
+//        [view3 mas_makeConstraints:^(MASConstraintMaker *make) {
+//        make.top.equalTo(view1.mas_bottom).offset(padding);
+//        make.left.equalTo(superview.mas_left).offset(padding);
+//        make.bottom.equalTo(superview.mas_bottom).offset(-padding);
+//        make.right.equalTo(superview.mas_right).offset(-padding);
+//        make.height.equalTo(@[view1.mas_height, view2.mas_height]); //can pass array of attributes
+//        }];
+    }
+}

+ 44 - 0
ExpressiveLayout/SingleConstraint.swift

@@ -0,0 +1,44 @@
+//
+//  ViewConstraint.swift
+//  ExpressiveLayout
+//
+//  Created by Jonas Budelmann on 5/06/14.
+//  Copyright (c) 2014 Jonas Budelmann. All rights reserved.
+//
+
+import UIKit
+
+class SingleConstraint : Constraint {
+    
+    var firstViewAttribute: ViewAttribute
+    var secondViewAttribute: ViewAttribute?
+    var layoutConstant: Double = 0
+    
+    init(view: UIView, attribute: ViewLayoutAttribute) {
+        firstViewAttribute = ViewAttribute(view: view, attribute: attribute)
+    }
+    
+    func add(other: Any) -> Constraint {
+        switch other {
+        case let offset as Double:
+            layoutConstant += offset;
+        case let constraint as SingleConstraint:
+            println("TODO add to \(constraint)")
+        default:
+            println("unsupported value: \(other)")
+        }
+        return self;
+    }
+    
+    func equalTo(other: Any) -> Constraint {
+        switch other {
+        case let offset as Double:
+            layoutConstant = offset;
+        case let constraint as SingleConstraint:
+            self.secondViewAttribute = constraint.firstViewAttribute;
+        default:
+            println("unsupported value: \(other)")
+        }
+        return self;
+    }
+}

+ 35 - 0
ExpressiveLayoutTests/ExpressiveLayoutTests.swift

@@ -0,0 +1,35 @@
+//
+//  ExpressiveLayoutTests.swift
+//  ExpressiveLayoutTests
+//
+//  Created by Jonas Budelmann on 5/06/14.
+//  Copyright (c) 2014 Jonas Budelmann. All rights reserved.
+//
+
+import XCTest
+
+class ExpressiveLayoutTests: XCTestCase {
+    
+    override func setUp() {
+        super.setUp()
+        // Put setup code here. This method is called before the invocation of each test method in the class.
+    }
+    
+    override func tearDown() {
+        // Put teardown code here. This method is called after the invocation of each test method in the class.
+        super.tearDown()
+    }
+    
+    func testExample() {
+        // This is an example of a functional test case.
+        XCTAssert(true, "Pass")
+    }
+    
+    func testPerformanceExample() {
+        // This is an example of a performance test case.
+        self.measureBlock() {
+            // Put the code you want to measure the time of here.
+        }
+    }
+    
+}

+ 24 - 0
ExpressiveLayoutTests/Info.plist

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>en</string>
+	<key>CFBundleExecutable</key>
+	<string>${EXECUTABLE_NAME}</string>
+	<key>CFBundleIdentifier</key>
+	<string>com.cloudling.${PRODUCT_NAME:rfc1034identifier}</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>${PRODUCT_NAME}</string>
+	<key>CFBundlePackageType</key>
+	<string>BNDL</string>
+	<key>CFBundleShortVersionString</key>
+	<string>1.0</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>1</string>
+</dict>
+</plist>