diff options
author | valmat <ufabiz@gmail.com> | 2014-04-09 11:00:05 +0600 |
---|---|---|
committer | valmat <ufabiz@gmail.com> | 2014-04-09 11:00:05 +0600 |
commit | 6c7c846edd5b74450b76532da33c25e6cc6a10a4 (patch) | |
tree | 51b0e0be5c43ddba6ca9351026fc94bf8ae7bc07 /zend/global.cpp | |
parent | 08ed8866a5bba0b23a8d5587116a968512df2568 (diff) | |
parent | 33760c3efba4207eac826ff080b5f9b9672fc60e (diff) |
Merge branch 'master' into ini-master
Conflicts:
include/namespace.h
zend/extensionimpl.cpp
Diffstat (limited to 'zend/global.cpp')
-rw-r--r-- | zend/global.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/zend/global.cpp b/zend/global.cpp new file mode 100644 index 0000000..7eea8e7 --- /dev/null +++ b/zend/global.cpp @@ -0,0 +1,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 + */ +} + |