comparison src/luan/lib/StringLib.java @ 46:a443637829c1

remove LuaNumber git-svn-id: https://luan-java.googlecode.com/svn/trunk@47 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Thu, 27 Dec 2012 01:48:36 +0000
parents 57054fa43189
children 64ecb7a3aad7
comparison
equal deleted inserted replaced
45:b1b14d09fc98 46:a443637829c1
5 import luan.Lua; 5 import luan.Lua;
6 import luan.LuaState; 6 import luan.LuaState;
7 import luan.LuaTable; 7 import luan.LuaTable;
8 import luan.LuaFunction; 8 import luan.LuaFunction;
9 import luan.LuaJavaFunction; 9 import luan.LuaJavaFunction;
10 import luan.LuaNumber;
11 import luan.LuaElement; 10 import luan.LuaElement;
12 import luan.LuaException; 11 import luan.LuaException;
13 12
14 13
15 public final class StringLib { 14 public final class StringLib {
155 while( i<max && m.find() ) { 154 while( i<max && m.find() ) {
156 m.appendReplacement(sb,replacement); 155 m.appendReplacement(sb,replacement);
157 i++; 156 i++;
158 } 157 }
159 m.appendTail(sb); 158 m.appendTail(sb);
160 return new Object[]{ sb.toString(), LuaNumber.of(i) }; 159 return new Object[]{ sb.toString(), i };
161 } 160 }
162 if( repl instanceof LuaTable ) { 161 if( repl instanceof LuaTable ) {
163 LuaTable t = (LuaTable)repl; 162 LuaTable t = (LuaTable)repl;
164 int i = 0; 163 int i = 0;
165 StringBuffer sb = new StringBuffer(); 164 StringBuffer sb = new StringBuffer();
173 m.appendReplacement(sb,replacement); 172 m.appendReplacement(sb,replacement);
174 } 173 }
175 i++; 174 i++;
176 } 175 }
177 m.appendTail(sb); 176 m.appendTail(sb);
178 return new Object[]{ sb.toString(), LuaNumber.of(i) }; 177 return new Object[]{ sb.toString(), i };
179 } 178 }
180 if( repl instanceof LuaFunction ) { 179 if( repl instanceof LuaFunction ) {
181 LuaFunction fn = (LuaFunction)repl; 180 LuaFunction fn = (LuaFunction)repl;
182 int i = 0; 181 int i = 0;
183 StringBuffer sb = new StringBuffer(); 182 StringBuffer sb = new StringBuffer();
200 m.appendReplacement(sb,replacement); 199 m.appendReplacement(sb,replacement);
201 } 200 }
202 i++; 201 i++;
203 } 202 }
204 m.appendTail(sb); 203 m.appendTail(sb);
205 return new Object[]{ sb.toString(), LuaNumber.of(i) }; 204 return new Object[]{ sb.toString(), i };
206 } 205 }
207 throw new LuaException( lua, LuaElement.JAVA, "bad argument #3 to 'gsub' (string/function/table expected)" ); 206 throw new LuaException( lua, LuaElement.JAVA, "bad argument #3 to 'gsub' (string/function/table expected)" );
208 } 207 }
209 208
210 } 209 }