Skip to content

Instantly share code, notes, and snippets.

@skial
skial / Main.hx
Last active June 26, 2016 23:50
Haxe 3.3.0-rc.1 Abstract @:resolve and @:op(a.b) metadata simplified examples.
package;
import haxe.macro.Expr;
class Main {
static function main() {
var smap:StringMap = ['firstName' => 'Skial', 'lastName' => 'Bainn'];
trace( smap.lastName, smap.firstName ); // Bainn, Skial
@skial
skial / Macro.hx
Last active March 20, 2016 13:09
@:astSource test code, originally for https://github.com/HaxeFoundation/haxe/issues/4959
package;
import haxe.macro.Type;
import haxe.macro.Context;
import haxe.macro.Printer;
class Macro {
// Runs on class `Test`.
public static function build() {
@skial
skial / Main.hx
Last active September 23, 2015 11:49
Unifill Utf8 decoding? problem
package;
import unifill.Utf8;
import unifill.InternalEncoding;
using unifill.Unifill;
/**
* ...
* @author Skial Bainn
@skial
skial / Main.hx
Last active August 29, 2015 14:21
Official Haxe NodeJS Type Definitions - example from https://github.com/HaxeFoundation/hxnodejs used in http://haxe.io/releases/3.2.0/
package;
import js.node.Net;
class Main {
static function main() {
var server = Net.createServer(function(socket) {
socket.write("Echo server\n\n");
socket.pipe(socket);
package js.html;
@:native("Blob")
extern class Blob
{
var size(default,null) : Int;
var type(default,null) : String;
/** @throws DOMError */
@:overload( function() : Void {} )
@skial
skial / Main.hx
Last active August 29, 2015 14:21
Haxe 3.2.0 @:callable example used in http://haxe.io/releases/3.2.0/
package;
@:callable abstract Function<T>(T) from T {}
class Main {
static function main() {
var a:Function<Int->Int> = function(v) return v * v;
a(31);
}
@skial
skial / Main.hx
Last active February 25, 2021 06:41
Haxe 3.2.0 @:selfCall example used in http://haxe.io/releases/3.2.0/
package;
extern class A {
@:selfCall public function new(v:String);
@:selfCall public function run():Void;
}
extern class B {
@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>']);
}
@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 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!' );
}
}