blob: 54f07173cfbd75ed4b9114ccdf3a51cfb32e8fc9 (
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 for the function class
*
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* @copyright 2013 Copernica BV
*/
#include "includes.h"
/**
* Set up namespace
*/
namespace PhpCpp {
/**
* Constructor
* @param name Name of the function
* @param arguments The arguments that can be passed to the function
*/
Function::Function(const std::string &name, const std::initializer_list<Argument> &arguments)
{
// one reference to the callable
_refcount = new int(1);
_callable = new Callable(name, arguments);
}
/**
* Remove one reference
*/
void Function::cleanup()
{
// decrease number of references
(*_refcount)--;
// leap out if there are still other references
if (*_refcount > 0) return;
// release memory
delete _refcount;
delete _callable;
}
/**
* End of namespace
*/
}
|