blob: 789175ea368263ddd8e418833f1d3a0ee1b2ef2c (
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
|
/**
* Function.cpp
*
* Implementation file for the Function class
*
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* @copyright 2015 Copernica BV
*/
/**
* Dependencies
*/
#include "includes.h"
/**
* Set up namespace
*/
namespace Php {
/**
* Function returns a pointer to the class-entry of the Functor class
* @return zend_class_entry
*/
zend_class_entry *Function::entry()
{
// and the actual class entry
static zend_class_entry *entry = nullptr;
// is the class entry already valid?
if (entry) return entry;
// construct functor object
static std::unique_ptr<ClassBase> functor(new Class<Functor>("Functor"));
// initialize the functor class
return entry = functor->implementation()->initialize(functor.get(), "" TSRMLS_CC);
}
/**
* Constructor
* @param function The function to be wrapped
*/
Function::Function(const std::function<Php::Value(Php::Parameters&)> &function) : Value(Object(entry(), new Functor(function))) {}
/**
* End of namespace
*/
}
|