2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP 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.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_PHP7_UTIL_H
18 #define incl_HPHP_PHP7_UTIL_H
20 #include "hphp/php7/zend/zend.h"
22 namespace HPHP
{ namespace php7
{
24 // helpers to cope with these functions taking non-const pointers
27 inline const zval
* zend_ast_get_zval(const zend_ast
* ast
) {
28 return &reinterpret_cast<const zend_ast_zval
*>(ast
)->val
;
31 inline const zend_ast_list
* zend_ast_get_list(const zend_ast
* ast
) {
32 return reinterpret_cast<const zend_ast_list
*>(ast
);
35 inline const zend_ast_decl
* zend_ast_get_decl(const zend_ast
* ast
) {
36 return reinterpret_cast<const zend_ast_decl
*>(ast
);
39 inline std::string
zval_to_string(const zval
* zv
) {
41 switch (Z_TYPE_P(zv
)) {
43 out
.append(folly::to
<std::string
>(Z_LVAL_P(zv
)));
52 out
.append(folly::to
<std::string
>(Z_DVAL_P(zv
)));
55 out
.append(Z_STRVAL_P(zv
));
63 #endif // incl_HPHP_PHP7_UTIL_H