diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-04-02 22:25:45 +0200 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-04-02 22:25:45 +0200 |
commit | bbdcdae98979e002476fc1e8296effd0b270928b (patch) | |
tree | 8634ff596c4209296a36dd7f8c54d00a8ec29478 /include/class.h | |
parent | 735ec67aeb40e04a2cf47fa7216b2030c66b37fd (diff) |
refactored the class and classbase classes, and introduced a classimpl class in the src directory, this is a first step to remove all zend-specific code from the header files, so that we can later have a hhvm backend for the php-cpp library
Diffstat (limited to 'include/class.h')
-rw-r--r-- | include/class.h | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/include/class.h b/include/class.h index b9295ea..8bc034c 100644 --- a/include/class.h +++ b/include/class.h @@ -18,11 +18,7 @@ /** * Zend/SPL interfaces that we support */ -//extern struct _zend_class_entry *zend_ce_traversable; -//extern struct _zend_class_entry *zend_ce_aggregate; -//extern struct _zend_class_entry *zend_ce_iterator; extern struct _zend_class_entry *zend_ce_arrayaccess; -//extern struct _zend_class_entry *zend_ce_serializable; /** * Set up namespace @@ -132,6 +128,7 @@ public: * @param name Name of the method * @param flags Optional flags * @param args Argument descriptions + * @return Class Same object to allow chaining */ Class<T> &method(const char *name, int flags, const Arguments &args = {}) { ClassBase::method(name, flags | Abstract, args); return *this; } Class<T> &method(const char *name, const Arguments &args = {}) { ClassBase::method(name, Public | Abstract, args); return *this; } @@ -148,6 +145,7 @@ public: * @param name Name of the property * @param value Actual property value * @param flags Optional flags + * @return Class Same object to allow chaining */ Class<T> &property(const char *name, std::nullptr_t value, int flags = Public) { ClassBase::property(name, value, flags); return *this; } Class<T> &property(const char *name, int64_t value, int flags = Public) { ClassBase::property(name, value, flags); return *this; } @@ -178,6 +176,34 @@ public: Class<T> &property(const char *name, Value (T::*getter)() const, void (T::*setter)(const Value &value) ) { ClassBase::property(name, static_cast<getter_callback_1>(getter), static_cast<setter_callback_0>(setter)); return *this; } Class<T> &property(const char *name, Value (T::*getter)() , void (T::*setter)(const Value &value) const) { ClassBase::property(name, static_cast<getter_callback_0>(getter), static_cast<setter_callback_1>(setter)); return *this; } Class<T> &property(const char *name, Value (T::*getter)() const, void (T::*setter)(const Value &value) const) { ClassBase::property(name, static_cast<getter_callback_1>(getter), static_cast<setter_callback_1>(setter)); return *this; } + + /** + * Add a PHP interface to the class + * + * Note that the interface that you supply must already exist! Therefore + * you can only supply interfaces that you created in your own extension. + * + * @param interface Interface object + * @return Class Same object to allow chaining + */ +// Class<T> &implements(const Interface &interface) { ClassBase::implements(interface); return *this; } + + /** + * Add a base class + * + * Because PHP does not allow multiple inheritance, you can only add one + * base class. If you call this method more than once, the earlier base + * class is overridden. + * + * The base class that you supply must already be registered. And because + * your extension is most likely registered before any user space PHP scripts + * run, you can only specify built-in classes, or classes that you created + * in your own extension. + * + * @param name Name of the base class + * @return Class Same object to allow chaining + */ +// Class<T> &extends(const char *name) { ClassBase::extends(name); return *this; } private: /** |