Browse Source

Fix array support for native java integration

Stan Hebben 6 years ago
parent
commit
045d7f4cea

+ 2
- 0
JavaIntegration/src/main/java/org/openzen/zencode/java/JavaNativeModule.java View File

@@ -503,6 +503,8 @@ public class JavaNativeModule {
503 503
 					return unsignedByClass.get(classType);
504 504
 				else
505 505
 					throw new IllegalArgumentException("This class cannot be used as unsigned: " + classType);
506
+			} else if (classType.isArray()) {
507
+				return registry.getArray(loadType(classType.getComponentType(), false, false).stored(), 1);
506 508
 			}
507 509
 			
508 510
 			if (typeByClass.containsKey(classType))

+ 3
- 0
ScriptingExample/scripts/integration.zs View File

@@ -17,3 +17,6 @@ val testInstance = new TestOperators();
17 17
 //testInstance("something");
18 18
 
19 19
 something.dump();
20
+
21
+val objects = makeArray(5);
22
+printMany(objects);

+ 15
- 0
ScriptingExample/src/main/java/org/openzen/zenscript/scriptingexample/Globals.java View File

@@ -17,8 +17,23 @@ public class Globals implements ZenCodeGlobals {
17 17
 	@Global
18 18
 	public static TestClass something = new TestClass("hello");
19 19
 	
20
+	@Global
21
+	public static TestClass[] makeArray(int amount) {
22
+		TestClass[] result = new TestClass[amount];
23
+		for (int i = 0; i < result.length; i++)
24
+			result[i] = new TestClass("test " + i);
25
+		return result;
26
+	}
27
+	
20 28
 	@Global
21 29
 	public static void println(String message) {
22 30
 		System.out.println(message);
23 31
 	}
32
+	
33
+	@Global
34
+	public static void printMany(TestClass[] objects) {
35
+		System.out.println(objects.length + " objects present:");
36
+		for (TestClass object : objects)
37
+			System.out.println("  - " + object.getName());
38
+	}
24 39
 }

+ 1
- 1
common.gradle View File

@@ -6,7 +6,7 @@ apply plugin: 'java'
6 6
 apply plugin: 'maven'
7 7
 
8 8
 String mavenGroupId = 'org.openzen.zencode'
9
-String mavenVersion = '0.3.1'
9
+String mavenVersion = '0.3.3'
10 10
 
11 11
 sourceCompatibility = '1.8'
12 12
 [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

Loading…
Cancel
Save