warning updates in Bind.hx
This commit is contained in:
+8
-12
@@ -39,13 +39,8 @@ class Bind {
|
|||||||
|
|
||||||
public static function internalBind(field:Expr, listener:Expr, doBind:Bool):Expr {
|
public static function internalBind(field:Expr, listener:Expr, doBind:Bool):Expr {
|
||||||
var fieldData = warnCheckField(field);
|
var fieldData = warnCheckField(field);
|
||||||
return if (fieldData != null) {
|
return if (doBind) BindMacros.bindingSignalProvider.getClassFieldBindExpr(fieldData.e, fieldData.field, listener);
|
||||||
if (doBind) BindMacros.bindingSignalProvider.getClassFieldBindExpr(fieldData.e, fieldData.field, listener);
|
|
||||||
else BindMacros.bindingSignalProvider.getClassFieldUnbindExpr(fieldData.e, fieldData.field, listener);
|
else BindMacros.bindingSignalProvider.getClassFieldUnbindExpr(fieldData.e, fieldData.field, listener);
|
||||||
} else {
|
|
||||||
Context.fatalError('can\'t bind field ${field.expr}', field.pos);
|
|
||||||
macro {};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function internalBindTo(field:Expr, target:Expr):Expr {
|
public static function internalBindTo(field:Expr, target:Expr):Expr {
|
||||||
@@ -114,16 +109,17 @@ class Bind {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function isBindable(classType:ClassType):Bool {
|
public static function isBindable(classType:ClassType):Bool {
|
||||||
if (classType.module == "bindx.IBindable" && classType.name == "IBindable")
|
var check = [classType];
|
||||||
return true;
|
while (check.length > 0) {
|
||||||
|
var t = check.shift();
|
||||||
var t = classType;
|
|
||||||
while (t != null) {
|
while (t != null) {
|
||||||
for (it in t.interfaces)
|
if (t.module == "bindx.IBindable" && t.name == "IBindable")
|
||||||
if (isBindable(it.t.get()))
|
|
||||||
return true;
|
return true;
|
||||||
|
for (it in t.interfaces)
|
||||||
|
check.push(it.t.get());
|
||||||
t = t.superClass != null ? t.superClass.t.get() : null;
|
t = t.superClass != null ? t.superClass.t.get() : null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package bindx;
|
package bindx;
|
||||||
|
|
||||||
|
import bindx.Error;
|
||||||
import haxe.macro.Type;
|
import haxe.macro.Type;
|
||||||
import haxe.macro.Expr;
|
import haxe.macro.Expr;
|
||||||
import haxe.macro.Context;
|
import haxe.macro.Context;
|
||||||
@@ -62,7 +63,7 @@ class BindMacros {
|
|||||||
var inlineSetter = meta.findParam(INLINE_SETTER);
|
var inlineSetter = meta.findParam(INLINE_SETTER);
|
||||||
if (forceParam.isNotNullAndTrue()) {
|
if (forceParam.isNotNullAndTrue()) {
|
||||||
if (inlineSetter != null)
|
if (inlineSetter != null)
|
||||||
Context.warning('\'$INLINE_SETTER\' ignored. \'$FORCE\' mode', inlineSetter.pos);
|
Warn.w('\'$INLINE_SETTER\' ignored. \'$FORCE\' mode', inlineSetter.pos, WarnPriority.INFO);
|
||||||
res.push(field);
|
res.push(field);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -91,7 +92,7 @@ class BindMacros {
|
|||||||
|
|
||||||
case FProp(get, set, type, expr):
|
case FProp(get, set, type, expr):
|
||||||
if (inlineSetter != null)
|
if (inlineSetter != null)
|
||||||
Context.warning('$INLINE_SETTER ignored. Setter already exist', inlineSetter.pos);
|
Warn.w('$INLINE_SETTER ignored. Setter already exist', inlineSetter.pos, WarnPriority.INFO);
|
||||||
var fieldName = field.name;
|
var fieldName = field.name;
|
||||||
var setter = fields.find(function (it) return it.name == 'set_$fieldName');
|
var setter = fields.find(function (it) return it.name == 'set_$fieldName');
|
||||||
if (setter != null) {
|
if (setter != null) {
|
||||||
@@ -111,7 +112,7 @@ class BindMacros {
|
|||||||
|
|
||||||
case FFun(f):
|
case FFun(f):
|
||||||
if (inlineSetter != null)
|
if (inlineSetter != null)
|
||||||
Context.warning('methods doesn\'t support \'$INLINE_SETTER\'', inlineSetter.pos);
|
Warn.w('methods doesn\'t support \'$INLINE_SETTER\'', inlineSetter.pos, WarnPriority.INFO);
|
||||||
res.push(field);
|
res.push(field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,8 +151,7 @@ class BindMacros {
|
|||||||
static function isFieldBindable(field:Field, fields:Array<Field>, force = false):Bool {
|
static function isFieldBindable(field:Field, fields:Array<Field>, force = false):Bool {
|
||||||
if (field.name == "new") return false;
|
if (field.name == "new") return false;
|
||||||
|
|
||||||
if (field.access.exists(function (it) return it.equals(AMacro) || it.equals(ADynamic) || it.equals(AStatic)))
|
if (field.access.exists(function (it) return it.equals(AMacro) || it.equals(ADynamic) || it.equals(AStatic))) return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
if (field.name.startsWith("set_") || field.name.startsWith("get_")) {
|
if (field.name.startsWith("set_") || field.name.startsWith("get_")) {
|
||||||
var propName = field.name.substr(4);
|
var propName = field.name.substr(4);
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package bindx;
|
package bindx;
|
||||||
|
|
||||||
|
#if macro
|
||||||
|
|
||||||
import haxe.macro.Expr;
|
import haxe.macro.Expr;
|
||||||
import haxe.macro.Type;
|
import haxe.macro.Type;
|
||||||
|
|
||||||
interface IBindingSignalProvider {
|
interface IBindingSignalProvider {
|
||||||
#if macro
|
|
||||||
function getFieldDispatcher(field:Field, result:Array<Field>):Void;
|
function getFieldDispatcher(field:Field, result:Array<Field>):Void;
|
||||||
function getFieldChangedExpr(field:Field, oldValue:Expr, newValue:Expr):Expr;
|
function getFieldChangedExpr(field:Field, oldValue:Expr, newValue:Expr):Expr;
|
||||||
|
|
||||||
@@ -13,5 +15,7 @@ interface IBindingSignalProvider {
|
|||||||
function getClassFieldUnbindExpr(expr:Expr, field:ClassField, listener:Expr):Expr;
|
function getClassFieldUnbindExpr(expr:Expr, field:ClassField, listener:Expr):Expr;
|
||||||
function getClassFieldChangedExpr(expr:Expr, field:ClassField, oldValue:Expr, newValue:Expr):Expr;
|
function getClassFieldChangedExpr(expr:Expr, field:ClassField, oldValue:Expr, newValue:Expr):Expr;
|
||||||
function getUnbindAllExpr(expr:ExprOf<IBindable>, type:Type):Expr;
|
function getUnbindAllExpr(expr:ExprOf<IBindable>, type:Type):Expr;
|
||||||
#end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#end
|
||||||
Reference in New Issue
Block a user