Mercurial > pub > dyncall > dyncall
comparison test/call_suite/main.c @ 511:a0c51f34023a
test/call_suite:
- less confusing and simpler generated code (with first arg in V_?[0] output)
- avoid using same test reference value for retval and last arg
author | Tassilo Philipp |
---|---|
date | Sat, 09 Apr 2022 23:48:01 +0200 |
parents | ed7d1f5e7973 |
children | c9c546f8598b |
comparison
equal
deleted
inserted
replaced
510:f0080b53635d | 511:a0c51f34023a |
---|---|
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 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 | 21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
23 | 23 |
24 */ | 24 */ |
25 | |
25 | 26 |
26 #include "dyncall.h" | 27 #include "dyncall.h" |
27 #include "globals.h" | 28 #include "globals.h" |
28 #include <string.h> | 29 #include <string.h> |
29 #include "../common/platformInit.h" | 30 #include "../common/platformInit.h" |
54 } | 55 } |
55 | 56 |
56 ++rtype; | 57 ++rtype; |
57 | 58 |
58 while ( (atype = *sig++) != ')') { | 59 while ( (atype = *sig++) != ')') { |
59 pos++; | |
60 switch(atype) { | 60 switch(atype) { |
61 case 'c': dcArgChar (p,K_c[pos]); break; | 61 case 'c': dcArgChar (p,K_c[pos]); break; |
62 case 's': dcArgShort (p,K_s[pos]); break; | 62 case 's': dcArgShort (p,K_s[pos]); break; |
63 case 'i': dcArgInt (p,K_i[pos]); break; | 63 case 'i': dcArgInt (p,K_i[pos]); break; |
64 case 'j': dcArgLong (p,K_j[pos]); break; | 64 case 'j': dcArgLong (p,K_j[pos]); break; |
71 case 'p': dcArgPointer (p,K_p[pos]); break; | 71 case 'p': dcArgPointer (p,K_p[pos]); break; |
72 case 'f': dcArgFloat (p,K_f[pos]); break; | 72 case 'f': dcArgFloat (p,K_f[pos]); break; |
73 case 'd': dcArgDouble (p,K_d[pos]); break; | 73 case 'd': dcArgDouble (p,K_d[pos]); break; |
74 default: printf("unknown atype '%c' (1) ;", atype); return 0; | 74 default: printf("unknown atype '%c' (1) ;", atype); return 0; |
75 } | 75 } |
76 ++pos; | |
76 } | 77 } |
77 | 78 |
78 switch(*rtype) | 79 switch(*rtype) |
79 { | 80 { |
80 case 'v': dcCallVoid (p,t); s=1; break; /*TODO:check that no return-arg was touched.*/ | 81 case 'v': dcCallVoid (p,t); s=1; break; /*TODO:check that no return-arg was touched.*/ |
96 | 97 |
97 if (!s) { printf("rval wrong;"); return 0; } | 98 if (!s) { printf("rval wrong;"); return 0; } |
98 | 99 |
99 /* test: */ | 100 /* test: */ |
100 sig = signature; | 101 sig = signature; |
101 pos = 1; | 102 pos = 0; |
102 while ( (atype = *sig++) != ')') { | 103 while ( (atype = *sig++) != ')') { |
103 switch(atype) { | 104 switch(atype) { |
104 case 'c': s = ( V_c[pos] == K_c[pos] ); if (!s) printf("'%c':%d: %d != %d ; ", atype, pos, V_c[pos], K_c[pos]); break; | 105 case 'c': s = ( V_c[pos] == K_c[pos] ); if (!s) printf("'%c':%d: %d != %d ; ", atype, pos, V_c[pos], K_c[pos]); break; |
105 case 's': s = ( V_s[pos] == K_s[pos] ); if (!s) printf("'%c':%d: %d != %d ; ", atype, pos, V_s[pos], K_s[pos]); break; | 106 case 's': s = ( V_s[pos] == K_s[pos] ); if (!s) printf("'%c':%d: %d != %d ; ", atype, pos, V_s[pos], K_s[pos]); break; |
106 case 'i': s = ( V_i[pos] == K_i[pos] ); if (!s) printf("'%c':%d: %d != %d ; ", atype, pos, V_i[pos], K_i[pos]); break; | 107 case 'i': s = ( V_i[pos] == K_i[pos] ); if (!s) printf("'%c':%d: %d != %d ; ", atype, pos, V_i[pos], K_i[pos]); break; |