This file contains hidden or 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
internal class NSAutoreleasePool { | |
fileprivate static var _current = NSThreadSpecific<NSAutoreleasePool>() | |
internal static var current: NSAutoreleasePool { | |
return _current.get() { | |
return NSAutoreleasePool() | |
} | |
} | |
var depth: Int = 0 |
This file contains hidden or 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
/// - Note: this requires Swift 3.0 (Mac OS X or iOS, Linux currently crashes in locale fetching) | |
import Foundation | |
func permuteLetterCountCycles(_ start: Int, _ formatter: NumberFormatter) -> [String] { | |
var foundNumbers = Set<Int>() | |
var result = Array<String>() | |
var number = start | |
formatter.numberStyle = .spellOut | |
while true { | |
// convert the number into the string representation (and presume all locales have a string representation) |
This file contains hidden or 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 | |
class ConsumerOperation<T> : Operation { | |
private var consumer: (T) -> Void | |
private weak var prodcuer: ProducerOperation<T>? | |
init(prodcuer: ProducerOperation<T>, consumer: (T) -> Void) { | |
self.prodcuer = prodcuer | |
self.consumer = consumer |
This file contains hidden or 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
#!/usr/bin/env bash | |
set -e | |
# This should live in the same directory that contains the swift repository and other tools. | |
SRC_DIR=$PWD/swift | |
RUN_TESTS= | |
if [[ "$1" == "-t" || "$1" == "--test" ]] ; then | |
RUN_TESTS="-t" |
This file contains hidden or 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
#if DEBUG | |
#define ONLY_FOR_DEBUGGER | |
#else | |
#define ONLY_FOR_DEBUGGER UNAVAILABLE_ATTRIBUTE | |
#endif |
This file contains hidden or 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
diff --git a/lib/product.py b/lib/product.py | |
index 82684cc..bcc6b6c 100644 | |
--- a/lib/product.py | |
+++ b/lib/product.py | |
@@ -115,7 +115,7 @@ class DynamicLibrary(Library): | |
def generate(self): | |
if Configuration.current.target.sdk == OSType.Linux: | |
- return Library.generate(self, ["-shared", "-Wl,-soname," + self.product_name, "-Wl,--no-undefined"]) | |
+ return Library.generate(self, ["-shared", "-Wl,-soname," + self.product_name, "-Wl,--no-undefined", "-Wl,-Bsymbolic"]) |
This file contains hidden or 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
#if defined(__APPLE__) // apple ld specific | |
// wrapped ala -Wl,-alias,___wrap_printf,_printf | |
#include <dlfcn.h> | |
#define WRAPFN(f) __wrap_##f | |
#define WRAPFN_DECL(f) WRAPFN(f) | |
#define REALFN(f) __real_##f | |
#define REALFN_DECL(f) (*REALFN(f)) |
This file contains hidden or 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
extern void _NSSetDeallocHandler(id object, void (^block)(void)); | |
_NSSetDeallocHandler(someObject, ^{ | |
NSLog(@"someObject was deallocated"); | |
}); |
This file contains hidden or 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
#ifndef _CFBLOCKQUEUE_H_ | |
#define _CFBLOCKQUEUE_H_ | |
#include <Block.h> | |
#include <libkern/OSAtomic.h> | |
#include <CoreFoundation/CFString.h> | |
#include <CoreFoundation/CFSet.h> | |
#include <CoreFoundation/CFRunLoop.h> | |
typedef void (^CFBlockQueueBlock)(void); |
This file contains hidden or 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
<snippet> | |
<content><![CDATA[ | |
#include "CFBase.h" | |
#include "CFRuntime.h" | |
#include "${1:name}.h" | |
struct __${1:name} { | |
CFRuntimeBase _base; | |
}; |