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
class Main { | |
macro static function compileJson(path:String) { | |
return haxe.macro.Context.parseInlineString(sys.io.File.getContent(path), haxe.macro.Context.currentPos()); | |
} | |
static function main() { | |
final a = compileJson("test.json"); | |
trace(a); | |
a.obj.sub += 1; | |
trace(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
using Test; | |
class Test { | |
var A (default, never): Int = 1; | |
public function new() { | |
} | |
public function set(value:Int) { | |
trace(value); |
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
package luautils; | |
import lua.Lua; | |
import lua.Table in LuaTable; | |
abstract Table<K, V> (LuaTable<K, V>) from LuaTable<K, V> | |
{ | |
function new (table:LuaTable<K, V>) this = table; | |
@:from static function fromMap<K, V> (map:Map<K, V>) : Table<K, V> |
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 haxe.macro.Context; | |
#if !macro | |
@:genericBuild(GenericClass.build()) | |
#end | |
class GenericClass<@:const Content> { | |
public static function build () { | |
return switch (Context.getLocalType()) | |
{ | |
case TInst(_, [TInst(_.get() => { kind: KExpr(macro $v{(s:String)}) }, _)]): |
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
// haxe -main Host -cpp host | |
// ./host/Host ./lib/Main.dso | |
class Host { | |
public static function main () { | |
var lib = Dl.open(Sys.args()[0], Dl.RTLD_NOW); | |
if (lib == null) { | |
trace("can't find library"); | |
Sys.exit(1); | |
} |
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
#include <fstream> | |
#include <iostream> | |
#include <sstream> | |
#include <unordered_map> | |
#include <vector> | |
#include "constraint_solver/constraint_solver.h" | |
// Unzip https://github.com/google/or-tools/releases/tag/v2015-12 next to this file |
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 haxe.macro.Expr; | |
import haxe.macro.Context; | |
class GenNew | |
{ | |
macro public static function build () : Array<Field> | |
{ | |
var fields = Context.getBuildFields(); | |
var args = []; | |
var assigns = []; |
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
class Test { | |
static function main() { | |
trace(isDemo()); | |
} | |
macro static function isDemo () : haxe.macro.Expr | |
{ | |
return macro $v{haxe.macro.Compiler.getDefine("demo") != null}; | |
} | |
} |
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
class Test { | |
static function main() { | |
var ar = new MyArray<Int>([1, 2, 5]); | |
trace(ar); | |
ar.length = 5; | |
trace(ar); | |
ar.length = 2; | |
trace(ar); | |
var ar2 = new MyArray<Float>([1.1, 2.2, 5.5]); |
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 com.haxepunk.Engine; | |
import com.haxepunk.HXP; | |
import com.haxepunk.utils.Draw; | |
class Main extends Engine | |
{ | |
override public function init() | |
{ | |
#if debug |
NewerOlder