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
                 compiled.setMethodInfo(member, JavaMethod.getStatic(javaClass, name, getMethodDescriptor(method), getMethodModifiers(method)));
489
                 compiled.setMethodInfo(member, JavaMethod.getStatic(javaClass, name, getMethodDescriptor(method), getMethodModifiers(method)));
490
                 addExpansion = true;
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
             final ZenCodeType.Caster casterAnnotation = method.getAnnotation(ZenCodeType.Caster.class);
505
             final ZenCodeType.Caster casterAnnotation = method.getAnnotation(ZenCodeType.Caster.class);
494
             if(casterAnnotation != null) {
506
             if(casterAnnotation != null) {
495
                 boolean implicit = casterAnnotation.implicit();
507
                 boolean implicit = casterAnnotation.implicit();

Loading…
Cancel
Save