aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/gluegen/JavaEmitter.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-02-02 00:22:29 +0100
committerSven Gothel <[email protected]>2015-02-02 00:22:29 +0100
commit7db9df61142694965b50f2e0553d4c9e5668439b (patch)
tree411c69a61d0f693acd55a65f458a2d2b75b84db8 /src/java/com/jogamp/gluegen/JavaEmitter.java
parent234819d531cdf20842cd0b3302935b187b2012d6 (diff)
Bug 1126 - Remove static query requirement of MachineDescriptor, find matching StaticConfig at runtime; Fix PPC (Bug 1056) and MIPSLE (Bug 1014) issues.
Currently the StaticConfig is being queried via the key[OSType, CPUType ..] as pre-determined by Java properties or the ELF parser. This adds complication to maintain different platforms and the key query might not even be sufficient. The MachineDescriptor's StaticConfig only purpose shall be to speed-up native data size and offset/alignment retrieval. This is done by using the StaticConfig index within all StaticConfig[]s as a lookup-index for the precomputed struct's size and offset tables. +++ Solution: Rename: MachineDescriptor -> MachineDataInfo Rename: MachineDescriptorRuntime -> MachineDataInfoRuntime After having defined os.and.arch (OSType, CPUType and ABIType) w/ the optional help of the now self containing ELF Reader (Bug 1125), the native gluegen-rt library gets loaded enabling JNI methods. It is satisfactory to retrieve MachineDataInfo at runtime w/ JNI and find the matching/compatible StaticConfig. Only in case none is found, the program needs to abort. Otherwise the found MachineDataInfo.StaticConfig and MachineDataInfo are stored for further use (see above). This removes above complication and key to StaticConfig mapping. New platforms simply need to add a new unique entry into the StaticConfig[] table. ++ Also fixes Bug 1056 (PPC), thanks to tmancill [@] debian [.] org, and Bug 1014 (MIPSLE), thanks to Dejan Latinovic. Parts of the patch for Bug 1014 from Dejan Latinovic are included. also solved by this change set.
Diffstat (limited to 'src/java/com/jogamp/gluegen/JavaEmitter.java')
-rw-r--r--src/java/com/jogamp/gluegen/JavaEmitter.java32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java
index 48c7047..d2dc4ba 100644
--- a/src/java/com/jogamp/gluegen/JavaEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaEmitter.java
@@ -42,7 +42,7 @@ package com.jogamp.gluegen;
import com.jogamp.common.nio.Buffers;
import com.jogamp.common.os.DynamicLookupHelper;
-import com.jogamp.common.os.MachineDescription;
+import com.jogamp.common.os.MachineDataInfo;
import java.io.*;
import java.util.*;
@@ -53,7 +53,7 @@ import com.jogamp.gluegen.cgram.types.*;
import java.nio.Buffer;
import java.util.logging.Logger;
-import jogamp.common.os.MachineDescriptionRuntime;
+import jogamp.common.os.MachineDataInfoRuntime;
import static java.util.logging.Level.*;
import static com.jogamp.gluegen.JavaEmitter.MethodAccess.*;
@@ -100,8 +100,8 @@ public class JavaEmitter implements GlueEmitter {
private PrintWriter javaWriter; // Emits either interface or, in AllStatic mode, everything
private PrintWriter javaImplWriter; // Only used in non-AllStatic modes for impl class
private PrintWriter cWriter;
- private final MachineDescription machDescJava = MachineDescription.StaticConfig.LP64_UNIX.md;
- private final MachineDescription.StaticConfig[] machDescTargetConfigs = MachineDescription.StaticConfig.values();
+ private final MachineDataInfo machDescJava = MachineDataInfo.StaticConfig.LP64_UNIX.md;
+ private final MachineDataInfo.StaticConfig[] machDescTargetConfigs = MachineDataInfo.StaticConfig.values();
protected final static Logger LOG = Logger.getLogger(JavaEmitter.class.getPackage().getName());
@@ -858,7 +858,7 @@ public class JavaEmitter implements GlueEmitter {
this.requiresStaticInitialization = false; // reset
- // machDescJava global MachineDescription is the one used to determine
+ // machDescJava global MachineDataInfo is the one used to determine
// the sizes of the primitive types seen in the public API in Java.
// For example, if a C long is an element of a struct, it is the size
// of a Java int on a 32-bit machine but the size of a Java long
@@ -868,11 +868,11 @@ public class JavaEmitter implements GlueEmitter {
// implementation on a 32-bit platform must downcast this to an
// int and set only an int's worth of data in the struct.
//
- // The machDescTarget MachineDescription is the one used to determine how
+ // The machDescTarget MachineDataInfo is the one used to determine how
// much data to set in or get from the struct and exactly from
// where it comes.
//
- // Note that machDescJava MachineDescription is always 64bit unix,
+ // Note that machDescJava MachineDataInfo is always 64bit unix,
// which complies w/ Java types.
boolean needsNativeCode = false;
@@ -935,7 +935,7 @@ public class JavaEmitter implements GlueEmitter {
javaWriter.println("import " + cfg.gluegenRuntimePackage() + ".*;");
javaWriter.println("import " + DynamicLookupHelper.class.getPackage().getName() + ".*;");
javaWriter.println("import " + Buffers.class.getPackage().getName() + ".*;");
- javaWriter.println("import " + MachineDescriptionRuntime.class.getName() + ";");
+ javaWriter.println("import " + MachineDataInfoRuntime.class.getName() + ";");
javaWriter.println();
final List<String> imports = cfg.imports();
for (final String str : imports) {
@@ -963,10 +963,10 @@ public class JavaEmitter implements GlueEmitter {
javaWriter.println();
javaWriter.println(" StructAccessor accessor;");
javaWriter.println();
- final String cfgMachDescrIdxCode = cfg.returnStructMachineDescriptorIndex(containingJTypeName);
- final String machDescrIdxCode = null != cfgMachDescrIdxCode ? cfgMachDescrIdxCode : "private static final int mdIdx = MachineDescriptionRuntime.getStatic().ordinal();";
+ final String cfgMachDescrIdxCode = cfg.returnStructMachineDataInfoIndex(containingJTypeName);
+ final String machDescrIdxCode = null != cfgMachDescrIdxCode ? cfgMachDescrIdxCode : "private static final int mdIdx = MachineDataInfoRuntime.getStatic().ordinal();";
javaWriter.println(" "+machDescrIdxCode);
- javaWriter.println(" private final MachineDescription md;");
+ javaWriter.println(" private final MachineDataInfo md;");
javaWriter.println();
// generate all offset and size arrays
generateOffsetAndSizeArrays(javaWriter, " ", containingJTypeName, structCType, null, null); /* w/o offset */
@@ -1058,7 +1058,7 @@ public class JavaEmitter implements GlueEmitter {
}
if( !cfg.manuallyImplement(JavaConfiguration.canonicalStructFieldSymbol(containingJTypeName, containingJTypeName)) ) {
javaWriter.println(" " + containingJTypeName + "(java.nio.ByteBuffer buf) {");
- javaWriter.println(" md = MachineDescription.StaticConfig.values()[mdIdx].md;");
+ javaWriter.println(" md = MachineDataInfo.StaticConfig.values()[mdIdx].md;");
javaWriter.println(" accessor = new StructAccessor(buf);");
javaWriter.println(" }");
javaWriter.println();
@@ -1948,7 +1948,7 @@ public class JavaEmitter implements GlueEmitter {
}
private static final boolean DEBUG_TYPEC2JAVA = false;
- private JavaType typeToJavaType(final Type cType, final MachineDescription curMachDesc) {
+ private JavaType typeToJavaType(final Type cType, final MachineDataInfo curMachDesc) {
final JavaType jt = typeToJavaTypeImpl(cType, curMachDesc);
if( DEBUG_TYPEC2JAVA ) {
System.err.println("typeToJavaType: "+cType.getDebugString()+" -> "+jt.getDebugString());
@@ -1961,7 +1961,7 @@ public class JavaEmitter implements GlueEmitter {
(opt.getTargetType().getName() != null) &&
(opt.getTargetType().getName().equals("JNIEnv"));
}
- private JavaType typeToJavaTypeImpl(final Type cType, final MachineDescription curMachDesc) {
+ private JavaType typeToJavaTypeImpl(final Type cType, final MachineDataInfo curMachDesc) {
// Recognize JNIEnv* case up front
if( isJNIEnvPointer(cType) ) {
return JavaType.createForJNIEnv();
@@ -2194,7 +2194,7 @@ public class JavaEmitter implements GlueEmitter {
private String compatiblePrimitiveJavaTypeName(final Type fieldType,
final JavaType javaType,
- final MachineDescription curMachDesc) {
+ final MachineDataInfo curMachDesc) {
final Class<?> c = javaType.getJavaClass();
if (!isIntegerType(c)) {
// FIXME
@@ -2583,7 +2583,7 @@ public class JavaEmitter implements GlueEmitter {
private MethodBinding bindFunction(final FunctionSymbol sym,
final JavaType containingType,
final Type containingCType,
- final MachineDescription curMachDesc) {
+ final MachineDataInfo curMachDesc) {
final MethodBinding binding = new MethodBinding(sym, containingType, containingCType);