Skip to content

Commit aad1829

Browse files
committed
Zend/zend_types.h: move IS_* to zend_type_code.h
More decoupling of circular header dependencies.
1 parent e9706c9 commit aad1829

File tree

6 files changed

+63
-39
lines changed

6 files changed

+63
-39
lines changed

Zend/zend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "zend_smart_str_public.h"
4040
#include "zend_smart_string_public.h"
4141
#include "zend_signal.h"
42+
#include "zend_type_code.h"
4243

4344
#define zend_sprintf sprintf
4445

Zend/zend_API.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "zend_variables.h"
2929
#include "zend_execute.h"
3030
#include "zend_type_info.h"
31-
31+
#include "zend_type_code.h"
3232

3333
BEGIN_EXTERN_C()
3434

Zend/zend_execute.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "zend_compile.h"
2525
#include "zend_hash.h"
2626
#include "zend_operators.h"
27+
#include "zend_type_code.h"
2728
#include "zend_variables.h"
2829

2930
#include <stdint.h>

Zend/zend_hash.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "zend.h"
2525
#include "zend_sort.h"
26+
#include "zend_type_code.h"
2627

2728
#define HASH_KEY_IS_STRING 1
2829
#define HASH_KEY_IS_LONG 2

Zend/zend_type_code.h

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| Zend Engine |
4+
+----------------------------------------------------------------------+
5+
| Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
6+
+----------------------------------------------------------------------+
7+
| This source file is subject to version 2.00 of the Zend license, |
8+
| that is bundled with this package in the file LICENSE, and is |
9+
| available through the world-wide-web at the following url: |
10+
| http://www.zend.com/license/2_00.txt. |
11+
| If you did not receive a copy of the Zend license and are unable to |
12+
| obtain it through the world-wide-web, please send a note to |
13+
| license@zend.com so we can mail you a copy immediately. |
14+
+----------------------------------------------------------------------+
15+
*/
16+
17+
#ifndef ZEND_TYPE_CODE_H
18+
#define ZEND_TYPE_CODE_H
19+
20+
/* Regular data types: Must be in sync with zend_variables.c. */
21+
#define IS_UNDEF 0
22+
#define IS_NULL 1
23+
#define IS_FALSE 2
24+
#define IS_TRUE 3
25+
#define IS_LONG 4
26+
#define IS_DOUBLE 5
27+
#define IS_STRING 6
28+
#define IS_ARRAY 7
29+
#define IS_OBJECT 8
30+
#define IS_RESOURCE 9
31+
#define IS_REFERENCE 10
32+
#define IS_CONSTANT_AST 11 /* Constant expressions */
33+
34+
/* Fake types used only for type hinting.
35+
* These are allowed to overlap with the types below. */
36+
#define IS_CALLABLE 12
37+
#define IS_ITERABLE 13
38+
#define IS_VOID 14
39+
#define IS_STATIC 15
40+
#define IS_MIXED 16
41+
#define IS_NEVER 17
42+
43+
/* internal types */
44+
#define IS_INDIRECT 12
45+
#define IS_PTR 13
46+
#define IS_ALIAS_PTR 14
47+
#define _IS_ERROR 15
48+
49+
/* used for casts */
50+
#define _IS_BOOL 18
51+
#define _IS_NUMBER 19
52+
53+
#define ZEND_SAME_FAKE_TYPE(faketype, realtype) ( \
54+
(faketype) == (realtype) \
55+
|| ((faketype) == _IS_BOOL && ((realtype) == IS_TRUE || (realtype) == IS_FALSE)) \
56+
)
57+
58+
#endif /* ZEND_TYPE_CODE_H */

Zend/zend_types.h

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "zend_long.h"
2727
#include "zend_rc_debug.h"
2828
#include "zend_result.h"
29+
#include "zend_type_code.h"
2930

3031
#include <stdbool.h>
3132
#include <stdint.h>
@@ -538,48 +539,10 @@ struct _zend_ast_ref {
538539
/*zend_ast ast; zend_ast follows the zend_ast_ref structure */
539540
};
540541

541-
/* Regular data types: Must be in sync with zend_variables.c. */
542-
#define IS_UNDEF 0
543-
#define IS_NULL 1
544-
#define IS_FALSE 2
545-
#define IS_TRUE 3
546-
#define IS_LONG 4
547-
#define IS_DOUBLE 5
548-
#define IS_STRING 6
549-
#define IS_ARRAY 7
550-
#define IS_OBJECT 8
551-
#define IS_RESOURCE 9
552-
#define IS_REFERENCE 10
553-
#define IS_CONSTANT_AST 11 /* Constant expressions */
554-
555-
/* Fake types used only for type hinting.
556-
* These are allowed to overlap with the types below. */
557-
#define IS_CALLABLE 12
558-
#define IS_ITERABLE 13
559-
#define IS_VOID 14
560-
#define IS_STATIC 15
561-
#define IS_MIXED 16
562-
#define IS_NEVER 17
563-
564-
/* internal types */
565-
#define IS_INDIRECT 12
566-
#define IS_PTR 13
567-
#define IS_ALIAS_PTR 14
568-
#define _IS_ERROR 15
569-
570-
/* used for casts */
571-
#define _IS_BOOL 18
572-
#define _IS_NUMBER 19
573-
574542
static zend_always_inline uint8_t zval_get_type(const zval* pz) {
575543
return pz->u1.v.type;
576544
}
577545

578-
#define ZEND_SAME_FAKE_TYPE(faketype, realtype) ( \
579-
(faketype) == (realtype) \
580-
|| ((faketype) == _IS_BOOL && ((realtype) == IS_TRUE || (realtype) == IS_FALSE)) \
581-
)
582-
583546
/* we should never set just Z_TYPE, we should set Z_TYPE_INFO */
584547
#define Z_TYPE(zval) zval_get_type(&(zval))
585548
#define Z_TYPE_P(zval_p) Z_TYPE(*(zval_p))

0 commit comments

Comments
 (0)