EvalEmitDVArray: varray
[hiphop-php.git] / hphp / runtime / base / php-globals.h
blob4d27325ed4b6913475a41df4b522bfeeffa3f694
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2013 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 +----------------------------------------------------------------------+
16 #ifndef incl_HPHP_PHP_GLOBALS_H_
17 #define incl_HPHP_PHP_GLOBALS_H_
19 namespace HPHP {
21 //////////////////////////////////////////////////////////////////////
23 struct StaticString;
24 struct Variant;
25 struct TypedValue;
26 struct Array;
28 //////////////////////////////////////////////////////////////////////
31 * Set a $GLOBALS[foo] to the supplied value, using normal php set
32 * semantics.
34 void php_global_set(const StaticString&, Variant);
37 * Exchange a value in $GLOBALS.
39 * This sets $GLOBALS[key] to newV, and returns its previous value.
40 * This is sometimes particularly useful if you want to temporarily
41 * take an Array out of $GLOBALS so it can be modified with its
42 * reference count as one, and then stored back in.
44 * For example:
46 * auto arr = php_global_exchange(s_MyKey, uninit_null());
47 * arr.set(123, "foo");
48 * php_global_set(s_MyKey, std::move(arr));
50 Variant php_global_exchange(const StaticString& key, Variant newV);
53 * Read a variable from $GLOBALS, returning a temporary for read-only
54 * access.
56 * Returns a KindOfNull if the global didn't exist, without changing
57 * $GLOBALS.
59 Variant php_global(const StaticString&);
61 //////////////////////////////////////////////////////////////////////
65 #include "hphp/runtime/base/php-globals-inl.h"
67 #endif