|
@@ -60,7 +60,6 @@ import org.openzen.zenscript.javashared.JavaMethod;
|
60
|
60
|
import stdlib.Strings;
|
61
|
61
|
|
62
|
62
|
/**
|
63
|
|
- *
|
64
|
63
|
* @author Stan Hebben
|
65
|
64
|
*/
|
66
|
65
|
public class JavaNativeModule {
|
|
@@ -82,8 +81,7 @@ public class JavaNativeModule {
|
82
|
81
|
String name,
|
83
|
82
|
String basePackage,
|
84
|
83
|
GlobalTypeRegistry registry,
|
85
|
|
- JavaNativeModule[] dependencies)
|
86
|
|
- {
|
|
84
|
+ JavaNativeModule[] dependencies) {
|
87
|
85
|
this.pkg = pkg;
|
88
|
86
|
this.basePackage = basePackage;
|
89
|
87
|
module = new Module(name);
|
|
@@ -208,7 +206,8 @@ public class JavaNativeModule {
|
208
|
206
|
}
|
209
|
207
|
|
210
|
208
|
private ZSPackage getPackage(String className) {
|
211
|
|
- if (!className.contains("."))
|
|
209
|
+ //TODO make a lang package?
|
|
210
|
+ if (!className.contains(".") || className.startsWith("java.lang"))
|
212
|
211
|
return pkg;
|
213
|
212
|
|
214
|
213
|
if (className.startsWith("."))
|
|
@@ -277,10 +276,8 @@ public class JavaNativeModule {
|
277
|
276
|
continue;
|
278
|
277
|
if (!isPublic(field.getModifiers()))
|
279
|
278
|
continue;
|
280
|
|
-
|
281
|
|
- String fieldName = field.getName();
|
282
|
|
- if (annotation != null && !annotation.value().isEmpty())
|
283
|
|
- fieldName = annotation.value();
|
|
279
|
+
|
|
280
|
+ final String fieldName = annotation.value().isEmpty() ? field.getName() : annotation.value();
|
284
|
281
|
|
285
|
282
|
StoredType fieldType = loadStoredType(field.getAnnotatedType());
|
286
|
283
|
FieldMember member = new FieldMember(CodePosition.NATIVE, definition, Modifiers.PUBLIC, fieldName, thisType, fieldType, registry, 0, 0, null);
|
|
@@ -290,7 +287,7 @@ public class JavaNativeModule {
|
290
|
287
|
|
291
|
288
|
boolean hasConstructor = false;
|
292
|
289
|
for (java.lang.reflect.Constructor constructor : cls.getConstructors()) {
|
293
|
|
- ZenCodeType.Constructor constructorAnnotation = (ZenCodeType.Constructor)constructor.getAnnotation(ZenCodeType.Constructor.class);
|
|
290
|
+ ZenCodeType.Constructor constructorAnnotation = (ZenCodeType.Constructor) constructor.getAnnotation(ZenCodeType.Constructor.class);
|
294
|
291
|
if (constructorAnnotation != null) {
|
295
|
292
|
ConstructorMember member = asConstructor(definition, constructor);
|
296
|
293
|
definition.addMember(member);
|
|
@@ -468,8 +465,7 @@ public class JavaNativeModule {
|
468
|
465
|
AnnotatedType javaReturnType,
|
469
|
466
|
AnnotatedType[] parameterTypes,
|
470
|
467
|
TypeVariable<Method>[] javaTypeParameters,
|
471
|
|
- AnnotatedType[] exceptionTypes)
|
472
|
|
- {
|
|
468
|
+ AnnotatedType[] exceptionTypes) {
|
473
|
469
|
StoredType returnType = javaReturnType == null ? BasicTypeID.VOID.stored : loadStoredType(javaReturnType);
|
474
|
470
|
|
475
|
471
|
FunctionParameter[] parameters = new FunctionParameter[parameterTypes.length];
|
|
@@ -513,7 +509,7 @@ public class JavaNativeModule {
|
513
|
509
|
|
514
|
510
|
private TypeID loadType(Type type, boolean nullable, boolean unsigned) {
|
515
|
511
|
if (type instanceof Class) {
|
516
|
|
- Class<?> classType = (Class<?>)type;
|
|
512
|
+ Class<?> classType = (Class<?>) type;
|
517
|
513
|
if (unsigned) {
|
518
|
514
|
if (unsignedByClass.containsKey(classType))
|
519
|
515
|
return unsignedByClass.get(classType);
|
|
@@ -529,8 +525,8 @@ public class JavaNativeModule {
|
529
|
525
|
HighLevelDefinition definition = addClass(classType);
|
530
|
526
|
return registry.getForDefinition(definition);
|
531
|
527
|
} else if (type instanceof ParameterizedType) {
|
532
|
|
- ParameterizedType parameterizedType = (ParameterizedType)type;
|
533
|
|
- Class<?> rawType = (Class)parameterizedType.getRawType();
|
|
528
|
+ ParameterizedType parameterizedType = (ParameterizedType) type;
|
|
529
|
+ Class<?> rawType = (Class) parameterizedType.getRawType();
|
534
|
530
|
|
535
|
531
|
HighLevelDefinition definition = addClass(rawType);
|
536
|
532
|
Type[] parameters = parameterizedType.getActualTypeArguments();
|