java-gobject-introspection r72 - trunk/src/org/gnome/gir/compiler
- From: walters svn gnome org
- To: svn-commits-list gnome org
- Subject: java-gobject-introspection r72 - trunk/src/org/gnome/gir/compiler
- Date: Thu, 2 Oct 2008 03:40:01 +0000 (UTC)
Author: walters
Date: Thu Oct 2 03:40:01 2008
New Revision: 72
URL: http://svn.gnome.org/viewvc/java-gobject-introspection?rev=72&view=rev
Log:
Ensure we pass the correct argument for arrays
Modified:
trunk/src/org/gnome/gir/compiler/CodeFactory.java
Modified: trunk/src/org/gnome/gir/compiler/CodeFactory.java
==============================================================================
--- trunk/src/org/gnome/gir/compiler/CodeFactory.java (original)
+++ trunk/src/org/gnome/gir/compiler/CodeFactory.java Thu Oct 2 03:40:01 2008
@@ -1255,7 +1255,8 @@
boolean throwsGError;
boolean isInterfaceMethod = false;
InterfaceInfo targetInterface = null;
- Map<Integer, Integer> lengthIndices;
+ Map<Integer, Integer> lengthOfArrayIndices = new HashMap<Integer,Integer>();
+ Map<Integer, Integer> arrayToLengthIndices = new HashMap<Integer,Integer>();
public CallableCompilationContext() {
// TODO Auto-generated constructor stub
@@ -1270,7 +1271,7 @@
}
public int argOffsetToApi(int offset) {
- return offset - lengthIndices.size();
+ return offset - lengthOfArrayIndices.size();
}
public LocalVariableTable allocLocals() {
@@ -1320,7 +1321,6 @@
List<Type> types = new ArrayList<Type>();
boolean skipFirst = ctx.isMethod;
- ctx.lengthIndices = new HashMap<Integer,Integer>();
for (int i = 0; i < args.length; i++) {
ArgInfo arg = args[i];
Type t;
@@ -1339,8 +1339,10 @@
}
if (tag.equals(TypeTag.ARRAY)) {
int lenIdx = arg.getType().getArrayLength();
- if (lenIdx >= 0)
- ctx.lengthIndices.put(lenIdx, i);
+ if (lenIdx >= 0) {
+ ctx.lengthOfArrayIndices.put(lenIdx, i);
+ ctx.arrayToLengthIndices.put(i, lenIdx);
+ }
}
if (skipFirst) {
skipFirst = false;
@@ -1355,7 +1357,7 @@
/* Now go through and remove array length indices */
List<Type> filteredTypes = new ArrayList<Type>();
for (int i = 0; i < types.size(); i++) {
- Integer index = ctx.lengthIndices.get(i + (ctx.isMethod ? 1 : 0));
+ Integer index = ctx.lengthOfArrayIndices.get(i + (ctx.isMethod ? 1 : 0));
if (index == null) {
filteredTypes.add(types.get(i));
}
@@ -1540,7 +1542,8 @@
for (int i = 0; i < nInvokeArgsNoError; i++) {
mv.visitInsn(DUP);
mv.visitIntInsn(BIPUSH, i);
- Integer arraySource = ctx.lengthIndices.get(i);
+ Integer arraySource = ctx.lengthOfArrayIndices.get(i);
+ Integer lengthOfArray = ctx.arrayToLengthIndices.get(i);
if (arraySource != null) {
ArgInfo source = ctx.args[arraySource];
assert source.getType().getTag().equals(TypeTag.ARRAY);
@@ -1549,7 +1552,10 @@
writeLoadArgument(mv, var.offset, var.type);
mv.visitInsn(ARRAYLENGTH);
mv.visitMethodInsn(INVOKESTATIC, Type.getInternalName(Integer.class), "valueOf",
- Type.getMethodDescriptor(getType(Integer.class), new Type[] { Type.INT_TYPE }));
+ Type.getMethodDescriptor(getType(Integer.class), new Type[] { Type.INT_TYPE }));
+ } else if (lengthOfArray != null) {
+ LocalVariable var = locals.get(lengthOfArray);
+ writeLoadArgument(mv, var.offset, var.type);
} else if (!includeThis || i > 0) {
LocalVariable var = locals.get(i);
writeLoadArgument(mv, var.offset, var.type);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]