summaryrefslogtreecommitdiffstats
path: root/src/java/com/sun/gluegen/CMethodBindingEmitter.java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2009-08-08 21:46:55 +0200
committerMichael Bien <[email protected]>2009-08-08 21:46:55 +0200
commit889b9574958b04988ab3acbabab109745fbc379a (patch)
tree5f3485268de0f59f113c9d524561fc49b50ad75f /src/java/com/sun/gluegen/CMethodBindingEmitter.java
parenta07c223b8dbde8f81886b7b2bf602e26ab9531b3 (diff)
parent5f8e46324f245c99080d2c340cd4fb2ec9c4fa8d (diff)
Merge branch 'master' of ssh://[email protected]/gluegen~gluegen-git
Diffstat (limited to 'src/java/com/sun/gluegen/CMethodBindingEmitter.java')
-rw-r--r--src/java/com/sun/gluegen/CMethodBindingEmitter.java30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/java/com/sun/gluegen/CMethodBindingEmitter.java b/src/java/com/sun/gluegen/CMethodBindingEmitter.java
index 2085477..af632c3 100644
--- a/src/java/com/sun/gluegen/CMethodBindingEmitter.java
+++ b/src/java/com/sun/gluegen/CMethodBindingEmitter.java
@@ -155,7 +155,7 @@ public class CMethodBindingEmitter extends FunctionEmitter
public final MethodBinding getBinding() { return binding; }
public String getName() {
- return binding.getRenamedMethodName();
+ return binding.getName();
}
/**
@@ -691,11 +691,12 @@ public class CMethodBindingEmitter extends FunctionEmitter
"Could not copy data for type \"" + cArgType +
"\"; currently only pointer types supported.");
}
- PointerType cArgElementType = cArgPtrType.getTargetType().asPointer();
+ PointerType cArgElementType = cArgPtrType.getTargetType().asPointer();
emitMalloc(
writer,
convName+"_copy",
cArgElementType.getName(),
+ isConstPtrPtr(cArgPtrType),
arrayLenName,
"Could not allocate buffer for copying data in argument \\\""+binding.getArgumentName(i)+"\\\"");
@@ -757,6 +758,7 @@ public class CMethodBindingEmitter extends FunctionEmitter
writer,
convName+"_copy[_copyIndex]",
cArgElementType.getTargetType().getName(), // assumes cArgPtrType is ptr-to-ptr-to-primitive !!
+ isConstPtrPtr(cArgPtrType),
"(*env)->GetArrayLength(env, _tmpObj)",
"Could not allocate buffer during copying of data in argument \\\""+binding.getArgumentName(i)+"\\\"");
// FIXME: copy the data (use matched Get/ReleasePrimitiveArrayCritical() calls)
@@ -982,6 +984,9 @@ public class CMethodBindingEmitter extends FunctionEmitter
} else {
writer.print("(");
Type cArgType = binding.getCSymbol().getArgumentType(i);
+ if (isConstPtrPtr(cArgType)) {
+ writer.print("const ");
+ }
writer.print(cArgType.getName());
writer.print(") ");
if (binding.getCArgumentType(i).isPointer() && binding.getJavaArgumentType(i).isPrimitive()) {
@@ -1277,12 +1282,16 @@ public class CMethodBindingEmitter extends FunctionEmitter
private void emitMalloc(PrintWriter writer,
String targetVarName,
String elementTypeString,
+ boolean elementTypeIsConst,
String numElementsExpression,
String mallocFailureErrorString)
{
writer.print(" ");
writer.print(targetVarName);
writer.print(" = (");
+ if(elementTypeIsConst) {
+ writer.print("const ");
+ }
writer.print(elementTypeString);
writer.print(" *) malloc(");
writer.print(numElementsExpression);
@@ -1467,9 +1476,22 @@ public class CMethodBindingEmitter extends FunctionEmitter
// incoming data has been properly laid out in memory to match the C
// memory model
if (javaType.isStringArray()) {
- writer.print(" const char **");
+ String cElementTypeName = "char *";
+ PointerType cPtrType = cType.asPointer();
+ if (cPtrType != null) {
+ cElementTypeName = cPtrType.getTargetType().asPointer().getName();
+ }
+ if (isConstPtrPtr(cType)) {
+ writer.print(" const "+cElementTypeName+" *");
+ } else {
+ writer.print(" "+cElementTypeName+" *");
+ }
} else {
- writer.print(" " + ptrTypeString);
+ if (isConstPtrPtr(cType)) {
+ writer.print(" const " + ptrTypeString);
+ } else {
+ writer.print(" " + ptrTypeString);
+ }
}
writer.print(" ");
writer.print(cVariableName);