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
/** | |
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) |
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
/** | |
NekoScript | |
By Jason O'Neil, 2011. Licensed under the GPL. | |
*/ | |
import hscript.Parser; | |
import neko.Sys; | |
import neko.FileSystem; | |
import neko.io.File; | |
import haxe.Http; |
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 erazor.Template; | |
class Main | |
{ | |
public static function main() | |
{ | |
var template = new Template("hello @file"); | |
trace(template.execute({ "file": "world" })); | |
} | |
} |
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; | |
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"; |
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
// 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; | |
#end |
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 Detox; | |
public class DOMReady | |
{ | |
static function main() | |
{ | |
Detox.ready(function (e) { | |
Detox.document.title = "Page is ready"; | |
}); | |
} |
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
/** | |
* Macro Compiler Define example | |
* | |
* Shows how to use a compiler configuration macro to set up more "defines" based | |
* on an existing define. | |
* | |
* Jason O'Neil 2013. Use as you please. | |
* | |
* haxe -D mydebug --macro "MacroDefine.setDefines()" -x MacroDefine.hx | |
* -- traces "A" and "B" |
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 with: haxe -main WebSocketTest.hx -js WebSocketTest.js | |
// Doing your imports like this makes it much easier to port with existing Javascript code. | |
import js.Browser.window; | |
import js.Browser.document; | |
import js.html.*; | |
class WebSocketTest | |
{ | |
static var wsUri = "ws://echo.websocket.org/"; |
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 sys.db.Types; | |
using Lambda; | |
/** | |
* What this class shows: | |
* | |
* Using a custom serialiser for SPOD can reduce speeds by more than half. | |
* Have a build macro append a static array containing the names of the fields to serialise. | |
*/ |
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 ClassicSwitch | |
{ | |
macro static public function from(inExpr:Expr):Expr | |
{ | |
var retExpr:Expr = null; | |
switch (inExpr.expr) |
OlderNewer