Mercurial Hosting > luan
changeset 429:e3a6d9dbd694
rename __tostring to __to_string
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 02 May 2015 20:13:24 -0600 |
parents | df95199ca4c0 |
children | f28320fd671d |
files | core/src/luan/LuanBit.java core/src/luan/LuanMeta.java website/src/manual.html.luan |
diffstat | 3 files changed, 7 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
diff -r df95199ca4c0 -r e3a6d9dbd694 core/src/luan/LuanBit.java --- a/core/src/luan/LuanBit.java Sat May 02 20:10:31 2015 -0600 +++ b/core/src/luan/LuanBit.java Sat May 02 20:13:24 2015 -0600 @@ -90,15 +90,15 @@ public String toString(Object obj) throws LuanException { if( obj instanceof LuanTable ) { LuanTable tbl = (LuanTable)obj; - Object h = tbl.getHandler("__tostring"); + Object h = tbl.getHandler("__to_string"); if( h instanceof LuanMeta ) { LuanMeta meta = (LuanMeta)h; - return meta.__tostring(luan,tbl); + return meta.__to_string(luan,tbl); } if( h != null ) { LuanFunction fn = checkFunction(h); if( fn != null ) - return checkString( Luan.first( call(fn,"__tostring",new Object[]{obj}) ) ); + return checkString( Luan.first( call(fn,"__to_string",new Object[]{obj}) ) ); } } return Luan.toString(obj);
diff -r df95199ca4c0 -r e3a6d9dbd694 core/src/luan/LuanMeta.java --- a/core/src/luan/LuanMeta.java Sat May 02 20:10:31 2015 -0600 +++ b/core/src/luan/LuanMeta.java Sat May 02 20:13:24 2015 -0600 @@ -47,7 +47,7 @@ protected abstract String type(LuanTable tbl); - public String __tostring(LuanState luan,LuanTable tbl) throws LuanException { + public String __to_string(LuanState luan,LuanTable tbl) throws LuanException { return type(tbl) + "-" + tbl; } @@ -55,7 +55,7 @@ LuanTable mt = new LuanTable(); mt.rawPut( "__index", this ); mt.rawPut( "__pairs", this ); - mt.rawPut( "__tostring", this ); + mt.rawPut( "__to_string", this ); if( canNewindex() ) mt.rawPut( "__new_index", this ); return mt;
diff -r df95199ca4c0 -r e3a6d9dbd694 website/src/manual.html.luan --- a/website/src/manual.html.luan Sat May 02 20:10:31 2015 -0600 +++ b/website/src/manual.html.luan Sat May 02 20:13:24 2015 -0600 @@ -2290,7 +2290,7 @@ <p> -If the metatable of <code>v</code> has a <code>"__tostring"</code> field, +If the metatable of <code>v</code> has a <code>"__to_string"</code> field, then <code>tostring</code> calls the corresponding value with <code>v</code> as argument, and uses the result of the call as its result. @@ -5229,7 +5229,7 @@ In case of unprotected errors in the script, the interpreter reports the error to the standard error stream. If the error object is not a string but -has a metamethod <code>__tostring</code>, +has a metamethod <code>__to_string</code>, the interpreter calls this metamethod to produce the final message. Otherwise, the interpreter converts the error object to a string and adds a stack traceback to it.