From 35fd3ccbeb4def71b4d8a59dfbb5c31201b099b9 Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Sun, 6 Apr 2014 21:53:24 +0200 Subject: renamed src directory to zend directory, disabled TSRM debug code --- zend/global.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 zend/global.cpp (limited to 'zend/global.cpp') 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 + * @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 + */ +} + -- cgit v1.2.3