Support haxe/java oddities.
This commit is contained in:
@@ -4,8 +4,8 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"tags": ["tink", "macro", "utility"],
|
"tags": ["tink", "macro", "utility"],
|
||||||
"description": "The macro toolkit ;)",
|
"description": "The macro toolkit ;)",
|
||||||
"version": "0.0.1-beta",
|
"version": "0.0.2-beta",
|
||||||
"releasenote": "Minor enhancements.",
|
"releasenote": "Support haxe/java oddities.",
|
||||||
"contributors": ["back2dos"],
|
"contributors": ["back2dos"],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tink_core": "1.0.0-beta.4"
|
"tink_core": "1.0.0-beta.4"
|
||||||
|
|||||||
@@ -48,28 +48,36 @@ class ClassBuilder {
|
|||||||
if (constructor == null)
|
if (constructor == null)
|
||||||
if (fallback != null)
|
if (fallback != null)
|
||||||
new Constructor(fallback);
|
new Constructor(fallback);
|
||||||
else if (target.superClass != null && target.superClass.t.get().constructor != null) {
|
else {
|
||||||
try {
|
var sup = target.superClass;
|
||||||
var ctor = Context.getLocalClass().get().superClass.t.get().constructor.get();
|
while (sup != null) {
|
||||||
var func = Context.getTypedExpr(ctor.expr()).getFunction().sure();
|
var cl = sup.t.get();
|
||||||
|
if (cl.constructor != null) {
|
||||||
//TODO: Check that the code below is no longer necessary
|
try {
|
||||||
// for (arg in func.args)
|
var ctor = cl.constructor.get();
|
||||||
// arg.type = null;
|
var func = Context.getTypedExpr(ctor.expr()).getFunction().sure();
|
||||||
|
|
||||||
func.expr = "super".resolve().call(func.getArgIdents());
|
for (arg in func.args) //this is to deal with type parameter substitutions
|
||||||
constructor = new Constructor(func);
|
arg.type = null;
|
||||||
if (ctor.isPublic)
|
|
||||||
constructor.publish();
|
func.expr = "super".resolve().call(func.getArgIdents());
|
||||||
|
constructor = new Constructor(func);
|
||||||
|
if (ctor.isPublic)
|
||||||
|
constructor.publish();
|
||||||
|
}
|
||||||
|
catch (e:Dynamic) {//fails for unknown reason
|
||||||
|
if (e == 'assert')
|
||||||
|
neko.Lib.rethrow(e);
|
||||||
|
constructor = new Constructor(null);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else sup = cl.superClass;
|
||||||
}
|
}
|
||||||
catch (e:Dynamic) {//fails for unknown reason
|
if (constructor == null)
|
||||||
if (e == 'assert')
|
|
||||||
neko.Lib.rethrow(e);
|
|
||||||
constructor = new Constructor(null);
|
constructor = new Constructor(null);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
constructor = new Constructor(null);
|
|
||||||
return constructor;
|
return constructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,8 +87,23 @@ class Constructor {
|
|||||||
var tmp = MacroApi.tempName();
|
var tmp = MacroApi.tempName();
|
||||||
|
|
||||||
if (options.bypass) {
|
if (options.bypass) {
|
||||||
addStatement(macro @:pos(pos) if (false) { var $tmp = this.$name; $i{tmp} = $e; }, true);
|
if (haxe.macro.Context.defined('java')) {
|
||||||
addStatement(macro @:pos(pos) (untyped this).$name = $e, options.prepend);
|
addStatement(
|
||||||
|
macro @:pos(pos)
|
||||||
|
if (Math.random() < .0) {
|
||||||
|
//if this is false, then it gets thrown out before reaching the backend which will then generate invalid code
|
||||||
|
var $tmp = this.$name;
|
||||||
|
$i{tmp} = $e;
|
||||||
|
this.$name = $i{tmp};
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
|
addStatement(macro @:pos(pos) (cast this).$name = $e, options.prepend);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
addStatement(macro @:pos(pos) if (false) { var $tmp = this.$name; $i{tmp} = $e; }, true);
|
||||||
|
addStatement(macro @:pos(pos) (cast this).$name = $e, options.prepend);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
addStatement(macro @:pos(pos) this.$name = $e, options.prepend);
|
addStatement(macro @:pos(pos) this.$name = $e, options.prepend);
|
||||||
|
|||||||
Reference in New Issue
Block a user