2019
Nov
12
zend_string
zend_string
- typedef struct _zend_string zend_string;
- struct _zend_string {
- struct _zend_string {
- zend_refcounted_h gc;
- zend_ulong h; /* hash value */
- size_t len;
- char val[1];
- };
zend_array
zend_array
- typedef struct _zend_array zend_array;
- struct _zend_array {
- zend_refcounted_h gc;
- union {
- struct {
- ZEND_ENDIAN_LOHI_4(
- zend_uchar flags,
- zend_uchar nApplyCount,
- zend_uchar nIteratorsCount,
- zend_uchar consistency)
- } v;
- uint32_t flags;
- } u;
- uint32_t nTableMask;
- Bucket *arData;
- uint32_t nNumUsed;
- uint32_t nNumOfElements;
- uint32_t nTableSize;
- uint32_t nInternalPointer;
- zend_long nNextFreeElement;
- dtor_func_t pDestructor;
- };
zval
zval
- typedef struct _zval_struct zval;
- struct _zval_struct {
- zend_value value; /* value */
- union {
- struct {
- ZEND_ENDIAN_LOHI_4(
- zend_uchar type, /* active type */
- zend_uchar type_flags,
- zend_uchar const_flags,
- zend_uchar reserved) /* call info for EX(This) */
- } v;
- uint32_t type_info;
- } u1;
- union {
- uint32_t next; /* hash collision chain */
- uint32_t cache_slot; /* literal cache slot */
- uint32_t lineno; /* line number (for ast nodes) */
- uint32_t num_args; /* arguments number for EX(This) */
- uint32_t fe_pos; /* foreach position */
- uint32_t fe_iter_idx; /* foreach iterator index */
- uint32_t access_flags; /* class constant access flags */
- uint32_t property_guard; /* single property guard */
- uint32_t extra; /* not further specified */
- } u2;
- };
zend_value
zend_value
- typedef union _zend_value {
- zend_long lval; /* long value */
- double dval; /* double value */
- zend_refcounted *counted;
- zend_string *str;
- zend_array *arr;
- zend_object *obj;
- zend_resource *res;
- zend_reference *ref;
- zend_ast_ref *ast;
- zval *zv;
- void *ptr;
- zend_class_entry *ce;
- zend_function *func;
- struct {
- uint32_t w1;
- uint32_t w2;
- } ww;
- } zend_value;
zend_refcounted
zend_refcounted
- typedef struct _zend_refcounted_h {
- uint32_t refcount; /* reference counter 32-bit */
- union {
- struct {
- ZEND_ENDIAN_LOHI_3(
- zend_uchar type,
- zend_uchar flags, /* used for strings & objects */
- uint16_t gc_info) /* keeps GC root number (or 0) and color */
- } v;
- uint32_t type_info;
- } u;
- } zend_refcounted_h;
string to zend_string
string to zend_string
- // static zend_always_inline zend_string *zend_string_init(const char *str, size_t len, int persistent)
- // #define pemalloc(size, persistent) ((persistent)?__zend_malloc(size):emalloc(size))
- std::string str = "abc";
- zend_string *zstr = zend_string_init((char*) str.c_str(), str.size(), 0);
回應 (Leave a comment)