|
1 |
| -/* Copyright (c) 2007 Timothy Wall, All Rights Reserved |
| 1 | +/* Copyright (c) 2007-2014 Timothy Wall, All Rights Reserved |
2 | 2 | *
|
3 | 3 | * This library is free software; you can redistribute it and/or
|
4 | 4 | * modify it under the terms of the GNU Lesser General Public
|
|
23 | 23 | import com.sun.jna.Library;
|
24 | 24 | import com.sun.jna.Native;
|
25 | 25 | import com.sun.jna.NativeLibrary;
|
| 26 | +import com.sun.jna.NativeLong; |
26 | 27 | import com.sun.jna.Structure;
|
27 | 28 |
|
28 | 29 | /**
|
@@ -54,6 +55,15 @@ interface Int32Callback extends StdCallCallback {
|
54 | 55 | int callback(int arg, int arg2);
|
55 | 56 | }
|
56 | 57 | int callInt32StdCallCallback(Int32Callback c, int arg, int arg2);
|
| 58 | + interface BugCallback extends StdCallCallback { |
| 59 | + void callback(NativeLong arg1, int arg2, double arg3, |
| 60 | + String arg4, String arg5, double arg6, |
| 61 | + NativeLong arg7, NativeLong arg8, NativeLong arg9); |
| 62 | + } |
| 63 | + int callBugCallback(BugCallback c, NativeLong arg1, int arg2, |
| 64 | + double arg3, String arg4, String arg5, |
| 65 | + double arg6, NativeLong arg7, |
| 66 | + NativeLong arg8, NativeLong arg9); |
57 | 67 | }
|
58 | 68 |
|
59 | 69 | public static void main(java.lang.String[] argList) {
|
@@ -136,4 +146,25 @@ public int callback(int arg, int arg2) {
|
136 | 146 | }
|
137 | 147 | assertEquals("Wrong stdcall callback return", -3, value);
|
138 | 148 | }
|
| 149 | + |
| 150 | + public void testCallBugCallback() { |
| 151 | + final boolean[] called = { false }; |
| 152 | + TestLibrary.BugCallback cb = new TestLibrary.BugCallback() { |
| 153 | + public void callback(NativeLong arg1, int arg2, double arg3, |
| 154 | + String arg4, String arg5, double arg6, |
| 155 | + NativeLong arg7, NativeLong arg8, |
| 156 | + NativeLong arg9) { |
| 157 | + called[0] = true; |
| 158 | + } |
| 159 | + }; |
| 160 | + int value = testlib.callBugCallback(cb, new NativeLong(1), |
| 161 | + 2, 3, "four", "five", 6, |
| 162 | + new NativeLong(7), |
| 163 | + new NativeLong(8), |
| 164 | + new NativeLong(9)); |
| 165 | + assertTrue("stdcall callback not called", called[0]); |
| 166 | + if (value == -1) { |
| 167 | + fail("stdcall callback did not restore the stack pointer"); |
| 168 | + } |
| 169 | + } |
139 | 170 | }
|
0 commit comments