| 1 | #include "datatypes.h" |
| 2 | |
| 3 | |
| 4 | //=========================================================================== |
| 5 | std::vector<EFruit> vecFruits{kCitrus, kApple}; |
| 6 | |
| 7 | |
| 8 | //=========================================================================== |
| 9 | CppyyTestData::CppyyTestData() : m_const_int(17), m_owns_arrays(false) |
| 10 | { |
| 11 | m_bool = false; |
| 12 | m_char = 'a'; |
| 13 | m_schar = 'b'; |
| 14 | m_uchar = 'c'; |
| 15 | m_wchar = L'D'; |
| 16 | m_char16 = u'\u00df'; |
| 17 | m_char32 = U'\u00df'; |
| 18 | #if __cplusplus > 201402L |
| 19 | m_byte = (std::byte)'d'; |
| 20 | #endif |
| 21 | m_int8 = -9; |
| 22 | m_uint8 = 9; |
| 23 | m_short = -11; |
| 24 | m_ushort = 11u; |
| 25 | m_int = -22; |
| 26 | m_uint = 22u; |
| 27 | m_long = -33l; |
| 28 | m_ulong = 33ul; |
| 29 | m_llong = -44ll; |
| 30 | m_ullong = 44ull; |
| 31 | m_long64 = -55ll; |
| 32 | m_ulong64 = 55ull; |
| 33 | m_float = -66.f; |
| 34 | m_double = -77.; |
| 35 | m_ldouble = -88.l; |
| 36 | m_complex = {99., 101.}; |
| 37 | m_icomplex = {121, 141}; |
| 38 | m_enum = kNothing; |
| 39 | m_voidp = (void*)0; |
| 40 | |
| 41 | m_bool_array2 = new bool[N]; |
| 42 | m_schar_array2 = new signed char[N]; |
| 43 | m_uchar_array2 = new unsigned char[N]; |
| 44 | #if __cplusplus > 201402L |
| 45 | m_byte_array2 = new std::byte[N]; |
| 46 | #endif |
| 47 | m_short_array2 = new short[N]; |
| 48 | m_ushort_array2 = new unsigned short[N]; |
| 49 | m_int_array2 = new int[N]; |
| 50 | m_uint_array2 = new unsigned int[N]; |
| 51 | m_long_array2 = new long[N]; |
| 52 | m_ulong_array2 = new unsigned long[N]; |
| 53 | |
| 54 | m_float_array2 = new float[N]; |
| 55 | m_double_array2 = new double[N]; |
| 56 | m_complex_array2 = new complex_t[N]; |
| 57 | |
| 58 | for (int i = 0; i < N; ++i) { |
| 59 | m_bool_array[i] = bool(i%2); |
| 60 | m_bool_array2[i] = bool((i+1)%2); |
| 61 | m_uchar_array[i] = 1u*i; |
| 62 | m_uchar_array2[i] = 2u*i; |
| 63 | #if __cplusplus > 201402L |
| 64 | m_byte_array[i] = (std::byte)(3u*i); |
| 65 | m_byte_array2[i] = (std::byte)(4u*i); |
| 66 | #endif |
| 67 | m_short_array[i] = -1*i; |
| 68 | m_short_array2[i] = -2*i; |
| 69 | m_ushort_array[i] = 3u*i; |
| 70 | m_ushort_array2[i] = 4u*i; |
| 71 | m_int_array[i] = -5*i; |
| 72 | m_int_array2[i] = -6*i; |
| 73 | m_uint_array[i] = 7u*i; |
| 74 | m_uint_array2[i] = 8u*i; |
| 75 | m_long_array[i] = -9l*i; |
| 76 | m_long_array2[i] = -10l*i; |
| 77 | m_ulong_array[i] = 11ul*i; |
| 78 | m_ulong_array2[i] = 12ul*i; |
| 79 | |
| 80 | m_float_array[i] = -13.f*i; |
| 81 | m_float_array2[i] = -14.f*i; |
| 82 | m_double_array[i] = -15.*i; |
| 83 | m_double_array2[i] = -16.*i; |
| 84 | m_complex_array2[i] = {17.*i, 18.*i}; |
| 85 | } |
| 86 | |
| 87 | m_owns_arrays = true; |
| 88 | |
| 89 | m_pod.m_int = 888; |
| 90 | m_pod.m_double = 3.14; |
| 91 | |
| 92 | m_ppod = &m_pod; |
| 93 | }; |
| 94 | |
| 95 | CppyyTestData::~CppyyTestData() |
| 96 | { |
| 97 | destroy_arrays(); |
| 98 | } |
| 99 | |
| 100 | void CppyyTestData::destroy_arrays() { |
| 101 | if (m_owns_arrays == true) { |
| 102 | delete[] m_bool_array2; |
| 103 | delete[] m_uchar_array2; |
| 104 | #if __cplusplus > 201402L |
| 105 | delete[] m_byte_array2; |
| 106 | #endif |
| 107 | delete[] m_short_array2; |
| 108 | delete[] m_ushort_array2; |
| 109 | delete[] m_int_array2; |
| 110 | delete[] m_uint_array2; |
| 111 | delete[] m_long_array2; |
| 112 | delete[] m_ulong_array2; |
| 113 | |
| 114 | delete[] m_float_array2; |
| 115 | delete[] m_double_array2; |
| 116 | delete[] m_complex_array2; |
| 117 | |
| 118 | m_owns_arrays = false; |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | //- getters ----------------------------------------------------------------- |
| 123 | bool CppyyTestData::get_bool() { return m_bool; } |
| 124 | char CppyyTestData::get_char() { return m_char; } |
| 125 | signed char CppyyTestData::get_schar() { return m_schar; } |
| 126 | unsigned char CppyyTestData::get_uchar() { return m_uchar; } |
| 127 | wchar_t CppyyTestData::get_wchar() { return m_wchar; } |
| 128 | char16_t CppyyTestData::get_char16() { return m_char16; } |
| 129 | char32_t CppyyTestData::get_char32() { return m_char32; } |
| 130 | #if __cplusplus > 201402L |
| 131 | std::byte CppyyTestData::get_byte() { return m_byte; } |
| 132 | #endif |
| 133 | int8_t CppyyTestData::get_int8() { return m_int8; } |
| 134 | uint8_t CppyyTestData::get_uint8() { return m_uint8; } |
| 135 | short CppyyTestData::get_short() { return m_short; } |
| 136 | unsigned short CppyyTestData::get_ushort() { return m_ushort; } |
| 137 | int CppyyTestData::get_int() { return m_int; } |
| 138 | unsigned int CppyyTestData::get_uint() { return m_uint; } |
| 139 | long CppyyTestData::get_long() { return m_long; } |
| 140 | unsigned long CppyyTestData::get_ulong() { return m_ulong; } |
| 141 | long long CppyyTestData::get_llong() { return m_llong; } |
| 142 | unsigned long long CppyyTestData::get_ullong() { return m_ullong; } |
| 143 | Long64_t CppyyTestData::get_long64() { return m_long64; } |
| 144 | ULong64_t CppyyTestData::get_ulong64() { return m_ulong64; } |
| 145 | float CppyyTestData::get_float() { return m_float; } |
| 146 | double CppyyTestData::get_double() { return m_double; } |
| 147 | long double CppyyTestData::get_ldouble() { return m_ldouble; } |
| 148 | long double CppyyTestData::get_ldouble_def(long double ld) { return ld; } |
| 149 | complex_t CppyyTestData::get_complex() { return m_complex; } |
| 150 | icomplex_t CppyyTestData::get_icomplex() { return m_icomplex; } |
| 151 | CppyyTestData::EWhat CppyyTestData::get_enum() { return m_enum; } |
| 152 | void* CppyyTestData::get_voidp() { return m_voidp; } |
| 153 | |
| 154 | bool* CppyyTestData::get_bool_array() { return m_bool_array; } |
| 155 | bool* CppyyTestData::get_bool_array2() { return m_bool_array2; } |
| 156 | signed char* CppyyTestData::get_schar_array() { return m_schar_array; } |
| 157 | signed char* CppyyTestData::get_schar_array2() { return m_schar_array2; } |
| 158 | unsigned char* CppyyTestData::get_uchar_array() { return m_uchar_array; } |
| 159 | unsigned char* CppyyTestData::get_uchar_array2() { return m_uchar_array2; } |
| 160 | #if __cplusplus > 201402L |
| 161 | std::byte* CppyyTestData::get_byte_array() { return m_byte_array; } |
| 162 | std::byte* CppyyTestData::get_byte_array2() { return m_byte_array2; } |
| 163 | #endif |
| 164 | short* CppyyTestData::get_short_array() { return m_short_array; } |
| 165 | short* CppyyTestData::get_short_array2() { return m_short_array2; } |
| 166 | unsigned short* CppyyTestData::get_ushort_array() { return m_ushort_array; } |
| 167 | unsigned short* CppyyTestData::get_ushort_array2() { return m_ushort_array2; } |
| 168 | int* CppyyTestData::get_int_array() { return m_int_array; } |
| 169 | int* CppyyTestData::get_int_array2() { return m_int_array2; } |
| 170 | unsigned int* CppyyTestData::get_uint_array() { return m_uint_array; } |
| 171 | unsigned int* CppyyTestData::get_uint_array2() { return m_uint_array2; } |
| 172 | long* CppyyTestData::get_long_array() { return m_long_array; } |
| 173 | long* CppyyTestData::get_long_array2() { return m_long_array2; } |
| 174 | unsigned long* CppyyTestData::get_ulong_array() { return m_ulong_array; } |
| 175 | unsigned long* CppyyTestData::get_ulong_array2() { return m_ulong_array2; } |
| 176 | |
| 177 | float* CppyyTestData::get_float_array() { return m_float_array; } |
| 178 | float* CppyyTestData::get_float_array2() { return m_float_array2; } |
| 179 | double* CppyyTestData::get_double_array() { return m_double_array; } |
| 180 | double* CppyyTestData::get_double_array2() { return m_double_array2; } |
| 181 | complex_t* CppyyTestData::get_complex_array() { return m_complex_array; } |
| 182 | complex_t* CppyyTestData::get_complex_array2() { return m_complex_array2; } |
| 183 | |
| 184 | CppyyTestPod CppyyTestData::get_pod_val() { return m_pod; } |
| 185 | CppyyTestPod* CppyyTestData::get_pod_val_ptr() { return &m_pod; } |
| 186 | CppyyTestPod& CppyyTestData::get_pod_val_ref() { return m_pod; } |
| 187 | CppyyTestPod*& CppyyTestData::get_pod_ptrref() { return m_ppod; } |
| 188 | |
| 189 | CppyyTestPod* CppyyTestData::get_pod_ptr() { return m_ppod; } |
| 190 | |
| 191 | //- getters const-ref ------------------------------------------------------- |
| 192 | const bool& CppyyTestData::get_bool_cr() { return m_bool; } |
| 193 | const char& CppyyTestData::get_char_cr() { return m_char; } |
| 194 | const signed char& CppyyTestData::get_schar_cr() { return m_schar; } |
| 195 | const unsigned char& CppyyTestData::get_uchar_cr() { return m_uchar; } |
| 196 | const wchar_t& CppyyTestData::get_wchar_cr() { return m_wchar; } |
| 197 | const char16_t& CppyyTestData::get_char16_cr() { return m_char16; } |
| 198 | const char32_t& CppyyTestData::get_char32_cr() { return m_char32; } |
| 199 | #if __cplusplus > 201402L |
| 200 | const std::byte& CppyyTestData::get_byte_cr() { return m_byte; } |
| 201 | #endif |
| 202 | const int8_t& CppyyTestData::get_int8_cr() { return m_int8; } |
| 203 | const uint8_t& CppyyTestData::get_uint8_cr() { return m_uint8; } |
| 204 | const short& CppyyTestData::get_short_cr() { return m_short; } |
| 205 | const unsigned short& CppyyTestData::get_ushort_cr() { return m_ushort; } |
| 206 | const int& CppyyTestData::get_int_cr() { return m_int; } |
| 207 | const unsigned int& CppyyTestData::get_uint_cr() { return m_uint; } |
| 208 | const long& CppyyTestData::get_long_cr() { return m_long; } |
| 209 | const unsigned long& CppyyTestData::get_ulong_cr() { return m_ulong; } |
| 210 | const long long& CppyyTestData::get_llong_cr() { return m_llong; } |
| 211 | const unsigned long long& CppyyTestData::get_ullong_cr() { return m_ullong; } |
| 212 | const Long64_t& CppyyTestData::get_long64_cr() { return m_long64; } |
| 213 | const ULong64_t& CppyyTestData::get_ulong64_cr() { return m_ulong64; } |
| 214 | const float& CppyyTestData::get_float_cr() { return m_float; } |
| 215 | const double& CppyyTestData::get_double_cr() { return m_double; } |
| 216 | const long double& CppyyTestData::get_ldouble_cr() { return m_ldouble; } |
| 217 | const complex_t& CppyyTestData::get_complex_cr() { return m_complex; } |
| 218 | const icomplex_t& CppyyTestData::get_icomplex_cr() { return m_icomplex; } |
| 219 | const CppyyTestData::EWhat& CppyyTestData::get_enum_cr() { return m_enum; } |
| 220 | |
| 221 | //- getters ref ------------------------------------------------------------- |
| 222 | bool& CppyyTestData::get_bool_r() { return m_bool; } |
| 223 | char& CppyyTestData::get_char_r() { return m_char; } |
| 224 | signed char& CppyyTestData::get_schar_r() { return m_schar; } |
| 225 | unsigned char& CppyyTestData::get_uchar_r() { return m_uchar; } |
| 226 | wchar_t& CppyyTestData::get_wchar_r() { return m_wchar; } |
| 227 | char16_t& CppyyTestData::get_char16_r() { return m_char16; } |
| 228 | char32_t& CppyyTestData::get_char32_r() { return m_char32; } |
| 229 | #if __cplusplus > 201402L |
| 230 | std::byte& CppyyTestData::get_byte_r() { return m_byte; } |
| 231 | #endif |
| 232 | int8_t& CppyyTestData::get_int8_r() { return m_int8; } |
| 233 | uint8_t& CppyyTestData::get_uint8_r() { return m_uint8; } |
| 234 | short& CppyyTestData::get_short_r() { return m_short; } |
| 235 | unsigned short& CppyyTestData::get_ushort_r() { return m_ushort; } |
| 236 | int& CppyyTestData::get_int_r() { return m_int; } |
| 237 | unsigned int& CppyyTestData::get_uint_r() { return m_uint; } |
| 238 | long& CppyyTestData::get_long_r() { return m_long; } |
| 239 | unsigned long& CppyyTestData::get_ulong_r() { return m_ulong; } |
| 240 | long long& CppyyTestData::get_llong_r() { return m_llong; } |
| 241 | unsigned long long& CppyyTestData::get_ullong_r() { return m_ullong; } |
| 242 | Long64_t& CppyyTestData::get_long64_r() { return m_long64; } |
| 243 | ULong64_t& CppyyTestData::get_ulong64_r() { return m_ulong64; } |
| 244 | float& CppyyTestData::get_float_r() { return m_float; } |
| 245 | double& CppyyTestData::get_double_r() { return m_double; } |
| 246 | long double& CppyyTestData::get_ldouble_r() { return m_ldouble; } |
| 247 | complex_t& CppyyTestData::get_complex_r() { return m_complex; } |
| 248 | icomplex_t& CppyyTestData::get_icomplex_r() { return m_icomplex; } |
| 249 | CppyyTestData::EWhat& CppyyTestData::get_enum_r() { return m_enum; } |
| 250 | |
| 251 | //- setters ----------------------------------------------------------------- |
| 252 | void CppyyTestData::set_bool(bool b) { m_bool = b; } |
| 253 | void CppyyTestData::set_char(char c) { m_char = c; } |
| 254 | void CppyyTestData::set_schar(signed char sc) { m_schar = sc; } |
| 255 | void CppyyTestData::set_uchar(unsigned char uc) { m_uchar = uc; } |
| 256 | void CppyyTestData::set_wchar(wchar_t wc) { m_wchar = wc; } |
| 257 | void CppyyTestData::set_char16(char16_t c16) { m_char16 = c16; } |
| 258 | void CppyyTestData::set_char32(char32_t c32) { m_char32 = c32; } |
| 259 | #if __cplusplus > 201402L |
| 260 | void CppyyTestData::set_byte(std::byte b) { m_byte = b; } |
| 261 | #endif |
| 262 | void CppyyTestData::set_int8(int8_t s8) { m_int8 = s8; } |
| 263 | void CppyyTestData::set_uint8(uint8_t u8) { m_uint8 = u8; } |
| 264 | void CppyyTestData::set_short(short s) { m_short = s; } |
| 265 | void CppyyTestData::set_ushort(unsigned short us) { m_ushort = us; } |
| 266 | void CppyyTestData::set_int(int i) { m_int = i; } |
| 267 | void CppyyTestData::set_uint(unsigned int ui) { m_uint = ui; } |
| 268 | void CppyyTestData::set_long(long l) { m_long = l; } |
| 269 | void CppyyTestData::set_ulong(unsigned long ul) { m_ulong = ul; } |
| 270 | void CppyyTestData::set_llong(long long ll) { m_llong = ll; } |
| 271 | void CppyyTestData::set_ullong(unsigned long long ull) { m_ullong = ull; } |
| 272 | void CppyyTestData::set_long64(Long64_t l64) { m_long64 = l64; } |
| 273 | void CppyyTestData::set_ulong64(ULong64_t ul64) { m_ulong64 = ul64; } |
| 274 | void CppyyTestData::set_float(float f) { m_float = f; } |
| 275 | void CppyyTestData::set_double(double d) { m_double = d; } |
| 276 | void CppyyTestData::set_ldouble(long double ld) { m_ldouble = ld; } |
| 277 | void CppyyTestData::set_complex(complex_t cd) { m_complex = cd; } |
| 278 | void CppyyTestData::set_icomplex(icomplex_t ci) { m_icomplex = ci; } |
| 279 | void CppyyTestData::set_enum(EWhat w) { m_enum = w; } |
| 280 | void CppyyTestData::set_voidp(void* p) { m_voidp = p; } |
| 281 | |
| 282 | void CppyyTestData::set_pod_val(CppyyTestPod p) { m_pod = p; } |
| 283 | void CppyyTestData::set_pod_ptr_in(CppyyTestPod* pp) { m_pod = *pp; } |
| 284 | void CppyyTestData::set_pod_ptr_out(CppyyTestPod* pp) { *pp = m_pod; } |
| 285 | void CppyyTestData::set_pod_ref(const CppyyTestPod& rp) { m_pod = rp; } |
| 286 | void CppyyTestData::set_pod_ptrptr_in(CppyyTestPod** ppp) { m_pod = **ppp; } |
| 287 | void CppyyTestData::set_pod_void_ptrptr_in(void** pp) { m_pod = **((CppyyTestPod**)pp); } |
| 288 | void CppyyTestData::set_pod_ptrptr_out(CppyyTestPod** ppp) { delete *ppp; *ppp = new CppyyTestPod(m_pod); } |
| 289 | void CppyyTestData::set_pod_void_ptrptr_out(void** pp) { delete *((CppyyTestPod**)pp); |
| 290 | *((CppyyTestPod**)pp) = new CppyyTestPod(m_pod); } |
| 291 | |
| 292 | void CppyyTestData::set_pod_ptr(CppyyTestPod* pp) { m_ppod = pp; } |
| 293 | |
| 294 | //- setters const-ref ------------------------------------------------------- |
| 295 | void CppyyTestData::set_bool_cr(const bool& b) { m_bool = b; } |
| 296 | void CppyyTestData::set_char_cr(const char& c) { m_char = c; } |
| 297 | void CppyyTestData::set_schar_cr(const signed char& sc) { m_schar = sc; } |
| 298 | void CppyyTestData::set_uchar_cr(const unsigned char& uc) { m_uchar = uc; } |
| 299 | void CppyyTestData::set_wchar_cr(const wchar_t& wc) { m_wchar = wc; } |
| 300 | void CppyyTestData::set_char16_cr(const char16_t& c16) { m_char16 = c16; } |
| 301 | void CppyyTestData::set_char32_cr(const char32_t& c32) { m_char32 = c32; } |
| 302 | #if __cplusplus > 201402L |
| 303 | void CppyyTestData::set_byte_cr(const std::byte& b) { m_byte = b; } |
| 304 | #endif |
| 305 | void CppyyTestData::set_int8_cr(const int8_t& s8) { m_int8 = s8; } |
| 306 | void CppyyTestData::set_uint8_cr(const uint8_t& u8) { m_uint8 = u8; } |
| 307 | void CppyyTestData::set_short_cr(const short& s) { m_short = s; } |
| 308 | void CppyyTestData::set_ushort_cr(const unsigned short& us) { m_ushort = us; } |
| 309 | void CppyyTestData::set_int_cr(const int& i) { m_int = i; } |
| 310 | void CppyyTestData::set_uint_cr(const unsigned int& ui) { m_uint = ui; } |
| 311 | void CppyyTestData::set_long_cr(const long& l) { m_long = l; } |
| 312 | void CppyyTestData::set_ulong_cr(const unsigned long& ul) { m_ulong = ul; } |
| 313 | void CppyyTestData::set_llong_cr(const long long& ll) { m_llong = ll; } |
| 314 | void CppyyTestData::set_ullong_cr(const unsigned long long& ull) { m_ullong = ull; } |
| 315 | void CppyyTestData::set_long64_cr(const Long64_t& l64) { m_long64 = l64; } |
| 316 | void CppyyTestData::set_ulong64_cr(const ULong64_t& ul64) { m_ulong64 = ul64; } |
| 317 | void CppyyTestData::set_float_cr(const float& f) { m_float = f; } |
| 318 | void CppyyTestData::set_double_cr(const double& d) { m_double = d; } |
| 319 | void CppyyTestData::set_ldouble_cr(const long double& ld) { m_ldouble = ld; } |
| 320 | void CppyyTestData::set_complex_cr(const complex_t& cd) { m_complex = cd; } |
| 321 | void CppyyTestData::set_icomplex_cr(const icomplex_t& ci) { m_icomplex = ci; } |
| 322 | void CppyyTestData::set_enum_cr(const EWhat& w) { m_enum = w; } |
| 323 | |
| 324 | //- setters ref ------------------------------------------------------------- |
| 325 | void CppyyTestData::set_bool_r(bool& b) { b = true; } |
| 326 | void CppyyTestData::set_char_r(char& c) { c = 'a'; } |
| 327 | void CppyyTestData::set_wchar_r(wchar_t& wc) { wc = 'b'; } |
| 328 | void CppyyTestData::set_char16_r(char16_t& c16) { c16 = u'\u6c24'; } |
| 329 | void CppyyTestData::set_char32_r(char32_t& c32) { c32 = U'\U0001f34e'; } |
| 330 | void CppyyTestData::set_schar_r(signed char& sc) { sc = 'c'; } |
| 331 | void CppyyTestData::set_uchar_r(unsigned char& uc) { uc = 'd'; } |
| 332 | #if __cplusplus > 201402L |
| 333 | void CppyyTestData::set_byte_r(std::byte& b) { b = (std::byte)'e'; } |
| 334 | #endif |
| 335 | void CppyyTestData::set_short_r(short& s) { s = -1; } |
| 336 | void CppyyTestData::set_ushort_r(unsigned short& us) { us = 2; } |
| 337 | void CppyyTestData::set_int_r(int& i) { i = -3; } |
| 338 | void CppyyTestData::set_uint_r(unsigned int& ui) { ui = 4; } |
| 339 | void CppyyTestData::set_long_r(long& l) { l = -5; } |
| 340 | void CppyyTestData::set_ulong_r(unsigned long& ul) { ul = 6; } |
| 341 | void CppyyTestData::set_llong_r(long long& ll) { ll = -7; } |
| 342 | void CppyyTestData::set_ullong_r(unsigned long long& ull) { ull = 8; } |
| 343 | void CppyyTestData::set_float_r(float& f) { f = 5.f; } |
| 344 | void CppyyTestData::set_double_r(double& d) { d = -5.; } |
| 345 | void CppyyTestData::set_ldouble_r(long double& ld) { ld = 10.l; } |
| 346 | |
| 347 | //- setters ptr ------------------------------------------------------------- |
| 348 | void CppyyTestData::set_bool_p(bool* b) { *b = true; } |
| 349 | void CppyyTestData::set_char_p(char* c) { *c = 'a'; } |
| 350 | void CppyyTestData::set_wchar_p(wchar_t* wc) { *wc = 'b'; } |
| 351 | void CppyyTestData::set_char16_p(char16_t* c16) { *c16 = u'\u6c24'; } |
| 352 | void CppyyTestData::set_char32_p(char32_t* c32) { *c32 = U'\U0001f34e'; } |
| 353 | void CppyyTestData::set_schar_p(signed char* sc) { *sc = 'c'; } |
| 354 | void CppyyTestData::set_uchar_p(unsigned char* uc) { *uc = 'd'; } |
| 355 | #if __cplusplus > 201402L |
| 356 | void CppyyTestData::set_byte_p(std::byte* b) { *b = (std::byte)'e'; } |
| 357 | #endif |
| 358 | void CppyyTestData::set_short_p(short* s) { *s = -1; } |
| 359 | void CppyyTestData::set_ushort_p(unsigned short* us) { *us = 2; } |
| 360 | void CppyyTestData::set_int_p(int* i) { *i = -3; } |
| 361 | void CppyyTestData::set_uint_p(unsigned int* ui) { *ui = 4; } |
| 362 | void CppyyTestData::set_long_p(long* l) { *l = -5; } |
| 363 | void CppyyTestData::set_ulong_p(unsigned long* ul) { *ul = 6; } |
| 364 | void CppyyTestData::set_llong_p(long long* ll) { *ll = -7; } |
| 365 | void CppyyTestData::set_ullong_p(unsigned long long* ull) { *ull = 8; } |
| 366 | void CppyyTestData::set_float_p(float* f) { *f = 5.f; } |
| 367 | void CppyyTestData::set_double_p(double* d) { *d = -5.; } |
| 368 | void CppyyTestData::set_ldouble_p(long double* ld) { *ld = 10.l; } |
| 369 | |
| 370 | //- setters ptrptr ---------------------------------------------------------- |
| 371 | void CppyyTestData::set_bool_ppa(bool** b) { |
| 372 | (*b) = new bool[3]; |
| 373 | (*b)[0] = true; (*b)[1] = false; (*b)[2] = true; |
| 374 | } |
| 375 | void CppyyTestData::set_char_ppa(char** c) { |
| 376 | (*c) = new char[3]; |
| 377 | (*c)[0] = 'a'; (*c)[1] = 'b'; (*c)[2] = 'c'; |
| 378 | } |
| 379 | void CppyyTestData::set_wchar_ppa(wchar_t** wc) { |
| 380 | (*wc) = new wchar_t[3]; |
| 381 | (*wc)[0] = 'd'; (*wc)[1] = 'e'; (*wc)[2] = 'f'; |
| 382 | } |
| 383 | void CppyyTestData::set_char16_ppa(char16_t** c16) { |
| 384 | (*c16) = new char16_t[3]; |
| 385 | (*c16)[0] = u'\u6c24'; (*c16)[1] = u'\u6c25'; (*c16)[2] = u'\u6c26'; |
| 386 | } |
| 387 | void CppyyTestData::set_char32_ppa(char32_t** c32) { |
| 388 | (*c32) = new char32_t[3]; |
| 389 | (*c32)[0] = U'\U0001f34d'; (*c32)[1] = U'\U0001f34e'; (*c32)[2] = U'\U0001f34f'; |
| 390 | } |
| 391 | void CppyyTestData::set_schar_ppa(signed char** sc) { |
| 392 | (*sc) = new signed char[3]; |
| 393 | (*sc)[0] = 'g'; (*sc)[1] = 'h'; (*sc)[2] = 'j'; |
| 394 | } |
| 395 | void CppyyTestData::set_uchar_ppa(unsigned char** uc) { |
| 396 | (*uc) = new unsigned char[3]; |
| 397 | (*uc)[0] = 'k'; (*uc)[1] = 'l'; (*uc)[2] = 'm'; |
| 398 | } |
| 399 | #if __cplusplus > 201402L |
| 400 | void CppyyTestData::set_byte_ppa(std::byte** b) { |
| 401 | (*b) = new std::byte[3]; |
| 402 | (*b)[0] = (std::byte)'n'; (*b)[1] = (std::byte)'o'; (*b)[2] = (std::byte)'p'; |
| 403 | } |
| 404 | #endif |
| 405 | void CppyyTestData::set_short_ppa(short** s) { |
| 406 | (*s) = new short[3]; |
| 407 | (*s)[0] = -1; (*s)[1] = -2; (*s)[2] = -3; |
| 408 | } |
| 409 | void CppyyTestData::set_ushort_ppa(unsigned short** us) { |
| 410 | (*us) = new unsigned short[3]; |
| 411 | (*us)[0] = 4; (*us)[1] = 5; (*us)[2] = 6; |
| 412 | } |
| 413 | void CppyyTestData::set_int_ppa(int** i) { |
| 414 | (*i) = new int[3]; |
| 415 | (*i)[0] = -7; (*i)[1] = -8; (*i)[2] = -9; |
| 416 | } |
| 417 | void CppyyTestData::set_uint_ppa(unsigned int** ui) { |
| 418 | (*ui) = new unsigned int[3]; |
| 419 | (*ui)[0] = 10; (*ui)[1] = 11; (*ui)[2] = 12; |
| 420 | } |
| 421 | void CppyyTestData::set_long_ppa(long** l) { |
| 422 | (*l) = new long[3]; |
| 423 | (*l)[0] = -13; (*l)[1] = -14; (*l)[2] = -15; |
| 424 | } |
| 425 | void CppyyTestData::set_ulong_ppa(unsigned long** ul) { |
| 426 | (*ul) = new unsigned long[3]; |
| 427 | (*ul)[0] = 16; (*ul)[1] = 17; (*ul)[2] = 18; |
| 428 | } |
| 429 | void CppyyTestData::set_llong_ppa(long long** ll) { |
| 430 | (*ll) = new long long[3]; |
| 431 | (*ll)[0] = -19; (*ll)[1] = -20; (*ll)[2] = -21; |
| 432 | } |
| 433 | void CppyyTestData::set_ullong_ppa(unsigned long long** ull) { |
| 434 | (*ull) = new unsigned long long[3]; |
| 435 | (*ull)[0] = 22; (*ull)[1] = 23; (*ull)[2] = 24; |
| 436 | } |
| 437 | void CppyyTestData::set_float_ppa(float** f) { |
| 438 | (*f) = new float[3]; |
| 439 | (*f)[0] = 5.f; (*f)[1] = 10.f; (*f)[2] = 20.f; |
| 440 | } |
| 441 | void CppyyTestData::set_double_ppa(double** d) { |
| 442 | (*d) = new double[3]; |
| 443 | (*d)[0] = -5; (*d)[1] = -10.; (*d)[2] = -20.; |
| 444 | } |
| 445 | void CppyyTestData::set_ldouble_ppa(long double** ld) { |
| 446 | (*ld) = new long double[3]; |
| 447 | (*ld)[0] = 5.l; (*ld)[1] = 10.f; (*ld)[2] = 20.l; |
| 448 | } |
| 449 | |
| 450 | intptr_t CppyyTestData::set_char_ppm(char** c) { |
| 451 | *c = (char*)malloc(4*sizeof(char)); |
| 452 | return (intptr_t)*c; |
| 453 | } |
| 454 | intptr_t CppyyTestData::set_cchar_ppm(const char** cc) { |
| 455 | *cc = (const char*)malloc(4*sizeof(char)); |
| 456 | return (intptr_t)*cc; |
| 457 | } |
| 458 | intptr_t CppyyTestData::set_wchar_ppm(wchar_t** w) { |
| 459 | *w = (wchar_t*)malloc(4*sizeof(wchar_t)); |
| 460 | return (intptr_t)*w; |
| 461 | } |
| 462 | intptr_t CppyyTestData::set_char16_ppm(char16_t** c16) { |
| 463 | *c16 = (char16_t*)malloc(4*sizeof(char16_t)); |
| 464 | return (intptr_t)*c16; |
| 465 | } |
| 466 | intptr_t CppyyTestData::set_char32_ppm(char32_t** c32) { |
| 467 | *c32 = (char32_t*)malloc(4*sizeof(char32_t)); |
| 468 | return (intptr_t)*c32; |
| 469 | } |
| 470 | intptr_t CppyyTestData::set_cwchar_ppm(const wchar_t** cw) { |
| 471 | *cw = (const wchar_t*)malloc(4*sizeof(wchar_t)); |
| 472 | return (intptr_t)*cw; |
| 473 | } |
| 474 | intptr_t CppyyTestData::set_cchar16_ppm(const char16_t** c16) { |
| 475 | *c16 = (const char16_t*)malloc(4*sizeof(char16_t)); |
| 476 | return (intptr_t)*c16; |
| 477 | } |
| 478 | intptr_t CppyyTestData::set_cchar32_ppm(const char32_t** c32) { |
| 479 | *c32 = (const char32_t*)malloc(4*sizeof(char32_t)); |
| 480 | return (intptr_t)*c32; |
| 481 | } |
| 482 | intptr_t CppyyTestData::set_void_ppm(void** v) { |
| 483 | *v = malloc(4*sizeof(void*)); |
| 484 | return (intptr_t)*v; |
| 485 | } |
| 486 | |
| 487 | intptr_t CppyyTestData::freeit(void* ptr) { |
| 488 | intptr_t out = (intptr_t)ptr; |
| 489 | free(ptr); |
| 490 | return out; |
| 491 | } |
| 492 | |
| 493 | //- setters r-value --------------------------------------------------------- |
| 494 | void CppyyTestData::set_bool_rv(bool&& b) { m_bool = b; } |
| 495 | void CppyyTestData::set_char_rv(char&& c) { m_char = c; } |
| 496 | void CppyyTestData::set_schar_rv(signed char&& sc) { m_schar = sc; } |
| 497 | void CppyyTestData::set_uchar_rv(unsigned char&& uc) { m_uchar = uc; } |
| 498 | void CppyyTestData::set_wchar_rv(wchar_t&& wc) { m_wchar = wc; } |
| 499 | void CppyyTestData::set_char16_rv(char16_t&& c16) { m_char16 = c16; } |
| 500 | void CppyyTestData::set_char32_rv(char32_t&& c32) { m_char32 = c32; } |
| 501 | #if __cplusplus > 201402L |
| 502 | void CppyyTestData::set_byte_rv(std::byte&& b) { m_byte = b; } |
| 503 | #endif |
| 504 | void CppyyTestData::set_int8_rv(int8_t&& s8) { m_int8 = s8; } |
| 505 | void CppyyTestData::set_uint8_rv(uint8_t&& u8) { m_uint8 = u8; } |
| 506 | void CppyyTestData::set_short_rv(short&& s) { m_short = s; } |
| 507 | void CppyyTestData::set_ushort_rv(unsigned short&& us) { m_ushort = us; } |
| 508 | void CppyyTestData::set_int_rv(int&& i) { m_int = i; } |
| 509 | void CppyyTestData::set_uint_rv(unsigned int&& ui) { m_uint = ui; } |
| 510 | void CppyyTestData::set_long_rv(long&& l) { m_long = l; } |
| 511 | void CppyyTestData::set_ulong_rv(unsigned long&& ul) { m_ulong = ul; } |
| 512 | void CppyyTestData::set_llong_rv(long long&& ll) { m_llong = ll; } |
| 513 | void CppyyTestData::set_ullong_rv(unsigned long long&& ull) { m_ullong = ull; } |
| 514 | void CppyyTestData::set_long64_rv(Long64_t&& l64) { m_long64 = l64; } |
| 515 | void CppyyTestData::set_ulong64_rv(ULong64_t&& ul64) { m_ulong64 = ul64; } |
| 516 | void CppyyTestData::set_float_rv(float&& f) { m_float = f; } |
| 517 | void CppyyTestData::set_double_rv(double&& d) { m_double = d; } |
| 518 | void CppyyTestData::set_ldouble_rv(long double&& ld) { m_ldouble = ld; } |
| 519 | void CppyyTestData::set_complex_rv(complex_t&& cd) { m_complex = cd; } |
| 520 | void CppyyTestData::set_icomplex_rv(icomplex_t&& ci) { m_icomplex = ci; } |
| 521 | void CppyyTestData::set_enum_rv(EWhat&& w) { m_enum = w; } |
| 522 | |
| 523 | //- passers ----------------------------------------------------------------- |
| 524 | unsigned char* CppyyTestData::pass_array(unsigned char* a) { return a; } |
| 525 | short* CppyyTestData::pass_array(short* a) { return a; } |
| 526 | unsigned short* CppyyTestData::pass_array(unsigned short* a) { return a; } |
| 527 | int* CppyyTestData::pass_array(int* a) { return a; } |
| 528 | unsigned int* CppyyTestData::pass_array(unsigned int* a) { return a; } |
| 529 | long* CppyyTestData::pass_array(long* a) { return a; } |
| 530 | unsigned long* CppyyTestData::pass_array(unsigned long* a) { return a; } |
| 531 | float* CppyyTestData::pass_array(float* a) { return a; } |
| 532 | double* CppyyTestData::pass_array(double* a) { return a; } |
| 533 | complex_t* CppyyTestData::pass_array(complex_t* a) { return a; } |
| 534 | |
| 535 | //- static data members ----------------------------------------------------- |
| 536 | bool CppyyTestData::s_bool = false; |
| 537 | char CppyyTestData::s_char = 'c'; |
| 538 | signed char CppyyTestData::s_schar = 's'; |
| 539 | unsigned char CppyyTestData::s_uchar = 'u'; |
| 540 | wchar_t CppyyTestData::s_wchar = L'U'; |
| 541 | char16_t CppyyTestData::s_char16 = u'\u6c29'; |
| 542 | char32_t CppyyTestData::s_char32 = U'\U0001f34b'; |
| 543 | #if __cplusplus > 201402L |
| 544 | std::byte CppyyTestData::s_byte = (std::byte)'b'; |
| 545 | #endif |
| 546 | int8_t CppyyTestData::s_int8 = - 87; |
| 547 | uint8_t CppyyTestData::s_uint8 = 87; |
| 548 | short CppyyTestData::s_short = -101; |
| 549 | unsigned short CppyyTestData::s_ushort = 255u; |
| 550 | int CppyyTestData::s_int = -202; |
| 551 | unsigned int CppyyTestData::s_uint = 202u; |
| 552 | long CppyyTestData::s_long = -303l; |
| 553 | unsigned long CppyyTestData::s_ulong = 303ul; |
| 554 | long long CppyyTestData::s_llong = -404ll; |
| 555 | unsigned long long CppyyTestData::s_ullong = 404ull; |
| 556 | Long64_t CppyyTestData::s_long64 = -505ll; |
| 557 | ULong64_t CppyyTestData::s_ulong64 = 505ull; |
| 558 | float CppyyTestData::s_float = -606.f; |
| 559 | double CppyyTestData::s_double = -707.; |
| 560 | long double CppyyTestData::s_ldouble = -808.l; |
| 561 | complex_t CppyyTestData::s_complex = {909., -909.}; |
| 562 | icomplex_t CppyyTestData::s_icomplex = {979, -979}; |
| 563 | CppyyTestData::EWhat CppyyTestData::s_enum = CppyyTestData::kNothing; |
| 564 | void* CppyyTestData::s_voidp = (void*)0; |
| 565 | std::string CppyyTestData::s_strv = "Hello"; |
| 566 | std::string* CppyyTestData::s_strp = nullptr; |
| 567 | |
| 568 | //- strings ----------------------------------------------------------------- |
| 569 | const char* CppyyTestData::get_valid_string(const char* in) { return in; } |
| 570 | const char* CppyyTestData::get_invalid_string() { return (const char*)0; } |
| 571 | const wchar_t* CppyyTestData::get_valid_wstring(const wchar_t* in) { return in; } |
| 572 | const wchar_t* CppyyTestData::get_invalid_wstring() { return (const wchar_t*)0; } |
| 573 | const char16_t* CppyyTestData::get_valid_string16(const char16_t* in) { return in; } |
| 574 | const char16_t* CppyyTestData::get_invalid_string16() { return (const char16_t*)0; } |
| 575 | const char32_t* CppyyTestData::get_valid_string32(const char32_t* in) { return in; } |
| 576 | const char32_t* CppyyTestData::get_invalid_string32() { return (const char32_t*)0; } |
| 577 | |
| 578 | |
| 579 | //= global functions ======================================================== |
| 580 | intptr_t get_pod_address(CppyyTestData& c) |
| 581 | { |
| 582 | return (intptr_t)&c.m_pod; |
| 583 | } |
| 584 | |
| 585 | intptr_t get_int_address(CppyyTestData& c) |
| 586 | { |
| 587 | return (intptr_t)&c.m_pod.m_int; |
| 588 | } |
| 589 | |
| 590 | intptr_t get_double_address(CppyyTestData& c) |
| 591 | { |
| 592 | return (intptr_t)&c.m_pod.m_double; |
| 593 | } |
| 594 | |
| 595 | |
| 596 | //= global variables/pointers =============================================== |
| 597 | bool g_bool = false; |
| 598 | char g_char = 'w'; |
| 599 | signed char g_schar = 'v'; |
| 600 | unsigned char g_uchar = 'u'; |
| 601 | wchar_t g_wchar = L'U'; |
| 602 | char16_t g_char16 = u'\u6c21'; |
| 603 | char32_t g_char32 = U'\u6c21'; |
| 604 | #if __cplusplus > 201402L |
| 605 | std::byte g_byte = (std::byte)'x'; |
| 606 | #endif |
| 607 | int8_t g_int8 = -66; |
| 608 | uint8_t g_uint8 = 66; |
| 609 | short g_short = -88; |
| 610 | unsigned short g_ushort = 88u; |
| 611 | int g_int = -188; |
| 612 | unsigned int g_uint = 188u; |
| 613 | long g_long = -288; |
| 614 | unsigned long g_ulong = 288ul; |
| 615 | long long g_llong = -388ll; |
| 616 | unsigned long long g_ullong = 388ull; |
| 617 | Long64_t g_long64 = -488ll; |
| 618 | ULong64_t g_ulong64 = 488ull; |
| 619 | float g_float = -588.f; |
| 620 | double g_double = -688.; |
| 621 | long double g_ldouble = -788.l; |
| 622 | complex_t g_complex = {808., -808.}; |
| 623 | icomplex_t g_icomplex = {909, -909}; |
| 624 | EFruit g_enum = kBanana; |
| 625 | void* g_voidp = nullptr; |
| 626 | |
| 627 | |
| 628 | //= global accessors ======================================================== |
| 629 | void set_global_int(int i) { |
| 630 | g_int = i; |
| 631 | } |
| 632 | |
| 633 | int get_global_int() { |
| 634 | return g_int; |
| 635 | } |
| 636 | |
| 637 | CppyyTestPod* g_pod = (CppyyTestPod*)0; |
| 638 | |
| 639 | bool is_global_pod(CppyyTestPod* t) { |
| 640 | return t == g_pod; |
| 641 | } |
| 642 | |
| 643 | void set_global_pod(CppyyTestPod* t) { |
| 644 | g_pod = t; |
| 645 | } |
| 646 | |
| 647 | CppyyTestPod* get_global_pod() { |
| 648 | return g_pod; |
| 649 | } |
| 650 | |
| 651 | CppyyTestPod* get_null_pod() { |
| 652 | return (CppyyTestPod*)0; |
| 653 | } |
| 654 | |
| 655 | std::string g_some_global_string = "C++"; |
| 656 | std::string get_some_global_string() { return g_some_global_string; } |
| 657 | std::string g_some_global_string2 = "C++"; |
| 658 | std::string get_some_global_string2() { return g_some_global_string2; } |
| 659 | |
| 660 | const char16_t* g_some_global_string16 = u"z\u00df\u6c34"; |
| 661 | const char32_t* g_some_global_string32 = U"z\u00df\u6c34\U0001f34c"; |
| 662 | |
| 663 | std::string SomeStaticDataNS::s_some_static_string = "C++"; |
| 664 | std::string SomeStaticDataNS::get_some_static_string() { return s_some_static_string; } |
| 665 | std::string SomeStaticDataNS::s_some_static_string2 = "C++"; |
| 666 | std::string SomeStaticDataNS::get_some_static_string2() { return s_some_static_string2; } |
| 667 | |
| 668 | StorableData gData{5.}; |
| 669 | |
| 670 | |
| 671 | //= special case of "byte" arrays =========================================== |
| 672 | int64_t sum_uc_data(unsigned char* data, int size) |
| 673 | { |
| 674 | int64_t total = 0; |
| 675 | for (int i = 0; i < size; ++i) total += int64_t(data[i]); |
| 676 | return total; |
| 677 | } |
| 678 | |
| 679 | #if __cplusplus > 201402L |
| 680 | int64_t sum_byte_data(std::byte* data, int size) |
| 681 | { |
| 682 | return sum_uc_data((unsigned char*)data, size); |
| 683 | } |
| 684 | #endif |
| 685 | |
| 686 | |
| 687 | //= function pointer passing ================================================ |
| 688 | int sum_of_int1(int i1, int i2) { |
| 689 | return i1+i2; |
| 690 | } |
| 691 | |
| 692 | int sum_of_int2(int i1, int i2) { |
| 693 | return 2*i1+i2; |
| 694 | } |
| 695 | |
| 696 | int (*sum_of_int_ptr)(int, int) = sum_of_int1; |
| 697 | |
| 698 | int call_sum_of_int(int i1, int i2) { |
| 699 | if (sum_of_int_ptr) |
| 700 | return (*sum_of_int_ptr)(i1, i2); |
| 701 | return -1; |
| 702 | } |
| 703 | |
| 704 | double sum_of_double(double d1, double d2) { |
| 705 | return d1+d2; |
| 706 | } |
| 707 | |
| 708 | double call_double_double(double (*f)(double, double), double d1, double d2) { |
| 709 | if (!f) return -1.; |
| 710 | return f(d1, d2); |
| 711 | } |
| 712 | |
| 713 | |
| 714 | //= callable passing ======================================================== |
| 715 | int call_int_int(int (*f)(int, int), int i1, int i2) { |
| 716 | return f(i1, i2); |
| 717 | } |
| 718 | |
| 719 | void call_void(void (*f)(int), int i) { |
| 720 | f(i); |
| 721 | } |
| 722 | |
| 723 | int call_refi(void (*f)(int&)) { |
| 724 | int i = -1; f(i); return i; |
| 725 | } |
| 726 | |
| 727 | int call_refl(void (*f)(long&)) { |
| 728 | long l = -1L; f(l); return l; |
| 729 | } |
| 730 | |
| 731 | int call_refd(void (*f)(double&)) { |
| 732 | double d = -1.; f(d); return d; |
| 733 | } |
| 734 | |
| 735 | |
| 736 | StoreCallable::StoreCallable(double (*f)(double, double)) : fF(f) { |
| 737 | /* empty */ |
| 738 | } |
| 739 | |
| 740 | void StoreCallable::set_callable(double (*f)(double, double)) { |
| 741 | fF = f; |
| 742 | } |
| 743 | |
| 744 | double StoreCallable::operator()(double d1, double d2) { |
| 745 | return fF(d1, d2); |
| 746 | } |
| 747 | |
| 748 | //= callable through std::function ========================================== |
| 749 | double call_double_double_sf(const std::function<double(double, double)>& f, double d1, double d2) { |
| 750 | return f(d1, d2); |
| 751 | } |
| 752 | |
| 753 | int call_int_int_sf(const std::function<int(int, int)>& f, int i1, int i2) { |
| 754 | return f(i1, i2); |
| 755 | } |
| 756 | |
| 757 | void call_void_sf(const std::function<void(int)>& f, int i) { |
| 758 | f(i); |
| 759 | } |
| 760 | |
| 761 | int call_refi_sf(const std::function<void(int&)>& f) { |
| 762 | int i = -1; f(i); return i; |
| 763 | } |
| 764 | |
| 765 | int call_refl_sf(const std::function<void(long&)>& f) { |
| 766 | long l = -1L; f(l); return l; |
| 767 | } |
| 768 | |
| 769 | int call_refd_sf(const std::function<void(double&)>& f) { |
| 770 | double d = -1.; f(d); return d; |
| 771 | } |
| 772 | |
| 773 | |
| 774 | StoreCallable_sf::StoreCallable_sf(const std::function<double(double, double)>& f) : fF(f) { |
| 775 | /* empty */ |
| 776 | } |
| 777 | |
| 778 | void StoreCallable_sf::set_callable(const std::function<double(double, double)>& f) { |
| 779 | fF = f; |
| 780 | } |
| 781 | |
| 782 | double StoreCallable_sf::operator()(double d1, double d2) { |
| 783 | return fF(d1, d2); |
| 784 | } |
| 785 | |
| 786 | |
| 787 | //= array of C strings passing ============================================== |
| 788 | std::vector<std::string> ArrayOfCStrings::takes_array_of_cstrings(const char* args[], int len) |
| 789 | { |
| 790 | std::vector<std::string> v; |
| 791 | v.reserve(len); |
| 792 | for (int i = 0; i < len; ++i) |
| 793 | v.emplace_back(args[i]); |
| 794 | |
| 795 | return v; |
| 796 | } |
| 797 | |
| 798 | |
| 799 | //= aggregate testing ====================================================== |
| 800 | int AggregateTest::Aggregate1::sInt = 17; |
| 801 | int AggregateTest::Aggregate2::sInt = 27; |