|
@@ -240,12 +240,27 @@ public class JavaNativeModule {
|
240
|
240
|
if ((cls.getModifiers() & Modifier.PUBLIC) == 0)
|
241
|
241
|
throw new IllegalArgumentException("Class must be public");
|
242
|
242
|
|
243
|
|
- ZenCodeType.Name name = cls.getDeclaredAnnotation(ZenCodeType.Name.class);
|
244
|
|
- String className = name == null ? cls.getName() : name.value();
|
|
243
|
+ String className = cls.getName();
|
245
|
244
|
boolean isStruct = cls.getAnnotation(ZenCodeType.Struct.class) != null;
|
246
|
245
|
|
247
|
246
|
ZSPackage classPkg = getPackage(className);
|
|
247
|
+ ZenCodeType.Name name = cls.getDeclaredAnnotation(ZenCodeType.Name.class);
|
248
|
248
|
className = className.contains(".") ? className.substring(className.lastIndexOf('.') + 1) : className;
|
|
249
|
+ if (name != null) {
|
|
250
|
+ String specifiedName = name.value();
|
|
251
|
+ if (specifiedName.startsWith(".")) {
|
|
252
|
+ classPkg = getPackage(specifiedName);
|
|
253
|
+ className = className.substring(className.lastIndexOf('.') + 1);
|
|
254
|
+ } else if (specifiedName.indexOf('.') >= 0) {
|
|
255
|
+ if (!specifiedName.startsWith(pkg.fullName))
|
|
256
|
+ throw new IllegalArgumentException("Specified @Name as " + specifiedName + " but it's not in the module root package");
|
|
257
|
+
|
|
258
|
+ classPkg = getPackage(basePackage + specifiedName.substring(pkg.fullName.length()));
|
|
259
|
+ className = className.substring(className.lastIndexOf('.') + 1);
|
|
260
|
+ } else {
|
|
261
|
+ className = name.value();
|
|
262
|
+ }
|
|
263
|
+ }
|
249
|
264
|
|
250
|
265
|
TypeVariableContext context = new TypeVariableContext();
|
251
|
266
|
TypeVariable<Class<T>>[] javaTypeParameters = cls.getTypeParameters();
|
|
@@ -546,6 +561,14 @@ public class JavaNativeModule {
|
546
|
561
|
}
|
547
|
562
|
|
548
|
563
|
private StoredType loadType(TypeVariableContext context, Type type, boolean nullable, boolean unsigned) {
|
|
564
|
+ StoredType result = loadType(context, type, unsigned);
|
|
565
|
+ if (nullable)
|
|
566
|
+ result = new StoredType(registry.getOptional(result.type), result.getSpecifiedStorage());
|
|
567
|
+
|
|
568
|
+ return result;
|
|
569
|
+ }
|
|
570
|
+
|
|
571
|
+ private StoredType loadType(TypeVariableContext context, Type type, boolean unsigned) {
|
549
|
572
|
if (type instanceof Class) {
|
550
|
573
|
Class<?> classType = (Class<?>) type;
|
551
|
574
|
if (unsigned) {
|