Created
August 1, 2017 16:15
-
-
Save bnham/f9a0cf6c1cf232a1fbb1ea8bc8be7c9f to your computer and use it in GitHub Desktop.
test2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
class ObjectWrapper { | |
public: | |
ObjectWrapper(id obj); | |
id get(); | |
void set(id obj); | |
private: | |
id obj_; | |
}; | |
@interface Foo : NSObject | |
+ (ObjectWrapper)foo; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "foo.h" | |
ObjectWrapper::ObjectWrapper(id obj) | |
: obj_(obj) { | |
} | |
id ObjectWrapper::get() { | |
return obj_; | |
} | |
void ObjectWrapper::set(id obj) { | |
obj_ = obj; | |
} | |
@implementation Foo | |
+ (ObjectWrapper)foo { | |
const char *status = (self == [Foo class]) ? "CORRECT" : "INCORRECT"; | |
NSLog(@"%s: receiver is %s", __func__, status); | |
return ObjectWrapper{[[NSObject alloc] init]}; | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: test2-arc-caller test2-mrr-caller | |
.PHONY: all | |
CXXFLAGS = -gdwarf -std=c++11 | |
LDLIBS = -framework Foundation | |
test2-arc-caller: test2.mm foo.h foo.mm | |
$(CXX) $(CXXFLAGS) -fobjc-arc -o test2-arc.o -c test2.mm | |
$(CXX) $(CXXFLAGS) -fobjc-arc -o foo-arc.o -c foo.mm | |
$(CXX) $(LDFLAGS) $(LDLIBS) -o $@ test2-arc.o foo-arc.o | |
test2-mrr-caller: test2.mm foo.h foo.mm | |
$(CXX) $(CXXFLAGS) -fno-objc-arc -o test2-mrr.o -c test2.mm | |
$(CXX) $(CXXFLAGS) -fobjc-arc -o foo-arc.o -c foo.mm | |
$(CXX) $(LDFLAGS) $(LDLIBS) -o $@ test2-mrr.o foo-arc.o | |
clean: | |
rm -rf test2-* *.o | |
.PHONY: clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import "foo.h" | |
int main() { | |
@autoreleasepool { | |
[Foo foo]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment