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
/** | |
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() { |
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 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; |
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; | |
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): |
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
Convert js-style callback to Future, with macro |
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" |
OlderNewer