Lines 34-40
Link Here
|
34 |
# include <config.h> |
34 |
# include <config.h> |
35 |
#endif |
35 |
#endif |
36 |
|
36 |
|
37 |
#include <stdint.h> |
37 |
#if defined(HAVE_STDINT_H) |
|
|
38 |
# include <stdint.h> |
39 |
#elsif defined(HAVE_INTTYPES_H) |
40 |
# include <inttypes.h> |
41 |
#endif |
38 |
#include "pycairo-private.h" |
42 |
#include "pycairo-private.h" |
39 |
|
43 |
|
40 |
|
44 |
|
Lines 519-524
Link Here
|
519 |
static PyObject * |
523 |
static PyObject * |
520 |
image_surface_create_from_png (PyTypeObject *type, PyObject *file) |
524 |
image_surface_create_from_png (PyTypeObject *type, PyObject *file) |
521 |
{ |
525 |
{ |
|
|
526 |
PyObject* reader; |
522 |
if (PyObject_TypeCheck (file, &PyBaseString_Type)) { |
527 |
if (PyObject_TypeCheck (file, &PyBaseString_Type)) { |
523 |
return PycairoSurface_FromSurface ( |
528 |
return PycairoSurface_FromSurface ( |
524 |
cairo_image_surface_create_from_png (PyString_AsString(file)), |
529 |
cairo_image_surface_create_from_png (PyString_AsString(file)), |
Lines 526-532
Link Here
|
526 |
} |
531 |
} |
527 |
|
532 |
|
528 |
/* file or file-like object argument */ |
533 |
/* file or file-like object argument */ |
529 |
PyObject* reader = PyObject_GetAttrString (file, "read"); |
534 |
reader = PyObject_GetAttrString (file, "read"); |
530 |
if (reader == NULL || !PyCallable_Check (reader)) { |
535 |
if (reader == NULL || !PyCallable_Check (reader)) { |
531 |
Py_XDECREF(reader); |
536 |
Py_XDECREF(reader); |
532 |
PyErr_SetString(PyExc_TypeError, |
537 |
PyErr_SetString(PyExc_TypeError, |
Lines 700-705
Link Here
|
700 |
{ |
705 |
{ |
701 |
double width_in_points, height_in_points; |
706 |
double width_in_points, height_in_points; |
702 |
PyObject *file; |
707 |
PyObject *file; |
|
|
708 |
PyObject* writer; |
703 |
|
709 |
|
704 |
if (!PyArg_ParseTuple(args, "Odd:PDFSurface.__new__", |
710 |
if (!PyArg_ParseTuple(args, "Odd:PDFSurface.__new__", |
705 |
&file, &width_in_points, &height_in_points)) |
711 |
&file, &width_in_points, &height_in_points)) |
Lines 713-719
Link Here
|
713 |
NULL); |
719 |
NULL); |
714 |
} |
720 |
} |
715 |
/* file or file-like object argument */ |
721 |
/* file or file-like object argument */ |
716 |
PyObject* writer = PyObject_GetAttrString (file, "write"); |
722 |
writer = PyObject_GetAttrString (file, "write"); |
717 |
if (writer == NULL || !PyCallable_Check (writer)) { |
723 |
if (writer == NULL || !PyCallable_Check (writer)) { |
718 |
Py_XDECREF(writer); |
724 |
Py_XDECREF(writer); |
719 |
PyErr_SetString(PyExc_TypeError, |
725 |
PyErr_SetString(PyExc_TypeError, |
Lines 803-808
Link Here
|
803 |
{ |
809 |
{ |
804 |
double width_in_points, height_in_points; |
810 |
double width_in_points, height_in_points; |
805 |
PyObject *file; |
811 |
PyObject *file; |
|
|
812 |
PyObject* writer; |
806 |
|
813 |
|
807 |
if (!PyArg_ParseTuple(args, "Odd:PSSurface.__new__", |
814 |
if (!PyArg_ParseTuple(args, "Odd:PSSurface.__new__", |
808 |
&file, &width_in_points, &height_in_points)) |
815 |
&file, &width_in_points, &height_in_points)) |
Lines 817-823
Link Here
|
817 |
|
824 |
|
818 |
} |
825 |
} |
819 |
/* else: file or file-like object argument */ |
826 |
/* else: file or file-like object argument */ |
820 |
PyObject* writer = PyObject_GetAttrString (file, "write"); |
827 |
writer = PyObject_GetAttrString (file, "write"); |
821 |
if (writer == NULL || !PyCallable_Check (writer)) { |
828 |
if (writer == NULL || !PyCallable_Check (writer)) { |
822 |
Py_XDECREF(writer); |
829 |
Py_XDECREF(writer); |
823 |
PyErr_SetString(PyExc_TypeError, |
830 |
PyErr_SetString(PyExc_TypeError, |
Lines 942-947
Link Here
|
942 |
{ |
949 |
{ |
943 |
double width_in_points, height_in_points; |
950 |
double width_in_points, height_in_points; |
944 |
PyObject *file; |
951 |
PyObject *file; |
|
|
952 |
PyObject* writer; |
945 |
|
953 |
|
946 |
if (!PyArg_ParseTuple(args, "Odd:SVGSurface.__new__", |
954 |
if (!PyArg_ParseTuple(args, "Odd:SVGSurface.__new__", |
947 |
&file, &width_in_points, &height_in_points)) |
955 |
&file, &width_in_points, &height_in_points)) |
Lines 955-961
Link Here
|
955 |
NULL); |
963 |
NULL); |
956 |
} |
964 |
} |
957 |
/* else: file or file-like object argument */ |
965 |
/* else: file or file-like object argument */ |
958 |
PyObject* writer = PyObject_GetAttrString (file, "write"); |
966 |
writer = PyObject_GetAttrString (file, "write"); |
959 |
if (writer == NULL || !PyCallable_Check (writer)) { |
967 |
if (writer == NULL || !PyCallable_Check (writer)) { |
960 |
Py_XDECREF(writer); |
968 |
Py_XDECREF(writer); |
961 |
PyErr_SetString(PyExc_TypeError, |
969 |
PyErr_SetString(PyExc_TypeError, |