blob: 4ff1b604f3fd51d0ffe6528b8d70356140eb7bb1 (
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
/**
* Members.cpp
*
* Implementation of the members class
*
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* @copyright 2013 Copernica BV
*/
#include "includes.h"
/**
* Set up namespace
*/
namespace Php {
/**
* Destructor
*/
Members::~Members()
{
// check if there are methods
if (_methods) delete[] _methods;
}
/**
* Number of methods
* @return integer
*/
int Members::methods()
{
// result variable
int result = 0;
// loop through the functions
for (auto it = begin(); it != end(); it++)
{
// check if this is a method
if (it->isMethod()) result++;
}
// done
return result;
}
/**
* Get access to the methods
* @return Methods
*/
struct _zend_function_entry *Members::methods(const char *classname)
{
// already set?
if (_methods) return _methods;
// the number of methods
int count = methods();
// allocate memory for the functions
_methods = new zend_function_entry[count + 1];
// keep iterator counter
int i = 0;
// loop through the functions
for (auto it = begin(); it != end(); it++)
{
// skip if this is not a method
if (!it->isMethod()) continue;
// retrieve entry
zend_function_entry *entry = &_methods[i++];
// let the function fill the entry
it->fill(entry, classname);
}
// last entry should be set to all zeros
zend_function_entry *last = &_methods[i];
// all should be set to zero
memset(last, 0, sizeof(zend_function_entry));
// done
return _methods;
}
/**
* End of namespace
*/
}
|