aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/gluegen/FunctionEmitter.java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2005-11-09 00:32:37 +0000
committerKenneth Russel <[email protected]>2005-11-09 00:32:37 +0000
commitcf7b8b87f78687b8e4a867d3b18bd7f072a955ee (patch)
tree739fe8eec21acfe26cf7a684232f1219dbdd43b8 /src/classes/com/sun/gluegen/FunctionEmitter.java
parente42abe5e45c693abc4c06ac5c1928ee2c3fe8d27 (diff)
Refactored computations of sizes of data types and offsets of fields
in data structures in GlueGen to be performed lazily via SizeThunks. The concrete size of primitive data types is computed only by passing a MachineDescription into one of these thunks. Changed generated glue code for struct accessors to delegate their instantiation and field access to specialized 32- or 64-bit versions. This should allow one jar file to support both 32-bit and 64-bit CPUs; the native code is of course still specialized for the processor and data model. Changed default build to generate both 32-bit and 64-bit accessors for all generated data structures. Tested on Windows; more testing, including build testing, is needed on other platforms. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@426 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun/gluegen/FunctionEmitter.java')
-rw-r--r--src/classes/com/sun/gluegen/FunctionEmitter.java26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/classes/com/sun/gluegen/FunctionEmitter.java b/src/classes/com/sun/gluegen/FunctionEmitter.java
index baf08b93a..2f52a9f36 100644
--- a/src/classes/com/sun/gluegen/FunctionEmitter.java
+++ b/src/classes/com/sun/gluegen/FunctionEmitter.java
@@ -41,6 +41,7 @@ package com.sun.gluegen;
import java.util.*;
import java.io.*;
+import com.sun.gluegen.cgram.types.MachineDescription;
public abstract class FunctionEmitter
{
@@ -49,14 +50,16 @@ public abstract class FunctionEmitter
private HashSet modifiers = new HashSet(4);
private CommentEmitter commentEmitter = null;
private PrintWriter defaultOutput;
+ private MachineDescription defaultMachDesc;
/**
* Constructs the FunctionEmitter with a CommentEmitter that emits nothing.
*/
- public FunctionEmitter(PrintWriter defaultOutput)
+ public FunctionEmitter(PrintWriter defaultOutput, MachineDescription defaultMachDesc)
{
assert(defaultOutput != null);
this.defaultOutput = defaultOutput;
+ this.defaultMachDesc = defaultMachDesc;
}
/**
@@ -66,9 +69,12 @@ public abstract class FunctionEmitter
modifiers = (HashSet) arg.modifiers.clone();
commentEmitter = arg.commentEmitter;
defaultOutput = arg.defaultOutput;
+ defaultMachDesc = arg.defaultMachDesc;
}
public PrintWriter getDefaultOutput() { return defaultOutput; }
+
+ public MachineDescription getDefaultMachineDescription() { return defaultMachDesc; }
public void addModifiers(Iterator/*<EmissionModifier>*/ mi)
{
@@ -93,29 +99,35 @@ public abstract class FunctionEmitter
* Emit the function to the specified output (instead of the default
* output).
*/
- public void emit(PrintWriter output)
+ public void emit(PrintWriter output, MachineDescription machDesc)
{
emitDocComment(output);
//output.println(" // Emitter: " + getClass().getName());
emitSignature(output);
- emitBody(output);
+ emitBody(output, machDesc);
}
/**
* Emit the function to the default output (the output that was passed to
* the constructor)
*/
- public final void emit()
+ public final void emit(MachineDescription machDesc)
{
- emit(getDefaultOutput());
+ emit(getDefaultOutput(), machDesc);
}
/** Returns, as a String, whatever {@link #emit} would output. */
public String toString()
{
+ return toString(getDefaultMachineDescription());
+ }
+
+ /** Returns, as a String, whatever {@link #emit} would output. */
+ public String toString(MachineDescription machDesc)
+ {
StringWriter sw = new StringWriter(500);
PrintWriter w = new PrintWriter(sw);
- emit(w);
+ emit(w, machDesc);
return sw.toString();
}
@@ -195,7 +207,7 @@ public abstract class FunctionEmitter
protected abstract void emitName(PrintWriter writer);
/** Returns the number of arguments emitted. */
protected abstract int emitArguments(PrintWriter writer);
- protected abstract void emitBody(PrintWriter writer);
+ protected abstract void emitBody(PrintWriter writer, MachineDescription machDesc);
public static class EmissionModifier
{