string interpolation support!
This commit is contained in:
@@ -4,6 +4,7 @@ package bindx;
|
|||||||
|
|
||||||
import bindx.Error;
|
import bindx.Error;
|
||||||
import haxe.macro.Expr;
|
import haxe.macro.Expr;
|
||||||
|
import haxe.macro.MacroStringTools;
|
||||||
import haxe.macro.Type;
|
import haxe.macro.Type;
|
||||||
import haxe.macro.Context;
|
import haxe.macro.Context;
|
||||||
import haxe.macro.Printer;
|
import haxe.macro.Printer;
|
||||||
@@ -74,6 +75,15 @@ class BindExt {
|
|||||||
var prefix = 0;
|
var prefix = 0;
|
||||||
function findChain(expr:Expr) {
|
function findChain(expr:Expr) {
|
||||||
var isChain;
|
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);
|
||||||
|
}
|
||||||
var e = expr;
|
var e = expr;
|
||||||
var ecall = false;
|
var ecall = false;
|
||||||
do switch (e.expr) {
|
do switch (e.expr) {
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ class ExprBindTest extends BuddySuite {
|
|||||||
var b = new BaseTest.Bindable1();
|
var b = new BaseTest.Bindable1();
|
||||||
a.str = "a1";
|
a.str = "a1";
|
||||||
b.str = "b1";
|
b.str = "b1";
|
||||||
inline function val() return b.str + "ab".charAt(a.str.length - 2) + Std.string(1);
|
inline function val() return b.str + '${"ab".charAt(a.str.length - 2)}${Std.string(1)}';
|
||||||
|
|
||||||
BindExt.exprTo(b.str + "ab".charAt(a.str.length - 2) + Std.string(1), target.a);
|
BindExt.exprTo(b.str + '${"ab".charAt(a.str.length - 2)}${Std.string(1)}', target.a);
|
||||||
BindExt.expr(b.str + "ab".charAt(a.str.length - 2) + Std.string(1), function (f, to:String) {
|
BindExt.expr(b.str + '${"ab".charAt(a.str.length - 2)}${Std.string(1)}', function (f, to:String) {
|
||||||
f.should.be(from);
|
f.should.be(from);
|
||||||
from = to;
|
from = to;
|
||||||
to.should.be(val());
|
to.should.be(val());
|
||||||
|
|||||||
Reference in New Issue
Block a user