Files
kutu/src/mruby/types.ml
T
2026-09-09 23:39:05 +01:00

53 lines
1.2 KiB
OCaml

open Ctypes
open Foreign
module Mrb_value = struct
type t
let typ : t structure typ = structure "mrb_value"
let value = field typ "w" uintptr_t
let () = seal typ
end
module Mrb_sym = struct
type t
let typ = uint32_t
end
module Mrb_class = struct
type t
type class_ptr = t structure ptr
let typ : t structure typ = structure "RClass"
(* as it builds by default on x86_64 linux *)
let padding = field typ "padding" (array 40 char)
let () = seal typ
end
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)
let top_self = field typ "top_self" (ptr void)
let object_class = field typ "object_class" (ptr Mrb_class.typ)
(* as it builds by default on x86_64 linux *)
let padding = field typ "padding" (array 24464 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
let get_object_class mrb_ptr = getf !@mrb_ptr object_class
end