blob: 153da9cfe07f1612b9104b9e1f2b1cd7fb60c0ee (
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
|
/**
* Argument.cpp
*
* Implementation for the Argument class
*
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* @copyright 2013 Copernica BV
*/
#include "includes.h"
/**
* Set up namespace
*/
namespace PhpCpp {
/**
* Constructor if this argument should be an instance of a certain class
* @param name Name of the argument
* @param classname If a specific class is required, the class type
* @param null Are NULL values allowed in stead of an instance?
* @param ref Is this a pass-by-reference argument?
*/
Argument::Argument(const std::string &name, const std::string &classname, bool null, bool ref)
{
_refcount = new int[1];
_info = new ArgInfo(name, classname, null, ref);
}
/**
* Constructor if the argument can be anything
* @param name Name of the argument
* @param type Type hint
* @param ref Is this a pass-by-reference argument?
*/
Argument::Argument(const std::string &name, Type type, bool ref)
{
_refcount = new int[1];
_info = new ArgInfo(name, type, ref);
}
/**
* Clean up the object
*/
void Argument::cleanup()
{
// one reference less
(*_refcount)--;
// leap out if still in use
if (*_refcount > 0) return;
// release memory
delete _refcount;
delete _info;
}
/**
* End of namespace
*/
}
|