|
@@ -5,17 +5,6 @@
|
5
|
5
|
*/
|
6
|
6
|
package org.openzen.zencode.java;
|
7
|
7
|
|
8
|
|
-import java.lang.reflect.AnnotatedType;
|
9
|
|
-import java.lang.reflect.Field;
|
10
|
|
-import java.lang.reflect.Method;
|
11
|
|
-import java.lang.reflect.Modifier;
|
12
|
|
-import java.lang.reflect.Parameter;
|
13
|
|
-import java.lang.reflect.ParameterizedType;
|
14
|
|
-import java.lang.reflect.Type;
|
15
|
|
-import java.lang.reflect.TypeVariable;
|
16
|
|
-import java.util.Collections;
|
17
|
|
-import java.util.HashMap;
|
18
|
|
-import java.util.Map;
|
19
|
8
|
import org.openzen.zencode.shared.CodePosition;
|
20
|
9
|
import org.openzen.zenscript.codemodel.FunctionHeader;
|
21
|
10
|
import org.openzen.zenscript.codemodel.FunctionParameter;
|
|
@@ -79,6 +68,18 @@ import org.openzen.zenscript.javashared.JavaMethod;
|
79
|
68
|
import org.openzen.zenscript.javashared.JavaModifiers;
|
80
|
69
|
import stdlib.Strings;
|
81
|
70
|
|
|
71
|
+import java.lang.reflect.AnnotatedType;
|
|
72
|
+import java.lang.reflect.Field;
|
|
73
|
+import java.lang.reflect.Method;
|
|
74
|
+import java.lang.reflect.Modifier;
|
|
75
|
+import java.lang.reflect.Parameter;
|
|
76
|
+import java.lang.reflect.ParameterizedType;
|
|
77
|
+import java.lang.reflect.Type;
|
|
78
|
+import java.lang.reflect.TypeVariable;
|
|
79
|
+import java.util.Collections;
|
|
80
|
+import java.util.HashMap;
|
|
81
|
+import java.util.Map;
|
|
82
|
+
|
82
|
83
|
/**
|
83
|
84
|
* @author Stan Hebben
|
84
|
85
|
*/
|
|
@@ -532,7 +533,7 @@ public class JavaNativeModule {
|
532
|
533
|
if (parameter.isAnnotationPresent(ZenCodeType.Optional.class)) {
|
533
|
534
|
Expression defaultValue = type.type.getDefaultValue();
|
534
|
535
|
if (defaultValue == null)
|
535
|
|
- throw new IllegalArgumentException(type.toString() + " doesn't have a default value");
|
|
536
|
+ defaultValue = new org.openzen.zenscript.codemodel.expression.NullExpression(CodePosition.NATIVE);
|
536
|
537
|
return defaultValue;
|
537
|
538
|
} else if (parameter.isAnnotationPresent(ZenCodeType.OptionalInt.class)) {
|
538
|
539
|
ZenCodeType.OptionalInt annotation = parameter.getAnnotation(ZenCodeType.OptionalInt.class);
|
|
@@ -630,7 +631,7 @@ public class JavaNativeModule {
|
630
|
631
|
else if (annotatedType.isAnnotationPresent(ZenCodeType.NullableUSize.class))
|
631
|
632
|
return registry.getOptional(BasicTypeID.USIZE).stored();
|
632
|
633
|
|
633
|
|
- boolean nullable = annotatedType.isAnnotationPresent(ZenCodeType.Nullable.class);
|
|
634
|
+ boolean nullable = annotatedType.isAnnotationPresent(ZenCodeType.Nullable.class) || annotatedType.isAnnotationPresent(ZenCodeType.Optional.class);
|
634
|
635
|
boolean unsigned = annotatedType.isAnnotationPresent(ZenCodeType.Unsigned.class);
|
635
|
636
|
|
636
|
637
|
Type type = annotatedType.getType();
|