From 32b9e3ffd3ac207cb381dc1ddc7d2c55c8e06051 Mon Sep 17 00:00:00 2001 From: aki Date: Tue, 27 May 2008 19:50:15 +0530 Subject: [PATCH] CairoContext almost done ... testing still to be done ... --- individual_files/phpCairoContext.c | 358 +++++++++++++++++++------------------ individual_files/php_phpCairo.h | 27 ++- 2 files changed, 206 insertions(+), 179 deletions(-) diff --git a/individual_files/phpCairoContext.c b/individual_files/phpCairoContext.c index 0e7c6e1..604442c 100644 --- a/individual_files/phpCairoContext.c +++ b/individual_files/phpCairoContext.c @@ -724,7 +724,7 @@ PHP_METHOD(CairoContext, get_font_matrix) object_init(return_value); matrix_object *matobj = (matrix_object *)zend_object_get_address(return_value TSRMLS_CC); - matobj->matrix = &matrix; + matobj->matrix = matrix; } /* }}} get_font_matrix */ @@ -878,7 +878,7 @@ PHP_METHOD(CairoContext, get_matrix) cairo_get_matrix(curr->context, &matrix); object_init(return_value); matrix_object *mobj = (matrix_object *)zend_objects_get_address(return_value TSRMLS_CC); - mobj->matrix = &matrix; + mobj->matrix = matrix; } /* }}} get_matrix */ @@ -1270,8 +1270,9 @@ PHP_METHOD(CairoContext, mask) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - php_error(E_WARNING, "mask: not yet implemented"); RETURN_FALSE; + pattern_object *ptobj = (pattern_object *)zend_objects_get_address(p TSRMLS_CC); + cairo_mask(curr->context, ptobj->pattern); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} mask */ @@ -1297,9 +1298,10 @@ PHP_METHOD(CairoContext, mask_surface) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - + surface_object *sobj=(surface_object *)zend_objects_get_address(s TSRMLS_CC); + cairo_mask_surface(curr->context, sobj->surface, surface_x, surface_y); + phpCAIRO_CONTEXT_ERROR(curr->context); - php_error(E_WARNING, "mask_surface: not yet implemented"); RETURN_FALSE; } /* }}} mask_surface */ @@ -1324,10 +1326,10 @@ PHP_METHOD(CairoContext, move_to) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "move_to: not yet implemented"); RETURN_FALSE; - + + cairo_move_to(curr->context, x, y); + phpCAIRO_CONTEXT_ERROR(curr->context); + } /* }}} move_to */ @@ -1349,9 +1351,8 @@ PHP_METHOD(CairoContext, new_path) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "new_path: not yet implemented"); RETURN_FALSE; + cairo_new_path(curr->context); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} new_path */ @@ -1375,9 +1376,8 @@ PHP_METHOD(CairoContext, new_sub_path) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - php_error(E_WARNING, "new_sub_path: not yet implemented"); RETURN_FALSE; - + cairo_new_sub_path(curr->context); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} new_sub_path */ @@ -1399,10 +1399,10 @@ PHP_METHOD(CairoContext, paint) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); + cairo_paint(curr->context); + phpCAIRO_CONTEXT_ERROR(curr->context); - php_error(E_WARNING, "paint: not yet implemented"); RETURN_FALSE; - } /* }}} paint */ @@ -1425,16 +1425,15 @@ PHP_METHOD(CairoContext, paint_with_alpha) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "paint_with_alpha: not yet implemented"); RETURN_FALSE; + cairo_paint_with_alpha(curr->context, alpha); + } /* }}} paint_with_alpha */ -/* {{{ proto array path_extents([object path]) +/* {{{ proto array path_extents([object path]) --- need to shift it to path -- */ PHP_METHOD(CairoContext, path_extents) { @@ -1480,10 +1479,10 @@ PHP_METHOD(CairoContext, pop_group) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - php_error(E_WARNING, "pop_group: not yet implemented"); RETURN_FALSE; - object_init(return_value); + pattern_object *ptobj=(pattern_object *)zend_objects_get_address(return_value TSRMLS_CC); + ptobj->pattern = cairo_pop_group(curr->context); + } /* }}} pop_group */ @@ -1505,10 +1504,10 @@ PHP_METHOD(CairoContext, pop_group_to_source) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); + cairo_pop_group_to_source(curr->context); + phpCAIRO_CONTEXT_ERROR(curr->context); - php_error(E_WARNING, "pop_group_to_source: not yet implemented"); RETURN_FALSE; - } /* }}} pop_group_to_source */ @@ -1530,10 +1529,10 @@ PHP_METHOD(CairoContext, push_group) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); + cairo_push_group(curr->context); + phpCAIRO_CONTEXT_ERROR(curr->context); - php_error(E_WARNING, "push_group: not yet implemented"); RETURN_FALSE; - } /* }}} push_group */ @@ -1546,7 +1545,7 @@ PHP_METHOD(CairoContext, push_group_with_content) zend_class_entry * _this_ce; zval * _this_zval = NULL; - long content = 0; + cairo_content_t content; @@ -1556,9 +1555,8 @@ PHP_METHOD(CairoContext, push_group_with_content) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "push_group_with_content: not yet implemented"); RETURN_FALSE; + cairo_push_group_with_content(curr->context, content); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} push_group_with_content */ @@ -1585,9 +1583,9 @@ PHP_METHOD(CairoContext, rectangle) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "rectangle: not yet implemented"); RETURN_FALSE; + cairo_rectangle(curr->context, x, y, width, height); + phpCAIRO_CONTEXT_ERROR(curr->context); + } /* }}} rectangle */ @@ -1616,9 +1614,8 @@ PHP_METHOD(CairoContext, rel_curve_to) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "rel_curve_to: not yet implemented"); RETURN_FALSE; + cairo_rel_curve_to(curr->context, x1, y1, x2, y2, x3, y3); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} rel_curve_to */ @@ -1643,9 +1640,8 @@ PHP_METHOD(CairoContext, rel_line_to) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "rel_line_to: not yet implemented"); RETURN_FALSE; + cairo_rel_line_to(curr->context, x, y); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} rel_line_to */ @@ -1670,10 +1666,8 @@ PHP_METHOD(CairoContext, rel_move_to) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "rel_move_to: not yet implemented"); RETURN_FALSE; - + cairo_rel_move_to(curr->context, x, y); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} rel_move_to */ @@ -1695,10 +1689,10 @@ PHP_METHOD(CairoContext, reset_clip) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); + cairo_reset_clip(curr->context); + phpCAIRO_CONTEXT_ERROR(curr->context); - php_error(E_WARNING, "reset_clip: not yet implemented"); RETURN_FALSE; - } /* }}} reset_clip */ @@ -1721,8 +1715,9 @@ PHP_METHOD(CairoContext, restore) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - php_error(E_WARNING, "restore: not yet implemented"); RETURN_FALSE; + cairo_restore(curr->context); + phpCAIRO_CONTEXT_ERROR(curr->context); + } /* }}} restore */ @@ -1746,10 +1741,9 @@ PHP_METHOD(CairoContext, rotate) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "rotate: not yet implemented"); RETURN_FALSE; - + cairo_rotate(curr->context, angle); + phpCAIRO_CONTEXT_ERROR(curr->context); + } /* }}} rotate */ @@ -1772,8 +1766,8 @@ PHP_METHOD(CairoContext, save) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - php_error(E_WARNING, "save: not yet implemented"); RETURN_FALSE; + cairo_save(curr->context); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} save */ @@ -1799,8 +1793,9 @@ PHP_METHOD(CairoContext, scale) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); + cairo_scale(curr->context, x, y); + phpCAIRO_CONTEXT_ERROR(curr->context); - php_error(E_WARNING, "scale: not yet implemented"); RETURN_FALSE; } /* }}} scale */ @@ -1814,21 +1809,21 @@ PHP_METHOD(CairoContext, select_font_face) zend_class_entry * _this_ce; zval * _this_zval = NULL; - zval * obj = NULL; - long slant = 0; - long weight = 0; + const char * family = NULL; + int family_len = 0; + cairo_font_slant_t slant = CAIRO_FONT_SLANT_NORMAL; + cairo_font_weight_t weight = CAIRO_FONT_WEIGHT_NORMAL; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo|ll", &_this_zval, CairoContext_ce_ptr, &obj, &slant, &weight) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|ll", &_this_zval, CairoContext_ce_ptr, &family, &family_len, &slant, &weight) == FAILURE) { return; } _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "select_font_face: not yet implemented"); RETURN_FALSE; + cairo_select_font_face(curr->context, family, slant, weight); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} select_font_face */ @@ -1842,7 +1837,7 @@ PHP_METHOD(CairoContext, set_antialias) zend_class_entry * _this_ce; zval * _this_zval = NULL; - long antialias = 0; + cairo_antialias_t antialias = CAIRO_ANTIALIAS_DEFAULT; @@ -1852,36 +1847,43 @@ PHP_METHOD(CairoContext, set_antialias) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "set_antialias: not yet implemented"); RETURN_FALSE; - + cairo_set_antialias(curr->context, antialias); + phpCAIRO_CONTEXT_ERROR(curr->context); + } /* }}} set_antialias */ -/* {{{ proto void set_dash(object dashes [,float offset]) +/* {{{ proto void set_dash(array dashes, int num_dashes [,float offset]) */ PHP_METHOD(CairoContext, set_dash) { zend_class_entry * _this_ce; - + double *das; zval * _this_zval = NULL; zval * dashes = NULL; + long num_dashes = 0; + HashTable *dashes_hash = NULL; double offset = 0.0; + int i; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo|d", &_this_zval, CairoContext_ce_ptr, &dashes, &offset) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oa/l|d", &_this_zval, CairoContext_ce_ptr, &dashes, &offset) == FAILURE) { return; } - + dashes_hash = HASH_OF(dashes); + das = emalloc(num_dashes * sizeof(double)); _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); + for(i=0; icontext, das, num_dashes, offset); + phpCAIRO_CONTEXT_ERROR(curr->context); - php_error(E_WARNING, "set_dash: not yet implemented"); RETURN_FALSE; } /* }}} set_dash */ @@ -1895,7 +1897,7 @@ PHP_METHOD(CairoContext, set_fill_rule) zend_class_entry * _this_ce; zval * _this_zval = NULL; - long fill_rule = 0; + cairo_fill_rule_t fill_rule = 0; @@ -1905,10 +1907,8 @@ PHP_METHOD(CairoContext, set_fill_rule) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "set_fill_rule: not yet implemented"); RETURN_FALSE; - + cairo_set_fill_rule(curr->context, fill_rule); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} set_fill_rule */ @@ -1931,10 +1931,15 @@ PHP_METHOD(CairoContext, set_font_face) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "set_font_face: not yet implemented"); RETURN_FALSE; - + if (obj != NULL) { + fontface_object *ffobj = (fontface_object *)zend_objects_get_address(obj TSRMLS_CC); + cairo_set_font_face(curr->context, ffobj->fontface); + } + else + cairo_set_font_face(curr->context, NULL); + phpCAIRO_CONTEXT_ERROR(curr->context); + + } /* }}} set_font_face */ @@ -1957,9 +1962,9 @@ PHP_METHOD(CairoContext, set_font_matrix) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "set_font_matrix: not yet implemented"); RETURN_FALSE; + matrix_object *mobj=(matrix_object *)zend_objects_get_address(matrix TSRMLS_CC); + cairo_set_font_matrix(curr->context, &mobj->matrix); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} set_font_matrix */ @@ -1983,9 +1988,10 @@ PHP_METHOD(CairoContext, set_font_options) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - + fontoptions_object *foobj=(fontoptions_object *)zend_objects_get_address(options TSRMLS_CC); + cairo_set_font_options(curr->context, foobj->fontoptions); + phpCAIRO_CONTEXT_ERROR(curr->context); - php_error(E_WARNING, "set_font_options: not yet implemented"); RETURN_FALSE; } /* }}} set_font_options */ @@ -2009,9 +2015,8 @@ PHP_METHOD(CairoContext, set_font_size) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "set_font_size: not yet implemented"); RETURN_FALSE; + cairo_set_font_size(curr->context, size); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} set_font_size */ @@ -2035,9 +2040,10 @@ PHP_METHOD(CairoContext, set_line_cap) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); + cairo_set_line_cap(curr->context, line_cap); + phpCAIRO_CONTEXT_ERROR(curr->context); - php_error(E_WARNING, "set_line_cap: not yet implemented"); RETURN_FALSE; } /* }}} set_line_cap */ @@ -2062,8 +2068,8 @@ PHP_METHOD(CairoContext, set_line_join) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - php_error(E_WARNING, "set_line_join: not yet implemented"); RETURN_FALSE; + cairo_set_line_join(curr->context, line_join); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} set_line_join */ @@ -2110,9 +2116,9 @@ PHP_METHOD(CairoContext, set_matrix) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "set_matrix: not yet implemented"); RETURN_FALSE; + matrix_object *mobj=(matrix_object *)zend_objects_get_address(matix TSRMLS_CC); + cairo_set_matrix(curr->context, &mobj->matrix); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} set_matrix */ @@ -2136,10 +2142,9 @@ PHP_METHOD(CairoContext, set_miter_limit) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "set_miter_limit: not yet implemented"); RETURN_FALSE; - + cairo_set_mitter_limit(curr->context, limit); + phpCAIRO_CONTEXT_ERROR(curr->context); + } /* }}} set_miter_limit */ @@ -2162,9 +2167,8 @@ PHP_METHOD(CairoContext, set_operator) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "set_operator: not yet implemented"); RETURN_FALSE; + cairo_set_operator(curr->context, op); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} set_operator */ @@ -2188,9 +2192,9 @@ PHP_METHOD(CairoContext, set_source) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "set_source: not yet implemented"); RETURN_FALSE; + pattern_object *ptobj=(pattern_object *)zend_objects_get_address(p TSRMLS_CC); + cairo_set_source(curr->context, ptobj->pattern); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} set_source */ @@ -2216,9 +2220,8 @@ PHP_METHOD(CairoContext, set_source_rgb) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "set_source_rgb: not yet implemented"); RETURN_FALSE; + cairo_set_source_rgb(curr->context, red, green, blue); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} set_source_rgb */ @@ -2245,10 +2248,9 @@ PHP_METHOD(CairoContext, set_source_rgba) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "set_source_rgba: not yet implemented"); RETURN_FALSE; - + cairo_set_source_rgba(curr->context, red, green, blue, alpha); + phpCAIRO_CONTEXT_ERROR(curr->context); + } /* }}} set_source_rgba */ @@ -2273,9 +2275,9 @@ PHP_METHOD(CairoContext, set_source_surface) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "set_source_surface: not yet implemented"); RETURN_FALSE; + surface_object *sobj=(surface_object *)zend_objects_get_address(surface TSRMLS_CC); + cairo_set_source_surface(curr->context, sobj->surface, x, y); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} set_source_surface */ @@ -2299,36 +2301,44 @@ PHP_METHOD(CairoContext, set_tolerance) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "set_tolerance: not yet implemented"); RETURN_FALSE; + cairo_set_tolerance(curr->context, tolerance); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} set_tolerance */ -/* {{{ proto void show_glyphs(object glyphs [,int num_glyphs]) +/* {{{ proto void show_glyphs(array obj ,int num_glyphs) */ PHP_METHOD(CairoContext, show_glyphs) { zend_class_entry * _this_ce; - + int i; zval * _this_zval = NULL; - zval * glyphs = NULL; + zval * obj = NULL; long num_glyphs = 0; + HashTable *obj_hash = NULL; + cairo_glyph_t *glyphs=NULL, *glyph; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo|l", &_this_zval, CairoContext_ce_ptr, &glyphs, &num_glyphs) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oa/l", &_this_zval, CairoContext_ce_ptr, &obj, &num_glyphs) == FAILURE) { return; } _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); + obj_hash = HASH_OF(obj); + glyphs = emalloc(num_glyphs*sizeof(cairo_glyph_t)); + for(i=0 , glyph=glyphs; icontext, glyphs, num_glyphs); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} show_glyphs */ @@ -2351,36 +2361,35 @@ PHP_METHOD(CairoContext, show_page) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "show_page: not yet implemented"); RETURN_FALSE; + cairo_show_page(curr->context); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} show_page */ -/* {{{ proto void show_text(object obj) +/* {{{ proto void show_text(string obj) */ PHP_METHOD(CairoContext, show_text) { zend_class_entry * _this_ce; zval * _this_zval = NULL; - zval * obj = NULL; + const char * obj = NULL; + int obj_len = 0; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &_this_zval, CairoContext_ce_ptr, &obj) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &_this_zval, CairoContext_ce_ptr, &obj, &obj_len) == FAILURE) { return; } _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "show_text: not yet implemented"); RETURN_FALSE; - + cairo_show_text(curr->context, obj); + phpCAIRO_CONTEXT_ERROR(curr->context); + } /* }}} show_text */ @@ -2403,6 +2412,8 @@ PHP_METHOD(CairoContext, stroke) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr = (context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); cairo_stroke(curr->context); + phpCAIRO_CONTEXT_ERROR(curr->context); + } /* }}} stroke */ @@ -2416,6 +2427,7 @@ PHP_METHOD(CairoContext, stroke_extents) zend_class_entry * _this_ce; zval * _this_zval = NULL; + double x1=0, x2=0, y1=0, y2=0; @@ -2425,13 +2437,14 @@ PHP_METHOD(CairoContext, stroke_extents) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - + cairo_stroke_extents(curr->context, &x1, &y1, &x2, &y2); array_init(return_value); + add_assoc_double(return_value, "x1", x1); + add_assoc_double(return_value, "y1", y1); + add_assoc_double(return_value, "x2", x2); + add_assoc_double(return_value, "y2", y2); - php_error(E_WARNING, "stroke_extents: not yet implemented"); RETURN_FALSE; - - array_init(return_value); } /* }}} stroke_extents */ @@ -2453,64 +2466,68 @@ PHP_METHOD(CairoContext, stroke_preserve) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "stroke_preserve: not yet implemented"); RETURN_FALSE; + cairo_stroke_preserve(curr->context); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} stroke_preserve */ -/* {{{ proto array text_extents(object extents) +/* {{{ proto array text_extents(string str) */ PHP_METHOD(CairoContext, text_extents) { zend_class_entry * _this_ce; zval * _this_zval = NULL; - zval * extents = NULL; - + const char * str = NULL; + long str_len=0; + cairo_text_extents_t extents; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &_this_zval, CairoContext_ce_ptr, &extents) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &_this_zval, CairoContext_ce_ptr, &str, &str_len) == FAILURE) { return; } _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); + cairo_text_extents(curr->context, str, &extents); array_init(return_value); + add_assoc_double(return_value, "x_bearing", extents.x_bearing); + add_assoc_double(return_value, "y_bearing", extents.y_bearing); + add_assoc_double(return_value, "width", extents.width); + add_assoc_double(return_value, "height", extents.height); + add_assoc_double(return_value, "x_advance", extents.x_advance); + add_assoc_double(return_value, "y_advance", extents.y_advance); - php_error(E_WARNING, "text_extents: not yet implemented"); RETURN_FALSE; - - array_init(return_value); } /* }}} text_extents */ -/* {{{ proto void text_path(object obj) +/* {{{ proto void text_path(string obj) */ PHP_METHOD(CairoContext, text_path) { zend_class_entry * _this_ce; zval * _this_zval = NULL; - zval * obj = NULL; + const char * obj = NULL; + long obj_len = 0; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &_this_zval, CairoContext_ce_ptr, &obj) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &_this_zval, CairoContext_ce_ptr, &obj, &obj_len) == FAILURE) { return; } _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "text_path: not yet implemented"); RETURN_FALSE; + cairo_text_path(curr->context, obj); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} text_path */ @@ -2534,10 +2551,10 @@ PHP_METHOD(CairoContext, transform) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - - php_error(E_WARNING, "transform: not yet implemented"); RETURN_FALSE; - + matrix_object *mobj = (matrix_object *)zend_objects_get_address(matrix TSRMLS_CC); + cairo_transform(curr->context, &mobj->matrix); + phpCAIRO_CONTEXT_ERROR(curr->context); + } /* }}} transform */ @@ -2562,8 +2579,8 @@ PHP_METHOD(CairoContext, translate) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - php_error(E_WARNING, "translate: not yet implemented"); RETURN_FALSE; + cairo_translate(curr->context, tx, ty); + phpCAIRO_CONTEXT_ERROR(curr->context); } /* }}} translate */ @@ -2589,12 +2606,13 @@ PHP_METHOD(CairoContext, user_to_device) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); + cairo_user_to_device(curr->context, &x, &y); + phpCAIRO_CONTEXT_ERROR(curr->context); array_init(return_value); + add_assoc_double(return_value, "x", x); + add_assoc_double(return_value, "y", y); - php_error(E_WARNING, "user_to_device: not yet implemented"); RETURN_FALSE; - - array_init(return_value); } /* }}} user_to_device */ @@ -2618,13 +2636,13 @@ PHP_METHOD(CairoContext, user_to_device_distance) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - - + cairo_user_to_device_distance(curr->context, &dx, &dy); + phpCAIRO_CONTEXT_ERROR(curr->context); + array_init(return_value); + add_assoc_double(return_value, "x", dx); + add_assoc_double(return_value, "y", dy); - php_error(E_WARNING, "user_to_device_distance: not yet implemented"); RETURN_FALSE; - - array_init(return_value); } /* }}} user_to_device_distance */ diff --git a/individual_files/php_phpCairo.h b/individual_files/php_phpCairo.h index 62f1d42..f941aed 100644 --- a/individual_files/php_phpCairo.h +++ b/individual_files/php_phpCairo.h @@ -71,7 +71,7 @@ typedef struct _fontface_object { typedef struct _matrix_object { zend_object std; - cairo_matrix_t *matrix; + cairo_matrix_t matrix; } matrix_object; typedef struct _pattern_object { @@ -727,7 +727,7 @@ ZEND_END_ARG_INFO() PHP_METHOD(CairoContext, select_font_face); #if (PHP_MAJOR_VERSION >= 5) ZEND_BEGIN_ARG_INFO_EX(CairoContext__select_font_face_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_OBJ_INFO(0, obj, , 1) + ZEND_ARG_INFO(0, family) ZEND_ARG_INFO(0, slant) ZEND_ARG_INFO(0, weight) ZEND_END_ARG_INFO() @@ -746,8 +746,13 @@ ZEND_END_ARG_INFO() PHP_METHOD(CairoContext, set_dash); #if (PHP_MAJOR_VERSION >= 5) -ZEND_BEGIN_ARG_INFO_EX(CairoContext__set_dash_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_OBJ_INFO(0, dashes, , 1) +ZEND_BEGIN_ARG_INFO_EX(CairoContext__set_dash_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2) +#if (PHP_MINOR_VERSION > 0) + ZEND_ARG_ARRAY_INFO(0, dashes, 1) +#else + ZEND_ARG_INFO(0, dashes) +#endif + ZEND_ARG_INFO(0, num_dashes) ZEND_ARG_INFO(0, offset) ZEND_END_ARG_INFO() #else /* PHP 4.x */ @@ -907,8 +912,12 @@ ZEND_END_ARG_INFO() PHP_METHOD(CairoContext, show_glyphs); #if (PHP_MAJOR_VERSION >= 5) -ZEND_BEGIN_ARG_INFO_EX(CairoContext__show_glyphs_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_OBJ_INFO(0, glyphs, , 1) +ZEND_BEGIN_ARG_INFO_EX(CairoContext__show_glyphs_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2) +#if (PHP_MINOR_VERSION > 0) + ZEND_ARG_ARRAY_INFO(0, obj, 1) +#else + ZEND_ARG_INFO(0, obj) +#endif ZEND_ARG_INFO(0, num_glyphs) ZEND_END_ARG_INFO() #else /* PHP 4.x */ @@ -926,7 +935,7 @@ ZEND_END_ARG_INFO() PHP_METHOD(CairoContext, show_text); #if (PHP_MAJOR_VERSION >= 5) ZEND_BEGIN_ARG_INFO_EX(CairoContext__show_text_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_OBJ_INFO(0, obj, , 1) + ZEND_ARG_INFO(0, obj) ZEND_END_ARG_INFO() #else /* PHP 4.x */ #define CairoContext__show_text_args NULL @@ -959,7 +968,7 @@ ZEND_END_ARG_INFO() PHP_METHOD(CairoContext, text_extents); #if (PHP_MAJOR_VERSION >= 5) ZEND_BEGIN_ARG_INFO_EX(CairoContext__text_extents_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_OBJ_INFO(0, extents, , 1) + ZEND_ARG_INFO(0, str) ZEND_END_ARG_INFO() #else /* PHP 4.x */ #define CairoContext__text_extents_args NULL @@ -968,7 +977,7 @@ ZEND_END_ARG_INFO() PHP_METHOD(CairoContext, text_path); #if (PHP_MAJOR_VERSION >= 5) ZEND_BEGIN_ARG_INFO_EX(CairoContext__text_path_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1) - ZEND_ARG_OBJ_INFO(0, obj, , 1) + ZEND_ARG_INFO(0, obj) ZEND_END_ARG_INFO() #else /* PHP 4.x */ #define CairoContext__text_path_args NULL -- 2.11.4.GIT