1 /* {{{ Class CairoPath */
3 static zend_class_entry
* CairoPath_ce_ptr
= NULL
;
8 /* {{{ proto void construct()
10 PHP_METHOD(CairoPath
, __construct
)
12 zend_class_entry
* _this_ce
;
17 if (ZEND_NUM_ARGS()>0) {
22 php_error(E_WARNING
, "__construct: not yet implemented"); RETURN_FALSE
;
29 /* {{{ proto array toStr()
31 PHP_METHOD(CairoPath
, toStr
)
33 zend_class_entry
* _this_ce
;
35 zval
* _this_zval
= NULL
;
37 _this_zval
= getThis();
38 path_object
*curr
= (path_object
*)zend_objects_get_address(_this_zval TSRMLS_CC
);
40 cairo_path_t
*path
= curr
->path
;
41 array_init(return_value
);
43 cairo_path_data_t
*data
;
47 for (i
=0; i
< path
->num_data
; i
+= path
->data
[i
].header
.length
) {
48 data
= &path
->data
[i
];
49 switch (data
->header
.type
) {
50 case CAIRO_PATH_MOVE_TO
:
51 sprintf(buf
, "move_to %f %f", data
[1].point
.x
, data
[1].point
.y
);
52 add_next_index_string(return_value
, buf
, 1);
54 case CAIRO_PATH_LINE_TO
:
55 sprintf(buf
, "line_to %f %f", data
[1].point
.x
, data
[1].point
.y
);
56 add_next_index_string(return_value
, buf
, 1);
58 case CAIRO_PATH_CURVE_TO
:
59 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
);
60 add_next_index_string(return_value
, buf
, 1);
62 case CAIRO_PATH_CLOSE_PATH
:
63 sprintf(buf
, "close_path");
64 add_next_index_string(return_value
, buf
, 1);
74 static zend_function_entry CairoPath_methods
[] = {
75 PHP_ME(CairoPath
, __construct
, NULL
, /**/ZEND_ACC_PUBLIC
| ZEND_ACC_CTOR
)
76 PHP_ME(CairoPath
, toStr
, NULL
, /**/ZEND_ACC_PUBLIC
)
82 static zend_object_handlers CairoPath_handlers
;
85 static void CairoPath_object_dtor(void *object
)
87 path_object
*path
= (path_object
*)object
;
88 zend_hash_destroy(path
->std
.properties
);
89 FREE_HASHTABLE(path
->std
.properties
);
92 cairo_path_destroy(path
->path
);
97 static zend_object_value
CairoPath_object_new(zend_class_entry
*ce
)
99 zend_object_value retval
;
103 path
=emalloc(sizeof(path_object
));
104 memset(path
,0,sizeof(path_object
));
106 ALLOC_HASHTABLE(path
->std
.properties
);
107 zend_hash_init(path
->std
.properties
, 0, NULL
, ZVAL_PTR_DTOR
,0);
108 zend_hash_copy(path
->std
.properties
, &ce
->default_properties
, (copy_ctor_func_t
) zval_add_ref
, (void *) &temp
, sizeof(zval
*));
109 retval
.handle
= zend_objects_store_put(path
, NULL
, (zend_objects_free_object_storage_t
)CairoPath_object_dtor
, NULL TSRMLS_CC
);
110 retval
.handlers
= &CairoPath_handlers
;
114 static void class_init_CairoPath(void)
118 INIT_CLASS_ENTRY(ce
, "CairoPath", CairoPath_methods
);
119 CairoPath_ce_ptr
= zend_register_internal_class(&ce
);
120 CairoPath_ce_ptr
->create_object
= CairoPath_object_new
;
121 memcpy(&CairoPath_handlers
, zend_get_std_object_handlers(), sizeof(zend_object_handlers
));
122 CairoPath_handlers
.clone_obj
=NULL
;
126 /* }}} Class CairoPath */