Zend/zend_types.h: move IS_* to zend_type_code.h

More decoupling of circular header dependencies.
This commit is contained in:
Max Kellermann 2023-02-21 20:33:32 +01:00 committed by George Peter Banyard
parent e509a66a9c
commit 0270a1e54c
6 changed files with 63 additions and 39 deletions

View File

@ -39,6 +39,7 @@
#include "zend_smart_str_public.h"
#include "zend_smart_string_public.h"
#include "zend_signal.h"
#include "zend_type_code.h"
#define zend_sprintf sprintf

View File

@ -28,7 +28,7 @@
#include "zend_variables.h"
#include "zend_execute.h"
#include "zend_type_info.h"
#include "zend_type_code.h"
BEGIN_EXTERN_C()

View File

@ -24,6 +24,7 @@
#include "zend_compile.h"
#include "zend_hash.h"
#include "zend_operators.h"
#include "zend_type_code.h"
#include "zend_variables.h"
#include <stdint.h>

View File

@ -23,6 +23,7 @@
#include "zend.h"
#include "zend_sort.h"
#include "zend_type_code.h"
#define HASH_KEY_IS_STRING 1
#define HASH_KEY_IS_LONG 2

58
Zend/zend_type_code.h Normal file
View File

@ -0,0 +1,58 @@
/*
+----------------------------------------------------------------------+
| Zend Engine |
+----------------------------------------------------------------------+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| 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 |
| available through the world-wide-web at the following url: |
| 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. |
+----------------------------------------------------------------------+
*/
#ifndef ZEND_TYPE_CODE_H
#define ZEND_TYPE_CODE_H
/* Regular data types: Must be in sync with zend_variables.c. */
#define IS_UNDEF 0
#define IS_NULL 1
#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
#define IS_REFERENCE 10
#define IS_CONSTANT_AST 11 /* Constant expressions */
/* Fake types used only for type hinting.
* These are allowed to overlap with the types below. */
#define IS_CALLABLE 12
#define IS_ITERABLE 13
#define IS_VOID 14
#define IS_STATIC 15
#define IS_MIXED 16
#define IS_NEVER 17
/* internal types */
#define IS_INDIRECT 12
#define IS_PTR 13
#define IS_ALIAS_PTR 14
#define _IS_ERROR 15
/* used for casts */
#define _IS_BOOL 18
#define _IS_NUMBER 19
#define ZEND_SAME_FAKE_TYPE(faketype, realtype) ( \
(faketype) == (realtype) \
|| ((faketype) == _IS_BOOL && ((realtype) == IS_TRUE || (realtype) == IS_FALSE)) \
)
#endif /* ZEND_TYPE_CODE_H */

View File

@ -26,6 +26,7 @@
#include "zend_long.h"
#include "zend_rc_debug.h"
#include "zend_result.h"
#include "zend_type_code.h"
#include <stdbool.h>
#include <stdint.h>
@ -538,48 +539,10 @@ struct _zend_ast_ref {
/*zend_ast ast; zend_ast follows the zend_ast_ref structure */
};
/* Regular data types: Must be in sync with zend_variables.c. */
#define IS_UNDEF 0
#define IS_NULL 1
#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
#define IS_REFERENCE 10
#define IS_CONSTANT_AST 11 /* Constant expressions */
/* Fake types used only for type hinting.
* These are allowed to overlap with the types below. */
#define IS_CALLABLE 12
#define IS_ITERABLE 13
#define IS_VOID 14
#define IS_STATIC 15
#define IS_MIXED 16
#define IS_NEVER 17
/* internal types */
#define IS_INDIRECT 12
#define IS_PTR 13
#define IS_ALIAS_PTR 14
#define _IS_ERROR 15
/* used for casts */
#define _IS_BOOL 18
#define _IS_NUMBER 19
static zend_always_inline uint8_t zval_get_type(const zval* pz) {
return pz->u1.v.type;
}
#define ZEND_SAME_FAKE_TYPE(faketype, realtype) ( \
(faketype) == (realtype) \
|| ((faketype) == _IS_BOOL && ((realtype) == IS_TRUE || (realtype) == IS_FALSE)) \
)
/* we should never set just Z_TYPE, we should set Z_TYPE_INFO */
#define Z_TYPE(zval) zval_get_type(&(zval))
#define Z_TYPE_P(zval_p) Z_TYPE(*(zval_p))