Reputation: 10862
Normally I would just use Type.getClassName(Type.getClass(this)
, but obviously that doesn't work because there is no this
. Any ideas?
Upvotes: 2
Views: 750
Reputation: 6023
If that is a static method, since there is no static member inheritance in Haxe, you already know what class it belongs to. So I would recommend hard-coding the class.
Or, you can use... macros!
import haxe.macro.Context;
import haxe.macro.Expr;
class ClassNameHelper {
macro static public function getClassName():ExprOf<String> {
return { expr: EConst(CString(Context.getLocalClass().toString())), pos: Context.currentPos() }
}
}
class Test {
public static function main() {
trace(ClassNameHelper.getClassName()); //Test
}
}
Upvotes: 6