< prev index next >

src/jdk.jextract/share/classes/com/sun/tools/jextract/AsmCodeFactory.java

Print this page




 277 
 278     Layout decorateAsAccessor(VarTree varTree, Layout layout) {
 279         return addGetterSetterName(layout, varTree.name()).
 280             withAnnotation("ptr", varTree.name() + "$ptr");
 281     }
 282 
 283     Layout decorateAsAccessor(FieldTree fieldTree, Layout layout) {
 284         layout = addGetterSetterName(layout, fieldTree.name());
 285         if (!fieldTree.isBitField()) {
 286             //no pointer accessors for bitfield!
 287             layout = layout.withAnnotation("ptr", fieldTree.name() + "$ptr");
 288         }
 289         return layout;
 290     }
 291 
 292     @Override
 293     public Void visitEnum(EnumTree enumTree, JType jt) {
 294         // define enum constants in global_cw
 295         enumTree.constants().forEach(constant -> addConstant(global_cw, constant));
 296 
 297         if (enumTree.isAnonymous()) {
 298             // We are done with anonymous enum
 299             return null;
 300         }
 301 
 302         // generate annotation class for named enum
 303         createAnnotationCls(enumTree);
 304         return null;
 305     }
 306 
 307     private void createAnnotationCls(Tree tree) {
 308         String nativeName = tree.identifier();
 309         logger.fine(() -> "Create annotation for: " + nativeName);
 310 
 311         String intf = Utils.toClassName(nativeName);
 312         String name = internal_name + "$" + intf;
 313 
 314         logger.fine(() -> "Define class " + name + " for native type " + nativeName);
 315         global_cw.visitInnerClass(name, internal_name, intf,
 316                 ACC_PUBLIC | ACC_STATIC | ACC_ABSTRACT | ACC_INTERFACE | ACC_ANNOTATION);
 317         ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);




 277 
 278     Layout decorateAsAccessor(VarTree varTree, Layout layout) {
 279         return addGetterSetterName(layout, varTree.name()).
 280             withAnnotation("ptr", varTree.name() + "$ptr");
 281     }
 282 
 283     Layout decorateAsAccessor(FieldTree fieldTree, Layout layout) {
 284         layout = addGetterSetterName(layout, fieldTree.name());
 285         if (!fieldTree.isBitField()) {
 286             //no pointer accessors for bitfield!
 287             layout = layout.withAnnotation("ptr", fieldTree.name() + "$ptr");
 288         }
 289         return layout;
 290     }
 291 
 292     @Override
 293     public Void visitEnum(EnumTree enumTree, JType jt) {
 294         // define enum constants in global_cw
 295         enumTree.constants().forEach(constant -> addConstant(global_cw, constant));
 296 
 297         if (enumTree.name().isEmpty()) {
 298             // We are done with anonymous enum
 299             return null;
 300         }
 301 
 302         // generate annotation class for named enum
 303         createAnnotationCls(enumTree);
 304         return null;
 305     }
 306 
 307     private void createAnnotationCls(Tree tree) {
 308         String nativeName = tree.identifier();
 309         logger.fine(() -> "Create annotation for: " + nativeName);
 310 
 311         String intf = Utils.toClassName(nativeName);
 312         String name = internal_name + "$" + intf;
 313 
 314         logger.fine(() -> "Define class " + name + " for native type " + nativeName);
 315         global_cw.visitInnerClass(name, internal_name, intf,
 316                 ACC_PUBLIC | ACC_STATIC | ACC_ABSTRACT | ACC_INTERFACE | ACC_ANNOTATION);
 317         ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);


< prev index next >