|
2 | 2 |
|
3 | 3 | '' test mapping of mangling between c++ class and fbc type |
4 | 4 |
|
| 5 | +'' helper macro to track progress |
5 | 6 | #define DLOG( msg ) '' print #msg |
6 | 7 |
|
7 | | -/' |
8 | | -#undef assert |
9 | | -#macro assert( expr ) |
10 | | - if( (expr) = 0 ) then |
11 | | - '' filename.ext(###): assertion failed at PROC: EXPR |
12 | | - print __FILE__; "("; __LINE__; "): assertion failed at "; __FUNCTION__; ": "; #expr |
13 | | - end if |
14 | | -#endmacro |
15 | | -'/ |
16 | | - |
17 | 8 | #if ENABLE_CHECK_BUGS |
18 | 9 | #define DOTEST |
19 | 10 | #else |
| 11 | + '' thiscall is not supported in -gen gas |
20 | 12 | #if __FB_BACKEND__ <> "gas" |
21 | 13 | #define DOTEST |
22 | 14 | #endif |
23 | 15 | #endif |
24 | 16 |
|
25 | | -#ifdef DOTEST |
26 | | - |
27 | 17 | '' !!! TODO !!! this default should be handled in fbc |
28 | 18 | #if defined(__FB_WIN32__) and not defined(__FB_64BIT__) |
29 | 19 | #define thiscall __thiscall |
|
36 | 26 | #endif |
37 | 27 |
|
38 | 28 | extern "c++" |
| 29 | + '' getters to retrieve call information |
| 30 | + '' from the c++ side |
| 31 | + declare sub setInitial( byval flag as long ) |
| 32 | + declare sub resetChecks() |
| 33 | + declare function getPtr1() as any ptr |
| 34 | + declare function getPtr2() as any ptr |
| 35 | + declare function getMsg1() as zstring ptr |
| 36 | + declare function getVal1() as long |
| 37 | + declare function getVal2() as long |
| 38 | + declare function getVal3() as long |
| 39 | +end extern |
| 40 | + |
| 41 | +extern "c++" |
| 42 | + '' simple UDT to test with and we |
| 43 | + '' declare the same on c++ side |
| 44 | + |
| 45 | + type UDT |
| 46 | + value as long |
39 | 47 |
|
40 | | -declare sub setInitial( byval flag as long ) |
41 | | -declare sub resetChecks() |
42 | | -declare function getPtr1() as any ptr |
43 | | -declare function getPtr2() as any ptr |
44 | | -declare function getMsg1() as zstring ptr |
45 | | -declare function getVal1() as long |
46 | | -declare function getVal2() as long |
47 | | -declare function getVal3() as long |
48 | | - |
49 | | -type UDT |
50 | | - value as long |
51 | | - self as any ptr |
52 | | - |
53 | | - declare constructor thiscall () |
54 | | - declare constructor thiscall ( byref rhs as const UDT ) |
55 | | - declare constructor thiscall ( byref rhs as const long ) |
56 | | - declare destructor thiscall () |
57 | | - declare operator let thiscall ( byref rhs as const UDT ) |
58 | | - /' declare operator thiscall +( byref rhs as const long ) as UDT '/ |
59 | | - /' declare operator thiscall -( byref rhs as const long ) as UDT '/ |
60 | | - |
61 | | -end type |
62 | | - |
63 | | -'' global operators |
64 | | -declare operator +( byref lhs as const UDT, byref rhs as const UDT ) as UDT |
65 | | -declare operator -( byref lhs as const UDT, byref rhs as const UDT ) as UDT |
66 | | -declare operator +( byref lhs as const long, byref rhs as const UDT ) as UDT |
67 | | -declare operator -( byref lhs as const long, byref rhs as const UDT ) as UDT |
| 48 | + declare constructor thiscall () |
| 49 | + declare constructor thiscall ( byref rhs as const UDT ) |
| 50 | + declare constructor thiscall ( byref rhs as const long ) |
| 51 | + declare destructor thiscall () |
| 52 | + declare operator let thiscall ( byref rhs as const UDT ) |
| 53 | + /' declare operator thiscall +( byref rhs as const long ) as UDT '/ |
| 54 | + /' declare operator thiscall -( byref rhs as const long ) as UDT '/ |
| 55 | + |
| 56 | + end type |
| 57 | + |
| 58 | + '' global operators |
| 59 | + declare operator +( byref lhs as const UDT, byref rhs as const UDT ) as UDT |
| 60 | + declare operator -( byref lhs as const UDT, byref rhs as const UDT ) as UDT |
| 61 | + declare operator +( byref lhs as const long, byref rhs as const UDT ) as UDT |
| 62 | + declare operator -( byref lhs as const long, byref rhs as const UDT ) as UDT |
68 | 63 |
|
69 | 64 | end extern |
70 | 65 |
|
71 | 66 | #macro checkResults( p1, p2, v1, v2, v3, m1 ) |
| 67 | + assert( m1 = *getMsg1() ) |
72 | 68 | assert( p1 = getPtr1() ) |
73 | 69 | assert( p2 = getPtr2() ) |
74 | 70 | assert( v1 = getVal1() ) |
75 | 71 | assert( v2 = getVal2() ) |
76 | 72 | assert( v3 = getVal3() ) |
77 | | - assert( m1 = *getMsg1() ) |
78 | 73 | #endmacro |
79 | 74 |
|
| 75 | +#ifdef DOTEST |
| 76 | + |
80 | 77 | '' enable results for ctor/dtor/copy-ctor/let |
81 | 78 | setInitial( 1 ) |
82 | 79 |
|
@@ -152,7 +149,7 @@ scope |
152 | 149 | dim as UDT b = 11 |
153 | 150 | dim as UDT c |
154 | 151 | resetChecks() |
155 | | - c = a + b |
| 152 | + c = (a + b) |
156 | 153 | checkResults( @a, @b, 3, 11, 14, "UDT operator+( UDT const& lhs, UDT const& rhs )" ) |
157 | 154 | end scope |
158 | 155 |
|
@@ -186,5 +183,4 @@ scope |
186 | 183 | checkResults( @a, @b, 17, 5, 12, "UDT operator-( int const& lhs, UDT const& rhs )" ) |
187 | 184 | end scope |
188 | 185 |
|
189 | | -#endif |
190 | | - |
| 186 | +#endif '' DOTEST |
0 commit comments