From 361cdbe65e25921f80bf1cc3a9e15b9002568f21 Mon Sep 17 00:00:00 2001 From: Dima Granetchi Date: Tue, 9 Dec 2014 22:43:48 +0200 Subject: [PATCH] unwrapFormatedString --- src/bindx/BindExt.hx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/bindx/BindExt.hx b/src/bindx/BindExt.hx index 804c795..a526329 100644 --- a/src/bindx/BindExt.hx +++ b/src/bindx/BindExt.hx @@ -62,6 +62,16 @@ class BindExt { )($listener); } + static inline function unwrapFormatedString(expr:Expr):Expr { + return if (MacroStringTools.isFormatExpr(expr)) { + var f = switch (expr.expr) { + case EConst(CString(s)): s; + case _: null; + } + if (f != null) MacroStringTools.formatString(f, expr.pos) else expr; + } else expr; + } + static function internalBindExpr(expr:Expr, listener:Expr):Expr { var type = Context.typeof(expr).toComplexType(); var listenerNameExpr = macro listener; @@ -75,15 +85,7 @@ class BindExt { var prefix = 0; function findChain(expr:Expr) { var isChain; - - if (MacroStringTools.isFormatExpr(expr)) { - var f = switch (expr.expr) { - case EConst(CString(s)): s; - case _: null; - } - if (f != null) - expr = MacroStringTools.formatString(f, expr.pos); - } + expr = unwrapFormatedString(expr); var e = expr; var ecall = false; do switch (e.expr) {