Files
project_misth/include/binding/ruby.h
T

26 lines
516 B
C++

#include "pch.h"
#include "utils.h"
namespace Ruby {
inline mrb_state *mrb = mrb_open();
struct Block {
mrb_value proc;
Block(mrb_value proc) : proc(proc) {
mrb_gc_register(mrb, proc);
}
Block() : proc(mrb_nil_value()) {}
Block(const Block &) = delete;
Block &operator=(const Block &) = delete;
mrb_value call(int argc = 0, mrb_value *argv = nullptr) const {
return mrb_funcall(mrb, proc, "call", argc, argv);
}
~Block() {
mrb_gc_unregister(mrb, proc);
}
};
}; // namespace Ruby