blob: 7eea8e790c25028aff00c6a4dfa85b9e8771cd0d (
plain)
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
|
/**
* Global.cpp
*
* Implementation for the global variable
*
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* @copyright 2013 Copernica BV
*/
#include "includes.h"
/**
* Namespace
*/
namespace Php {
/**
* Function that is called when the value is updated
* @return Value
*/
Global &Global::update()
{
// skip if the variable already exists
if (_exists) return *this;
// we need the TSRMLS variable
TSRMLS_FETCH();
// add the variable to the globals
zend_hash_add(EG(active_symbol_table), _name.c_str(), _name.size()+1, &_val, sizeof(zval*), NULL);
// add one extra reference because the variable now is a global var too
Z_ADDREF_P(_val);
// remember that the variable now exists
_exists = true;
// done
return *this;
}
/**
* End of namespace
*/
}
|