-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.cpp
63 lines (49 loc) · 1.17 KB
/
example.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <meevax/basis.hpp>
#include <meevax/kernel/environment.hpp>
using namespace meevax; // NOTE: DIRTY HACK
extern "C"
{
auto argument_length(object & xs)
{
return make<exact_integer>(length(xs));
}
auto dummy_procedure(object & xs)
{
std::cout << "\n; calling C++ function." << std::endl;
std::size_t count = 0;
for (let const& each : xs)
{
std::cout << "; [" << count++ << "] is " << each << " (C++ typename " << each.type().name() << ")" << std::endl;
}
for (let const& x : xs)
{
if (x.is<exact_integer>())
{
std::cout << "; return incremented left-most integer object." << std::endl;
auto value = static_cast<int>(x.as<exact_integer>());
return make<exact_integer>(++value);
}
}
return unspecified;
}
struct hoge
{
int value;
~hoge()
{
std::cout << "DESTRUCTOR!" << std::endl;
}
};
auto make_hoge(object & xs)
{
return make<hoge>(car(xs).as<exact_integer>());
}
auto is_hoge(object & xs)
{
return car(xs).is<hoge>() ? t : f;
}
auto hoge_value(object & xs)
{
return make<exact_integer>(car(xs).as<hoge>().value);
}
}