Mercurial Hosting > luan
changeset 440:93e6e67768d7
remove Luan.asString()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 04 May 2015 11:34:38 -0600 |
parents | 057c10f55f72 |
children | aedb90df53ce |
files | core/src/luan/Luan.java core/src/luan/LuanBit.java core/src/luan/modules/StringLuan.java core/src/luan/modules/TableLuan.java |
diffstat | 4 files changed, 6 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/core/src/luan/Luan.java Mon May 04 11:21:46 2015 -0600 +++ b/core/src/luan/Luan.java Mon May 04 11:34:38 2015 -0600 @@ -51,14 +51,6 @@ return obj != null && !Boolean.FALSE.equals(obj); } - public static String asString(Object obj) { - if( obj instanceof String ) - return (String)obj; - if( obj instanceof Number ) - return toString((Number)obj); - return null; - } - public static Number toNumber(Object obj) { return toNumber(obj,null); }
--- a/core/src/luan/LuanBit.java Mon May 04 11:21:46 2015 -0600 +++ b/core/src/luan/LuanBit.java Mon May 04 11:34:38 2015 -0600 @@ -42,9 +42,8 @@ } public String checkString(Object obj) throws LuanException { - String s = Luan.asString(obj); - if( s != null ) - return s; + if( obj instanceof String ) + return (String)obj; if( el instanceof LuanSource.Element ) { LuanSource.Element se = (LuanSource.Element)el; throw exception( "attempt to use '"+se.text()+"' (a " + Luan.type(obj) + " value) as a string" );
--- a/core/src/luan/modules/StringLuan.java Mon May 04 11:21:46 2015 -0600 +++ b/core/src/luan/modules/StringLuan.java Mon May 04 11:34:38 2015 -0600 @@ -182,7 +182,7 @@ String match = m.groupCount()==0 ? m.group() : m.group(1); Object val = t.get(luan,match); if( Luan.toBoolean(val) ) { - String replacement = Luan.asString(val); + String replacement = luan.checkString(val); if( replacement==null ) throw luan.exception( "invalid replacement value (a "+Luan.type(val)+")" ); m.appendReplacement(sb,replacement); @@ -209,7 +209,7 @@ } Object val = Luan.first( luan.call(fn,"repl-arg",args) ); if( Luan.toBoolean(val) ) { - String replacement = Luan.asString(val); + String replacement = luan.checkString(val); if( replacement==null ) throw luan.exception( "invalid replacement value (a "+Luan.type(val)+")" ); m.appendReplacement(sb,replacement);
--- a/core/src/luan/modules/TableLuan.java Mon May 04 11:21:46 2015 -0600 +++ b/core/src/luan/modules/TableLuan.java Mon May 04 11:34:38 2015 -0600 @@ -26,10 +26,8 @@ break; if( sep!=null && k > first ) buf.append(sep); - String s = Luan.asString(val); - if( s==null ) - throw luan.exception( "invalid value ("+Luan.type(val)+") at index "+k+" in table for 'concat'" ); - buf.append(val); + String s = luan.toString(val); + buf.append(s); } return buf.toString(); }