From deae50ad41478ff4d5ad75899e33563101809ddf Mon Sep 17 00:00:00 2001 From: aki Date: Sat, 24 May 2008 14:44:04 +0530 Subject: [PATCH] Started adding Exception Handling --- individual_files/phpCairo.c | 24 +----- individual_files/phpCairoContext.c | 137 ++++++++++++++++++++++-------- individual_files/phpCairoException.c | 48 +++++++++++ individual_files/phpCairoExceptionMacro.c | 31 +++++++ 4 files changed, 184 insertions(+), 56 deletions(-) create mode 100644 individual_files/phpCairoException.c create mode 100644 individual_files/phpCairoExceptionMacro.c diff --git a/individual_files/phpCairo.c b/individual_files/phpCairo.c index c073f59..e92fbc8 100644 --- a/individual_files/phpCairo.c +++ b/individual_files/phpCairo.c @@ -15,6 +15,8 @@ /* $ Id: $ */ #include "php_phpCairo.h" +#include "phpCairoExceptionMacro.c" +#include "phpCairoException.c" #include "phpCairoSurface.c" #include "phpCairoContext.c" #if HAVE_PHPCAIRO @@ -1446,28 +1448,6 @@ static void class_init_CairoScaledFont(void) /* }}} Class CairoScaledFont */ -/* {{{ Class CairoException */ - -static zend_class_entry * CairoException_ce_ptr = NULL; - -/* {{{ Methods */ - -static zend_function_entry CairoException_methods[] = { - { NULL, NULL, NULL } -}; - -/* }}} Methods */ - -static void class_init_CairoException(void) -{ - zend_class_entry ce; - - INIT_CLASS_ENTRY(ce, "CairoException", CairoException_methods); - CairoException_ce_ptr = zend_register_internal_class_ex(&ce, NULL, "Exception" TSRMLS_CC); -} - -/* }}} Class CairoException */ - /* }}} Class definitions*/ /* {{{ phpCairo_functions[] */ diff --git a/individual_files/phpCairoContext.c b/individual_files/phpCairoContext.c index e91bdb0..b17e31f 100644 --- a/individual_files/phpCairoContext.c +++ b/individual_files/phpCairoContext.c @@ -58,9 +58,8 @@ PHP_METHOD(CairoContext, append_path) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr = (context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); path_object *pobj=(path_object *)zend_objects_get_address(p TSRMLS_CC); - //cairo_append_path(curr->context,pobj->path); - - php_error(E_WARNING, "append_path: not yet implemented"); RETURN_FALSE; + cairo_append_path(curr->context,pobj->path); + phpCAIRO_CONTEXT_ERROR(curr->context) } /* }}} append_path */ @@ -89,16 +88,11 @@ PHP_METHOD(CairoContext, arc) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); cairo_arc(curr->context,xc,yc,radius,angle1,angle2); - - - - //php_error(E_WARNING, "arc: not yet implemented"); RETURN_FALSE; + phpCAIRO_CONTEXT_ERROR(curr->context) } /* }}} arc */ - - /* {{{ proto void arc_negative(float xc, float yc, float radius, float angle1, float angle2) */ PHP_METHOD(CairoContext, arc_negative) @@ -121,10 +115,11 @@ PHP_METHOD(CairoContext, arc_negative) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr = (context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - cairo_arc_negative(curr->context, xc, yc, radius, angle1, angle2); + + cairo_arc_negative(curr->context, xc, yc, radius, angle1, angle2); + phpCAIRO_CONTEXT_ERROR(curr->context) - php_error(E_WARNING, "arc_negative: not yet implemented"); RETURN_FALSE; } /* }}} arc_negative */ @@ -148,9 +143,7 @@ PHP_METHOD(CairoContext, clip) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); cairo_clip(curr->context); - - php_error(E_WARNING, "clip: not yet implemented"); RETURN_FALSE; - + phpCAIRO_CONTEXT_ERROR(curr->context) } /* }}} clip */ @@ -174,15 +167,13 @@ PHP_METHOD(CairoContext, clip_extents) context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); cairo_clip_extents(curr->context, &x1, &y1, &x2, &y2); - + phpCAIRO_CONTEXT_ERROR(curr->context) array_init(return_value); add_next_index_double(return_value, x1); add_next_index_double(return_value, y1); add_next_index_double(return_value, x2); add_next_index_double(return_value, y2); - php_error(E_WARNING, "clip_extents: not yet implemented"); RETURN_FALSE; - } /* }}} clip_extents */ @@ -207,7 +198,7 @@ PHP_METHOD(CairoContext, clip_preserve) context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); cairo_clip_preserve(curr->context); - + phpCAIRO_CONTEXT_ERROR(curr->context) } /* }}} clip_preserve */ @@ -231,8 +222,7 @@ PHP_METHOD(CairoContext, close_path) context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); cairo_close_path(curr->context); - - php_error(E_WARNING, "close_path: not yet implemented"); RETURN_FALSE; + phpCAIRO_CONTEXT_ERROR(curr->context) } /* }}} close_path */ @@ -258,7 +248,7 @@ PHP_METHOD(CairoContext, copy_clip_rectangle_list) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); rlist = cairo_copy_clip_rectangle_list(curr->context); - /* NEED TO CHECK FOR EXCEPTION */ + phpCAIRO_ERROR(rlist->status) /* ALLOC_INIT_ZVAL(arr); array_init(arr); @@ -299,7 +289,7 @@ PHP_METHOD(CairoContext, copy_page) _this_ce = Z_OBJCE_P(_this_zval); context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); cairo_copy_page(curr->context); - + phpCAIRO_CONTEXT_ERROR(curr->context) } /* }}} copy_page */ @@ -323,12 +313,9 @@ PHP_METHOD(CairoContext, copy_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, "copy_path: not yet implemented"); RETURN_FALSE; - object_init(return_value); path_object *pobj = (path_object *)zend_objects_get_address(return_value TSRMLS_CC); - + pobj = cairo_copy_path(curr->context); } /* }}} copy_path */ @@ -349,10 +336,9 @@ PHP_METHOD(CairoContext, copy_path_flat) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); - php_error(E_WARNING, "copy_path_flat: not yet implemented"); RETURN_FALSE; - object_init(return_value); } /* }}} copy_path_flat */ @@ -380,6 +366,7 @@ PHP_METHOD(CairoContext, 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, "curve_to: not yet implemented"); RETURN_FALSE; @@ -406,6 +393,7 @@ PHP_METHOD(CairoContext, device_to_user) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); array_init(return_value); @@ -435,6 +423,7 @@ PHP_METHOD(CairoContext, device_to_user_distance) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); array_init(return_value); @@ -462,6 +451,7 @@ PHP_METHOD(CairoContext, fill) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); php_error(E_WARNING, "fill: not yet implemented"); RETURN_FALSE; @@ -486,6 +476,7 @@ PHP_METHOD(CairoContext, fill_extents) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); array_init(return_value); @@ -513,6 +504,7 @@ PHP_METHOD(CairoContext, fill_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, "fill_preserve: not yet implemented"); RETURN_FALSE; @@ -537,6 +529,7 @@ PHP_METHOD(CairoContext, font_extents) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); array_init(return_value); @@ -564,6 +557,7 @@ PHP_METHOD(CairoContext, get_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, "get_antialias: not yet implemented"); RETURN_FALSE; @@ -589,6 +583,7 @@ PHP_METHOD(CairoContext, get_current_point) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); array_init(return_value); @@ -616,6 +611,7 @@ PHP_METHOD(CairoContext, get_dash) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); array_init(return_value); @@ -643,6 +639,7 @@ PHP_METHOD(CairoContext, get_dash_count) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); php_error(E_WARNING, "get_dash_count: not yet implemented"); RETURN_FALSE; @@ -668,6 +665,7 @@ PHP_METHOD(CairoContext, get_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, "get_fill_rule: not yet implemented"); RETURN_FALSE; @@ -693,6 +691,7 @@ PHP_METHOD(CairoContext, get_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, "get_font_face: not yet implemented"); RETURN_FALSE; @@ -718,6 +717,7 @@ PHP_METHOD(CairoContext, get_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, "get_font_matrix: not yet implemented"); RETURN_FALSE; @@ -743,6 +743,7 @@ PHP_METHOD(CairoContext, get_font_options) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); php_error(E_WARNING, "get_font_options: not yet implemented"); RETURN_FALSE; @@ -768,6 +769,7 @@ PHP_METHOD(CairoContext, get_group_target) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); php_error(E_WARNING, "get_group_target: not yet implemented"); RETURN_FALSE; @@ -793,6 +795,7 @@ PHP_METHOD(CairoContext, get_line_cap) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); php_error(E_WARNING, "get_line_cap: not yet implemented"); RETURN_FALSE; @@ -818,6 +821,7 @@ PHP_METHOD(CairoContext, get_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, "get_line_join: not yet implemented"); RETURN_FALSE; @@ -843,6 +847,7 @@ PHP_METHOD(CairoContext, get_line_width) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); php_error(E_WARNING, "get_line_width: not yet implemented"); RETURN_FALSE; @@ -868,6 +873,7 @@ PHP_METHOD(CairoContext, get_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, "get_matrix: not yet implemented"); RETURN_FALSE; @@ -893,6 +899,7 @@ PHP_METHOD(CairoContext, get_matrix_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, "get_matrix_limit: not yet implemented"); RETURN_FALSE; @@ -918,7 +925,8 @@ PHP_METHOD(CairoContext, get_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, "get_operator: not yet implemented"); RETURN_FALSE; @@ -943,6 +951,7 @@ PHP_METHOD(CairoContext, get_scaled_font) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); php_error(E_WARNING, "get_scaled_font: not yet implemented"); RETURN_FALSE; @@ -968,6 +977,7 @@ PHP_METHOD(CairoContext, get_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, "get_source: not yet implemented"); RETURN_FALSE; @@ -993,6 +1003,7 @@ PHP_METHOD(CairoContext, get_target) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); php_error(E_WARNING, "get_target: not yet implemented"); RETURN_FALSE; @@ -1018,6 +1029,7 @@ PHP_METHOD(CairoContext, get_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, "get_tolerance: not yet implemented"); RETURN_FALSE; @@ -1045,6 +1057,7 @@ PHP_METHOD(CairoContext, glyph_extents) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); array_init(return_value); @@ -1074,6 +1087,7 @@ PHP_METHOD(CairoContext, glyph_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, "glyph_path: not yet implemented"); RETURN_FALSE; @@ -1098,6 +1112,7 @@ PHP_METHOD(CairoContext, has_current_point) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); do { @@ -1123,6 +1138,7 @@ PHP_METHOD(CairoContext, identity_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, "identity_matrix: not yet implemented"); RETURN_FALSE; @@ -1149,6 +1165,7 @@ PHP_METHOD(CairoContext, in_fill) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); php_error(E_WARNING, "in_fill: not yet implemented"); RETURN_FALSE; @@ -1176,6 +1193,7 @@ PHP_METHOD(CairoContext, in_stroke) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); php_error(E_WARNING, "in_stroke: not yet implemented"); RETURN_FALSE; @@ -1203,6 +1221,7 @@ PHP_METHOD(CairoContext, 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, "line_to: not yet implemented"); RETURN_FALSE; @@ -1228,6 +1247,7 @@ 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; @@ -1255,8 +1275,9 @@ 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); - + php_error(E_WARNING, "mask_surface: not yet implemented"); RETURN_FALSE; } @@ -1281,6 +1302,7 @@ 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; @@ -1305,6 +1327,7 @@ 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; @@ -1329,6 +1352,7 @@ 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; @@ -1353,6 +1377,7 @@ PHP_METHOD(CairoContext, paint) } _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: not yet implemented"); RETURN_FALSE; @@ -1378,6 +1403,7 @@ 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; @@ -1403,6 +1429,7 @@ PHP_METHOD(CairoContext, path_extents) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); array_init(return_value); @@ -1430,6 +1457,7 @@ 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; @@ -1455,6 +1483,7 @@ 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); php_error(E_WARNING, "pop_group_to_source: not yet implemented"); RETURN_FALSE; @@ -1479,6 +1508,7 @@ 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); php_error(E_WARNING, "push_group: not yet implemented"); RETURN_FALSE; @@ -1504,6 +1534,7 @@ 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; @@ -1532,6 +1563,7 @@ 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; @@ -1562,6 +1594,7 @@ 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; @@ -1588,6 +1621,7 @@ 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; @@ -1614,6 +1648,7 @@ 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; @@ -1638,6 +1673,7 @@ 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); php_error(E_WARNING, "reset_clip: not yet implemented"); RETURN_FALSE; @@ -1662,8 +1698,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; } @@ -1687,6 +1724,7 @@ 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; @@ -1711,6 +1749,7 @@ 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; @@ -1737,6 +1776,7 @@ PHP_METHOD(CairoContext, scale) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); php_error(E_WARNING, "scale: not yet implemented"); RETURN_FALSE; @@ -1764,6 +1804,7 @@ PHP_METHOD(CairoContext, select_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, "select_font_face: not yet implemented"); RETURN_FALSE; @@ -1789,6 +1830,7 @@ 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; @@ -1815,8 +1857,9 @@ PHP_METHOD(CairoContext, set_dash) } _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_dash: not yet implemented"); RETURN_FALSE; } @@ -1840,6 +1883,7 @@ 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; @@ -1865,6 +1909,7 @@ 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; @@ -1890,6 +1935,7 @@ 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; @@ -1915,8 +1961,9 @@ 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); - + php_error(E_WARNING, "set_font_options: not yet implemented"); RETURN_FALSE; } @@ -1940,6 +1987,7 @@ 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; @@ -1965,6 +2013,7 @@ 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); php_error(E_WARNING, "set_line_cap: not yet implemented"); RETURN_FALSE; @@ -1990,6 +2039,7 @@ 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; @@ -2038,6 +2088,7 @@ 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; @@ -2063,6 +2114,7 @@ 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; @@ -2088,6 +2140,7 @@ 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; @@ -2113,6 +2166,7 @@ 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; @@ -2140,8 +2194,9 @@ 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; } @@ -2168,6 +2223,7 @@ 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; @@ -2195,6 +2251,7 @@ 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; @@ -2220,6 +2277,7 @@ 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; @@ -2246,6 +2304,7 @@ PHP_METHOD(CairoContext, show_glyphs) } _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_glyphs: not yet implemented"); RETURN_FALSE; @@ -2270,6 +2329,7 @@ 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; @@ -2295,6 +2355,7 @@ PHP_METHOD(CairoContext, show_text) } _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; @@ -2342,6 +2403,7 @@ 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); array_init(return_value); @@ -2369,6 +2431,7 @@ 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; @@ -2394,6 +2457,7 @@ PHP_METHOD(CairoContext, text_extents) } _this_ce = Z_OBJCE_P(_this_zval); + context_object *curr=(context_object *)zend_objects_get_address(_this_zval TSRMLS_CC); array_init(return_value); @@ -2422,6 +2486,7 @@ PHP_METHOD(CairoContext, text_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, "text_path: not yet implemented"); RETURN_FALSE; @@ -2447,6 +2512,7 @@ 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; @@ -2473,6 +2539,7 @@ 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; @@ -2499,6 +2566,7 @@ 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); array_init(return_value); @@ -2528,6 +2596,7 @@ 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); array_init(return_value); diff --git a/individual_files/phpCairoException.c b/individual_files/phpCairoException.c new file mode 100644 index 0000000..1b74ad4 --- /dev/null +++ b/individual_files/phpCairoException.c @@ -0,0 +1,48 @@ +/* {{{ Class CairoException */ + +static zend_class_entry * CairoException_ce_ptr = NULL; + +/* {{{ Methods */ + +static zend_function_entry CairoException_methods[] = { + { NULL, NULL, NULL } +}; + +/* }}} Methods */ + +static void class_init_CairoException(void) +{ + zend_class_entry ce; + + INIT_CLASS_ENTRY(ce, "CairoException", CairoException_methods); + CairoException_ce_ptr = zend_register_internal_class_ex(&ce, zend_exception_get_default(), "Exception" TSRMLS_CC); +} + +/* }}} Class CairoException */ + +void phpCairoCheckStatus(cairo_status_t status) +{ + zend_throw_exception(CairoException_ce_ptr, cairo_status_to_string(status)); + return; + + /* + switch(status) { + case CAIRO_STATUS_SUCCESS: + return 0; + case CAIRO_STATUS_NO_MEMORY: + zend_throw_exception(CairoException_ce_ptr,"No memory", NULL); + break; + case CAIRO_STATUS_READ_ERROR: + case CAIRO_STATUS_WRITE_ERROR: + zend_throw_exception(CairoException_ce_ptr, cairo_status_to_string(status), NULL); + break; + case CAIRO_STATUS_INVALID_RESTORE: + zend_throw_expetion(CairoException_ce_ptr, "Invalid restore", NULL); + break; + case CAIRO_STATUS_INVALID_POP_GROUP: + zend_throw_exception(CairoException_ce_ptr, "Pop group error", NULL); + break; + } */ +} + + diff --git a/individual_files/phpCairoExceptionMacro.c b/individual_files/phpCairoExceptionMacro.c new file mode 100644 index 0000000..933ccbf --- /dev/null +++ b/individual_files/phpCairoExceptionMacro.c @@ -0,0 +1,31 @@ +#define phpCAIRO_ERROR(status) \ + if (status != CAIRO_STATUS_SUCCESS) { \ + phpCairoCheckStatus(status); \ + return; \ + } + +#define phpCAIRO_CONTEXT_ERROR(context) \ + cairo_status_t status = cairo_status (context); \ + phpCAIRO_ERROR(status) + +#define phpCAIRO_PATTERN_ERROR(pattern) \ + cairo_status_t status = cairo_pattern_status(pattern); \ + phpCAIRO_ERROR(status) + +#define phpCAIRO_SURFACE_ERROR(surface) \ + cairo_status_t status = cairo_surface_status(surface); \ + phpCAIRO_ERROR(status) + +#define phpCAIRO_SCALEDFONT_ERROR(sc_font) \ + cairo_status_t status = cairo_scaled_font_status(sc_font); \ + phpCAIRO_ERROR(status) + +#define phpCAIRO_FONTOPTIONS_ERROR(font_opt) \ + cairo_status_t status = cairo_font_options_status(font_opt); \ + phpCAIRO_ERROR(status) + + + + + + -- 2.11.4.GIT