blob: bae0a0afc1ff7285e0f5c43c77a8d4910f65948f (
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
|
/**
* Call.h
*
* This file holds a function to call a PHP function
*
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* @copyright 2014 Copernica BV
*/
/**
* Set up namespace
*/
namespace Php {
/**
* Call a function in PHP
* @param name Name of the function to call
* @param params Variable number of parameters
* @return Value
*/
template <typename ...Params>
Value call(const char *name, Params&&... params)
{
// the name can be turned into a Php::Value object, which implements
// the operator () method to call it
Value function(name);
// invoke the operator ()
return function(std::forward<Params>(params)...);
}
/**
* Long list of simply-forwarded function calls
*
* Most functions in this list are forwarded to the call() method described
* above, which of course is slower than necessary, because they will have to
* pass the entire zend engine to look up the actual implementation, while a
* direct call the C implementation was possible too. The reason for this is
* that we are lazy - if you feel like looking up the actual implementation for
* each function in the PHP source, your support is more than welcome.
*
* But since it is a stupid idea to call a PHP function from your extension
* anyway (that's what people write extension for: to get away from PHP and
* make the code run on the highway), it is not expected that these functions
* are going to be used very often anyway.
*/
inline Value array_keys(const Value &value) { return call("array_keys", value); }
inline Value array_values(const Value &value) { return call("array_values", value); }
/**
* End of namespace
*/
}
|