Fix ARRAYSOFCLASSES bug reported by Kevin Mills where the changes made to an array element in the C layer are not reflected back into Java
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10220 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
87394a2daf
commit
cc59a22121
2 changed files with 14 additions and 0 deletions
|
|
@ -55,6 +55,12 @@ public class java_lib_arrays_runme {
|
||||||
if (java_lib_arrays.extract_ptr(array_yet_another_struct, 0) != 222.333) throw new RuntimeException("extract_ptr 0 failed");
|
if (java_lib_arrays.extract_ptr(array_yet_another_struct, 0) != 222.333) throw new RuntimeException("extract_ptr 0 failed");
|
||||||
if (java_lib_arrays.extract_ptr(array_yet_another_struct, 1) != 444.555) throw new RuntimeException("extract_ptr 1 failed");
|
if (java_lib_arrays.extract_ptr(array_yet_another_struct, 1) != 444.555) throw new RuntimeException("extract_ptr 1 failed");
|
||||||
|
|
||||||
|
java_lib_arrays.modifyYAS(array_yet_another_struct, array_yet_another_struct.length);
|
||||||
|
for (int i=0; i<2; ++i) {
|
||||||
|
if (array_yet_another_struct[i].getSimple().getDouble_field() != array_struct[i].getDouble_field() * 10.0)
|
||||||
|
throw new RuntimeException("modifyYAS failed ");
|
||||||
|
}
|
||||||
|
|
||||||
java_lib_arrays.toestest(array_toe, array_toe, array_toe);
|
java_lib_arrays.toestest(array_toe, array_toe, array_toe);
|
||||||
|
|
||||||
// Now set the array members and check that they have been set correctly
|
// Now set the array members and check that they have been set correctly
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,14 @@ struct YetAnotherStruct {
|
||||||
double extract_ptr(struct YetAnotherStruct *yas, int index) {
|
double extract_ptr(struct YetAnotherStruct *yas, int index) {
|
||||||
return yas[index].simple.double_field;
|
return yas[index].simple.double_field;
|
||||||
}
|
}
|
||||||
|
void modifyYAS(struct YetAnotherStruct yas[], int size) {
|
||||||
|
int i;
|
||||||
|
for (i=0; i<size; ++i) {
|
||||||
|
SimpleStruct ss;
|
||||||
|
ss.double_field = yas[i].simple.double_field * 10.0;
|
||||||
|
yas[i].simple = ss;
|
||||||
|
}
|
||||||
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%apply ARRAYSOFENUMS[ANY] { toe[ANY] }
|
%apply ARRAYSOFENUMS[ANY] { toe[ANY] }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue