Browse Source

JavaNativeModule: Allow getters in Expansions

kindlich 4 years ago
parent
commit
7134ba06b3
No known key found for this signature in database

+ 13
- 1
JavaIntegration/src/main/java/org/openzen/zencode/java/JavaNativeModule.java View File

@@ -489,7 +489,19 @@ public class JavaNativeModule {
489 489
                 compiled.setMethodInfo(member, JavaMethod.getStatic(javaClass, name, getMethodDescriptor(method), getMethodModifiers(method)));
490 490
                 addExpansion = true;
491 491
             }
492
-
492
+            
493
+            final ZenCodeType.Getter getterAnnotation = method.getAnnotation(ZenCodeType.Getter.class);
494
+            if(getterAnnotation != null) {
495
+                StoredType type = loadStoredType(context, method.getAnnotatedReturnType());
496
+                int modifiers = getMethodModifiers(method) ^ Modifiers.STATIC;
497
+                final String name = getterAnnotation.value().isEmpty() ? translateGetterName(method.getName()) : getterAnnotation.value();
498
+                final GetterMember member = new GetterMember(CodePosition.NATIVE, expansion, modifiers, name, type, null);
499
+                
500
+                expansion.addMember(member);
501
+                compiled.setMethodInfo(member, getMethod(javaClass, method, type));
502
+                addExpansion = true;
503
+            }
504
+            
493 505
             final ZenCodeType.Caster casterAnnotation = method.getAnnotation(ZenCodeType.Caster.class);
494 506
             if(casterAnnotation != null) {
495 507
                 boolean implicit = casterAnnotation.implicit();

Loading…
Cancel
Save