Added JNIEXPORT to AL alternate methods.
Now forcing full regen when any class in the Generator changes.
This commit is contained in:
parent
3715e4b39d
commit
b17aa7d21b
|
@ -35,6 +35,8 @@ package org.lwjgl.util.generator;
|
||||||
import com.sun.mirror.apt.*;
|
import com.sun.mirror.apt.*;
|
||||||
import com.sun.mirror.declaration.*;
|
import com.sun.mirror.declaration.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileFilter;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -108,10 +110,11 @@ public class GeneratorProcessorFactory implements AnnotationProcessorFactory, Ro
|
||||||
|
|
||||||
TypeDeclaration lastFile = null;
|
TypeDeclaration lastFile = null;
|
||||||
try {
|
try {
|
||||||
|
long generatorLM = getGeneratorLastModified();
|
||||||
TypeMap type_map = (TypeMap)(Class.forName(typemap_classname).newInstance());
|
TypeMap type_map = (TypeMap)(Class.forName(typemap_classname).newInstance());
|
||||||
for (TypeDeclaration typedecl : env.getSpecifiedTypeDeclarations()) {
|
for (TypeDeclaration typedecl : env.getSpecifiedTypeDeclarations()) {
|
||||||
lastFile = typedecl;
|
lastFile = typedecl;
|
||||||
typedecl.accept(getDeclarationScanner(new GeneratorVisitor(env, type_map, generate_error_checks, context_specific), NO_OP));
|
typedecl.accept(getDeclarationScanner(new GeneratorVisitor(env, type_map, generate_error_checks, context_specific, generatorLM), NO_OP));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if ( lastFile == null )
|
if ( lastFile == null )
|
||||||
|
@ -120,5 +123,35 @@ public class GeneratorProcessorFactory implements AnnotationProcessorFactory, Ro
|
||||||
throw new RuntimeException("\n-- Failed to process template: " + lastFile.getQualifiedName() + " --", e);
|
throw new RuntimeException("\n-- Failed to process template: " + lastFile.getQualifiedName() + " --", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the time of the latest change on the Generator classes.
|
||||||
|
*
|
||||||
|
* @return time of the latest change
|
||||||
|
*/
|
||||||
|
private static long getGeneratorLastModified() {
|
||||||
|
final File pck = new File(System.getProperty("user.dir") + "/bin/org/lwjgl/util/generator");
|
||||||
|
if ( !pck.exists() || !pck.isDirectory() )
|
||||||
|
return Long.MAX_VALUE;
|
||||||
|
|
||||||
|
final File[] classes = pck.listFiles(new FileFilter() {
|
||||||
|
public boolean accept(final File pathname) {
|
||||||
|
return pathname.isFile() && pathname.getName().endsWith(".class");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if ( classes == null || classes.length == 0 )
|
||||||
|
return Long.MAX_VALUE;
|
||||||
|
|
||||||
|
long lastModified = 0;
|
||||||
|
|
||||||
|
for ( File clazz : classes ) {
|
||||||
|
long lm = clazz.lastModified();
|
||||||
|
if ( lastModified < lm )
|
||||||
|
lastModified = lm;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lastModified;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -58,12 +58,14 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor {
|
||||||
private final TypeMap type_map;
|
private final TypeMap type_map;
|
||||||
private final boolean generate_error_checks;
|
private final boolean generate_error_checks;
|
||||||
private final boolean context_specific;
|
private final boolean context_specific;
|
||||||
|
private final long generatorLM;
|
||||||
|
|
||||||
public GeneratorVisitor(AnnotationProcessorEnvironment env, TypeMap type_map, boolean generate_error_checks, boolean context_specific) {
|
public GeneratorVisitor(AnnotationProcessorEnvironment env, TypeMap type_map, boolean generate_error_checks, boolean context_specific, long generatorLM) {
|
||||||
this.env = env;
|
this.env = env;
|
||||||
this.type_map = type_map;
|
this.type_map = type_map;
|
||||||
this.generate_error_checks = generate_error_checks;
|
this.generate_error_checks = generate_error_checks;
|
||||||
this.context_specific = context_specific;
|
this.context_specific = context_specific;
|
||||||
|
this.generatorLM = generatorLM;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateMethods(InterfaceDeclaration d) {
|
private void validateMethods(InterfaceDeclaration d) {
|
||||||
|
@ -254,7 +256,7 @@ public class GeneratorVisitor extends SimpleDeclarationVisitor {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Skip this class if the output exists and the input has not been modified.
|
// Skip this class if the output exists and the input has not been modified.
|
||||||
if ( output.exists() && input.lastModified() < output.lastModified() )
|
if ( output.exists() && Math.max(input.lastModified(), generatorLM) < output.lastModified() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (d.getMethods().size() > 0 || d.getFields().size() > 0) {
|
if (d.getMethods().size() > 0 || d.getFields().size() > 0) {
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class NativeMethodStubsGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void generateMethodStub(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, String interface_name, MethodDeclaration method, Mode mode, boolean generate_error_checks, boolean context_specific) {
|
private static void generateMethodStub(AnnotationProcessorEnvironment env, TypeMap type_map, PrintWriter writer, String interface_name, MethodDeclaration method, Mode mode, boolean generate_error_checks, boolean context_specific) {
|
||||||
if ( !context_specific )
|
if ( !context_specific && method.getAnnotation(Alternate.class) == null )
|
||||||
writer.print("static ");
|
writer.print("static ");
|
||||||
else
|
else
|
||||||
writer.print("JNIEXPORT ");
|
writer.print("JNIEXPORT ");
|
||||||
|
|
Loading…
Reference in New Issue