diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-03-02 23:28:10 +0100 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-03-02 23:28:10 +0100 |
commit | 8f24af4c28e74ef1769aef6ab00c480e09be7453 (patch) | |
tree | c73b7de11abbdd8ed2d3f3fa5b63fdd2a1409cb8 /include/classbase.h | |
parent | f7dcf5d81fa1e43533c786d9443e5222398dc8b9 (diff) |
work in progress to support implementing SPL interfaces, disabled the _self variable in Php::Base because by having each object keeping a reference to itself, the refcounter never reached zero and the object was thus never destructed, checking if we can get a new implementation one way or another
Diffstat (limited to 'include/classbase.h')
-rw-r--r-- | include/classbase.h | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/include/classbase.h b/include/classbase.h index baa1624..e23c579 100644 --- a/include/classbase.h +++ b/include/classbase.h @@ -85,14 +85,15 @@ public: * @param value * @return Base */ - Base* construct(Value &&value) + Base* construct(const struct _zend_object_value &value) { // construct the base auto *result = construct(); if (!result) return nullptr; // assign the zend object to it - result->assign(std::move(value)); + // @todo fix this +// result->assign(value); // done return result; @@ -170,6 +171,27 @@ protected: void property(const char *name, const char *value, int flags = Php::Public); void property(const char *name, double value, int flags = Php::Public); + /** + * Add an implemented interface + * + * This can only be used to register interfaces that are already defined + * by Zend, and not for user space interface or custom extension interfaces. + * This is probably not so much of a problem, as this feature is mostly + * useful for interfaces like 'Countable', 'ArrayAccess', 'Iterator', et + * cetera. Interfaces defined in user space are in normal operations + * inaccessible (user space code normally runs after the extension has been + * set up) - so we do not need a feature to set these. + * + * It does however make sense to support implementing extension-specific + * interface. We may add this feature in the future. + * + * @param interface + */ + void interface(struct _zend_class_entry *interface) + { + // register the interface + _interfaces.push_back(interface); + } private: /** @@ -224,6 +246,12 @@ private: */ std::list<std::shared_ptr<Member>> _members; + /** + * All interfaces that are implemented + * @var std::list + */ + std::list<struct _zend_class_entry*> _interfaces; + }; /** |