2019
Nov
12

網頁好讀版

zend_string

zend_string
  1. typedef struct _zend_string zend_string;
  2.  
  3. struct _zend_string {
  4. struct _zend_string {
  5. zend_refcounted_h gc;
  6. zend_ulong h; /* hash value */
  7. size_t len;
  8. char val[1];
  9. };

zend_array

zend_array
  1. typedef struct _zend_array zend_array;
  2. struct _zend_array {
  3. zend_refcounted_h gc;
  4. union {
  5. struct {
  6. ZEND_ENDIAN_LOHI_4(
  7. zend_uchar flags,
  8. zend_uchar nApplyCount,
  9. zend_uchar nIteratorsCount,
  10. zend_uchar consistency)
  11. } v;
  12. uint32_t flags;
  13. } u;
  14. uint32_t nTableMask;
  15. Bucket *arData;
  16. uint32_t nNumUsed;
  17. uint32_t nNumOfElements;
  18. uint32_t nTableSize;
  19. uint32_t nInternalPointer;
  20. zend_long nNextFreeElement;
  21. dtor_func_t pDestructor;
  22. };

zval

zval
  1. typedef struct _zval_struct zval;
  2.  
  3. struct _zval_struct {
  4. zend_value value; /* value */
  5. union {
  6. struct {
  7. ZEND_ENDIAN_LOHI_4(
  8. zend_uchar type, /* active type */
  9. zend_uchar type_flags,
  10. zend_uchar const_flags,
  11. zend_uchar reserved) /* call info for EX(This) */
  12. } v;
  13. uint32_t type_info;
  14. } u1;
  15. union {
  16. uint32_t next; /* hash collision chain */
  17. uint32_t cache_slot; /* literal cache slot */
  18. uint32_t lineno; /* line number (for ast nodes) */
  19. uint32_t num_args; /* arguments number for EX(This) */
  20. uint32_t fe_pos; /* foreach position */
  21. uint32_t fe_iter_idx; /* foreach iterator index */
  22. uint32_t access_flags; /* class constant access flags */
  23. uint32_t property_guard; /* single property guard */
  24. uint32_t extra; /* not further specified */
  25. } u2;
  26. };

zend_value

zend_value
  1. typedef union _zend_value {
  2. zend_long lval; /* long value */
  3. double dval; /* double value */
  4. zend_refcounted *counted;
  5. zend_string *str;
  6. zend_array *arr;
  7. zend_object *obj;
  8. zend_resource *res;
  9. zend_reference *ref;
  10. zend_ast_ref *ast;
  11. zval *zv;
  12. void *ptr;
  13. zend_class_entry *ce;
  14. zend_function *func;
  15. struct {
  16. uint32_t w1;
  17. uint32_t w2;
  18. } ww;
  19. } zend_value;

zend_refcounted

zend_refcounted
  1. typedef struct _zend_refcounted_h {
  2. uint32_t refcount; /* reference counter 32-bit */
  3. union {
  4. struct {
  5. ZEND_ENDIAN_LOHI_3(
  6. zend_uchar type,
  7. zend_uchar flags, /* used for strings & objects */
  8. uint16_t gc_info) /* keeps GC root number (or 0) and color */
  9. } v;
  10. uint32_t type_info;
  11. } u;
  12. } zend_refcounted_h;

string to zend_string

string to zend_string
  1. // static zend_always_inline zend_string *zend_string_init(const char *str, size_t len, int persistent)
  2. // #define pemalloc(size, persistent) ((persistent)?__zend_malloc(size):emalloc(size))
  3.  
  4. std::string str = "abc";
  5. zend_string *zstr = zend_string_init((char*) str.c_str(), str.size(), 0);

網頁好讀版