Some more debugs
[phpCairo.git] / individual_files / phpCairoSurface.c
blob59b69fbcab344a41e6263ba2c8bee378fd62eccd
1 /* {{{ Class CairoSurface */
3 static zend_class_entry * CairoSurface_ce_ptr = NULL;
4 static zend_object_handlers CairoSurface_handlers;
6 static cairo_status_t
7 _write_func(void *closure, const unsigned char *data, unsigned int length)
9 int written;
10 php_stream *zs = (php_stream *)closure ;
11 written = php_stream_write(zs, data, length);
12 //written = php_stream_write_string(zs, data);
13 printf("%d %d",written, length);
14 if(written == length)
15 return CAIRO_STATUS_SUCCESS;
16 else {
17 printf("is it an error ?");
18 // CAIRO_STATUS_WRITE_ERROR;
22 static cairo_status_t
23 _read_func(void *closure, const unsigned char *data, unsigned int length)
25 int read;
26 php_stream *zs = (php_stream *)closure;
27 //data = emalloc(length);
28 read = php_stream_read(zs, data, length);
29 printf("%d %d", read, length);
30 if(read == length)
31 return CAIRO_STATUS_SUCCESS;
32 else {
33 printf("is it an error");
40 typedef struct _surface_object {
41 zend_object std;
42 cairo_surface_t *surface;
43 } surface_object;
46 /* {{{ Methods */
49 /* {{{ proto void construct()
51 PHP_METHOD(CairoSurface, __construct)
53 zend_class_entry * _this_ce;
54 zval * _this_zval;
58 if (ZEND_NUM_ARGS()>0) {
59 WRONG_PARAM_COUNT;
60 php_print("wtf");
61 return;
64 php_print("No direct call for this constructor");
68 /* }}} __construct */
72 /* {{{ proto object create_similar(int content, int width, int height)
74 PHP_METHOD(CairoSurface, create_similar)
76 zend_class_entry * _this_ce, *ce;
78 zval * _this_zval = NULL;
79 cairo_surface_t *sur;
80 int content;
81 long width = 0;
82 long height = 0;
84 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oill", &_this_zval, CairoSurface_ce_ptr, &content, &width, &height) == FAILURE) {
85 return;
88 _this_ce = Z_OBJCE_P(_this_zval);
89 surface_object *curr = (surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
90 sur = cairo_surface_create_similar(curr->surface, content, width, height);
91 ce = getCairoSurface_ce_ptr(sur);
92 object_init_ex(return_value, ce);
93 surface_object *sobj = (surface_object *)zend_objects_get_address(return_value TSRMLS_CC);
94 sobj->surface=sur;
97 /* }}} create_similar */
100 /* {{{ proto void finish()
102 PHP_METHOD(CairoSurface, finish)
104 zend_class_entry * _this_ce;
106 zval * _this_zval = NULL;
108 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoSurface_ce_ptr) == FAILURE) {
109 return;
112 _this_ce = Z_OBJCE_P(_this_zval);
113 surface_object *curr = (surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
114 cairo_surface_finish(curr->surface);
116 /* }}} finish */
120 /* {{{ proto void flush()
122 PHP_METHOD(CairoSurface, flush)
124 zend_class_entry * _this_ce;
126 zval * _this_zval = NULL;
128 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoSurface_ce_ptr) == FAILURE) {
129 return;
132 _this_ce = Z_OBJCE_P(_this_zval);
133 surface_object *curr = (surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
135 cairo_surface_flush(curr->surface);
138 /* }}} flush */
142 /* {{{ proto int get_content()
144 PHP_METHOD(CairoSurface, get_content)
146 zend_class_entry * _this_ce;
148 zval * _this_zval = NULL;
149 long x;
150 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoSurface_ce_ptr) == FAILURE) {
151 return;
154 _this_ce = Z_OBJCE_P(_this_zval);
155 surface_object *curr = (surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
157 x=cairo_surface_get_content(curr->surface);
158 RETURN_LONG(x);
160 /* }}} get_content */
164 /* {{{ proto array get_device_offset()
166 PHP_METHOD(CairoSurface, get_device_offset)
168 zend_class_entry * _this_ce;
170 zval * _this_zval = NULL;
171 double x_offset, y_offset;
173 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoSurface_ce_ptr) == FAILURE) {
174 return;
177 _this_ce = Z_OBJCE_P(_this_zval);
178 surface_object *curr = (surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
180 cairo_surface_get_device_offset(curr->surface, &x_offset, &y_offset);
182 array_init(return_value);
183 add_assoc_double(return_value, "x_offset", x_offset);
184 add_assoc_double(return_value, "y_offset", y_offset);
187 /* }}} get_device_offset */
191 /* {{{ proto object get_font_options()
193 PHP_METHOD(CairoSurface, get_font_options)
195 zend_class_entry * _this_ce;
197 zval * _this_zval = NULL;
199 cairo_font_options_t *options = cairo_font_options_create();
202 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoSurface_ce_ptr) == FAILURE) {
203 return;
206 _this_ce = Z_OBJCE_P(_this_zval);
207 surface_object *curr = (surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
209 cairo_surface_get_font_options(curr->surface, options);
210 object_init_ex(return_value, CairoFontOptions_ce_ptr);
211 fontoptions_object *fobj = (fontoptions_object *)zend_objects_get_address(return_value TSRMLS_CC);
212 fobj->fontoptions=options;
215 /* }}} get_font_options */
219 /* {{{ proto void mark_dirty_rectangle([int x, int y, int width, int height])
221 PHP_METHOD(CairoSurface, mark_dirty_rectangle)
223 zend_class_entry * _this_ce;
225 zval * _this_zval = NULL;
226 long x = 0;
227 long y = 0;
228 long width = -1;
229 long height = -1;
233 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|llll", &_this_zval, CairoSurface_ce_ptr, &x, &y, &width, &height) == FAILURE) {
234 return;
236 _this_ce = Z_OBJCE_P(_this_zval);
237 surface_object *curr = (surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
238 cairo_surface_mark_dirty_rectangle(curr->surface, x, y, width, height);
241 /* }}} mark_dirty_rectangle */
245 /* {{{ proto void set_device_offset(float x_offset, float y_offset)
247 PHP_METHOD(CairoSurface, set_device_offset)
249 zend_class_entry * _this_ce;
251 zval * _this_zval = NULL;
252 double x_offset = 0.0;
253 double y_offset = 0.0;
255 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoSurface_ce_ptr, &x_offset, &y_offset) == FAILURE) {
256 return;
259 _this_ce = Z_OBJCE_P(_this_zval);
260 surface_object *curr = (surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
261 cairo_surface_set_device_offset(curr->surface, x_offset, y_offset);
264 /* }}} set_device_offset */
268 /* {{{ proto void set_fallback_resolution(float x_ppi, float y_ppi)
270 PHP_METHOD(CairoSurface, set_fallback_resolution)
272 zend_class_entry * _this_ce;
274 zval * _this_zval = NULL;
275 double x_ppi = 0.0;
276 double y_ppi = 0.0;
278 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoSurface_ce_ptr, &x_ppi, &y_ppi) == FAILURE) {
279 return;
282 _this_ce = Z_OBJCE_P(_this_zval);
283 surface_object *curr = (surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
284 cairo_surface_set_fallback_resolution(curr->surface, x_ppi, y_ppi);
287 /* }}} set_fallback_resolution */
291 /* {{{ proto void write_to_png(string file)
293 PHP_METHOD(CairoSurface, write_to_png)
295 zend_class_entry * _this_ce;
297 zval * _this_zval = NULL;
298 const char * file = NULL;
299 int file_len = 0;
300 cairo_status_t status;
302 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &_this_zval, CairoSurface_ce_ptr, &file, &file_len) == FAILURE) {
303 return;
306 _this_ce = Z_OBJCE_P(_this_zval);
307 surface_object *curr = (surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
308 status = cairo_surface_write_to_png(curr->surface, file);
311 /* }}} write_to_png */
314 /* {{{ proto void write_to_png_stream(stream file)
316 PHP_METHOD(CairoSurface, write_to_png_stream)
318 zend_class_entry *_this_ce;
319 FILE *file;
320 zval *_this_zval = NULL;
321 cairo_status_t status;
322 zval *zstream;
323 php_stream *stream;
324 int err;
326 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Or", &_this_zval, CairoSurface_ce_ptr, &zstream)) {
327 return;
330 _this_ce = Z_OBJCE_P(_this_zval);
331 surface_object *curr = (surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
332 php_stream_from_zval(stream, &zstream);
333 status = cairo_surface_write_to_png_stream(curr->surface, _write_func, stream);
337 /* }}} */
340 static zend_function_entry CairoSurface_methods[] = {
341 PHP_ME(CairoSurface, __construct, NULL, /**/ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
342 PHP_ME(CairoSurface, create_similar, CairoSurface__create_similar_args, /**/ZEND_ACC_PUBLIC)
343 PHP_ME(CairoSurface, finish, NULL, /**/ZEND_ACC_PUBLIC)
344 PHP_ME(CairoSurface, flush, NULL, /**/ZEND_ACC_PUBLIC)
345 PHP_ME(CairoSurface, get_content, NULL, /**/ZEND_ACC_PUBLIC)
346 PHP_ME(CairoSurface, get_device_offset, NULL, /**/ZEND_ACC_PUBLIC)
347 PHP_ME(CairoSurface, get_font_options, NULL, /**/ZEND_ACC_PUBLIC)
348 PHP_ME(CairoSurface, mark_dirty_rectangle, CairoSurface__mark_dirty_rectangle_args, /**/ZEND_ACC_PUBLIC)
349 PHP_ME(CairoSurface, set_device_offset, CairoSurface__set_device_offset_args, /**/ZEND_ACC_PUBLIC)
350 PHP_ME(CairoSurface, set_fallback_resolution, CairoSurface__set_fallback_resolution_args, /**/ZEND_ACC_PUBLIC)
351 PHP_ME(CairoSurface, write_to_png, CairoSurface__write_to_png_args, /**/ZEND_ACC_PUBLIC)
352 PHP_ME(CairoSurface, write_to_png_stream, CairoSurface__write_to_png_stream_args, /**/ZEND_ACC_PUBLIC)
353 { NULL, NULL, NULL }
356 /* }}} Methods */
359 static void CairoSurface_object_dtor(void *object)
361 surface_object *surface = (surface_object *)object;
362 zend_hash_destroy(surface->std.properties);
363 FREE_HASHTABLE(surface->std.properties);
364 if(surface->surface){
365 cairo_surface_finish(surface->surface);
366 cairo_surface_destroy(surface->surface);
369 efree(object);
372 static zend_object_value CairoSurface_object_new(zend_class_entry *ce)
374 zend_object_value retval;
375 surface_object *surface;
376 zval *temp;
378 surface = emalloc(sizeof(surface_object));
379 memset(surface,0,sizeof(surface_object));
381 surface->std.ce=ce;
383 ALLOC_HASHTABLE(surface->std.properties);
384 zend_hash_init(surface->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
385 zend_hash_copy(surface->std.properties, &ce->default_properties, (copy_ctor_func_t) zval_add_ref,(void *) &temp, sizeof(zval *));
386 retval.handle=zend_objects_store_put(surface, NULL, (zend_objects_free_object_storage_t)CairoSurface_object_dtor, NULL TSRMLS_CC);
387 retval.handlers = &CairoSurface_handlers;
388 return retval;
391 static void class_init_CairoSurface(void)
393 zend_class_entry ce;
395 INIT_CLASS_ENTRY(ce, "CairoSurface", CairoSurface_methods);
396 CairoSurface_ce_ptr = zend_register_internal_class(&ce);
397 CairoSurface_ce_ptr->create_object = CairoSurface_object_new;
398 memcpy(&CairoSurface_handlers, zend_get_std_object_handlers(),sizeof(zend_object_handlers));
399 CairoSurface_handlers.clone_obj = NULL;
402 /* }}} Class CairoSurface */
404 /* {{{ Class CairoImageSurface -- done :)*/
406 static zend_class_entry * CairoImageSurface_ce_ptr = NULL;
407 static zend_object_handlers CairoImageSurface_handlers;
408 /* {{{ Methods */
411 /* {{{ proto void construct(int format, int widthm, int height)
413 PHP_METHOD(CairoImageSurface, __construct)
415 zend_class_entry * _this_ce;
416 zval * _this_zval;
418 cairo_format_t format = 0;
419 long widthm = 0;
420 long height = 0;
424 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &format, &widthm, &height) == FAILURE) {
425 return;
428 _this_zval = getThis();
429 _this_ce = Z_OBJCE_P(_this_zval);
430 surface_object *curr = (surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
431 curr->surface = cairo_image_surface_create(format, widthm, height);
434 /* }}} __construct */
438 /* {{{ proto void create_from_data(object obj, int format, int width, int height [, int stride])
440 PHP_METHOD(CairoImageSurface, create_from_data)
442 zend_class_entry * _this_ce;
444 zval * _this_zval = NULL;
445 const char * buffer = NULL;
446 int buffer_len = 0;
447 long format = 0;
448 long width = 0;
449 long height = 0;
450 long stride = -1;
454 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oslll|l", &_this_zval, CairoImageSurface_ce_ptr, &buffer, &buffer_len, &format, &width, &height, &stride) == FAILURE) {
455 return;
458 _this_ce = Z_OBJCE_P(_this_zval);
459 surface_object *curr = (surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
461 if(stride < 0 ){
462 switch(format) {
463 case CAIRO_FORMAT_ARGB32:
464 case CAIRO_FORMAT_RGB24:
465 stride = width * 4;
466 break;
467 case CAIRO_FORMAT_RGB16_565:
468 stride = width * 2;
469 break;
470 case CAIRO_FORMAT_A8:
471 stride = width;
472 break;
473 case CAIRO_FORMAT_A1:
474 stride = (width + 1) / 8;
475 break;
476 default:
477 //php_error(CairoError, "Unknown format");
478 return;
482 if (height * stride > buffer_len) {
483 php_error(E_ERROR,"buffer is not long enough");
484 return;
486 curr->surface = cairo_image_surface_create_for_data(buffer, format, width, height, stride);
488 /* }}} create_from_data */
492 /* {{{ proto void create_from_png(string file)
494 PHP_METHOD(CairoImageSurface, create_from_png)
496 zend_class_entry * _this_ce;
498 zval * _this_zval = NULL;
499 const char * file = NULL;
500 int file_len = 0;
502 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &_this_zval, CairoImageSurface_ce_ptr, &file, &file_len) == FAILURE) {
503 return;
506 _this_ce = Z_OBJCE_P(_this_zval);
507 surface_object *curr = (surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
509 curr->surface = cairo_image_surface_create_from_png(file);
512 /* }}} create_from_png */
516 /* {{{ proto void create_from_png_stream(stream zstream)
519 PHP_METHOD(CairoImageSurface, create_from_png_stream)
521 zend_class_entry *_this_ce;
522 FILE *file;
523 zval *_this_zval = NULL;
524 cairo_status_t status;
525 zval *zstream;
526 php_stream *stream;
527 int err;
529 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Or", &_this_zval, CairoImageSurface_ce_ptr, &zstream)) {
530 return;
533 _this_ce = Z_OBJCE_P(_this_zval);
534 surface_object *curr = (surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
536 php_stream_from_zval(stream, &zstream);
537 curr->surface = cairo_image_surface_create_from_png_stream( _read_func, stream);
542 /* }}} */
546 /* {{{ proto string get_data() -- not required
548 PHP_METHOD(CairoImageSurface, get_data)
550 zend_class_entry * _this_ce;
552 zval * _this_zval = NULL;
556 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoImageSurface_ce_ptr) == FAILURE) {
557 return;
560 _this_ce = Z_OBJCE_P(_this_zval);
561 php_error(E_WARNING,"Not Implemented .. not required");
563 RETURN_STRINGL("", 0, 1);
565 /* }}} get_data */
569 /* {{{ proto int get_format()
571 PHP_METHOD(CairoImageSurface, get_format)
573 zend_class_entry * _this_ce;
574 long x;
575 zval * _this_zval = NULL;
577 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoImageSurface_ce_ptr) == FAILURE) {
578 return;
580 _this_ce = Z_OBJCE_P(_this_zval);
581 surface_object *curr = (surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
583 x = cairo_image_surface_get_format(curr->surface);
584 RETURN_LONG(x);
586 /* }}} get_format */
590 /* {{{ proto int get_height()
592 PHP_METHOD(CairoImageSurface, get_height)
594 zend_class_entry * _this_ce;
595 zval * _this_zval = NULL;
596 long x;
598 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoImageSurface_ce_ptr) == FAILURE) {
599 return;
602 _this_ce = Z_OBJCE_P(_this_zval);
603 surface_object *curr = (surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
604 x = cairo_image_surface_get_height(curr->surface);
606 RETURN_LONG(x);
608 /* }}} get_height */
612 /* {{{ proto int get_stride()
614 PHP_METHOD(CairoImageSurface, get_stride)
616 zend_class_entry * _this_ce;
617 zval * _this_zval = NULL;
618 long x;
620 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoImageSurface_ce_ptr) == FAILURE) {
621 return;
624 _this_ce = Z_OBJCE_P(_this_zval);
625 surface_object *curr = (surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
626 x = cairo_image_surface_get_stride(curr->surface);
628 RETURN_LONG(x);
630 /* }}} get_stride */
634 /* {{{ proto int get_width()
636 PHP_METHOD(CairoImageSurface, get_width)
638 zend_class_entry * _this_ce;
639 zval * _this_zval = NULL;
640 long x;
642 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoImageSurface_ce_ptr) == FAILURE) {
643 return;
646 _this_ce = Z_OBJCE_P(_this_zval);
648 surface_object *curr = (surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
650 x = cairo_image_surface_get_width(curr->surface);
651 RETURN_LONG(x);
653 /* }}} get_width */
656 static zend_function_entry CairoImageSurface_methods[] = {
657 PHP_ME(CairoImageSurface, __construct, CairoImageSurface____construct_args, /**/ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
658 PHP_ME(CairoImageSurface, create_from_data, CairoImageSurface__create_from_data_args, /**/ZEND_ACC_PUBLIC)
659 PHP_ME(CairoImageSurface, create_from_png, CairoImageSurface__create_from_png_args, /**/ZEND_ACC_PUBLIC)
660 PHP_ME(CairoImageSurface, create_from_png_stream, CairoImageSurface__create_from_png_stream_args, /**/ZEND_ACC_PUBLIC)
661 PHP_ME(CairoImageSurface, get_data, NULL, /**/ZEND_ACC_PUBLIC)
662 PHP_ME(CairoImageSurface, get_format, NULL, /**/ZEND_ACC_PUBLIC)
663 PHP_ME(CairoImageSurface, get_height, NULL, /**/ZEND_ACC_PUBLIC)
664 PHP_ME(CairoImageSurface, get_stride, NULL, /**/ZEND_ACC_PUBLIC)
665 PHP_ME(CairoImageSurface, get_width, NULL, /**/ZEND_ACC_PUBLIC)
666 { NULL, NULL, NULL }
669 /* }}} Methods */
671 static zend_object_value CairoImageSurface_object_new(zend_class_entry *ce TSRMLS_DC)
673 zend_object_value retval;
674 retval=CairoSurface_object_new(ce TSRMLS_CC);
675 retval.handlers = &CairoImageSurface_handlers;
676 return retval;
680 static void class_init_CairoImageSurface(void)
682 zend_class_entry ce;
684 INIT_CLASS_ENTRY(ce, "CairoImageSurface", CairoImageSurface_methods);
685 CairoImageSurface_ce_ptr = zend_register_internal_class_ex(&ce, CairoSurface_ce_ptr, "CairoSurface" TSRMLS_CC);
686 CairoImageSurface_ce_ptr->create_object = CairoImageSurface_object_new;
687 memcpy(&CairoImageSurface_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
690 /* }}} Class CairoImageSurface */
692 /* {{{ Class CairoPDFSurface */
694 static zend_class_entry * CairoPDFSurface_ce_ptr = NULL;
695 static zend_object_handlers CairoPDFSurface_handlers;
696 /* {{{ Methods */
699 /* {{{ proto void construct(string file, float wpts, float hpts)
701 PHP_METHOD(CairoPDFSurface, __construct)
703 zend_class_entry * _this_ce;
704 zval * _this_zval;
705 zval *zstream = NULL;
706 const char * file = NULL;
707 int file_len = 0;
708 double wpts = 0.0;
709 double hpts = 0.0;
710 php_stream *stream;
711 int argc = ZEND_NUM_ARGS();
712 zval ***args, *obj;
714 args = (zval **)safe_emalloc(argc, sizeof(zval *),0);
715 if(ZEND_NUM_ARGS()== 0 ||
716 zend_get_parameters_array_ex(argc, args)== FAILURE) {
717 printf("ERROR");
718 efree(args);
719 WRONG_PARAM_COUNT;
722 obj = *(args[1]);
723 switch(Z_TYPE_P(obj)) {
724 case IS_DOUBLE:
725 wpts = Z_DVAL_P(obj);
726 break;
727 case IS_LONG:
728 wpts = Z_LVAL_P(obj);
729 break;
730 default :
731 printf("Error!!!");
732 return;
735 obj = *(args[2]);
737 switch(Z_TYPE_P(obj)) {
738 case IS_DOUBLE:
739 hpts = Z_DVAL_P(obj);
740 break;
741 case IS_LONG:
742 hpts = Z_LVAL_P(obj);
743 break;
744 default :
745 printf("Error!!!");
746 return;
750 _this_zval = getThis();
751 _this_ce = Z_OBJCE_P(_this_zval);
752 surface_object *curr =(surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
754 obj = *(args[0]);
755 if(Z_TYPE_P(obj)==IS_STRING) {
756 file = Z_STRVAL_P(obj);
757 curr->surface = cairo_pdf_surface_create(file, wpts, hpts);
759 else if(Z_TYPE_P(obj)==IS_RESOURCE) {
760 zstream = obj;
761 php_stream_from_zval(stream, &zstream);
762 curr->surface = cairo_pdf_surface_create_for_stream(_write_func, stream, wpts, hpts);
764 else {
765 printf("ERROR\n");
768 efree(args);
770 /* }}} __construct */
774 /* {{{ proto void set_size(float wptd, float hpts)
776 PHP_METHOD(CairoPDFSurface, set_size)
778 zend_class_entry * _this_ce;
780 zval * _this_zval = NULL;
781 double wpts = 0.0;
782 double hpts = 0.0;
786 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoPDFSurface_ce_ptr, &wpts, &hpts) == FAILURE) {
787 return;
790 _this_ce = Z_OBJCE_P(_this_zval);
791 surface_object *curr =(surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
792 cairo_pdf_surface_set_size(curr->surface, wpts, hpts);
795 /* }}} set_size */
798 static zend_function_entry CairoPDFSurface_methods[] = {
799 PHP_ME(CairoPDFSurface, __construct, CairoPDFSurface____construct_args, /**/ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
800 PHP_ME(CairoPDFSurface, set_size, CairoPDFSurface__set_size_args, /**/ZEND_ACC_PUBLIC)
801 { NULL, NULL, NULL }
804 /* }}} Methods */
806 static zend_object_value CairoPDFSurface_object_new(zend_class_entry *ce TSRMLS_DC)
808 zend_object_value retval;
809 retval=CairoSurface_object_new(ce TSRMLS_CC);
810 retval.handlers = &CairoPDFSurface_handlers;
811 return retval;
814 static void class_init_CairoPDFSurface(void)
816 zend_class_entry ce;
818 INIT_CLASS_ENTRY(ce, "CairoPDFSurface", CairoPDFSurface_methods);
819 CairoPDFSurface_ce_ptr = zend_register_internal_class_ex(&ce, CairoSurface_ce_ptr, "CairoSurface" TSRMLS_CC);
820 CairoPDFSurface_ce_ptr->create_object = CairoPDFSurface_object_new;
821 memcpy(&CairoPDFSurface_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
825 /* }}} Class CairoPDFSurface */
827 /* {{{ Class CairoPSSurface */
829 static zend_class_entry * CairoPSSurface_ce_ptr = NULL;
830 static zend_object_handlers CairoPSSurface_handlers;
831 /* {{{ Methods */
834 /* {{{ proto void construct(string file | stream stream, float wpts, float hpts)
836 PHP_METHOD(CairoPSSurface, __construct)
838 zend_class_entry * _this_ce;
839 zval * _this_zval;
840 zval *zstream = NULL;
841 const char * file = NULL;
842 int file_len = 0;
843 double wpts = 0.0;
844 double hpts = 0.0;
845 php_stream *stream;
846 int argc = ZEND_NUM_ARGS();
847 zval ***args, *obj;
849 args = (zval **)safe_emalloc(argc, sizeof(zval *),0);
850 if(ZEND_NUM_ARGS()== 0 ||
851 zend_get_parameters_array_ex(argc, args)== FAILURE) {
852 printf("ERROR");
853 efree(args);
854 WRONG_PARAM_COUNT;
857 obj = *(args[1]);
858 switch(Z_TYPE_P(obj)) {
859 case IS_DOUBLE:
860 wpts = Z_DVAL_P(obj);
861 break;
862 case IS_LONG:
863 wpts = Z_LVAL_P(obj);
864 break;
865 default :
866 printf("Error!!!");
867 return;
870 obj = *(args[2]);
872 switch(Z_TYPE_P(obj)) {
873 case IS_DOUBLE:
874 hpts = Z_DVAL_P(obj);
875 break;
876 case IS_LONG:
877 hpts = Z_LVAL_P(obj);
878 break;
879 default :
880 printf("Error!!!");
881 return;
885 _this_zval = getThis();
886 _this_ce = Z_OBJCE_P(_this_zval);
887 surface_object *curr =(surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
889 obj = *(args[0]);
890 if(Z_TYPE_P(obj)==IS_STRING) {
891 file = Z_STRVAL_P(obj);
892 curr->surface = cairo_ps_surface_create(file, wpts, hpts);
894 else if(Z_TYPE_P(obj)==IS_RESOURCE) {
895 zstream = obj;
896 php_stream_from_zval(stream, &zstream);
897 curr->surface = cairo_ps_surface_create_for_stream(_write_func, stream, wpts, hpts);
899 else {
900 printf("ERROR\n");
903 efree(args);
909 /* }}} __construct */
913 /* {{{ proto void dsc_begin_page_setup()
915 PHP_METHOD(CairoPSSurface, dsc_begin_page_setup)
917 zend_class_entry * _this_ce;
919 zval * _this_zval = NULL;
923 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoPSSurface_ce_ptr) == FAILURE) {
924 return;
926 _this_ce = Z_OBJCE_P(_this_zval);
927 surface_object *curr =(surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
928 cairo_ps_surface_dsc_begin_page_setup(curr->surface);
929 phpCAIRO_SURFACE_ERROR(curr->surface);
934 /* }}} dsc_begin_page_setup */
938 /* {{{ proto void dsc_begin_setup()
940 PHP_METHOD(CairoPSSurface, dsc_begin_setup)
942 zend_class_entry * _this_ce;
944 zval * _this_zval = NULL;
948 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoPSSurface_ce_ptr) == FAILURE) {
949 return;
952 _this_ce = Z_OBJCE_P(_this_zval);
953 surface_object *curr =(surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
954 cairo_ps_surface_dsc_begin_setup(curr->surface);
955 phpCAIRO_SURFACE_ERROR(curr->surface);
958 /* }}} dsc_begin_setup */
962 /* {{{ proto void dsc_comment()
964 PHP_METHOD(CairoPSSurface, dsc_comment)
966 zend_class_entry * _this_ce;
968 zval * _this_zval = NULL;
972 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoPSSurface_ce_ptr) == FAILURE) {
973 return;
976 _this_ce = Z_OBJCE_P(_this_zval);
977 surface_object *curr =(surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
978 cairo_ps_surface_dsc_comment(curr->surface);
979 phpCAIRO_SURFACE_ERROR(curr->surface);
982 /* }}} dsc_comment */
986 /* {{{ proto array get_levels() -- cairo 1.6
988 PHP_METHOD(CairoPSSurface, get_levels)
990 zend_class_entry * _this_ce;
992 zval * _this_zval = NULL;
996 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoPSSurface_ce_ptr) == FAILURE) {
997 return;
1000 _this_ce = Z_OBJCE_P(_this_zval);
1001 surface_object *curr =(surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1004 array_init(return_value);
1006 do {
1007 /* ONLY for CAIRO 1.6 */
1008 } while (0);
1010 /* }}} get_levels */
1014 /* {{{ proto string get_level_string() --cairo 1.6
1016 PHP_METHOD(CairoPSSurface, get_level_string)
1018 zend_class_entry * _this_ce;
1020 zval * _this_zval = NULL;
1024 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoPSSurface_ce_ptr) == FAILURE) {
1025 return;
1028 _this_ce = Z_OBJCE_P(_this_zval);
1029 surface_object *curr =(surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1032 do {
1033 /* ONLY for CAIRO 1.6*/
1034 } while (0);
1036 /* }}} get_level_string */
1040 /* {{{ proto void restrict_to_level(int level) --cairo 1.6
1042 PHP_METHOD(CairoPSSurface, restrict_to_level)
1044 zend_class_entry * _this_ce;
1046 zval * _this_zval = NULL;
1047 long level = 0;
1051 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &_this_zval, CairoPSSurface_ce_ptr, &level) == FAILURE) {
1052 return;
1055 _this_ce = Z_OBJCE_P(_this_zval);
1056 surface_object *curr =(surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1059 do {
1060 /* ONLY for CAIRO 1.6 */
1061 } while (0);
1063 /* }}} restrict_to_level */
1067 /* {{{ proto void set_eps() --cairo 1.6
1069 PHP_METHOD(CairoPSSurface, set_eps)
1071 zend_class_entry * _this_ce;
1073 zval * _this_zval = NULL;
1077 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoPSSurface_ce_ptr) == FAILURE) {
1078 return;
1081 _this_ce = Z_OBJCE_P(_this_zval);
1082 surface_object *curr =(surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1085 do {
1086 /* ONLY for CAIRO 1.6 */
1087 } while (0);
1089 /* }}} set_eps */
1093 /* {{{ proto void set_size(float wpts, float hpts)
1095 PHP_METHOD(CairoPSSurface, set_size)
1097 zend_class_entry * _this_ce;
1099 zval * _this_zval = NULL;
1100 double wpts = 0.0;
1101 double hpts = 0.0;
1105 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Odd", &_this_zval, CairoPSSurface_ce_ptr, &wpts, &hpts) == FAILURE) {
1106 return;
1109 _this_ce = Z_OBJCE_P(_this_zval);
1110 surface_object *curr =(surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1111 cairo_ps_surface_set_size(curr->surface, wpts, hpts);
1114 /* }}} set_size */
1117 static zend_function_entry CairoPSSurface_methods[] = {
1118 PHP_ME(CairoPSSurface, __construct, CairoPSSurface____construct_args, /**/ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
1119 PHP_ME(CairoPSSurface, dsc_begin_page_setup, NULL, /**/ZEND_ACC_PUBLIC)
1120 PHP_ME(CairoPSSurface, dsc_begin_setup, NULL, /**/ZEND_ACC_PUBLIC)
1121 PHP_ME(CairoPSSurface, dsc_comment, NULL, /**/ZEND_ACC_PUBLIC)
1122 PHP_ME(CairoPSSurface, get_levels, NULL, /**/ZEND_ACC_PUBLIC)
1123 PHP_ME(CairoPSSurface, get_level_string, NULL, /**/ZEND_ACC_PUBLIC)
1124 PHP_ME(CairoPSSurface, restrict_to_level, CairoPSSurface__restrict_to_level_args, /**/ZEND_ACC_PUBLIC)
1125 PHP_ME(CairoPSSurface, set_eps, NULL, /**/ZEND_ACC_PUBLIC)
1126 PHP_ME(CairoPSSurface, set_size, CairoPSSurface__set_size_args, /**/ZEND_ACC_PUBLIC)
1127 { NULL, NULL, NULL }
1130 /* }}} Methods */
1132 static zend_object_value CairoPSSurface_object_new(zend_class_entry *ce TSRMLS_DC)
1134 zend_object_value retval;
1135 retval=CairoSurface_object_new(ce TSRMLS_CC);
1136 retval.handlers = &CairoPSSurface_handlers;
1137 return retval;
1140 static void class_init_CairoPSSurface(void)
1142 zend_class_entry ce;
1144 INIT_CLASS_ENTRY(ce, "CairoPSSurface", CairoPSSurface_methods);
1145 CairoPSSurface_ce_ptr = zend_register_internal_class_ex(&ce, CairoSurface_ce_ptr, "CairoSurface" TSRMLS_CC);
1146 CairoPSSurface_ce_ptr->create_object = CairoPSSurface_object_new;
1147 memcpy(&CairoPSSurface_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
1150 /* }}} Class CairoPSSurface */
1152 /* {{{ Class CairoQuartzSurface */
1154 static zend_class_entry * CairoQuartzSurface_ce_ptr = NULL;
1155 static zend_object_handlers CairoQuartzSurface_handlers;
1156 /* {{{ Methods */
1159 /* {{{ proto void construct(float wpixels, float hpixels [, int format])
1161 PHP_METHOD(CairoQuartzSurface, __construct)
1163 zend_class_entry * _this_ce;
1164 zval * _this_zval;
1166 double wpixels = 0.0;
1167 double hpixels = 0.0;
1168 long format = 0;
1172 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd|l", &wpixels, &hpixels, &format) == FAILURE) {
1173 return;
1176 _this_zval = getThis();
1177 _this_ce = Z_OBJCE_P(_this_zval);
1178 surface_object *curr =(surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1181 php_error(E_ERROR, "CANNOT BE CALLED"); RETURN_FALSE;
1184 /* }}} __construct */
1187 static zend_function_entry CairoQuartzSurface_methods[] = {
1188 PHP_ME(CairoQuartzSurface, __construct, CairoQuartzSurface____construct_args, /**/ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
1189 { NULL, NULL, NULL }
1192 /* }}} Methods */
1194 static zend_object_value CairoQuartzSurface_object_new(zend_class_entry *ce TSRMLS_DC)
1196 zend_object_value retval;
1197 retval=CairoSurface_object_new(ce TSRMLS_CC);
1198 retval.handlers = &CairoQuartzSurface_handlers;
1199 return retval;
1202 static void class_init_CairoQuartzSurface(void)
1204 zend_class_entry ce;
1206 INIT_CLASS_ENTRY(ce, "CairoQuartzSurface", CairoQuartzSurface_methods);
1207 CairoQuartzSurface_ce_ptr = zend_register_internal_class_ex(&ce, CairoSurface_ce_ptr, "CairoSurface" TSRMLS_CC);
1208 CairoQuartzSurface_ce_ptr->create_object = CairoQuartzSurface_object_new;
1209 memcpy(&CairoQuartzSurface_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
1213 /* }}} Class CairoQuartzSurface */
1215 /* {{{ Class CairoSVGSurface */
1217 static zend_class_entry * CairoSVGSurface_ce_ptr = NULL;
1218 static zend_object_handlers CairoSVGSurface_handlers;
1221 /* {{{ Methods */
1224 /* {{{ proto void construct(string file, float wpts, float hpts)
1226 PHP_METHOD(CairoSVGSurface, __construct)
1228 zend_class_entry * _this_ce;
1229 zval * _this_zval;
1230 zval *zstream = NULL;
1231 const char * file = NULL;
1232 int file_len = 0;
1233 double wpts = 0.0;
1234 double hpts = 0.0;
1235 php_stream *stream;
1236 int argc = ZEND_NUM_ARGS();
1237 zval ***args, *obj;
1239 args = (zval **)safe_emalloc(argc, sizeof(zval *),0);
1240 if(ZEND_NUM_ARGS()== 0 ||
1241 zend_get_parameters_array_ex(argc, args)== FAILURE) {
1242 printf("ERROR");
1243 efree(args);
1244 WRONG_PARAM_COUNT;
1247 obj = *(args[1]);
1248 switch(Z_TYPE_P(obj)) {
1249 case IS_DOUBLE:
1250 wpts = Z_DVAL_P(obj);
1251 break;
1252 case IS_LONG:
1253 wpts = Z_LVAL_P(obj);
1254 break;
1255 default :
1256 printf("error!!!");
1257 return;
1260 obj = *(args[2]);
1262 switch(Z_TYPE_P(obj)) {
1263 case IS_DOUBLE:
1264 hpts = Z_DVAL_P(obj);
1265 break;
1266 case IS_LONG:
1267 hpts = Z_LVAL_P(obj);
1268 break;
1269 default :
1270 printf("Error!!!");
1271 return;
1275 _this_zval = getThis();
1276 _this_ce = Z_OBJCE_P(_this_zval);
1277 surface_object *curr =(surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1279 obj = *(args[0]);
1280 if(Z_TYPE_P(obj)==IS_STRING) {
1281 file = Z_STRVAL_P(obj);
1282 curr->surface = cairo_svg_surface_create(file, wpts, hpts);
1284 else if(Z_TYPE_P(obj)==IS_RESOURCE) {
1285 zstream = obj;
1286 php_stream_from_zval(stream, &zstream);
1287 curr->surface = cairo_svg_surface_create_for_stream(_write_func, stream, wpts, hpts);
1289 else {
1290 printf("ERROR\n");
1293 efree(args);
1297 /* }}} __construct */
1300 static zend_function_entry CairoSVGSurface_methods[] = {
1301 PHP_ME(CairoSVGSurface, __construct, CairoSVGSurface____construct_args, /**/ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
1302 { NULL, NULL, NULL }
1305 /* }}} Methods */
1307 static zend_object_value CairoSVGSurface_object_new(zend_class_entry *ce TSRMLS_DC)
1309 zend_object_value retval;
1310 retval=CairoSurface_object_new(ce TSRMLS_CC);
1311 retval.handlers = &CairoSVGSurface_handlers;
1312 return retval;
1315 static void class_init_CairoSVGSurface(void)
1317 zend_class_entry ce;
1319 INIT_CLASS_ENTRY(ce, "CairoSVGSurface", CairoSVGSurface_methods);
1320 CairoSVGSurface_ce_ptr = zend_register_internal_class_ex(&ce, CairoSurface_ce_ptr, "CairoSurface" TSRMLS_CC);
1321 CairoSVGSurface_ce_ptr->create_object = CairoSVGSurface_object_new;
1322 memcpy(&CairoSVGSurface_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
1326 /* }}} Class CairoSVGSurface */
1328 /* {{{ Class CairoWin32Surface -- Have to work on this aswell */
1330 static zend_class_entry * CairoWin32Surface_ce_ptr = NULL;
1331 static zend_object_handlers CairoWin32Surface_handlers;
1333 /* {{{ Methods */
1336 /* {{{ proto void construct(int hdc)
1338 PHP_METHOD(CairoWin32Surface, __construct)
1340 zend_class_entry * _this_ce;
1341 zval * _this_zval;
1343 long hdc = 0;
1347 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &hdc) == FAILURE) {
1348 return;
1351 _this_zval = getThis();
1352 _this_ce = Z_OBJCE_P(_this_zval);
1353 surface_object *curr =(surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1354 curr->surface = cairo_win32_surface_create(hdc, NULL);
1356 /* }}} __construct */
1359 static zend_function_entry CairoWin32Surface_methods[] = {
1360 PHP_ME(CairoWin32Surface, __construct, NULL, /**/ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
1361 { NULL, NULL, NULL }
1364 /* }}} Methods */
1366 static zend_object_value CairoWin32Surface_object_new(zend_class_entry *ce TSRMLS_DC)
1368 zend_object_value retval;
1369 retval=CairoSurface_object_new(ce TSRMLS_CC);
1370 retval.handlers = &CairoWin32Surface_handlers;
1371 return retval;
1374 static void class_init_CairoWin32Surface(void)
1376 zend_class_entry ce;
1378 INIT_CLASS_ENTRY(ce, "CairoWin32Surface", CairoWin32Surface_methods);
1379 CairoWin32Surface_ce_ptr = zend_register_internal_class_ex(&ce, CairoSurface_ce_ptr, "CairoSurface" TSRMLS_CC);
1380 CairoWin32Surface_ce_ptr->create_object = CairoWin32Surface_object_new;
1381 memcpy(&CairoWin32Surface_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
1385 /* }}} Class CairoWin32Surface */
1387 /* {{{ Class CairoXlibSurface */
1389 static zend_class_entry * CairoXlibSurface_ce_ptr = NULL;
1390 static zend_object_handlers CairoXlibSurface_handlers;
1391 /* {{{ Methods */
1394 /* {{{ proto void construct()
1396 PHP_METHOD(CairoXlibSurface, __construct)
1398 zend_class_entry * _this_ce;
1399 zval * _this_zval;
1403 if (ZEND_NUM_ARGS()>0) {
1404 WRONG_PARAM_COUNT;
1407 _this_zval = getThis();
1408 surface_object *curr =(surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1410 php_error(E_WARNING, "Cannot Be Initialized"); RETURN_FALSE;
1413 /* }}} __construct */
1417 /* {{{ proto int get_depth()
1419 PHP_METHOD(CairoXlibSurface, get_depth)
1421 zend_class_entry * _this_ce;
1423 zval * _this_zval = NULL;
1424 long depth;
1427 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoXlibSurface_ce_ptr) == FAILURE) {
1428 return;
1431 _this_ce = Z_OBJCE_P(_this_zval);
1432 surface_object *curr =(surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1434 depth = cairo_xlib_surface_get_depth(curr->surface);
1436 RETURN_LONG(depth);
1438 /* }}} get_depth */
1442 /* {{{ proto int get_height()
1444 PHP_METHOD(CairoXlibSurface, get_height)
1446 zend_class_entry * _this_ce;
1448 zval * _this_zval = NULL;
1449 long height;
1452 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoXlibSurface_ce_ptr) == FAILURE) {
1453 return;
1456 _this_ce = Z_OBJCE_P(_this_zval);
1457 surface_object *curr =(surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1458 height = cairo_xlib_surface_get_height(curr->surface);
1460 RETURN_LONG(height);
1462 /* }}} get_height */
1466 /* {{{ proto int get_width()
1468 PHP_METHOD(CairoXlibSurface, get_width)
1470 zend_class_entry * _this_ce;
1472 zval * _this_zval = NULL;
1473 long width;
1476 if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, CairoXlibSurface_ce_ptr) == FAILURE) {
1477 return;
1480 _this_ce = Z_OBJCE_P(_this_zval);
1481 surface_object *curr =(surface_object *)zend_objects_get_address(_this_zval TSRMLS_CC);
1482 width = cairo_xlib_surface_get_width(curr->surface);
1484 RETURN_LONG(width);
1486 /* }}} get_width */
1489 static zend_function_entry CairoXlibSurface_methods[] = {
1490 PHP_ME(CairoXlibSurface, __construct, NULL, /**/ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
1491 PHP_ME(CairoXlibSurface, get_depth, NULL, /**/ZEND_ACC_PUBLIC)
1492 PHP_ME(CairoXlibSurface, get_height, NULL, /**/ZEND_ACC_PUBLIC)
1493 PHP_ME(CairoXlibSurface, get_width, NULL, /**/ZEND_ACC_PUBLIC)
1494 { NULL, NULL, NULL }
1497 /* }}} Methods */
1499 static zend_object_value CairoXlibSurface_object_new(zend_class_entry *ce TSRMLS_DC)
1501 zend_object_value retval;
1502 retval=CairoSurface_object_new(ce TSRMLS_CC);
1503 retval.handlers = &CairoXlibSurface_handlers;
1504 return retval;
1507 static void class_init_CairoXlibSurface(void)
1509 zend_class_entry ce;
1511 INIT_CLASS_ENTRY(ce, "CairoXlibSurface", CairoXlibSurface_methods);
1512 CairoXlibSurface_ce_ptr = zend_register_internal_class_ex(&ce, CairoSurface_ce_ptr, "CairoSurface" TSRMLS_CC);
1513 CairoXlibSurface_ce_ptr->create_object = CairoXlibSurface_object_new;
1514 memcpy(&CairoXlibSurface_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
1518 /* }}} Class CairoXlibSurface */
1520 /* {{{ Helper Functions */
1521 zend_class_entry *
1522 get_CairoSurface_ce_ptr(cairo_surface_t *surface)
1524 zend_class_entry *type;
1525 if(surface == NULL)
1526 return;
1528 switch(cairo_surface_get_type(surface)) {
1529 case CAIRO_SURFACE_TYPE_IMAGE:
1530 type = CairoImageSurface_ce_ptr;
1531 break;
1532 case CAIRO_SURFACE_TYPE_PDF:
1533 type = CairoPDFSurface_ce_ptr;
1534 break;
1535 case CAIRO_SURFACE_TYPE_PS:
1536 type = CairoPSSurface_ce_ptr;
1537 break;
1538 case CAIRO_SURFACE_TYPE_SVG:
1539 type = CairoSVGSurface_ce_ptr;
1540 break;
1541 case CAIRO_SURFACE_TYPE_WIN32:
1542 type = CairoWin32Surface_ce_ptr;
1543 break;
1544 case CAIRO_SURFACE_TYPE_XLIB:
1545 type = CairoXlibSurface_ce_ptr;
1546 break;
1547 case CAIRO_SURFACE_TYPE_QUARTZ:
1548 type = CairoQuartzSurface_ce_ptr;
1549 break;
1550 default:
1551 php_error(E_ERROR,"Unsupported Surface Type");
1552 return NULL;
1554 return type;
1557 /* }}} Helper Function*/