-
Notifications
You must be signed in to change notification settings - Fork 11
/
icppapi.cc
54 lines (43 loc) · 1.73 KB
/
icppapi.cc
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
#include <icpp.hpp>
int main(int argc, const char *argv[]) {
auto thisdir = fs::path(argv[0]).parent_path();
icpp::prints("The running {} version is {}.\nCurrent user home is {}.\n",
icpp::program(), icpp::version(), icpp::home_directory());
icpp::prints("The {} is a c++ source? {}.\n", argv[0],
icpp::is_cpp_source(argv[0]));
icpp::prints("Random values: i={}, s={}.\n", icpp::rand_value(),
icpp::rand_string<16>());
std::puts("Executing a c code...");
icpp::exec_string("#include <stdio.h>\n"
"int main() {"
"puts(\"Hello world from c.\");"
"return 0;"
"}");
std::puts("Executing a c++ expression...");
icpp::exec_expression("icpp::result_set(88888888)");
icpp::prints("Current result: i={}\n", icpp::result_get());
std::puts("Executing a c++ code...");
icpp::exec_string("#include <icpp.hpp>\n"
"int main(int argc, const char *argv[]) {"
"std::puts(\"Executing string...\");"
"icpp::result_set(argv[0]);"
"std::puts(\"Done.\");"
"return 0;"
"}",
argc, argv);
icpp::prints("Current result: s={}\n", icpp::result_gets());
std::puts("Executing a c++ source...");
icpp::exec_source((thisdir / "split.cc").string());
std::puts("Executing a icpp module...");
icpp::exec_module("module-demo");
if (argc == -1) {
icpp::result_set(0);
icpp::result_set("");
icpp::load_library("");
icpp::unload_library(nullptr);
icpp::resolve_symbol("");
icpp::iterate_modules(
[](uint64_t base, std::string_view path) { return true; });
}
return 0;
}