| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -206,7 +206,7 @@ static PyObject *PyRendererAgg_draw_text_image(PyRendererAgg *self, PyObject *ar | |||
| 206 | 206 | ||
| 207 | 207 | if (!PyArg_ParseTuple(args, | |
| 208 | 208 | "O&dddO&:draw_text_image", | |
| 209 | - &numpy::convert_array_contiguous<agg::int8u, 2>, | ||
| 209 | + &image.converter_contiguous, | ||
| 210 | 210 | &image, | |
| 211 | 211 | &x, | |
| 212 | 212 | &y, | |
@@ -274,7 +274,7 @@ static PyObject *PyRendererAgg_draw_image(PyRendererAgg *self, PyObject *args, P | |||
| 274 | 274 | &gc, | |
| 275 | 275 | &x, | |
| 276 | 276 | &y, | |
| 277 | - &numpy::convert_array_contiguous<agg::int8u, 3>, | ||
| 277 | + &image.converter_contiguous, | ||
| 278 | 278 | &image, | |
| 279 | 279 | &w, | |
| 280 | 280 | &h, | |
@@ -319,21 +319,21 @@ PyRendererAgg_draw_path_collection(PyRendererAgg *self, PyObject *args, PyObject | |||
| 319 | 319 | &convert_trans_affine, | |
| 320 | 320 | &master_transform, | |
| 321 | 321 | &pathobj, | |
| 322 | - &numpy::convert_array<const double, 3>, | ||
| 322 | + &transforms.converter, | ||
| 323 | 323 | &transforms, | |
| 324 | - &numpy::convert_array<const double, 2>, | ||
| 324 | + &offsets.converter, | ||
| 325 | 325 | &offsets, | |
| 326 | 326 | &convert_trans_affine, | |
| 327 | 327 | &offset_trans, | |
| 328 | - &numpy::convert_array<const double, 2>, | ||
| 328 | + &facecolors.converter, | ||
| 329 | 329 | &facecolors, | |
| 330 | - &numpy::convert_array<const double, 2>, | ||
| 330 | + &edgecolors.converter, | ||
| 331 | 331 | &edgecolors, | |
| 332 | - &numpy::convert_array<const double, 1>, | ||
| 332 | + &linewidths.converter, | ||
| 333 | 333 | &linewidths, | |
| 334 | 334 | &convert_dashes_vector, | |
| 335 | 335 | &dashes, | |
| 336 | - &numpy::convert_array<const uint8_t, 1>, | ||
| 336 | + &antialiaseds.converter, | ||
| 337 | 337 | &antialiaseds, | |
| 338 | 338 | &ignored, | |
| 339 | 339 | &convert_offset_position, | |
@@ -388,16 +388,16 @@ static PyObject *PyRendererAgg_draw_quad_mesh(PyRendererAgg *self, PyObject *arg | |||
| 388 | 388 | &master_transform, | |
| 389 | 389 | &mesh_width, | |
| 390 | 390 | &mesh_height, | |
| 391 | - &numpy::convert_array<const double, 3>, | ||
| 391 | + &coordinates.converter, | ||
| 392 | 392 | &coordinates, | |
| 393 | - &numpy::convert_array<const double, 2>, | ||
| 393 | + &offsets.converter, | ||
| 394 | 394 | &offsets, | |
| 395 | 395 | &convert_trans_affine, | |
| 396 | 396 | &offset_trans, | |
| 397 | - &numpy::convert_array<const double, 2>, | ||
| 397 | + &facecolors.converter, | ||
| 398 | 398 | &facecolors, | |
| 399 | 399 | &antialiased, | |
| 400 | - &numpy::convert_array<const double, 2>, | ||
| 400 | + &edgecolors.converter, | ||
| 401 | 401 | &edgecolors)) { | |
| 402 | 402 | return NULL; | |
| 403 | 403 | } | |
@@ -429,9 +429,9 @@ PyRendererAgg_draw_gouraud_triangle(PyRendererAgg *self, PyObject *args, PyObjec | |||
| 429 | 429 | "O&O&O&O&|O:draw_gouraud_triangle", | |
| 430 | 430 | &convert_gcagg, | |
| 431 | 431 | &gc, | |
| 432 | - &numpy::convert_array<const double, 2>, | ||
| 432 | + &points.converter, | ||
| 433 | 433 | &points, | |
| 434 | - &numpy::convert_array<const double, 2>, | ||
| 434 | + &colors.converter, | ||
| 435 | 435 | &colors, | |
| 436 | 436 | &convert_trans_affine, | |
| 437 | 437 | &trans)) { | |
@@ -455,9 +455,9 @@ PyRendererAgg_draw_gouraud_triangles(PyRendererAgg *self, PyObject *args, PyObje | |||
| 455 | 455 | "O&O&O&O&|O:draw_gouraud_triangles", | |
| 456 | 456 | &convert_gcagg, | |
| 457 | 457 | &gc, | |
| 458 | - &numpy::convert_array<const double, 3>, | ||
| 458 | + &points.converter, | ||
| 459 | 459 | &points, | |
| 460 | - &numpy::convert_array<const double, 3>, | ||
| 460 | + &colors.converter, | ||
| 461 | 461 | &colors, | |
| 462 | 462 | &convert_trans_affine, | |
| 463 | 463 | &trans)) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,7 +31,7 @@ static PyObject *Py_agg_to_gtk_drawable(PyObject *self, PyObject *args, PyObject | |||
| 31 | 31 | if (!PyArg_ParseTuple(args, | |
| 32 | 32 | "OO&O&:agg_to_gtk_drawable", | |
| 33 | 33 | &py_drawable, | |
| 34 | - &numpy::convert_array<agg::int8u, 3>, | ||
| 34 | + &buffer.converter, | ||
| 35 | 35 | &buffer, | |
| 36 | 36 | &convert_rect, | |
| 37 | 37 | &rect)) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -530,9 +530,9 @@ static PyObject *image_fromarray(PyObject *self, PyObject *args, PyObject *kwds) | |||
| 530 | 530 | numpy::array_view<const double, 2> grey_array; | |
| 531 | 531 | Image *result = NULL; | |
| 532 | 532 | ||
| 533 | - if (numpy::convert_array<const double, 3>(array, &color_array)) { | ||
| 533 | + if (color_array.converter(array, &color_array)) { | ||
| 534 | 534 | CALL_CPP("fromarray", result = from_color_array(color_array, isoutput)); | |
| 535 | - } else if (numpy::convert_array<const double, 2>(array, &grey_array)) { | ||
| 535 | + } else if (grey_array.converter(array, &grey_array)) { | ||
| 536 | 536 | CALL_CPP("fromarray", result = from_grey_array(grey_array, isoutput)); | |
| 537 | 537 | } else { | |
| 538 | 538 | PyErr_SetString(PyExc_ValueError, "invalid array"); | |
@@ -561,7 +561,7 @@ static PyObject *image_frombyte(PyObject *self, PyObject *args, PyObject *kwds) | |||
| 561 | 561 | kwds, | |
| 562 | 562 | "O&|i:frombyte", | |
| 563 | 563 | (char **)names, | |
| 564 | - &numpy::convert_array_contiguous<const uint8_t, 3>, | ||
| 564 | + &array.converter, | ||
| 565 | 565 | &array, | |
| 566 | 566 | &isoutput)) { | |
| 567 | 567 | return NULL; | |
@@ -644,11 +644,11 @@ static PyObject *image_pcolor(PyObject *self, PyObject *args, PyObject *kwds) | |||
| 644 | 644 | ||
| 645 | 645 | if (!PyArg_ParseTuple(args, | |
| 646 | 646 | "O&O&O&II(ffff)i:pcolor", | |
| 647 | - &numpy::convert_array_contiguous<const float, 1>, | ||
| 647 | + &x.converter, | ||
| 648 | 648 | &x, | |
| 649 | - &numpy::convert_array_contiguous<const float, 1>, | ||
| 649 | + &y.converter, | ||
| 650 | 650 | &y, | |
| 651 | - &numpy::convert_array_contiguous<const agg::int8u, 3>, | ||
| 651 | + &d.converter_contiguous, | ||
| 652 | 652 | &d, | |
| 653 | 653 | &rows, | |
| 654 | 654 | &cols, | |
@@ -686,19 +686,19 @@ static PyObject *image_pcolor2(PyObject *self, PyObject *args, PyObject *kwds) | |||
| 686 | 686 | ||
| 687 | 687 | if (!PyArg_ParseTuple(args, | |
| 688 | 688 | "O&O&O&II(ffff)O&:pcolor2", | |
| 689 | - &numpy::convert_array_contiguous<const double, 1>, | ||
| 689 | + &x.converter, | ||
| 690 | 690 | &x, | |
| 691 | - &numpy::convert_array_contiguous<const double, 1>, | ||
| 691 | + &y.converter, | ||
| 692 | 692 | &y, | |
| 693 | - &numpy::convert_array<const agg::int8u, 3>, | ||
| 693 | + &d.converter_contiguous, | ||
| 694 | 694 | &d, | |
| 695 | 695 | &rows, | |
| 696 | 696 | &cols, | |
| 697 | 697 | &bounds[0], | |
| 698 | 698 | &bounds[1], | |
| 699 | 699 | &bounds[2], | |
| 700 | 700 | &bounds[3], | |
| 701 | - &numpy::convert_array<const agg::int8u, 1>, | ||
| 701 | + &bg.converter, | ||
| 702 | 702 | &bg)) { | |
| 703 | 703 | return NULL; | |
| 704 | 704 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -67,7 +67,7 @@ static PyObject *Py_points_in_path(PyObject *self, PyObject *args, PyObject *kwd | |||
| 67 | 67 | ||
| 68 | 68 | if (!PyArg_ParseTuple(args, | |
| 69 | 69 | "O&dO&O&:points_in_path", | |
| 70 | - &numpy::convert_array<const double, 2>, | ||
| 70 | + &points.converter, | ||
| 71 | 71 | &points, | |
| 72 | 72 | &r, | |
| 73 | 73 | &convert_path, | |
@@ -126,7 +126,7 @@ static PyObject *Py_points_on_path(PyObject *self, PyObject *args, PyObject *kwd | |||
| 126 | 126 | ||
| 127 | 127 | if (!PyArg_ParseTuple(args, | |
| 128 | 128 | "O&dO&O&:points_on_path", | |
| 129 | - &numpy::convert_array<const double, 2>, | ||
| 129 | + &points.converter, | ||
| 130 | 130 | &points, | |
| 131 | 131 | &r, | |
| 132 | 132 | &convert_path, | |
@@ -191,7 +191,7 @@ static PyObject *Py_update_path_extents(PyObject *self, PyObject *args, PyObject | |||
| 191 | 191 | &trans, | |
| 192 | 192 | &convert_rect, | |
| 193 | 193 | &rect, | |
| 194 | - &numpy::convert_array<double, 1>, | ||
| 194 | + &minpos.converter, | ||
| 195 | 195 | &minpos, | |
| 196 | 196 | &ignore)) { | |
| 197 | 197 | return NULL; | |
@@ -261,9 +261,9 @@ static PyObject *Py_get_path_collection_extents(PyObject *self, PyObject *args, | |||
| 261 | 261 | &convert_trans_affine, | |
| 262 | 262 | &master_transform, | |
| 263 | 263 | &pathsobj, | |
| 264 | - &numpy::convert_array<const double, 3>, | ||
| 264 | + &transforms.converter, | ||
| 265 | 265 | &transforms, | |
| 266 | - &numpy::convert_array<const double, 2>, | ||
| 266 | + &offsets.converter, | ||
| 267 | 267 | &offsets, | |
| 268 | 268 | &convert_trans_affine, | |
| 269 | 269 | &offset_trans)) { | |
@@ -317,9 +317,9 @@ static PyObject *Py_point_in_path_collection(PyObject *self, PyObject *args, PyO | |||
| 317 | 317 | &convert_trans_affine, | |
| 318 | 318 | &master_transform, | |
| 319 | 319 | &pathsobj, | |
| 320 | - &numpy::convert_array<const double, 3>, | ||
| 320 | + &transforms.converter, | ||
| 321 | 321 | &transforms, | |
| 322 | - &numpy::convert_array<const double, 2>, | ||
| 322 | + &offsets.converter, | ||
| 323 | 323 | &offsets, | |
| 324 | 324 | &convert_trans_affine, | |
| 325 | 325 | &offset_trans, | |
@@ -422,7 +422,7 @@ static PyObject *Py_affine_transform(PyObject *self, PyObject *args, PyObject *k | |||
| 422 | 422 | ||
| 423 | 423 | if (!PyArg_ParseTuple(args, | |
| 424 | 424 | "O&O&:affine_transform", | |
| 425 | - &numpy::convert_array<const double, 2>, | ||
| 425 | + &vertices.converter, | ||
| 426 | 426 | &vertices, | |
| 427 | 427 | &convert_trans_affine, | |
| 428 | 428 | &trans)) { | |
@@ -449,7 +449,7 @@ static PyObject *Py_count_bboxes_overlapping_bbox(PyObject *self, PyObject *args | |||
| 449 | 449 | "O&O&:count_bboxes_overlapping_bbox", | |
| 450 | 450 | &convert_rect, | |
| 451 | 451 | &bbox, | |
| 452 | - &numpy::convert_array<const double, 3>, | ||
| 452 | + &bboxes.converter, | ||
| 453 | 453 | &bboxes)) { | |
| 454 | 454 | return NULL; | |
| 455 | 455 | } | |
@@ -662,7 +662,7 @@ extern "C" { | |||
| 662 | 662 | {"convert_path_to_polygons", (PyCFunction)Py_convert_path_to_polygons, METH_VARARGS, Py_convert_path_to_polygons__doc__}, | |
| 663 | 663 | {"cleanup_path", (PyCFunction)Py_cleanup_path, METH_VARARGS, Py_cleanup_path__doc__}, | |
| 664 | 664 | {"convert_to_svg", (PyCFunction)Py_convert_to_svg, METH_VARARGS, Py_convert_to_svg__doc__}, | |
| 665 | - {NULL, NULL, NULL, NULL} | ||
| 665 | + {NULL} | ||
| 666 | 666 | }; | |
| 667 | 667 | ||
| 668 | 668 | struct module_state | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -79,7 +79,7 @@ static PyObject *Py_write_png(PyObject *self, PyObject *args, PyObject *kwds) | |||
| 79 | 79 | kwds, | |
| 80 | 80 | "O&O|d:write_png", | |
| 81 | 81 | (char **)names, | |
| 82 | - &numpy::convert_array<unsigned char, 3>, | ||
| 82 | + &buffer.converter, | ||
| 83 | 83 | &buffer, | |
| 84 | 84 | &filein, | |
| 85 | 85 | &dpi)) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -309,7 +309,43 @@ class array_view_accessors<AV, T, 3> | |||
| 309 | 309 | self->m_shape + 1, | |
| 310 | 310 | self->m_strides + 1); | |
| 311 | 311 | } | |
| 312 | + | ||
| 313 | + | ||
| 312 | 314 | }; | |
| 315 | + | ||
| 316 | + // /* These are converter functions designed for use with the "O&" | ||
| 317 | + // functionality of PyArg_ParseTuple and friends. */ | ||
| 318 | + | ||
| 319 | + // template<class T> | ||
| 320 | + // class array_converter { | ||
| 321 | + // public: | ||
| 322 | + // int operator()(PyObject *obj, void *arrp) | ||
| 323 | + // { | ||
| 324 | + // T *arr = (T *)arrp; | ||
| 325 | + | ||
| 326 | + // if (!arr->set(obj)) { | ||
| 327 | + // return 0; | ||
| 328 | + // } | ||
| 329 | + | ||
| 330 | + // return 1; | ||
| 331 | + // } | ||
| 332 | + // }; | ||
| 333 | + | ||
| 334 | + // template <class T> | ||
| 335 | + // class array_converter_contiguous { | ||
| 336 | + // public: | ||
| 337 | + // int operator()(PyObject *obj, void *arrp) | ||
| 338 | + // { | ||
| 339 | + // T *arr = (T *)arrp; | ||
| 340 | + | ||
| 341 | + // if (!arr->set(obj, true)) { | ||
| 342 | + // return 0; | ||
| 343 | + // } | ||
| 344 | + | ||
| 345 | + // return 1; | ||
| 346 | + // } | ||
| 347 | + // }; | ||
| 348 | + | ||
| 313 | 349 | } | |
| 314 | 350 | ||
| 315 | 351 | static npy_intp zeros[] = { 0, 0, 0 }; | |
@@ -328,6 +364,7 @@ class array_view : public detail::array_view_accessors<array_view, T, ND> | |||
| 328 | 364 | ||
| 329 | 365 | public: | |
| 330 | 366 | typedef T value_type; | |
| 367 | + | ||
| 331 | 368 | enum { | |
| 332 | 369 | ndim = ND | |
| 333 | 370 | }; | |
@@ -446,35 +483,31 @@ class array_view : public detail::array_view_accessors<array_view, T, ND> | |||
| 446 | 483 | Py_INCREF(m_arr); | |
| 447 | 484 | return (PyObject *)m_arr; | |
| 448 | 485 | } | |
| 449 | - }; | ||
| 450 | 486 | ||
| 451 | - /* These are converter functions designed for use with the "O&" | ||
| 452 | - functionality of PyArg_ParseTuple and friends. */ | ||
| 487 | + static int converter(PyObject *obj, void *arrp) | ||
| 488 | + { | ||
| 489 | + array_view<T, ND> *arr = (array_view<T, ND> *)arrp; | ||
| 453 | 490 | ||
| 454 | - template <class T, int ND> | ||
| 455 | - int convert_array(PyObject *obj, void *arrp) | ||
| 456 | - { | ||
| 457 | - numpy::array_view<T, ND> *arr = (numpy::array_view<T, ND> *)arrp; | ||
| 491 | + if (!arr->set(obj)) { | ||
| 492 | + return 0; | ||
| 493 | + } | ||
| 458 | 494 | ||
| 459 | - if (!arr->set(obj)) { | ||
| 460 | - return 0; | ||
| 495 | + return 1; | ||
| 461 | 496 | } | |
| 462 | 497 | ||
| 463 | - return 1; | ||
| 464 | - } | ||
| 498 | + static int converter_contiguous(PyObject *obj, void *arrp) | ||
| 499 | + { | ||
| 500 | + array_view<T, ND> *arr = (array_view<T, ND> *)arrp; | ||
| 465 | 501 | ||
| 466 | - template <class T, int ND> | ||
| 467 | - int convert_array_contiguous(PyObject *obj, void *arrp) | ||
| 468 | - { | ||
| 469 | - numpy::array_view<T, ND> *arr = (numpy::array_view<T, ND> *)arrp; | ||
| 502 | + if (!arr->set(obj, true)) { | ||
| 503 | + return 0; | ||
| 504 | + } | ||
| 470 | 505 | ||
| 471 | - if (!arr->set(obj, true)) { | ||
| 472 | - return 0; | ||
| 506 | + return 1; | ||
| 473 | 507 | } | |
| 474 | - | ||
| 475 | - return 1; | ||
| 476 | - } | ||
| 508 | + }; | ||
| 477 | 509 | ||
| 478 | 510 | } // namespace numpy | |
| 479 | 511 | ||
| 512 | + | ||
| 480 | 513 | #endif | |
| Back | FazBrowse Home | New Git URL |
0 commit comments