33 lines
780 B
C++
33 lines
780 B
C++
|
#include <iostream>
|
||
|
#include <wren.hpp>
|
||
|
#include <chrono>
|
||
|
#include <thread>
|
||
|
|
||
|
namespace {
|
||
|
void wren_print (WrenVM*, const char* text) {
|
||
|
std::cout << text;
|
||
|
}
|
||
|
|
||
|
void wren_error (WrenVM*, WrenErrorType type, const char* module, int line, const char* message) {
|
||
|
std::cerr << "Wren error: " << message << " in " << module << ':' << line << '\n';
|
||
|
}
|
||
|
} //unnamed namespace
|
||
|
|
||
|
int main() {
|
||
|
std::cout << "hello world\n";
|
||
|
WrenConfiguration config;
|
||
|
wrenInitConfiguration(&config);
|
||
|
config.writeFn = &wren_print;
|
||
|
config.errorFn = &wren_error;
|
||
|
WrenVM* vm = wrenNewVM(&config);
|
||
|
WrenInterpretResult result = wrenInterpret(
|
||
|
vm,
|
||
|
"my_module",
|
||
|
"System.print(\"I am running in a VM!\")"
|
||
|
);
|
||
|
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
|
||
|
wrenFreeVM(vm);
|
||
|
|
||
|
return 0;
|
||
|
}
|