From 7d49fdb90b4acebed6be8c0850d5c1fa9792cb49 Mon Sep 17 00:00:00 2001 From: John (J5) Palmieri Date: Mon, 25 Oct 2010 17:49:57 -0400 Subject: [PATCH] wrap cairo_rectangle_int_t https://bugs.freedesktop.org/show_bug.cgi?id=31111 --- src/cairomodule.c | 9 +++++++++ src/private.h | 3 +++ src/py3cairo.h | 11 +++++++++++ src/wscript | 1 + test/api_test.py | 11 +++++++++++ 5 files changed, 35 insertions(+), 0 deletions(-) diff --git a/src/cairomodule.c b/src/cairomodule.c index 58e665c..120378a 100644 --- a/src/cairomodule.c +++ b/src/cairomodule.c @@ -140,6 +140,9 @@ static Pycairo_CAPI_t CAPI = { #endif PycairoSurface_FromSurface, + &PycairoRectangleInt_Type, + PycairoRectangleInt_FromRectangleInt, + Pycairo_Check_Status, }; @@ -266,6 +269,8 @@ PyInit__cairo(void) return NULL; #endif + if (PyType_Ready(&PycairoRectangleInt_Type) < 0) + return NULL; PyObject *m = PyModule_Create(&cairomodule); //PyObject *m; @@ -335,6 +340,10 @@ PyInit__cairo(void) Py_INCREF(&PycairoSurface_Type); PyModule_AddObject(m, "Surface", (PyObject *)&PycairoSurface_Type); + Py_INCREF(&PycairoRectangleInt_Type); + PyModule_AddObject(m, "RectangleInt", + (PyObject *)&PycairoRectangleInt_Type); + #ifdef CAIRO_HAS_IMAGE_SURFACE Py_INCREF(&PycairoImageSurface_Type); PyModule_AddObject(m, "ImageSurface", diff --git a/src/private.h b/src/private.h index ba59daf..3fba518 100644 --- a/src/private.h +++ b/src/private.h @@ -61,6 +61,9 @@ extern PyTypeObject PycairoRadialGradient_Type; PyObject *PycairoPattern_FromPattern (cairo_pattern_t *pattern, PyObject *base); +extern PyTypeObject PycairoRectangleInt_Type; +PyObject *PycairoRectangleInt_FromRectangleInt (cairo_rectangle_int_t *rectangle_int); + extern PyTypeObject PycairoScaledFont_Type; PyObject *PycairoScaledFont_FromScaledFont (cairo_scaled_font_t *scaled_font); diff --git a/src/py3cairo.h b/src/py3cairo.h index 35b4240..7d86b84 100644 --- a/src/py3cairo.h +++ b/src/py3cairo.h @@ -67,6 +67,11 @@ typedef struct { typedef struct { PyObject_HEAD + cairo_rectangle_int_t *rectangle_int; +} PycairoRectangleInt; + +typedef struct { + PyObject_HEAD cairo_scaled_font_t *scaled_font; } PycairoScaledFont; @@ -113,6 +118,9 @@ typedef struct { PyTypeObject *RadialGradient_Type; PyObject *(*Pattern_FromPattern)(cairo_pattern_t *pattern, PyObject *base); + PyTypeObject *RectangleInt_Type; + PyObject *(*RectangleInt_FromRectangleInt)(cairo_rectangle_int_t *rectangle_int); + PyTypeObject *ScaledFont_Type; PyObject *(*ScaledFont_FromScaledFont)(cairo_scaled_font_t *scaled_font); @@ -156,6 +164,9 @@ typedef struct { #define PycairoRadialGradient_Type *(Pycairo_CAPI->RadialGradient_Type) #define PycairoPattern_FromPattern (Pycairo_CAPI->Pattern_FromPattern) +#define PycairoRectangleInt_Type *(Pycairo_CAPI->RectangleInt_Type) +#define PycairoRectangleInt_FromRectangleInt (Pycairo_CAPI->RectangleInt_FromRectangleInt) + #define PycairoScaledFont_Type *(Pycairo_CAPI->ScaledFont_Type) #define PycairoScaledFont_FromScaledFont \ (Pycairo_CAPI->ScaledFont_FromScaledFont) diff --git a/src/wscript b/src/wscript index d30c6ad..01d79ff 100644 --- a/src/wscript +++ b/src/wscript @@ -27,6 +27,7 @@ def build(ctx): 'pattern.c', 'matrix.c', 'surface.c', + 'rectangle.c', ], target = '_cairo', includes = '.', diff --git a/test/api_test.py b/test/api_test.py index c83bf99..343531d 100644 --- a/test/api_test.py +++ b/test/api_test.py @@ -81,6 +81,17 @@ def test_surface(): f, w, h = tfi.TemporaryFile(mode='w+b'), 100, 100 s = cairo.SVGSurface(f, w, h) +def test_rectangle_int(): + ri = cairo.RectangleInt() + ri.x = 5 + ri.y = 14 + ri.height = 764 + ri.width = 1080 + + assert ri.x == 5 + assert ri.y == 14 + assert ri.height = 764 + assert ri.width = 1080 def test_text(): pass -- 1.7.2.3