Skip to content

Instantly share code, notes, and snippets.

@skial
skial / MacroHijacked.hx
Created February 20, 2014 14:10
Initial step towards creating `Hijacked` type's. Probably a more appropriate name for this.
package ;
import haxe.macro.Type;
import haxe.macro.Expr;
import haxe.macro.Context;
using haxe.macro.Tools;
class MacroHijacked {
package ;
import byte.ByteData;
class Main {
public static function main() {
var l = new RandomLexer( ByteData.ofString( '<tag><hello></hello><world></world></tag>' ), 'random-pause' );
var t = [];
try while (true) t.push( l.token( RandomLexer.root ) ) catch (e:Dynamic) trace( e );
@skial
skial / Macro.hx
Created October 29, 2014 11:35
How to collect values across multiple @:autoBuild macro runs. Using Haxe 3.2.0 (git build development @ 3a255a8).
package ;
import haxe.ds.StringMap;
import haxe.macro.Compiler;
import haxe.macro.Printer;
import haxe.macro.Type;
import haxe.macro.Expr;
import haxe.macro.Context;
using StringTools;
package ;
/**
* ...
* @author Skial Bainn
*/
class Main {
public static function main() new Main();
@skial
skial / Macro.hx
Created March 16, 2015 14:57
Abusing macros causes flat js packages mixed with normal dotted packages.
package;
#if macro
import haxe.macro.Compiler;
import haxe.macro.Context;
import haxe.macro.Expr;
#end
class Macro {
@skial
skial / Macro.hx
Last active August 29, 2015 14:17
Compiler.exclude and flat js package issue
package;
#if macro
import haxe.macro.Compiler;
import haxe.macro.Context;
import haxe.macro.Expr;
#end
class Macro {
@skial
skial / Macro.hx
Created March 17, 2015 15:02
Change with the output order, but not the execution order of classes using Haxe 3.2.0.rc.1 and node.
package;
import haxe.ds.StringMap;
import haxe.macro.Type;
import haxe.macro.Expr;
import haxe.macro.Context;
import haxe.macro.Compiler;
using StringTools;
@skial
skial / Main.hx
Last active August 29, 2015 14:21
Haxe 3.2.0 Python Output used in http://haxe.io/releases/3.2.0/
package;
class Main {
static function main() {
for (projectile in ['apples', 'oranges']) trace( 'I threw $projectile!' );
}
}
@skial
skial / Main.hx
Last active August 29, 2015 14:21
Haxe 3.2.0 Python Extern Rest example used in http://haxe.io/releases/3.2.0/
package;
import python.lib.os.Path;
class Main {
static function main() {
trace( Path.join('C:\\', 'myPath') );
trace( Path.join('C:\\', 'my', 'longer', 'python', 'powered', 'path' ) );
}
@skial
skial / Main.hx
Last active August 29, 2015 14:21
Haxe 3.2.0 EitherType example used in http://haxe.io/releases/3.2.0/
package;
import js.html.Blob;
class Main {
static function main() {
var blob1 = new Blob(['<a href="http://haxememes.tumblr.com/post/52244226107/type-inference">Haxe Memes</a>']);
var blob2 = new Blob([blob1, '<a href="http://haxememes.tumblr.com/post/98160270445/simon-working-on-haxe">Haxe Memes</a>']);
}