On Tue, 2004-04-20 at 02:13, Leopold Toetsch wrote:
Can you provide some test code (s. t/pmc/nci.t and src/nci_test.c) for
signatures similar to the real:
extern DECLSPEC void SDLCALL SDL_UpdateRects
(SDL_Surface *screen, int numrects, SDL_Rect *rects);
No problem. Fair warning, though: nci_test doesn't build by default on
Linux PPC. I had to build it manually then copy it into
runtime/parrot/dynext/.
After commenting out the skipall() which doesn't like my platform, tests
5 and 27-29 fail. More importantly, the other tests pass.
After adding a signature for vpP to src/nci_call.txt and rebuilding,
only test 5 fails. That might be due to differences in the size of
shorts on this platform as compared to i386; just a guess. (The return
value is 128, while the test expects -128).
Anyhow, I've attached a new test which shows of more or less my idea for
what this should do. It may be horribly wrong, but it's wrong in a way
that has actual code, not just vague ideas.
On the other hand, I'm really *not* a C programmer.
-- c
Index: t/pmc/nci.t
===
RCS file: /cvs/public/parrot/t/pmc/nci.t,v
retrieving revision 1.35
diff -u -u -r1.35 nci.t
--- t/pmc/nci.t 8 Mar 2004 00:20:09 - 1.35
+++ t/pmc/nci.t 28 Apr 2004 04:06:07 -
@@ -17,7 +17,7 @@
=cut
-use Parrot::Test tests = 29;
+use Parrot::Test tests = 30;
use Parrot::Config;
print STDERR $PConfig{jitcpuarch}, JIT CPU\n;
output_is('CODE', 'OUTPUT', nci_d_d);
@@ -1014,6 +1015,63 @@
user data: 42
external data: 77
done.
+OUTPUT
+
+output_is('CODE', 'OUTPUT', 'array of structs');
+ loadlib P1, libnci
+ dlfunc P0, P1, nci_pip, pip
+.include datatypes.pasm
+ new P3, .OrderedHash
+ set P3[x], .DATATYPE_INT
+ push P3, 0
+ push P3, 0
+ set P3[y], .DATATYPE_INT
+ push P3, 0
+ push P3, 0
+ set P3[w], .DATATYPE_INT
+ push P3, 0
+ push P3, 0
+ set P3[h], .DATATYPE_INT
+ push P3, 0
+ push P3, 0
+
+ new P5, .ManagedStruct, P3
+ set P5['x'], 100
+ set P5['y'], 100
+ set P5['w'], 100
+ set P5['h'], 100
+
+ new P6, .ManagedStruct, P3
+ set P6['x'], 200
+ set P6['y'], 200
+ set P6['w'], 200
+ set P6['h'], 200
+
+ new P7, .ManagedStruct, P3
+ set P7['x'], 300
+ set P7['y'], 300
+ set P7['w'], 300
+ set P7['h'], 300
+
+ new P8, .ManagedStruct, P3
+ set P8['x'], 400
+ set P8['y'], 400
+ set P8['w'], 400
+ set P8['h'], 400
+
+ set I5, 4
+ set I0, 1
+ set I1, 1
+ set I3, 4
+
+ invoke
+
+CODE
+Count: 4
+X: 100
+Y: 200
+W: 300
+H: 400
OUTPUT
} # SKIP
Index: src/nci_test.c
===
RCS file: /cvs/public/parrot/src/nci_test.c,v
retrieving revision 1.22
diff -u -u -r1.22 nci_test.c
--- src/nci_test.c 9 Feb 2004 15:54:47 - 1.22
+++ src/nci_test.c 28 Apr 2004 04:06:38 -
@@ -28,6 +28,14 @@
typedef void (*cb_D1_func)(void*, const char*);
void nci_cb_D1(cb_D1_func, void*);
+typedef struct
+{
+ int x, y;
+ int w, h;
+} Rect_Like;
+
+void nci_pip (int count, Rect_Like *rects);
+
double nci_dd(double d) {
return d * 2.0;
}
@@ -255,6 +263,12 @@
const char *result = succeeded;
/* call the cb synchronously */
(cb)(user_data, result);
+}
+
+void nci_pip (int count, Rect_Like *rects)
+{
+ printf( Count: %d\nX: %d\nY: %d\nW: %d\nH: %d,
+ count, rects[0].x, rects[1].y, rects[2].w, rects[3].h );
}
#ifdef TEST
Index: src/call_list.txt
===
RCS file: /cvs/public/parrot/src/call_list.txt,v
retrieving revision 1.29
Index: src/call_list.txt
===
RCS file: /cvs/public/parrot/src/call_list.txt,v
retrieving revision 1.29
diff -u -u -r1.29 call_list.txt
--- src/call_list.txt 30 Mar 2004 10:23:25 - 1.29
+++ src/call_list.txt 28 Apr 2004 04:08:21 -
@@ -209,3 +209,7 @@
# Used by library/sdl.imc
p iiil
i ppl
+
+# used by t/pmc/nci.t
+v pP
+p ip