1 #ifndef PHP_DS_PRIORITY_QUEUE_H 2 #define PHP_DS_PRIORITY_QUEUE_H 3 4 #include "../../ds/ds_priority_queue.h" 5 6 typedef struct _php_ds_priority_queue_t { 7 ds_priority_queue_t *queue; 8 zval *gc_data; 9 int gc_size; 10 zend_object std; 11 } php_ds_priority_queue_t; 12 php_ds_priority_queue_fetch_object(zend_object * obj)13static inline php_ds_priority_queue_t *php_ds_priority_queue_fetch_object(zend_object *obj) { 14 return (php_ds_priority_queue_t *)((char*)(obj) - XtOffsetOf(php_ds_priority_queue_t, std)); 15 } 16 17 #define Z_DS_PRIORITY_QUEUE(z) (php_ds_priority_queue_fetch_object(Z_OBJ(z))->queue) 18 #define Z_DS_PRIORITY_QUEUE_P(z) Z_DS_PRIORITY_QUEUE(*z) 19 #define THIS_DS_PRIORITY_QUEUE() Z_DS_PRIORITY_QUEUE_P(getThis()) 20 21 #define ZVAL_DS_PRIORITY_QUEUE(z, queue) \ 22 ZVAL_OBJ(z, (php_ds_priority_queue_create_object_ex(queue))) 23 24 #define RETURN_DS_PRIORITY_QUEUE(queue) \ 25 do { \ 26 ds_priority_queue_t *_queue = queue; \ 27 if (_queue) { \ 28 ZVAL_DS_PRIORITY_QUEUE(return_value, _queue); \ 29 } else { \ 30 ZVAL_NULL(return_value); \ 31 } \ 32 return; \ 33 } while(0) 34 35 zend_object *php_ds_priority_queue_create_object_ex(ds_priority_queue_t *queue); 36 zend_object *php_ds_priority_queue_create_object(zend_class_entry *ce); 37 zend_object *php_ds_priority_queue_create_clone(ds_priority_queue_t *queue); 38 39 PHP_DS_SERIALIZE_FUNCIONS(php_ds_priority_queue); 40 41 #endif 42