annotate test/plain_c++/test_main.cc @ 557:b36a738c8975

- dyncallback: fix for calling back win/x64 C++ methods returning non-trivial aggregates (thanks Raphael!) - test/callback_plain_c++: * added test code for C++ method callbacks returning non-trivial aggregates * makefile linker command fix (was linking assuming c and not c++) - test/plain_c++: comments for completeness
author Tassilo Philipp
date Sat, 20 Aug 2022 21:04:15 +0200
parents 0c3f5355769d
children fcb9d00b5a00
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
1 /*
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
2
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
3 Package: dyncall
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
4 Library: test
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
5 File: test/plain_c++/test_main.cc
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
6 Description:
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
7 License:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
8
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
9 Copyright (c) 2007-2022 Daniel Adler <dadler@uni-goettingen.de>,
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
10 Tassilo Philipp <tphilipp@potion-studios.com>
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
11
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
12 Permission to use, copy, modify, and distribute this software for any
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
13 purpose with or without fee is hereby granted, provided that the above
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
14 copyright notice and this permission notice appear in all copies.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
15
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
23
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
24 */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
25
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
26
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
27
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
28
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
29 #include "../../dyncall/dyncall.h"
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
30 #include "../common/platformInit.h"
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
31 #include "../common/platformInit.c" /* Impl. for functions only used in this translation unit */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
32
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
33 #include "../../dyncall/dyncall_aggregate.h"
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
34
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
35 #include <signal.h>
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
36 #include <setjmp.h>
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
37 #include <stdarg.h>
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
38
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
39 jmp_buf jbuf;
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
40
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
41
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
42 void segv_handler(int sig)
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
43 {
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
44 longjmp(jbuf, 1);
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
45 }
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
46
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
47
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
48 /* -------------------------------------------------------------------------
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
49 * test: identity function calls
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
50 * ------------------------------------------------------------------------- */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
51
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
52 #define DEF_FUNCS(API,NAME) \
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
53 void API fun_##NAME##_v() { } \
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
54 DCbool API fun_##NAME##_b(DCbool x) { return x; } \
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
55 DCint API fun_##NAME##_i(DCint x) { return x; } \
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
56 DClong API fun_##NAME##_j(DClong x) { return x; } \
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
57 DClonglong API fun_##NAME##_l(DClonglong x) { return x; } \
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
58 DCfloat API fun_##NAME##_f(DCfloat x) { return x; } \
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
59 DCdouble API fun_##NAME##_d(DCdouble x) { return x; } \
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
60 DCpointer API fun_##NAME##_p(DCpointer x) { return x; }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
61
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
62 /* __cdecl */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
63
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
64 #if !defined(DC__OS_Win32)
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
65 # define __cdecl
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
66 #endif
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
67
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
68
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
69 /* -------------------------------------------------------------------------
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
70 * test: identity this calls
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
71 * ------------------------------------------------------------------------- */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
72
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
73 union ValueUnion
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
74 {
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
75 DCbool B;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
76 DCint i;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
77 DClong j;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
78 DClonglong l;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
79 DCfloat f;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
80 DCdouble d;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
81 DCpointer p;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
82 };
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
83
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
84 /* C++ class using __cdecl this call */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
85
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
86 // #define VTBI_DESTRUCTOR 0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
87
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
88 /*
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
89 * the layout of the VTable is non-standard and it is not clear what is the initial real first method index.
557
b36a738c8975 - dyncallback: fix for calling back win/x64 C++ methods returning non-trivial aggregates (thanks Raphael!)
Tassilo Philipp
parents: 539
diff changeset
90 * so far it turns out, *iff* dtor is defined, that:
b36a738c8975 - dyncallback: fix for calling back win/x64 C++ methods returning non-trivial aggregates (thanks Raphael!)
Tassilo Philipp
parents: 539
diff changeset
91 * on msvc/x86 : 1
b36a738c8975 - dyncallback: fix for calling back win/x64 C++ methods returning non-trivial aggregates (thanks Raphael!)
Tassilo Philipp
parents: 539
diff changeset
92 * on msvc/x64 : 1
b36a738c8975 - dyncallback: fix for calling back win/x64 C++ methods returning non-trivial aggregates (thanks Raphael!)
Tassilo Philipp
parents: 539
diff changeset
93 * on gcc/x86 : 2
b36a738c8975 - dyncallback: fix for calling back win/x64 C++ methods returning non-trivial aggregates (thanks Raphael!)
Tassilo Philipp
parents: 539
diff changeset
94 * on gcc/x64 : 2
b36a738c8975 - dyncallback: fix for calling back win/x64 C++ methods returning non-trivial aggregates (thanks Raphael!)
Tassilo Philipp
parents: 539
diff changeset
95 * on clang/x86 : 2
b36a738c8975 - dyncallback: fix for calling back win/x64 C++ methods returning non-trivial aggregates (thanks Raphael!)
Tassilo Philipp
parents: 539
diff changeset
96 * on clang/x64 : 2
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
97 */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
98
557
b36a738c8975 - dyncallback: fix for calling back win/x64 C++ methods returning non-trivial aggregates (thanks Raphael!)
Tassilo Philipp
parents: 539
diff changeset
99 // vtable offset to first func of class Value and class ValueMS, skipping dtor
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
100 #if defined DC__C_MSVC
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
101 #define VTBI_BASE 1
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
102 #else
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
103 #define VTBI_BASE 2
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
104 #endif
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
105
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
106 #define VTBI_SET_BOOL VTBI_BASE+0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
107 #define VTBI_GET_BOOL VTBI_BASE+1
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
108 #define VTBI_SET_INT VTBI_BASE+2
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
109 #define VTBI_GET_INT VTBI_BASE+3
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
110 #define VTBI_SET_LONG VTBI_BASE+4
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
111 #define VTBI_GET_LONG VTBI_BASE+5
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
112 #define VTBI_SET_LONG_LONG VTBI_BASE+6
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
113 #define VTBI_GET_LONG_LONG VTBI_BASE+7
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
114 #define VTBI_SET_FLOAT VTBI_BASE+8
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
115 #define VTBI_GET_FLOAT VTBI_BASE+9
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
116 #define VTBI_SET_DOUBLE VTBI_BASE+10
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
117 #define VTBI_GET_DOUBLE VTBI_BASE+11
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
118 #define VTBI_SET_POINTER VTBI_BASE+12
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
119 #define VTBI_GET_POINTER VTBI_BASE+13
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
120 #define VTBI_SUM_3_INTS VTBI_BASE+14
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
121
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
122 class Value
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
123 {
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
124 public:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
125 virtual ~Value() {}
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
126
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
127 virtual void __cdecl setBool(DCbool x) { mValue.B = x; }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
128 virtual DCbool __cdecl getBool() { return mValue.B; }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
129 virtual void __cdecl setInt(DCint x) { mValue.i = x; }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
130 virtual DCint __cdecl getInt() { return mValue.i; }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
131 virtual void __cdecl setLong(DClong x) { mValue.j = x; }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
132 virtual DClong __cdecl getLong() { return mValue.j; }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
133 virtual void __cdecl setLongLong(DClonglong x) { mValue.l = x; }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
134 virtual DClonglong __cdecl getLongLong() { return mValue.l; }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
135 virtual void __cdecl setFloat(DCfloat x) { mValue.f = x; }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
136 virtual DCfloat __cdecl getFloat() { return mValue.f; }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
137 virtual void __cdecl setDouble(DCdouble x) { mValue.d = x; }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
138 virtual DCdouble __cdecl getDouble() { return mValue.d; }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
139 virtual void __cdecl setPtr(DCpointer x) { mValue.p = x; }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
140 virtual DCpointer __cdecl getPtr() { return mValue.p; }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
141
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
142 /* ellipsis test w/ this ptr */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
143 virtual int __cdecl sum3Ints(DCint x, ...) { va_list va; va_start(va,x); x += va_arg(va,int) + va_arg(va,int); va_end(va); return x; }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
144
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
145 private:
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
146 ValueUnion mValue;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
147 };
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
148
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
149 template<typename T>
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
150 bool testCallValue(DCCallVM* pc, const char* name)
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
151 {
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
152 bool r = true, b;
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
153 T o;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
154 T* pThis = &o;
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
155 DCpointer* vtbl = *( (DCpointer**) pThis ); /* vtbl is located at beginning of class */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
156
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
157 /* set/get bool (TRUE) */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
158
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
159 dcReset(pc);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
160 dcArgPointer(pc, pThis);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
161 dcArgBool(pc,DC_TRUE);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
162 dcCallVoid(pc, vtbl[VTBI_SET_BOOL] );
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
163 dcReset(pc);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
164 dcArgPointer(pc, pThis);
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
165 b = ( dcCallBool(pc, vtbl[VTBI_GET_BOOL] ) == DC_TRUE );
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
166 printf("bt (%s): %d\n", name, b);
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
167 r = r && b;
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
168
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
169 /* set/get bool (FALSE) */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
170
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
171 dcReset(pc);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
172 dcArgPointer(pc, pThis);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
173 dcArgBool(pc,DC_FALSE);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
174 dcCallVoid(pc, vtbl[VTBI_SET_BOOL] );
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
175 dcReset(pc);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
176 dcArgPointer(pc, pThis);
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
177 b = ( dcCallBool(pc, vtbl[VTBI_GET_BOOL] ) == DC_FALSE );
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
178 printf("bf (%s): %d\n", name, b);
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
179 r = r && b;
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
180
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
181 /* set/get int */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
182
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
183 dcReset(pc);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
184 dcArgPointer(pc, pThis);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
185 dcArgInt(pc,1234);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
186 dcCallVoid(pc, vtbl[VTBI_SET_INT] );
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
187 dcReset(pc);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
188 dcArgPointer(pc, pThis);
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
189 b = ( dcCallInt(pc, vtbl[VTBI_GET_INT] ) == 1234 );
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
190 printf("i (%s): %d\n", name, b);
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
191 r = r && b;
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
192
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
193 /* set/get long */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
194
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
195 dcReset(pc);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
196 dcArgPointer(pc, pThis);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
197 dcArgLong(pc,0xCAFEBABEUL);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
198 dcCallVoid(pc, vtbl[VTBI_SET_LONG] );
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
199 dcReset(pc);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
200 dcArgPointer(pc, pThis);
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
201 b = ( dcCallLong(pc, vtbl[VTBI_GET_LONG] ) == (DClong)0xCAFEBABEUL );
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
202 printf("l (%s): %d\n", name, b);
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
203 r = r && b;
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
204
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
205 /* set/get long long */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
206
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
207 dcReset(pc);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
208 dcArgPointer(pc, pThis);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
209 dcArgLongLong(pc,0xCAFEBABEDEADC0DELL);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
210 dcCallVoid(pc, vtbl[VTBI_SET_LONG_LONG] );
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
211 dcReset(pc);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
212 dcArgPointer(pc, pThis);
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
213 b = ( dcCallLongLong(pc, vtbl[VTBI_GET_LONG_LONG] ) == (DClonglong)0xCAFEBABEDEADC0DELL );
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
214 printf("ll (%s): %d\n", name, b);
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
215 r = r && b;
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
216
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
217 /* set/get float */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
218
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
219 dcReset(pc);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
220 dcArgPointer(pc, pThis);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
221 dcArgFloat(pc,1.2345f);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
222 dcCallVoid(pc, vtbl[VTBI_SET_FLOAT] );
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
223 dcReset(pc);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
224 dcArgPointer(pc, pThis);
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
225 b = ( dcCallFloat(pc, vtbl[VTBI_GET_FLOAT] ) == 1.2345f );
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
226 printf("f (%s): %d\n", name, b);
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
227 r = r && b;
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
228
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
229 /* set/get double */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
230
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
231 dcReset(pc);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
232 dcArgPointer(pc, pThis);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
233 dcArgDouble(pc,1.23456789);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
234 dcCallVoid(pc, vtbl[VTBI_SET_DOUBLE] );
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
235 dcReset(pc);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
236 dcArgPointer(pc, pThis);
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
237 b = ( dcCallDouble(pc, vtbl[VTBI_GET_DOUBLE] ) == 1.23456789 );
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
238 printf("d (%s): %d\n", name, b);
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
239 r = r && b;
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
240
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
241 /* set/get pointer */
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
242
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
243 dcReset(pc);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
244 dcArgPointer(pc, pThis);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
245 dcArgPointer(pc, (DCpointer) 0xCAFEBABE );
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
246 dcCallVoid(pc, vtbl[VTBI_SET_POINTER] );
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
247 dcReset(pc);
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
248 dcArgPointer(pc, pThis);
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
249 b = ( dcCallPointer(pc, vtbl[VTBI_GET_POINTER] ) == ( (DCpointer) 0xCAFEBABE ) );
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
250 printf("p (%s): %d\n", name, b);
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
251 r = r && b;
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
252
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
253 /* ellipsis test w/ this pointer */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
254
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
255 dcReset(pc);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
256 dcMode(pc, DC_CALL_C_ELLIPSIS);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
257 dcArgPointer(pc, pThis);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
258 dcArgInt(pc, 23);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
259 dcMode(pc, DC_CALL_C_ELLIPSIS_VARARGS);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
260 dcArgInt(pc, -223);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
261 dcArgInt(pc, 888);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
262 int r_ = dcCallInt(pc, vtbl[VTBI_SUM_3_INTS]);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
263 b = (r_ == 688);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
264 printf("... (%s): %d\n", name, b);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
265 r = r && b;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
266
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
267 return r;
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
268 }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
269
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
270
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
271 #if defined(DC__OS_Win32) && defined(DC__C_MSVC)
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
272
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
273 /* C++ class using (on win32: microsoft) this call */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
274
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
275 class ValueMS
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
276 {
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
277 public:
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
278 virtual ~ValueMS() {}
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
279
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
280 virtual void setBool(DCbool x) { mValue.B = x; }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
281 virtual DCbool getBool() { return mValue.B; }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
282 virtual void setInt(DCint x) { mValue.i = x; }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
283 virtual DCint getInt() { return mValue.i; }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
284 virtual void setLong(DClong x) { mValue.j = x; }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
285 virtual DClong getLong() { return mValue.j; }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
286 virtual void setLongLong(DClonglong x) { mValue.l = x; }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
287 virtual DClonglong getLongLong() { return mValue.l; }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
288 virtual void setFloat(DCfloat x) { mValue.f = x; }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
289 virtual DCfloat getFloat() { return mValue.f; }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
290 virtual void setDouble(DCdouble x) { mValue.d = x; }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
291 virtual DCdouble getDouble() { return mValue.d; }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
292 virtual void setPtr(DCpointer x) { mValue.p = x; }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
293 virtual DCpointer getPtr() { return mValue.p; }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
294 private:
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
295 ValueUnion mValue;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
296 };
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
297
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
298 static bool testCallThisMS()
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
299 {
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
300 bool r = false;
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
301 DCCallVM* pc = dcNewCallVM(4096);
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
302 dcMode(pc, DC_CALL_C_X86_WIN32_THIS_MS);
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
303 dcReset(pc);
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
304 if(setjmp(jbuf) != 0)
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
305 printf("sigsegv\n"), r=false;
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
306 else
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
307 r = testCallValue<ValueMS>(pc, "MS");
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
308 dcFree(pc);
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
309 return r;
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
310 }
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
311
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
312 #endif
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
313
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
314
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
315 static bool testCallThisC()
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
316 {
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
317 bool r = false;
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
318 DCCallVM* pc = dcNewCallVM(4096);
466
ddfb9577a00e introduced platform-native thiscall mode (DC_CALL_C_DEFAULT_THIS), as needed
Tassilo Philipp
parents: 348
diff changeset
319 dcMode(pc, DC_CALL_C_DEFAULT_THIS);
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
320 dcReset(pc);
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
321 if(setjmp(jbuf) != 0)
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
322 printf("sigsegv\n"), r=false;
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
323 else
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
324 r = testCallValue<Value>(pc, "c");
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
325 dcFree(pc);
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
326 return r;
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
327 }
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
328
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
329
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
330 #if defined(DC__Feature_AggrByVal)
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
331
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
332 class ValueAggr
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
333 {
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
334 public:
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
335 struct S { int i, j, k, l, m; };
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
336
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
337 virtual ~ValueAggr() {}
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
338
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
339 virtual void __cdecl setAggr(S x) { mS.i = x.i; mS.j = x.j; mS.k = x.k; mS.l = x.l; mS.m = x.m; }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
340 virtual S __cdecl getAggr() { return mS; }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
341
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
342 /* ellipsis test w/ this ptr and big (!) aggregate return */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
343 struct Big { int sum; long long dummy[50]; /*dummy to make it not fit in any regs*/ };
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
344 virtual struct Big __cdecl sum3RetAggr(DCint x, ...) { va_list va; va_start(va,x); struct Big r = { x + va_arg(va,int) + va_arg(va,int) }; va_end(va); return r; }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
345
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
346 /* non-trivial aggregate */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
347 struct NonTriv {
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
348 int i, j;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
349 NonTriv(int a, int b) : i(a),j(b) { }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
350 NonTriv(const NonTriv& rhs) { static int a=13, b=37; i = a++; j = b++; }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
351 };
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
352 /* by value, so on first invocation a = 13,37, b = 14,38 and retval = 13*14,37*38, no matter the contents of the instances as copy ctor is called */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
353 /* NOTE: copy of return value is subject to C++ "copy elision", so it is *not* calling the copy ctor for the return value */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
354 virtual struct NonTriv __cdecl squareFields(NonTriv a, NonTriv b) { return NonTriv(a.i*b.i, a.j*b.j); }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
355
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
356 private:
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
357 struct S mS;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
358 };
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
359
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
360 #if (__cplusplus >= 201103L)
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
361 # include <type_traits>
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
362 #endif
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
363
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
364 /* special case w/ e.g. MS x64 C++ calling cconf: struct return ptr is passed as *2nd* arg */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
365 static bool testCallThisAggr()
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
366 {
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
367 bool r = false;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
368 DCCallVM* pc = dcNewCallVM(4096);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
369 dcMode(pc, DC_CALL_C_DEFAULT_THIS);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
370
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
371 if(setjmp(jbuf) != 0)
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
372 printf("sigsegv\n"), r=false;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
373 else
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
374 {
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
375 ValueAggr o;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
376
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
377 DCpointer* vtbl = *( (DCpointer**) &o ); /* vtbl is located at beginning of class */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
378 ValueAggr::S st = { 124, -12, 434, 20202, -99999 }, returned;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
379
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
380 #if (__cplusplus >= 201103L)
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
381 bool istriv = std::is_trivial<ValueAggr::S>::value;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
382 #else
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
383 bool istriv = true; /* own deduction as no type trait */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
384 #endif
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
385 DCaggr *s = dcNewAggr(5, sizeof(ValueAggr::S));
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
386 dcAggrField(s, DC_SIGCHAR_INT, offsetof(ValueAggr::S, i), 1);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
387 dcAggrField(s, DC_SIGCHAR_INT, offsetof(ValueAggr::S, j), 1);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
388 dcAggrField(s, DC_SIGCHAR_INT, offsetof(ValueAggr::S, k), 1);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
389 dcAggrField(s, DC_SIGCHAR_INT, offsetof(ValueAggr::S, l), 1);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
390 dcAggrField(s, DC_SIGCHAR_INT, offsetof(ValueAggr::S, m), 1);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
391 dcCloseAggr(s);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
392
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
393 // set S::mS
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
394 dcReset(pc);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
395 dcArgPointer(pc, &o); // this ptr
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
396 dcArgAggr(pc, s, &st);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
397 dcCallVoid(pc, vtbl[VTBI_BASE+0]);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
398
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
399 // get it back
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
400 dcReset(pc);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
401 dcBeginCallAggr(pc, s);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
402 dcArgPointer(pc, &o); // this ptr
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
403 dcCallAggr(pc, vtbl[VTBI_BASE+1], s, &returned);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
404
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
405 dcFreeAggr(s);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
406
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
407 r = returned.i == st.i && returned.j == st.j && returned.k == st.k && returned.l == st.l && returned.m == st.m && istriv;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
408 printf("r:{iiiii} (this/trivial): %d\n", r);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
409
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
410
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
411
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
412 /* ellipsis test w/ this pointer returning big aggregate (quite an edge
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
413 * case) by value (won't fit in regs, so hidden pointer is is used to write
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
414 * return values to), showing the need to use the DC_CALL_C_DEFAULT_THIS
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
415 * mode first, for the this ptr alone, then DC_CALL_C_ELLIPSIS, then
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
416 * DC_CALL_C_ELLIPSIS_VARARGS (test is useful on win64 where thisptr is
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
417 * passed *after* return aggregate's hidden ptr) */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
418 #if (__cplusplus >= 201103L)
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
419 istriv = std::is_trivial<ValueAggr::Big>::value;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
420 #else
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
421 istriv = true; /* own deduction as no type trait */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
422 #endif
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
423 s = dcNewAggr(2, sizeof(struct ValueAggr::Big));
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
424 dcAggrField(s, DC_SIGCHAR_INT, offsetof(struct ValueAggr::Big, sum), 1);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
425 dcAggrField(s, DC_SIGCHAR_LONGLONG, offsetof(struct ValueAggr::Big, dummy), 50);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
426 dcCloseAggr(s);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
427 dcReset(pc);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
428 dcMode(pc, DC_CALL_C_DEFAULT_THIS); /* <-- needed on x64/win64 */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
429
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
430 dcBeginCallAggr(pc, s);
539
0c3f5355769d - test code: dcmode setting order fix, test worked but was incorrect according to the definition/doc
Tassilo Philipp
parents: 533
diff changeset
431 dcArgPointer(pc, &o);
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
432 dcMode(pc, DC_CALL_C_ELLIPSIS);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
433 dcArgInt(pc, 89);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
434 dcMode(pc, DC_CALL_C_ELLIPSIS_VARARGS);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
435 dcArgInt(pc, -157);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
436 dcArgInt(pc, 888);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
437 struct ValueAggr::Big big;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
438 dcCallAggr(pc, vtbl[VTBI_BASE+2], s, &big);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
439
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
440 dcFreeAggr(s);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
441
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
442 bool b = (big.sum == 820) && istriv;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
443 r = r && b;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
444 printf("r:{il[50]} (this/trivial/ellipsis): %d\n", b);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
445
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
446
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
447
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
448 /* non-trivial test ----------------------------------------------------------- */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
449
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
450 #if (__cplusplus >= 201103L)
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
451 istriv = std::is_trivial<ValueAggr::NonTriv>::value;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
452 #else
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
453 istriv = false; /* own deduction as no type trait */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
454 #endif
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
455 dcReset(pc);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
456 dcMode(pc, DC_CALL_C_DEFAULT_THIS);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
457
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
458 /* non trivial aggregates: pass NULL for DCaggr* and do copy on our own (see doc) */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
459 dcBeginCallAggr(pc, NULL);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
460
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
461 ValueAggr::NonTriv nt0(5, 6), nt1(7, 8), ntr(0, 0);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
462 dcArgAggr(pc, NULL, &o); // this ptr
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
463 /* make *own* copies, as dyncall cannot know how to call copy ctor */ //@@@ put into doc
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
464 ValueAggr::NonTriv nt0_ = nt0, nt1_ = nt1;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
465 dcArgAggr(pc, NULL, &nt0_); /* use *own* copy */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
466 dcArgAggr(pc, NULL, &nt1_); /* use *own* copy */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
467
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
468 dcCallAggr(pc, vtbl[VTBI_BASE+3], NULL, &ntr); /* note: "copy elision", so retval might *not* call copy ctor */
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
469
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
470
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
471 b = ntr.i == 13*14 && ntr.j == 37*38 && !istriv;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
472 r = r && b;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
473 printf("r:{ii} (this/nontrivial/retval_copy_elision): %d\n", b);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
474 }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
475
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
476 dcFree(pc);
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
477 return r;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
478 }
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
479
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
480 #endif
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
481
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
482
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
483 extern "C" {
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
484
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
485 int main(int argc, char* argv[])
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
486 {
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
487 dcTest_initPlatform();
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
488
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
489 signal(SIGSEGV, segv_handler);
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
490
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
491 bool r = true;
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
492
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
493 r = testCallThisC() && r;
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
494 #if defined(DC__OS_Win32) && defined(DC__C_MSVC)
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
495 r = testCallThisMS() && r;
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
496 #endif
533
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
497 #if defined(DC__Feature_AggrByVal)
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
498 r = testCallThisAggr() && r;
71c884e610f0 - integration of patches from Raphael Luba, Thekla, Inc.:
Tassilo Philipp
parents: 466
diff changeset
499 #endif
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
500
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
501 printf("result: plain_cpp: %d\n", r);
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
502
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
503 dcTest_deInitPlatform();
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
504
324
dd78bd0152af - removal of never-adopted mini-test framework stub
Tassilo Philipp
parents: 281
diff changeset
505 return !r;
0
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
506 }
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
507
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
508 } // extern "C"
3e629dc19168 initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
509