-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathphp_jsond_compat.h
65 lines (57 loc) · 2.56 KB
/
php_jsond_compat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP 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.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Jakub Zelenka <bukka@php.net> |
+----------------------------------------------------------------------+
*/
/* The compatibility changes to support at least PHP 7.2 */
#ifndef PHP_JSOND_COMPAT_H
#define PHP_JSOND_COMPAT_H
/* Recursion protection changes */
#if PHP_VERSION_ID < 70300
#define PHP_JSON_HAS_APPLY_COUNT(_tht) (ZEND_HASH_GET_APPLY_COUNT(_tht) > 0)
#define PHP_JSON_GET_APPLY_COUNT ZEND_HASH_GET_APPLY_COUNT
#define PHP_JSON_INC_APPLY_COUNT ZEND_HASH_INC_APPLY_COUNT
#define PHP_JSON_DEC_APPLY_COUNT ZEND_HASH_DEC_APPLY_COUNT
#define PHP_JSON_APPLY_PROTECTION ZEND_HASH_APPLY_PROTECTION
#else
#define PHP_JSON_HAS_APPLY_COUNT GC_IS_RECURSIVE
#define PHP_JSON_GET_APPLY_COUNT GC_IS_RECURSIVE
#define PHP_JSON_INC_APPLY_COUNT GC_PROTECT_RECURSION
#define PHP_JSON_DEC_APPLY_COUNT GC_UNPROTECT_RECURSION
#define PHP_JSON_APPLY_PROTECTION(_tht) (!(GC_FLAGS(_tht) & GC_IMMUTABLE))
#endif
/* zend_string_release_ex introduction */
#if PHP_VERSION_ID < 70300
#define PHP_JSOND_RELEASE_STRING zend_string_release
#else
#define PHP_JSOND_RELEASE_STRING(_str) zend_string_release_ex(_str, 0)
#endif
/* zend_std_write_property changes */
#if PHP_VERSION_ID < 80000
#define PHP_JSOND_WRITE_PROPERTY(_object, _key, _value) \
do { \
zval _zkey; \
ZVAL_NEW_STR(&_zkey, _key); \
zend_std_write_property(_object, &_zkey, _value, NULL); \
} while(0)
#else
#define PHP_JSOND_WRITE_PROPERTY(_object, _key, _value) \
zend_std_write_property(Z_OBJ_P(_object), _key, _value, NULL)
#endif
/* zend_dtoa sign type */
#if PHP_VERSION_ID < 80100
typedef int php_jsond_dtoa_sign_t;
#else
typedef bool php_jsond_dtoa_sign_t;
#endif
#endif /* PHP_JSOND_COMPAT_H */