diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-03-01 23:50:27 +0100 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-03-01 23:50:27 +0100 |
commit | 20091783de937a72a86800f8025dd238afb139a1 (patch) | |
tree | 996a0439fb0b1d55a059cabe2b23df708b2201a7 | |
parent | 6abc8b4c062c7333a98830004da894ff81613d5b (diff) |
grouped all class constants in a single file ClassType.h
to make it easier to edit in the event of future changes to the Zend API
-rw-r--r-- | include/abstractclass.h | 2 | ||||
-rw-r--r-- | include/classbase.h | 15 | ||||
-rw-r--r-- | include/classtype.h | 36 | ||||
-rw-r--r-- | include/finalclass.h | 2 | ||||
-rw-r--r-- | include/interface.h | 2 | ||||
-rw-r--r-- | phpcpp.h | 1 | ||||
-rw-r--r-- | src/classbase.cpp | 2 | ||||
-rw-r--r-- | src/includes.h | 1 |
8 files changed, 50 insertions, 11 deletions
diff --git a/include/abstractclass.h b/include/abstractclass.h index 3f41ff9..a791794 100644 --- a/include/abstractclass.h +++ b/include/abstractclass.h @@ -23,7 +23,7 @@ public: * Constructor * @param name Name of the class */ - AbstractClass(const char *name) : Class<T>(name, 0x20) {} + AbstractClass(const char *name) : Class<T>(name, ClassType::Abstract) {} /** * Destructor diff --git a/include/classbase.h b/include/classbase.h index 1cfba83..ad501ea 100644 --- a/include/classbase.h +++ b/include/classbase.h @@ -42,9 +42,9 @@ protected: /** * Protected constructor * @param classname Class name - * @param flags The class flags + * @param type The class type */ - ClassBase(const char *classname, int flags = 0) : _name(classname), _flags(flags) {} + ClassBase(const char *classname, ClassType type = ClassType::Regular) : _name(classname), _type(type) {} public: /** @@ -54,14 +54,14 @@ public: * @todo prefer move */ ClassBase(const ClassBase &that) : - _name(that._name), _flags(that._flags), _methods(that._methods), _members(that._members) {} + _name(that._name), _type(that._type), _methods(that._methods), _members(that._members) {} /** * Move constructor * @param that */ ClassBase(ClassBase &&that) : - _flags(that._flags), _methods(std::move(that._methods)), _members(std::move(that._members)), _entry(that._entry) + _type(that._type), _methods(std::move(that._methods)), _members(std::move(that._members)), _entry(that._entry) { // other entry are invalid now (not that it is used..., class objects are // only moved during extension setup, when the entry pointer has not yet @@ -165,10 +165,10 @@ private: std::string _name; /** - * The class flags (this can be values like Php::Abstract and Php::Final) - * @var int + * The class type (this can be values like Php::Abstract and Php::Final) + * @var ClassType */ - int _flags = 0; + ClassType _type = ClassType::Regular; /** * The class entry @@ -193,6 +193,7 @@ private: * @var std::list */ std::list<std::shared_ptr<Member>> _members; + }; /** diff --git a/include/classtype.h b/include/classtype.h new file mode 100644 index 0000000..382a8db --- /dev/null +++ b/include/classtype.h @@ -0,0 +1,36 @@ +/** + * ClassType.h + * + * Internal class types enumeration. + * + * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com> + * @copyright 2014 Copernica BV + */ + +/** + * Set up namespace + */ +namespace Php { + +/** + * Enumeration definition. + * + * The PHP-CPP library tries to hide the Zend engine internals completely from + * the user. Therefore, it does not include any of the Zend header files, nor + * can it refer to the constants defined in the Zend header files. The + * following constants have been copied from Zend. If the Zend engine ever + * changes (which we do not expect) we should also copy the constant values + * used here. + * + */ +enum class ClassType { + Regular = 0x00, + Abstract = 0x20, + Final = 0x40, + Interface = 0x80 +}; + +/** + * End namespace + */ +} diff --git a/include/finalclass.h b/include/finalclass.h index 5c5a1b6..70f64fb 100644 --- a/include/finalclass.h +++ b/include/finalclass.h @@ -23,7 +23,7 @@ public: * Constructor * @param name Name of the class */ - FinalClass(const char *name) : Class<T>(name, 0x40) {} + FinalClass(const char *name) : Class<T>(name, ClassType::Final) {} /** * Destructor diff --git a/include/interface.h b/include/interface.h index 38f85f3..f276d6f 100644 --- a/include/interface.h +++ b/include/interface.h @@ -20,7 +20,7 @@ public: * Constructor * @param name */ - Interface(const char *name) : ClassBase(name, 0x80) {} + Interface(const char *name) : ClassBase(name, ClassType::Interface) {} /** * Destructor @@ -38,6 +38,7 @@ #include <phpcpp/modifiers.h> #include <phpcpp/properties.h> #include <phpcpp/base.h> +#include <phpcpp/classtype.h> #include <phpcpp/classbase.h> #include <phpcpp/class.h> #include <phpcpp/abstractclass.h> diff --git a/src/classbase.cpp b/src/classbase.cpp index 3fabdea..134164d 100644 --- a/src/classbase.cpp +++ b/src/classbase.cpp @@ -203,7 +203,7 @@ void ClassBase::initialize(const std::string &prefix) #endif // set access types flags for class - _entry->ce_flags = _flags; + _entry->ce_flags = (int)_type; // declare all member variables for (auto &member : _members) member->initialize(_entry); diff --git a/src/includes.h b/src/includes.h index 4117884..53dd354 100644 --- a/src/includes.h +++ b/src/includes.h @@ -59,6 +59,7 @@ #include "../include/modifiers.h" #include "../include/properties.h" #include "../include/base.h" +#include "../include/classtype.h" #include "../include/classbase.h" #include "../include/class.h" #include "../include/abstractclass.h" |