Fix and make mruby work better

This commit is contained in:
2026-07-26 16:49:43 +01:00
parent 45ef92f27e
commit 5f40c0536c
7 changed files with 92 additions and 40 deletions
+24
View File
@@ -0,0 +1,24 @@
open Ctypes
open Foreign
module Mrb_state = struct
type t
type mrb_ptr = t structure ptr
let typ : t structure typ = structure "mrb_state"
let jmp = field typ "jmp" (ptr void)
let c = field typ "c" (ptr void)
let root_c = field typ "root_c" (ptr void)
let globals = field typ "globals" (ptr void)
let exc = field typ "exc" (ptr void)
(* as it builds by default on x86_64 linux *)
let padding = field typ "padding" (array 24472 char)
let () = seal typ
let has_error mrb_ptr =
let exc_val = getf !@mrb_ptr exc in
not (is_null exc_val)
let clear_error mrb_ptr = setf !@mrb_ptr exc null
end