summaryrefslogtreecommitdiff
path: root/src/internalfunction.h
blob: 31abccaa3ea22d0b8188fef4298da7403d66bf69 (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
/**
 *  InternalFunction.h
 *
 *  Helper union to create an internal function
 *
 *  @documentation private
 */

/**
 *  Namespace
 */
namespace Php {

/**
 *  An internal function
 */
class InternalFunction
{
public:
    /**
     *  Constructor
     *  @param  handler
     *  @param  flags
     */
    InternalFunction(void (*handler)(INTERNAL_FUNCTION_PARAMETERS), int flags = 0)
    {
        // set everything to zero
        memset(&_func, 0, sizeof(zend_internal_function));
        
        // set the appropriate properties
        _func.type = ZEND_INTERNAL_FUNCTION;
        _func.handler = handler;
        _func.fn_flags = flags;

//        _func.function_name = NULL;
//        _func.scope = NULL;
//        _func.prototype = NULL;
//        _func.num_args = 0;
//        _func.required_num_args = 0;
//        _func.arg_info = NULL;
//        _func.module = NULL;
    }
    
    /**
     *  Destructor
     */
    virtual ~InternalFunction() {}
    
    /**
     *  Cast to zend_function pointer
     *  @return zend_function
     */
    zend_function *function()
    {
        return (zend_function *)&_func;
    }

private:
    /**
     *  The internal function object
     *  @var    zend_internal_function
     */
    zend_internal_function _func;
};


/**
 *  End of namespace
 */
}