blob: f9e0ffbcdaa8aa4c7d690a7c8dd0e55b38dd5f1d (
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
|
/**
* Functions.cpp
*
* Implementation for the functions class
*
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* @copyright 2013 Copernica BV
*/
#include "includes.h"
/**
* Set up namespace
*/
namespace PhpCpp {
/**
* Constructor
* @param functions The functions to parse
*/
Functions::Functions(const std::initializer_list<Function> &functions) : _functions(functions)
{
// allocate the function entries
_entries = new zend_function_entry[functions.size() + 1];
// keep iterator counter
int i = 0;
// loop through the functions
for (auto it = begin(functions); it != functions.end(); it++)
{
// let the callable fill the array
it->internal()->fill(&_entries[i++]);
}
// last entry should be set to all zeros
zend_function_entry *last = &_entries[i];
// all should be set to zero
memset(last, 0, sizeof(zend_function_entry));
}
/**
* Destructor
*/
Functions::~Functions()
{
delete[] _entries;
}
/**
* End of namespace
*/
}
|