diff options
Diffstat (limited to 'src/object.cpp')
-rw-r--r-- | src/object.cpp | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/src/object.cpp b/src/object.cpp index 99de4a0..aa99c0d 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -12,37 +12,27 @@ namespace Php { /** - * Constructor + * Internal method to instantiate an object * @param name */ -Object::Object(const char *name) +void Object::instantiate(const char *name) { - // step 1: convert the name into a class_entry + // convert the name into a class_entry auto *entry = zend_fetch_class(name, strlen(name), 0); - if (!entry) throw Php::Exception("Unknown class name"); + if (!entry) throw Php::Exception(std::string("Unknown class name ") + name); // initiate the zval (which was already allocated in the base constructor) object_init_ex(_val, entry); -// // is there a special function to create the object? -// if (entry->create_object) -// { -// // create the object -// zend_object_value value = entry->create_object(entry); -// -// // wrap this in the zval (which was already allocated in the base constructor) -// Z_TYPE_P(_val) = IS_OBJECT; -// Z_OBJVAL_P(_val) = value; -// } -// else -// { -// } + // @todo should we call methods like allocating hashtables, copying and + // initializing properties, et cetera????? In all example you always + // see such complicated and next-to-impossible-to-understand + // sequences of functions being called, but this object_init_ex + // also seems to work... - // @todo should we call methods like allocating hashtables, copyint and - // initializing properties, et cetera????? + // @todo is this a memory leak? the base class first initializes a stdClass, + // and then we overwrite it with a specific class - // call the constructor - call("__construct"); } /** |