summaryrefslogtreecommitdiffstats
path: root/src/java/com/sun/gluegen/procaddress/ProcAddressJavaMethodBindingEmitter.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-03-31 23:32:39 +0200
committerSven Gothel <[email protected]>2010-03-31 23:32:39 +0200
commite37c383c4a09432fff009e81d572c8a92b42eef6 (patch)
tree9ebb8bacc940a3460be1639ad771f8e5d98ad012 /src/java/com/sun/gluegen/procaddress/ProcAddressJavaMethodBindingEmitter.java
parent73829c38665c57052bf703ae58a2bd1dc7dc4625 (diff)
parent22262166e07de99ae0d4557e4f87e3bd1c5cd6dd (diff)
Merged with latest of mbien
Diffstat (limited to 'src/java/com/sun/gluegen/procaddress/ProcAddressJavaMethodBindingEmitter.java')
-rwxr-xr-xsrc/java/com/sun/gluegen/procaddress/ProcAddressJavaMethodBindingEmitter.java185
1 files changed, 91 insertions, 94 deletions
diff --git a/src/java/com/sun/gluegen/procaddress/ProcAddressJavaMethodBindingEmitter.java b/src/java/com/sun/gluegen/procaddress/ProcAddressJavaMethodBindingEmitter.java
index 2dda752..5a30ee5 100755
--- a/src/java/com/sun/gluegen/procaddress/ProcAddressJavaMethodBindingEmitter.java
+++ b/src/java/com/sun/gluegen/procaddress/ProcAddressJavaMethodBindingEmitter.java
@@ -36,118 +36,115 @@
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-
package com.sun.gluegen.procaddress;
import java.io.*;
-import java.util.*;
import com.sun.gluegen.*;
-import com.sun.gluegen.cgram.types.*;
/** A specialization of JavaMethodBindingEmitter with knowledge of how
- to call through a function pointer. */
-
+to call through a function pointer. */
public class ProcAddressJavaMethodBindingEmitter extends JavaMethodBindingEmitter {
- private final CommentEmitter commentEmitterForWrappedMethod =
- new WrappedMethodCommentEmitter();
-
- protected boolean callThroughProcAddress;
- protected String getProcAddressTableExpr;
- protected boolean changeNameAndArguments;
- protected ProcAddressEmitter emitter;
-
- public ProcAddressJavaMethodBindingEmitter(JavaMethodBindingEmitter methodToWrap,
- boolean callThroughProcAddress,
- String getProcAddressTableExpr,
- boolean changeNameAndArguments,
- ProcAddressEmitter emitter) {
- super(methodToWrap);
- this.callThroughProcAddress = callThroughProcAddress;
- this.getProcAddressTableExpr = getProcAddressTableExpr;
- this.changeNameAndArguments = changeNameAndArguments;
- this.emitter = emitter;
- if (callThroughProcAddress) {
- setCommentEmitter(new WrappedMethodCommentEmitter());
+
+ protected boolean callThroughProcAddress;
+ protected boolean changeNameAndArguments;
+
+ protected String getProcAddressTableExpr;
+ protected ProcAddressEmitter emitter;
+
+ public ProcAddressJavaMethodBindingEmitter(JavaMethodBindingEmitter methodToWrap, boolean callThroughProcAddress,
+ String getProcAddressTableExpr, boolean changeNameAndArguments, ProcAddressEmitter emitter) {
+
+ super(methodToWrap);
+
+ this.callThroughProcAddress = callThroughProcAddress;
+ this.getProcAddressTableExpr = getProcAddressTableExpr;
+ this.changeNameAndArguments = changeNameAndArguments;
+ this.emitter = emitter;
+
+ if (callThroughProcAddress) {
+ setCommentEmitter(new WrappedMethodCommentEmitter());
+ }
+
+ if (methodToWrap.getBinding().hasContainingType()) {
+ throw new IllegalArgumentException(
+ "Cannot create proc. address wrapper; method has containing type: \""
+ + methodToWrap.getBinding() + "\"");
+ }
}
- if (methodToWrap.getBinding().hasContainingType())
- {
- throw new IllegalArgumentException(
- "Cannot create proc. address wrapper; method has containing type: \"" +
- methodToWrap.getBinding() + "\"");
+ public ProcAddressJavaMethodBindingEmitter(ProcAddressJavaMethodBindingEmitter methodToWrap) {
+ this(methodToWrap, methodToWrap.callThroughProcAddress, methodToWrap.getProcAddressTableExpr,
+ methodToWrap.changeNameAndArguments, methodToWrap.emitter);
}
- }
-
- public ProcAddressJavaMethodBindingEmitter(ProcAddressJavaMethodBindingEmitter methodToWrap) {
- this(methodToWrap,
- methodToWrap.callThroughProcAddress,
- methodToWrap.getProcAddressTableExpr,
- methodToWrap.changeNameAndArguments,
- methodToWrap.emitter);
- }
-
- public String getName() {
- String res = super.getName();
- if (changeNameAndArguments) {
- return ProcAddressEmitter.WRAP_PREFIX + res;
+
+ @Override
+ public String getName() {
+ String res = super.getName();
+ if (changeNameAndArguments) {
+ return ProcAddressEmitter.WRAP_PREFIX + res;
+ }
+ return res;
}
- return res;
- }
-
- protected int emitArguments(PrintWriter writer) {
- int numEmitted = super.emitArguments(writer);
- if (callThroughProcAddress) {
- if (changeNameAndArguments) {
- if (numEmitted > 0) {
- writer.print(", ");
+
+ @Override
+ protected int emitArguments(PrintWriter writer) {
+ int numEmitted = super.emitArguments(writer);
+ if (callThroughProcAddress) {
+ if (changeNameAndArguments) {
+ if (numEmitted > 0) {
+ writer.print(", ");
+ }
+
+ writer.print("long procAddress");
+ ++numEmitted;
+ }
}
- writer.print("long procAddress");
- ++numEmitted;
- }
+ return numEmitted;
}
-
- return numEmitted;
- }
-
- protected String getImplMethodName() {
- String name = super.getImplMethodName();
- if (callThroughProcAddress) {
- return ProcAddressEmitter.WRAP_PREFIX + name;
+
+ @Override
+ protected String getImplMethodName() {
+ String name = super.getImplMethodName();
+ if (callThroughProcAddress) {
+ return ProcAddressEmitter.WRAP_PREFIX + name;
+ }
+ return name;
}
- return name;
- }
-
- protected void emitPreCallSetup(MethodBinding binding, PrintWriter writer) {
- super.emitPreCallSetup(binding, writer);
-
- if (callThroughProcAddress) {
- String procAddressVariable =
- ProcAddressEmitter.PROCADDRESS_VAR_PREFIX + binding.getName();
- writer.println(" final long __addr_ = " + getProcAddressTableExpr + "." + procAddressVariable + ";");
- writer.println(" if (__addr_ == 0) {");
- writer.println(" throw new " + emitter.unsupportedExceptionType() + "(\"Method \\\"" + binding.getName() + "\\\" not available\");");
- writer.println(" }");
+
+ @Override
+ protected void emitPreCallSetup(MethodBinding binding, PrintWriter writer) {
+ super.emitPreCallSetup(binding, writer);
+
+ if (callThroughProcAddress) {
+ String procAddressVariable = ProcAddressEmitter.PROCADDRESS_VAR_PREFIX + binding.getName();
+ writer.println(" final long __addr_ = " + getProcAddressTableExpr + "." + procAddressVariable + ";");
+ writer.println(" if (__addr_ == 0) {");
+ writer.println(" throw new " + emitter.unsupportedExceptionType() + "(\"Method \\\"" + binding.getName() + "\\\" not available\");");
+ writer.println(" }");
+ }
}
- }
-
- protected int emitCallArguments(MethodBinding binding, PrintWriter writer) {
- int numEmitted = super.emitCallArguments(binding, writer);
- if (callThroughProcAddress) {
- if (numEmitted > 0) {
- writer.print(", ");
- }
- writer.print("__addr_");
- ++numEmitted;
+
+ @Override
+ protected int emitCallArguments(MethodBinding binding, PrintWriter writer) {
+ int numEmitted = super.emitCallArguments(binding, writer);
+ if (callThroughProcAddress) {
+ if (numEmitted > 0) {
+ writer.print(", ");
+ }
+ writer.print("__addr_");
+ ++numEmitted;
+ }
+
+ return numEmitted;
}
- return numEmitted;
- }
+ /** This class emits the comment for the wrapper method */
+ public class WrappedMethodCommentEmitter extends JavaMethodBindingEmitter.DefaultCommentEmitter {
- /** This class emits the comment for the wrapper method */
- public class WrappedMethodCommentEmitter extends JavaMethodBindingEmitter.DefaultCommentEmitter {
- protected void emitBeginning(FunctionEmitter methodEmitter, PrintWriter writer) {
- writer.print("Entry point (through function pointer) to C language function: <br> ");
+ @Override
+ protected void emitBeginning(FunctionEmitter methodEmitter, PrintWriter writer) {
+ writer.print("Entry point (through function pointer) to C language function: <br> ");
+ }
}
- }
}