-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.cpp
More file actions
62 lines (49 loc) · 1.18 KB
/
example.cpp
File metadata and controls
62 lines (49 loc) · 1.18 KB
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
#include <meevax/basis.hpp>
#include <meevax/kernel/boolean.hpp>
#include <meevax/kernel/environment.hpp>
using namespace meevax; // NOTE: DIRTY HACK
extern "C"
{
auto argument_length(object & xs)
{
return make(static_cast<small_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<small_integer>())
{
std::cout << "; return incremented left-most integer object." << std::endl;
return make(x.as<small_integer>() + 1);
}
}
return unspecified;
}
struct hoge
{
small_integer value;
~hoge()
{
std::cout << "DESTRUCTOR!" << std::endl;
}
};
auto make_hoge(object & xs)
{
return make<hoge>(exact_integer_cast<small_integer>(car(xs)));
}
auto is_hoge(object & xs)
{
return car(xs).is<hoge>() ? t : f;
}
auto hoge_value(object & xs)
{
return make<small_integer>(car(xs).as<hoge>().value);
}
}