comparison core/src/luan/modules/BasicLuan.java @ 491:4dc9cb26a3a8

raw_set and set_metatable now return void instead of LuanTable
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 12 May 2015 13:05:01 -0600
parents 5d4a78c93383
children d3183a330ff5
comparison
equal deleted inserted replaced
490:ddee9f5167d8 491:4dc9cb26a3a8
70 return null; 70 return null;
71 Object obj = metatable.rawGet("__metatable"); 71 Object obj = metatable.rawGet("__metatable");
72 return obj!=null ? obj : metatable; 72 return obj!=null ? obj : metatable;
73 } 73 }
74 74
75 public static LuanTable set_metatable(LuanState luan,LuanTable table,LuanTable metatable) throws LuanException { 75 public static void set_metatable(LuanState luan,LuanTable table,LuanTable metatable) throws LuanException {
76 if( table.getHandler("__metatable") != null ) 76 if( table.getHandler("__metatable") != null )
77 throw luan.exception("cannot change a protected metatable"); 77 throw luan.exception("cannot change a protected metatable");
78 table.setMetatable(metatable); 78 table.setMetatable(metatable);
79 return table;
80 } 79 }
81 80
82 public static boolean raw_equal(Object v1,Object v2) { 81 public static boolean raw_equal(Object v1,Object v2) {
83 return v1 == v2 || v1 != null && v1.equals(v2); 82 return v1 == v2 || v1 != null && v1.equals(v2);
84 } 83 }
85 84
86 public static Object raw_get(LuanTable table,Object index) { 85 public static Object raw_get(LuanTable table,Object index) {
87 return table.rawGet(index); 86 return table.rawGet(index);
88 } 87 }
89 88
90 public static LuanTable raw_set(LuanTable table,Object index,Object value) { 89 public static void raw_set(LuanTable table,Object index,Object value) {
91 table.rawPut(index,value); 90 table.rawPut(index,value);
92 return table;
93 } 91 }
94 92
95 public static int raw_len(LuanState luan,Object v) throws LuanException { 93 public static int raw_len(LuanState luan,Object v) throws LuanException {
96 if( v instanceof String ) { 94 if( v instanceof String ) {
97 String s = (String)v; 95 String s = (String)v;