diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/base.h | 22 | ||||
-rw-r--r-- | include/classbase.h | 17 |
2 files changed, 39 insertions, 0 deletions
diff --git a/include/base.h b/include/base.h index 93ee66e..04f0c0e 100644 --- a/include/base.h +++ b/include/base.h @@ -52,6 +52,28 @@ public: { return value()[name]; } + +private: + /** + * The zend_object + * @var zend_object + */ + struct _zend_object *_object = nullptr; + + /** + * Private method to assign the zend object + * @param zend_object + */ + void assign(struct _zend_object *object) + { + // copy pointer + _object = object; + } + + /** + * ClassBase has access to private data + */ + friend class ClassBase; }; diff --git a/include/classbase.h b/include/classbase.h index 249122a..a9d9ef5 100644 --- a/include/classbase.h +++ b/include/classbase.h @@ -76,6 +76,23 @@ public: * Destructor */ virtual ~ClassBase(); + + /** + * Construct a new instance of the object + * @return Base + */ + Base* construct(struct _zend_object *object) + { + // construct the base + auto *result = construct(); + if (!result) return nullptr; + + // assign the zend object to it + result->assign(object); + + // done + return result; + } /** * Construct a new instance of the object |