Skip to content
Permalink
Browse files
8261073: Remove @C annotations from jextracted code
Reviewed-by: mcimadamore
  • Loading branch information
sundararajana committed Feb 4, 2021
1 parent 4d083c1 commit cb45274e094ffdee5d599af5c8e0fd63e6f3e794

This file was deleted.

@@ -31,8 +31,6 @@
import java.lang.invoke.MethodType;

public class FunctionalInterfaceBuilder extends NestedClassBuilder {

private final String fiAnno;
private final MethodType fiType;
private final FunctionDescriptor fiDesc;

@@ -41,7 +39,6 @@ public class FunctionalInterfaceBuilder extends NestedClassBuilder {
super(enclosing, Kind.INTERFACE, className);
this.fiType = fiType;
this.fiDesc = fiDesc;
this.fiAnno = annotationWriter.getCAnnotation(funcType);
}

@Override
@@ -67,7 +64,7 @@ void emitFunctionalInterfaceMethod() {
private void emitFunctionalFactories() {
builder.incrAlign();
builder.indent();
builder.append(PUB_MODS + " " + fiAnno + " MemorySegment allocate(" + className + " fi) {\n");
builder.append(PUB_MODS + " MemorySegment allocate(" + className + " fi) {\n");
builder.incrAlign();
builder.indent();
builder.append("return RuntimeHelper.upcallStub(" + className + ".class, fi, " + functionGetCallString(className, fiDesc) + ", " +
@@ -76,7 +73,7 @@ private void emitFunctionalFactories() {
builder.indent();
builder.append("}\n");
builder.indent();
builder.append(PUB_MODS + " " + fiAnno + " MemorySegment allocate(" + className + " fi, NativeScope scope) {\n");
builder.append(PUB_MODS + " MemorySegment allocate(" + className + " fi, NativeScope scope) {\n");
builder.incrAlign();
builder.indent();
builder.append("return allocate(fi).handoff(scope);\n");
@@ -43,8 +43,8 @@ class HeaderFileBuilder extends JavaSourceBuilder {

private String superclass;

HeaderFileBuilder(String clsName, String pkgName, String superclass, ConstantHelper constantHelper, AnnotationWriter annotationWriter) {
super(new StringSourceBuilder(), Kind.CLASS, clsName, pkgName, constantHelper, annotationWriter);
HeaderFileBuilder(String clsName, String pkgName, String superclass, ConstantHelper constantHelper) {
super(new StringSourceBuilder(), Kind.CLASS, clsName, pkgName, constantHelper);
this.superclass = superclass;
}

@@ -59,14 +59,10 @@ protected String getClassModifiers() {
}

void addStaticFunctionWrapper(String javaName, String nativeName, MethodType mtype, FunctionDescriptor desc,
boolean varargs, List<String> paramNames, List<String> annos, String returnAnno) {
boolean varargs, List<String> paramNames) {
builder.incrAlign();
builder.indent();
builder.append(PUB_MODS);
if (mtype.returnType() != void.class) {
builder.append(returnAnno);
builder.append(' ');
}
builder.append(mtype.returnType().getSimpleName() + " " + javaName + " (");
String delim = "";
List<String> pExprs = new ArrayList<>();
@@ -85,7 +81,7 @@ void addStaticFunctionWrapper(String javaName, String nativeName, MethodType mty
if (pType.equals(MemoryAddress.class)) {
pType = Addressable.class;
}
builder.append(delim + annos.get(i) + " " + pType.getSimpleName() + " " + pName);
builder.append(delim + " " + pType.getSimpleName() + " " + pName);
delim = ", ";
}
if (varargs) {
@@ -127,13 +123,13 @@ void addStaticFunctionWrapper(String javaName, String nativeName, MethodType mty
builder.decrAlign();
}

void emitPrimitiveTypedef(Type.Primitive primType, String name, String anno) {
void emitPrimitiveTypedef(Type.Primitive primType, String name) {
Type.Primitive.Kind kind = primType.kind();
if (primitiveKindSupported(kind) && !kind.layout().isEmpty()) {
builder.incrAlign();
builder.indent();
builder.append(PUB_MODS);
builder.append(anno + " ValueLayout ");
builder.append(" ValueLayout ");
builder.append(uniqueNestedClassName(name));
builder.append(" = ");
builder.append(TypeTranslator.typeToLayoutName(kind));
@@ -58,18 +58,16 @@ enum Kind {
protected final String className;
protected final String pkgName;
protected final ConstantHelper constantHelper;
protected final AnnotationWriter annotationWriter;

Set<String> nestedClassNames = new HashSet<>();
int nestedClassNameCount = 0;

JavaSourceBuilder(StringSourceBuilder builder, Kind kind, String className, String pkgName, ConstantHelper constantHelper, AnnotationWriter annotationWriter) {
JavaSourceBuilder(StringSourceBuilder builder, Kind kind, String className, String pkgName, ConstantHelper constantHelper) {
this.builder = builder;
this.kind = kind;
this.className = className;
this.pkgName = pkgName;
this.constantHelper = constantHelper;
this.annotationWriter = annotationWriter;
}

String superClass() {
@@ -89,9 +87,6 @@ void classBegin() {
addImportSection();

builder.indent();
if (type() != null) {
builder.append(annotationWriter.getCAnnotation(type()));
}
builder.append(getClassModifiers());
builder.append(kind.kindName + " " + className);
if (superClass() != null) {
@@ -121,31 +116,31 @@ JavaSourceBuilder classEnd() {
}

void addLayoutGetter(String javaName, MemoryLayout layout) {
emitForwardGetter(constantHelper.addLayout(javaName, layout), "");
emitForwardGetter(constantHelper.addLayout(javaName, layout));
}

void addVarHandleGetter(String javaName, String nativeName, MemoryLayout layout, Class<?> type) {
emitForwardGetter(constantHelper.addGlobalVarHandle(javaName, nativeName, layout, type), "");
emitForwardGetter(constantHelper.addGlobalVarHandle(javaName, nativeName, layout, type));
}

void addMethodHandleGetter(String javaName, String nativeName, MethodType mtype, FunctionDescriptor desc, boolean varargs) {
emitForwardGetter(constantHelper.addMethodHandle(javaName, nativeName, mtype, desc, varargs), "",
emitForwardGetter(constantHelper.addMethodHandle(javaName, nativeName, mtype, desc, varargs),
true, "unresolved symbol: " + nativeName);
}

void addSegmentGetter(String javaName, String nativeName, MemoryLayout layout) {
emitForwardGetter(constantHelper.addSegment(javaName, nativeName, layout), "",
emitForwardGetter(constantHelper.addSegment(javaName, nativeName, layout),
true, "unresolved symbol: " + nativeName);
}

void addConstantGetter(String javaName, Class<?> type, Object value, String anno) {
emitForwardGetter(constantHelper.addConstant(javaName, type, value), anno);
void addConstantGetter(String javaName, Class<?> type, Object value) {
emitForwardGetter(constantHelper.addConstant(javaName, type, value));
}

void addGetter(String javaName, String nativeName, MemoryLayout layout, Class<?> type, String anno) {
void addGetter(String javaName, String nativeName, MemoryLayout layout, Class<?> type) {
builder.incrAlign();
builder.indent();
builder.append(PUB_MODS + anno + " " + type.getSimpleName() + " " + javaName + "$get() {\n");
builder.append(PUB_MODS + " " + type.getSimpleName() + " " + javaName + "$get() {\n");
builder.incrAlign();
builder.indent();
String vhParam = addressGetCallString(javaName, nativeName, layout);
@@ -162,10 +157,10 @@ void addGetter(String javaName, String nativeName, MemoryLayout layout, Class<?>
builder.decrAlign();
}

void addSetter(String javaName, String nativeName, MemoryLayout layout, Class<?> type, String anno) {
void addSetter(String javaName, String nativeName, MemoryLayout layout, Class<?> type) {
builder.incrAlign();
builder.indent();
builder.append(PUB_MODS + "void " + javaName + "$set(" + anno + " " + type.getSimpleName() + " x) {\n");
builder.append(PUB_MODS + "void " + javaName + "$set(" + " " + type.getSimpleName() + " x) {\n");
builder.incrAlign();
builder.indent();
String vhParam = addressGetCallString(javaName, nativeName, layout);
@@ -204,14 +199,14 @@ protected void addImportSection() {
builder.append(".*;\n");
}

protected void emitForwardGetter(DirectMethodHandleDesc desc, String anno) {
emitForwardGetter(desc, anno, false, "");
protected void emitForwardGetter(DirectMethodHandleDesc desc) {
emitForwardGetter(desc, false, "");
}

protected void emitForwardGetter(DirectMethodHandleDesc desc, String anno, boolean nullCheck, String errMsg) {
protected void emitForwardGetter(DirectMethodHandleDesc desc, boolean nullCheck, String errMsg) {
builder.incrAlign();
builder.indent();
builder.append(PUB_MODS + anno + " " + displayName(desc.invocationType().returnType()) + " " + desc.methodName() + "() {\n");
builder.append(PUB_MODS + " " + displayName(desc.invocationType().returnType()) + " " + desc.methodName() + "() {\n");
builder.incrAlign();
builder.indent();
builder.append("return ");
@@ -30,7 +30,7 @@ public abstract class NestedClassBuilder extends JavaSourceBuilder {
protected final JavaSourceBuilder enclosing;

public NestedClassBuilder(JavaSourceBuilder enclosing, Kind kind, String className) {
super(enclosing.builder, kind, enclosing.uniqueNestedClassName(className), enclosing.pkgName, enclosing.constantHelper, enclosing.annotationWriter);
super(enclosing.builder, kind, enclosing.uniqueNestedClassName(className), enclosing.pkgName, enclosing.constantHelper);
this.enclosing = enclosing;
}

0 comments on commit cb45274

Please sign in to comment.