| 1 | /***************************************************************************** |
| 2 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | you may not use this file except in compliance with the License. |
| 4 | You may obtain a copy of the License at |
| 5 | |
| 6 | http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | |
| 8 | Unless required by applicable law or agreed to in writing, software |
| 9 | distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | See the License for the specific language governing permissions and |
| 12 | limitations under the License. |
| 13 | |
| 14 | See NOTICE file for details. |
| 15 | *****************************************************************************/ |
| 16 | #include "jpype.h" |
| 17 | #include <math.h> |
| 18 | #include <bitset> |
| 19 | |
| 20 | namespace |
| 21 | { |
| 22 | |
| 23 | template <jvalue func(void *c) > |
| 24 | class Half |
| 25 | { |
| 26 | public: |
| 27 | static jvalue convert(void* c) |
| 28 | { |
| 29 | uint16_t i = *(uint16_t*) c; |
| 30 | uint32_t sign = (i&0x8000)>>15; |
| 31 | uint32_t exp = (i&0x7C00)>>10; |
| 32 | uint32_t frac = (i&0x03ff); |
| 33 | uint32_t k = sign<<31; |
| 34 | uint32_t count = (i&0x03ff); |
| 35 | |
| 36 | if (exp == 0) |
| 37 | { |
| 38 | // subnormal numbers |
| 39 | if (frac != 0) |
| 40 | { |
| 41 | count = count | (count >> 1); |
| 42 | count = count | (count >> 2); |
| 43 | count = count | (count >> 4); |
| 44 | count = count | (count >> 8); |
| 45 | int zeros = std::bitset<32>(~count).count(); |
| 46 | exp = 127-zeros+7; |
| 47 | exp <<= 23; |
| 48 | frac <<= zeros-8; |
| 49 | frac &= 0x7fffff; |
| 50 | k |= exp | frac; |
| 51 | } |
| 52 | } |
| 53 | else if (exp < 31) |
| 54 | { |
| 55 | // normal numbers |
| 56 | exp = exp-15+127; |
| 57 | exp <<= 23; |
| 58 | frac <<= 13; |
| 59 | k |= exp | frac; |
| 60 | } |
| 61 | else |
| 62 | { |
| 63 | // to infinity and beyond! |
| 64 | if (frac == 0) |
| 65 | k |= 0x7f800000; |
| 66 | else |
| 67 | k |= 0x7f800001 | ((frac&0x200)<<12); |
| 68 | } |
| 69 | return func(&k); |
| 70 | } |
| 71 | }; |
| 72 | |
| 73 | template <class T> |
| 74 | class Convert |
| 75 | { |
| 76 | public: |
| 77 | |
| 78 | static jvalue toZ(void* c) |
| 79 | { |
| 80 | jvalue v; |
| 81 | v.z = (*(T*) c) != 0; |
| 82 | return v; |
| 83 | } |
| 84 | |
| 85 | static jvalue toB(void* c) |
| 86 | { |
| 87 | jvalue v; |
| 88 | v.b = (jbyte) (*(T*) c); |
| 89 | return v; |
| 90 | } |
| 91 | |
| 92 | static jvalue toC(void* c) |
| 93 | { |
| 94 | jvalue v; |
| 95 | v.c = (jchar) (*(T*) c); |
| 96 | return v; |
| 97 | } |
| 98 | |
| 99 | static jvalue toS(void* c) |
| 100 | { |
| 101 | jvalue v; |
| 102 | v.s = (jshort) (*(T*) c); |
| 103 | return v; |
| 104 | } |
| 105 | |
| 106 | static jvalue toI(void* c) |
| 107 | { |
| 108 | jvalue v; |
| 109 | v.i = (jint) (*(T*) c); |
| 110 | return v; |
| 111 | } |
| 112 | |
| 113 | static jvalue toJ(void* c) |
| 114 | { |
| 115 | jvalue v; |
| 116 | v.j = (jlong) (*(T*) c); |
| 117 | return v; |
| 118 | } |
| 119 | |
| 120 | static jvalue toF(void* c) |
| 121 | { |
| 122 | jvalue v; |
| 123 | v.f = (jfloat) (*(T*) c); |
| 124 | return v; |
| 125 | } |
| 126 | |
| 127 | static jvalue toD(void* c) |
| 128 | { |
| 129 | jvalue v; |
| 130 | v.d = (jdouble) (*(T*) c); |
| 131 | return v; |
| 132 | } |
| 133 | |
| 134 | } ; |
| 135 | |
| 136 | template <jvalue func(void *c) > |
| 137 | class Reverse |
| 138 | { |
| 139 | public: |
| 140 | |
| 141 | static jvalue call2(void* c) |
| 142 | { |
| 143 | char r[2]; |
| 144 | char* c2 = (char*)c; |
| 145 | r[0]=c2[1]; |
| 146 | r[1]=c2[0]; |
| 147 | return func(r); |
| 148 | } |
| 149 | |
| 150 | static jvalue call4(void* c) |
| 151 | { |
| 152 | char r[4]; |
| 153 | char* c2 = (char*)c; |
| 154 | r[0]=c2[3]; |
| 155 | r[1]=c2[2]; |
| 156 | r[2]=c2[1]; |
| 157 | r[3]=c2[0]; |
| 158 | return func(r); |
| 159 | } |
| 160 | |
| 161 | static jvalue call8(void* c) |
| 162 | { |
| 163 | char r[8]; |
| 164 | char* c2 = (char*)c; |
| 165 | r[0]=c2[7]; |
| 166 | r[1]=c2[6]; |
| 167 | r[2]=c2[5]; |
| 168 | r[3]=c2[4]; |
| 169 | r[4]=c2[3]; |
| 170 | r[5]=c2[2]; |
| 171 | r[6]=c2[1]; |
| 172 | r[7]=c2[0]; |
| 173 | return func(r); |
| 174 | } |
| 175 | } ; |
| 176 | |
| 177 | |
| 178 | } // namespace |
| 179 | |
| 180 | jconverter getConverter(const char* from, int itemsize, const char* to) |
| 181 | { |
| 182 | // If not specified then the type is bytes |
| 183 | if (from == nullptr) |
| 184 | from = "B"; |
| 185 | |
| 186 | // Skip specifiers |
| 187 | bool reverse = false; |
| 188 | unsigned int x = 1; |
| 189 | bool little = *((char*)&x)==1; |
| 190 | switch (from[0]) |
| 191 | { |
| 192 | case '!': |
| 193 | case '>': |
| 194 | if (little) |
| 195 | reverse = true; |
| 196 | from++; |
| 197 | break; |
| 198 | case '<': |
| 199 | if (!little) |
| 200 | reverse = true; |
| 201 | from++; |
| 202 | break; |
| 203 | case '@': |
| 204 | case '=': |
| 205 | from++; |
| 206 | default: |
| 207 | break; |
| 208 | } |
| 209 | |
| 210 | // Standard size for 'l' is 4 in docs, but numpy uses format 'l' for long long |
| 211 | if (itemsize == 8 && from[0] == 'l') |
| 212 | from = "q"; |
| 213 | if (itemsize == 8 && from[0] == 'L') |
| 214 | from = "Q"; |
| 215 | |
| 216 | switch (from[0]) |
| 217 | { |
| 218 | case '?': |
| 219 | case 'c': |
| 220 | case 'b': |
| 221 | switch (to[0]) |
| 222 | { |
| 223 | case 'z': return &Convert<int8_t>::toZ; |
| 224 | case 'b': return &Convert<int8_t>::toB; |
| 225 | case 'c': return &Convert<int8_t>::toC; |
| 226 | case 's': return &Convert<int8_t>::toS; |
| 227 | case 'i': return &Convert<int8_t>::toI; |
| 228 | case 'j': return &Convert<int8_t>::toJ; |
| 229 | case 'f': return &Convert<int8_t>::toF; |
| 230 | case 'd': return &Convert<int8_t>::toD; |
| 231 | } |
| 232 | break; |
| 233 | case 'B': |
| 234 | switch (to[0]) |
| 235 | { |
| 236 | case 'z': return &Convert<uint8_t>::toZ; |
| 237 | case 'b': return &Convert<uint8_t>::toB; |
| 238 | case 'c': return &Convert<uint8_t>::toC; |
| 239 | case 's': return &Convert<uint8_t>::toS; |
| 240 | case 'i': return &Convert<uint8_t>::toI; |
| 241 | case 'j': return &Convert<uint8_t>::toJ; |
| 242 | case 'f': return &Convert<uint8_t>::toF; |
| 243 | case 'd': return &Convert<uint8_t>::toD; |
| 244 | } |
| 245 | break; |
| 246 | case 'h': |
| 247 | if (reverse) switch (to[0]) |
| 248 | { |
| 249 | case 'z': return &Reverse<Convert<int16_t>::toZ>::call2; |
| 250 | case 'b': return &Reverse<Convert<int16_t>::toB>::call2; |
| 251 | case 'c': return &Reverse<Convert<int16_t>::toC>::call2; |
| 252 | case 's': return &Reverse<Convert<int16_t>::toS>::call2; |
| 253 | case 'i': return &Reverse<Convert<int16_t>::toI>::call2; |
| 254 | case 'j': return &Reverse<Convert<int16_t>::toJ>::call2; |
| 255 | case 'f': return &Reverse<Convert<int16_t>::toF>::call2; |
| 256 | case 'd': return &Reverse<Convert<int16_t>::toD>::call2; |
| 257 | } |
| 258 | else switch (to[0]) |
| 259 | { |
| 260 | case 'z': return &Convert<int16_t>::toZ; |
| 261 | case 'b': return &Convert<int16_t>::toB; |
| 262 | case 'c': return &Convert<int16_t>::toC; |
| 263 | case 's': return &Convert<int16_t>::toS; |
| 264 | case 'i': return &Convert<int16_t>::toI; |
| 265 | case 'j': return &Convert<int16_t>::toJ; |
| 266 | case 'f': return &Convert<int16_t>::toF; |
| 267 | case 'd': return &Convert<int16_t>::toD; |
| 268 | } |
| 269 | break; |
| 270 | case 'H': |
| 271 | if (reverse) switch (to[0]) |
| 272 | { |
| 273 | case 'z': return &Reverse<Convert<uint16_t>::toZ>::call2; |
| 274 | case 'b': return &Reverse<Convert<uint16_t>::toB>::call2; |
| 275 | case 'c': return &Reverse<Convert<uint16_t>::toC>::call2; |
| 276 | case 's': return &Reverse<Convert<uint16_t>::toS>::call2; |
| 277 | case 'i': return &Reverse<Convert<uint16_t>::toI>::call2; |
| 278 | case 'j': return &Reverse<Convert<uint16_t>::toJ>::call2; |
| 279 | case 'f': return &Reverse<Convert<uint16_t>::toF>::call2; |
| 280 | case 'd': return &Reverse<Convert<uint16_t>::toD>::call2; |
| 281 | } |
| 282 | else switch (to[0]) |
| 283 | { |
| 284 | case 'z': return &Convert<uint16_t>::toZ; |
| 285 | case 'b': return &Convert<uint16_t>::toB; |
| 286 | case 'c': return &Convert<uint16_t>::toC; |
| 287 | case 's': return &Convert<uint16_t>::toS; |
| 288 | case 'i': return &Convert<uint16_t>::toI; |
| 289 | case 'j': return &Convert<uint16_t>::toJ; |
| 290 | case 'f': return &Convert<uint16_t>::toF; |
| 291 | case 'd': return &Convert<uint16_t>::toD; |
| 292 | } |
| 293 | break; |
| 294 | case 'i': |
| 295 | case 'l': |
| 296 | if (reverse) switch (to[0]) |
| 297 | { |
| 298 | case 'z': return &Reverse<Convert<int32_t>::toZ>::call4; |
| 299 | case 'b': return &Reverse<Convert<int32_t>::toB>::call4; |
| 300 | case 'c': return &Reverse<Convert<int32_t>::toC>::call4; |
| 301 | case 's': return &Reverse<Convert<int32_t>::toS>::call4; |
| 302 | case 'i': return &Reverse<Convert<int32_t>::toI>::call4; |
| 303 | case 'j': return &Reverse<Convert<int32_t>::toJ>::call4; |
| 304 | case 'f': return &Reverse<Convert<int32_t>::toF>::call4; |
| 305 | case 'd': return &Reverse<Convert<int32_t>::toD>::call4; |
| 306 | } |
| 307 | else switch (to[0]) |
| 308 | { |
| 309 | case 'z': return &Convert<int32_t>::toZ; |
| 310 | case 'b': return &Convert<int32_t>::toB; |
| 311 | case 'c': return &Convert<int32_t>::toC; |
| 312 | case 's': return &Convert<int32_t>::toS; |
| 313 | case 'i': return &Convert<int32_t>::toI; |
| 314 | case 'j': return &Convert<int32_t>::toJ; |
| 315 | case 'f': return &Convert<int32_t>::toF; |
| 316 | case 'd': return &Convert<int32_t>::toD; |
| 317 | } |
| 318 | break; |
| 319 | case 'I': |
| 320 | case 'L': |
| 321 | if (reverse) switch (to[0]) |
| 322 | { |
| 323 | case 'z': return &Reverse<Convert<uint32_t>::toZ>::call4; |
| 324 | case 'b': return &Reverse<Convert<uint32_t>::toB>::call4; |
| 325 | case 'c': return &Reverse<Convert<uint32_t>::toC>::call4; |
| 326 | case 's': return &Reverse<Convert<uint32_t>::toS>::call4; |
| 327 | case 'i': return &Reverse<Convert<uint32_t>::toI>::call4; |
| 328 | case 'j': return &Reverse<Convert<uint32_t>::toJ>::call4; |
| 329 | case 'f': return &Reverse<Convert<uint32_t>::toF>::call4; |
| 330 | case 'd': return &Reverse<Convert<uint32_t>::toD>::call4; |
| 331 | } |
| 332 | else switch (to[0]) |
| 333 | { |
| 334 | case 'z': return &Convert<uint32_t>::toZ; |
| 335 | case 'b': return &Convert<uint32_t>::toB; |
| 336 | case 'c': return &Convert<uint32_t>::toC; |
| 337 | case 's': return &Convert<uint32_t>::toS; |
| 338 | case 'i': return &Convert<uint32_t>::toI; |
| 339 | case 'j': return &Convert<uint32_t>::toJ; |
| 340 | case 'f': return &Convert<uint32_t>::toF; |
| 341 | case 'd': return &Convert<uint32_t>::toD; |
| 342 | } |
| 343 | break; |
| 344 | case 'q': |
| 345 | if (reverse) switch (to[0]) |
| 346 | { |
| 347 | case 'z': return &Reverse<Convert<int64_t>::toZ>::call8; |
| 348 | case 'b': return &Reverse<Convert<int64_t>::toB>::call8; |
| 349 | case 'c': return &Reverse<Convert<int64_t>::toC>::call8; |
| 350 | case 's': return &Reverse<Convert<int64_t>::toS>::call8; |
| 351 | case 'i': return &Reverse<Convert<int64_t>::toI>::call8; |
| 352 | case 'j': return &Reverse<Convert<int64_t>::toJ>::call8; |
| 353 | case 'f': return &Reverse<Convert<int64_t>::toF>::call8; |
| 354 | case 'd': return &Reverse<Convert<int64_t>::toD>::call8; |
| 355 | } |
| 356 | else switch (to[0]) |
| 357 | { |
| 358 | case 'z': return &Convert<int64_t>::toZ; |
| 359 | case 'b': return &Convert<int64_t>::toB; |
| 360 | case 'c': return &Convert<int64_t>::toC; |
| 361 | case 's': return &Convert<int64_t>::toS; |
| 362 | case 'i': return &Convert<int64_t>::toI; |
| 363 | case 'j': return &Convert<int64_t>::toJ; |
| 364 | case 'f': return &Convert<int64_t>::toF; |
| 365 | case 'd': return &Convert<int64_t>::toD; |
| 366 | } |
| 367 | break; |
| 368 | case 'Q': |
| 369 | if (reverse) switch (to[0]) |
| 370 | { |
| 371 | case 'z': return &Reverse<Convert<uint64_t>::toZ>::call8; |
| 372 | case 'b': return &Reverse<Convert<uint64_t>::toB>::call8; |
| 373 | case 'c': return &Reverse<Convert<uint64_t>::toC>::call8; |
| 374 | case 's': return &Reverse<Convert<uint64_t>::toS>::call8; |
| 375 | case 'i': return &Reverse<Convert<uint64_t>::toI>::call8; |
| 376 | case 'j': return &Reverse<Convert<uint64_t>::toJ>::call8; |
| 377 | case 'f': return &Reverse<Convert<uint64_t>::toF>::call8; |
| 378 | case 'd': return &Reverse<Convert<uint64_t>::toD>::call8; |
| 379 | } |
| 380 | else switch (to[0]) |
| 381 | { |
| 382 | case 'z': return &Convert<uint64_t>::toZ; |
| 383 | case 'b': return &Convert<uint64_t>::toB; |
| 384 | case 'c': return &Convert<uint64_t>::toC; |
| 385 | case 's': return &Convert<uint64_t>::toS; |
| 386 | case 'i': return &Convert<uint64_t>::toI; |
| 387 | case 'j': return &Convert<uint64_t>::toJ; |
| 388 | case 'f': return &Convert<uint64_t>::toF; |
| 389 | case 'd': return &Convert<uint64_t>::toD; |
| 390 | } |
| 391 | break; |
| 392 | case 'f': |
| 393 | if (reverse) switch (to[0]) |
| 394 | { |
| 395 | case 'z': return &Reverse<Convert<float>::toZ>::call4; |
| 396 | case 'b': return &Reverse<Convert<float>::toB>::call4; |
| 397 | case 'c': return &Reverse<Convert<float>::toC>::call4; |
| 398 | case 's': return &Reverse<Convert<float>::toS>::call4; |
| 399 | case 'i': return &Reverse<Convert<float>::toI>::call4; |
| 400 | case 'j': return &Reverse<Convert<float>::toJ>::call4; |
| 401 | case 'f': return &Reverse<Convert<float>::toF>::call4; |
| 402 | case 'd': return &Reverse<Convert<float>::toD>::call4; |
| 403 | } |
| 404 | else switch (to[0]) |
| 405 | { |
| 406 | case 'z': return &Convert<float>::toZ; |
| 407 | case 'b': return &Convert<float>::toB; |
| 408 | case 'c': return &Convert<float>::toC; |
| 409 | case 's': return &Convert<float>::toS; |
| 410 | case 'i': return &Convert<float>::toI; |
| 411 | case 'j': return &Convert<float>::toJ; |
| 412 | case 'f': return &Convert<float>::toF; |
| 413 | case 'd': return &Convert<float>::toD; |
| 414 | } |
| 415 | break; |
| 416 | case 'd': |
| 417 | if (reverse) switch (to[0]) |
| 418 | { |
| 419 | case 'z': return &Reverse<Convert<double>::toZ>::call8; |
| 420 | case 'b': return &Reverse<Convert<double>::toB>::call8; |
| 421 | case 'c': return &Reverse<Convert<double>::toC>::call8; |
| 422 | case 's': return &Reverse<Convert<double>::toS>::call8; |
| 423 | case 'i': return &Reverse<Convert<double>::toI>::call8; |
| 424 | case 'j': return &Reverse<Convert<double>::toJ>::call8; |
| 425 | case 'f': return &Reverse<Convert<double>::toF>::call8; |
| 426 | case 'd': return &Reverse<Convert<double>::toD>::call8; |
| 427 | } |
| 428 | else switch (to[0]) |
| 429 | { |
| 430 | case 'z': return &Convert<double>::toZ; |
| 431 | case 'b': return &Convert<double>::toB; |
| 432 | case 'c': return &Convert<double>::toC; |
| 433 | case 's': return &Convert<double>::toS; |
| 434 | case 'i': return &Convert<double>::toI; |
| 435 | case 'j': return &Convert<double>::toJ; |
| 436 | case 'f': return &Convert<double>::toF; |
| 437 | case 'd': return &Convert<double>::toD; |
| 438 | } |
| 439 | break; |
| 440 | case 'e': |
| 441 | if (reverse) switch (to[0]) |
| 442 | { |
| 443 | case 'z': return &Reverse<Half<Convert<float>::toZ>::convert>::call4; |
| 444 | case 'b': return &Reverse<Half<Convert<float>::toB>::convert>::call4; |
| 445 | case 'c': return &Reverse<Half<Convert<float>::toC>::convert>::call4; |
| 446 | case 's': return &Reverse<Half<Convert<float>::toS>::convert>::call4; |
| 447 | case 'i': return &Reverse<Half<Convert<float>::toI>::convert>::call4; |
| 448 | case 'j': return &Reverse<Half<Convert<float>::toJ>::convert>::call4; |
| 449 | case 'f': return &Reverse<Half<Convert<float>::toF>::convert>::call4; |
| 450 | case 'd': return &Reverse<Half<Convert<float>::toD>::convert>::call4; |
| 451 | } |
| 452 | else switch (to[0]) |
| 453 | { |
| 454 | case 'z': return &Half<Convert<float>::toZ>::convert; |
| 455 | case 'b': return &Half<Convert<float>::toB>::convert; |
| 456 | case 'c': return &Half<Convert<float>::toC>::convert; |
| 457 | case 's': return &Half<Convert<float>::toS>::convert; |
| 458 | case 'i': return &Half<Convert<float>::toI>::convert; |
| 459 | case 'j': return &Half<Convert<float>::toJ>::convert; |
| 460 | case 'f': return &Half<Convert<float>::toF>::convert; |
| 461 | case 'd': return &Half<Convert<float>::toD>::convert; |
| 462 | } |
| 463 | break; |
| 464 | |
| 465 | case 'n': |
| 466 | if (reverse) switch (to[0]) |
| 467 | { |
| 468 | case 'z': return &Reverse<Convert<Py_ssize_t>::toZ>::call8; |
| 469 | case 'b': return &Reverse<Convert<Py_ssize_t>::toB>::call8; |
| 470 | case 'c': return &Reverse<Convert<Py_ssize_t>::toC>::call8; |
| 471 | case 's': return &Reverse<Convert<Py_ssize_t>::toS>::call8; |
| 472 | case 'i': return &Reverse<Convert<Py_ssize_t>::toI>::call8; |
| 473 | case 'j': return &Reverse<Convert<Py_ssize_t>::toJ>::call8; |
| 474 | case 'f': return &Reverse<Convert<Py_ssize_t>::toF>::call8; |
| 475 | case 'd': return &Reverse<Convert<Py_ssize_t>::toD>::call8; |
| 476 | } |
| 477 | else switch (to[0]) |
| 478 | { |
| 479 | case 'z': return &Convert<Py_ssize_t>::toZ; |
| 480 | case 'b': return &Convert<Py_ssize_t>::toB; |
| 481 | case 'c': return &Convert<Py_ssize_t>::toC; |
| 482 | case 's': return &Convert<Py_ssize_t>::toS; |
| 483 | case 'i': return &Convert<Py_ssize_t>::toI; |
| 484 | case 'j': return &Convert<Py_ssize_t>::toJ; |
| 485 | case 'f': return &Convert<Py_ssize_t>::toF; |
| 486 | case 'd': return &Convert<Py_ssize_t>::toD; |
| 487 | } |
| 488 | break; |
| 489 | case 'N': |
| 490 | if (reverse) switch (to[0]) |
| 491 | { |
| 492 | case 'z': return &Reverse<Convert<size_t>::toZ>::call8; |
| 493 | case 'b': return &Reverse<Convert<size_t>::toB>::call8; |
| 494 | case 'c': return &Reverse<Convert<size_t>::toC>::call8; |
| 495 | case 's': return &Reverse<Convert<size_t>::toS>::call8; |
| 496 | case 'i': return &Reverse<Convert<size_t>::toI>::call8; |
| 497 | case 'j': return &Reverse<Convert<size_t>::toJ>::call8; |
| 498 | case 'f': return &Reverse<Convert<size_t>::toF>::call8; |
| 499 | case 'd': return &Reverse<Convert<size_t>::toD>::call8; |
| 500 | } |
| 501 | else switch (to[0]) |
| 502 | { |
| 503 | case 'z': return &Convert<size_t>::toZ; |
| 504 | case 'b': return &Convert<size_t>::toB; |
| 505 | case 'c': return &Convert<size_t>::toC; |
| 506 | case 's': return &Convert<size_t>::toS; |
| 507 | case 'i': return &Convert<size_t>::toI; |
| 508 | case 'j': return &Convert<size_t>::toJ; |
| 509 | case 'f': return &Convert<size_t>::toF; |
| 510 | case 'd': return &Convert<size_t>::toD; |
| 511 | } |
| 512 | break; |
| 513 | default: break; |
| 514 | } |
| 515 | PyErr_Format(PyExc_ValueError, "Unable to handle buffer type '%s'", from); |
| 516 | JP_RAISE_PYTHON(); |
| 517 | } |