55f4b4d933
- Add pool struct for data pools
26 lines
503 B
C++
26 lines
503 B
C++
#include "pch.h"
|
|
#include "utils.h"
|
|
|
|
namespace Ruby {
|
|
extern mrb_state *mrb;
|
|
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
|