-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpuntype.cpp
48 lines (37 loc) · 888 Bytes
/
puntype.cpp
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
#include "puntype.h"
#include "parameter.h"
using namespace pun;
const char* PunType::PHP_NAME = "Pun\\Type";
void
PunType::setup_ext(Php::Extension& ext)
{
Php::Class<PunType> ptype(PunType::PHP_NAME);
ptype.method<&PunType::fromValue> ("fromValue");
ptype.method<&PunType::isMatch> ("isMatch");
ptype.method<&PunType::type> ("type");
ptype.method<&PunType::name> ("name");
ext.add(std::move(ptype));
}
void PunType::fromValue(Php::Parameters& param)
{
pun::need_Value(param);
_type = pun::getPype(param[0]);
}
void PunType::fn_fromValue(Php::Value& val) {
_type = pun::getPype(val);
}
Php::Value
PunType::type() const
{
return _type;
}
Php::Value
PunType::name() const
{
return pun::getPypeId(_type);
}
Php::Value PunType::isMatch(Php::Parameters& param)
{
pun::need_Value(param);
return (_type == pun::getPype(param[0])) ? Same : Different;
}