Skip to content

Instantly share code, notes, and snippets.

@andyli
andyli / AbstractClass.hx
Last active June 24, 2021 13:40
Java abstract class implemented in Haxe macros. Related: https://groups.google.com/forum/?fromgroups=#!topic/haxelang/WzeI-N1XbIg
import haxe.macro.Context;
import haxe.macro.Expr;
import haxe.macro.Type;
using Lambda;
/**
Old school abstract class.
Classes that implements it, and their sub-classes, will be able to declare abstract methods (methods that without body).
There will be a check in compile-time such that no public constructor is allowed without all abstract methods implemented.
*/
Index: std/haxe/macro/ComplexTypeTools.hx
===================================================================
--- std/haxe/macro/ComplexTypeTools.hx (revision 6236)
+++ std/haxe/macro/ComplexTypeTools.hx (working copy)
@@ -48,7 +48,7 @@
If [c] is null, the result is null.
**/
static public function toType( c : ComplexType ) : Null<Type>
- return c == null ? null : haxe.macro.Context.typeof( { expr: ECheckType(macro null, c), pos: Context.currentPos() } )
+ return c == null ? null : haxe.macro.Context.typeof( { expr: ECheckType(macro null, c), pos: Context.currentPos() } );
Index: std/haxe/macro/Printer.hx
===================================================================
--- std/haxe/macro/Printer.hx (revision 6202)
+++ std/haxe/macro/Printer.hx (working copy)
@@ -113,10 +113,11 @@
case ADynamic: "dynamic";
case AMacro: "macro";
}
-
+
@andyli
andyli / Makefile
Created October 20, 2012 22:59
Makefile for compiling TypeScript compiler on a Unix system.
BIN=$(BASE)bin
BUILT=$(BASE)built
BUILT_LOCAL=$(BUILT)/local
BUILT_LOCALTEST=$(BUILT)/localtest
HOST=$(TYPESCRIPT_HOST)
#compiler source location
CSRC=$(BASE)src/compiler
@andyli
andyli / gist:3738772
Created September 17, 2012 17:56
NME Android crash log
09-18 01:47:07.976 134 214 I Adreno200-EGLSUB: <CreateImage:893>: Android Image
09-18 01:47:07.976 134 214 I Adreno200-EGLSUB: <GetImageAttributes:1102>: RGBA_8888
09-18 01:47:08.016 376 376 I ActivityManager: START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=net.onthewings.bezelcursor/.MainActivity bnds=[0,581][180,807]} from pid 5454
09-18 01:47:08.016 376 376 I am_create_task: 369
09-18 01:47:08.016 376 376 I am_create_activity: [1105649936,369,net.onthewings.bezelcursor/.MainActivity,android.intent.action.MAIN,NULL,NULL,270532608]
09-18 01:47:08.056 376 376 I am_pause_activity: [1106162912,com.sonyericsson.home/.HomeActivity]
09-18 01:47:08.106 134 11115 D memalloc: /dev/pmem: Allocated buffer base:0x4291f000 size:3768320 offset:40681472 fd:37
09-18 01:47:08.116 376 437 D memalloc: /dev/pmem: Mapped buffer base:0x68fe6000 size:44449792 offset:40681472 fd:284
09-18 01:47:08.126 134 214 I Adreno200-EGLSUB: <CreateImage:893>: And
@andyli
andyli / Limit.hx
Created September 14, 2012 16:07
new haxe metadata proposal
package mylib;
//extends or implements a special class/interface
class Limit implements haxe.rtti.Meta {
//the 1st param tell what kinds of field it applies, just like "using"
//Used as @limitMinMax(0, 100) or @mylib.Limit.limitMinMax(0, 100)
static public function limitMinMax(field:Float, min:Float, max:Float):Bool {
//return whether the input is valid
return min <= max;
package;
/*
* 1€ Filter http://www.lifl.fr/~casiez/1euro/
* Haxe version by Andy Li (andy@onthewings.net)
*
* Based on OneEuroFilter.cc - Nicolas Roussel (nicolas.roussel@inria.fr)
*/
class OneEuroFilter {
@andyli
andyli / Test.hx
Created July 23, 2012 16:31
Haxe completion gives invalid xml
class Test {
/**
* Center's the Entity's origin (half width & height).
*/
public var a:Bool;
public function new():Void {
this.
}
@andyli
andyli / Test.hx
Created July 23, 2012 10:28
fakeEnum
@:fakeEnum(String)
extern enum StageAlign {
BOTTOM;
}
@:native ("StageAlign")
class StageAlign_impl {
static public var BOTTOM = "_bottom_";
}
@andyli
andyli / haxe.php
Created July 13, 2012 20:13
Add haxe syntax to GeSHi
<?php
/*************************************************************************************
* haxe.php
* --------
* Author: Andy Li (andy@onthewings.net)
* John Liao (colorhook@gmail.com)
* Copyright: (c) 2012 onthewings (http://www.onthewings.net/)
* 2010 colorhook (http://colorhook.com/)
* Release Version: 1.1.0.0
* Date Started: 2010/10/05