diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-03-13 22:09:42 +0100 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-03-13 22:09:42 +0100 |
commit | 20559a70bfd9d18c6ba3138878c0e1936a78e684 (patch) | |
tree | c265b17dda381eeba5fc2d40ad0c1f8665cee92e /include | |
parent | 0c244b567d251a0bb0069c24090ce3a578f7c886 (diff) |
removed interfaces, removed abstract class and remove final class
Diffstat (limited to 'include')
-rw-r--r-- | include/abstractclass.h | 38 | ||||
-rw-r--r-- | include/class.h | 41 | ||||
-rw-r--r-- | include/classbase.h | 49 | ||||
-rw-r--r-- | include/finalclass.h | 38 |
4 files changed, 13 insertions, 153 deletions
diff --git a/include/abstractclass.h b/include/abstractclass.h deleted file mode 100644 index a791794..0000000 --- a/include/abstractclass.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * AbstractClass.h - * - * An abstract class can not be instantiated, it can only be extended - * - * @copyright 2014 Copernica BV - * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com> - */ - -/** - * Set up namespace - */ -namespace Php { - -/** - * Class definition - */ -template <typename T> -class AbstractClass : public Class<T> -{ -public: - /** - * Constructor - * @param name Name of the class - */ - AbstractClass(const char *name) : Class<T>(name, ClassType::Abstract) {} - - /** - * Destructor - */ - virtual ~AbstractClass() {} -}; - -/** - * End namespace - */ -} - diff --git a/include/class.h b/include/class.h index ca09a66..0bfa745 100644 --- a/include/class.h +++ b/include/class.h @@ -25,23 +25,6 @@ extern struct _zend_class_entry *zend_ce_arrayaccess; //extern struct _zend_class_entry *zend_ce_serializable; /** - * SFINAE test to check if the __callStatic method is defined - * @see http://stackoverflow.com/questions/257288/is-it-possible-to-write-a-c-template-to-check-for-a-functions-existence - */ -template <typename T> -class HasCallStatic -{ - typedef char one; - typedef long two; - - template <typename C> static one test( decltype(&C::__callStatic) ) ; - template <typename C> static two test(...); - -public: - static const bool value = sizeof(test<T>(0)) == sizeof(char); -}; - -/** * Set up namespace */ namespace Php { @@ -56,21 +39,13 @@ public: /** * Constructor * - * The flags can be a combination of Php::Final and Php::Abstract. If no - * flags are set, a regular public class will be formed. + * The flags can be a combination of Php::Final and Php::Abstract. + * If no flags are set, a regular public class will be formed. * * @param name Name of the class + * @param flags Accessibility flags */ - Class(const char *name) : ClassBase(name) - { - // check for special classes, and register the interface if it does - // register the interface (we register a pointer-to-a-pointer here, - // because when this code runs (during the get_module() call), the - // interfaces are not yet initialized by the zend engine, this only - // happens later when the all classes are registered (after the - // get_module() call) -// if (std::is_base_of<ArrayAccess, T>::value) interface(&zend_ce_arrayaccess); - } + Class(const char *name, int flags = 0) : ClassBase(name, flags) {} /** * Copy constructor @@ -182,14 +157,6 @@ public: void property(const char *name, bool value, int flags = Public) { ClassBase::property(name, value, flags); } void property(const char *name, double value, int flags = Public) { ClassBase::property(name, value, flags); } -protected: - /** - * Protected constructor - * @param name - * @param flags - */ - Class(const char *name, int flags) : ClassBase(name, flags) {} - private: /** * Construct a new instance of the object diff --git a/include/classbase.h b/include/classbase.h index d19a1b2..77f7948 100644 --- a/include/classbase.h +++ b/include/classbase.h @@ -66,9 +66,16 @@ protected: /** * Protected constructor * @param classname Class name - * @param type The class type + * @param flags Class flags */ - ClassBase(const char *classname, ClassType type = ClassType::Regular) : _name(classname), _type(type) {} + ClassBase(const char *classname, int flags); + + /** + * Protected constructor + * @param classname Class name + * @param type Class type + */ + ClassBase(const char *classname, ClassType type) : _name(classname), _type(type) {} public: /** @@ -80,7 +87,6 @@ public: _type(that._type), _methods(that._methods), _members(that._members), - _interfaces(that._interfaces), _entry(nullptr) {} /** @@ -92,7 +98,6 @@ public: _type(that._type), _methods(std::move(that._methods)), _members(std::move(that._members)), - _interfaces(std::move(that._interfaces)), _entry(that._entry) { // other entry are invalid now (not that it is used..., class objects are @@ -257,35 +262,6 @@ 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. - * - * This method is called _during_ the get_module() call when all classes - * are defined by the extension. However, at that time the Zend engine has - * not yet initialized the zend_class_entry's with the interface addresses. - * That's why we ask for a pointer-to-a-pointer. Later, when the classes - * are really registered, the Zend engine is with registering interfaces - * and the pointers point to a valid variable. - * - * @param interface - */ - void interface(struct ::_zend_class_entry **interface) - { - // register the interface - _interfaces.push_back(interface); - } - private: /** * Retrieve an array of zend_function_entry objects that hold the @@ -517,13 +493,6 @@ private: * @var std::list */ std::list<std::shared_ptr<Member>> _members; - - /** - * All interfaces that are implemented - * @var std::list - */ - std::list<struct ::_zend_class_entry**> _interfaces; - }; /** diff --git a/include/finalclass.h b/include/finalclass.h deleted file mode 100644 index 70f64fb..0000000 --- a/include/finalclass.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * FinalClass.h - * - * An final class can not be extended - * - * @copyright 2014 Copernica BV - * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com> - */ - -/** - * Set up namespace - */ -namespace Php { - -/** - * Class definition - */ -template <typename T> -class FinalClass : public Class<T> -{ -public: - /** - * Constructor - * @param name Name of the class - */ - FinalClass(const char *name) : Class<T>(name, ClassType::Final) {} - - /** - * Destructor - */ - virtual ~FinalClass() {} -}; - -/** - * End namespace - */ -} - |