comparison core/src/luan/modules/Utils.java @ 637:6ea90dc10375

bbcode parser now takes a quoter function
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 03 Mar 2016 12:38:24 -0700
parents 31926755689e
children cdc70de628b5
comparison
equal deleted inserted replaced
636:13b390bfed32 637:6ea90dc10375
17 public final class Utils { 17 public final class Utils {
18 private Utils() {} // never 18 private Utils() {} // never
19 19
20 static final int bufSize = 8192; 20 static final int bufSize = 8192;
21 21
22 private static void checkNotNull(LuanState luan,Object v,String expected) throws LuanException { 22 private static void checkNotNull(LuanState luan,Object v,String expected,int pos) throws LuanException {
23 if( v == null ) 23 if( v == null )
24 throw new LuanException(luan,"bad argument #1 ("+expected+" expected, got nil)"); 24 throw new LuanException(luan,"bad argument #"+pos+" ("+expected+" expected, got nil)");
25 }
26
27 public static void checkNotNull(LuanState luan,String s,int pos) throws LuanException {
28 checkNotNull(luan,s,"string",pos);
25 } 29 }
26 30
27 public static void checkNotNull(LuanState luan,String s) throws LuanException { 31 public static void checkNotNull(LuanState luan,String s) throws LuanException {
28 checkNotNull(luan,s,"string"); 32 checkNotNull(luan,s,1);
33 }
34
35 public static void checkNotNull(LuanState luan,byte[] b,int pos) throws LuanException {
36 checkNotNull(luan,b,"binary",pos);
29 } 37 }
30 38
31 public static void checkNotNull(LuanState luan,byte[] b) throws LuanException { 39 public static void checkNotNull(LuanState luan,byte[] b) throws LuanException {
32 checkNotNull(luan,b,"binary"); 40 checkNotNull(luan,b,1);
41 }
42
43 public static void checkNotNull(LuanState luan,LuanTable t,int pos) throws LuanException {
44 checkNotNull(luan,t,"table",pos);
33 } 45 }
34 46
35 public static void checkNotNull(LuanState luan,LuanTable t) throws LuanException { 47 public static void checkNotNull(LuanState luan,LuanTable t) throws LuanException {
36 checkNotNull(luan,t,"table"); 48 checkNotNull(luan,t,1);
49 }
50
51 public static void checkNotNull(LuanState luan,Number n,int pos) throws LuanException {
52 checkNotNull(luan,n,"number",pos);
37 } 53 }
38 54
39 public static void checkNotNull(LuanState luan,Number n) throws LuanException { 55 public static void checkNotNull(LuanState luan,Number n) throws LuanException {
40 checkNotNull(luan,n,"number"); 56 checkNotNull(luan,n,1);
57 }
58
59 public static void checkNotNull(LuanState luan,LuanFunction fn,int pos) throws LuanException {
60 checkNotNull(luan,fn,"function",pos);
41 } 61 }
42 62
43 public static void checkNotNull(LuanState luan,LuanFunction fn) throws LuanException { 63 public static void checkNotNull(LuanState luan,LuanFunction fn) throws LuanException {
44 checkNotNull(luan,fn,"function"); 64 checkNotNull(luan,fn,1);
45 } 65 }
46 66
47 public static String readAll(Reader in) 67 public static String readAll(Reader in)
48 throws IOException 68 throws IOException
49 { 69 {