Mercurial Hosting > luan
comparison core/src/luan/LuanJavaFunction.java @ 431:3ffe8ba5b297
TableLuan cleanup
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 02 May 2015 21:12:48 -0600 |
parents | 1b38de2b1845 |
children | d9df6d6cb927 |
comparison
equal
deleted
inserted
replaced
430:f28320fd671d | 431:3ffe8ba5b297 |
---|---|
400 return new LuanTable(list); | 400 return new LuanTable(list); |
401 } | 401 } |
402 if( obj instanceof Map ) { | 402 if( obj instanceof Map ) { |
403 @SuppressWarnings("unchecked") | 403 @SuppressWarnings("unchecked") |
404 Map<Object,Object> map = (Map<Object,Object>)obj; | 404 Map<Object,Object> map = (Map<Object,Object>)obj; |
405 return new LuanTable(map); | 405 LuanTable tbl = new LuanTable(); |
406 for( Map.Entry<Object,Object> entry : map.entrySet() ) { | |
407 Object key = entry.getKey(); | |
408 Object value = entry.getValue(); | |
409 if( key != null && value != null ) | |
410 tbl.rawPut(key,value); | |
411 } | |
412 return tbl; | |
406 } | 413 } |
407 if( obj instanceof Set ) { | 414 if( obj instanceof Set ) { |
408 @SuppressWarnings("unchecked") | 415 @SuppressWarnings("unchecked") |
409 Set<Object> set = (Set<Object>)obj; | 416 Set<Object> set = (Set<Object>)obj; |
410 return new LuanTable(set); | 417 LuanTable tbl = new LuanTable(); |
418 for( Object el : set ) { | |
419 if( el != null ) | |
420 tbl.rawPut(el,Boolean.TRUE); | |
421 } | |
422 return tbl; | |
411 } | 423 } |
412 Class cls = obj.getClass(); | 424 Class cls = obj.getClass(); |
413 if( cls.isArray() && !cls.getComponentType().isPrimitive() ) { | 425 if( cls.isArray() && !cls.getComponentType().isPrimitive() ) { |
414 Object[] a = (Object[])obj; | 426 Object[] a = (Object[])obj; |
415 return new LuanTable(Arrays.asList(a)); | 427 return new LuanTable(Arrays.asList(a)); |