Pattern Class is complete -- Testing to be done ;)
[phpCairo.git] / individual_files / phpCairoPattern.c
blob8dc9d1b00dad02dda12bbca654f9effa187425f0
2 /* {{{ Class CairoPattern */
4 static zend_class_entry * CairoPattern_ce_ptr = NULL;
6 /* {{{ Methods */
9 /* {{{ proto void contruct()
11 PHP_METHOD(CairoPattern, __construct)
13 zend_class_entry * _this_ce;
14 zval * _this_zval;
18 if (ZEND_NUM_ARGS()>0) {
19 WRONG_PARAM_COUNT;
23 php_error(E_ERROR, "Pattern Cannot be initialized"); RETURN_FALSE;
26 /* }}} __construct */
30 /* {{{ proto object get_matrix()
32 PHP_METHOD(CairoPattern, get_matrix)
34 zend_class_entry * _this_ce;
36 zval * _this_zval = NULL;
37 cairo_matrix_t matrix;
39 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoPattern_ce_ptr) == FAILURE) {
40 return;
43 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
44 _this_ce = Z_OBJCE_P(_this_zval);
46 cairo_pattern_get_matrix(curr->pattern, &matrix);
47 object_init(return_value);
48 matrix_object *mobj = (matrix_object *)zend_objects_get_address(return_value TSRMLS_CC);
49 mobj->matrix = matrix;
51 /* }}} get_matrix */
55 /* {{{ proto void set_matrix(object m)
57 PHP_METHOD(CairoPattern, set_matrix)
59 zend_class_entry * _this_ce;
61 zval * _this_zval = NULL;
62 zval * m = NULL;
66 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &_this_zval, CairoPattern_ce_ptr, &m) == FAILURE) {
67 return;
70 _this_ce = Z_OBJCE_P(_this_zval);
71 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
72 matrix_object *mobj = (matrix_object *)zend_objects_get_address(m TSRMLS_CC);
73 cairo_pattern_set_matrix(curr->pattern, &mobj->matrix);
75 /* }}} set_matrix */
78 static zend_function_entry CairoPattern_methods[] = {
79 PHP_ME(CairoPattern, __construct, NULL, /**/ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
80 PHP_ME(CairoPattern, get_matrix, NULL, /**/ZEND_ACC_PUBLIC)
81 PHP_ME(CairoPattern, set_matrix, CairoPattern__set_matrix_args, /**/ZEND_ACC_PUBLIC)
82 { NULL, NULL, NULL }
85 /* }}} Methods */
87 static zend_object_handlers CairoPattern_handlers;
89 static void CairoPattern_object_dtor(void *object)
91 pattern_object *pattern = (pattern_object *)object;
92 zend_hash_destroy(pattern->std.properties);
93 FREE_HASHTABLE(pattern->std.properties);
94 if(pattern->pattern){
95 cairo_pattern_destroy(pattern->pattern);
97 efree(object);
100 static zend_object_value CairoPattern_object_new(zend_class_entry *ce)
102 zend_object_value retval;
103 pattern_object *pattern;
104 zval *temp;
105 pattern=emalloc(sizeof(pattern_object));
106 memset(pattern,0,sizeof(pattern_object));
107 pattern->std.ce = ce;
108 ALLOC_HASHTABLE(pattern->std.properties);
109 zend_hash_init(pattern->std.properties, 0, NULL, ZVAL_PTR_DTOR,0);
110 zend_hash_copy(pattern->std.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &temp, sizeof(zval *));
111 retval.handle = zend_objects_store_put(pattern, NULL, (zend_objects_free_object_storage_t)CairoPattern_object_dtor, NULL TSRMLS_CC);
112 retval.handlers = &CairoPattern_handlers;
113 return retval;
117 static void class_init_CairoPattern(void)
119 zend_class_entry ce;
121 INIT_CLASS_ENTRY(ce, "CairoPattern", CairoPattern_methods);
122 CairoPattern_ce_ptr = zend_register_internal_class(&ce);
123 CairoPattern_ce_ptr->create_object = CairoPattern_object_new;
124 memcpy(&CairoPattern_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
125 CairoPattern_handlers.clone_obj = NULL;
128 /* }}} Class CairoPattern */
130 /* {{{ Class CairoGradient */
132 static zend_class_entry * CairoGradient_ce_ptr = NULL;
134 /* {{{ Methods */
137 /* {{{ proto void construct()
139 PHP_METHOD(CairoGradient, __contruct)
141 zend_class_entry * _this_ce;
143 zval * _this_zval = NULL;
147 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoGradient_ce_ptr) == FAILURE) {
148 return;
151 _this_ce = Z_OBJCE_P(_this_zval);
154 php_error(E_ERROR, "Gradient cannot be initialized"); RETURN_FALSE;
157 /* }}} __contruct */
161 /* {{{ proto void add_color_stop_rgb(float offset, float red, float green, float blue)
163 PHP_METHOD(CairoGradient, add_color_stop_rgb)
165 zend_class_entry * _this_ce;
167 zval * _this_zval = NULL;
168 double offset = 0.0;
169 double red = 0.0;
170 double green = 0.0;
171 double blue = 0.0;
175 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odddd", &_this_zval, CairoGradient_ce_ptr, &offset, &red, &green, &blue) == FAILURE) {
176 return;
179 _this_ce = Z_OBJCE_P(_this_zval);
180 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
181 cairo_pattern_add_color_stop_rgb(curr->pattern, offset, red, green, blue);
182 php_CAIRO_PATTERN_ERROR(curr->pattern);
184 /* }}} add_color_stop_rgb */
188 /* {{{ proto void add_color_stop_rgba(float offset, float red, float green, float blue, float alpha)
190 PHP_METHOD(CairoGradient, add_color_stop_rgba)
192 zend_class_entry * _this_ce;
194 zval * _this_zval = NULL;
195 double offset = 0.0;
196 double red = 0.0;
197 double green = 0.0;
198 double blue = 0.0;
199 double alpha = 0.0;
203 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oddddd", &_this_zval, CairoGradient_ce_ptr, &offset, &red, &green, &blue, &alpha) == FAILURE) {
204 return;
207 _this_ce = Z_OBJCE_P(_this_zval);
208 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
209 cairo_pattern_add_color_stop_rgba(curr->pattern, offset, red, green, blue, alpha);
210 php_CAIRO_PATTERN_ERROR(curr->pattern);
212 /* }}} add_color_stop_rgba */
215 static zend_function_entry CairoGradient_methods[] = {
216 PHP_ME(CairoGradient, __contruct, NULL, /**/ZEND_ACC_PUBLIC)
217 PHP_ME(CairoGradient, add_color_stop_rgb, CairoGradient__add_color_stop_rgb_args, /**/ZEND_ACC_PUBLIC)
218 PHP_ME(CairoGradient, add_color_stop_rgba, CairoGradient__add_color_stop_rgba_args, /**/ZEND_ACC_PUBLIC)
219 { NULL, NULL, NULL }
222 /* }}} Methods */
224 static zend_object_handlers CairoGradient_handlers;
226 static zend_object_value CairoGradient_object_new(zend_class_entry *ce TSRMLS_CC)
228 zend_object_value retval;
229 retval = CairoPattern_object_new(ce TSRMLS_CC);
230 retval.handlers = &CairoGradient_handlers;
231 return retval;
234 static void class_init_CairoGradient(void)
236 zend_class_entry ce;
237 INIT_CLASS_ENTRY(ce, "CairoGradient", CairoGradient_methods);
238 CairoGradient_ce_ptr = zend_register_internal_class_ex(&ce, CairoPattern_ce_ptr, "CairoPattern" TSRMLS_CC);
239 CairoGradient_ce_ptr->create_object = CairoGradient_object_new;
240 memcpy(&CairoGradient_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
244 /* }}} Class CairoGradient */
246 /* {{{ Class CairoLinearGradient */
248 static zend_class_entry * CairoLinearGradient_ce_ptr = NULL;
250 /* {{{ Methods */
253 /* {{{ proto void construct(float x0, float y0, float x1, float y1)
255 PHP_METHOD(CairoLinearGradient, __construct)
257 zend_class_entry * _this_ce;
258 zval * _this_zval;
260 double x0 = 0.0;
261 double y0 = 0.0;
262 double x1 = 0.0;
263 double y1 = 0.0;
267 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddd", &x0, &y0, &x1, &y1) == FAILURE) {
268 return;
271 _this_zval = getThis();
272 _this_ce = Z_OBJCE_P(_this_zval);
273 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
274 curr->pattern = cairo_pattern_create_linear(x0, y0, x1, y1);
277 /* }}} __construct */
281 /* {{{ proto array get_linear_points()
283 PHP_METHOD(CairoLinearGradient, get_linear_points)
285 zend_class_entry * _this_ce;
287 zval * _this_zval = NULL;
288 double x0, y0, x1, y1;
291 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoLinearGradient_ce_ptr) == FAILURE) {
292 return;
295 _this_ce = Z_OBJCE_P(_this_zval);
296 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
297 cairo_pattern_get_linear_points(curr->pattern, &x0, &y0, &x1, &y1);
299 array_init(return_value);
300 add_assoc_double(return_value, "x0", x0);
301 add_assoc_double(return_value, "y0", y0);
302 add_assoc_double(return_value, "x1", x1);
303 add_assoc_double(return_value, "y1", y1);
306 /* }}} get_linear_points */
309 static zend_function_entry CairoLinearGradient_methods[] = {
310 PHP_ME(CairoLinearGradient, __construct, CairoLinearGradient____construct_args, /**/ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
311 PHP_ME(CairoLinearGradient, get_linear_points, NULL, /**/ZEND_ACC_PUBLIC)
312 { NULL, NULL, NULL }
315 /* }}} Methods */
317 static zend_object_handlers CairoLinearGradient_handlers;
319 static zend_object_value CairoLinearGradient_object_new(zend_class_entry *ce TSRMLS_CC)
321 zend_object_value retval;
322 retval = CairoPattern_object_new(ce TSRMLS_CC);
323 retval.handlers = &CairoLinearGradient_handlers;
324 return retval;
327 static void class_init_CairoLinearGradient(void)
329 zend_class_entry ce;
330 INIT_CLASS_ENTRY(ce, "CairoLinearGradient", CairoLinearGradient_methods);
331 CairoLinearGradient_ce_ptr = zend_register_internal_class_ex(&ce, CairoGradient_ce_ptr, "CairoGradient" TSRMLS_CC);
332 CairoLinearGradient_ce_ptr->create_object = CairoLinearGradient_object_new;
333 memcpy(&CairoLinearGradient_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
337 /* }}} Class CairoLinearGradient */
339 /* {{{ Class CairoRadialGradient */
341 static zend_class_entry * CairoRadialGradient_ce_ptr = NULL;
343 /* {{{ Methods */
346 /* {{{ proto void construct(float cx0, float cy0, float radius0, float cx1, float cy1, float radius1)
348 PHP_METHOD(CairoRadialGradient, __constuct)
350 zend_class_entry * _this_ce;
352 zval * _this_zval = NULL;
353 double cx0 = 0.0;
354 double cy0 = 0.0;
355 double radius0 = 0.0;
356 double cx1 = 0.0;
357 double cy1 = 0.0;
358 double radius1 = 0.0;
362 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odddddd", &_this_zval, CairoRadialGradient_ce_ptr, &cx0, &cy0, &radius0, &cx1, &cy1, &radius1) == FAILURE) {
363 return;
366 _this_ce = Z_OBJCE_P(_this_zval);
367 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
368 curr->pattern = cairo_pattern_create_radial(cx0, cy0, radius0, cx1, cy1, radius1);
371 /* }}} __constuct */
375 /* {{{ proto array get_radial_circles()
377 PHP_METHOD(CairoRadialGradient, get_radial_circles)
379 zend_class_entry * _this_ce;
381 zval * _this_zval = NULL;
382 double x0, y0, r0, x1, y1, r1;
385 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoRadialGradient_ce_ptr) == FAILURE) {
386 return;
389 _this_ce = Z_OBJCE_P(_this_zval);
390 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
391 cairo_pattern_get_radial_circles(curr->pattern, &x0, &y0, &r0, &x1, &y1, &r1);
393 array_init(return_value);
394 add_assoc_double(return_value, "x0", x0);
395 add_assoc_double(return_value, "y0", y0);
396 add_assoc_double(return_value, "r0", r0);
397 add_assoc_double(return_value, "x1", x1);
398 add_assoc_double(return_value, "y1", y1);
399 add_assoc_double(return_value, "r1", r1);
402 /* }}} get_radial_circles */
405 static zend_function_entry CairoRadialGradient_methods[] = {
406 PHP_ME(CairoRadialGradient, __constuct, CairoRadialGradient____constuct_args, /**/ZEND_ACC_PUBLIC)
407 PHP_ME(CairoRadialGradient, get_radial_circles, NULL, /**/ZEND_ACC_PUBLIC)
408 { NULL, NULL, NULL }
411 /* }}} Methods */
413 static zend_object_handlers CairoRadialGradient_handlers;
415 static zend_object_value CairoRadialGradient_object_new(zend_class_entry *ce TSRMLS_CC)
417 zend_object_value retval;
418 retval = CairoPattern_object_new(ce TSRMLS_CC);
419 retval.handlers = &CairoRadialGradient_handlers;
420 return retval;
423 static void class_init_CairoRadialGradient(void)
425 zend_class_entry ce;
426 INIT_CLASS_ENTRY(ce, "CairoRadialGradient", CairoRadialGradient_methods);
427 CairoRadialGradient_ce_ptr = zend_register_internal_class_ex(&ce, CairoGradient_ce_ptr, "CairoGradient" TSRMLS_CC);
428 CairoRadialGradient_ce_ptr->create_object = CairoRadialGradient_object_new;
429 memcpy(&CairoRadialGradient_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
432 /* }}} Class CairoRadialGradient */
434 /* {{{ Class CairoSolidPattern */
436 static zend_class_entry * CairoSolidPattern_ce_ptr = NULL;
438 /* {{{ Methods */
441 /* {{{ proto void construct(float r, float g, float b [, float a])
443 PHP_METHOD(CairoSolidPattern, __construct)
445 zend_class_entry * _this_ce;
446 zval * _this_zval;
448 double r = 0.0;
449 double g = 0.0;
450 double b = 0.0;
451 double a = 1.0;
455 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddd|d", &r, &g, &b, &a) == FAILURE) {
456 return;
459 _this_zval = getThis();
460 _this_ce = Z_OBJCE_P(_this_zval);
461 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
462 curr->pattern = cairo_pattern_create_rgba(r, g, b, a);
465 /* }}} __construct */
469 /* {{{ proto array get_rgba()
471 PHP_METHOD(CairoSolidPattern, get_rgba)
473 zend_class_entry * _this_ce;
475 zval * _this_zval = NULL;
476 double r,g,b,a;
479 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoSolidPattern_ce_ptr) == FAILURE) {
480 return;
483 _this_ce = Z_OBJCE_P(_this_zval);
484 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
485 cairo_pattern_get_rgba(curr->pattern, &r, &g, &b, &a);
487 array_init(return_value);
488 add_assoc_double(return_value, "red", r);
489 add_assoc_double(return_value, "green", g);
490 add_assoc_double(return_value, "blue", b);
491 add_assoc_double(return_value, "alpha", a);
494 /* }}} get_rgba */
497 static zend_function_entry CairoSolidPattern_methods[] = {
498 PHP_ME(CairoSolidPattern, __construct, CairoSolidPattern____construct_args, /**/ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
499 PHP_ME(CairoSolidPattern, get_rgba, NULL, /**/ZEND_ACC_PUBLIC)
500 { NULL, NULL, NULL }
503 /* }}} Methods */
505 static zend_object_handlers CairoSolidPattern_handlers;
507 static zend_object_value CairoSolidPattern_object_new(zend_class_entry *ce TSRMLS_CC)
509 zend_object_value retval;
510 retval = CairoPattern_object_new(ce TSRMLS_CC);
511 retval.handlers = &CairoSolidPattern_handlers;
512 return retval;
516 static void class_init_CairoSolidPattern(void)
518 zend_class_entry ce;
520 INIT_CLASS_ENTRY(ce, "CairoSolidPattern", CairoSolidPattern_methods);
521 CairoSolidPattern_ce_ptr = zend_register_internal_class_ex(&ce, CairoPattern_ce_ptr, "CairoPattern" TSRMLS_CC);
522 CairoSolidPattern_ce_ptr->create_object = CairoSolidPattern_object_new;
523 memcpy(&CairoSolidPattern_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
526 /* }}} Class CairoSolidPattern */
528 /* {{{ Class CairoSurfacePattern */
530 static zend_class_entry * CairoSurfacePattern_ce_ptr = NULL;
532 /* {{{ Methods */
535 /* {{{ proto void construct(object s)
537 PHP_METHOD(CairoSurfacePattern, __construct)
539 zend_class_entry * _this_ce;
540 zval * _this_zval;
542 zval * s = NULL;
546 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &s) == FAILURE) {
547 return;
550 _this_zval = getThis();
551 _this_ce = Z_OBJCE_P(_this_zval);
552 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
553 surface_object *sobj = (surface_object *)zend_objects_get_address(s TSRMLS_CC);
554 curr->pattern = cairo_pattern_create_for_surface(sobj->surface);
557 /* }}} __construct */
561 /* {{{ proto int get_extend()
563 PHP_METHOD(CairoSurfacePattern, get_extend)
565 zend_class_entry * _this_ce;
566 long extend;
567 zval * _this_zval = NULL;
571 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoSurfacePattern_ce_ptr) == FAILURE) {
572 return;
575 _this_ce = Z_OBJCE_P(_this_zval);
576 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
578 extend = cairo_pattern_get_extend(curr->pattern);
579 RETURN_LONG(extend);
582 /* }}} get_extend */
586 /* {{{ proto int get_filter()
588 PHP_METHOD(CairoSurfacePattern, get_filter)
590 zend_class_entry * _this_ce;
591 int filter;
592 zval * _this_zval = NULL;
596 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoSurfacePattern_ce_ptr) == FAILURE) {
597 return;
600 _this_ce = Z_OBJCE_P(_this_zval);
601 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
602 filter = cairo_pattern_get_filter(curr->pattern);
603 RETURN_LONG(filter);
605 /* }}} get_filter */
609 /* {{{ proto object get_surface()
611 PHP_METHOD(CairoSurfacePattern, get_surface)
613 zend_class_entry * _this_ce;
614 zend_class_entry *surface_ce;
615 cairo_surface_t *surface;
616 zval * _this_zval = NULL;
620 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoSurfacePattern_ce_ptr) == FAILURE) {
621 return;
624 _this_ce = Z_OBJCE_P(_this_zval);
625 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
626 cairo_pattern_get_surface(curr->pattern, &surface);
627 surface_ce = get_CairoSurface_ce_ptr(surface);
629 object_init_ex(return_value,surface_ce);
630 surface_object *sobj = (surface_object *)zend_objects_get_address(return_value TSRMLS_CC);
631 sobj->surface = cairo_surface_reference(surface);
633 /* }}} get_surface */
637 /* {{{ proto void set_extend(int extend)
639 PHP_METHOD(CairoSurfacePattern, set_extend)
641 zend_class_entry * _this_ce;
643 zval * _this_zval = NULL;
644 long extend = 0;
648 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &_this_zval, CairoSurfacePattern_ce_ptr, &extend) == FAILURE) {
649 return;
652 _this_ce = Z_OBJCE_P(_this_zval);
653 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
654 cairo_pattern_set_extend(curr->pattern, extend);
657 /* }}} set_extend */
661 /* {{{ proto void set_filter(int filter)
663 PHP_METHOD(CairoSurfacePattern, set_filter)
665 zend_class_entry * _this_ce;
667 zval * _this_zval = NULL;
668 long filter = 0;
672 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &_this_zval, CairoSurfacePattern_ce_ptr, &filter) == FAILURE) {
673 return;
676 _this_ce = Z_OBJCE_P(_this_zval);
677 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
679 cairo_pattern_set_filter(curr->pattern, filter);
681 /* }}} set_filter */
684 static zend_function_entry CairoSurfacePattern_methods[] = {
685 PHP_ME(CairoSurfacePattern, __construct, NULL, /**/ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
686 PHP_ME(CairoSurfacePattern, get_extend, NULL, /**/ZEND_ACC_PUBLIC)
687 PHP_ME(CairoSurfacePattern, get_filter, NULL, /**/ZEND_ACC_PUBLIC)
688 PHP_ME(CairoSurfacePattern, get_surface, NULL, /**/ZEND_ACC_PUBLIC)
689 PHP_ME(CairoSurfacePattern, set_extend, CairoSurfacePattern__set_extend_args, /**/ZEND_ACC_PUBLIC)
690 PHP_ME(CairoSurfacePattern, set_filter, CairoSurfacePattern__set_filter_args, /**/ZEND_ACC_PUBLIC)
691 { NULL, NULL, NULL }
694 /* }}} Methods */
696 static zend_object_handlers CairoSurfacePattern_handlers;
698 static zend_object_value CairoSurfacePattern_object_new(zend_class_entry *ce TSRMLS_CC)
700 zend_object_value retval;
701 retval = CairoPattern_object_new(ce TSRMLS_CC);
702 retval.handlers = &CairoSurfacePattern_handlers;
703 return retval;
706 static void class_init_CairoSurfacePattern(void)
708 zend_class_entry ce;
709 INIT_CLASS_ENTRY(ce, "CairoSurfacePattern", CairoSurfacePattern_methods);
710 CairoSurfacePattern_ce_ptr = zend_register_internal_class_ex(&ce, CairoPattern_ce_ptr, "CairoPattern" TSRMLS_CC);
711 CairoSurfacePattern_ce_ptr->create_object = CairoSurfacePattern_object_new;
712 memcpy(&CairoSurfacePattern_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
716 /* }}} Class CairoSurfacePattern */
718 /* {{{ Helper functions */
720 zend_class_entry *
721 get_CairoPattern_ce_ptr(cairo_pattern_t *pattern)
723 zend_class_entry *type;
724 if(pattern == NULL)
725 return NULL;
726 switch(cairo_pattern_get_type(pattern)) {
727 case CAIRO_PATTERN_TYPE_SOLID:
728 type = CairoSolidPattern_ce_ptr;
729 break;
730 case CAIRO_PATTERN_TYPE_SURFACE:
731 type = CairoSurfacePattern_ce_ptr;
732 break;
733 case CAIRO_PATTERN_TYPE_LINEAR:
734 type = CairoLinearGradient_ce_ptr;
735 break;
736 case CAIRO_PATTERN_TYPE_RADIAL:
737 type = CairoRadialGradient_ce_ptr;
738 break;
739 default:
740 php_error(E_ERROR,"Unsupported Pattern");
741 return NULL;
743 return type;
745 /* }}} Helper functions */