comparison test/suite/case.c @ 0:3e629dc19168

initial from svn dyncall-1745
author Daniel Adler
date Thu, 19 Mar 2015 22:24:28 +0100
parents
children f5577f6bf97a
comparison
equal deleted inserted replaced
-1:000000000000 0:3e629dc19168
1 /*
2
3 Package: dyncall
4 Library: test
5 File: test/suite/case.c
6 Description:
7 License:
8
9 Copyright (c) 2007-2015 Daniel Adler <dadler@uni-goettingen.de>,
10 Tassilo Philipp <tphilipp@potion-studios.com>
11
12 Permission to use, copy, modify, and distribute this software for any
13 purpose with or without fee is hereby granted, provided that the above
14 copyright notice and this permission notice appear in all copies.
15
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23
24 */
25
26
27
28 #include "../../dyncall/dyncall.h"
29 #include "config.h"
30 #include "../../dyncall/dyncall_value.h"
31
32 DCValue mValue[NARGS];
33
34 void clearValues() { int i; for(i=0; i<NARGS; ++i) mValue[i].L = 0xCAFEBABEDEADC0DEULL; }
35
36 void g_DCbool (DCbool value, int pos) { mValue[pos].B = value; }
37 void g_DCchar (DCchar value, int pos) { mValue[pos].c = value; }
38 void g_DCshort (DCshort value, int pos) { mValue[pos].s = value; }
39 void g_DCint (DCint value, int pos) { mValue[pos].i = value; }
40 void g_DClonglong(DClonglong value, int pos) { mValue[pos].l = value; }
41 void g_DCfloat (DCfloat value, int pos) { mValue[pos].f = value; }
42 void g_DCdouble (DCdouble value, int pos) { mValue[pos].d = value; }
43 void g_DCpointer (DCpointer value, int pos) { mValue[pos].p = value; }
44
45 DCValue* getArg(int pos) { return &mValue[pos]; }
46
47 int gID;
48 int getId() { return gID; }
49
50 // Generate function definitions.
51 #define VF0( id, S) void S( ) {gID=id; }
52 #define VF1( id,A1, S) void S(A1 a1 ) {gID=id;g_##A1(a1,0); }
53 #define VF2( id,A1,A2, S) void S(A1 a1, A2 a2 ) {gID=id;g_##A1(a1,0);g_##A2(a2,1); }
54 #define VF3( id,A1,A2,A3, S) void S(A1 a1, A2 a2,A3 a3 ) {gID=id;g_##A1(a1,0);g_##A2(a2,1);g_##A3(a3,2); }
55 #define VF4( id,A1,A2,A3,A4, S) void S(A1 a1, A2 a2,A3 a3,A4 a4 ) {gID=id;g_##A1(a1,0);g_##A2(a2,1);g_##A3(a3,2);g_##A4(a4,3); }
56 #define VF5( id,A1,A2,A3,A4,A5, S) void S(A1 a1, A2 a2,A3 a3,A4 a4,A5 a5 ) {gID=id;g_##A1(a1,0);g_##A2(a2,1);g_##A3(a3,2);g_##A4(a4,3);g_##A5(a5,4); }
57 #define VF6( id,A1,A2,A3,A4,A5,A6, S) void S(A1 a1, A2 a2,A3 a3,A4 a4,A5 a5,A6 a6 ) {gID=id;g_##A1(a1,0);g_##A2(a2,1);g_##A3(a3,2);g_##A4(a4,3);g_##A5(a5,4);g_##A6(a6,5); }
58 #define VF7( id,A1,A2,A3,A4,A5,A6,A7, S) void S(A1 a1, A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7 ) {gID=id;g_##A1(a1,0);g_##A2(a2,1);g_##A3(a3,2);g_##A4(a4,3);g_##A5(a5,4);g_##A6(a6,5);g_##A7(a7,6); }
59 #define VF8( id,A1,A2,A3,A4,A5,A6,A7,A8, S) void S(A1 a1, A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8 ) {gID=id;g_##A1(a1,0);g_##A2(a2,1);g_##A3(a3,2);g_##A4(a4,3);g_##A5(a5,4);g_##A6(a6,5);g_##A7(a7,6);g_##A8(a8,7); }
60 #define VF9( id,A1,A2,A3,A4,A5,A6,A7,A8,A9, S) void S(A1 a1, A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9 ) {gID=id;g_##A1(a1,0);g_##A2(a2,1);g_##A3(a3,2);g_##A4(a4,3);g_##A5(a5,4);g_##A6(a6,5);g_##A7(a7,6);g_##A8(a8,7);g_##A9(a9,8); }
61 #define VF10(id,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,S) void S(A1 a1, A2 a2,A3 a3,A4 a4,A5 a5,A6 a6,A7 a7,A8 a8,A9 a9,A10 a10) {gID=id;g_##A1(a1,0);g_##A2(a2,1);g_##A3(a3,2);g_##A4(a4,3);g_##A5(a5,4);g_##A6(a6,5);g_##A7(a7,6);g_##A8(a8,7);g_##A9(a9,8);g_##A10(a10,9);}
62 #include "case.h"
63
64
65 // Generate function pointer table used for loop.
66 #undef VF0
67 #undef VF1
68 #undef VF2
69 #undef VF3
70 #undef VF4
71 #undef VF5
72 #undef VF6
73 #undef VF7
74 #undef VF8
75 #undef VF9
76 #undef VF10
77
78 #define VF0( id, S) (void(*)())(S),
79 #define VF1( id,A1, S) (void(*)())(S),
80 #define VF2( id,A1,A2, S) (void(*)())(S),
81 #define VF3( id,A1,A2,A3, S) (void(*)())(S),
82 #define VF4( id,A1,A2,A3,A4, S) (void(*)())(S),
83 #define VF5( id,A1,A2,A3,A4,A5, S) (void(*)())(S),
84 #define VF6( id,A1,A2,A3,A4,A5,A6, S) (void(*)())(S),
85 #define VF7( id,A1,A2,A3,A4,A5,A6,A7, S) (void(*)())(S),
86 #define VF8( id,A1,A2,A3,A4,A5,A6,A7,A8, S) (void(*)())(S),
87 #define VF9( id,A1,A2,A3,A4,A5,A6,A7,A8,A9, S) (void(*)())(S),
88 #define VF10(id,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,S) (void(*)())(S),
89
90 typedef void (*fp)();
91 fp gFuncTable[] = {
92 #include "case.h"
93 };
94
95 DCpointer getFunc(int x) {
96 return (DCpointer)gFuncTable[x];
97 }