Skip to content

Instantly share code, notes, and snippets.

Jason O'Neil jasononeil

Block or report user

Report or block jasononeil

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jasononeil / MethodTyper.hx
Created Feb 19, 2014
Method used in a macro to figure out the return type of a member method. Uses tink_macro
View MethodTyper.hx
Figure out return type of function.
Will first to check if it is explicitly defined.
If not, it attempts to set the function up as a local function expression (EFunction), and then use `Context.typeof( fnExpr )` to evaluate the type.
Will generate a compiler error if member was not a method or method type could not be determined.
static function figureOutReturnTypeOfMemberMethod( member:Member ) {
switch member.getFunction() {
jasononeil / Http.hx
Created Mar 5, 2014
Workaround for Hxssl being broken for Http requests. Drop these 4 files into a package called "haxe", and you can use this as a drop-in workaround for HxSSL breaking regular HTTP port 80 requests
View Http.hx
package haxe;
@:access( haxe.Https )
@:access( haxe.Http80 )
class Http {
public var h:IHttp;
public var url(get, set) : String;
function get_url() return h.url;
jasononeil / ObjectInit.hx
Created Dec 2, 2014
Object initialisations syntax sugar
View ObjectInit.hx
import haxe.macro.Expr;
import haxe.macro.Context;
using haxe.macro.ExprTools;
class ObjectInit {
macro public static function init( expr:Expr, varsToSet:ExprOf<Dynamic<Dynamic>> ) {
var lines:Array<Expr> = [];
lines.push( macro var __obj_init_tmp = $expr );
switch varsToSet.expr {
case EObjectDecl(fields):
jasononeil / Console.hx
Created Mar 6, 2012
A really simple proof of concept for a haxe interactive shell
View Console.hx
A super basic interactive console for haxe.
Done because someone on the mailing list asked and I got distracted :)
Consider this code Public Domain.
Jason O'Neil
Run using:
haxe -lib hscript -x Console.hx
(you will need hscript installed via haxelib)
jasononeil / NekoScript.hx
Created May 23, 2012
NekoScript proof of concept - simple scripting language using hscript
View NekoScript.hx
By Jason O'Neil, 2011. Licensed under the GPL.
import hscript.Parser;
import neko.Sys;
import neko.FileSystem;
import haxe.Http;
jasononeil / Main.hx
Created Jun 18, 2012
Xirsys_std and erazor do not co-operate
View Main.hx
import erazor.Template;
class Main
public static function main()
var template = new Template("hello @file");
trace(template.execute({ "file": "world" }));
jasononeil / JS Callback to Future
Last active Nov 10, 2015 — forked from kevinresol/ JS Callback to Future
Convert js-style callback to Future, with macro
View JS Callback to Future
Convert js-style callback to Future, with macro
View Builder.hx
import haxe.macro.Context;
import haxe.macro.Expr;
class Builder {
// Build macros are called using @:build() or @:autoBuild() metadata
// They must return an array containing all of the fields of the new type
macro static function build():Array<Field> {
// Create expression representing the test() function
var funcExpr = macro function():String {
return "test";
jasononeil / InitialisationChecker.hx
Last active Dec 14, 2015
Very simple proof of concept for a macro which checks that all member variables and static variables have been initialised. Currently it checks for every single type... so it finds a bunch of errors in the standard library too. Someone may want to fork it and make it a little bit more clever... UPDATE: modified it to only check Int, Float, Strin…
View InitialisationChecker.hx
// Only tested on Neko, Haxe3RC
// Compile and run with:
// haxe -x InitialisationChecker.hx
// Created by Jason O'Neil, 2013. Release public domain.
#if macro
import haxe.macro.Context;
using Lambda;
jasononeil / DOMReady.hx
Last active Dec 15, 2015
A lot of the time in JS we have to wait for the page to finish loading, or at least, for the DOM to be loaded, before we can begin our various operations. Detox makes this easy with the Detox.ready() function, which fires the given function as soon as the DOM is loaded.
View DOMReady.hx
using Detox;
public class DOMReady
static function main()
Detox.ready(function (e) {
Detox.document.title = "Page is ready";
You can’t perform that action at this time.