summaryrefslogtreecommitdiff
path: root/zend/object.cpp
diff options
context:
space:
mode:
authorToon Schoenmakers <toon.schoenmakers@copernica.com>2014-11-21 13:51:04 +0100
committerToon Schoenmakers <toon.schoenmakers@copernica.com>2014-11-21 13:51:04 +0100
commit2e25bc7e1b9faf89e6057ed7874ef2f4a8c86ca1 (patch)
tree4be1d5481cfa68719245ba670375e263fa8ebadd /zend/object.cpp
parentcc5da69ebf5eda704a29c75ef33b0b358370e805 (diff)
Removed move constructor from Object class, because it caused failures when instantiating with a std::string parameter, Php::Object constructors now always first call the base constructor, and the __construct() function is now always called
Diffstat (limited to 'zend/object.cpp')
-rw-r--r--zend/object.cpp20
1 files changed, 7 insertions, 13 deletions
diff --git a/zend/object.cpp b/zend/object.cpp
index 30fdcdb..a4eaf1e 100644
--- a/zend/object.cpp
+++ b/zend/object.cpp
@@ -17,7 +17,7 @@ namespace Php {
* @param name Name of the class to instantiate
* @param base Implementation of the class
*/
-Object::Object(const char *name, Base *base)
+Object::Object(const char *name, Base *base) : Value(Type::Object)
{
// does the object already have a handle?
if (base->implementation())
@@ -56,20 +56,14 @@ Object::Object(const char *name, Base *base)
* or when it is a string holding a classname
* @param that An other object
*/
-Object::Object(const Value &value) : Value()
+Object::Object(const Value &value) : Value(Type::Object)
{
// when a string is passed in, we are going to make a new instance of the
// passed in string
if (value.isString())
{
// instantiate the object
- auto *entry = instantiate(value);
-
- // leap out if there is no __construct function
- if (!zend_hash_exists(&entry->function_table, "__construct", 12)) return;
-
- // call the construct function
- call("__construct");
+ if (instantiate(value)) call("__construct");
}
else
{
@@ -81,9 +75,9 @@ Object::Object(const Value &value) : Value()
/**
* Internal method to instantiate an object
* @param name Name of the class to instantiate
- * @return zend_class_entry
+ * @return bool True if there is a __construct function
*/
-zend_class_entry *Object::instantiate(const char *name)
+bool Object::instantiate(const char *name)
{
// we need the tsrm_ls variable
TSRMLS_FETCH();
@@ -107,8 +101,8 @@ zend_class_entry *Object::instantiate(const char *name)
// @todo is this a memory leak? the base class first initializes a stdClass,
// and then we overwrite it with a specific class
- // return the class entry
- return entry;
+ // return whether there is a __construct function
+ return zend_hash_exists(&entry->function_table, "__construct", 12);
}
/**