Skip to content

Instantly share code, notes, and snippets.

View phausler's full-sized avatar

Philippe Hausler phausler

View GitHub Profile
@phausler
phausler / gist:6058774
Last active December 20, 2015 02:49
NEVER EVER DO THIS!
struct BlockObject {
Class isa;
int retainCount;
struct BlockObject *(^alloc)();
struct BlockObject *(^init)();
struct BlockObject *(^retain)();
void (^release)();
struct BlockObject *(^autorelease)();
void (^dealloc)();
} BlockObject = {
@phausler
phausler / gist:6725188
Created September 27, 2013 07:21
just because...
#import <objc/message.h>
typedef struct class_t {
struct class_t *isa;
struct class_t *superclass;
void *cache;
IMP *vtable;
uintptr_t data_NEVER_USE;
} class_t;
@phausler
phausler / gist:7079724
Created October 21, 2013 07:05
example bridge callbacks
/*
Foo.java
*/
package com.apportable.example;
...
public class Foo {
public static void initialize(Activity activity, String appId) {
@phausler
phausler / gist:7190603
Last active December 26, 2015 17:59
CFType registration SublimeText snippet
<snippet>
<content><![CDATA[
#include "CFBase.h"
#include "CFRuntime.h"
#include "${1:name}.h"
struct __${1:name} {
CFRuntimeBase _base;
};
@phausler
phausler / CFBlockQueue.h
Created December 5, 2013 22:31
A simple CFRunLoopSource based atomic queue for block execution in a header implementation (poor man's GCD)
#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);
@phausler
phausler / gist:8248182
Created January 3, 2014 22:47
NSGenericDeallocHandler for tracking when objects die
extern void _NSSetDeallocHandler(id object, void (^block)(void));
_NSSetDeallocHandler(someObject, ^{
NSLog(@"someObject was deallocated");
});
@phausler
phausler / wrappers.h
Created September 17, 2014 18:48
portable function wrappers
#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))
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"])
#if DEBUG
#define ONLY_FOR_DEBUGGER
#else
#define ONLY_FOR_DEBUGGER UNAVAILABLE_ATTRIBUTE
#endif
@phausler
phausler / build.sh
Last active June 24, 2016 19:34
Swift Toolchain Build Script
#!/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"