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
extern crate libc; | |
use libc::uintptr_t; | |
type Sel = libc::uintptr_t; | |
enum ObjcObject {} | |
type Class<'a> = &'a ObjcObject; | |
type Id<'a> = &'a ObjcObject; | |
type NSObjectClass<'a> = Class<'a>; |
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
#![feature(macro_rules)] | |
extern crate libc; | |
extern crate sync; | |
use std::cast::transmute; | |
use std::c_str::CString; | |
use std::sync::atomics::{ AtomicUint, INIT_ATOMIC_UINT, SeqCst }; | |
type Sel = uint; | |
enum ObjcObject {} |
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 <objc/runtime.h> | |
#import <objc/message.h> | |
typedef id (^FLazyProxyResolver)(); | |
@interface FLazyProxy : NSProxy | |
@end | |
@interface FLazyProxy () { |
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
// Would an instance created from C++ be safe to pass to C and vice versa? | |
struct Name { | |
int x, y, z; | |
#ifdef __cplusplus | |
int foo() { return x+y+z; } | |
#endif | |
} |
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
- (NSDictionary *)cy_flippedDictionary | |
{ | |
NSArray * const keys = [self allKeys]; | |
NSArray * const vals = [self objectsForKeys:keys notFoundMarker:[NSNull null]]; | |
return [NSDictionary dictionaryWithObjects:keys forKeys:vals]; | |
} |
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
protocol TypeEquality { | |
typealias From | |
typealias To | |
func apply(a: From) -> To | |
} | |
struct Refl<X> : TypeEquality { | |
typealias From = X | |
typealias To = X | |
func apply(a: From) -> To { |
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
# Compile localized nibs | |
require "tmpdir" | |
ibtool = "#{ENV["DEVELOPER_BIN_DIR"]}/ibtool" | |
xib_dir = "#{ENV["PROJECT_DIR"]}/Fii/ja.lproj" | |
str_dir = "#{ENV["PROJECT_DIR"]}/Foo/en.lproj" | |
out_dir = "#{ENV["BUILT_PRODUCTS_DIR"]}/Foo.app/en.lproj" | |
Dir.mktmpdir do |tmpdir| |
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
NSMapTable *attributes; | |
for(id path in PSVGPathsFromSVGString(svg, &attributes)) { | |
CAShapeLayer *layer = [CAShapeLayer layer]; | |
layer.path = (__bridge CGPathRef)path; | |
NSDictionary *attrs = [attributes objectForKey:path]; | |
layer.strokeColor = (__bridge CGColorRef)attrs[@"strokeColor"]; | |
layer.lineWidth = [attrs[@"strokeWidth"] floatValue]; | |
layer.fillColor = (__bridge CGColorRef)attrs[@"fillColor"]; | |
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
__weak MyView *self_ = self; | |
int const fdes = open([path fileSystemRepresentation], O_RDONLY); | |
_fileWatcher = dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, fdes, | |
DISPATCH_VNODE_DELETE | DISPATCH_VNODE_WRITE, | |
GlobalQueue); | |
dispatch_source_set_event_handler(_fileWatcher, ^{ | |
unsigned long l = dispatch_source_get_data(_fileWatcher); | |
if(l & DISPATCH_VNODE_DELETE || l & DISPATCH_VNODE_WRITE) { | |
dispatch_source_cancel(_fileWatcher); | |
NSLog(@"Reloading %@", path); |
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 <objc/runtime.h> | |
#import <objc/message.h> | |
#import <ffi/ffi.h> | |
#import <sys/mman.h> | |
// Wrapper closure called as a result of a message to `initWith..` | |
static void _ai_closure(ffi_cif * const aCif, id * const aoRet, void * const aArgs[], NSArray * const paramInfo); | |
static ffi_closure *_ai_ffi_allocClosure(void ** const codePtr); |