2002-06-24 07:11:12 +00:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Zend Engine |
|
|
|
|
+----------------------------------------------------------------------+
|
2016-01-02 09:56:11 +00:00
|
|
|
| Copyright (c) 1998-2016 Zend Technologies Ltd. (http://www.zend.com) |
|
2002-06-24 07:11:12 +00:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| This source file is subject to version 2.00 of the Zend license, |
|
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-06-10 20:04:29 +00:00
|
|
|
| available through the world-wide-web at the following url: |
|
2002-06-24 07:11:12 +00:00
|
|
|
| http://www.zend.com/license/2_00.txt. |
|
|
|
|
| If you did not receive a copy of the Zend license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@zend.com so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Authors: Andi Gutmans <andi@zend.com> |
|
|
|
|
| Zeev Suraski <zeev@zend.com> |
|
2014-09-18 00:58:04 +00:00
|
|
|
| Dmitry Stogov <dmitry@zend.com> |
|
2015-08-31 08:38:16 +00:00
|
|
|
| Xinchen Hui <xinchen.h@zend.com> |
|
2002-06-24 07:11:12 +00:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
2003-02-01 01:49:15 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2002-06-24 07:11:12 +00:00
|
|
|
#ifndef ZEND_TYPES_H
|
|
|
|
#define ZEND_TYPES_H
|
|
|
|
|
2014-09-18 00:58:04 +00:00
|
|
|
#include "zend_portability.h"
|
2014-08-25 18:57:25 +00:00
|
|
|
#include "zend_long.h"
|
2014-08-16 09:16:11 +00:00
|
|
|
|
2014-04-02 10:34:44 +00:00
|
|
|
#ifdef WORDS_BIGENDIAN
|
|
|
|
# define ZEND_ENDIAN_LOHI(lo, hi) hi; lo;
|
|
|
|
# define ZEND_ENDIAN_LOHI_3(lo, mi, hi) hi; mi; lo;
|
|
|
|
# define ZEND_ENDIAN_LOHI_4(a, b, c, d) d; c; b; a;
|
|
|
|
# define ZEND_ENDIAN_LOHI_C(lo, hi) hi, lo
|
|
|
|
# define ZEND_ENDIAN_LOHI_C_3(lo, mi, hi) hi, mi, lo,
|
|
|
|
# define ZEND_ENDIAN_LOHI_C_4(a, b, c, d) d, c, b, a
|
|
|
|
#else
|
|
|
|
# define ZEND_ENDIAN_LOHI(lo, hi) lo; hi;
|
|
|
|
# define ZEND_ENDIAN_LOHI_3(lo, mi, hi) lo; mi; hi;
|
|
|
|
# define ZEND_ENDIAN_LOHI_4(a, b, c, d) a; b; c; d;
|
|
|
|
# define ZEND_ENDIAN_LOHI_C(lo, hi) lo, hi
|
|
|
|
# define ZEND_ENDIAN_LOHI_C_3(lo, mi, hi) lo, mi, hi,
|
|
|
|
# define ZEND_ENDIAN_LOHI_C_4(a, b, c, d) a, b, c, d
|
|
|
|
#endif
|
|
|
|
|
2002-06-24 07:11:12 +00:00
|
|
|
typedef unsigned char zend_bool;
|
|
|
|
typedef unsigned char zend_uchar;
|
|
|
|
|
2014-09-18 00:58:04 +00:00
|
|
|
typedef enum {
|
|
|
|
SUCCESS = 0,
|
|
|
|
FAILURE = -1, /* this MUST stay a negative number, or it may affect functions! */
|
|
|
|
} ZEND_RESULT_CODE;
|
|
|
|
|
2014-08-26 07:55:17 +00:00
|
|
|
#ifdef ZEND_ENABLE_ZVAL_LONG64
|
2014-08-16 09:16:11 +00:00
|
|
|
# ifdef ZEND_WIN32
|
|
|
|
# define ZEND_SIZE_MAX _UI64_MAX
|
|
|
|
# else
|
|
|
|
# define ZEND_SIZE_MAX SIZE_MAX
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
# if defined(ZEND_WIN32)
|
|
|
|
# define ZEND_SIZE_MAX _UI32_MAX
|
|
|
|
# else
|
|
|
|
# define ZEND_SIZE_MAX SIZE_MAX
|
|
|
|
# endif
|
|
|
|
#endif
|
2002-06-24 07:11:12 +00:00
|
|
|
|
2014-10-16 10:17:20 +00:00
|
|
|
typedef intptr_t zend_intptr_t;
|
|
|
|
typedef uintptr_t zend_uintptr_t;
|
2007-04-16 09:43:53 +00:00
|
|
|
|
2015-07-28 14:55:30 +00:00
|
|
|
#ifdef ZTS
|
|
|
|
#define ZEND_TLS static TSRM_TLS
|
2015-07-29 14:56:22 +00:00
|
|
|
#define ZEND_EXT_TLS TSRM_TLS
|
2015-07-28 14:55:30 +00:00
|
|
|
#else
|
|
|
|
#define ZEND_TLS static
|
2015-07-29 14:56:22 +00:00
|
|
|
#define ZEND_EXT_TLS
|
2015-07-28 14:55:30 +00:00
|
|
|
#endif
|
|
|
|
|
2005-12-20 21:35:17 +00:00
|
|
|
typedef struct _zend_object_handlers zend_object_handlers;
|
2014-02-10 06:04:30 +00:00
|
|
|
typedef struct _zend_class_entry zend_class_entry;
|
|
|
|
typedef union _zend_function zend_function;
|
2014-10-03 15:32:46 +00:00
|
|
|
typedef struct _zend_execute_data zend_execute_data;
|
2005-12-20 21:35:17 +00:00
|
|
|
|
2014-02-10 06:04:30 +00:00
|
|
|
typedef struct _zval_struct zval;
|
|
|
|
|
|
|
|
typedef struct _zend_refcounted zend_refcounted;
|
|
|
|
typedef struct _zend_string zend_string;
|
|
|
|
typedef struct _zend_array zend_array;
|
|
|
|
typedef struct _zend_object zend_object;
|
|
|
|
typedef struct _zend_resource zend_resource;
|
|
|
|
typedef struct _zend_reference zend_reference;
|
|
|
|
typedef struct _zend_ast_ref zend_ast_ref;
|
|
|
|
typedef struct _zend_ast zend_ast;
|
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
typedef int (*compare_func_t)(const void *, const void *);
|
2015-01-14 09:22:58 +00:00
|
|
|
typedef void (*swap_func_t)(void *, void *);
|
|
|
|
typedef void (*sort_func_t)(void *, size_t, size_t, compare_func_t, swap_func_t);
|
2014-02-11 11:30:42 +00:00
|
|
|
typedef void (*dtor_func_t)(zval *pDest);
|
|
|
|
typedef void (*copy_ctor_func_t)(zval *pElement);
|
2014-02-10 06:04:30 +00:00
|
|
|
|
|
|
|
typedef union _zend_value {
|
2014-09-16 07:56:56 +00:00
|
|
|
zend_long lval; /* long value */
|
2014-02-10 06:04:30 +00:00
|
|
|
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;
|
2014-12-09 15:07:39 +00:00
|
|
|
struct {
|
2015-08-10 14:58:58 +00:00
|
|
|
uint32_t w1;
|
|
|
|
uint32_t w2;
|
2014-12-09 15:07:39 +00:00
|
|
|
} ww;
|
2014-02-10 06:04:30 +00:00
|
|
|
} zend_value;
|
|
|
|
|
|
|
|
struct _zval_struct {
|
|
|
|
zend_value value; /* value */
|
|
|
|
union {
|
2014-04-02 10:34:44 +00:00
|
|
|
struct {
|
|
|
|
ZEND_ENDIAN_LOHI_4(
|
2014-04-03 11:26:23 +00:00
|
|
|
zend_uchar type, /* active type */
|
|
|
|
zend_uchar type_flags,
|
|
|
|
zend_uchar const_flags,
|
2014-11-28 07:33:03 +00:00
|
|
|
zend_uchar reserved) /* call info for EX(This) */
|
2014-04-02 10:34:44 +00:00
|
|
|
} v;
|
2014-08-25 17:28:33 +00:00
|
|
|
uint32_t type_info;
|
2014-04-03 11:26:23 +00:00
|
|
|
} u1;
|
|
|
|
union {
|
2014-08-25 17:28:33 +00:00
|
|
|
uint32_t var_flags;
|
|
|
|
uint32_t next; /* hash collision chain */
|
|
|
|
uint32_t cache_slot; /* literal cache slot */
|
2014-08-25 19:21:16 +00:00
|
|
|
uint32_t lineno; /* line number (for ast nodes) */
|
2014-11-28 07:28:49 +00:00
|
|
|
uint32_t num_args; /* arguments number for EX(This) */
|
2015-02-12 10:57:12 +00:00
|
|
|
uint32_t fe_pos; /* foreach position */
|
|
|
|
uint32_t fe_iter_idx; /* foreach iterator index */
|
2015-12-08 09:40:42 +00:00
|
|
|
uint32_t access_flags; /* class constant access flags */
|
2014-04-03 11:26:23 +00:00
|
|
|
} u2;
|
2014-02-10 06:04:30 +00:00
|
|
|
};
|
|
|
|
|
2015-08-13 10:56:29 +00:00
|
|
|
typedef struct _zend_refcounted_h {
|
2014-08-25 17:28:33 +00:00
|
|
|
uint32_t refcount; /* reference counter 32-bit */
|
2014-02-10 06:04:30 +00:00
|
|
|
union {
|
|
|
|
struct {
|
2014-04-02 10:34:44 +00:00
|
|
|
ZEND_ENDIAN_LOHI_3(
|
|
|
|
zend_uchar type,
|
|
|
|
zend_uchar flags, /* used for strings & objects */
|
2014-09-16 07:56:56 +00:00
|
|
|
uint16_t gc_info) /* keeps GC root number (or 0) and color */
|
2014-02-10 06:04:30 +00:00
|
|
|
} v;
|
2014-08-25 17:28:33 +00:00
|
|
|
uint32_t type_info;
|
2014-03-19 13:00:28 +00:00
|
|
|
} u;
|
2015-08-13 10:56:29 +00:00
|
|
|
} zend_refcounted_h;
|
|
|
|
|
|
|
|
struct _zend_refcounted {
|
|
|
|
zend_refcounted_h gc;
|
2014-02-10 06:04:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _zend_string {
|
2015-08-13 10:56:29 +00:00
|
|
|
zend_refcounted_h gc;
|
2014-09-16 07:56:56 +00:00
|
|
|
zend_ulong h; /* hash value */
|
|
|
|
size_t len;
|
2014-02-10 06:04:30 +00:00
|
|
|
char val[1];
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _Bucket {
|
2014-11-17 11:06:50 +00:00
|
|
|
zval val;
|
2014-09-16 07:56:56 +00:00
|
|
|
zend_ulong h; /* hash value (or numeric index) */
|
2014-02-10 06:04:30 +00:00
|
|
|
zend_string *key; /* string key or NULL for numerics */
|
|
|
|
} Bucket;
|
|
|
|
|
2015-02-13 19:20:39 +00:00
|
|
|
typedef struct _zend_array HashTable;
|
|
|
|
|
|
|
|
struct _zend_array {
|
2015-08-13 10:56:29 +00:00
|
|
|
zend_refcounted_h gc;
|
2014-04-21 14:25:34 +00:00
|
|
|
union {
|
|
|
|
struct {
|
2015-02-12 10:57:12 +00:00
|
|
|
ZEND_ENDIAN_LOHI_4(
|
2014-04-21 14:25:34 +00:00
|
|
|
zend_uchar flags,
|
|
|
|
zend_uchar nApplyCount,
|
2015-02-12 10:57:12 +00:00
|
|
|
zend_uchar nIteratorsCount,
|
|
|
|
zend_uchar reserve)
|
2014-04-21 14:25:34 +00:00
|
|
|
} v;
|
2014-08-25 17:28:33 +00:00
|
|
|
uint32_t flags;
|
2014-04-21 14:25:34 +00:00
|
|
|
} u;
|
2014-12-27 08:07:12 +00:00
|
|
|
uint32_t nTableMask;
|
2015-03-13 14:13:19 +00:00
|
|
|
Bucket *arData;
|
2014-12-27 08:07:12 +00:00
|
|
|
uint32_t nNumUsed;
|
|
|
|
uint32_t nNumOfElements;
|
2015-03-13 14:13:19 +00:00
|
|
|
uint32_t nTableSize;
|
2015-01-03 09:22:58 +00:00
|
|
|
uint32_t nInternalPointer;
|
2014-12-27 08:07:12 +00:00
|
|
|
zend_long nNextFreeElement;
|
|
|
|
dtor_func_t pDestructor;
|
2014-02-10 06:04:30 +00:00
|
|
|
};
|
|
|
|
|
2015-03-13 14:13:19 +00:00
|
|
|
/*
|
|
|
|
* HashTable Data Layout
|
|
|
|
* =====================
|
|
|
|
*
|
|
|
|
* +=============================+
|
|
|
|
* | HT_HASH(ht, ht->nTableMask) |
|
|
|
|
* | ... |
|
|
|
|
* | HT_HASH(ht, -1) |
|
|
|
|
* +-----------------------------+
|
|
|
|
* ht->arData ---> | Bucket[0] |
|
|
|
|
* | ... |
|
|
|
|
* | Bucket[ht->nTableSize-1] |
|
|
|
|
* +=============================+
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define HT_INVALID_IDX ((uint32_t) -1)
|
|
|
|
|
|
|
|
#define HT_MIN_MASK ((uint32_t) -2)
|
2015-02-12 23:12:42 +00:00
|
|
|
#define HT_MIN_SIZE 8
|
|
|
|
|
|
|
|
#if SIZEOF_SIZE_T == 4
|
|
|
|
# define HT_MAX_SIZE 0x04000000 /* small enough to avoid overflow checks */
|
2015-03-13 14:13:19 +00:00
|
|
|
# define HT_HASH_TO_BUCKET_EX(data, idx) \
|
|
|
|
((Bucket*)((char*)(data) + (idx)))
|
|
|
|
# define HT_IDX_TO_HASH(idx) \
|
|
|
|
((idx) * sizeof(Bucket))
|
2015-03-17 20:13:39 +00:00
|
|
|
# define HT_HASH_TO_IDX(idx) \
|
|
|
|
((idx) / sizeof(Bucket))
|
2015-02-12 23:12:42 +00:00
|
|
|
#elif SIZEOF_SIZE_T == 8
|
|
|
|
# define HT_MAX_SIZE 0x80000000
|
2015-03-13 14:13:19 +00:00
|
|
|
# define HT_HASH_TO_BUCKET_EX(data, idx) \
|
|
|
|
((data) + (idx))
|
|
|
|
# define HT_IDX_TO_HASH(idx) \
|
|
|
|
(idx)
|
2015-03-17 20:13:39 +00:00
|
|
|
# define HT_HASH_TO_IDX(idx) \
|
|
|
|
(idx)
|
2015-02-12 23:12:42 +00:00
|
|
|
#else
|
|
|
|
# error "Unknown SIZEOF_SIZE_T"
|
|
|
|
#endif
|
|
|
|
|
2015-03-13 14:13:19 +00:00
|
|
|
#define HT_HASH_EX(data, idx) \
|
2015-03-31 04:40:29 +00:00
|
|
|
((uint32_t*)(data))[(int32_t)(idx)]
|
2015-03-13 14:13:19 +00:00
|
|
|
#define HT_HASH(ht, idx) \
|
|
|
|
HT_HASH_EX((ht)->arData, idx)
|
|
|
|
|
2015-08-13 15:38:39 +00:00
|
|
|
#define HT_HASH_SIZE(nTableMask) \
|
2015-08-13 04:08:57 +00:00
|
|
|
(((size_t)(uint32_t)-(int32_t)(nTableMask)) * sizeof(uint32_t))
|
2015-08-13 15:38:39 +00:00
|
|
|
#define HT_DATA_SIZE(nTableSize) \
|
2015-08-13 04:08:57 +00:00
|
|
|
((size_t)(nTableSize) * sizeof(Bucket))
|
2015-08-13 15:38:39 +00:00
|
|
|
#define HT_SIZE_EX(nTableSize, nTableMask) \
|
|
|
|
(HT_DATA_SIZE((nTableSize)) + HT_HASH_SIZE((nTableMask)))
|
2015-03-13 14:13:19 +00:00
|
|
|
#define HT_SIZE(ht) \
|
2015-08-13 15:38:39 +00:00
|
|
|
HT_SIZE_EX((ht)->nTableSize, (ht)->nTableMask)
|
2015-03-13 14:13:19 +00:00
|
|
|
#define HT_USED_SIZE(ht) \
|
2015-08-13 15:38:39 +00:00
|
|
|
(HT_HASH_SIZE((ht)->nTableMask) + ((size_t)(ht)->nNumUsed * sizeof(Bucket)))
|
2015-03-13 14:13:19 +00:00
|
|
|
#define HT_HASH_RESET(ht) \
|
2015-08-13 15:38:39 +00:00
|
|
|
memset(&HT_HASH(ht, (ht)->nTableMask), HT_INVALID_IDX, HT_HASH_SIZE((ht)->nTableMask))
|
2015-03-13 14:13:19 +00:00
|
|
|
#define HT_HASH_RESET_PACKED(ht) do { \
|
|
|
|
HT_HASH(ht, -2) = HT_INVALID_IDX; \
|
|
|
|
HT_HASH(ht, -1) = HT_INVALID_IDX; \
|
|
|
|
} while (0)
|
|
|
|
#define HT_HASH_TO_BUCKET(ht, idx) \
|
|
|
|
HT_HASH_TO_BUCKET_EX((ht)->arData, idx)
|
|
|
|
|
|
|
|
#define HT_SET_DATA_ADDR(ht, ptr) do { \
|
2015-08-13 15:38:39 +00:00
|
|
|
(ht)->arData = (Bucket*)(((char*)(ptr)) + HT_HASH_SIZE((ht)->nTableMask)); \
|
2015-03-13 14:13:19 +00:00
|
|
|
} while (0)
|
|
|
|
#define HT_GET_DATA_ADDR(ht) \
|
2015-08-13 15:38:39 +00:00
|
|
|
((char*)((ht)->arData) - HT_HASH_SIZE((ht)->nTableMask))
|
2015-03-13 14:13:19 +00:00
|
|
|
|
2015-02-12 10:57:12 +00:00
|
|
|
typedef uint32_t HashPosition;
|
|
|
|
|
|
|
|
typedef struct _HashTableIterator {
|
|
|
|
HashTable *ht;
|
|
|
|
HashPosition pos;
|
|
|
|
} HashTableIterator;
|
|
|
|
|
2014-02-10 06:04:30 +00:00
|
|
|
struct _zend_object {
|
2015-08-13 10:56:29 +00:00
|
|
|
zend_refcounted_h gc;
|
2014-09-16 07:56:56 +00:00
|
|
|
uint32_t handle; // TODO: may be removed ???
|
2014-02-10 06:04:30 +00:00
|
|
|
zend_class_entry *ce;
|
2011-09-13 13:29:35 +00:00
|
|
|
const zend_object_handlers *handlers;
|
2014-02-10 06:04:30 +00:00
|
|
|
HashTable *properties;
|
|
|
|
zval properties_table[1];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _zend_resource {
|
2015-08-13 10:56:29 +00:00
|
|
|
zend_refcounted_h gc;
|
2014-12-15 05:43:28 +00:00
|
|
|
int handle; // TODO: may be removed ???
|
2014-02-10 06:04:30 +00:00
|
|
|
int type;
|
|
|
|
void *ptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _zend_reference {
|
2015-08-13 10:56:29 +00:00
|
|
|
zend_refcounted_h gc;
|
2014-02-10 06:04:30 +00:00
|
|
|
zval val;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _zend_ast_ref {
|
2015-08-13 10:56:29 +00:00
|
|
|
zend_refcounted_h gc;
|
2014-02-10 06:04:30 +00:00
|
|
|
zend_ast *ast;
|
|
|
|
};
|
|
|
|
|
2014-04-29 06:54:59 +00:00
|
|
|
/* regular data types */
|
2014-02-10 06:04:30 +00:00
|
|
|
#define IS_UNDEF 0
|
|
|
|
#define IS_NULL 1
|
2014-04-30 14:32:42 +00:00
|
|
|
#define IS_FALSE 2
|
|
|
|
#define IS_TRUE 3
|
|
|
|
#define IS_LONG 4
|
|
|
|
#define IS_DOUBLE 5
|
|
|
|
#define IS_STRING 6
|
|
|
|
#define IS_ARRAY 7
|
|
|
|
#define IS_OBJECT 8
|
|
|
|
#define IS_RESOURCE 9
|
2014-05-06 23:26:13 +00:00
|
|
|
#define IS_REFERENCE 10
|
2014-04-29 06:54:59 +00:00
|
|
|
|
|
|
|
/* constant expressions */
|
2014-04-30 14:32:42 +00:00
|
|
|
#define IS_CONSTANT 11
|
2014-05-07 11:03:56 +00:00
|
|
|
#define IS_CONSTANT_AST 12
|
2014-04-29 06:54:59 +00:00
|
|
|
|
2014-04-30 14:32:42 +00:00
|
|
|
/* fake types */
|
2014-05-07 11:03:56 +00:00
|
|
|
#define _IS_BOOL 13
|
|
|
|
#define IS_CALLABLE 14
|
2015-10-14 18:15:32 +00:00
|
|
|
#define IS_VOID 18
|
2014-04-29 06:54:59 +00:00
|
|
|
|
|
|
|
/* internal types */
|
2014-05-07 11:03:56 +00:00
|
|
|
#define IS_INDIRECT 15
|
|
|
|
#define IS_PTR 17
|
2014-04-03 11:26:23 +00:00
|
|
|
|
2014-09-18 00:59:01 +00:00
|
|
|
static zend_always_inline zend_uchar zval_get_type(const zval* pz) {
|
2014-04-03 11:26:23 +00:00
|
|
|
return pz->u1.v.type;
|
|
|
|
}
|
|
|
|
|
2015-01-10 03:29:41 +00:00
|
|
|
#define ZEND_SAME_FAKE_TYPE(faketype, realtype) ( \
|
|
|
|
(faketype) == (realtype) \
|
|
|
|
|| ((faketype) == _IS_BOOL && ((realtype) == IS_TRUE || (realtype) == IS_FALSE)) \
|
|
|
|
)
|
|
|
|
|
2014-04-15 11:40:40 +00:00
|
|
|
/* we should never set just Z_TYPE, we should set Z_TYPE_INFO */
|
|
|
|
#define Z_TYPE(zval) zval_get_type(&(zval))
|
2014-04-03 11:26:23 +00:00
|
|
|
#define Z_TYPE_P(zval_p) Z_TYPE(*(zval_p))
|
2014-02-10 06:04:30 +00:00
|
|
|
|
2014-04-03 11:26:23 +00:00
|
|
|
#define Z_TYPE_FLAGS(zval) (zval).u1.v.type_flags
|
|
|
|
#define Z_TYPE_FLAGS_P(zval_p) Z_TYPE_FLAGS(*(zval_p))
|
2014-02-10 06:04:30 +00:00
|
|
|
|
2014-04-03 11:26:23 +00:00
|
|
|
#define Z_CONST_FLAGS(zval) (zval).u1.v.const_flags
|
|
|
|
#define Z_CONST_FLAGS_P(zval_p) Z_CONST_FLAGS(*(zval_p))
|
2014-02-10 06:04:30 +00:00
|
|
|
|
2014-04-03 11:26:23 +00:00
|
|
|
#define Z_VAR_FLAGS(zval) (zval).u2.var_flags
|
|
|
|
#define Z_VAR_FLAGS_P(zval_p) Z_VAR_FLAGS(*(zval_p))
|
2014-04-02 10:34:44 +00:00
|
|
|
|
2014-04-03 11:26:23 +00:00
|
|
|
#define Z_TYPE_INFO(zval) (zval).u1.type_info
|
2014-04-02 10:34:44 +00:00
|
|
|
#define Z_TYPE_INFO_P(zval_p) Z_TYPE_INFO(*(zval_p))
|
|
|
|
|
2014-04-03 11:26:23 +00:00
|
|
|
#define Z_NEXT(zval) (zval).u2.next
|
2014-04-02 10:34:44 +00:00
|
|
|
#define Z_NEXT_P(zval_p) Z_NEXT(*(zval_p))
|
|
|
|
|
2014-04-17 11:40:45 +00:00
|
|
|
#define Z_CACHE_SLOT(zval) (zval).u2.cache_slot
|
|
|
|
#define Z_CACHE_SLOT_P(zval_p) Z_CACHE_SLOT(*(zval_p))
|
|
|
|
|
2015-02-12 10:57:12 +00:00
|
|
|
#define Z_FE_POS(zval) (zval).u2.fe_pos
|
|
|
|
#define Z_FE_POS_P(zval_p) Z_FE_POS(*(zval_p))
|
|
|
|
|
|
|
|
#define Z_FE_ITER(zval) (zval).u2.fe_iter_idx
|
|
|
|
#define Z_FE_ITER_P(zval_p) Z_FE_ITER(*(zval_p))
|
|
|
|
|
2015-12-08 09:40:42 +00:00
|
|
|
#define Z_ACCESS_FLAGS(zval) (zval).u2.access_flags
|
|
|
|
#define Z_ACCESS_FLAGS_P(zval_p) Z_ACCESS_FLAGS(*(zval_p))
|
|
|
|
|
2014-04-02 10:34:44 +00:00
|
|
|
#define Z_COUNTED(zval) (zval).value.counted
|
|
|
|
#define Z_COUNTED_P(zval_p) Z_COUNTED(*(zval_p))
|
|
|
|
|
2015-05-13 09:55:42 +00:00
|
|
|
#define Z_TYPE_MASK 0xff
|
|
|
|
|
2014-04-03 22:52:53 +00:00
|
|
|
#define Z_TYPE_FLAGS_SHIFT 8
|
2014-12-26 19:34:44 +00:00
|
|
|
#define Z_CONST_FLAGS_SHIFT 16
|
2014-04-03 22:52:53 +00:00
|
|
|
|
2015-08-13 10:56:29 +00:00
|
|
|
#define GC_REFCOUNT(p) (p)->gc.refcount
|
|
|
|
#define GC_TYPE(p) (p)->gc.u.v.type
|
|
|
|
#define GC_FLAGS(p) (p)->gc.u.v.flags
|
|
|
|
#define GC_INFO(p) (p)->gc.u.v.gc_info
|
|
|
|
#define GC_TYPE_INFO(p) (p)->gc.u.type_info
|
2014-04-02 10:34:44 +00:00
|
|
|
|
|
|
|
#define Z_GC_TYPE(zval) GC_TYPE(Z_COUNTED(zval))
|
|
|
|
#define Z_GC_TYPE_P(zval_p) Z_GC_TYPE(*(zval_p))
|
|
|
|
|
|
|
|
#define Z_GC_FLAGS(zval) GC_FLAGS(Z_COUNTED(zval))
|
2014-05-16 20:00:07 +00:00
|
|
|
#define Z_GC_FLAGS_P(zval_p) Z_GC_FLAGS(*(zval_p))
|
2014-04-02 10:34:44 +00:00
|
|
|
|
|
|
|
#define Z_GC_INFO(zval) GC_INFO(Z_COUNTED(zval))
|
|
|
|
#define Z_GC_INFO_P(zval_p) Z_GC_INFO(*(zval_p))
|
|
|
|
|
|
|
|
#define Z_GC_TYPE_INFO(zval) GC_TYPE_INFO(Z_COUNTED(zval))
|
|
|
|
#define Z_GC_TYPE_INFO_P(zval_p) Z_GC_TYPE_INFO(*(zval_p))
|
|
|
|
|
2014-04-03 11:26:23 +00:00
|
|
|
/* zval.u1.v.type_flags */
|
|
|
|
#define IS_TYPE_CONSTANT (1<<0)
|
2014-12-26 19:34:44 +00:00
|
|
|
#define IS_TYPE_IMMUTABLE (1<<1)
|
|
|
|
#define IS_TYPE_REFCOUNTED (1<<2)
|
|
|
|
#define IS_TYPE_COLLECTABLE (1<<3)
|
|
|
|
#define IS_TYPE_COPYABLE (1<<4)
|
2014-04-03 11:26:23 +00:00
|
|
|
|
|
|
|
/* extended types */
|
|
|
|
#define IS_INTERNED_STRING_EX IS_STRING
|
|
|
|
|
2014-04-03 22:52:53 +00:00
|
|
|
#define IS_STRING_EX (IS_STRING | (( IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE) << Z_TYPE_FLAGS_SHIFT))
|
|
|
|
#define IS_ARRAY_EX (IS_ARRAY | (( IS_TYPE_REFCOUNTED | IS_TYPE_COLLECTABLE | IS_TYPE_COPYABLE) << Z_TYPE_FLAGS_SHIFT))
|
|
|
|
#define IS_OBJECT_EX (IS_OBJECT | (( IS_TYPE_REFCOUNTED | IS_TYPE_COLLECTABLE ) << Z_TYPE_FLAGS_SHIFT))
|
|
|
|
#define IS_RESOURCE_EX (IS_RESOURCE | (( IS_TYPE_REFCOUNTED ) << Z_TYPE_FLAGS_SHIFT))
|
|
|
|
#define IS_REFERENCE_EX (IS_REFERENCE | (( IS_TYPE_REFCOUNTED ) << Z_TYPE_FLAGS_SHIFT))
|
2014-04-03 11:26:23 +00:00
|
|
|
|
2014-04-03 22:52:53 +00:00
|
|
|
#define IS_CONSTANT_EX (IS_CONSTANT | ((IS_TYPE_CONSTANT | IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE) << Z_TYPE_FLAGS_SHIFT))
|
|
|
|
#define IS_CONSTANT_AST_EX (IS_CONSTANT_AST | ((IS_TYPE_CONSTANT | IS_TYPE_REFCOUNTED | IS_TYPE_COPYABLE) << Z_TYPE_FLAGS_SHIFT))
|
2014-04-03 11:26:23 +00:00
|
|
|
|
|
|
|
/* zval.u1.v.const_flags */
|
|
|
|
#define IS_CONSTANT_UNQUALIFIED 0x010
|
2015-03-18 12:31:29 +00:00
|
|
|
#define IS_CONSTANT_CLASS 0x080 /* __CLASS__ in trait */
|
2014-04-03 11:26:23 +00:00
|
|
|
#define IS_CONSTANT_IN_NAMESPACE 0x100 /* used only in opline->extended_value */
|
|
|
|
|
|
|
|
/* zval.u2.var_flags */
|
2014-03-07 08:25:55 +00:00
|
|
|
#define IS_VAR_RET_REF (1<<0) /* return by by reference */
|
|
|
|
|
2014-02-24 11:25:24 +00:00
|
|
|
/* string flags (zval.value->gc.u.flags) */
|
2014-02-10 06:04:30 +00:00
|
|
|
#define IS_STR_PERSISTENT (1<<0) /* allocated using malloc */
|
|
|
|
#define IS_STR_INTERNED (1<<1) /* interned string */
|
|
|
|
#define IS_STR_PERMANENT (1<<2) /* relives request boundary */
|
|
|
|
|
2014-02-24 11:25:24 +00:00
|
|
|
#define IS_STR_CONSTANT (1<<3) /* constant index */
|
|
|
|
#define IS_STR_CONSTANT_UNQUALIFIED (1<<4) /* the same as IS_CONSTANT_UNQUALIFIED */
|
|
|
|
|
2015-02-20 10:28:26 +00:00
|
|
|
/* array flags */
|
|
|
|
#define IS_ARRAY_IMMUTABLE (1<<1) /* the same as IS_TYPE_IMMUTABLE */
|
|
|
|
|
2014-04-03 11:26:23 +00:00
|
|
|
/* object flags (zval.value->gc.u.flags) */
|
2014-02-12 14:08:11 +00:00
|
|
|
#define IS_OBJ_APPLY_COUNT 0x07
|
|
|
|
#define IS_OBJ_DESTRUCTOR_CALLED (1<<3)
|
2014-04-08 21:50:15 +00:00
|
|
|
#define IS_OBJ_FREE_CALLED (1<<4)
|
2015-02-04 12:24:13 +00:00
|
|
|
#define IS_OBJ_USE_GUARDS (1<<5)
|
|
|
|
#define IS_OBJ_HAS_GUARDS (1<<6)
|
2014-02-12 14:08:11 +00:00
|
|
|
|
|
|
|
#define Z_OBJ_APPLY_COUNT(zval) \
|
2014-04-02 10:34:44 +00:00
|
|
|
(Z_GC_FLAGS(zval) & IS_OBJ_APPLY_COUNT)
|
2014-02-12 14:08:11 +00:00
|
|
|
|
|
|
|
#define Z_OBJ_INC_APPLY_COUNT(zval) do { \
|
2014-04-02 10:34:44 +00:00
|
|
|
Z_GC_FLAGS(zval) = \
|
|
|
|
(Z_GC_FLAGS(zval) & ~IS_OBJ_APPLY_COUNT) | \
|
|
|
|
((Z_GC_FLAGS(zval) & IS_OBJ_APPLY_COUNT) + 1); \
|
2014-02-12 14:08:11 +00:00
|
|
|
} while (0)
|
2015-01-03 09:22:58 +00:00
|
|
|
|
2014-02-12 14:08:11 +00:00
|
|
|
#define Z_OBJ_DEC_APPLY_COUNT(zval) do { \
|
2014-04-02 10:34:44 +00:00
|
|
|
Z_GC_FLAGS(zval) = \
|
|
|
|
(Z_GC_FLAGS(zval) & ~IS_OBJ_APPLY_COUNT) | \
|
|
|
|
((Z_GC_FLAGS(zval) & IS_OBJ_APPLY_COUNT) - 1); \
|
2014-02-12 14:08:11 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define Z_OBJ_APPLY_COUNT_P(zv) Z_OBJ_APPLY_COUNT(*(zv))
|
|
|
|
#define Z_OBJ_INC_APPLY_COUNT_P(zv) Z_OBJ_INC_APPLY_COUNT(*(zv))
|
|
|
|
#define Z_OBJ_DEC_APPLY_COUNT_P(zv) Z_OBJ_DEC_APPLY_COUNT(*(zv))
|
2014-02-10 06:04:30 +00:00
|
|
|
|
2014-04-03 11:26:23 +00:00
|
|
|
/* All data types < IS_STRING have their constructor/destructors skipped */
|
2014-04-03 23:55:27 +00:00
|
|
|
#define Z_CONSTANT(zval) ((Z_TYPE_FLAGS(zval) & IS_TYPE_CONSTANT) != 0)
|
|
|
|
#define Z_CONSTANT_P(zval_p) Z_CONSTANT(*(zval_p))
|
|
|
|
|
2014-04-03 22:52:53 +00:00
|
|
|
#define Z_REFCOUNTED(zval) ((Z_TYPE_FLAGS(zval) & IS_TYPE_REFCOUNTED) != 0)
|
2014-02-10 06:04:30 +00:00
|
|
|
#define Z_REFCOUNTED_P(zval_p) Z_REFCOUNTED(*(zval_p))
|
|
|
|
|
2014-04-03 22:52:53 +00:00
|
|
|
#define Z_COLLECTABLE(zval) ((Z_TYPE_FLAGS(zval) & IS_TYPE_COLLECTABLE) != 0)
|
|
|
|
#define Z_COLLECTABLE_P(zval_p) Z_COLLECTABLE(*(zval_p))
|
|
|
|
|
|
|
|
#define Z_COPYABLE(zval) ((Z_TYPE_FLAGS(zval) & IS_TYPE_COPYABLE) != 0)
|
|
|
|
#define Z_COPYABLE_P(zval_p) Z_COPYABLE(*(zval_p))
|
|
|
|
|
2014-05-29 14:21:56 +00:00
|
|
|
#define Z_IMMUTABLE(zval) ((Z_TYPE_FLAGS(zval) & IS_TYPE_IMMUTABLE) != 0)
|
|
|
|
#define Z_IMMUTABLE_P(zval_p) Z_IMMUTABLE(*(zval_p))
|
|
|
|
|
2014-04-03 22:52:53 +00:00
|
|
|
/* the following Z_OPT_* macros make better code when Z_TYPE_INFO accessed before */
|
2015-05-13 09:55:42 +00:00
|
|
|
#define Z_OPT_TYPE(zval) (Z_TYPE_INFO(zval) & Z_TYPE_MASK)
|
2014-04-03 22:52:53 +00:00
|
|
|
#define Z_OPT_TYPE_P(zval_p) Z_OPT_TYPE(*(zval_p))
|
|
|
|
|
2014-04-03 23:55:27 +00:00
|
|
|
#define Z_OPT_CONSTANT(zval) ((Z_TYPE_INFO(zval) & (IS_TYPE_CONSTANT << Z_TYPE_FLAGS_SHIFT)) != 0)
|
|
|
|
#define Z_OPT_CONSTANT_P(zval_p) Z_OPT_CONSTANT(*(zval_p))
|
|
|
|
|
2014-04-03 22:52:53 +00:00
|
|
|
#define Z_OPT_REFCOUNTED(zval) ((Z_TYPE_INFO(zval) & (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT)) != 0)
|
|
|
|
#define Z_OPT_REFCOUNTED_P(zval_p) Z_OPT_REFCOUNTED(*(zval_p))
|
|
|
|
|
|
|
|
#define Z_OPT_COLLECTABLE(zval) ((Z_TYPE_INFO(zval) & (IS_TYPE_COLLECTABLE << Z_TYPE_FLAGS_SHIFT)) != 0)
|
|
|
|
#define Z_OPT_COLLECTABLE_P(zval_p) Z_OPT_COLLECTABLE(*(zval_p))
|
|
|
|
|
|
|
|
#define Z_OPT_COPYABLE(zval) ((Z_TYPE_INFO(zval) & (IS_TYPE_COPYABLE << Z_TYPE_FLAGS_SHIFT)) != 0)
|
|
|
|
#define Z_OPT_COPYABLE_P(zval_p) Z_OPT_COPYABLE(*(zval_p))
|
|
|
|
|
2014-05-29 14:21:56 +00:00
|
|
|
#define Z_OPT_IMMUTABLE(zval) ((Z_TYPE_INFO(zval) & (IS_TYPE_IMMUTABLE << Z_TYPE_FLAGS_SHIFT)) != 0)
|
|
|
|
#define Z_OPT_IMMUTABLE_P(zval_p) Z_OPT_IMMUTABLE(*(zval_p))
|
|
|
|
|
2015-07-10 08:39:21 +00:00
|
|
|
#define Z_OPT_ISREF(zval) (Z_OPT_TYPE(zval) == IS_REFERENCE)
|
|
|
|
#define Z_OPT_ISREF_P(zval_p) Z_OPT_ISREF(*(zval_p))
|
|
|
|
|
2014-02-10 06:04:30 +00:00
|
|
|
#define Z_ISREF(zval) (Z_TYPE(zval) == IS_REFERENCE)
|
|
|
|
#define Z_ISREF_P(zval_p) Z_ISREF(*(zval_p))
|
|
|
|
|
2014-05-03 08:06:27 +00:00
|
|
|
#define Z_ISUNDEF(zval) (Z_TYPE(zval) == IS_UNDEF)
|
|
|
|
#define Z_ISUNDEF_P(zval_p) Z_ISUNDEF(*(zval_p))
|
|
|
|
|
|
|
|
#define Z_ISNULL(zval) (Z_TYPE(zval) == IS_NULL)
|
|
|
|
#define Z_ISNULL_P(zval_p) Z_ISNULL(*(zval_p))
|
|
|
|
|
2014-02-10 06:04:30 +00:00
|
|
|
#define Z_LVAL(zval) (zval).value.lval
|
|
|
|
#define Z_LVAL_P(zval_p) Z_LVAL(*(zval_p))
|
|
|
|
|
|
|
|
#define Z_DVAL(zval) (zval).value.dval
|
|
|
|
#define Z_DVAL_P(zval_p) Z_DVAL(*(zval_p))
|
|
|
|
|
|
|
|
#define Z_STR(zval) (zval).value.str
|
|
|
|
#define Z_STR_P(zval_p) Z_STR(*(zval_p))
|
|
|
|
|
2015-06-29 13:44:54 +00:00
|
|
|
#define Z_STRVAL(zval) ZSTR_VAL(Z_STR(zval))
|
2014-02-10 06:04:30 +00:00
|
|
|
#define Z_STRVAL_P(zval_p) Z_STRVAL(*(zval_p))
|
|
|
|
|
2015-06-29 13:44:54 +00:00
|
|
|
#define Z_STRLEN(zval) ZSTR_LEN(Z_STR(zval))
|
2014-02-10 06:04:30 +00:00
|
|
|
#define Z_STRLEN_P(zval_p) Z_STRLEN(*(zval_p))
|
|
|
|
|
2015-06-29 13:44:54 +00:00
|
|
|
#define Z_STRHASH(zval) ZSTR_HASH(Z_STR(zval))
|
2014-02-10 06:04:30 +00:00
|
|
|
#define Z_STRHASH_P(zval_p) Z_STRHASH(*(zval_p))
|
|
|
|
|
|
|
|
#define Z_ARR(zval) (zval).value.arr
|
|
|
|
#define Z_ARR_P(zval_p) Z_ARR(*(zval_p))
|
|
|
|
|
2015-02-13 19:20:39 +00:00
|
|
|
#define Z_ARRVAL(zval) Z_ARR(zval)
|
2014-02-10 06:04:30 +00:00
|
|
|
#define Z_ARRVAL_P(zval_p) Z_ARRVAL(*(zval_p))
|
|
|
|
|
|
|
|
#define Z_OBJ(zval) (zval).value.obj
|
|
|
|
#define Z_OBJ_P(zval_p) Z_OBJ(*(zval_p))
|
|
|
|
|
|
|
|
#define Z_OBJ_HT(zval) Z_OBJ(zval)->handlers
|
|
|
|
#define Z_OBJ_HT_P(zval_p) Z_OBJ_HT(*(zval_p))
|
|
|
|
|
|
|
|
#define Z_OBJ_HANDLER(zval, hf) Z_OBJ_HT((zval))->hf
|
|
|
|
#define Z_OBJ_HANDLER_P(zv_p, hf) Z_OBJ_HANDLER(*(zv_p), hf)
|
|
|
|
|
2014-02-11 11:30:42 +00:00
|
|
|
#define Z_OBJ_HANDLE(zval) (Z_OBJ((zval)))->handle
|
|
|
|
#define Z_OBJ_HANDLE_P(zval_p) Z_OBJ_HANDLE(*(zval_p))
|
|
|
|
|
2014-10-09 12:17:30 +00:00
|
|
|
#define Z_OBJCE(zval) (Z_OBJ(zval)->ce)
|
2014-02-10 06:04:30 +00:00
|
|
|
#define Z_OBJCE_P(zval_p) Z_OBJCE(*(zval_p))
|
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
#define Z_OBJPROP(zval) Z_OBJ_HT((zval))->get_properties(&(zval))
|
2014-02-10 06:04:30 +00:00
|
|
|
#define Z_OBJPROP_P(zval_p) Z_OBJPROP(*(zval_p))
|
|
|
|
|
2014-12-13 22:06:14 +00:00
|
|
|
#define Z_OBJDEBUG(zval,tmp) (Z_OBJ_HANDLER((zval),get_debug_info)?Z_OBJ_HANDLER((zval),get_debug_info)(&(zval),&tmp):(tmp=0,Z_OBJ_HANDLER((zval),get_properties)?Z_OBJPROP(zval):NULL))
|
2014-02-10 06:04:30 +00:00
|
|
|
#define Z_OBJDEBUG_P(zval_p,tmp) Z_OBJDEBUG(*(zval_p), tmp)
|
|
|
|
|
|
|
|
#define Z_RES(zval) (zval).value.res
|
|
|
|
#define Z_RES_P(zval_p) Z_RES(*zval_p)
|
|
|
|
|
|
|
|
#define Z_RES_HANDLE(zval) Z_RES(zval)->handle
|
|
|
|
#define Z_RES_HANDLE_P(zval_p) Z_RES_HANDLE(*zval_p)
|
|
|
|
|
|
|
|
#define Z_RES_TYPE(zval) Z_RES(zval)->type
|
|
|
|
#define Z_RES_TYPE_P(zval_p) Z_RES_TYPE(*zval_p)
|
|
|
|
|
|
|
|
#define Z_RES_VAL(zval) Z_RES(zval)->ptr
|
|
|
|
#define Z_RES_VAL_P(zval_p) Z_RES_VAL(*zval_p)
|
|
|
|
|
|
|
|
#define Z_REF(zval) (zval).value.ref
|
|
|
|
#define Z_REF_P(zval_p) Z_REF(*(zval_p))
|
|
|
|
|
|
|
|
#define Z_REFVAL(zval) &Z_REF(zval)->val
|
|
|
|
#define Z_REFVAL_P(zval_p) Z_REFVAL(*(zval_p))
|
|
|
|
|
|
|
|
#define Z_AST(zval) (zval).value.ast
|
|
|
|
#define Z_AST_P(zval_p) Z_AST(*(zval_p))
|
|
|
|
|
|
|
|
#define Z_ASTVAL(zval) (zval).value.ast->ast
|
|
|
|
#define Z_ASTVAL_P(zval_p) Z_ASTVAL(*(zval_p))
|
|
|
|
|
|
|
|
#define Z_INDIRECT(zval) (zval).value.zv
|
|
|
|
#define Z_INDIRECT_P(zval_p) Z_INDIRECT(*(zval_p))
|
|
|
|
|
|
|
|
#define Z_CE(zval) (zval).value.ce
|
|
|
|
#define Z_CE_P(zval_p) Z_CE(*(zval_p))
|
|
|
|
|
|
|
|
#define Z_FUNC(zval) (zval).value.func
|
|
|
|
#define Z_FUNC_P(zval_p) Z_FUNC(*(zval_p))
|
|
|
|
|
|
|
|
#define Z_PTR(zval) (zval).value.ptr
|
|
|
|
#define Z_PTR_P(zval_p) Z_PTR(*(zval_p))
|
|
|
|
|
2014-04-03 11:26:23 +00:00
|
|
|
#define ZVAL_UNDEF(z) do { \
|
|
|
|
Z_TYPE_INFO_P(z) = IS_UNDEF; \
|
2014-02-10 06:04:30 +00:00
|
|
|
} while (0)
|
|
|
|
|
2014-04-03 11:26:23 +00:00
|
|
|
#define ZVAL_NULL(z) do { \
|
|
|
|
Z_TYPE_INFO_P(z) = IS_NULL; \
|
2014-02-10 06:04:30 +00:00
|
|
|
} while (0)
|
|
|
|
|
2014-04-30 14:32:42 +00:00
|
|
|
#define ZVAL_FALSE(z) do { \
|
|
|
|
Z_TYPE_INFO_P(z) = IS_FALSE; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ZVAL_TRUE(z) do { \
|
|
|
|
Z_TYPE_INFO_P(z) = IS_TRUE; \
|
|
|
|
} while (0)
|
|
|
|
|
2014-04-03 11:26:23 +00:00
|
|
|
#define ZVAL_BOOL(z, b) do { \
|
2014-04-30 14:32:42 +00:00
|
|
|
Z_TYPE_INFO_P(z) = \
|
|
|
|
(b) ? IS_TRUE : IS_FALSE; \
|
2014-02-10 06:04:30 +00:00
|
|
|
} while (0)
|
|
|
|
|
2014-04-03 11:26:23 +00:00
|
|
|
#define ZVAL_LONG(z, l) { \
|
|
|
|
zval *__z = (z); \
|
|
|
|
Z_LVAL_P(__z) = l; \
|
|
|
|
Z_TYPE_INFO_P(__z) = IS_LONG; \
|
2014-02-10 06:04:30 +00:00
|
|
|
}
|
|
|
|
|
2014-04-03 11:26:23 +00:00
|
|
|
#define ZVAL_DOUBLE(z, d) { \
|
|
|
|
zval *__z = (z); \
|
|
|
|
Z_DVAL_P(__z) = d; \
|
|
|
|
Z_TYPE_INFO_P(__z) = IS_DOUBLE; \
|
2014-02-10 06:04:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define ZVAL_STR(z, s) do { \
|
|
|
|
zval *__z = (z); \
|
2014-04-03 11:26:23 +00:00
|
|
|
zend_string *__s = (s); \
|
|
|
|
Z_STR_P(__z) = __s; \
|
|
|
|
/* interned strings support */ \
|
2015-06-29 13:44:54 +00:00
|
|
|
Z_TYPE_INFO_P(__z) = ZSTR_IS_INTERNED(__s) ? \
|
2014-04-03 11:26:23 +00:00
|
|
|
IS_INTERNED_STRING_EX : \
|
|
|
|
IS_STRING_EX; \
|
|
|
|
} while (0)
|
|
|
|
|
2014-09-16 07:56:56 +00:00
|
|
|
#define ZVAL_INTERNED_STR(z, s) do { \
|
|
|
|
zval *__z = (z); \
|
|
|
|
zend_string *__s = (s); \
|
|
|
|
Z_STR_P(__z) = __s; \
|
2014-04-03 11:26:23 +00:00
|
|
|
Z_TYPE_INFO_P(__z) = IS_INTERNED_STRING_EX; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ZVAL_NEW_STR(z, s) do { \
|
|
|
|
zval *__z = (z); \
|
|
|
|
zend_string *__s = (s); \
|
|
|
|
Z_STR_P(__z) = __s; \
|
|
|
|
Z_TYPE_INFO_P(__z) = IS_STRING_EX; \
|
2014-02-10 06:04:30 +00:00
|
|
|
} while (0)
|
|
|
|
|
2014-09-19 13:32:50 +00:00
|
|
|
#define ZVAL_STR_COPY(z, s) do { \
|
|
|
|
zval *__z = (z); \
|
|
|
|
zend_string *__s = (s); \
|
|
|
|
Z_STR_P(__z) = __s; \
|
|
|
|
/* interned strings support */ \
|
2015-06-29 13:44:54 +00:00
|
|
|
if (ZSTR_IS_INTERNED(__s)) { \
|
2014-09-19 13:32:50 +00:00
|
|
|
Z_TYPE_INFO_P(__z) = IS_INTERNED_STRING_EX; \
|
|
|
|
} else { \
|
|
|
|
GC_REFCOUNT(__s)++; \
|
|
|
|
Z_TYPE_INFO_P(__z) = IS_STRING_EX; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2014-02-10 06:04:30 +00:00
|
|
|
#define ZVAL_ARR(z, a) do { \
|
|
|
|
zval *__z = (z); \
|
|
|
|
Z_ARR_P(__z) = (a); \
|
2014-04-03 11:26:23 +00:00
|
|
|
Z_TYPE_INFO_P(__z) = IS_ARRAY_EX; \
|
2014-02-10 06:04:30 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ZVAL_NEW_ARR(z) do { \
|
|
|
|
zval *__z = (z); \
|
2015-06-16 03:33:44 +00:00
|
|
|
zend_array *_arr = \
|
|
|
|
(zend_array *) emalloc(sizeof(zend_array)); \
|
2014-02-10 06:04:30 +00:00
|
|
|
Z_ARR_P(__z) = _arr; \
|
2014-04-03 11:26:23 +00:00
|
|
|
Z_TYPE_INFO_P(__z) = IS_ARRAY_EX; \
|
2014-02-10 06:04:30 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ZVAL_NEW_PERSISTENT_ARR(z) do { \
|
|
|
|
zval *__z = (z); \
|
2015-06-16 03:33:44 +00:00
|
|
|
zend_array *_arr = \
|
|
|
|
(zend_array *) malloc(sizeof(zend_array)); \
|
2014-02-10 06:04:30 +00:00
|
|
|
Z_ARR_P(__z) = _arr; \
|
2014-04-03 11:26:23 +00:00
|
|
|
Z_TYPE_INFO_P(__z) = IS_ARRAY_EX; \
|
2014-02-10 06:04:30 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ZVAL_OBJ(z, o) do { \
|
|
|
|
zval *__z = (z); \
|
|
|
|
Z_OBJ_P(__z) = (o); \
|
2014-04-03 11:26:23 +00:00
|
|
|
Z_TYPE_INFO_P(__z) = IS_OBJECT_EX; \
|
2014-02-10 06:04:30 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ZVAL_RES(z, r) do { \
|
|
|
|
zval *__z = (z); \
|
|
|
|
Z_RES_P(__z) = (r); \
|
2014-04-03 11:26:23 +00:00
|
|
|
Z_TYPE_INFO_P(__z) = IS_RESOURCE_EX; \
|
2014-02-10 06:04:30 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ZVAL_NEW_RES(z, h, p, t) do { \
|
2015-06-16 03:33:44 +00:00
|
|
|
zend_resource *_res = \
|
|
|
|
(zend_resource *) emalloc(sizeof(zend_resource)); \
|
2014-09-16 07:56:56 +00:00
|
|
|
zval *__z; \
|
2014-04-02 10:34:44 +00:00
|
|
|
GC_REFCOUNT(_res) = 1; \
|
|
|
|
GC_TYPE_INFO(_res) = IS_RESOURCE; \
|
2014-02-10 06:04:30 +00:00
|
|
|
_res->handle = (h); \
|
|
|
|
_res->type = (t); \
|
|
|
|
_res->ptr = (p); \
|
2014-09-16 07:56:56 +00:00
|
|
|
__z = (z); \
|
2014-02-10 06:04:30 +00:00
|
|
|
Z_RES_P(__z) = _res; \
|
2014-04-03 11:26:23 +00:00
|
|
|
Z_TYPE_INFO_P(__z) = IS_RESOURCE_EX; \
|
2014-02-10 06:04:30 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ZVAL_NEW_PERSISTENT_RES(z, h, p, t) do { \
|
2015-06-16 03:33:44 +00:00
|
|
|
zend_resource *_res = \
|
|
|
|
(zend_resource *) malloc(sizeof(zend_resource)); \
|
2014-09-16 07:56:56 +00:00
|
|
|
zval *__z; \
|
2014-04-02 10:34:44 +00:00
|
|
|
GC_REFCOUNT(_res) = 1; \
|
|
|
|
GC_TYPE_INFO(_res) = IS_RESOURCE; \
|
2014-02-10 06:04:30 +00:00
|
|
|
_res->handle = (h); \
|
|
|
|
_res->type = (t); \
|
|
|
|
_res->ptr = (p); \
|
2014-09-16 07:56:56 +00:00
|
|
|
__z = (z); \
|
2014-02-10 06:04:30 +00:00
|
|
|
Z_RES_P(__z) = _res; \
|
2014-04-03 11:26:23 +00:00
|
|
|
Z_TYPE_INFO_P(__z) = IS_RESOURCE_EX; \
|
2014-02-10 06:04:30 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ZVAL_REF(z, r) do { \
|
|
|
|
zval *__z = (z); \
|
|
|
|
Z_REF_P(__z) = (r); \
|
2014-04-03 11:26:23 +00:00
|
|
|
Z_TYPE_INFO_P(__z) = IS_REFERENCE_EX; \
|
2014-02-10 06:04:30 +00:00
|
|
|
} while (0)
|
2015-04-03 13:35:06 +00:00
|
|
|
|
|
|
|
#define ZVAL_NEW_EMPTY_REF(z) do { \
|
2015-06-16 03:33:44 +00:00
|
|
|
zend_reference *_ref = \
|
|
|
|
(zend_reference *) emalloc(sizeof(zend_reference)); \
|
2015-04-03 13:35:06 +00:00
|
|
|
GC_REFCOUNT(_ref) = 1; \
|
|
|
|
GC_TYPE_INFO(_ref) = IS_REFERENCE; \
|
|
|
|
Z_REF_P(z) = _ref; \
|
|
|
|
Z_TYPE_INFO_P(z) = IS_REFERENCE_EX; \
|
|
|
|
} while (0)
|
2014-02-10 06:04:30 +00:00
|
|
|
|
|
|
|
#define ZVAL_NEW_REF(z, r) do { \
|
2015-06-16 03:33:44 +00:00
|
|
|
zend_reference *_ref = \
|
|
|
|
(zend_reference *) emalloc(sizeof(zend_reference)); \
|
2014-04-02 10:34:44 +00:00
|
|
|
GC_REFCOUNT(_ref) = 1; \
|
|
|
|
GC_TYPE_INFO(_ref) = IS_REFERENCE; \
|
2014-03-28 19:34:49 +00:00
|
|
|
ZVAL_COPY_VALUE(&_ref->val, r); \
|
2014-02-10 06:04:30 +00:00
|
|
|
Z_REF_P(z) = _ref; \
|
2014-04-03 11:26:23 +00:00
|
|
|
Z_TYPE_INFO_P(z) = IS_REFERENCE_EX; \
|
2014-02-10 06:04:30 +00:00
|
|
|
} while (0)
|
|
|
|
|
2014-04-14 09:24:43 +00:00
|
|
|
#define ZVAL_NEW_PERSISTENT_REF(z, r) do { \
|
2015-06-16 03:33:44 +00:00
|
|
|
zend_reference *_ref = \
|
|
|
|
(zend_reference *) malloc(sizeof(zend_reference)); \
|
2014-04-14 09:24:43 +00:00
|
|
|
GC_REFCOUNT(_ref) = 1; \
|
|
|
|
GC_TYPE_INFO(_ref) = IS_REFERENCE; \
|
|
|
|
ZVAL_COPY_VALUE(&_ref->val, r); \
|
|
|
|
Z_REF_P(z) = _ref; \
|
|
|
|
Z_TYPE_INFO_P(z) = IS_REFERENCE_EX; \
|
|
|
|
} while (0)
|
|
|
|
|
2014-02-10 06:04:30 +00:00
|
|
|
#define ZVAL_NEW_AST(z, a) do { \
|
|
|
|
zval *__z = (z); \
|
2015-06-16 03:33:44 +00:00
|
|
|
zend_ast_ref *_ast = \
|
|
|
|
(zend_ast_ref *) emalloc(sizeof(zend_ast_ref)); \
|
2014-04-02 10:34:44 +00:00
|
|
|
GC_REFCOUNT(_ast) = 1; \
|
|
|
|
GC_TYPE_INFO(_ast) = IS_CONSTANT_AST; \
|
2014-02-10 06:04:30 +00:00
|
|
|
_ast->ast = (a); \
|
|
|
|
Z_AST_P(__z) = _ast; \
|
2014-04-03 11:26:23 +00:00
|
|
|
Z_TYPE_INFO_P(__z) = IS_CONSTANT_AST_EX; \
|
2014-02-10 06:04:30 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ZVAL_INDIRECT(z, v) do { \
|
|
|
|
Z_INDIRECT_P(z) = (v); \
|
2014-04-03 11:26:23 +00:00
|
|
|
Z_TYPE_INFO_P(z) = IS_INDIRECT; \
|
2014-02-10 06:04:30 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ZVAL_PTR(z, p) do { \
|
|
|
|
Z_PTR_P(z) = (p); \
|
2014-04-03 11:26:23 +00:00
|
|
|
Z_TYPE_INFO_P(z) = IS_PTR; \
|
2014-02-10 06:04:30 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ZVAL_FUNC(z, f) do { \
|
|
|
|
Z_FUNC_P(z) = (f); \
|
2014-04-03 11:26:23 +00:00
|
|
|
Z_TYPE_INFO_P(z) = IS_PTR; \
|
2014-02-10 06:04:30 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ZVAL_CE(z, c) do { \
|
|
|
|
Z_CE_P(z) = (c); \
|
2014-04-03 11:26:23 +00:00
|
|
|
Z_TYPE_INFO_P(z) = IS_PTR; \
|
2014-02-10 06:04:30 +00:00
|
|
|
} while (0)
|
|
|
|
|
2014-09-18 00:58:04 +00:00
|
|
|
#define Z_REFCOUNT_P(pz) zval_refcount_p(pz)
|
|
|
|
#define Z_SET_REFCOUNT_P(pz, rc) zval_set_refcount_p(pz, rc)
|
|
|
|
#define Z_ADDREF_P(pz) zval_addref_p(pz)
|
|
|
|
#define Z_DELREF_P(pz) zval_delref_p(pz)
|
|
|
|
|
|
|
|
#define Z_REFCOUNT(z) Z_REFCOUNT_P(&(z))
|
|
|
|
#define Z_SET_REFCOUNT(z, rc) Z_SET_REFCOUNT_P(&(z), rc)
|
|
|
|
#define Z_ADDREF(z) Z_ADDREF_P(&(z))
|
|
|
|
#define Z_DELREF(z) Z_DELREF_P(&(z))
|
|
|
|
|
|
|
|
#define Z_TRY_ADDREF_P(pz) do { \
|
|
|
|
if (Z_REFCOUNTED_P((pz))) { \
|
|
|
|
Z_ADDREF_P((pz)); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define Z_TRY_DELREF_P(pz) do { \
|
|
|
|
if (Z_REFCOUNTED_P((pz))) { \
|
|
|
|
Z_DELREF_P((pz)); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define Z_TRY_ADDREF(z) Z_TRY_ADDREF_P(&(z))
|
|
|
|
#define Z_TRY_DELREF(z) Z_TRY_DELREF_P(&(z))
|
|
|
|
|
|
|
|
static zend_always_inline uint32_t zval_refcount_p(zval* pz) {
|
2015-12-16 04:11:55 +00:00
|
|
|
ZEND_ASSERT(Z_REFCOUNTED_P(pz) || Z_IMMUTABLE_P(pz));
|
2014-09-18 00:58:04 +00:00
|
|
|
return GC_REFCOUNT(Z_COUNTED_P(pz));
|
|
|
|
}
|
|
|
|
|
|
|
|
static zend_always_inline uint32_t zval_set_refcount_p(zval* pz, uint32_t rc) {
|
|
|
|
ZEND_ASSERT(Z_REFCOUNTED_P(pz));
|
|
|
|
return GC_REFCOUNT(Z_COUNTED_P(pz)) = rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static zend_always_inline uint32_t zval_addref_p(zval* pz) {
|
|
|
|
ZEND_ASSERT(Z_REFCOUNTED_P(pz));
|
|
|
|
return ++GC_REFCOUNT(Z_COUNTED_P(pz));
|
|
|
|
}
|
|
|
|
|
|
|
|
static zend_always_inline uint32_t zval_delref_p(zval* pz) {
|
|
|
|
ZEND_ASSERT(Z_REFCOUNTED_P(pz));
|
|
|
|
return --GC_REFCOUNT(Z_COUNTED_P(pz));
|
|
|
|
}
|
|
|
|
|
2015-05-23 19:15:11 +00:00
|
|
|
#if SIZEOF_SIZE_T == 4
|
2015-08-10 14:58:58 +00:00
|
|
|
# define ZVAL_COPY_VALUE_EX(z, v, gc, t) \
|
2014-12-09 15:07:39 +00:00
|
|
|
do { \
|
2015-05-13 09:55:42 +00:00
|
|
|
uint32_t _w2 = v->value.ww.w2; \
|
|
|
|
Z_COUNTED_P(z) = gc; \
|
2014-12-09 15:07:39 +00:00
|
|
|
z->value.ww.w2 = _w2; \
|
|
|
|
Z_TYPE_INFO_P(z) = t; \
|
|
|
|
} while (0)
|
2015-05-23 19:15:11 +00:00
|
|
|
#elif SIZEOF_SIZE_T == 8
|
2014-12-09 15:07:39 +00:00
|
|
|
# define ZVAL_COPY_VALUE_EX(z, v, gc, t) \
|
|
|
|
do { \
|
2015-05-13 09:55:42 +00:00
|
|
|
Z_COUNTED_P(z) = gc; \
|
2014-12-09 15:07:39 +00:00
|
|
|
Z_TYPE_INFO_P(z) = t; \
|
|
|
|
} while (0)
|
|
|
|
#else
|
2015-05-23 19:15:11 +00:00
|
|
|
# error "Unknown SIZEOF_SIZE_T"
|
2014-12-09 15:07:39 +00:00
|
|
|
#endif
|
|
|
|
|
2014-09-18 00:58:04 +00:00
|
|
|
#define ZVAL_COPY_VALUE(z, v) \
|
|
|
|
do { \
|
|
|
|
zval *_z1 = (z); \
|
2014-12-05 04:10:31 +00:00
|
|
|
const zval *_z2 = (v); \
|
2015-05-13 09:55:42 +00:00
|
|
|
zend_refcounted *_gc = Z_COUNTED_P(_z2); \
|
|
|
|
uint32_t _t = Z_TYPE_INFO_P(_z2); \
|
2014-12-09 15:07:39 +00:00
|
|
|
ZVAL_COPY_VALUE_EX(_z1, _z2, _gc, _t); \
|
2014-09-18 00:58:04 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ZVAL_COPY(z, v) \
|
|
|
|
do { \
|
2014-12-09 15:07:39 +00:00
|
|
|
zval *_z1 = (z); \
|
|
|
|
const zval *_z2 = (v); \
|
2015-05-13 09:55:42 +00:00
|
|
|
zend_refcounted *_gc = Z_COUNTED_P(_z2); \
|
|
|
|
uint32_t _t = Z_TYPE_INFO_P(_z2); \
|
2014-12-09 15:07:39 +00:00
|
|
|
ZVAL_COPY_VALUE_EX(_z1, _z2, _gc, _t); \
|
|
|
|
if ((_t & (IS_TYPE_REFCOUNTED << Z_TYPE_FLAGS_SHIFT)) != 0) { \
|
|
|
|
GC_REFCOUNT(_gc)++; \
|
2014-09-18 00:58:04 +00:00
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ZVAL_DUP(z, v) \
|
|
|
|
do { \
|
2014-12-09 15:07:39 +00:00
|
|
|
zval *_z1 = (z); \
|
|
|
|
const zval *_z2 = (v); \
|
2015-05-13 09:55:42 +00:00
|
|
|
zend_refcounted *_gc = Z_COUNTED_P(_z2); \
|
|
|
|
uint32_t _t = Z_TYPE_INFO_P(_z2); \
|
2014-12-09 15:07:39 +00:00
|
|
|
ZVAL_COPY_VALUE_EX(_z1, _z2, _gc, _t); \
|
|
|
|
if ((_t & ((IS_TYPE_REFCOUNTED|IS_TYPE_IMMUTABLE) << Z_TYPE_FLAGS_SHIFT)) != 0) { \
|
|
|
|
if ((_t & ((IS_TYPE_COPYABLE|IS_TYPE_IMMUTABLE) << Z_TYPE_FLAGS_SHIFT)) != 0) { \
|
|
|
|
_zval_copy_ctor_func(_z1 ZEND_FILE_LINE_CC); \
|
|
|
|
} else { \
|
|
|
|
GC_REFCOUNT(_gc)++; \
|
|
|
|
} \
|
|
|
|
} \
|
2014-09-18 00:58:04 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ZVAL_DEREF(z) do { \
|
|
|
|
if (UNEXPECTED(Z_ISREF_P(z))) { \
|
|
|
|
(z) = Z_REFVAL_P(z); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2015-07-10 08:39:21 +00:00
|
|
|
#define ZVAL_OPT_DEREF(z) do { \
|
|
|
|
if (UNEXPECTED(Z_OPT_ISREF_P(z))) { \
|
|
|
|
(z) = Z_REFVAL_P(z); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2014-09-18 00:58:04 +00:00
|
|
|
#define ZVAL_MAKE_REF(zv) do { \
|
|
|
|
zval *__zv = (zv); \
|
|
|
|
if (!Z_ISREF_P(__zv)) { \
|
|
|
|
ZVAL_NEW_REF(__zv, __zv); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define ZVAL_UNREF(z) do { \
|
|
|
|
zval *_z = (z); \
|
|
|
|
zend_reference *ref; \
|
|
|
|
ZEND_ASSERT(Z_ISREF_P(_z)); \
|
|
|
|
ref = Z_REF_P(_z); \
|
|
|
|
ZVAL_COPY_VALUE(_z, &ref->val); \
|
|
|
|
efree_size(ref, sizeof(zend_reference)); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define SEPARATE_STRING(zv) do { \
|
|
|
|
zval *_zv = (zv); \
|
|
|
|
if (Z_REFCOUNTED_P(_zv) && \
|
|
|
|
Z_REFCOUNT_P(_zv) > 1) { \
|
|
|
|
Z_DELREF_P(_zv); \
|
|
|
|
zval_copy_ctor_func(_zv); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define SEPARATE_ARRAY(zv) do { \
|
|
|
|
zval *_zv = (zv); \
|
2015-06-02 09:03:34 +00:00
|
|
|
zend_array *_arr = Z_ARR_P(_zv); \
|
|
|
|
if (GC_REFCOUNT(_arr) > 1) { \
|
2014-09-18 00:58:04 +00:00
|
|
|
if (!Z_IMMUTABLE_P(_zv)) { \
|
2015-06-02 09:03:34 +00:00
|
|
|
GC_REFCOUNT(_arr)--; \
|
2014-09-18 00:58:04 +00:00
|
|
|
} \
|
2015-06-02 09:03:34 +00:00
|
|
|
ZVAL_ARR(_zv, zend_array_dup(_arr)); \
|
2014-09-18 00:58:04 +00:00
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define SEPARATE_ZVAL_NOREF(zv) do { \
|
|
|
|
zval *_zv = (zv); \
|
2014-10-09 10:51:05 +00:00
|
|
|
ZEND_ASSERT(Z_TYPE_P(_zv) != IS_REFERENCE); \
|
2014-09-18 00:58:04 +00:00
|
|
|
if (Z_COPYABLE_P(_zv) || \
|
|
|
|
Z_IMMUTABLE_P(_zv)) { \
|
|
|
|
if (Z_REFCOUNT_P(_zv) > 1) { \
|
|
|
|
if (!Z_IMMUTABLE_P(_zv)) { \
|
|
|
|
Z_DELREF_P(_zv); \
|
|
|
|
} \
|
|
|
|
zval_copy_ctor_func(_zv); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define SEPARATE_ZVAL(zv) do { \
|
|
|
|
zval *_zv = (zv); \
|
|
|
|
if (Z_REFCOUNTED_P(_zv) || \
|
|
|
|
Z_IMMUTABLE_P(_zv)) { \
|
|
|
|
if (Z_REFCOUNT_P(_zv) > 1) { \
|
|
|
|
if (Z_COPYABLE_P(_zv) || \
|
|
|
|
Z_IMMUTABLE_P(_zv)) { \
|
|
|
|
if (!Z_IMMUTABLE_P(_zv)) { \
|
|
|
|
Z_DELREF_P(_zv); \
|
|
|
|
} \
|
|
|
|
zval_copy_ctor_func(_zv); \
|
|
|
|
} else if (Z_ISREF_P(_zv)) { \
|
|
|
|
Z_DELREF_P(_zv); \
|
|
|
|
ZVAL_DUP(_zv, Z_REFVAL_P(_zv)); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define SEPARATE_ZVAL_IF_NOT_REF(zv) do { \
|
|
|
|
zval *_zv = (zv); \
|
|
|
|
if (Z_COPYABLE_P(_zv) || \
|
|
|
|
Z_IMMUTABLE_P(_zv)) { \
|
|
|
|
if (Z_REFCOUNT_P(_zv) > 1) { \
|
|
|
|
if (!Z_IMMUTABLE_P(_zv)) { \
|
|
|
|
Z_DELREF_P(_zv); \
|
|
|
|
} \
|
|
|
|
zval_copy_ctor_func(_zv); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define SEPARATE_ARG_IF_REF(varptr) do { \
|
|
|
|
ZVAL_DEREF(varptr); \
|
|
|
|
if (Z_REFCOUNTED_P(varptr)) { \
|
|
|
|
Z_ADDREF_P(varptr); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2002-06-24 07:11:12 +00:00
|
|
|
#endif /* ZEND_TYPES_H */
|
2003-02-01 01:49:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
|
|
|
*/
|