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
 					return unsignedByClass.get(classType);
503
 					return unsignedByClass.get(classType);
504
 				else
504
 				else
505
 					throw new IllegalArgumentException("This class cannot be used as unsigned: " + classType);
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
 			if (typeByClass.containsKey(classType))
510
 			if (typeByClass.containsKey(classType))

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

17
 //testInstance("something");
17
 //testInstance("something");
18
 
18
 
19
 something.dump();
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
 	@Global
17
 	@Global
18
 	public static TestClass something = new TestClass("hello");
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
 	@Global
28
 	@Global
21
 	public static void println(String message) {
29
 	public static void println(String message) {
22
 		System.out.println(message);
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
 apply plugin: 'maven'
6
 apply plugin: 'maven'
7
 
7
 
8
 String mavenGroupId = 'org.openzen.zencode'
8
 String mavenGroupId = 'org.openzen.zencode'
9
-String mavenVersion = '0.3.1'
9
+String mavenVersion = '0.3.3'
10
 
10
 
11
 sourceCompatibility = '1.8'
11
 sourceCompatibility = '1.8'
12
 [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
12
 [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

Loading…
Cancel
Save