1 /* {{{ Class CairoPath */
3 static zend_class_entry
* CairoPath_ce_ptr
= NULL
;
8 /* {{{ proto void construct()
10 PHP_METHOD(CairoPath
, __construct
)
16 if (ZEND_NUM_ARGS()>0) {
21 php_error(E_WARNING
, "Can not call directly"); RETURN_FALSE
;
28 /* {{{ proto array toStr()
30 PHP_METHOD(CairoPath
, toStr
)
33 zval
* _this_zval
= NULL
;
35 _this_zval
= getThis();
36 path_object
*curr
= (path_object
*)zend_objects_get_address(_this_zval TSRMLS_CC
);
38 cairo_path_t
*path
= curr
->path
;
39 array_init(return_value
);
41 cairo_path_data_t
*data
;
45 for (i
=0; i
< path
->num_data
; i
+= path
->data
[i
].header
.length
) {
46 data
= &path
->data
[i
];
47 switch (data
->header
.type
) {
48 case CAIRO_PATH_MOVE_TO
:
49 sprintf(buf
, "move_to %f %f", data
[1].point
.x
, data
[1].point
.y
);
50 add_next_index_string(return_value
, buf
, 1);
52 case CAIRO_PATH_LINE_TO
:
53 sprintf(buf
, "line_to %f %f", data
[1].point
.x
, data
[1].point
.y
);
54 add_next_index_string(return_value
, buf
, 1);
56 case CAIRO_PATH_CURVE_TO
:
57 sprintf(buf
, "curve_to %f %f %f %f %f %f", data
[1].point
.x
, data
[1].point
.y
, data
[2].point
.x
, data
[2].point
.y
, data
[3].point
.x
, data
[3].point
.y
);
58 add_next_index_string(return_value
, buf
, 1);
60 case CAIRO_PATH_CLOSE_PATH
:
61 sprintf(buf
, "close_path");
62 add_next_index_string(return_value
, buf
, 1);
72 static zend_function_entry CairoPath_methods
[] = {
73 PHP_ME(CairoPath
, __construct
, NULL
, /**/ZEND_ACC_PUBLIC
| ZEND_ACC_CTOR
)
74 PHP_ME(CairoPath
, toStr
, NULL
, /**/ZEND_ACC_PUBLIC
)
80 static zend_object_handlers CairoPath_handlers
;
83 static void CairoPath_object_dtor(void *object
)
85 path_object
*path
= (path_object
*)object
;
86 zend_hash_destroy(path
->std
.properties
);
87 FREE_HASHTABLE(path
->std
.properties
);
90 cairo_path_destroy(path
->path
);
95 static zend_object_value
CairoPath_object_new(zend_class_entry
*ce
)
97 zend_object_value retval
;
101 path
=emalloc(sizeof(path_object
));
102 memset(path
,0,sizeof(path_object
));
104 ALLOC_HASHTABLE(path
->std
.properties
);
105 zend_hash_init(path
->std
.properties
, 0, NULL
, ZVAL_PTR_DTOR
,0);
106 zend_hash_copy(path
->std
.properties
, &ce
->default_properties
, (copy_ctor_func_t
) zval_add_ref
, (void *) &temp
, sizeof(zval
*));
107 retval
.handle
= zend_objects_store_put(path
, NULL
, (zend_objects_free_object_storage_t
)CairoPath_object_dtor
, NULL TSRMLS_CC
);
108 retval
.handlers
= &CairoPath_handlers
;
112 static void class_init_CairoPath(void)
116 INIT_CLASS_ENTRY(ce
, "CairoPath", CairoPath_methods
);
117 CairoPath_ce_ptr
= zend_register_internal_class(&ce
);
118 CairoPath_ce_ptr
->create_object
= CairoPath_object_new
;
119 memcpy(&CairoPath_handlers
, zend_get_std_object_handlers(), sizeof(zend_object_handlers
));
120 CairoPath_handlers
.clone_obj
=NULL
;
124 /* }}} Class CairoPath */