changeset 1252:aa8517d7c065

convert primitive array to table
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 30 Aug 2018 10:58:19 -0600
parents ddd2ec2c0769
children 23e8f93055a4
files src/luan/LuanJavaFunction.java
diffstat 1 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
diff -r ddd2ec2c0769 -r aa8517d7c065 src/luan/LuanJavaFunction.java
--- a/src/luan/LuanJavaFunction.java	Mon Jul 23 20:04:14 2018 -0600
+++ b/src/luan/LuanJavaFunction.java	Thu Aug 30 10:58:19 2018 -0600
@@ -360,9 +360,18 @@
 				return new LuanTable((Set)obj);
 			}
 			Class cls = obj.getClass();
-			if( cls.isArray() && !cls.getComponentType().isPrimitive() ) {
-				Object[] a = (Object[])obj;
-				return new LuanTable(Arrays.asList(a));
+			if( cls.isArray() ) {
+				if( cls.getComponentType().isPrimitive() ) {
+					int len = Array.getLength(obj);
+					List list = new ArrayList();
+					for( int i=0; i<len; i++ ) {
+						list.add(Array.get(obj,i));
+					}
+					return new LuanTable(list);
+				} else {
+					Object[] a = (Object[])obj;
+					return new LuanTable(Arrays.asList(a));
+				}
 			}
 			return obj;
 		}