This file contains hidden or 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.PosInfos; | |
class TraceMemberMethod | |
{ | |
static function main() new TraceMemberMethod(); | |
public function new() { | |
messages = []; | |
trace( "hey" ); // Uses haxe.Log.trace() |
This file contains hidden or 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 -js AbstractExample.js -dce full -main AbstractExample.hx` | |
import js.html.AnchorElement; | |
class AbstractExample { | |
static function main() { | |
var myAnchor = new MyAnchor( "http://google.com", "Click here!" ); | |
expectsAnchor( myAnchor ); // Notice how it automatically casts back down to AnchorElement | |
} |
This file contains hidden or 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(){ | |
stringOrInt( "hello" ); | |
stringOrInt( 10 ); | |
} | |
static function stringOrInt( either:AcceptEither<String,Int> ) { | |
switch either.type { | |
case Left(str): trace("string: "+str); | |
case Right(int): trace("int: "+int); |
This file contains hidden or 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 hidden or 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 hidden or 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 Metric { | |
static function main() { | |
var coinRadius:Millimeters = 12; | |
var myHeight:Centimeters = 180; | |
var raceLength:Meters = 200; | |
var commuteDistance:Kilometers = 23; | |
diff( coinRadius, myHeight ); // 1.788 meters | |
diff( raceLength, commuteDistance ); // 22800 meters | |
sum( commuteDistance, coinRadius ); // 23000.012 meters |
This file contains hidden or 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 hidden or 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 hidden or 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 ReflectionCost { | |
public static function main() { | |
var obj = new ReflectionCost(); | |
#if reflect | |
Reflect.setField( obj, "name", "Jason" ); | |
Reflect.callMethod( obj, Reflect.field(obj, "printName"), [] ); | |
Type.getInstanceFields( Type.getClass(obj) ); | |
#else | |
obj.name = "Jason"; | |
obj.printName(); |
This file contains hidden or 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
browsertime.pageSummary.browserScripts.0.pageinfo.documentHeight | |
browsertime.pageSummary.browserScripts.0.pageinfo.documentWidth | |
browsertime.pageSummary.browserScripts.0.pageinfo.responsive | |
browsertime.pageSummary.browserScripts.0.timings.firstPaint | |
browsertime.pageSummary.browserScripts.0.timings.fullyLoaded | |
browsertime.pageSummary.browserScripts.0.timings.navigationTiming.connectEnd | |
browsertime.pageSummary.browserScripts.0.timings.navigationTiming.connectStart | |
browsertime.pageSummary.browserScripts.0.timings.navigationTiming.domComplete | |
browsertime.pageSummary.browserScripts.0.timings.navigationTiming.domContentLoadedEventEnd | |
browsertime.pageSummary.browserScripts.0.timings.navigationTiming.domContentLoadedEventStart |