1 #ifndef PHP_DS_STACK_H 2 #define PHP_DS_STACK_H 3 4 #include "../../ds/ds_stack.h" 5 6 typedef struct _php_ds_stack_t { 7 ds_stack_t *stack; 8 zend_object std; 9 } php_ds_stack_t; 10 php_ds_stack_fetch_object(zend_object * obj)11static inline php_ds_stack_t *php_ds_stack_fetch_object(zend_object *obj) { 12 return (php_ds_stack_t *)((char*)(obj) - XtOffsetOf(php_ds_stack_t, std)); 13 } 14 15 #define Z_DS_STACK(z) php_ds_stack_fetch_object(Z_OBJ(z))->stack 16 #define Z_DS_STACK_P(z) Z_DS_STACK(*z) 17 #define THIS_DS_STACK() Z_DS_STACK_P(getThis()) 18 19 #define ZVAL_DS_STACK(z, s) ZVAL_OBJ(z, php_ds_stack_create_object_ex(s)) 20 21 #define RETURN_DS_STACK(s) \ 22 do { \ 23 ds_stack_t *_s = s; \ 24 if (_s) { \ 25 ZVAL_DS_STACK(return_value, _s); \ 26 } else { \ 27 ZVAL_NULL(return_value); \ 28 } \ 29 return; \ 30 } while(0) 31 32 zend_object *php_ds_stack_create_object_ex(ds_stack_t *stack); 33 zend_object *php_ds_stack_create_object(zend_class_entry *ce); 34 zend_object *php_ds_stack_create_clone(ds_stack_t *stack); 35 36 PHP_DS_SERIALIZE_FUNCIONS(php_ds_stack); 37 38 #endif 39