summaryrefslogtreecommitdiff
path: root/src/methodmember.h
blob: 709aec9759d2963a65caac8937f17561a73fde9b (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
/**
 *  MethodMember.h
 *
 *  Implementation for a method in a class
 *
 *  @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
 *  @copyright 2013 Copernica BV
 */

/**
 *  Set up namespace
 */
namespace Php {

/**
 *  Class definition
 */
class MethodMember : public MemberInfo, public Function
{
public:
    /**
     *  Constructor
     *  @param  name
     *  @param  method
     *  @param  arguments
     */
    MethodMember(const char *name, const _Method &method, const std::initializer_list<Argument> &arguments = {}) : Function(name, arguments), _method(method) {}

    /**
     *  Destructor
     */
    virtual ~MethodMember() {}

    /**
     *  Is this a method member
     *  @return bool
     */
    virtual bool isMethod() { return true; }

    /**
     *  Fill a function entry object
     *  @param  entry       Function entry
     *  @param  classname   Name of the class
     *  @param  method      Is this a public entry
     */
    virtual void fill(struct _zend_function_entry *entry, const char *classname, MemberModifier flags) override
    {
        // call function object
        Function::fill(entry, classname, flags);
    }

    /**
     *  Method that gets called every time the function is executed
     *  @param  params      The parameters that were passed
     *  @return Variable    Return value
     */
    virtual Value invoke(Parameters &params)
    {
        return _method.invoke(params);
    }

private:
    /**
     *  The method pointer
     *  @var _Method
     */
    _Method _method;
};

/**
 *  End of namespace
 */
}