diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2015-02-05 22:59:15 +0100 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2015-02-05 22:59:15 +0100 |
commit | 7c7121e92b3ebd2763b4b03227eeec09461d8ea9 (patch) | |
tree | d4de14152798da46907795e773feac742d27a769 /zend/functor.cpp | |
parent | ba32a85db3f1130d01ccf228e253d2e717c53c70 (diff) |
refactored the initialization and shutdown of extension objects (code is moved from a static method to a real member method), and more importantly: fixed initialization of the PhpCpp::Functor class, previously, we created the class an runtime whenever we needed it, but that turned out to be a cause for crashes when php stopped, this has also been solved
Diffstat (limited to 'zend/functor.cpp')
-rw-r--r-- | zend/functor.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/zend/functor.cpp b/zend/functor.cpp new file mode 100644 index 0000000..7d0404b --- /dev/null +++ b/zend/functor.cpp @@ -0,0 +1,56 @@ +/** + * Functor.cpp + * + * Implementation file for the functor class + * + * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com> + * @copyright 2015 Copernica BV + */ + +/** + * Dependencies + */ +#include "includes.h" + +/** + * Set up namespace + */ +namespace Php { + +/** + * The classentry + * @var zend_class_entry + */ +zend_class_entry *Functor::_entry = nullptr; + +/** + * Initialize the class + * @param tsrmls + */ +void Functor::initialize(TSRMLS_D) +{ + // leap out if the class entry is already set + if (_entry) return; + + // construct functor object + static std::unique_ptr<ClassBase> functor(new Class<Functor>("PhpCpp::Functor")); + + // initialize the functor class + _entry = functor->implementation()->initialize(functor.get(), "" TSRMLS_CC); +} + +/** + * Shutdown the class + * @param tsrmls + */ +void Functor::shutdown(TSRMLS_D) +{ + // we forget the entry + _entry = nullptr; +} + +/** + * End of namespace + */ +} + |