Make it work with flake.nix
This commit is contained in:
@@ -191,6 +191,15 @@ BarLine bar_contents(uint8_t mode, uint32_t width, std::string foldername,
|
||||
mrb_value mod_val = mrb_obj_value(C_module);
|
||||
mrb_value block = mrb_funcall(mrb, mod_val, "b_bar", 0);
|
||||
mrb_value val_line = mrb_funcall(mrb, block, "call", 1, info);
|
||||
if (mrb_array_p(val_line) && RARRAY_LEN(val_line) == 1) {
|
||||
val_line = mrb_ary_ref(mrb, val_line, 0);
|
||||
}
|
||||
if (!mrb_hash_p(val_line)) {
|
||||
mrb_value inspected = mrb_funcall(mrb, val_line, "inspect", 0);
|
||||
printf("bar returned: %s\n", RSTRING_PTR(inspected));
|
||||
fprintf(stderr, "bar returned: %s\n", mrb_obj_classname(mrb, val_line));
|
||||
abort();
|
||||
}
|
||||
if (mrb->exc) {
|
||||
end_screen();
|
||||
fputs("Error when executing Ruby code:\n", stderr);
|
||||
@@ -200,6 +209,11 @@ BarLine bar_contents(uint8_t mode, uint32_t width, std::string foldername,
|
||||
}
|
||||
mrb_value text_val = mrb_hash_get(
|
||||
mrb, val_line, mrb_symbol_value(mrb_intern_cstr(mrb, "text")));
|
||||
if (!mrb_string_p(text_val)) {
|
||||
fprintf(stderr, "text is not a string: %s\n",
|
||||
mrb_obj_classname(mrb, text_val));
|
||||
abort();
|
||||
}
|
||||
const char *ptr = RSTRING_PTR(text_val);
|
||||
mrb_int len = RSTRING_LEN(text_val);
|
||||
bar_line.line = std::string(ptr, len);
|
||||
|
||||
Regular → Executable
Reference in New Issue
Block a user