1 #ifndef PHP_DS_VECTOR_H 2 #define PHP_DS_VECTOR_H 3 4 #include "../../ds/ds_vector.h" 5 6 typedef struct php_ds_vector { 7 ds_vector_t *vector; 8 zend_object std; 9 } php_ds_vector_t; 10 php_ds_vector_fetch_object(zend_object * obj)11static inline php_ds_vector_t *php_ds_vector_fetch_object(zend_object *obj) { 12 return (php_ds_vector_t *)((char*)(obj) - XtOffsetOf(php_ds_vector_t, std)); 13 } 14 15 #define Z_DS_VECTOR(z) (php_ds_vector_fetch_object(Z_OBJ(z))->vector) 16 #define Z_DS_VECTOR_P(z) Z_DS_VECTOR(*z) 17 #define THIS_DS_VECTOR() Z_DS_VECTOR_P(getThis()) 18 19 #define ZVAL_DS_VECTOR(z, v) ZVAL_OBJ(z, php_ds_vector_create_object_ex(v)) 20 21 #define RETURN_DS_VECTOR(v) \ 22 do { \ 23 ds_vector_t *_v = v; \ 24 if (_v) { \ 25 ZVAL_DS_VECTOR(return_value, _v); \ 26 } else { \ 27 ZVAL_NULL(return_value); \ 28 } \ 29 return; \ 30 } while(0) 31 32 zend_object *php_ds_vector_create_object_ex(ds_vector_t *vector); 33 zend_object *php_ds_vector_create_object(zend_class_entry *ce); 34 zend_object *php_ds_vector_create_clone(ds_vector_t *vector); 35 36 PHP_DS_SERIALIZE_FUNCIONS(php_ds_vector); 37 38 #endif 39