1 /*
2 Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is also distributed with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24 /*
25 * myapi.hpp
26 */
27
28 #ifndef _myapi
29 #define _myapi
30
31 #include <stdio.h> // not using namespaces yet
32
33 /*
34 * This test uses the C99 exact-width type aliases s int8_t, uint8_t,
35 * ... int64_t, uint64_t as defined in <stdint.h>.
36 *
37 * Unfortunately, some C/C++ compiler still lack a stdint.h header file.
38 * (For instance, MS Visual Studio until VS2010.) We delegate to a helper
39 * file that handles the absence of the <stdint.h> (without introducing
40 * a dependency upon JTie or NDB API).
41 */
42 #include "mystdint.h"
43
44 #include "helpers.hpp"
45
46 // ----------------------------------------------------------------------
47 // initializer and finalizer functions
48 // ----------------------------------------------------------------------
49
50 // initializer avoiding issues with static construction of objects
51 extern void myapi_init();
52 extern void myapi_finit();
53
54 // ----------------------------------------------------------------------
55 // void result/parameter types
56 // ----------------------------------------------------------------------
57
58 extern void f0();
59
60 // ----------------------------------------------------------------------
61 // [const] void/char * [const] result/parameter types
62 // ----------------------------------------------------------------------
63
64 // non-NULL-returning/accepting functions
65
66 extern const void * s010();
67 extern const char * s012();
68 extern void * s030();
69 extern char * s032();
70 extern const void * const s050();
71 extern const char * const s052();
72 extern void * const s070();
73 extern char * const s072();
74
75 extern void s110(const void * p0);
76 extern void s112(const char * p0);
77 extern void s130(void * p0);
78 extern void s132(char * p0);
79 extern void s150(const void * const p0);
80 extern void s152(const char * const p0);
81 extern void s170(void * const p0);
82 extern void s172(char * const p0);
83
84 // NULL-returning/accepting functions
85
86 extern const void * s210();
87 extern const char * s212();
88 extern void * s230();
89 extern char * s232();
90 extern const void * const s250();
91 extern const char * const s252();
92 extern void * const s270();
93 extern char * const s272();
94
95 extern void s310(const void * p0);
96 extern void s312(const char * p0);
97 extern void s330(void * p0);
98 extern void s332(char * p0);
99 extern void s350(const void * const p0);
100 extern void s352(const char * const p0);
101 extern void s370(void * const p0);
102 extern void s372(char * const p0);
103
104 // ----------------------------------------------------------------------
105 // all primitive result/parameter types
106 // ----------------------------------------------------------------------
107
108 extern const bool f11(const bool p0);
109 extern const char f12(const char p0);
110 extern const signed char f13(const signed char p0);
111 extern const unsigned char f14(const unsigned char p0);
112 extern const signed short f15(const signed short p0);
113 extern const unsigned short f16(const unsigned short p0);
114 extern const signed int f17(const signed int p0);
115 extern const unsigned int f18(const unsigned int p0);
116 extern const signed long f19(const signed long p0);
117 extern const unsigned long f20(const unsigned long p0);
118 extern const signed long long f21(const signed long long p0);
119 extern const unsigned long long f22(const unsigned long long p0);
120 extern const float f23(const float p0);
121 extern const double f24(const double p0);
122 extern const long double f25(const long double p0);
123
124 extern bool f31(bool p0);
125 extern char f32(char p0);
126 extern signed char f33(signed char p0);
127 extern unsigned char f34(unsigned char p0);
128 extern signed short f35(signed short p0);
129 extern unsigned short f36(unsigned short p0);
130 extern signed int f37(signed int p0);
131 extern unsigned int f38(unsigned int p0);
132 extern signed long f39(signed long p0);
133 extern unsigned long f40(unsigned long p0);
134 extern signed long long f41(signed long long p0);
135 extern unsigned long long f42(unsigned long long p0);
136 extern float f43(float p0);
137 extern double f44(double p0);
138 extern long double f45(long double p0);
139
140 // ----------------------------------------------------------------------
141 // all fixed-size primitive result/parameter types
142 // ----------------------------------------------------------------------
143
144 extern const bool f011();
145 extern const char f012();
146 extern const int8_t f013();
147 extern const uint8_t f014();
148 extern const int16_t f015();
149 extern const uint16_t f016();
150 extern const int32_t f017();
151 extern const uint32_t f018();
152 extern const int64_t f021();
153 extern const uint64_t f022();
154 extern const float f023();
155 extern const double f024();
156
157 extern bool f031();
158 extern char f032();
159 extern int8_t f033();
160 extern uint8_t f034();
161 extern int16_t f035();
162 extern uint16_t f036();
163 extern int32_t f037();
164 extern uint32_t f038();
165 extern int64_t f041();
166 extern uint64_t f042();
167 extern float f043();
168 extern double f044();
169
170 extern void f111(const bool);
171 extern void f112(const char);
172 extern void f113(const int8_t);
173 extern void f114(const uint8_t);
174 extern void f115(const int16_t);
175 extern void f116(const uint16_t);
176 extern void f117(const int32_t);
177 extern void f118(const uint32_t);
178 extern void f121(const int64_t);
179 extern void f122(const uint64_t);
180 extern void f123(const float);
181 extern void f124(const double);
182
183 extern void f131(bool);
184 extern void f132(char);
185 extern void f133(int8_t);
186 extern void f134(uint8_t);
187 extern void f135(int16_t);
188 extern void f136(uint16_t);
189 extern void f137(int32_t);
190 extern void f138(uint32_t);
191 extern void f141(int64_t);
192 extern void f142(uint64_t);
193 extern void f143(float);
194 extern void f144(double);
195
196 // ----------------------------------------------------------------------
197 // references of primitive result/parameter types
198 // ----------------------------------------------------------------------
199
200 extern const bool & f211();
201 extern const char & f212();
202 extern const int8_t & f213();
203 extern const uint8_t & f214();
204 extern const int16_t & f215();
205 extern const uint16_t & f216();
206 extern const int32_t & f217();
207 extern const uint32_t & f218();
208 extern const int64_t & f221();
209 extern const uint64_t & f222();
210 extern const float & f223();
211 extern const double & f224();
212
213 extern bool & f231();
214 extern char & f232();
215 extern int8_t & f233();
216 extern uint8_t & f234();
217 extern int16_t & f235();
218 extern uint16_t & f236();
219 extern int32_t & f237();
220 extern uint32_t & f238();
221 extern int64_t & f241();
222 extern uint64_t & f242();
223 extern float & f243();
224 extern double & f244();
225
226 extern void f311(const bool &);
227 extern void f312(const char &);
228 extern void f313(const int8_t &);
229 extern void f314(const uint8_t &);
230 extern void f315(const int16_t &);
231 extern void f316(const uint16_t &);
232 extern void f317(const int32_t &);
233 extern void f318(const uint32_t &);
234 extern void f321(const int64_t &);
235 extern void f322(const uint64_t &);
236 extern void f323(const float &);
237 extern void f324(const double &);
238
239 extern void f331(bool &);
240 extern void f332(char &);
241 extern void f333(int8_t &);
242 extern void f334(uint8_t &);
243 extern void f335(int16_t &);
244 extern void f336(uint16_t &);
245 extern void f337(int32_t &);
246 extern void f338(uint32_t &);
247 extern void f341(int64_t &);
248 extern void f342(uint64_t &);
249 extern void f343(float &);
250 extern void f344(double &);
251
252 // ----------------------------------------------------------------------
253 // pointers to primitive result/parameter types (array size == 1)
254 // ----------------------------------------------------------------------
255
256 extern const bool * f411();
257 extern const char * f412();
258 extern const int8_t * f413();
259 extern const uint8_t * f414();
260 extern const int16_t * f415();
261 extern const uint16_t * f416();
262 extern const int32_t * f417();
263 extern const uint32_t * f418();
264 extern const int64_t * f421();
265 extern const uint64_t * f422();
266 extern const float * f423();
267 extern const double * f424();
268
269 extern bool * f431();
270 extern char * f432();
271 extern int8_t * f433();
272 extern uint8_t * f434();
273 extern int16_t * f435();
274 extern uint16_t * f436();
275 extern int32_t * f437();
276 extern uint32_t * f438();
277 extern int64_t * f441();
278 extern uint64_t * f442();
279 extern float * f443();
280 extern double * f444();
281
282 extern const bool * const f451();
283 extern const char * const f452();
284 extern const int8_t * const f453();
285 extern const uint8_t * const f454();
286 extern const int16_t * const f455();
287 extern const uint16_t * const f456();
288 extern const int32_t * const f457();
289 extern const uint32_t * const f458();
290 extern const int64_t * const f461();
291 extern const uint64_t * const f462();
292 extern const float * const f463();
293 extern const double * const f464();
294
295 extern bool * const f471();
296 extern char * const f472();
297 extern int8_t * const f473();
298 extern uint8_t * const f474();
299 extern int16_t * const f475();
300 extern uint16_t * const f476();
301 extern int32_t * const f477();
302 extern uint32_t * const f478();
303 extern int64_t * const f481();
304 extern uint64_t * const f482();
305 extern float * const f483();
306 extern double * const f484();
307
308 extern void f511(const bool *);
309 extern void f512(const char *);
310 extern void f513(const int8_t *);
311 extern void f514(const uint8_t *);
312 extern void f515(const int16_t *);
313 extern void f516(const uint16_t *);
314 extern void f517(const int32_t *);
315 extern void f518(const uint32_t *);
316 extern void f521(const int64_t *);
317 extern void f522(const uint64_t *);
318 extern void f523(const float *);
319 extern void f524(const double *);
320
321 extern void f531(bool *);
322 extern void f532(char *);
323 extern void f533(int8_t *);
324 extern void f534(uint8_t *);
325 extern void f535(int16_t *);
326 extern void f536(uint16_t *);
327 extern void f537(int32_t *);
328 extern void f538(uint32_t *);
329 extern void f541(int64_t *);
330 extern void f542(uint64_t *);
331 extern void f543(float *);
332 extern void f544(double *);
333
334 extern void f551(const bool * const);
335 extern void f552(const char * const);
336 extern void f553(const int8_t * const);
337 extern void f554(const uint8_t * const);
338 extern void f555(const int16_t * const);
339 extern void f556(const uint16_t * const);
340 extern void f557(const int32_t * const);
341 extern void f558(const uint32_t * const);
342 extern void f561(const int64_t * const);
343 extern void f562(const uint64_t * const);
344 extern void f563(const float * const);
345 extern void f564(const double * const);
346
347 extern void f571(bool * const);
348 extern void f572(char * const);
349 extern void f573(int8_t * const);
350 extern void f574(uint8_t * const);
351 extern void f575(int16_t * const);
352 extern void f576(uint16_t * const);
353 extern void f577(int32_t * const);
354 extern void f578(uint32_t * const);
355 extern void f581(int64_t * const);
356 extern void f582(uint64_t * const);
357 extern void f583(float * const);
358 extern void f584(double * const);
359
360 // ----------------------------------------------------------------------
361 // pointers to primitive result/parameter types (array size == 0)
362 // ----------------------------------------------------------------------
363
364 extern const bool * f611();
365 extern const char * f612();
366 extern const int8_t * f613();
367 extern const uint8_t * f614();
368 extern const int16_t * f615();
369 extern const uint16_t * f616();
370 extern const int32_t * f617();
371 extern const uint32_t * f618();
372 extern const int64_t * f621();
373 extern const uint64_t * f622();
374 extern const float * f623();
375 extern const double * f624();
376
377 extern bool * f631();
378 extern char * f632();
379 extern int8_t * f633();
380 extern uint8_t * f634();
381 extern int16_t * f635();
382 extern uint16_t * f636();
383 extern int32_t * f637();
384 extern uint32_t * f638();
385 extern int64_t * f641();
386 extern uint64_t * f642();
387 extern float * f643();
388 extern double * f644();
389
390 extern const bool * const f651();
391 extern const char * const f652();
392 extern const int8_t * const f653();
393 extern const uint8_t * const f654();
394 extern const int16_t * const f655();
395 extern const uint16_t * const f656();
396 extern const int32_t * const f657();
397 extern const uint32_t * const f658();
398 extern const int64_t * const f661();
399 extern const uint64_t * const f662();
400 extern const float * const f663();
401 extern const double * const f664();
402
403 extern bool * const f671();
404 extern char * const f672();
405 extern int8_t * const f673();
406 extern uint8_t * const f674();
407 extern int16_t * const f675();
408 extern uint16_t * const f676();
409 extern int32_t * const f677();
410 extern uint32_t * const f678();
411 extern int64_t * const f681();
412 extern uint64_t * const f682();
413 extern float * const f683();
414 extern double * const f684();
415
416 extern void f711(const bool *);
417 extern void f712(const char *);
418 extern void f713(const int8_t *);
419 extern void f714(const uint8_t *);
420 extern void f715(const int16_t *);
421 extern void f716(const uint16_t *);
422 extern void f717(const int32_t *);
423 extern void f718(const uint32_t *);
424 extern void f721(const int64_t *);
425 extern void f722(const uint64_t *);
426 extern void f723(const float *);
427 extern void f724(const double *);
428
429 extern void f731(bool *);
430 extern void f732(char *);
431 extern void f733(int8_t *);
432 extern void f734(uint8_t *);
433 extern void f735(int16_t *);
434 extern void f736(uint16_t *);
435 extern void f737(int32_t *);
436 extern void f738(uint32_t *);
437 extern void f741(int64_t *);
438 extern void f742(uint64_t *);
439 extern void f743(float *);
440 extern void f744(double *);
441
442 extern void f751(const bool * const);
443 extern void f752(const char * const);
444 extern void f753(const int8_t * const);
445 extern void f754(const uint8_t * const);
446 extern void f755(const int16_t * const);
447 extern void f756(const uint16_t * const);
448 extern void f757(const int32_t * const);
449 extern void f758(const uint32_t * const);
450 extern void f761(const int64_t * const);
451 extern void f762(const uint64_t * const);
452 extern void f763(const float * const);
453 extern void f764(const double * const);
454
455 extern void f771(bool * const);
456 extern void f772(char * const);
457 extern void f773(int8_t * const);
458 extern void f774(uint8_t * const);
459 extern void f775(int16_t * const);
460 extern void f776(uint16_t * const);
461 extern void f777(int32_t * const);
462 extern void f778(uint32_t * const);
463 extern void f781(int64_t * const);
464 extern void f782(uint64_t * const);
465 extern void f783(float * const);
466 extern void f784(double * const);
467
468 // ----------------------------------------------------------------------
469 // object result/parameter types
470 // ----------------------------------------------------------------------
471
472 struct B0 {
473 static int32_t d0s;
474 static const int32_t d0sc;
475
476 int32_t d0;
477 const int32_t d0c;
478
479 static void init();
480
481 static void finit();
482
B0B0483 B0() : d0(21), d0c(-21) {
484 TRACE("B0()");
485 };
486
B0B0487 B0(const B0 & b0) : d0(b0.d0), d0c(b0.d0c) {
488 TRACE("B0(const B0 &)");
489 ABORT_ERROR("!USE OF COPY CONSTRUCTOR!");
490 };
491
~B0B0492 virtual ~B0() {};
493
operator =B0494 B0 & operator=(const B0 & p) {
495 TRACE("B0 & operator=(const B0 &)");
496 (void)p;
497 ABORT_ERROR("!USE OF ASSIGNMENT OPERATOR!");
498 return *this;
499 }
500
501 // ----------------------------------------------------------------------
502
f0sB0503 static int32_t f0s() {
504 TRACE("int32_t B0::f0s()");
505 return 20;
506 };
507
f0nB0508 int32_t f0n() const {
509 TRACE("int32_t B0::f0n()");
510 return 21;
511 };
512
f0vB0513 virtual int32_t f0v() const {
514 TRACE("int32_t B0::f0v()");
515 return 22;
516 };
517
518 };
519
520 struct B1 : public B0 {
521 static int32_t d0s;
522 static const int32_t d0sc;
523
524 int32_t d0;
525 const int32_t d0c;
526
527 static void init();
528
529 static void finit();
530
B1B1531 B1() : d0(31), d0c(-31) {
532 TRACE("B1()");
533 };
534
B1B1535 B1(const B1 & b1) : B0(b1), d0(b1.d0), d0c(b1.d0c) {
536 TRACE("B1(const B1 &)");
537 ABORT_ERROR("!USE OF COPY CONSTRUCTOR!");
538 };
539
~B1B1540 virtual ~B1() {};
541
operator =B1542 B1 & operator=(const B1 & p) {
543 TRACE("B1 & operator=(const B1 &)");
544 (void)p;
545 ABORT_ERROR("!USE OF ASSIGNMENT OPERATOR!");
546 return *this;
547 }
548
549 // ----------------------------------------------------------------------
550
f0sB1551 static int32_t f0s() {
552 TRACE("int32_t B1::f0s()");
553 return 30;
554 };
555
f0nB1556 int32_t f0n() const {
557 TRACE("int32_t B1::f0n()");
558 return 31;
559 };
560
f0vB1561 virtual int32_t f0v() const {
562 TRACE("int32_t B1::f0v()");
563 return 32;
564 };
565 };
566
567 struct A {
568 static A * a;
569 static int32_t d0s;
570 static const int32_t d0sc;
571
572 int32_t d0;
573 const int32_t d0c;
574
575 static void init();
576
577 static void finit();
578
AA579 A() : d0(11), d0c(-11) {
580 TRACE("A()");
581 };
582
AA583 A(int i) : d0(11), d0c(-11) {
584 TRACE("A(int)");
585 (void)i;
586 };
587
AA588 A(const A & a) : d0(a.d0), d0c(a.d0c) {
589 TRACE("A(const A &)");
590 ABORT_ERROR("!USE OF COPY CONSTRUCTOR!");
591 };
592
~AA593 virtual ~A() {
594 TRACE("~A()");
595 };
596
operator =A597 A & operator=(const A & p) {
598 TRACE("A & operator=(const A &)");
599 (void)p;
600 ABORT_ERROR("!USE OF ASSIGNMENT OPERATOR!");
601 return *this;
602 }
603
604 // ----------------------------------------------------------------------
605
deliver_ptrA606 static A * deliver_ptr() {
607 TRACE("A * A::deliver_ptr()");
608 return A::a;
609 };
610
deliver_null_ptrA611 static A * deliver_null_ptr() {
612 TRACE("A * A::deliver_null_ptr()");
613 return NULL;
614 };
615
deliver_refA616 static A & deliver_ref() {
617 TRACE("A & A::deliver_ref()");
618 return *A::a;
619 };
620
deliver_null_refA621 static A & deliver_null_ref() {
622 TRACE("A & A::deliver_null_ref()");
623 return *((A *)0);
624 };
625
take_ptrA626 static void take_ptr(A * o) {
627 TRACE("void A::take_ptr(A *)");
628 if (o != A::a) ABORT_ERROR("void A::take_ptr(A *)");
629 };
630
take_null_ptrA631 static void take_null_ptr(A * o) {
632 TRACE("void A::take_null_ptr(A *)");
633 if (o != NULL) ABORT_ERROR("void A::take_null_ptr(A *)");
634 };
635
take_refA636 static void take_ref(A & o) {
637 TRACE("void A::take_ref(A &)");
638 if (&o != A::a) ABORT_ERROR("void A::take_ref(A &)");
639 };
640
take_null_refA641 static void take_null_ref(A & o) {
642 TRACE("void A::take_null_ref(A &)");
643 if (&o != NULL) ABORT_ERROR("void A::take_null_ref(A &)");
644 };
645
printA646 static void print(A * p0) {
647 TRACE("void A::print(A *)");
648 printf(" p0 = %p\n", (void*)p0);
649 fflush(stdout);
650 };
651
652 // ----------------------------------------------------------------------
653
newB0A654 B0 * newB0() const {
655 TRACE("B0 A::newB0()");
656 return new B0();
657 };
658
newB1A659 B1 * newB1() const {
660 TRACE("B1 A::newB1()");
661 return new B1();
662 };
663
f0sA664 static int32_t f0s() {
665 TRACE("int32_t A::f0s()");
666 return 10;
667 };
668
f0nA669 int32_t f0n() const {
670 TRACE("int32_t A::f0n()");
671 return 11;
672 };
673
f0vA674 virtual int32_t f0v() const {
675 TRACE("int32_t A::f0v()");
676 return 12;
677 };
678
delA679 void del(B0 & b) {
680 TRACE("void A::del(B0 &)");
681 delete &b;
682 };
683
delA684 void del(B1 & b) {
685 TRACE("void A::del(B1 &)");
686 delete &b;
687 };
688
689 // ----------------------------------------------------------------------
690 // varying number of result/parameters
691 // ----------------------------------------------------------------------
692
g0cA693 void g0c() const {
694 TRACE("void A::g0c()");
695 };
696
g1cA697 void g1c(int8_t p0) const {
698 TRACE("void A::g1c(int8_t)");
699 if (p0 != 1) ABORT_ERROR("wrong arg value");
700 };
701
g2cA702 void g2c(int8_t p0, int16_t p1) const {
703 TRACE("void A::g2c(int8_t, int16_t)");
704 if (p0 != 1) ABORT_ERROR("wrong arg value");
705 if (p1 != 2) ABORT_ERROR("wrong arg value");
706 };
707
g3cA708 void g3c(int8_t p0, int16_t p1, int32_t p2) const {
709 TRACE("void A::g3c(int8_t, int16_t, int32_t)");
710 if (p0 != 1) ABORT_ERROR("wrong arg value");
711 if (p1 != 2) ABORT_ERROR("wrong arg value");
712 if (p2 != 3) ABORT_ERROR("wrong arg value");
713 };
714
g0A715 void g0() {
716 TRACE("void A::g0()");
717 };
718
g1A719 void g1(int8_t p0) {
720 TRACE("void A::g1(int8_t)");
721 if (p0 != 1) ABORT_ERROR("wrong arg value");
722 };
723
g2A724 void g2(int8_t p0, int16_t p1) {
725 TRACE("void A::g2(int8_t, int16_t)");
726 if (p0 != 1) ABORT_ERROR("wrong arg value");
727 if (p1 != 2) ABORT_ERROR("wrong arg value");
728 };
729
g3A730 void g3(int8_t p0, int16_t p1, int32_t p2) {
731 TRACE("void A::g3(int8_t, int16_t, int32_t)");
732 if (p0 != 1) ABORT_ERROR("wrong arg value");
733 if (p1 != 2) ABORT_ERROR("wrong arg value");
734 if (p2 != 3) ABORT_ERROR("wrong arg value");
735 };
736
737 // ----------------------------------------------------------------------
738
g0rcA739 int32_t g0rc() const {
740 TRACE("int32_t A::g0rc()");
741 return 0;
742 };
743
g1rcA744 int32_t g1rc(int8_t p0) const {
745 TRACE("int32_t A::g1rc(int8_t)");
746 if (p0 != 1) ABORT_ERROR("wrong arg value");
747 return p0;
748 };
749
g2rcA750 int32_t g2rc(int8_t p0, int16_t p1) const {
751 TRACE("int32_t A::g2rc(int8_t, int16_t)");
752 if (p0 != 1) ABORT_ERROR("wrong arg value");
753 if (p1 != 2) ABORT_ERROR("wrong arg value");
754 return p0 + p1;
755 };
756
g3rcA757 int32_t g3rc(int8_t p0, int16_t p1, int32_t p2) const {
758 TRACE("int32_t A::g3rc(int8_t, int16_t, int32_t)");
759 if (p0 != 1) ABORT_ERROR("wrong arg value");
760 if (p1 != 2) ABORT_ERROR("wrong arg value");
761 if (p2 != 3) ABORT_ERROR("wrong arg value");
762 return p0 + p1 + p2;
763 };
764
g0rA765 int32_t g0r() {
766 TRACE("int32_t A::g0r()");
767 return 0;
768 };
769
g1rA770 int32_t g1r(int8_t p0) {
771 TRACE("int32_t A::g1r(int8_t)");
772 if (p0 != 1) ABORT_ERROR("wrong arg value");
773 return p0;
774 };
775
g2rA776 int32_t g2r(int8_t p0, int16_t p1) {
777 TRACE("int32_t A::g2r(int8_t, int16_t)");
778 if (p0 != 1) ABORT_ERROR("wrong arg value");
779 if (p1 != 2) ABORT_ERROR("wrong arg value");
780 return p0 + p1;
781 };
782
g3rA783 int32_t g3r(int8_t p0, int16_t p1, int32_t p2) {
784 TRACE("int32_t A::g3r(int8_t, int16_t, int32_t)");
785 if (p0 != 1) ABORT_ERROR("wrong arg value");
786 if (p1 != 2) ABORT_ERROR("wrong arg value");
787 if (p2 != 3) ABORT_ERROR("wrong arg value");
788 return p0 + p1 + p2;
789 };
790 };
791
792 // ----------------------------------------------------------------------
793
h0()794 inline void h0() {
795 TRACE("void h0()");
796 }
797
h1(int8_t p0)798 inline void h1(int8_t p0) {
799 TRACE("void h1(int8_t)");
800 if (p0 != 1) ABORT_ERROR("wrong arg value");
801 }
802
h2(int8_t p0,int16_t p1)803 inline void h2(int8_t p0, int16_t p1) {
804 TRACE("void h2(int8_t, int16_t)");
805 if (p0 != 1) ABORT_ERROR("wrong arg value");
806 if (p1 != 2) ABORT_ERROR("wrong arg value");
807 }
808
h3(int8_t p0,int16_t p1,int32_t p2)809 inline void h3(int8_t p0, int16_t p1, int32_t p2) {
810 TRACE("void h3(int8_t, int16_t, int32_t)");
811 if (p0 != 1) ABORT_ERROR("wrong arg value");
812 if (p1 != 2) ABORT_ERROR("wrong arg value");
813 if (p2 != 3) ABORT_ERROR("wrong arg value");
814 }
815
h0r()816 inline int32_t h0r() {
817 TRACE("int32_t h0r()");
818 return 0;
819 }
820
h1r(int8_t p0)821 inline int32_t h1r(int8_t p0) {
822 TRACE("int32_t h1r(int8_t)");
823 if (p0 != 1) ABORT_ERROR("wrong arg value");
824 return p0;
825 }
826
h2r(int8_t p0,int16_t p1)827 inline int32_t h2r(int8_t p0, int16_t p1) {
828 TRACE("int32_t h2r(int8_t, int16_t)");
829 if (p0 != 1) ABORT_ERROR("wrong arg value");
830 if (p1 != 2) ABORT_ERROR("wrong arg value");
831 return p0 + p1;
832 }
833
h3r(int8_t p0,int16_t p1,int32_t p2)834 inline int32_t h3r(int8_t p0, int16_t p1, int32_t p2) {
835 TRACE("int32_t h3r(int8_t, int16_t, int32_t)");
836 if (p0 != 1) ABORT_ERROR("wrong arg value");
837 if (p1 != 2) ABORT_ERROR("wrong arg value");
838 if (p2 != 3) ABORT_ERROR("wrong arg value");
839 return p0 + p1 + p2;
840 }
841
842 // ----------------------------------------------------------------------
843 // [non-]const member functions and object[-array] result/parameter types
844 // ----------------------------------------------------------------------
845
846 struct C0 {
847 static C0 * c;
848 static const C0 * cc;
849
850 const int64_t id;
851
852 static void init();
853
854 static void finit();
855
C0C0856 C0() : id((int64_t)this) {
857 TRACE("C0()");
858 }
859
C0C0860 C0(const C0 & o) : id(o.id) {
861 TRACE("C0(const C0 &)");
862 (void)o;
863 ABORT_ERROR("!USE OF COPY CONSTRUCTOR!");
864 }
865
~C0C0866 virtual ~C0() {
867 TRACE("~C0()");
868 }
869
operator =C0870 C0 & operator=(const C0 & o) {
871 TRACE("C0 & operator=(const C0 &)");
872 (void)o;
873 ABORT_ERROR("!USE OF ASSIGNMENT OPERATOR!");
874 return *this;
875 }
876
877 // ----------------------------------------------------------------------
878 // static (on purpose) array functions
879 // ----------------------------------------------------------------------
880
passC0881 static C0 * pass(C0 * c0) {
882 return c0;
883 }
884
passC0885 static const C0 * pass(const C0 * c0) {
886 return c0;
887 }
888
hashC0889 static int64_t hash(const C0 * c0, int32_t n) {
890 TRACE("int64_t C0::hash(const C0 *, int32_t)");
891 if (c0 == NULL)
892 ABORT_ERROR("c0 == NULL");
893 if (n < 0)
894 ABORT_ERROR("n < 0");
895
896 int64_t r = 0;
897 for (int i = 0; i < n; i++) {
898 r ^= c0[i].id;
899 }
900 return r;
901 }
902
903 // ----------------------------------------------------------------------
904 // (non-virtual) instance (on purpose) array functions
905 // ----------------------------------------------------------------------
906
checkC0907 void check(int64_t id) const {
908 TRACE("void check(int64_t) const");
909 if (id != this->id) ABORT_ERROR("id != this->id");
910 }
911
printC0912 void print() const {
913 TRACE("void C0::print() const");
914 printf(" this->id = %llx\n", (long long unsigned int)id);
915 fflush(stdout);
916 }
917
deliver_C0CpC0918 const C0 * deliver_C0Cp() const {
919 TRACE("const C0 * C0::deliver_C0Cp() const");
920 return cc;
921 }
922
deliver_C0CrC0923 const C0 & deliver_C0Cr() const {
924 TRACE("const C0 & C0::deliver_C0Cr() const");
925 return *cc;
926 }
927
take_C0CpC0928 void take_C0Cp(const C0 * cp) const {
929 TRACE("void C0::take_C0Cp(const C0 *) const");
930 if (cp != C0::c && cp != C0::cc)
931 ABORT_ERROR("cp != C0::c && cp != C0::cc");
932 }
933
take_C0CrC0934 void take_C0Cr(const C0 & cp) const {
935 TRACE("void C0::take_C0Cr(const C0 &) const");
936 if (&cp != C0::c && &cp != C0::cc)
937 ABORT_ERROR("&cp != C0::c && &cp != C0::cc");
938 }
939
deliver_C0pC0940 C0 * deliver_C0p() {
941 TRACE("C0 * C0::deliver_C0p()");
942 return c;
943 }
944
deliver_C0rC0945 C0 & deliver_C0r() {
946 TRACE("C0 & C0::deliver_C0r()");
947 return *c;
948 }
949
take_C0pC0950 void take_C0p(C0 * p) {
951 TRACE("void C0::take_C0p(C0 *)");
952 if (p != C0::c)
953 ABORT_ERROR("p != C0::c");
954 }
955
take_C0rC0956 void take_C0r(C0 & p) {
957 TRACE("void C0::take_C0r(C0 &)");
958 if (&p != C0::c)
959 ABORT_ERROR("&p != C0::c");
960 }
961 };
962
963 struct C1 : public C0 {
964 static C1 * c;
965 static const C1 * cc;
966
967 static void init();
968
969 static void finit();
970
C1C1971 C1() {
972 TRACE("C1()");
973 };
974
C1C1975 C1(const C1 & o) : C0(o) {
976 TRACE("C1(const C1 &)");
977 (void)o;
978 ABORT_ERROR("!USE OF COPY CONSTRUCTOR!");
979 };
980
~C1C1981 virtual ~C1() {
982 TRACE("~C1()");
983 };
984
operator =C1985 C1 & operator=(const C1 & p) {
986 TRACE("C1 & operator=(const C1 &)");
987 (void)p;
988 ABORT_ERROR("!USE OF ASSIGNMENT OPERATOR!");
989 return *this;
990 }
991
992 // ----------------------------------------------------------------------
993 // static (on purpose) array functions
994 // ----------------------------------------------------------------------
995
passC1996 static C1 * pass(C1 * c1) {
997 return c1;
998 }
999
passC11000 static const C1 * pass(const C1 * c1) {
1001 return c1;
1002 }
1003
hashC11004 static int64_t hash(const C1 * c1, int32_t n) {
1005 TRACE("int64_t C1::hash(const C1 *, int32_t)");
1006 if (c1 == NULL)
1007 ABORT_ERROR("c1 == NULL");
1008 if (n < 0)
1009 ABORT_ERROR("n < 0");
1010
1011 int64_t r = 0;
1012 for (int i = 0; i < n; i++) {
1013 r ^= c1[i].id;
1014 }
1015 return r;
1016 }
1017
1018 // ----------------------------------------------------------------------
1019 // (non-virtual) instance (on purpose) array functions
1020 // ----------------------------------------------------------------------
1021
deliver_C1CpC11022 const C1 * deliver_C1Cp() const {
1023 TRACE("const C1 * C1::deliver_C1Cp() const");
1024 return cc;
1025 };
1026
deliver_C1CrC11027 const C1 & deliver_C1Cr() const {
1028 TRACE("const C1 & C1::deliver_C1Cr() const");
1029 return *cc;
1030 };
1031
take_C1CpC11032 void take_C1Cp(const C1 * cp) const {
1033 TRACE("void C1::take_C1Cp(const C1 *) const");
1034 if (cp != C1::c && cp != C1::cc)
1035 ABORT_ERROR("cp != C1::c && cp != C1::cc");
1036 };
1037
take_C1CrC11038 void take_C1Cr(const C1 & cp) const {
1039 TRACE("void C1::take_C1Cr(const C1 &) const");
1040 if (&cp != C1::c && &cp != C1::cc)
1041 ABORT_ERROR("&cp != C1::c && &cp != C1::cc");
1042 };
1043
deliver_C1pC11044 C1 * deliver_C1p() {
1045 TRACE("C1 * C1::deliver_C1p()");
1046 return c;
1047 };
1048
deliver_C1rC11049 C1 & deliver_C1r() {
1050 TRACE("C1 & C1::deliver_C1r()");
1051 return *c;
1052 };
1053
take_C1pC11054 void take_C1p(C1 * p) {
1055 TRACE("void C1::take_C1p(C1 *)");
1056 if (p != C1::c)
1057 ABORT_ERROR("p != C1::c");
1058 };
1059
take_C1rC11060 void take_C1r(C1 & p) {
1061 TRACE("void C1::take_C1r(C1 &)");
1062 if (&p != C1::c)
1063 ABORT_ERROR("&p != C1::c");
1064 };
1065 };
1066
1067 // ----------------------------------------------------------------------
1068 // overriding and virtual/non-virtual functions
1069 // ----------------------------------------------------------------------
1070
1071 struct D1;
1072
1073 struct D0 {
1074 static D0 * d;
1075 static void init();
1076 static void finit();
~D0D01077 virtual ~D0() {}
1078
f_d0D01079 int f_d0() { TRACE("D0::f_d0()"); return 20; }
f_nvD01080 int f_nv() { TRACE("D0::f_nv()"); return 21; }
f_vD01081 virtual int f_v() { TRACE("D0::f_v()"); return 22; }
1082 static D1 * sub();
1083 };
1084
1085 struct D1 : D0 {
1086 static D1 * d;
1087 static void init();
1088 static void finit();
~D1D11089 virtual ~D1() {}
1090
f_d1D11091 int f_d1() { TRACE("D0::f_d1()"); return 30; }
f_nvD11092 int f_nv() { TRACE("D1::f_nv()"); return 31; }
f_vD11093 virtual int f_v() { TRACE("D1::f_v()"); return 32; }
1094 static D1 * sub();
1095 };
1096
1097 struct D2 : D1 {
1098 static D2 * d;
1099 static void init();
1100 static void finit();
~D2D21101 virtual ~D2() {}
1102
f_d2D21103 int f_d2() { TRACE("D2::f_d2()"); return 40; }
f_nvD21104 int f_nv() { TRACE("D2::f_nv()"); return 41; }
f_vD21105 virtual int f_v() { TRACE("D2::f_v()"); return 42; }
1106 static D1 * sub();
1107 };
1108
1109 // d1class instance returns (casts unnecessary but for attention)
sub()1110 inline D1 * D0::sub() { TRACE("D1 * D0::sub()"); return ((D1*)D1::d); } // D1
sub()1111 inline D1 * D1::sub() { TRACE("D1 * D1::sub()"); return ((D1*)D2::d); } // D2
sub()1112 inline D1 * D2::sub() { TRACE("D1 * D2::sub()"); return NULL; } // --
1113
1114 // ----------------------------------------------------------------------
1115 // enums
1116 // ----------------------------------------------------------------------
1117
1118 struct E {
1119 enum EE { EE0, EE1 };
1120
deliver_EE1E1121 static EE deliver_EE1() {
1122 TRACE("E::EE E::deliver_EE1()");
1123 return EE1;
1124 };
1125
take_EE1E1126 static void take_EE1(EE e) {
1127 TRACE("void E::take_EE1(E::EE)");
1128 if (e != EE1) ABORT_ERROR("e != EE1");
1129 };
1130
deliver_EE1cE1131 static const EE deliver_EE1c() {
1132 TRACE("const E::EE E::deliver_EE1c()");
1133 return EE1;
1134 };
1135
take_EE1cE1136 static void take_EE1c(const EE e) {
1137 TRACE("void E::take_EE1c(const E::EE)");
1138 if (e != EE1) ABORT_ERROR("e != EE1");
1139 };
1140
1141 private:
1142 // no need to instantiate
EE1143 E() {
1144 TRACE("E()");
1145 }
1146
EE1147 E(const E & o) {
1148 TRACE("E(const E &)");
1149 (void)o;
1150 ABORT_ERROR("!USE OF COPY CONSTRUCTOR!");
1151 }
1152
~EE1153 virtual ~E() {
1154 TRACE("~E()");
1155 }
1156
operator =E1157 E & operator=(const E & o) {
1158 TRACE("E & operator=(const E &)");
1159 (void)o;
1160 ABORT_ERROR("!USE OF ASSIGNMENT OPERATOR!");
1161 return *this;
1162 }
1163 };
1164
1165 // ----------------------------------------------------------------------
1166
1167 #endif // _myapi
1168