Changed the names to match the PECL nomenclature
[phpCairo.git] / src / cairo / CairoPattern.c
bloba4645a32b637f07e67e7ce45a31b4e62e869a646
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 getMatrix()
32 PHP_METHOD(CairoPattern, getMatrix)
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_ex(return_value, CairoMatrix_ce_ptr);
48 matrix_object *mobj = (matrix_object *)zend_objects_get_address(return_value TSRMLS_CC);
49 mobj->matrix = matrix;
51 /* }}} getMatrix */
55 /* {{{ proto void setMatrix(object m)
57 PHP_METHOD(CairoPattern, setMatrix)
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 /* }}} setMatrix */
78 /* {{{ proto void setExtend(int extend)
80 PHP_METHOD(CairoPattern, setExtend)
82 zend_class_entry * _this_ce;
83 long extend;
85 zval * _this_zval = NULL;
86 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &_this_zval, CairoPattern_ce_ptr, &extend) == FAILURE) {
87 return;
89 _this_ce = Z_OBJCE_P(_this_zval);
90 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
91 cairo_pattern_set_extend(curr->pattern, extend);
92 phpCAIRO_PATTERN_ERROR(curr->pattern);
96 /* }}} setExtend */
99 /* {{{ proto void getExtend()
101 PHP_METHOD(CairoPattern, getExtend)
103 zend_class_entry * _this_ce;
104 long extend;
106 zval * _this_zval = NULL;
107 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoPattern_ce_ptr) == FAILURE) {
108 return;
110 _this_ce = Z_OBJCE_P(_this_zval);
111 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
112 extend = cairo_pattern_get_extend(curr->pattern);
113 RETURN_LONG(extend);
115 /* }}} setExtend */
118 static zend_function_entry CairoPattern_methods[] = {
119 PHP_ME(CairoPattern, __construct, NULL, /**/ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
120 PHP_ME(CairoPattern, getMatrix, NULL, /**/ZEND_ACC_PUBLIC)
121 PHP_ME(CairoPattern, setMatrix, CairoPattern__set_matrix_args, /**/ZEND_ACC_PUBLIC)
122 PHP_ME(CairoPattern, getExtend, NULL, /**/ZEND_ACC_PUBLIC)
123 PHP_ME(CairoPattern, setExtend, CairoPattern__set_extend_args, /**/ZEND_ACC_PUBLIC)
124 { NULL, NULL, NULL }
127 /* }}} Methods */
129 static zend_object_handlers CairoPattern_handlers;
131 static void CairoPattern_object_dtor(void *object)
133 pattern_object *pattern = (pattern_object *)object;
134 zend_hash_destroy(pattern->std.properties);
135 FREE_HASHTABLE(pattern->std.properties);
136 if(pattern->pattern){
137 cairo_pattern_destroy(pattern->pattern);
139 efree(object);
142 static zend_object_value CairoPattern_object_new(zend_class_entry *ce)
144 zend_object_value retval;
145 pattern_object *pattern;
146 zval *temp;
147 pattern=emalloc(sizeof(pattern_object));
148 memset(pattern,0,sizeof(pattern_object));
149 pattern->std.ce = ce;
150 ALLOC_HASHTABLE(pattern->std.properties);
151 zend_hash_init(pattern->std.properties, 0, NULL, ZVAL_PTR_DTOR,0);
152 zend_hash_copy(pattern->std.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &temp, sizeof(zval *));
153 retval.handle = zend_objects_store_put(pattern, NULL, (zend_objects_free_object_storage_t)CairoPattern_object_dtor, NULL TSRMLS_CC);
154 retval.handlers = &CairoPattern_handlers;
155 return retval;
159 static void class_init_CairoPattern(void)
161 zend_class_entry ce;
163 INIT_CLASS_ENTRY(ce, "CairoPattern", CairoPattern_methods);
164 CairoPattern_ce_ptr = zend_register_internal_class(&ce);
165 CairoPattern_ce_ptr->create_object = CairoPattern_object_new;
166 memcpy(&CairoPattern_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
167 CairoPattern_handlers.clone_obj = NULL;
170 /* }}} Class CairoPattern */
172 /* {{{ Class CairoGradient */
174 static zend_class_entry * CairoGradient_ce_ptr = NULL;
176 /* {{{ Methods */
179 /* {{{ proto void construct()
181 PHP_METHOD(CairoGradient, __construct)
183 zend_class_entry * _this_ce;
185 zval * _this_zval = NULL;
189 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoGradient_ce_ptr) == FAILURE) {
190 return;
193 _this_ce = Z_OBJCE_P(_this_zval);
196 php_error(E_ERROR, "Gradient cannot be initialized"); RETURN_FALSE;
199 /* }}} __construct */
203 /* {{{ proto void addColorStopRgb(float offset, float red, float green, float blue)
205 PHP_METHOD(CairoGradient, addColorStopRgb)
207 zend_class_entry * _this_ce;
209 zval * _this_zval = NULL;
210 double offset = 0.0;
211 double red = 0.0;
212 double green = 0.0;
213 double blue = 0.0;
217 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odddd", &_this_zval, CairoGradient_ce_ptr, &offset, &red, &green, &blue) == FAILURE) {
218 return;
221 _this_ce = Z_OBJCE_P(_this_zval);
222 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
223 cairo_pattern_add_color_stop_rgb(curr->pattern, offset, red, green, blue);
224 phpCAIRO_PATTERN_ERROR(curr->pattern);
226 /* }}} addColorStopRgb */
230 /* {{{ proto void addColorStopRgba(float offset, float red, float green, float blue, float alpha)
232 PHP_METHOD(CairoGradient, addColorStopRgba)
234 zend_class_entry * _this_ce;
236 zval * _this_zval = NULL;
237 double offset = 0.0;
238 double red = 0.0;
239 double green = 0.0;
240 double blue = 0.0;
241 double alpha = 0.0;
245 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oddddd", &_this_zval, CairoGradient_ce_ptr, &offset, &red, &green, &blue, &alpha) == FAILURE) {
246 return;
249 _this_ce = Z_OBJCE_P(_this_zval);
250 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
251 cairo_pattern_add_color_stop_rgba(curr->pattern, offset, red, green, blue, alpha);
252 phpCAIRO_PATTERN_ERROR(curr->pattern);
254 /* }}} addColorStopRgba */
258 static zend_function_entry CairoGradient_methods[] = {
259 PHP_ME(CairoGradient, __construct, NULL, /**/ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
260 PHP_ME(CairoGradient, addColorStopRgb, CairoGradient__add_color_stop_rgb_args, /**/ZEND_ACC_PUBLIC)
261 PHP_ME(CairoGradient, addColorStopRgba, CairoGradient__add_color_stop_rgba_args, /**/ZEND_ACC_PUBLIC)
262 { NULL, NULL, NULL }
265 /* }}} Methods */
267 static zend_object_handlers CairoGradient_handlers;
269 static zend_object_value CairoGradient_object_new(zend_class_entry *ce TSRMLS_CC)
271 zend_object_value retval;
272 retval = CairoPattern_object_new(ce TSRMLS_CC);
273 retval.handlers = &CairoGradient_handlers;
274 return retval;
277 static void class_init_CairoGradient(void)
279 zend_class_entry ce;
280 INIT_CLASS_ENTRY(ce, "CairoGradient", CairoGradient_methods);
281 CairoGradient_ce_ptr = zend_register_internal_class_ex(&ce, CairoPattern_ce_ptr, "CairoPattern" TSRMLS_CC);
282 CairoGradient_ce_ptr->create_object = CairoGradient_object_new;
283 memcpy(&CairoGradient_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
287 /* }}} Class CairoGradient */
289 /* {{{ Class CairoLinearGradient */
291 static zend_class_entry * CairoLinearGradient_ce_ptr = NULL;
293 /* {{{ Methods */
296 /* {{{ proto void construct(float x0, float y0, float x1, float y1)
298 PHP_METHOD(CairoLinearGradient, __construct)
300 zend_class_entry * _this_ce;
301 zval * _this_zval;
303 double x0 = 0.0;
304 double y0 = 0.0;
305 double x1 = 0.0;
306 double y1 = 0.0;
310 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dddd", &x0, &y0, &x1, &y1) == FAILURE) {
311 return;
314 _this_zval = getThis();
315 _this_ce = Z_OBJCE_P(_this_zval);
316 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
317 curr->pattern = cairo_pattern_create_linear(x0, y0, x1, y1);
320 /* }}} __construct */
324 /* {{{ proto array getLinearPoints()
326 PHP_METHOD(CairoLinearGradient, getLinearPoints)
328 zend_class_entry * _this_ce;
330 zval * _this_zval = NULL;
331 double x0, y0, x1, y1;
334 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoLinearGradient_ce_ptr) == FAILURE) {
335 return;
338 _this_ce = Z_OBJCE_P(_this_zval);
339 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
340 cairo_pattern_get_linear_points(curr->pattern, &x0, &y0, &x1, &y1);
342 array_init(return_value);
343 add_assoc_double(return_value, "x0", x0);
344 add_assoc_double(return_value, "y0", y0);
345 add_assoc_double(return_value, "x1", x1);
346 add_assoc_double(return_value, "y1", y1);
349 /* }}} getLinearPoints */
352 static zend_function_entry CairoLinearGradient_methods[] = {
353 PHP_ME(CairoLinearGradient, __construct, CairoLinearGradient____construct_args, /**/ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
354 PHP_ME(CairoLinearGradient, getLinearPoints, NULL, /**/ZEND_ACC_PUBLIC)
355 { NULL, NULL, NULL }
358 /* }}} Methods */
360 static zend_object_handlers CairoLinearGradient_handlers;
362 static zend_object_value CairoLinearGradient_object_new(zend_class_entry *ce TSRMLS_CC)
364 zend_object_value retval;
365 retval = CairoGradient_object_new(ce TSRMLS_CC);
366 retval.handlers = &CairoLinearGradient_handlers;
367 return retval;
370 static void class_init_CairoLinearGradient(void)
372 zend_class_entry ce;
373 INIT_CLASS_ENTRY(ce, "CairoLinearGradient", CairoLinearGradient_methods);
374 CairoLinearGradient_ce_ptr = zend_register_internal_class_ex(&ce, CairoGradient_ce_ptr, "CairoGradient" TSRMLS_CC);
375 CairoLinearGradient_ce_ptr->create_object = CairoLinearGradient_object_new;
376 memcpy(&CairoLinearGradient_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
380 /* }}} Class CairoLinearGradient */
382 /* {{{ Class CairoRadialGradient */
384 static zend_class_entry * CairoRadialGradient_ce_ptr = NULL;
386 /* {{{ Methods */
389 /* {{{ proto void construct(float cx0, float cy0, float radius0, float cx1, float cy1, float radius1)
391 PHP_METHOD(CairoRadialGradient, __construct)
393 zend_class_entry * _this_ce;
395 zval * _this_zval = NULL;
396 double cx0 = 0.0;
397 double cy0 = 0.0;
398 double radius0 = 0.0;
399 double cx1 = 0.0;
400 double cy1 = 0.0;
401 double radius1 = 0.0;
405 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odddddd", &_this_zval, CairoRadialGradient_ce_ptr, &cx0, &cy0, &radius0, &cx1, &cy1, &radius1) == FAILURE) {
406 return;
409 _this_ce = Z_OBJCE_P(_this_zval);
410 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
411 curr->pattern = cairo_pattern_create_radial(cx0, cy0, radius0, cx1, cy1, radius1);
414 /* }}} __construct */
418 /* {{{ proto array getRadialCircles()
420 PHP_METHOD(CairoRadialGradient, getRadialCircles)
422 zend_class_entry * _this_ce;
424 zval * _this_zval = NULL;
425 double x0, y0, r0, x1, y1, r1;
428 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoRadialGradient_ce_ptr) == FAILURE) {
429 return;
432 _this_ce = Z_OBJCE_P(_this_zval);
433 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
434 cairo_pattern_get_radial_circles(curr->pattern, &x0, &y0, &r0, &x1, &y1, &r1);
436 array_init(return_value);
437 add_assoc_double(return_value, "x0", x0);
438 add_assoc_double(return_value, "y0", y0);
439 add_assoc_double(return_value, "r0", r0);
440 add_assoc_double(return_value, "x1", x1);
441 add_assoc_double(return_value, "y1", y1);
442 add_assoc_double(return_value, "r1", r1);
445 /* }}} getRadialCircles */
448 static zend_function_entry CairoRadialGradient_methods[] = {
449 PHP_ME(CairoRadialGradient, __construct, CairoRadialGradient____constuct_args, /**/ZEND_ACC_PUBLIC| ZEND_ACC_CTOR)
450 PHP_ME(CairoRadialGradient, getRadialCircles, NULL, /**/ZEND_ACC_PUBLIC)
451 { NULL, NULL, NULL }
454 /* }}} Methods */
456 static zend_object_handlers CairoRadialGradient_handlers;
458 static zend_object_value CairoRadialGradient_object_new(zend_class_entry *ce TSRMLS_CC)
460 zend_object_value retval;
461 retval = CairoGradient_object_new(ce TSRMLS_CC);
462 retval.handlers = &CairoRadialGradient_handlers;
463 return retval;
466 static void class_init_CairoRadialGradient(void)
468 zend_class_entry ce;
469 INIT_CLASS_ENTRY(ce, "CairoRadialGradient", CairoRadialGradient_methods);
470 CairoRadialGradient_ce_ptr = zend_register_internal_class_ex(&ce, CairoGradient_ce_ptr, "CairoGradient" TSRMLS_CC);
471 CairoRadialGradient_ce_ptr->create_object = CairoRadialGradient_object_new;
472 memcpy(&CairoRadialGradient_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
475 /* }}} Class CairoRadialGradient */
477 /* {{{ Class CairoSolidPattern */
479 static zend_class_entry * CairoSolidPattern_ce_ptr = NULL;
481 /* {{{ Methods */
484 /* {{{ proto void construct(float r, float g, float b [, float a])
486 PHP_METHOD(CairoSolidPattern, __construct)
488 zend_class_entry * _this_ce;
489 zval * _this_zval;
491 double r = 0.0;
492 double g = 0.0;
493 double b = 0.0;
494 double a = 1.0;
498 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddd|d", &r, &g, &b, &a) == FAILURE) {
499 return;
502 _this_zval = getThis();
503 _this_ce = Z_OBJCE_P(_this_zval);
504 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
505 curr->pattern = cairo_pattern_create_rgba(r, g, b, a);
508 /* }}} __construct */
512 /* {{{ proto array getRgba()
514 PHP_METHOD(CairoSolidPattern, getRgba)
516 zend_class_entry * _this_ce;
518 zval * _this_zval = NULL;
519 double r,g,b,a;
522 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoSolidPattern_ce_ptr) == FAILURE) {
523 return;
526 _this_ce = Z_OBJCE_P(_this_zval);
527 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
528 cairo_pattern_get_rgba(curr->pattern, &r, &g, &b, &a);
530 array_init(return_value);
531 add_assoc_double(return_value, "red", r);
532 add_assoc_double(return_value, "green", g);
533 add_assoc_double(return_value, "blue", b);
534 add_assoc_double(return_value, "alpha", a);
537 /* }}} getRgba */
540 static zend_function_entry CairoSolidPattern_methods[] = {
541 PHP_ME(CairoSolidPattern, __construct, CairoSolidPattern____construct_args, /**/ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
542 PHP_ME(CairoSolidPattern, getRgba, NULL, /**/ZEND_ACC_PUBLIC)
543 { NULL, NULL, NULL }
546 /* }}} Methods */
548 static zend_object_handlers CairoSolidPattern_handlers;
550 static zend_object_value CairoSolidPattern_object_new(zend_class_entry *ce TSRMLS_CC)
552 zend_object_value retval;
553 retval = CairoPattern_object_new(ce TSRMLS_CC);
554 retval.handlers = &CairoSolidPattern_handlers;
555 return retval;
559 static void class_init_CairoSolidPattern(void)
561 zend_class_entry ce;
563 INIT_CLASS_ENTRY(ce, "CairoSolidPattern", CairoSolidPattern_methods);
564 CairoSolidPattern_ce_ptr = zend_register_internal_class_ex(&ce, CairoPattern_ce_ptr, "CairoPattern" TSRMLS_CC);
565 CairoSolidPattern_ce_ptr->create_object = CairoSolidPattern_object_new;
566 memcpy(&CairoSolidPattern_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
569 /* }}} Class CairoSolidPattern */
571 /* {{{ Class CairoSurfacePattern */
573 static zend_class_entry * CairoSurfacePattern_ce_ptr = NULL;
575 /* {{{ Methods */
578 /* {{{ proto void construct(object s)
580 PHP_METHOD(CairoSurfacePattern, __construct)
582 zend_class_entry * _this_ce;
583 zval * _this_zval;
585 zval * s = NULL;
589 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &s) == FAILURE) {
590 return;
593 _this_zval = getThis();
594 _this_ce = Z_OBJCE_P(_this_zval);
595 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
596 surface_object *sobj = (surface_object *)zend_objects_get_address(s TSRMLS_CC);
597 curr->pattern = cairo_pattern_create_for_surface(sobj->surface);
600 /* }}} __construct */
603 /* {{{ proto int getFilter()
605 PHP_METHOD(CairoSurfacePattern, getFilter)
607 zend_class_entry * _this_ce;
608 int filter;
609 zval * _this_zval = NULL;
613 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoSurfacePattern_ce_ptr) == FAILURE) {
614 return;
617 _this_ce = Z_OBJCE_P(_this_zval);
618 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
619 filter = cairo_pattern_get_filter(curr->pattern);
620 RETURN_LONG(filter);
622 /* }}} getFilter */
626 /* {{{ proto object getSurface()
628 PHP_METHOD(CairoSurfacePattern, getSurface)
630 zend_class_entry * _this_ce;
631 zend_class_entry *surface_ce;
632 cairo_surface_t *surface;
633 zval * _this_zval = NULL;
637 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoSurfacePattern_ce_ptr) == FAILURE) {
638 return;
641 _this_ce = Z_OBJCE_P(_this_zval);
642 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
643 cairo_pattern_get_surface(curr->pattern, &surface);
644 surface_ce = get_CairoSurface_ce_ptr(surface);
646 object_init_ex(return_value,surface_ce);
647 surface_object *sobj = (surface_object *)zend_objects_get_address(return_value TSRMLS_CC);
648 sobj->surface = cairo_surface_reference(surface);
650 /* }}} getSurface */
655 /* {{{ proto void setFilter(int filter)
657 PHP_METHOD(CairoSurfacePattern, setFilter)
659 zend_class_entry * _this_ce;
661 zval * _this_zval = NULL;
662 long filter = 0;
666 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &_this_zval, CairoSurfacePattern_ce_ptr, &filter) == FAILURE) {
667 return;
670 _this_ce = Z_OBJCE_P(_this_zval);
671 pattern_object *curr = (pattern_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
673 cairo_pattern_set_filter(curr->pattern, filter);
675 /* }}} setFilter */
678 static zend_function_entry CairoSurfacePattern_methods[] = {
679 PHP_ME(CairoSurfacePattern, __construct, NULL, /**/ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
680 PHP_ME(CairoSurfacePattern, getFilter, NULL, /**/ZEND_ACC_PUBLIC)
681 PHP_ME(CairoSurfacePattern, getSurface, NULL, /**/ZEND_ACC_PUBLIC)
682 PHP_ME(CairoSurfacePattern, setFilter, CairoSurfacePattern__set_filter_args, /**/ZEND_ACC_PUBLIC)
683 { NULL, NULL, NULL }
686 /* }}} Methods */
688 static zend_object_handlers CairoSurfacePattern_handlers;
690 static zend_object_value CairoSurfacePattern_object_new(zend_class_entry *ce TSRMLS_CC)
692 zend_object_value retval;
693 retval = CairoPattern_object_new(ce TSRMLS_CC);
694 retval.handlers = &CairoSurfacePattern_handlers;
695 return retval;
698 static void class_init_CairoSurfacePattern(void)
700 zend_class_entry ce;
701 INIT_CLASS_ENTRY(ce, "CairoSurfacePattern", CairoSurfacePattern_methods);
702 CairoSurfacePattern_ce_ptr = zend_register_internal_class_ex(&ce, CairoPattern_ce_ptr, "CairoPattern" TSRMLS_CC);
703 CairoSurfacePattern_ce_ptr->create_object = CairoSurfacePattern_object_new;
704 memcpy(&CairoSurfacePattern_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
708 /* }}} Class CairoSurfacePattern */
710 /* {{{ Helper functions */
712 zend_class_entry *
713 get_CairoPattern_ce_ptr(cairo_pattern_t *pattern)
715 zend_class_entry *type;
716 if(pattern == NULL)
717 return NULL;
718 switch(cairo_pattern_get_type(pattern)) {
719 case CAIRO_PATTERN_TYPE_SOLID:
720 type = CairoSolidPattern_ce_ptr;
721 break;
722 case CAIRO_PATTERN_TYPE_SURFACE:
723 type = CairoSurfacePattern_ce_ptr;
724 break;
725 case CAIRO_PATTERN_TYPE_LINEAR:
726 type = CairoLinearGradient_ce_ptr;
727 break;
728 case CAIRO_PATTERN_TYPE_RADIAL:
729 type = CairoRadialGradient_ce_ptr;
730 break;
731 default:
732 php_error(E_ERROR,"Unsupported Pattern");
733 return NULL;
735 return type;
737 /* }}} Helper functions */