blob: aa99c0d6b26dd6cd134ab3ae22a85e8734afdcdb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
/**
* Object.cpp
*
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* @copyright 2014 Copernica BV
*/
#include "includes.h"
/**
* Set up namespace
*/
namespace Php {
/**
* Internal method to instantiate an object
* @param name
*/
void Object::instantiate(const char *name)
{
// convert the name into a class_entry
auto *entry = zend_fetch_class(name, strlen(name), 0);
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);
// @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 is this a memory leak? the base class first initializes a stdClass,
// and then we overwrite it with a specific class
}
/**
* End namespace
*/
}
|