blob: 178f1bef6520f741925d13f60e85267471e53cd8 (
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/**
* ParametersImpl.h
*
* Extended parameters class that can be instantiated
*
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* @copyright 2013 Copernica BV
*/
/**
* Set up namespace
*/
namespace Php {
/**
* Class definition
*/
class ParametersImpl : public Parameters
{
public:
/**
* Constructor
* @param this_ptr Pointer to the object
* @param argc Number of arguments
* @param tsrm_ls
*/
ParametersImpl(zval *this_ptr, int argc TSRMLS_DC) : Parameters(this_ptr ? ObjectImpl::find(this_ptr TSRMLS_CC)->object() : nullptr)
{
// reserve plenty of space
reserve(argc);
// array to store all the arguments in
zval arguments[argc];
// retrieve the arguments
zend_get_parameters_array_ex(argc, arguments);
// loop through the arguments
for (int i=0; i<argc; i++)
{
// append value
emplace_back(&arguments[i]);
}
}
/**
* Do _not_ add a virtual destructor here.
*
* We are extending a vector, which does not itself
* have a virtual destructor, so destructing through
* a pointer to this vector has no effect.
*
* By adding a virtual destructor we create a vtable,
* which makes the class bigger, causing slicing and
* then we are actually introducing the problem that
* we are trying to avoid!
*/
};
/**
* End of namespace
*/
}
|