Mercurial Hosting > luan
comparison src/luan/modules/JavaLuan.java @ 795:dd36eae6aa04
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 05 Sep 2016 16:32:55 -0600 |
parents | 4083f5a67c63 |
children | e8fc6712b468 |
comparison
equal
deleted
inserted
replaced
794:f16c77ef0f4f | 795:dd36eae6aa04 |
---|---|
43 private static void checkJava(LuanState luan) throws LuanException { | 43 private static void checkJava(LuanState luan) throws LuanException { |
44 if( !luan.java.ok ) | 44 if( !luan.java.ok ) |
45 throw new LuanException("Java isn't allowed"); | 45 throw new LuanException("Java isn't allowed"); |
46 } | 46 } |
47 | 47 |
48 static final Object FAIL = new Object(); | 48 public static Object __index(LuanState luan,Object obj,Object key) throws LuanException { |
49 | |
50 public static Object __index(LuanState luan,Object obj,Object key,boolean canReturnFail) throws LuanException { | |
51 checkJava(luan); | 49 checkJava(luan); |
52 Class cls; | 50 Class cls; |
53 if( obj instanceof Static ) { | 51 if( obj instanceof Static ) { |
54 Static st = (Static)obj; | 52 Static st = (Static)obj; |
55 cls = st.cls; | 53 cls = st.cls; |
105 } | 103 } |
106 } | 104 } |
107 } | 105 } |
108 } | 106 } |
109 //System.out.println("invalid member '"+key+"' for java object: "+obj); | 107 //System.out.println("invalid member '"+key+"' for java object: "+obj); |
110 if( canReturnFail ) | |
111 return FAIL; | |
112 throw new LuanException( "invalid index '"+key+"' for java "+cls ); | 108 throw new LuanException( "invalid index '"+key+"' for java "+cls ); |
113 } | 109 } |
114 | 110 |
115 private static Object member(Object obj,List<Member> members) throws LuanException { | 111 private static Object member(Object obj,List<Member> members) throws LuanException { |
116 try { | 112 try { |