Skip to content

Instantly share code, notes, and snippets.

// gcc -o heap2 heap2.m -framework Foundation && ./heap2
#import <Foundation/Foundation.h>
CFTypeRef JBBRetainCallBack(CFAllocatorRef allocator, const void *obj) {
return [(id)obj retain];
}
void JBBReleaseCallBack(CFAllocatorRef allocator, const void *obj) {
[(id)obj release];
}
// gcc -o heap3 heap3.m -framework Foundation && ./heap3
#import <Foundation/Foundation.h>
CFTypeRef JBBRetainCallBack(CFAllocatorRef allocator, const void *obj) {
return [(id)obj retain];
}
void JBBReleaseCallBack(CFAllocatorRef allocator, const void *obj) {
[(id)obj release];
}
# bash script to generate .bridgesupport file for a Framework after building it
BRIDGE_SUPPORT_DIR="Resources/BridgeSupport"
BRIDGE_SUPPORT_FILE="${BRIDGE_SUPPORT_DIR}/${TARGET_NAME}.bridgesupport"
if [[ "${TARGET_BUILD_DIR}/${WRAPPER_NAME}/${TARGET_NAME}" -nt "${TARGET_BUILD_DIR}/${WRAPPER_NAME}/${BRIDGE_SUPPORT_FILE}" ]]; then
if [[ ! -d "${TARGET_BUILD_DIR}/${WRAPPER_NAME}/${BRIDGE_SUPPORT_DIR}" ]]; then
mkdir -p "${TARGET_BUILD_DIR}/${WRAPPER_NAME}/${BRIDGE_SUPPORT_DIR}"
fi
gen_bridge_metadata --64-bit --framework "${TARGET_BUILD_DIR}/${WRAPPER_NAME}" -o "${TARGET_BUILD_DIR}/${WRAPPER_NAME}/${BRIDGE_SUPPORT_FILE}"
# BinaryHeap and PriorityQueue based on my Objective-C version
class JBBBinaryHeap
def initialize(isMaxHeap = false)
@mStorage = []
@mCompareProc = (isMaxHeap) ? lambda { |x, y| x < y } : lambda { |x, y| x > y }
end
def add(objectToAdd)
@mStorage.push(nil)
// gcc -fobjc-gc-only -o test1 test1.m -framework Cocoa && ./test1
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[]) {
NSArray *arrayOne = [NSArray arrayWithObjects:@"one", @"two", @"three", nil];
NSArray *arrayTwo = [NSArray arrayWithObjects:arrayOne, nil];
NSPredicate *myPred = [NSPredicate predicateWithFormat:@"NOT (SELF in %@)" argumentArray: arrayTwo];
// gcc -fobjc-gc-only -o test2 test2.m -framework Cocoa && ./test2
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[]) {
NSArray *arrayOne = [NSArray arrayWithObjects:@"one", @"two", @"three", nil];
NSArray *arrayTwo = [NSArray arrayWithObjects:arrayOne, nil];
NSPredicate *myPred = [NSPredicate predicateWithFormat:@"NOT (SELF in %@)", arrayTwo];
// gcc -fobjc-gc-only -o test3 test3.m -framework Cocoa && ./test3
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[]) {
NSPredicate *myPred = [NSPredicate predicateWithFormat:@"NOT (SELF in %@)" argumentArray: [NSArray arrayWithObjects:[NSArray arrayWithObjects:@"one", @"two", @"three", nil], nil]];
NSLog(@"test3 finished running");
return 0;
}
18 jordan@thetourist /tmp > g++ -fobjc-gc-only -o test test.mm
test.mm: In function ‘int main(int, char**)’:
test.mm:4: error: ‘objc_collectingEnabled’ was not declared in this scope
test.mm:5: error: ‘objc_startCollectorThread’ was not declared in this scope
Tests running (compiler exit codes printed)...
0 is passing, anything else is an error...
These tests are verifying the presence of objc_startCollectorThread()...
Output for the following tests is in output/test1.m/ansi...
--- test2.m 2010-01-26 14:44:47.000000000 -0600
+++ test3.m 2010-01-25 20:18:22.000000000 -0600
@@ -1,4 +1,4 @@
-// /Developer/usr/bin/clang -arch x86_64 -std=gnu99 -fobjc-gc-only -o test2 -F. -Wl,-rpath,. test2.m -framework Foundation -framework JBBPriorityQueue -framework JBBAdditions
+// /Developer/usr/bin/clang -arch x86_64 -std=gnu99 -fobjc-gc-only -o test3 -F. -Wl,-rpath,. test3.m -framework Foundation -framework JBBPriorityQueue -framework JBBAdditions
#import <objc/objc-auto.h>
#import <dispatch/dispatch.h>
@@ -16,7 +16,6 @@