Try to optimize the builds a little bit more. There is a pretty rare race condition that causes a build failure (bad synchronization in the java compiler).
This commit is contained in:
parent
2ca4ae367b
commit
8dbd70ee34
|
@ -1 +1 @@
|
|||
java temurin-18.0.2+9
|
||||
java temurin-18.0.2+101
|
||||
|
|
|
@ -53,8 +53,7 @@
|
|||
<compilerarg value="-Xlint:none"/>
|
||||
</javac>
|
||||
|
||||
<!--<javac destdir="${lwjgl.target.gen.classes}" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.al}" fork="true" taskname="processor">-->
|
||||
<javac destdir="${lwjgl.target.gen.native}/openal" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.al}" fork="true" taskname="processor">
|
||||
<javac destdir="${lwjgl.target.gen.native}/openal" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.al}" fork="true" taskname="GeneratorProcessor+OpenAL">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
|
||||
|
@ -67,7 +66,8 @@
|
|||
<compilerarg value="-AgenJavaPath=${lwjgl.target.gen.java}"/>
|
||||
<compilerarg value="-AgenNativePath=${lwjgl.target.gen.native}/openal"/>
|
||||
<compilerarg value="-Atypemap=org.lwjgl.util.generator.openal.ALTypeMap"/>
|
||||
<compilerarg value="${javac.args.debug}"/>
|
||||
<compilerarg value="${javac.args.debug}"/>
|
||||
<compilerarg value="-J-XX:CompileThreshold=1"/>
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.al}">
|
||||
<include name="${openal-template-pattern}"/>
|
||||
|
@ -104,7 +104,7 @@
|
|||
</javac>
|
||||
|
||||
<parallel>
|
||||
<javac destdir="${lwjgl.target.gen.native}/opengl" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="processorGL">
|
||||
<javac destdir="${lwjgl.target.gen.native}/opengl" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="GeneratorProcessor+OpenGL">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
|
||||
|
@ -119,6 +119,7 @@
|
|||
<compilerarg value="${javac.args.debug}"/>
|
||||
<compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLTypeMap"/>
|
||||
<compilerarg value="-Acontextspecific"/>
|
||||
<compilerarg value="-J-XX:CompileThreshold=1"/>
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.gl}">
|
||||
<include name="${opengl-template-pattern}"/>
|
||||
|
@ -127,7 +128,7 @@
|
|||
</javac>
|
||||
|
||||
<!-- Generate OpenGL references -->
|
||||
<javac destdir="${lwjgl.target.gen.native}/opengl" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="processor">
|
||||
<javac destdir="${lwjgl.target.gen.native}/opengl" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="GLReferencesGeneratorProcessor">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.opengl.GLReferencesGeneratorProcessor"/>
|
||||
|
@ -138,6 +139,7 @@
|
|||
<compilerarg value="-s"/>
|
||||
<compilerarg path="${lwjgl.target.gen.java}"/>
|
||||
<compilerarg value="-AgenJavaPath=${lwjgl.target.gen.java}"/>
|
||||
<compilerarg value="-J-XX:CompileThreshold=1"/>
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.gl}">
|
||||
<include name="${opengl-template-pattern}"/>
|
||||
|
@ -146,7 +148,7 @@
|
|||
</javac>
|
||||
|
||||
<!-- Generate OpenGL context capabilities -->
|
||||
<javac destdir="${lwjgl.target.gen.native}/opengl" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="processor">
|
||||
<javac destdir="${lwjgl.target.gen.native}/opengl" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="GLGeneratorProcessor">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.opengl.GLGeneratorProcessor"/>
|
||||
|
@ -159,6 +161,7 @@
|
|||
<compilerarg value="-AgenJavaPath=${lwjgl.target.gen.java}"/>
|
||||
<compilerarg value="${javac.args.debug}"/>
|
||||
<compilerarg value="-Acontextspecific"/>
|
||||
<compilerarg value="-J-XX:CompileThreshold=1"/>
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.gl}">
|
||||
<include name="${opengl-template-pattern}"/>
|
||||
|
@ -193,7 +196,8 @@
|
|||
<include name="org/lwjgl/opengles/KHRDebugCallback.java"/>
|
||||
</javac>
|
||||
|
||||
<javac destdir="${lwjgl.target.gen.native}/opengles" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.gles}" fork="true" taskname="processor">
|
||||
<parallel>
|
||||
<javac destdir="${lwjgl.target.gen.native}/opengles" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.gles}" fork="true" taskname="GeneratorProcessor+OpenGLES">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
|
||||
|
@ -208,6 +212,7 @@
|
|||
<compilerarg value="${javac.args.debug}"/>
|
||||
<!--<compilerarg value="-Acontextspecific"/>-->
|
||||
<compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLESTypeMap"/>
|
||||
<compilerarg value="-J-XX:CompileThreshold=1"/>
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.gles}">
|
||||
<include name="${opengles-template-pattern}"/>
|
||||
|
@ -216,7 +221,7 @@
|
|||
</javac>
|
||||
|
||||
<!-- Generate OpenGL ES context capabilities -->
|
||||
<javac destdir="${lwjgl.target.gen.native}/opengles" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.gles}" fork="true" taskname="processor">
|
||||
<javac destdir="${lwjgl.target.gen.native}/opengles" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.gles}" fork="true" taskname="GLESGeneratorProcessor">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.opengl.GLESGeneratorProcessor"/>
|
||||
|
@ -227,15 +232,16 @@
|
|||
<compilerarg value="-s"/>
|
||||
<compilerarg path="${lwjgl.target.gen.java}"/>
|
||||
<compilerarg value="-AgenJavaPath=${lwjgl.target.gen.java}"/>
|
||||
<compilerarg value="-AgenNativePath=${lwjgl.target.gen.native}/opengles"/>
|
||||
<compilerarg value="${javac.args.debug}"/>
|
||||
<!--<compilerarg value="-Acontextspecific"/>-->
|
||||
<compilerarg value="-J-XX:CompileThreshold=1"/>
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.gles}">
|
||||
<include name="${opengles-template-pattern}"/>
|
||||
</fileset>
|
||||
</src>
|
||||
</javac>
|
||||
</parallel>
|
||||
</target>
|
||||
|
||||
<!-- ********************************************************************************
|
||||
|
@ -270,7 +276,8 @@
|
|||
<compilerarg value="-Xlint:none"/>
|
||||
</javac>
|
||||
|
||||
<javac destdir="${lwjgl.target.gen.native}/opencl" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.cl}" fork="true" taskname="processor">
|
||||
<parallel>
|
||||
<javac destdir="${lwjgl.target.gen.native}/opencl" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.cl}" fork="true" taskname="GeneratorProcessor+OpenCL">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
|
||||
|
@ -285,6 +292,7 @@
|
|||
<compilerarg value="${javac.args.debug}"/>
|
||||
<compilerarg value="-Acontextspecific"/>
|
||||
<compilerarg value="-Atypemap=org.lwjgl.util.generator.opencl.CLTypeMap"/>
|
||||
<compilerarg value="-J-XX:CompileThreshold=1"/>
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.cl}">
|
||||
<include name="${opencl-template-pattern}"/>
|
||||
|
@ -293,7 +301,7 @@
|
|||
</javac>
|
||||
|
||||
<!-- Generate OpenCL capabilities -->
|
||||
<javac destdir="${lwjgl.target.gen.native}/opencl" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.cl}" fork="true" taskname="processor">
|
||||
<javac destdir="${lwjgl.target.gen.native}/opencl" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.cl}" fork="true" taskname="CLGeneratorProcessor">
|
||||
<compilerarg value="-proc:only"/>
|
||||
<compilerarg value="-processor"/>
|
||||
<compilerarg value="org.lwjgl.util.generator.opencl.CLGeneratorProcessor"/>
|
||||
|
@ -306,11 +314,13 @@
|
|||
<compilerarg value="-AgenJavaPath=${lwjgl.target.gen.java}"/>
|
||||
<compilerarg value="${javac.args.debug}"/>
|
||||
<compilerarg value="-Acontextspecific"/>
|
||||
<compilerarg value="-J-XX:CompileThreshold=1"/>
|
||||
<src>
|
||||
<fileset dir="${lwjgl.src.templates.cl}">
|
||||
<include name="${opencl-template-pattern}"/>
|
||||
</fileset>
|
||||
</src>
|
||||
</javac>
|
||||
</parallel>
|
||||
</target>
|
||||
</project>
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Iterator;
|
|||
*/
|
||||
final class FastIntMap<V> implements Iterable<FastIntMap.Entry<V>> {
|
||||
|
||||
private Entry[] table;
|
||||
private Entry<V>[] table;
|
||||
private int size, mask, capacity, threshold;
|
||||
|
||||
/** Same as: FastIntMap(16, 0.75f); */
|
||||
|
@ -45,7 +45,7 @@ final class FastIntMap<V> implements Iterable<FastIntMap.Entry<V>> {
|
|||
while ( capacity < initialCapacity )
|
||||
capacity <<= 1;
|
||||
this.threshold = (int)(capacity * loadFactor);
|
||||
this.table = new Entry[capacity];
|
||||
this.table = (Entry<V>[]) new Entry[capacity];
|
||||
this.mask = capacity - 1;
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ final class FastIntMap<V> implements Iterable<FastIntMap.Entry<V>> {
|
|||
final int newCapacity = 2 * capacity;
|
||||
final int newMask = newCapacity - 1;
|
||||
|
||||
final Entry<V>[] newTable = new Entry[newCapacity];
|
||||
final Entry<V>[] newTable = (Entry<V>[]) new Entry[newCapacity];
|
||||
|
||||
for ( int i = 0, index; i < table.length; i++ ) {
|
||||
Entry<V> e = table[i];
|
||||
|
@ -235,4 +235,4 @@ final class FastIntMap<V> implements Iterable<FastIntMap.Entry<V>> {
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ public final class GLContext {
|
|||
majorVersion = Integer.parseInt(version_tokenizer.nextToken());
|
||||
minorVersion = Integer.parseInt(version_tokenizer.nextToken());
|
||||
} catch (NumberFormatException e) {
|
||||
LWJGLUtil.log("The major and/or minor OpenGL version is malformed: " + e.getMessage());
|
||||
LWJGLUtil.logger().log(() -> "The major and/or minor OpenGL version is malformed: " + e.getMessage());
|
||||
}
|
||||
|
||||
// ----------------------[ 2.X ]----------------------
|
||||
|
@ -202,7 +202,7 @@ public final class GLContext {
|
|||
try {
|
||||
doInitNativeStubs(extension_class);
|
||||
} catch (LWJGLException e) {
|
||||
LWJGLUtil.log("Failed to initialize extension " + extension_class + " - exception: " + e);
|
||||
LWJGLUtil.logger().log(() -> "Failed to initialize extension " + extension_class + " - exception: " + e);
|
||||
supported_extensions.remove(ext_name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ import javax.lang.model.type.PrimitiveType;
|
|||
import javax.lang.model.type.TypeKind;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
|
||||
public class FieldsGenerator {
|
||||
public final class FieldsGenerator {
|
||||
private static final Object sync = new Object();
|
||||
|
||||
private static void validateField(VariableElement field) {
|
||||
|
|
|
@ -37,6 +37,7 @@ import java.nio.file.Path;
|
|||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Future;
|
||||
import javax.annotation.processing.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.Element;
|
||||
|
@ -44,6 +45,7 @@ import javax.lang.model.element.TypeElement;
|
|||
import javax.lang.model.util.ElementFilter;
|
||||
import javax.tools.Diagnostic;
|
||||
|
||||
import static org.lwjgl.util.generator.Utils.await;
|
||||
import static org.lwjgl.util.generator.Utils.getRequiredOption;
|
||||
import static org.lwjgl.util.generator.Utils.getOptionalOption;
|
||||
|
||||
|
@ -57,7 +59,7 @@ import static org.lwjgl.util.generator.Utils.getOptionalOption;
|
|||
@SupportedAnnotationTypes({ "*" })
|
||||
@SupportedSourceVersion(SourceVersion.RELEASE_10)
|
||||
@SupportedOptions({ "genJavaPath", "genNativePath", "typemap", "generatechecks", "nogeneratechecks", "contextspecific" })
|
||||
public class GeneratorProcessor extends AbstractProcessor {
|
||||
public final class GeneratorProcessor extends AbstractProcessor {
|
||||
|
||||
private static boolean first_round = true;
|
||||
|
||||
|
@ -77,14 +79,18 @@ public class GeneratorProcessor extends AbstractProcessor {
|
|||
|
||||
try {
|
||||
TypeMap type_map = (TypeMap)(Class.forName(typemap_classname).newInstance());
|
||||
//ElementFilter.typesIn(roundEnv.getRootElements()).stream().sequential().forEach(file -> {
|
||||
ElementFilter.typesIn(roundEnv.getRootElements()).parallelStream().forEach(file -> {
|
||||
GeneratorVisitor visitor = new GeneratorVisitor(processingEnv, gen_java_path, gen_native_path, type_map, generate_error_checks, context_specific, validate);
|
||||
for (TypeElement file : ElementFilter.typesIn(roundEnv.getRootElements())) {
|
||||
try {
|
||||
file.accept(new GeneratorVisitor(processingEnv, gen_java_path, gen_native_path, type_map, generate_error_checks, context_specific, validate), null);
|
||||
file.accept(visitor, null);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("\n-- Failed to process template: " + file.asType().toString() + " --", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
Future<Void> future;
|
||||
while ((future = visitor.futures.poll()) != null) {
|
||||
await(future);
|
||||
}
|
||||
first_round = false;
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -47,6 +47,7 @@ import java.nio.channels.FileChannel;
|
|||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
@ -72,7 +73,7 @@ import static org.lwjgl.util.generator.Utils.spawn;
|
|||
* @author elias_naur <elias_naur@users.sourceforge.net>
|
||||
* @version $Revision$ $Id$
|
||||
*/
|
||||
public class GeneratorVisitor extends ElementKindVisitor6<Void, Void> {
|
||||
public final class GeneratorVisitor extends ElementKindVisitor6<Void, Void> {
|
||||
private static final String FAST_PREFIX = "";
|
||||
private static final String SLOW_PREFIX = "\u001b[1;31m";
|
||||
private static final String TIMING_SUFFIX = "\u001b[0m";
|
||||
|
@ -87,13 +88,14 @@ public class GeneratorVisitor extends ElementKindVisitor6<Void, Void> {
|
|||
messager.printMessage(Diagnostic.Kind.NOTE, message + " in " + elapsed + " ms" + TIMING_SUFFIX + '.');
|
||||
}
|
||||
|
||||
private final ProcessingEnvironment env;
|
||||
private final Path gen_java_path;
|
||||
private final Path gen_native_path;
|
||||
private final TypeMap type_map;
|
||||
private final boolean generate_error_checks;
|
||||
private final boolean context_specific;
|
||||
private final boolean validate;
|
||||
private final ProcessingEnvironment env;
|
||||
private final Path gen_java_path;
|
||||
private final Path gen_native_path;
|
||||
private final TypeMap type_map;
|
||||
private final boolean generate_error_checks;
|
||||
private final boolean context_specific;
|
||||
private final boolean validate;
|
||||
public final ArrayDeque<Future<Void>> futures = new ArrayDeque<>(128);
|
||||
|
||||
public GeneratorVisitor(ProcessingEnvironment env, Path gen_java_path, Path gen_native_path, TypeMap type_map, boolean generate_error_checks, boolean context_specific, boolean validate) {
|
||||
this.env = env;
|
||||
|
@ -178,7 +180,7 @@ public class GeneratorVisitor extends ElementKindVisitor6<Void, Void> {
|
|||
private static final String CHAR_SEQUENCE_ARRAY_DESC = DescriptorTypeTranslator.forArray(CHAR_SEQUENCE_DESC);
|
||||
|
||||
private void validateParameters(ExecutableElement method) {
|
||||
for (VariableElement param : method.getParameters()) {
|
||||
method.getParameters().parallelStream().parallel().forEach(param -> {
|
||||
validateTypes(method, param.getAnnotationMirrors(), param.asType());
|
||||
String param_type = Utils.getDescriptor(param.asType());
|
||||
if (Utils.getNIOBufferType(param.asType()) != null && !CHAR_SEQUENCE_DESC.equals(param_type) && !CHAR_SEQUENCE_ARRAY_DESC.equals(param_type)) {
|
||||
|
@ -217,7 +219,7 @@ public class GeneratorVisitor extends ElementKindVisitor6<Void, Void> {
|
|||
throw new RuntimeException(param + " type is not a buffer, but annotated as a CachedReference");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void generateMethodsNativePointers(PrintWriter writer, Collection<ExecutableElement> methods) {
|
||||
|
@ -348,34 +350,34 @@ public class GeneratorVisitor extends ElementKindVisitor6<Void, Void> {
|
|||
|
||||
@Override
|
||||
public Void visitTypeAsInterface(TypeElement e, Void p) {
|
||||
final Collection<ExecutableElement> methods = Utils.getMethods(e);
|
||||
final Collection<VariableElement> fields = Utils.getFields(e);
|
||||
final Collection<ExecutableElement> methods = List.copyOf(Utils.getMethods(e));
|
||||
final Collection<VariableElement> fields = List.copyOf(Utils.getFields(e));
|
||||
if (methods.isEmpty() && fields.isEmpty()) {
|
||||
return DEFAULT_VALUE;
|
||||
}
|
||||
|
||||
//env.getMessager().printMessage(Kind.NOTE, "methods count : " + Utils.getMethods(e).size() + " fields count : " + Utils.getFields(e).size(), e);
|
||||
if (this.validate) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
methods.parallelStream().forEach(method -> validateMethod(method));
|
||||
printTiming(env.getMessager(), "Validated " + e, startTime);
|
||||
this.futures.push(spawn(() -> {
|
||||
long startTime = System.currentTimeMillis();
|
||||
methods.parallelStream().parallel().forEach(method -> validateMethod(method));
|
||||
printTiming(env.getMessager(), "Validated " + e, startTime);
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
|
||||
if (this.gen_java_path != null) {
|
||||
this.futures.push(spawn(() -> {
|
||||
doJavaGen(e, methods, fields);
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
|
||||
if (methods.size() > 0 && this.gen_native_path != null) {
|
||||
if (this.gen_java_path != null) {
|
||||
Future<Void> javaGenThread = spawn(() -> {
|
||||
doJavaGen(e, methods, fields);
|
||||
return null;
|
||||
});
|
||||
|
||||
this.futures.push(spawn(() -> {
|
||||
doNativeGen(e, methods);
|
||||
|
||||
await(javaGenThread);
|
||||
} else {
|
||||
doNativeGen(e, methods);
|
||||
}
|
||||
} else if (this.gen_java_path != null) {
|
||||
doJavaGen(e, methods, fields);
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
|
||||
return DEFAULT_VALUE;
|
||||
|
|
|
@ -49,7 +49,7 @@ import javax.lang.model.util.SimpleTypeVisitor6;
|
|||
* @version $Revision$
|
||||
* $Id$
|
||||
*/
|
||||
public class JNITypeTranslator extends SimpleTypeVisitor6<Void, Void> {
|
||||
public final class JNITypeTranslator extends SimpleTypeVisitor6<Void, Void> {
|
||||
|
||||
private final StringBuilder signature = new StringBuilder();
|
||||
|
||||
|
|
|
@ -55,12 +55,12 @@ import javax.lang.model.element.VariableElement;
|
|||
import javax.lang.model.type.TypeKind;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
|
||||
public class JavaMethodsGenerator {
|
||||
public final class JavaMethodsGenerator {
|
||||
|
||||
private static final String SAVED_PARAMETER_POSTFIX = "_saved";
|
||||
|
||||
public static void generateMethodsJava(ProcessingEnvironment env, TypeMap type_map, PrintWriter writer, TypeElement interface_decl, boolean generate_error_checks, boolean context_specific) {
|
||||
Utils.getMethods(interface_decl).stream().parallel().map(method -> {
|
||||
List.copyOf(Utils.getMethods(interface_decl)).parallelStream().parallel().map(method -> {
|
||||
StringWriter writer1 = new StringWriter();
|
||||
PrintWriter writer2 = new PrintWriter(writer1);
|
||||
generateMethodJava(env, type_map, writer2, interface_decl, method, generate_error_checks, context_specific);
|
||||
|
@ -82,7 +82,8 @@ public class JavaMethodsGenerator {
|
|||
printMethodWithMultiType(env, type_map, writer, interface_decl, method, typeinfos_instance, Mode.NORMAL, generate_error_checks, context_specific);
|
||||
}
|
||||
}
|
||||
if ( method.getAnnotation(CachedResult.class) != null && !method.getAnnotation(CachedResult.class).isRange() ) {
|
||||
CachedResult cached_result = method.getAnnotation(CachedResult.class);
|
||||
if ( cached_result != null && !cached_result.isRange() ) {
|
||||
printMethodWithMultiType(env, type_map, writer, interface_decl, method, TypeInfo.getDefaultTypeInfoMap(method), Mode.CACHEDRESULT, generate_error_checks, context_specific);
|
||||
}
|
||||
|
||||
|
@ -132,8 +133,11 @@ public class JavaMethodsGenerator {
|
|||
private static boolean generateParametersJava(PrintWriter writer, ExecutableElement method, Map<VariableElement, TypeInfo> typeinfos_instance, boolean native_stub, final boolean printTypes, Mode mode) {
|
||||
boolean first_parameter = true;
|
||||
for ( VariableElement param : method.getParameters() ) {
|
||||
if ( native_stub && (param.getAnnotation(Helper.class) != null && !param.getAnnotation(Helper.class).passToNative()) ) {
|
||||
continue;
|
||||
if (native_stub) {
|
||||
Helper helper = param.getAnnotation(Helper.class);
|
||||
if (helper != null && !helper.passToNative()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
final Constant constant_annotation = param.getAnnotation(Constant.class);
|
||||
if ( constant_annotation != null && constant_annotation.isNative() ) {
|
||||
|
@ -281,10 +285,12 @@ public class JavaMethodsGenerator {
|
|||
final TypeMirror result_type = Utils.getMethodReturnType(method);
|
||||
boolean has_result = !result_type.equals(env.getTypeUtils().getNoType(TypeKind.VOID));
|
||||
|
||||
GLreturn gl_return = method.getAnnotation(GLreturn.class);
|
||||
|
||||
final Reuse reuse_annotation = method.getAnnotation(Reuse.class);
|
||||
if ( reuse_annotation != null ) {
|
||||
writer.append("\t\t");
|
||||
if ( has_result || method.getAnnotation(GLreturn.class) != null ) {
|
||||
if ( has_result || gl_return != null ) {
|
||||
writer.append("return ");
|
||||
}
|
||||
|
||||
|
@ -319,9 +325,7 @@ public class JavaMethodsGenerator {
|
|||
writer.append(getResultType(method, false)).append(" " + Utils.RESULT_VAR_NAME);
|
||||
|
||||
if ( code_annotation != null && code_annotation.tryBlock() ) {
|
||||
writer.append(" = ").append(getDefaultResultValue(method));
|
||||
writer.append(";\n\t\ttry {\n");
|
||||
writer.append("\t\t\t" + Utils.RESULT_VAR_NAME);
|
||||
writer.append(" = ").append(getDefaultResultValue(method)).append(";\n\t\ttry {\n" + "\t\t\t" + Utils.RESULT_VAR_NAME);
|
||||
}
|
||||
|
||||
writer.append(" = ");
|
||||
|
@ -332,9 +336,9 @@ public class JavaMethodsGenerator {
|
|||
writer.append("new ").append(getResultType(method, false)).append('(');
|
||||
}
|
||||
}
|
||||
} else if ( method.getAnnotation(GLreturn.class) != null ) {
|
||||
} else if ( gl_return != null ) {
|
||||
has_result = true;
|
||||
Utils.printGLReturnPre(writer, method, method.getAnnotation(GLreturn.class), type_map);
|
||||
Utils.printGLReturnPre(writer, method, gl_return, type_map);
|
||||
}
|
||||
writer.append(Utils.getSimpleNativeMethodName(method, generate_error_checks, context_specific));
|
||||
if ( mode == Mode.BUFFEROBJECT ) {
|
||||
|
@ -364,14 +368,14 @@ public class JavaMethodsGenerator {
|
|||
// DISABLED: indirect buffer support
|
||||
//printNondirectParameterCopies(writer, method, mode);
|
||||
if ( has_result ) {
|
||||
if ( method.getAnnotation(GLreturn.class) == null ) {
|
||||
if ( gl_return == null ) {
|
||||
if ( ByteBuffer.class.equals(Utils.getJavaType(result_type)) ) {
|
||||
writer.append(tabs).append("return LWJGLUtil.CHECKS && " + Utils.RESULT_VAR_NAME + " == null ? null : " + Utils.RESULT_VAR_NAME + ".order(ByteOrder.nativeOrder());\n"); // safeNewBuffer returns a direct ByteBuffer with BIG_ENDIAN order.
|
||||
} else {
|
||||
writer.append(tabs).append("return " + Utils.RESULT_VAR_NAME + ";\n");
|
||||
}
|
||||
} else {
|
||||
Utils.printGLReturnPost(writer, method, method.getAnnotation(GLreturn.class), type_map);
|
||||
Utils.printGLReturnPost(writer, method, gl_return, type_map);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -601,9 +605,10 @@ public class JavaMethodsGenerator {
|
|||
private static boolean printMethodCallArguments(PrintWriter writer, ExecutableElement method, Map<VariableElement, TypeInfo> typeinfos_instance, Mode mode, TypeMap type_map) {
|
||||
boolean first_parameter = true;
|
||||
for ( VariableElement param : method.getParameters() ) {
|
||||
if ( param.getAnnotation(Result.class) != null || (param.getAnnotation(Helper.class) != null && !param.getAnnotation(Helper.class).passToNative()) ) {
|
||||
continue;
|
||||
}
|
||||
if (param.getAnnotation(Result.class) != null) continue;
|
||||
|
||||
Helper helper = param.getAnnotation(Helper.class);
|
||||
if (helper != null && !helper.passToNative()) continue;
|
||||
|
||||
final Constant constant_annotation = param.getAnnotation(Constant.class);
|
||||
if ( constant_annotation == null || !constant_annotation.isNative() ) {
|
||||
|
@ -611,7 +616,8 @@ public class JavaMethodsGenerator {
|
|||
}
|
||||
}
|
||||
if ( Utils.getNIOBufferType(Utils.getMethodReturnType(method)) != null ) {
|
||||
if ( method.getAnnotation(CachedResult.class) != null && method.getAnnotation(CachedResult.class).isRange() ) {
|
||||
CachedResult cached_result = method.getAnnotation(CachedResult.class);
|
||||
if ( cached_result != null && cached_result.isRange() ) {
|
||||
first_parameter = false;
|
||||
Utils.printExtraCallArguments(writer, method, "");
|
||||
} else {
|
||||
|
@ -777,18 +783,22 @@ public class JavaMethodsGenerator {
|
|||
}
|
||||
|
||||
private static String getResultType(ExecutableElement method, boolean native_stub) {
|
||||
if ( native_stub && method.getAnnotation(PointerWrapper.class) != null ) {
|
||||
return "long";
|
||||
} else if ( !native_stub && method.getAnnotation(GLreturn.class) != null ) {
|
||||
return Utils.getMethodReturnType(method, method.getAnnotation(GLreturn.class), false);
|
||||
if (native_stub) {
|
||||
if (method.getAnnotation(PointerWrapper.class) != null) return "long";
|
||||
} else {
|
||||
return Utils.getJavaType(Utils.getMethodReturnType(method)).getSimpleName();
|
||||
GLreturn gl_return = method.getAnnotation(GLreturn.class);
|
||||
if (gl_return != null) {
|
||||
return Utils.getMethodReturnType(method, gl_return, false);
|
||||
}
|
||||
}
|
||||
|
||||
return Utils.getJavaType(Utils.getMethodReturnType(method)).getSimpleName();
|
||||
}
|
||||
|
||||
private static String getDefaultResultValue(ExecutableElement method) {
|
||||
if ( method.getAnnotation(GLreturn.class) != null ) {
|
||||
final String type = Utils.getMethodReturnType(method, method.getAnnotation(GLreturn.class), false);
|
||||
GLreturn gl_return = method.getAnnotation(GLreturn.class);
|
||||
if (gl_return != null) {
|
||||
final String type = Utils.getMethodReturnType(method, gl_return, false);
|
||||
if ( "boolean".equals(type) ) {
|
||||
return "false";
|
||||
} else if ( Character.isLowerCase(type.charAt(0)) ) {
|
||||
|
|
|
@ -42,7 +42,7 @@ import javax.lang.model.util.SimpleTypeVisitor6;
|
|||
* @author elias_naur <elias_naur@users.sourceforge.net>
|
||||
* @version $Revision$ $Id$
|
||||
*/
|
||||
public class JavaTypeTranslator extends SimpleTypeVisitor6<Void, Void> {
|
||||
public final class JavaTypeTranslator extends SimpleTypeVisitor6<Void, Void> {
|
||||
|
||||
private Class type;
|
||||
|
||||
|
@ -53,23 +53,27 @@ public class JavaTypeTranslator extends SimpleTypeVisitor6<Void, Void> {
|
|||
@Override
|
||||
public Void visitArray(ArrayType t, Void o) {
|
||||
final TypeMirror componentType = t.getComponentType();
|
||||
try {
|
||||
final Class c = Class.forName(t.getComponentType().toString());
|
||||
if ( CharSequence.class.isAssignableFrom(c) || ByteBuffer.class.isAssignableFrom(c) || org.lwjgl.PointerWrapper.class.isAssignableFrom(c) ) {
|
||||
type = Class.forName("[L" + t.getComponentType() + ";");
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
type = null;
|
||||
} finally {
|
||||
if ( type == null ) {
|
||||
if ( componentType instanceof PrimitiveType ) {
|
||||
type = getPrimitiveArrayClassFromKind(componentType.getKind());
|
||||
} else {
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
}
|
||||
|
||||
if (componentType instanceof PrimitiveType) {
|
||||
type = getPrimitiveArrayClassFromKind(componentType.getKind());
|
||||
return DEFAULT_VALUE;
|
||||
}
|
||||
|
||||
Class c;
|
||||
try {
|
||||
c = Class.forName(componentType.toString());
|
||||
} catch (ClassNotFoundException ex) {
|
||||
type = null;
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
if (c == CharSequence.class || c == ByteBuffer.class || c == org.lwjgl.PointerWrapper.class || CharSequence.class.isAssignableFrom(c) || ByteBuffer.class.isAssignableFrom(c) || org.lwjgl.PointerWrapper.class.isAssignableFrom(c)) {
|
||||
type = c.arrayType();
|
||||
return DEFAULT_VALUE;
|
||||
}
|
||||
|
||||
type = null;
|
||||
throw new RuntimeException(t + " is not allowed");
|
||||
}
|
||||
|
||||
public static Class getPrimitiveClassFromKind(TypeKind kind) {
|
||||
|
@ -93,7 +97,7 @@ public class JavaTypeTranslator extends SimpleTypeVisitor6<Void, Void> {
|
|||
}
|
||||
}
|
||||
|
||||
private static Class getPrimitiveArrayClassFromKind(TypeKind kind) {
|
||||
public static Class getPrimitiveArrayClassFromKind(TypeKind kind) {
|
||||
switch ( kind ) {
|
||||
case LONG:
|
||||
return long[].class;
|
||||
|
|
|
@ -54,7 +54,7 @@ import javax.lang.model.element.VariableElement;
|
|||
import javax.lang.model.type.TypeKind;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
|
||||
public class NativeMethodStubsGenerator {
|
||||
public final class NativeMethodStubsGenerator {
|
||||
private static final String BUFFER_ADDRESS_POSTFIX = "_address";
|
||||
public static final String BUFFER_POSITION_POSTFIX = "_position";
|
||||
private static final String STRING_LIST_NAME = "_str";
|
||||
|
|
|
@ -59,7 +59,7 @@ import javax.lang.model.util.SimpleTypeVisitor6;
|
|||
* @author elias_naur <elias_naur@users.sourceforge.net>
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class NativeTypeTranslator extends SimpleTypeVisitor6<Void, Void> {
|
||||
public final class NativeTypeTranslator extends SimpleTypeVisitor6<Void, Void> {
|
||||
|
||||
private Collection<Class> native_types;
|
||||
private boolean is_indirect;
|
||||
|
|
|
@ -51,7 +51,7 @@ import javax.lang.model.element.VariableElement;
|
|||
import javax.lang.model.type.TypeKind;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
|
||||
public class TypeInfo {
|
||||
public final class TypeInfo {
|
||||
|
||||
public static final String UNSIGNED_PARAMETER_NAME = "unsigned";
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ import javax.lang.model.type.TypeMirror;
|
|||
import javax.lang.model.type.TypeVisitor;
|
||||
import javax.lang.model.util.ElementFilter;
|
||||
|
||||
public class Utils {
|
||||
public final class Utils {
|
||||
|
||||
public static final String TYPEDEF_POSTFIX = "PROC";
|
||||
public static final String FUNCTION_POINTER_VAR_NAME = "function_pointer";
|
||||
|
|
|
@ -53,7 +53,7 @@ import javax.lang.model.element.AnnotationMirror;
|
|||
import javax.lang.model.element.ExecutableElement;
|
||||
import javax.lang.model.type.TypeKind;
|
||||
|
||||
public class ALTypeMap implements TypeMap {
|
||||
public final class ALTypeMap implements TypeMap {
|
||||
private static final Map<Class, TypeKind> native_types_to_primitive;
|
||||
|
||||
static {
|
||||
|
|
|
@ -45,7 +45,7 @@ import javax.lang.model.element.TypeElement;
|
|||
*
|
||||
* @author Spasi
|
||||
*/
|
||||
public class CLCapabilitiesGenerator {
|
||||
public final class CLCapabilitiesGenerator {
|
||||
|
||||
static void generateClassPrologue(final PrintWriter writer) {
|
||||
writer.println("public final class " + CLGeneratorProcessor.CLCAPS_CLASS_NAME + " {");
|
||||
|
|
|
@ -62,7 +62,7 @@ import static org.lwjgl.util.generator.Utils.spawn;
|
|||
@SupportedAnnotationTypes({ "*" })
|
||||
@SupportedSourceVersion(SourceVersion.RELEASE_10)
|
||||
@SupportedOptions({ "genJavaPath", "generatechecks", "contextspecific" })
|
||||
public class CLGeneratorProcessor extends AbstractProcessor {
|
||||
public final class CLGeneratorProcessor extends AbstractProcessor {
|
||||
|
||||
public static final String CLCAPS_CLASS_NAME = "CLCapabilities";
|
||||
public static final String PLATFORM_CAPS_CLASS_NAME = "CLPlatformCapabilities";
|
||||
|
|
|
@ -48,7 +48,7 @@ import javax.lang.model.element.TypeElement;
|
|||
*
|
||||
* @author Spasi
|
||||
*/
|
||||
public class CLPDCapabilitiesGenerator {
|
||||
public final class CLPDCapabilitiesGenerator {
|
||||
|
||||
// TODO: Add future versions here
|
||||
private static final int[][] CL_VERSIONS = {
|
||||
|
@ -56,7 +56,7 @@ public class CLPDCapabilitiesGenerator {
|
|||
};
|
||||
|
||||
static void generateClassPrologue(final PrintWriter writer, final String name) {
|
||||
writer.println("public class " + name + " {");
|
||||
writer.println("public final class " + name + " {");
|
||||
writer.println();
|
||||
writer.println("\tpublic final int majorVersion;");
|
||||
writer.println("\tpublic final int minorVersion;");
|
||||
|
@ -151,4 +151,4 @@ public class CLPDCapabilitiesGenerator {
|
|||
writer.println("\t}\n");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ import javax.lang.model.element.ExecutableElement;
|
|||
import javax.lang.model.element.VariableElement;
|
||||
import javax.lang.model.type.TypeKind;
|
||||
|
||||
public class CLTypeMap implements TypeMap {
|
||||
public final class CLTypeMap implements TypeMap {
|
||||
|
||||
private static final Map<Class, TypeKind> native_types_to_primitive;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ import javax.lang.model.type.TypeMirror;
|
|||
* @version $Revision: 3355 $
|
||||
* $Id: ContextCapabilitiesGenerator.java 3355 2010-05-27 22:56:29Z spasi $
|
||||
*/
|
||||
public class GLCapabilitiesGenerator {
|
||||
public final class GLCapabilitiesGenerator {
|
||||
|
||||
private static final String STUBS_LOADED_NAME = "loaded_stubs";
|
||||
private static final String ALL_INIT_METHOD_NAME = "initAllStubs";
|
||||
|
@ -62,7 +62,7 @@ public class GLCapabilitiesGenerator {
|
|||
private static final String CORE_PREFIX = "Open";
|
||||
|
||||
public static void generateClassPrologue(PrintWriter writer, boolean context_specific, boolean generate_error_checks) {
|
||||
writer.append("public class " + Utils.CONTEXT_CAPS_CLASS_NAME + " {\n");
|
||||
writer.append("public final class " + Utils.CONTEXT_CAPS_CLASS_NAME + " {\n");
|
||||
writer.append("\tstatic final boolean DEBUG = ").append(Boolean.toString(generate_error_checks)).append(";\n");
|
||||
writer.append("\tfinal APIUtil util = new APIUtil();\n");
|
||||
writer.append("\tfinal StateTracker tracker = new StateTracker();\n\n");
|
||||
|
@ -76,11 +76,9 @@ public class GLCapabilitiesGenerator {
|
|||
writer.append("\t\tSet<String> " + CACHED_EXTS_VAR_NAME + " = " + ALL_INIT_METHOD_NAME + "(forwardCompatible);\n");
|
||||
}
|
||||
|
||||
private static String translateFieldName(String interface_name) {
|
||||
if ( interface_name.startsWith("GL") )
|
||||
return CORE_PREFIX + interface_name;
|
||||
else
|
||||
return EXTENSION_PREFIX + interface_name;
|
||||
private static PrintWriter translateFieldName(PrintWriter writer, String interface_name) {
|
||||
return writer.append(interface_name.startsWith("GL") ? CORE_PREFIX : EXTENSION_PREFIX)
|
||||
.append(interface_name);
|
||||
}
|
||||
|
||||
public static void generateSuperClassAdds(PrintWriter writer, TypeElement d, ProcessingEnvironment env) {
|
||||
|
@ -89,42 +87,39 @@ public class GLCapabilitiesGenerator {
|
|||
throw new RuntimeException(d + " extends more than one other interface");
|
||||
if ( super_interfaces.size() == 1 ) {
|
||||
TypeMirror super_interface = super_interfaces.iterator().next();
|
||||
writer.append("\t\tif (").append(CACHED_EXTS_VAR_NAME).append(".contains(\"");
|
||||
writer.append(translateFieldName(d.getSimpleName().toString())).append("\"))\n");
|
||||
writer.append("\t\t\t");
|
||||
writer.append("\t\tif (" + CACHED_EXTS_VAR_NAME + ".contains(\"");
|
||||
translateFieldName(writer, d.getSimpleName().toString()).append("\"))\n" + "\t\t\t");
|
||||
generateAddExtension(writer, env.getElementUtils().getTypeElement(super_interface.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public static void generateInitializer(PrintWriter writer, TypeElement d, ProcessingEnvironment env) {
|
||||
String translated_field_name = translateFieldName(d.getSimpleName().toString());
|
||||
writer.append("\t\tthis.").append(translated_field_name).append(" = ");
|
||||
String non_translated_field_name = d.getSimpleName().toString();
|
||||
translateFieldName(writer.append("\t\tthis."), non_translated_field_name).append(" = ");
|
||||
writer.append(CACHED_EXTS_VAR_NAME + ".contains(\"");
|
||||
writer.append(translated_field_name).append("\")");
|
||||
translateFieldName(writer, non_translated_field_name).append("\")");
|
||||
List<? extends TypeMirror> super_interfaces = d.getInterfaces();
|
||||
if ( super_interfaces.size() > 1 )
|
||||
throw new RuntimeException(d + " extends more than one other interface");
|
||||
if ( super_interfaces.size() == 1 ) {
|
||||
TypeMirror super_interface = super_interfaces.iterator().next();
|
||||
writer.append('\n');
|
||||
writer.append("\t\t\t&& ").append(CACHED_EXTS_VAR_NAME).append(".contains(\"");
|
||||
writer.append(translateFieldName(env.getElementUtils().getTypeElement(super_interface.toString()).getSimpleName().toString())).append("\")");
|
||||
writer.append("\n\t\t\t&& " + CACHED_EXTS_VAR_NAME + ".contains(\"");
|
||||
translateFieldName(writer, env.getElementUtils().getTypeElement(super_interface.toString()).getSimpleName().toString()).append("\")");
|
||||
}
|
||||
Alias alias_annotation = d.getAnnotation(Alias.class);
|
||||
if ( alias_annotation != null ) {
|
||||
writer.append('\n');
|
||||
writer.append("\t\t\t|| ").append(CACHED_EXTS_VAR_NAME).append(".contains(\"");
|
||||
writer.append(translateFieldName(alias_annotation.value())).append("\")");
|
||||
writer.append("\n\t\t\t|| " + CACHED_EXTS_VAR_NAME + ".contains(\"");
|
||||
translateFieldName(writer, alias_annotation.value()).append("\")");
|
||||
}
|
||||
writer.append(";\n");
|
||||
}
|
||||
|
||||
private static String getAddressesInitializerName(String class_name) {
|
||||
return class_name + POINTER_INITIALIZER_POSTFIX;
|
||||
private static PrintWriter getAddressesInitializerName(PrintWriter writer, String class_name) {
|
||||
return writer.append(class_name).append(POINTER_INITIALIZER_POSTFIX);
|
||||
}
|
||||
|
||||
public static void generateInitStubsPrologue(PrintWriter writer, boolean context_specific) {
|
||||
writer.append("\tprivate Set<String> ").append(ALL_INIT_METHOD_NAME).append("(boolean forwardCompatible) throws LWJGLException {\n");
|
||||
writer.append("\tprivate Set<String> " + ALL_INIT_METHOD_NAME + "(boolean forwardCompatible) throws LWJGLException {\n");
|
||||
|
||||
// Load the basic pointers we need to detect OpenGL version and supported extensions.
|
||||
writer.append("\t\tglGetError = GLContext.getFunctionAddress(\"glGetError\");\n");
|
||||
|
@ -141,16 +136,18 @@ public class GLCapabilitiesGenerator {
|
|||
writer.append("\t\tint " + PROFILE_MASK_VAR_NAME + " = GLContext.getSupportedExtensions(" + CACHED_EXTS_VAR_NAME + ");\n");
|
||||
|
||||
// Force forward compatible mode when OpenGL version is 3.1 or higher and ARB_compatibility is not available.
|
||||
writer.append("\t\tif ( supported_extensions.contains(\"OpenGL31\") && !(supported_extensions.contains(\"GL_ARB_compatibility\") || (profileMask & GL32.GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0) )\n");
|
||||
writer.append("\t\tif (" + CACHED_EXTS_VAR_NAME + ".contains(\"OpenGL31\") && !(" + CACHED_EXTS_VAR_NAME + ".contains(\"GL_ARB_compatibility\") || (" + PROFILE_MASK_VAR_NAME + " & GL32.GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0)) {\n");
|
||||
writer.append("\t\t\tforwardCompatible = true;\n");
|
||||
writer.append("\t\t\tLWJGLUtil.logger().log(() -> \"Forcing forwardCompatible=true because OpenGL version is 3.1 or higher AND ARB_compatibility is not available OR " + PROFILE_MASK_VAR_NAME + " has GL32.GL_CONTEXT_COMPATIBILITY_PROFILE_BIT set.\");\n");
|
||||
writer.append("\t\t}\n");
|
||||
|
||||
if ( !context_specific ) {
|
||||
writer.append("\t\tif (" + STUBS_LOADED_NAME + ")\n");
|
||||
writer.append("\t\t\treturn GLContext.getSupportedExtensions();\n");
|
||||
writer.append("\t\torg.lwjgl.opengl.GL11." + Utils.STUB_INITIALIZER_NAME + "();\n");
|
||||
} else {
|
||||
writer.append("\t\tif (!").append(getAddressesInitializerName("GL11")).append("(forwardCompatible))\n");
|
||||
writer.append("\t\t\tthrow new LWJGLException(\"GL11 not supported\");\n");
|
||||
writer.append("\t\tif (!");
|
||||
getAddressesInitializerName(writer, "GL11").append("(forwardCompatible))\n" + "\t\t\tthrow new LWJGLException(\"GL11 not supported\");\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -173,67 +170,79 @@ public class GLCapabilitiesGenerator {
|
|||
if ( context_specific ) {
|
||||
final Alias alias_annotation = d.getAnnotation(Alias.class);
|
||||
|
||||
if ( d.getAnnotation(ForceInit.class) != null )
|
||||
writer.append("\t\t" + CACHED_EXTS_VAR_NAME + ".add(\"").append(translateFieldName(d.getSimpleName().toString())).append("\");\n");
|
||||
if ( d.getAnnotation(ForceInit.class) != null ) {
|
||||
writer.append("\t\t" + CACHED_EXTS_VAR_NAME + ".add(\"");
|
||||
translateFieldName(writer, d.getSimpleName().toString()).append("\");\n");
|
||||
}
|
||||
writer.append("\t\tif (");
|
||||
if ( alias_annotation != null )
|
||||
if ( alias_annotation != null ) {
|
||||
writer.append('(');
|
||||
}
|
||||
writer.append(CACHED_EXTS_VAR_NAME + ".contains(\"");
|
||||
writer.append(translateFieldName(d.getSimpleName().toString())).append("\")");
|
||||
translateFieldName(writer, d.getSimpleName().toString()).append("\")");
|
||||
if ( alias_annotation != null ) {
|
||||
writer.append(" || " + CACHED_EXTS_VAR_NAME + ".contains(\"");
|
||||
writer.append(translateFieldName(alias_annotation.value())).append("\"))");
|
||||
translateFieldName(writer, alias_annotation.value()).append("\"))");
|
||||
}
|
||||
writer.append(" && !").append(getAddressesInitializerName(d.getSimpleName().toString())).append('(');
|
||||
if ( d.getAnnotation(DeprecatedGL.class) != null )
|
||||
writer.append(" && !");
|
||||
getAddressesInitializerName(writer, d.getSimpleName().toString()).append('(');
|
||||
if ( d.getAnnotation(DeprecatedGL.class) != null ) {
|
||||
writer.append("forwardCompatible");
|
||||
}
|
||||
if ( d.getAnnotation(Dependent.class) != null ) {
|
||||
if ( d.getAnnotation(DeprecatedGL.class) != null )
|
||||
if ( d.getAnnotation(DeprecatedGL.class) != null ) {
|
||||
writer.append(",");
|
||||
writer.append("supported_extensions");
|
||||
}
|
||||
writer.append(CACHED_EXTS_VAR_NAME);
|
||||
}
|
||||
if ( alias_annotation != null ) {
|
||||
writer.append(")) {\n");
|
||||
writer.append("\t\t\tremove(" + CACHED_EXTS_VAR_NAME + ", \"").append(translateFieldName(alias_annotation.value())).append("\");\n");
|
||||
} else
|
||||
writer.append(")) {\n" + "\t\t\tremove(" + CACHED_EXTS_VAR_NAME + ", \"");
|
||||
translateFieldName(writer, alias_annotation.value()).append("\");\n");
|
||||
} else {
|
||||
writer.append("))\n");
|
||||
writer.append("\t\t\tremove(" + CACHED_EXTS_VAR_NAME + ", \"").append(translateFieldName(d.getSimpleName().toString())).append("\");\n");
|
||||
if ( alias_annotation != null )
|
||||
}
|
||||
writer.append("\t\t\tremove(" + CACHED_EXTS_VAR_NAME + ", \"");
|
||||
translateFieldName(writer, d.getSimpleName().toString()).append("\");\n");
|
||||
if ( alias_annotation != null ) {
|
||||
writer.append("\t\t}\n");
|
||||
}
|
||||
} else {
|
||||
writer.append("\t\tGLContext." + Utils.STUB_INITIALIZER_NAME + "(").append(Utils.getSimpleClassName(d));
|
||||
writer.append(".class, " + CACHED_EXTS_VAR_NAME + ", \"").append(translateFieldName(d.getSimpleName().toString())).append("\");\n");
|
||||
writer.append("\t\tGLContext." + Utils.STUB_INITIALIZER_NAME + '(').append(Utils.getSimpleClassName(d));
|
||||
writer.append(".class, " + CACHED_EXTS_VAR_NAME + ", \"");
|
||||
translateFieldName(writer, d.getSimpleName().toString()).append("\");\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void generateAddExtension(PrintWriter writer, TypeElement d) {
|
||||
writer.append(CACHED_EXTS_VAR_NAME + ".add(\"").append(translateFieldName(d.getSimpleName().toString())).append("\");\n");
|
||||
writer.append(CACHED_EXTS_VAR_NAME + ".add(\"");
|
||||
translateFieldName(writer, d.getSimpleName().toString()).append("\");\n");
|
||||
}
|
||||
|
||||
public static void generateAddressesInitializers(ProcessingEnvironment env, PrintWriter writer, TypeElement d) {
|
||||
Iterator<? extends ExecutableElement> methods = Utils.getMethods(d).iterator();
|
||||
if ( !methods.hasNext() )
|
||||
return;
|
||||
if (!methods.hasNext()) return;
|
||||
|
||||
writer.append("\tprivate boolean ").append(getAddressesInitializerName(d.getSimpleName().toString())).append('(');
|
||||
writer.append("\tprivate boolean ");
|
||||
getAddressesInitializerName(writer, d.getSimpleName().toString()).append('(');
|
||||
|
||||
boolean optional;
|
||||
boolean deprecated = d.getAnnotation(DeprecatedGL.class) != null;
|
||||
Dependent dependent = d.getAnnotation(Dependent.class);
|
||||
if ( deprecated )
|
||||
if (deprecated) {
|
||||
writer.append("boolean forwardCompatible");
|
||||
if ( dependent != null ) {
|
||||
if ( deprecated )
|
||||
}
|
||||
if (dependent != null) {
|
||||
if (deprecated) {
|
||||
writer.append(',');
|
||||
writer.append("Set<String> supported_extensions");
|
||||
}
|
||||
writer.append("Set<String> " + CACHED_EXTS_VAR_NAME);
|
||||
}
|
||||
|
||||
Alias alias_annotation = d.getAnnotation(Alias.class);
|
||||
boolean aliased = alias_annotation != null && alias_annotation.postfix().length() > 0;
|
||||
|
||||
writer.append(") {\n");
|
||||
writer.append("\t\treturn \n");
|
||||
writer.append(") {\n" + "\t\treturn \n");
|
||||
|
||||
boolean first = true;
|
||||
while ( methods.hasNext() ) {
|
||||
|
@ -241,75 +250,82 @@ public class GLCapabilitiesGenerator {
|
|||
if ( method.getAnnotation(Alternate.class) != null )
|
||||
continue;
|
||||
|
||||
if ( !first )
|
||||
if (!first) {
|
||||
writer.append(" &\n");
|
||||
else
|
||||
} else {
|
||||
first = false;
|
||||
}
|
||||
|
||||
optional = method.getAnnotation(Optional.class) != null;
|
||||
deprecated = method.getAnnotation(DeprecatedGL.class) != null;
|
||||
dependent = method.getAnnotation(Dependent.class);
|
||||
|
||||
writer.append("\t\t\t(");
|
||||
if ( optional )
|
||||
if (optional) {
|
||||
writer.append('(');
|
||||
if ( deprecated )
|
||||
}
|
||||
if (deprecated) {
|
||||
writer.append("forwardCompatible || ");
|
||||
if ( dependent != null ) {
|
||||
if ( dependent.value().indexOf(',') == -1 )
|
||||
writer.append("!supported_extensions.contains(\"").append(dependent.value()).append("\") || ");
|
||||
}
|
||||
if (dependent != null) {
|
||||
if (dependent.value().indexOf(',') == -1)
|
||||
writer.append("!" + CACHED_EXTS_VAR_NAME + ".contains(\"").append(dependent.value()).append("\") || ");
|
||||
else {
|
||||
writer.append("!(false");
|
||||
for ( String extension : dependent.value().split(",") )
|
||||
writer.append(" || supported_extensions.contains(\"").append(extension).append("\")");
|
||||
for (String extension : dependent.value().split(",")) {
|
||||
writer.append(" || " + CACHED_EXTS_VAR_NAME + ".contains(\"").append(extension).append("\")");
|
||||
}
|
||||
writer.append(") || ");
|
||||
}
|
||||
}
|
||||
if ( deprecated || dependent != null )
|
||||
if (deprecated || dependent != null) {
|
||||
writer.append('(');
|
||||
}
|
||||
writer.append(Utils.getFunctionAddressName(d, method)).append(" = ");
|
||||
PlatformDependent platform_dependent = method.getAnnotation(PlatformDependent.class);
|
||||
if ( platform_dependent != null ) {
|
||||
if (platform_dependent != null) {
|
||||
EnumSet<Platform> platform_set = EnumSet.copyOf(Arrays.asList(platform_dependent.value()));
|
||||
writer.append("GLContext.getPlatformSpecificFunctionAddress(\"");
|
||||
writer.append(Platform.ALL.getPrefix()).append("\", ");
|
||||
writer.append("new String[]{");
|
||||
writer.append("GLContext.getPlatformSpecificFunctionAddress(\"").append(Platform.ALL.getPrefix()).append("\", " + "new String[]{");
|
||||
Iterator<Platform> platforms = platform_set.iterator();
|
||||
while ( platforms.hasNext() ) {
|
||||
writer.append("\"").append(platforms.next().getOSPrefix()).append("\"");
|
||||
if ( platforms.hasNext() )
|
||||
if (platforms.hasNext()) {
|
||||
writer.append(", ");
|
||||
}
|
||||
}
|
||||
writer.append("}, new String[]{");
|
||||
platforms = platform_set.iterator();
|
||||
while ( platforms.hasNext() ) {
|
||||
while (platforms.hasNext()) {
|
||||
writer.append("\"").append(platforms.next().getPrefix()).append("\"");
|
||||
if ( platforms.hasNext() )
|
||||
if (platforms.hasNext()) {
|
||||
writer.append(", ");
|
||||
}
|
||||
}
|
||||
writer.append("}, ");
|
||||
} else if ( aliased ) {
|
||||
} else if (aliased) {
|
||||
writer.append("GLContext.getFunctionAddress(new String[] {\"").append(method.getSimpleName()).append("\",\"").append(method.getSimpleName()).append(alias_annotation.postfix()).append("\"})) != 0");
|
||||
} else
|
||||
} else {
|
||||
writer.append("GLContext.getFunctionAddress(");
|
||||
if ( !aliased )
|
||||
}
|
||||
if (!aliased) {
|
||||
writer.append("\"").append(method.getSimpleName()).append("\")) != 0");
|
||||
if ( deprecated || dependent != null )
|
||||
}
|
||||
if (deprecated || dependent != null) {
|
||||
writer.append(')');
|
||||
if ( optional )
|
||||
}
|
||||
if (optional) {
|
||||
writer.append(" || true)");
|
||||
}
|
||||
}
|
||||
writer.append(";\n");
|
||||
writer.append("\t}\n");
|
||||
writer.append(";\n" + "\t}\n");
|
||||
}
|
||||
|
||||
public static void generateSymbolAddresses(ProcessingEnvironment env, PrintWriter writer, TypeElement d) {
|
||||
boolean first = true;
|
||||
for ( final ExecutableElement method : Utils.getMethods(d) ) {
|
||||
if ( method.getAnnotation(Alternate.class) != null || method.getAnnotation(Reuse.class) != null )
|
||||
continue;
|
||||
for (final ExecutableElement method : Utils.getMethods(d)) {
|
||||
if (method.getAnnotation(Alternate.class) != null || method.getAnnotation(Reuse.class) != null) continue;
|
||||
|
||||
if ( first ) {
|
||||
if (first) {
|
||||
writer.append("\t// ").append(d.getSimpleName()).append('\n');
|
||||
first = false;
|
||||
}
|
||||
|
@ -318,6 +334,7 @@ public class GLCapabilitiesGenerator {
|
|||
}
|
||||
|
||||
public static void generateField(PrintWriter writer, TypeElement d) {
|
||||
writer.append("\tpublic final boolean ").append(translateFieldName(d.getSimpleName().toString())).append(";\n");
|
||||
writer.append("\tpublic final boolean ");
|
||||
translateFieldName(writer, d.getSimpleName().toString()).append(";\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ import javax.lang.model.type.TypeMirror;
|
|||
* @version $Revision: 3334 $
|
||||
* $Id: ContextCapabilitiesGenerator.java 3334 2010-04-22 23:21:48Z spasi $
|
||||
*/
|
||||
public class GLESCapabilitiesGenerator {
|
||||
public final class GLESCapabilitiesGenerator {
|
||||
|
||||
private static final String STUBS_LOADED_NAME = "loaded_stubs";
|
||||
private static final String ALL_INIT_METHOD_NAME = "initAllStubs";
|
||||
|
@ -61,7 +61,7 @@ public class GLESCapabilitiesGenerator {
|
|||
private static final String CORE_PREFIX = "Open";
|
||||
|
||||
public static void generateClassPrologue(PrintWriter writer, boolean context_specific, boolean generate_error_checks) {
|
||||
writer.println("public class " + Utils.CONTEXT_CAPS_CLASS_NAME + " {");
|
||||
writer.println("public final class " + Utils.CONTEXT_CAPS_CLASS_NAME + " {");
|
||||
writer.println("\tstatic final boolean DEBUG = " + Boolean.toString(generate_error_checks) + ";");
|
||||
writer.println();
|
||||
if ( !context_specific ) {
|
||||
|
@ -305,4 +305,4 @@ public class GLESCapabilitiesGenerator {
|
|||
writer.println("\tpublic final boolean " + translateFieldName(d.getSimpleName().toString()) + ";");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,15 +33,22 @@ package org.lwjgl.util.generator.opengl;
|
|||
|
||||
import org.lwjgl.util.generator.Utils;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import javax.annotation.processing.*;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.util.ElementFilter;
|
||||
|
||||
import static org.lwjgl.util.generator.GeneratorVisitor.saveGeneratedJavaSource;
|
||||
import static org.lwjgl.util.generator.Utils.getRequiredOption;
|
||||
import static org.lwjgl.util.generator.Utils.spawn;
|
||||
|
||||
/**
|
||||
* Generator tool for creating the ContexCapabilities class
|
||||
*
|
||||
|
@ -51,8 +58,8 @@ import javax.lang.model.util.ElementFilter;
|
|||
*/
|
||||
@SupportedAnnotationTypes({ "*" })
|
||||
@SupportedSourceVersion(SourceVersion.RELEASE_10)
|
||||
@SupportedOptions({ "contextspecific", "generatechecks" })
|
||||
public class GLESGeneratorProcessor extends AbstractProcessor {
|
||||
@SupportedOptions({ "genJavaPath", "contextspecific", "generatechecks" })
|
||||
public final class GLESGeneratorProcessor extends AbstractProcessor {
|
||||
|
||||
private static boolean first_round = true;
|
||||
|
||||
|
@ -65,8 +72,10 @@ public class GLESGeneratorProcessor extends AbstractProcessor {
|
|||
Map<String, String> options = processingEnv.getOptions();
|
||||
boolean generate_error_checks = options.containsKey("generatechecks");
|
||||
boolean context_specific = options.containsKey("contextspecific");
|
||||
Path genJavaPath = Path.of(getRequiredOption(options, "genJavaPath", "a path."));
|
||||
|
||||
try {
|
||||
generateContextCapabilitiesSource(ElementFilter.typesIn(roundEnv.getRootElements()), context_specific, generate_error_checks);
|
||||
generateContextCapabilitiesSource(genJavaPath, ElementFilter.typesIn(roundEnv.getRootElements()), context_specific, generate_error_checks);
|
||||
first_round = false;
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
|
@ -74,8 +83,13 @@ public class GLESGeneratorProcessor extends AbstractProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
private void generateContextCapabilitiesSource(Set<TypeElement> templates, boolean context_specific, boolean generate_error_checks) throws IOException {
|
||||
PrintWriter writer = new PrintWriter(processingEnv.getFiler().createSourceFile("org.lwjgl.opengles." + Utils.CONTEXT_CAPS_CLASS_NAME, processingEnv.getElementUtils().getPackageElement("org.lwjgl.opengles")).openWriter());
|
||||
private void generateContextCapabilitiesSource(Path genJavaPath, Set<TypeElement> templates, boolean context_specific, boolean generate_error_checks) throws IOException {
|
||||
long startTime = System.currentTimeMillis();
|
||||
ProcessingEnvironment env = this.processingEnv;
|
||||
|
||||
ByteArrayOutputStream writer1 = new ByteArrayOutputStream();
|
||||
PrintWriter writer = new PrintWriter(writer1);
|
||||
|
||||
writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */");
|
||||
writer.println();
|
||||
writer.println("package org.lwjgl.opengles;");
|
||||
|
@ -131,20 +145,17 @@ public class GLESGeneratorProcessor extends AbstractProcessor {
|
|||
}
|
||||
}
|
||||
GLESCapabilitiesGenerator.generateInitStubsEpilogue(writer, context_specific);
|
||||
writer.println();
|
||||
writer.println("\tstatic void unloadAllStubs() {");
|
||||
writer.append("\n\tstatic void unloadAllStubs() {\n");
|
||||
if ( !context_specific ) {
|
||||
writer.println("\t\tif (!loaded_stubs)");
|
||||
writer.println("\t\t\treturn;");
|
||||
writer.append("\t\tif (!loaded_stubs)\n" + "\t\t\treturn;\n");
|
||||
for ( TypeElement interface_decl : templates ) {
|
||||
if ( interface_decl.getKind().isInterface() ) {
|
||||
GLESCapabilitiesGenerator.generateUnloadStubs(processingEnv, writer, interface_decl);
|
||||
}
|
||||
}
|
||||
writer.println("\t\tloaded_stubs = false;");
|
||||
writer.append("\t\tloaded_stubs = false;\n");
|
||||
}
|
||||
writer.println("\t}");
|
||||
writer.println();
|
||||
writer.append("\t}\n\n");
|
||||
GLESCapabilitiesGenerator.generateInitializerPrologue(writer);
|
||||
for ( TypeElement interface_decl : templates ) {
|
||||
if ( interface_decl.getKind().isInterface() ) {
|
||||
|
@ -153,9 +164,12 @@ public class GLESGeneratorProcessor extends AbstractProcessor {
|
|||
}
|
||||
}
|
||||
}
|
||||
writer.println("\t}");
|
||||
writer.println("}");
|
||||
writer.close();
|
||||
writer.append("\t}\n}\n");
|
||||
|
||||
saveGeneratedJavaSource(env.getMessager(), genJavaPath, "org.lwjgl.opengles." + Utils.CONTEXT_CAPS_CLASS_NAME, spawn((Callable<byte[]>) () -> {
|
||||
writer.flush();
|
||||
return writer1.toByteArray();
|
||||
}), startTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ import javax.lang.model.element.AnnotationMirror;
|
|||
import javax.lang.model.element.ExecutableElement;
|
||||
import javax.lang.model.type.TypeKind;
|
||||
|
||||
public class GLESTypeMap implements TypeMap {
|
||||
public final class GLESTypeMap implements TypeMap {
|
||||
|
||||
private static final Map<Class<? extends Annotation>, TypeKind> native_types_to_primitive;
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@ import javax.lang.model.util.ElementFilter;
|
|||
|
||||
import static org.lwjgl.util.generator.GeneratorVisitor.saveGeneratedJavaSource;
|
||||
import static org.lwjgl.util.generator.Utils.getRequiredOption;
|
||||
import static org.lwjgl.util.generator.Utils.await;
|
||||
import static org.lwjgl.util.generator.Utils.spawn;
|
||||
|
||||
/**
|
||||
|
@ -60,7 +59,7 @@ import static org.lwjgl.util.generator.Utils.spawn;
|
|||
@SupportedAnnotationTypes({ "*" })
|
||||
@SupportedSourceVersion(SourceVersion.RELEASE_10)
|
||||
@SupportedOptions({ "genJavaPath", "generatechecks", "contextspecific" })
|
||||
public class GLGeneratorProcessor extends AbstractProcessor {
|
||||
public final class GLGeneratorProcessor extends AbstractProcessor {
|
||||
|
||||
private static boolean first_round = true;
|
||||
|
||||
|
@ -92,15 +91,12 @@ public class GLGeneratorProcessor extends AbstractProcessor {
|
|||
ByteArrayOutputStream writer1 = new ByteArrayOutputStream();
|
||||
PrintWriter writer = new PrintWriter(writer1);
|
||||
|
||||
writer.println("/* MACHINE GENERATED FILE, DO NOT EDIT */");
|
||||
writer.println();
|
||||
writer.println("package org.lwjgl.opengl;");
|
||||
writer.println();
|
||||
writer.println("import org.lwjgl.LWJGLException;");
|
||||
writer.println("import org.lwjgl.LWJGLUtil;");
|
||||
writer.println("import java.util.Set;");
|
||||
writer.println("import java.util.HashSet;");
|
||||
writer.println();
|
||||
writer.append("/* MACHINE GENERATED FILE, DO NOT EDIT */\n\n"
|
||||
+ "package org.lwjgl.opengl;\n\n"
|
||||
+ "import org.lwjgl.LWJGLException;\n"
|
||||
+ "import org.lwjgl.LWJGLUtil;\n"
|
||||
+ "import java.util.Set;\n"
|
||||
+ "import java.util.HashSet;\n\n");
|
||||
GLCapabilitiesGenerator.generateClassPrologue(writer, context_specific, generate_error_checks);
|
||||
for ( TypeElement interface_decl : templates ) {
|
||||
if ( interface_decl.getKind().isInterface() ) {
|
||||
|
@ -109,26 +105,26 @@ public class GLGeneratorProcessor extends AbstractProcessor {
|
|||
}
|
||||
}
|
||||
}
|
||||
writer.println();
|
||||
writer.append('\n');
|
||||
for ( TypeElement interface_decl : templates ) {
|
||||
if ( interface_decl.getKind().isInterface() ) {
|
||||
GLCapabilitiesGenerator.generateSymbolAddresses(processingEnv, writer, interface_decl);
|
||||
}
|
||||
}
|
||||
writer.println();
|
||||
writer.append('\n');
|
||||
if ( context_specific ) {
|
||||
for ( TypeElement interface_decl : templates ) {
|
||||
if ( interface_decl.getKind().isInterface() ) {
|
||||
GLCapabilitiesGenerator.generateAddressesInitializers(processingEnv, writer, interface_decl);
|
||||
}
|
||||
}
|
||||
writer.println();
|
||||
writer.append('\n');
|
||||
}
|
||||
|
||||
writer.println("\tprivate static void remove(Set supported_extensions, String extension) {");
|
||||
writer.println("\t\tLWJGLUtil.logger().log(() -> extension + \" was reported as available but an entry point is missing\");");
|
||||
writer.println("\t\tsupported_extensions.remove(extension);");
|
||||
writer.println("\t}\n");
|
||||
writer.append("\tprivate static void remove(Set supported_extensions, String extension) {\n"
|
||||
+ "\t\tLWJGLUtil.logger().log(() -> extension + \" was reported as available but an entry point is missing\");\n"
|
||||
+ "\t\tsupported_extensions.remove(extension);\n"
|
||||
+ "\t}\n\n");
|
||||
|
||||
GLCapabilitiesGenerator.generateInitStubsPrologue(writer, context_specific);
|
||||
for ( TypeElement interface_decl : templates ) {
|
||||
|
@ -146,20 +142,18 @@ public class GLGeneratorProcessor extends AbstractProcessor {
|
|||
}
|
||||
}
|
||||
GLCapabilitiesGenerator.generateInitStubsEpilogue(writer, context_specific);
|
||||
writer.println();
|
||||
writer.println("\tstatic void unloadAllStubs() {");
|
||||
writer.append("\n\tstatic void unloadAllStubs() {\n");
|
||||
if ( !context_specific ) {
|
||||
writer.println("\t\tif (!loaded_stubs)");
|
||||
writer.println("\t\t\treturn;");
|
||||
writer.append("\t\tif (!loaded_stubs)\n"
|
||||
+ "\t\t\treturn;\n");
|
||||
for ( TypeElement interface_decl : templates ) {
|
||||
if ( interface_decl.getKind().isInterface() ) {
|
||||
GLCapabilitiesGenerator.generateUnloadStubs(processingEnv, writer, interface_decl);
|
||||
}
|
||||
}
|
||||
writer.println("\t\tloaded_stubs = false;");
|
||||
writer.append("\t\tloaded_stubs = false;\n");
|
||||
}
|
||||
writer.println("\t}");
|
||||
writer.println();
|
||||
writer.append("\t}\n\n");
|
||||
GLCapabilitiesGenerator.generateInitializerPrologue(writer);
|
||||
for ( TypeElement interface_decl : templates ) {
|
||||
if ( interface_decl.getKind().isInterface() ) {
|
||||
|
@ -168,11 +162,13 @@ public class GLGeneratorProcessor extends AbstractProcessor {
|
|||
}
|
||||
}
|
||||
}
|
||||
writer.println("\t\ttracker.init();");
|
||||
writer.println("\t}");
|
||||
writer.println("}");
|
||||
writer.append("\t\ttracker.init();\n"
|
||||
+ "\t}\n"
|
||||
+ "}\n");
|
||||
|
||||
writer.flush();
|
||||
saveGeneratedJavaSource(env.getMessager(), genJavaPath, "org.lwjgl.opengl." + Utils.CONTEXT_CAPS_CLASS_NAME, spawn((Callable<byte[]>) () -> writer1.toByteArray()), startTime);
|
||||
saveGeneratedJavaSource(env.getMessager(), genJavaPath, "org.lwjgl.opengl." + Utils.CONTEXT_CAPS_CLASS_NAME, spawn((Callable<byte[]>) () -> {
|
||||
writer.flush();
|
||||
return writer1.toByteArray();
|
||||
}), startTime);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ import static org.lwjgl.util.generator.Utils.spawn;
|
|||
@SupportedAnnotationTypes({ "*" })
|
||||
@SupportedSourceVersion(SourceVersion.RELEASE_10)
|
||||
@SupportedOptions({ "genJavaPath", "generatechecks", "contextspecific" })
|
||||
public class GLReferencesGeneratorProcessor extends AbstractProcessor {
|
||||
public final class GLReferencesGeneratorProcessor extends AbstractProcessor {
|
||||
|
||||
private static final String REFERENCES_CLASS_NAME = "References";
|
||||
private static final String REFERENCES_PARAMETER_NAME = "references";
|
||||
|
@ -108,7 +108,7 @@ public class GLReferencesGeneratorProcessor extends AbstractProcessor {
|
|||
if ( cached_reference_annotation != null && cached_reference_annotation.name().length() == 0 ) {
|
||||
Class nio_type = Utils.getNIOBufferType(param.asType());
|
||||
String reference_name = Utils.getReferenceName(interface_decl, method, param);
|
||||
writer.append("\t\t\tthis.").append(reference_name).append(" = ").append(REFERENCES_PARAMETER_NAME + ".").append(reference_name).append(";\n");
|
||||
writer.append("\t\t\tthis.").append(reference_name).append(" = " + REFERENCES_PARAMETER_NAME + ".").append(reference_name).append(";\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -142,8 +142,7 @@ public class GLReferencesGeneratorProcessor extends AbstractProcessor {
|
|||
throw new RuntimeException(param + " in method " + method + " in " + interface_decl + " is annotated with "
|
||||
+ cached_reference_annotation.annotationType().getSimpleName() + " but the parameter is not a NIO buffer");
|
||||
}
|
||||
writer.append("\t" + nio_type.getName() + " " + Utils.getReferenceName(interface_decl, method, param));
|
||||
writer.append(";\n");
|
||||
writer.append('\t').append(nio_type.getName()).append(' ').append(Utils.getReferenceName(interface_decl, method, param)).append(";\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,48 +162,50 @@ public class GLReferencesGeneratorProcessor extends AbstractProcessor {
|
|||
ByteArrayOutputStream writer1 = new ByteArrayOutputStream();
|
||||
// interesting note: autoFlush does absolutely nothing
|
||||
PrintWriter writer = new PrintWriter(writer1);
|
||||
writer.append("/* MACHINE GENERATED FILE, DO NOT EDIT */\n\n");
|
||||
writer.append("package org.lwjgl.opengl;\n\n");
|
||||
writer.append("class " + REFERENCES_CLASS_NAME + " extends BaseReferences {\n");
|
||||
writer.append("\t" + REFERENCES_CLASS_NAME + "(ContextCapabilities caps) {\n");
|
||||
writer.append("\t\tsuper(caps);\n");
|
||||
writer.append("\t}\n\n");
|
||||
writer.append("/* MACHINE GENERATED FILE, DO NOT EDIT */\n\n"
|
||||
+ "package org.lwjgl.opengl;\n\n"
|
||||
+ "class " + REFERENCES_CLASS_NAME + " extends BaseReferences {\n"
|
||||
+ "\t" + REFERENCES_CLASS_NAME + "(ContextCapabilities caps) {\n"
|
||||
+ "\t\tsuper(caps);\n"
|
||||
+ "\t}\n\n");
|
||||
writer.flush();
|
||||
templates.parallelStream().filter(tmpl -> tmpl.getKind().isInterface()).map(interface_decl -> {
|
||||
templates.parallelStream().parallel().filter(tmpl -> tmpl.getKind().isInterface()).map(interface_decl -> {
|
||||
ByteArrayOutputStream writer2 = new ByteArrayOutputStream();
|
||||
PrintWriter writer3 = new PrintWriter(writer2);
|
||||
generateReferencesFromMethods(env, writer3, interface_decl);
|
||||
writer3.flush();
|
||||
return writer2.toByteArray();
|
||||
}).sequential().forEach(writer1::writeBytes);
|
||||
writer.append("\tvoid copy(" + REFERENCES_CLASS_NAME + " " + REFERENCES_PARAMETER_NAME + ", int mask) {\n");
|
||||
writer.append("\t\tsuper.copy(" + REFERENCES_PARAMETER_NAME + ", mask);\n");
|
||||
writer.append("\t\tif ( (mask & GL11.GL_CLIENT_VERTEX_ARRAY_BIT) != 0 ) {\n");
|
||||
writer.append("\tvoid copy(" + REFERENCES_CLASS_NAME + " " + REFERENCES_PARAMETER_NAME + ", int mask) {\n"
|
||||
+ "\t\tsuper.copy(" + REFERENCES_PARAMETER_NAME + ", mask);\n"
|
||||
+ "\t\tif ( (mask & GL11.GL_CLIENT_VERTEX_ARRAY_BIT) != 0 ) {\n");
|
||||
writer.flush();
|
||||
templates.parallelStream().filter(tmpl -> tmpl.getKind().isInterface()).map(interface_decl -> {
|
||||
templates.parallelStream().parallel().filter(tmpl -> tmpl.getKind().isInterface()).map(interface_decl -> {
|
||||
ByteArrayOutputStream writer2 = new ByteArrayOutputStream();
|
||||
PrintWriter writer3 = new PrintWriter(writer2);
|
||||
generateCopiesFromMethods(processingEnv, writer3, interface_decl);
|
||||
writer3.flush();
|
||||
return writer2.toByteArray();
|
||||
}).sequential().forEach(writer1::writeBytes);
|
||||
writer.append("\t\t}\n");
|
||||
writer.append("\t}\n");
|
||||
writer.append("\tvoid clear() {\n");
|
||||
writer.append("\t\tsuper.clear();\n");
|
||||
writer.append("\t\t}\n"
|
||||
+ "\t}\n"
|
||||
+ "\tvoid clear() {\n"
|
||||
+ "\t\tsuper.clear();\n");
|
||||
writer.flush();
|
||||
templates.parallelStream().filter(tmpl -> tmpl.getKind().isInterface()).map(interface_decl -> {
|
||||
templates.parallelStream().parallel().filter(tmpl -> tmpl.getKind().isInterface()).map(interface_decl -> {
|
||||
ByteArrayOutputStream writer2 = new ByteArrayOutputStream();
|
||||
PrintWriter writer3 = new PrintWriter(writer2);
|
||||
generateClearsFromMethods(processingEnv, writer3, interface_decl);
|
||||
writer3.flush();
|
||||
return writer2.toByteArray();
|
||||
}).sequential().forEach(writer1::writeBytes);
|
||||
writer.append("\t}\n");
|
||||
writer.append("}\n");
|
||||
writer.append("\t}\n"
|
||||
+ "}\n");
|
||||
|
||||
writer.flush();
|
||||
saveGeneratedJavaSource(env.getMessager(), genJavaPath, "org.lwjgl.opengl." + REFERENCES_CLASS_NAME, spawn((Callable<byte[]>) () -> writer1.toByteArray()), startTime);
|
||||
saveGeneratedJavaSource(env.getMessager(), genJavaPath, "org.lwjgl.opengl." + REFERENCES_CLASS_NAME, spawn((Callable<byte[]>) () -> {
|
||||
writer.flush();
|
||||
return writer1.toByteArray();
|
||||
}), startTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ import javax.lang.model.element.AnnotationMirror;
|
|||
import javax.lang.model.element.ExecutableElement;
|
||||
import javax.lang.model.type.TypeKind;
|
||||
|
||||
public class GLTypeMap implements TypeMap {
|
||||
public final class GLTypeMap implements TypeMap {
|
||||
|
||||
private static final Map<Class, TypeKind> native_types_to_primitive;
|
||||
|
||||
|
|
|
@ -255,8 +255,10 @@ public class MappedObjectTransformer {
|
|||
assert !pad.after() || ((byteOffset + byteLengthPadded) % CacheUtil.getCacheLineSize() == 0);
|
||||
}
|
||||
|
||||
if ( PRINT_ACTIVITY )
|
||||
LWJGLUtil.log(MappedObjectTransformer.class.getSimpleName() + ": " + className + "." + field.getName() + " [type=" + field.getType().getSimpleName() + ", offset=" + byteOffset + "]");
|
||||
if (PRINT_ACTIVITY) {
|
||||
long byteOffset1 = byteOffset;
|
||||
LWJGLUtil.logger().log(() -> MappedObjectTransformer.class.getSimpleName() + ": " + className + '.' + field.getName() + " [type=" + field.getType().getSimpleName() + ", offset=" + byteOffset1 + ']');
|
||||
}
|
||||
|
||||
return new FieldInfo(byteOffset, byteLength, byteLengthPadded, Type.getType(field.getType()), Modifier.isVolatile(field.getModifiers()), pointer != null);
|
||||
}
|
||||
|
@ -316,8 +318,9 @@ public class MappedObjectTransformer {
|
|||
return bytecode;
|
||||
|
||||
bytecode = cw.toByteArray();
|
||||
if ( PRINT_BYTECODE )
|
||||
if (PRINT_BYTECODE) {
|
||||
printBytecode(bytecode);
|
||||
}
|
||||
|
||||
return bytecode;
|
||||
}
|
||||
|
@ -509,8 +512,9 @@ public class MappedObjectTransformer {
|
|||
// remove redirected fields
|
||||
final MappedSubtypeInfo mappedSubtype = className_to_subtype.get(className);
|
||||
if ( mappedSubtype != null && mappedSubtype.fields.containsKey(name) ) {
|
||||
if ( PRINT_ACTIVITY )
|
||||
LWJGLUtil.log(MappedObjectTransformer.class.getSimpleName() + ": discarding field: " + className + "." + name + ":" + desc);
|
||||
if (PRINT_ACTIVITY) {
|
||||
LWJGLUtil.logger().log(() -> MappedObjectTransformer.class.getSimpleName() + ": discarding field: " + className + '.' + name + ':' + desc);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1311,9 +1315,8 @@ public class MappedObjectTransformer {
|
|||
StringWriter sw = new StringWriter();
|
||||
ClassVisitor tracer = new TraceClassVisitor(new ClassWriter(0), new PrintWriter(sw));
|
||||
new ClassReader(bytecode).accept(tracer, 0);
|
||||
String dump = sw.toString();
|
||||
|
||||
LWJGLUtil.log(dump);
|
||||
LWJGLUtil.logger().log(sw::toString);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue