From de6fd92656ed5f7be648ca59c45017bf05567e0c Mon Sep 17 00:00:00 2001 From: allevato Date: Sat, 16 Sep 2017 01:01:36 +0200 Subject: Move PrenotCalculator from Bazel examples to rules_apple examples. This also migrates the example to the new rules_apple ios_application rule, since the native Bazel rule is being deleted. PiperOrigin-RevId: 168902357 --- examples/BUILD | 1 - examples/objc/BUILD | 85 ------- examples/objc/PrenotCalculator/AppDelegate.h | 21 -- examples/objc/PrenotCalculator/AppDelegate.m | 59 ----- examples/objc/PrenotCalculator/CalculatedValues.h | 28 --- examples/objc/PrenotCalculator/CalculatedValues.m | 48 ---- .../PrenotCalculator/CalculatorViewController.h | 35 --- .../PrenotCalculator/CalculatorViewController.m | 127 ---------- .../PrenotCalculator/CalculatorViewController.xib | 257 --------------------- examples/objc/PrenotCalculator/CoreData.h | 23 -- examples/objc/PrenotCalculator/CoreData.m | 41 ---- .../DataModel.xcdatamodeld/.xccurrentversion | 23 -- .../DataModel-1.0.xcdatamodel/contents | 24 -- .../DataModel-1.1.xcdatamodel/contents | 25 -- examples/objc/PrenotCalculator/Equation.h | 34 --- examples/objc/PrenotCalculator/Equation.m | 108 --------- examples/objc/PrenotCalculator/Expression.h | 21 -- examples/objc/PrenotCalculator/Expression.m | 34 --- examples/objc/PrenotCalculator/Literal.h | 21 -- examples/objc/PrenotCalculator/Literal.m | 44 ---- .../PrenotCalculator/PrenotCalculator-Info.plist | 60 ----- examples/objc/PrenotCalculator/Resources/test.txt | 1 - .../objc/PrenotCalculator/ValuesViewController.h | 19 -- .../objc/PrenotCalculator/ValuesViewController.m | 64 ----- examples/objc/PrenotCalculator/main.m | 22 -- examples/objc/README.md | 16 -- examples/objc/expression_prebuilt.a | Bin 12712 -> 0 bytes 27 files changed, 1241 deletions(-) delete mode 100644 examples/objc/BUILD delete mode 100644 examples/objc/PrenotCalculator/AppDelegate.h delete mode 100644 examples/objc/PrenotCalculator/AppDelegate.m delete mode 100644 examples/objc/PrenotCalculator/CalculatedValues.h delete mode 100644 examples/objc/PrenotCalculator/CalculatedValues.m delete mode 100644 examples/objc/PrenotCalculator/CalculatorViewController.h delete mode 100644 examples/objc/PrenotCalculator/CalculatorViewController.m delete mode 100644 examples/objc/PrenotCalculator/CalculatorViewController.xib delete mode 100644 examples/objc/PrenotCalculator/CoreData.h delete mode 100644 examples/objc/PrenotCalculator/CoreData.m delete mode 100644 examples/objc/PrenotCalculator/DataModel.xcdatamodeld/.xccurrentversion delete mode 100644 examples/objc/PrenotCalculator/DataModel.xcdatamodeld/DataModel-1.0.xcdatamodel/contents delete mode 100644 examples/objc/PrenotCalculator/DataModel.xcdatamodeld/DataModel-1.1.xcdatamodel/contents delete mode 100644 examples/objc/PrenotCalculator/Equation.h delete mode 100644 examples/objc/PrenotCalculator/Equation.m delete mode 100644 examples/objc/PrenotCalculator/Expression.h delete mode 100644 examples/objc/PrenotCalculator/Expression.m delete mode 100644 examples/objc/PrenotCalculator/Literal.h delete mode 100644 examples/objc/PrenotCalculator/Literal.m delete mode 100644 examples/objc/PrenotCalculator/PrenotCalculator-Info.plist delete mode 100644 examples/objc/PrenotCalculator/Resources/test.txt delete mode 100644 examples/objc/PrenotCalculator/ValuesViewController.h delete mode 100644 examples/objc/PrenotCalculator/ValuesViewController.m delete mode 100644 examples/objc/PrenotCalculator/main.m delete mode 100644 examples/objc/README.md delete mode 100644 examples/objc/expression_prebuilt.a (limited to 'examples') diff --git a/examples/BUILD b/examples/BUILD index c86c71996a..b33cb8ab32 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -8,7 +8,6 @@ filegroup( "//examples/gen:srcs", "//examples/java-native:srcs", "//examples/java-skylark:srcs", - "//examples/objc:srcs", "//examples/py:srcs", "//examples/py_native:srcs", "//examples/shell:srcs", diff --git a/examples/objc/BUILD b/examples/objc/BUILD deleted file mode 100644 index d6c833dffe..0000000000 --- a/examples/objc/BUILD +++ /dev/null @@ -1,85 +0,0 @@ -# Copyright 2015 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -ios_application( - name = "PrenotCalculator", - binary = ":PrenotCalculator_binary", - bundles = [":PrenotCalculatorResources"], - datamodels = glob(["PrenotCalculator/DataModel.xcdatamodeld/**"]), - infoplist = "PrenotCalculator/PrenotCalculator-Info.plist", - visibility = ["//visibility:public"], - xibs = ["PrenotCalculator/CalculatorViewController.xib"], -) - -objc_binary( - name = "PrenotCalculator_binary", - srcs = [ - "PrenotCalculator/AppDelegate.m", - "PrenotCalculator/CalculatedValues.m", - "PrenotCalculator/CalculatorViewController.m", - "PrenotCalculator/CoreData.m", - "PrenotCalculator/Equation.m", - "PrenotCalculator/Literal.m", - "PrenotCalculator/ValuesViewController.m", - "PrenotCalculator/main.m", - ], - hdrs = glob( - ["**/*.h"], - exclude = ["PrenotCalculator/Expression.h"], - ), - sdk_frameworks = ["CoreData"], - deps = [":ExpressionPrebuilt"], -) - -# A prebuilt library that contains multiple architectures. -# Currently compiled for: i386, x86_64, armv7. -objc_import( - name = "ExpressionPrebuilt", - hdrs = ["PrenotCalculator/Expression.h"], - archives = [ - "expression_prebuilt.a", - ], -) - -# Don't use this directly, instead use it to construct ExpressionPrebuilt and -# depend on that instead. -# You can build using the following command: -# for i in armv7 arm64 i386 x86_64; \ -# do output/bazel build --xcode_version=7.2 --ios_sdk_version=9.2 --ios_cpu=$i examples/objc:ExpressionClasses; \ -# mv bazel-bin/examples/objc/libExpressionClasses.a bazel-bin/examples/objc/libExpressionClasses_$i.a; \ -# done; \ -# xcrun lipo -create bazel-bin/examples/objc/libExpressionClasses_{armv7,arm64,i386,x86_64}.a -output bazel-bin/examples/objc/expression_prebuilt.a \ -# cp bazel-bin/examples/objc/expression_prebuilt.a examples/objc/expression_prebuilt.a -# You may need to adjust the xcode_version and ios_sdk_versions as appropriate. -objc_library( - name = "ExpressionClasses", - srcs = [ - "PrenotCalculator/Expression.m", - ], - hdrs = ["PrenotCalculator/Expression.h"], -) - -objc_bundle_library( - name = "PrenotCalculatorResources", - resources = glob(["PrenotCalculator/Resources/**"]), -) - -filegroup( - name = "srcs", - srcs = glob([ - "**", - "BUILD", - ]), - visibility = ["//examples:__pkg__"], -) diff --git a/examples/objc/PrenotCalculator/AppDelegate.h b/examples/objc/PrenotCalculator/AppDelegate.h deleted file mode 100644 index 01b55df3d1..0000000000 --- a/examples/objc/PrenotCalculator/AppDelegate.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#import - -@interface AppDelegate : UIResponder - -@property (strong, nonatomic) UIWindow *window; - -@end diff --git a/examples/objc/PrenotCalculator/AppDelegate.m b/examples/objc/PrenotCalculator/AppDelegate.m deleted file mode 100644 index 3e61f8bb72..0000000000 --- a/examples/objc/PrenotCalculator/AppDelegate.m +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#import "AppDelegate.h" - -#import "CalculatorViewController.h" -#import "ValuesViewController.h" - -@implementation AppDelegate - -- (BOOL)application:(UIApplication *)application - didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - [self validateBundleLibrary]; - - UITabBarController *bar = [[UITabBarController alloc] init]; - [bar setViewControllers: - @[[[CalculatorViewController alloc] init], [[ValuesViewController alloc] init]]]; - bar.selectedIndex = 0; - self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - self.window.rootViewController = bar; - [self.window makeKeyAndVisible]; - return YES; -} - -- (void)applicationWillResignActive:(UIApplication *)application {} - -- (void)applicationDidEnterBackground:(UIApplication *)application {} - -- (void)applicationWillEnterForeground:(UIApplication *)application {} - -- (void)applicationDidBecomeActive:(UIApplication *)application {} - -- (void)applicationWillTerminate:(UIApplication *)application {} - -- (void)validateBundleLibrary { - NSString *bundlePath = [[[NSBundle mainBundle] bundlePath] - stringByAppendingPathComponent:@"PrenotCalculatorResources.bundle"]; - NSBundle *bundle = [NSBundle bundleWithPath:bundlePath]; - NSString *testPath = [bundle pathForResource:@"test" ofType:@"txt"]; - NSString *testContents = [NSString stringWithContentsOfFile:testPath - encoding:NSUTF8StringEncoding - error:NULL]; - NSAssert([testContents hasSuffix:@"It worked!\n"], - @"Unable to find file given mainBundle: %@", - [[NSBundle mainBundle] description]); -} - -@end diff --git a/examples/objc/PrenotCalculator/CalculatedValues.h b/examples/objc/PrenotCalculator/CalculatedValues.h deleted file mode 100644 index 2c29bef6c1..0000000000 --- a/examples/objc/PrenotCalculator/CalculatedValues.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#import - -#import "Equation.h" -#import "Expression.h" - -@interface CalculatedValues : NSObject - -+ (CalculatedValues *)sharedInstance; - -- (NSArray *)values; - -- (void)addEquation:(Equation *)equation; - -@end diff --git a/examples/objc/PrenotCalculator/CalculatedValues.m b/examples/objc/PrenotCalculator/CalculatedValues.m deleted file mode 100644 index 2ea8ed8ee2..0000000000 --- a/examples/objc/PrenotCalculator/CalculatedValues.m +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#import "CalculatedValues.h" - -#import "Equation.h" - -@implementation CalculatedValues { - NSMutableArray *_values; -} - -+ (CalculatedValues *)sharedInstance { - static CalculatedValues *values = nil; - if (!values) { - values = [[[self class] alloc] init]; - } - return values; -} - -- (id)init { - self = [super init]; - if (self) { - _values = [NSMutableArray array]; - } - return self; -} - -- (NSArray *)values { - return [_values copy]; -} - -- (void)addEquation:(Equation *)equation { - [_values addObject: - [NSString stringWithFormat:@"%@ = %0.2lf", equation, [equation calculate]]]; -} - -@end diff --git a/examples/objc/PrenotCalculator/CalculatorViewController.h b/examples/objc/PrenotCalculator/CalculatorViewController.h deleted file mode 100644 index 6b53d7d60d..0000000000 --- a/examples/objc/PrenotCalculator/CalculatorViewController.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#import - -@interface CalculatorViewController : UIViewController - -- (IBAction)enterDigit:(id)sender; - -- (IBAction)finish:(id)sender; - -- (IBAction)operate:(id)sender; - -@property (weak, nonatomic) IBOutlet UIButton *divideButton; -@property (weak, nonatomic) IBOutlet UIButton *multiplyButton; -@property (weak, nonatomic) IBOutlet UIButton *plusButton; -@property (weak, nonatomic) IBOutlet UIButton *minusButton; -@property (strong, nonatomic) IBOutletCollection(UIButton) - NSArray *nonZeroDigitButtons; -@property (weak, nonatomic) IBOutlet UILabel *resultLabel; -@property (weak, nonatomic) IBOutlet UIButton *finishButton; -@property (weak, nonatomic) IBOutlet UIButton *zeroButton; - -@end diff --git a/examples/objc/PrenotCalculator/CalculatorViewController.m b/examples/objc/PrenotCalculator/CalculatorViewController.m deleted file mode 100644 index 6e755a9ad5..0000000000 --- a/examples/objc/PrenotCalculator/CalculatorViewController.m +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#import "CalculatorViewController.h" - -#import "CalculatedValues.h" -#import "CoreData.h" -#import "Equation.h" -#import "Expression.h" -#import "Literal.h" - -@interface CalculatorViewController () -- (void)updateEnabledViews; -- (void)updateButtonColor:(UIButton *)button; -@end - -@implementation CalculatorViewController { - NSMutableArray *_locationStack; - NSMutableString *_currentNumber; -} - -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { - self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; - if (self) { - self.title = @"Calculator"; - CoreData *coreData = [[CoreData alloc] init]; - [coreData verify]; - } - return self; -} - -- (void)viewDidLoad { - [super viewDidLoad]; - _locationStack = [NSMutableArray array]; - _currentNumber = [NSMutableString stringWithString:@""]; - [self updateEnabledViews]; -} - -- (IBAction)enterDigit:(id)sender { - UIButton *button = (UIButton *)sender; - [_currentNumber appendString:button.titleLabel.text]; - self.resultLabel.text = _currentNumber; - [self updateEnabledViews]; -} - -- (IBAction)finish:(id)sender { - if (![_locationStack count]) { - _currentNumber = [NSMutableString stringWithString:@""]; - self.resultLabel.text = @"hello"; - } - if (![_locationStack count]) { - _currentNumber = [NSMutableString stringWithString:@""]; - } else if ([_currentNumber length]) { - Equation *last = [_locationStack lastObject]; - [last addExpressionAsChild:[[Literal alloc] initWithDouble: - atof([_currentNumber cStringUsingEncoding:NSUTF8StringEncoding])]]; - _currentNumber = [NSMutableString stringWithString:@""]; - self.resultLabel.text = [NSString stringWithFormat:@"%@", last]; - } else { - Equation *popped = [_locationStack lastObject]; - [_locationStack removeLastObject]; - [[CalculatedValues sharedInstance] addEquation:popped]; - self.resultLabel.text = - [NSString stringWithFormat:@"%lf", [popped calculate]]; - } - [self updateEnabledViews]; -} - -- (IBAction)operate:(id)sender { - Operation operation; - if ([_currentNumber length]) { - // finish the current number first automatically: - [self finish:nil]; - } - if (sender == self.multiplyButton) { - operation = kMultiply; - } else if (sender == self.plusButton) { - operation = kAdd; - } else if (sender == self.divideButton) { - operation = kDivide; - } else if (sender == self.minusButton) { - operation = kSubtract; - } else { - // Shouldn't happen - operation = kAdd; - } - Equation *newEquation = [[Equation alloc] initWithOperation:operation]; - if ([_locationStack count]) { - [[_locationStack lastObject] addExpressionAsChild:newEquation]; - } - [_locationStack addObject:newEquation]; - self.resultLabel.text = [NSString stringWithFormat:@"%@", _locationStack[0]]; - [self updateEnabledViews]; -} - -#pragma mark - Private - - -- (void)updateEnabledViews { - self.finishButton.enabled = [_locationStack count] || [_currentNumber length]; - [self updateButtonColor:self.finishButton]; - self.zeroButton.enabled = self.finishButton.enabled; - [self updateButtonColor:self.zeroButton]; - BOOL enableNonZeroDigits = ![_currentNumber isEqualToString:@"0"]; - for (UIButton *digit in self.nonZeroDigitButtons) { - digit.enabled = enableNonZeroDigits; - [self updateButtonColor:digit]; - } -} - -- (void)updateButtonColor:(UIButton *)button { - button.backgroundColor = button.enabled ? - [UIColor whiteColor] : [UIColor grayColor]; -} - -@end diff --git a/examples/objc/PrenotCalculator/CalculatorViewController.xib b/examples/objc/PrenotCalculator/CalculatorViewController.xib deleted file mode 100644 index f93dd821f7..0000000000 --- a/examples/objc/PrenotCalculator/CalculatorViewController.xib +++ /dev/null @@ -1,257 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/objc/PrenotCalculator/CoreData.h b/examples/objc/PrenotCalculator/CoreData.h deleted file mode 100644 index 1f29db1a23..0000000000 --- a/examples/objc/PrenotCalculator/CoreData.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#import - -// A simple class to confirm CoreData versioning works properly. -@interface CoreData : NSObject - -// Check that the datamodel was loaded properly. -- (void)verify; - -@end diff --git a/examples/objc/PrenotCalculator/CoreData.m b/examples/objc/PrenotCalculator/CoreData.m deleted file mode 100644 index b3ba6049a3..0000000000 --- a/examples/objc/PrenotCalculator/CoreData.m +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#import "CoreData.h" - -@implementation CoreData -- (id)init { - self = [super init]; - if (self) { - - } - return self; -} - -- (void)verify { - NSURL *modelURL = [self modelURL]; - NSAssert(modelURL, - @"Unable to find modelURL given mainBundle: %@", - [[NSBundle mainBundle] description]); -} - -#pragma mark Private Methods. - -- (NSURL *)modelURL { - NSBundle *bundle = [NSBundle bundleForClass:[CoreData class]]; - NSURL *modelURL = [bundle URLForResource:@"DataModel" withExtension:@"momd"]; - return modelURL; -} - -@end diff --git a/examples/objc/PrenotCalculator/DataModel.xcdatamodeld/.xccurrentversion b/examples/objc/PrenotCalculator/DataModel.xcdatamodeld/.xccurrentversion deleted file mode 100644 index b776fdca6b..0000000000 --- a/examples/objc/PrenotCalculator/DataModel.xcdatamodeld/.xccurrentversion +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - _XCCurrentVersionName - DataModel-1.1.xcdatamodel - - diff --git a/examples/objc/PrenotCalculator/DataModel.xcdatamodeld/DataModel-1.0.xcdatamodel/contents b/examples/objc/PrenotCalculator/DataModel.xcdatamodeld/DataModel-1.0.xcdatamodel/contents deleted file mode 100644 index 05b9a8b8db..0000000000 --- a/examples/objc/PrenotCalculator/DataModel.xcdatamodeld/DataModel-1.0.xcdatamodel/contents +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/examples/objc/PrenotCalculator/DataModel.xcdatamodeld/DataModel-1.1.xcdatamodel/contents b/examples/objc/PrenotCalculator/DataModel.xcdatamodeld/DataModel-1.1.xcdatamodel/contents deleted file mode 100644 index 02a74ec948..0000000000 --- a/examples/objc/PrenotCalculator/DataModel.xcdatamodeld/DataModel-1.1.xcdatamodel/contents +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/examples/objc/PrenotCalculator/Equation.h b/examples/objc/PrenotCalculator/Equation.h deleted file mode 100644 index d6192ea0b7..0000000000 --- a/examples/objc/PrenotCalculator/Equation.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#import - -#import "Expression.h" - -typedef enum { - kAdd, - kSubtract, - kMultiply, - kDivide -} Operation; - -@interface Equation : Expression - -@property (nonatomic, assign) Operation operation; - -- (id)initWithOperation:(Operation)operation; -- (NSArray *)children; -- (void)addExpressionAsChild:(Expression *)child; - -@end diff --git a/examples/objc/PrenotCalculator/Equation.m b/examples/objc/PrenotCalculator/Equation.m deleted file mode 100644 index 2bf8f5f67c..0000000000 --- a/examples/objc/PrenotCalculator/Equation.m +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#import "Equation.h" - -@implementation Equation { - NSMutableArray *_children; -} - -@synthesize operation = _operation; - -- (id)init { - [self doesNotRecognizeSelector:_cmd]; - return nil; -} - -- (id)initWithOperation:(Operation)operation { - self = [super init]; - if (self) { - _children = [NSMutableArray array]; - _operation = operation; - } - return self; -} - -- (NSArray *)children { - return [_children copy]; -} - -- (void)addExpressionAsChild:(Expression *)child { - [_children addObject:child]; -} - -- (double)calculate { - if ([_children count] == 1) { - return (_operation == kSubtract) - ? -[_children[0] calculate] : [_children[0] calculate]; - } else if ([_children count] == 0) { - return (_operation == kSubtract || _operation == kAdd) ? 0 : 1; - } - double value = [_children[0] calculate]; - for (Equation *child in [_children subarrayWithRange: - NSMakeRange(1, [_children count] - 1)]) { - double childValue = [child calculate]; - switch (_operation) { - case kAdd: - value += childValue; - break; - case kSubtract: - value -= childValue; - break; - case kMultiply: - value *= childValue; - break; - case kDivide: - value /= childValue; - break; - } - } - return value; -} - -- (NSString *)description { - NSMutableString *result = [[NSMutableString alloc] init]; - [result appendString:@"("]; - switch (_operation) { - case kAdd: - [result appendString:@"+"]; - break; - case kSubtract: - [result appendString:@"-"]; - break; - case kMultiply: - [result appendString:@"*"]; - break; - case kDivide: - [result appendString:@"/"]; - break; - } - for (Equation *child in _children) { - [result appendString:@" "]; - [result appendString:[child description]]; - } - [result appendString:@")"]; - return [result copy]; -} - -- (BOOL)isEqual:(id)object { - if (![object isKindOfClass:[self class]]) { - return NO; - } - Equation *other = object; - return other->_operation == _operation && - [other->_children isEqual:_children]; -} - -@end diff --git a/examples/objc/PrenotCalculator/Expression.h b/examples/objc/PrenotCalculator/Expression.h deleted file mode 100644 index ab6be2742e..0000000000 --- a/examples/objc/PrenotCalculator/Expression.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#import - -@interface Expression : NSObject - -- (double)calculate; - -@end diff --git a/examples/objc/PrenotCalculator/Expression.m b/examples/objc/PrenotCalculator/Expression.m deleted file mode 100644 index 5a304d791d..0000000000 --- a/examples/objc/PrenotCalculator/Expression.m +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#import "Expression.h" - -@implementation Expression - -- (double)calculate { - [self doesNotRecognizeSelector:_cmd]; - return NAN; -} - -- (BOOL)isEqual:(id)object { - [self doesNotRecognizeSelector:_cmd]; - return NO; -} - -- (NSString *)description { - [self doesNotRecognizeSelector:_cmd]; - return nil; -} - -@end diff --git a/examples/objc/PrenotCalculator/Literal.h b/examples/objc/PrenotCalculator/Literal.h deleted file mode 100644 index fab3369b55..0000000000 --- a/examples/objc/PrenotCalculator/Literal.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#import "Expression.h" - -@interface Literal : Expression - -- (id)initWithDouble:(double)value; - -@end diff --git a/examples/objc/PrenotCalculator/Literal.m b/examples/objc/PrenotCalculator/Literal.m deleted file mode 100644 index d3c8ed7802..0000000000 --- a/examples/objc/PrenotCalculator/Literal.m +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#import "Literal.h" - -@implementation Literal { - double _value; -} - -- (id)initWithDouble:(double)value { - self = [super init]; - if (self) { - _value = value; - } - return self; -} - -- (double)calculate { - return _value; -} - -- (NSString *)description { - return [NSString stringWithFormat:@"%0.2lf", _value]; -} - -- (BOOL)isEqual:(id)object { - if (![object isKindOfClass:[self class]]) { - return NO; - } - return _value == ((Literal *)object)->_value; -} - -@end diff --git a/examples/objc/PrenotCalculator/PrenotCalculator-Info.plist b/examples/objc/PrenotCalculator/PrenotCalculator-Info.plist deleted file mode 100644 index 71f8c75bd4..0000000000 --- a/examples/objc/PrenotCalculator/PrenotCalculator-Info.plist +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - CFBundleDevelopmentRegion - en - CFBundleDisplayName - PrenotCalculator - CFBundleExecutable - PrenotCalculator - CFBundleIdentifier - Google.PrenotCalculator - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - PrenotCalculator - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1.0 - LSRequiresIPhoneOS - - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - - diff --git a/examples/objc/PrenotCalculator/Resources/test.txt b/examples/objc/PrenotCalculator/Resources/test.txt deleted file mode 100644 index 3dc3aa5164..0000000000 --- a/examples/objc/PrenotCalculator/Resources/test.txt +++ /dev/null @@ -1 +0,0 @@ -It worked! diff --git a/examples/objc/PrenotCalculator/ValuesViewController.h b/examples/objc/PrenotCalculator/ValuesViewController.h deleted file mode 100644 index 4034f89c7a..0000000000 --- a/examples/objc/PrenotCalculator/ValuesViewController.h +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#import - -@interface ValuesViewController : UITableViewController - -@end diff --git a/examples/objc/PrenotCalculator/ValuesViewController.m b/examples/objc/PrenotCalculator/ValuesViewController.m deleted file mode 100644 index c6c9499c3f..0000000000 --- a/examples/objc/PrenotCalculator/ValuesViewController.m +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#import "ValuesViewController.h" - -#import "CalculatedValues.h" - -@interface ValuesViewController () - -@end - -@implementation ValuesViewController - -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { - self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; - if (self) { - self.title = @"Values"; - } - return self; -} - -#pragma mark - Table view data source - -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return 1; -} - -- (NSInteger)tableView:(UITableView *)tableView - numberOfRowsInSection:(NSInteger)section { - return [[[CalculatedValues sharedInstance] values] count]; -} - -- (UITableViewCell *)tableView:(UITableView *)tableView - cellForRowAtIndexPath:(NSIndexPath *)indexPath { - static NSString *CellIdentifier = @"Cell"; - UITableViewCell *cell = - [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; - if (!cell) { - cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault - reuseIdentifier:CellIdentifier]; - } - - cell.textLabel.text = - [CalculatedValues sharedInstance].values[[indexPath indexAtPosition:1]]; - - return cell; -} - -- (void)viewDidAppear:(BOOL)animated { - [self.tableView reloadData]; -} - -@end diff --git a/examples/objc/PrenotCalculator/main.m b/examples/objc/PrenotCalculator/main.m deleted file mode 100644 index 9c7f114bdb..0000000000 --- a/examples/objc/PrenotCalculator/main.m +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#import - -int main(int argc, char * argv[]) { - @autoreleasepool { - NSString *delegateClassName = @"AppDelegate"; - return UIApplicationMain(argc, argv, nil, delegateClassName); - } -} diff --git a/examples/objc/README.md b/examples/objc/README.md deleted file mode 100644 index a8769bf156..0000000000 --- a/examples/objc/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# Objective C Examples - -The example in this directory show typical use of Objective C libraries, -binaries and imports. Because they build an iOS application they can only be run -on Mac OSX. - -Build the top-level application with -`bazel build examples/objc:PrenotCalculator`, which when finished prints the -path to the generated .ipa. which you can then install to your test device. The -same build will also print the path to an Xcode project directory which you can -open to continue working with the application in Xcode. - -Running `bazel build examples/objc:PrenotCalculatorInstruments` will build and -run the application to obtain a screenshot, the path to which it then prints. - - diff --git a/examples/objc/expression_prebuilt.a b/examples/objc/expression_prebuilt.a deleted file mode 100644 index f3bce54b0c..0000000000 Binary files a/examples/objc/expression_prebuilt.a and /dev/null differ -- cgit v1.2.3