rutie/rubysys/
vm.rs

1use crate::rubysys::types::{c_char, c_int, c_void, Argc, CallbackPtr, Id, Value, VmPointer};
2
3extern "C" {
4    // void
5    // ruby_init(void)
6    pub fn ruby_init();
7    // void
8    // ruby_init_loadpath(void)
9    pub fn ruby_init_loadpath();
10    // void
11    // ruby_vm_at_exit(void(*func)(ruby_vm_t *))
12    pub fn ruby_vm_at_exit(func: VmPointer);
13    // VALUE
14    // rb_block_proc(void)
15    pub fn rb_block_proc() -> Value;
16    // int
17    // rb_block_given_p(void)
18    pub fn rb_block_given_p() -> c_int;
19    // VALUE
20    // rb_errinfo(void)
21    pub fn rb_errinfo() -> Value;
22    // VALUE
23    // rb_eval_string(const char *str)
24    pub fn rb_eval_string(string: *const c_char) -> Value;
25    // VALUE
26    // rb_eval_string_protect(const char *str, int *pstate)
27    pub fn rb_eval_string_protect(string: *const c_char, state: *mut c_int) -> Value;
28    // VALUE
29    // rb_f_abort(int argc, const VALUE *argv)
30    pub fn rb_f_abort(argc: Argc, argv: *const Value) -> Value;
31    // //////////////// UNAVAILABLE METHOD ////////////////
32    // // VALUE
33    // // rb_f_eval(int argc, const VALUE *argv, VALUE self)
34    // pub fn rb_f_eval(argc: c_int, argv: *const Value, self_: Value) -> Value;
35    // ///////////////// ///////////////// ///////////////
36    // void
37    // rb_exc_raise(VALUE mesg)
38    pub fn rb_exc_raise(exception: Value);
39    // void
40    // rb_exit(int status)
41    pub fn rb_exit(status: c_int);
42    // void
43    // rb_raise(VALUE exc, const char *fmt, ...)
44    pub fn rb_raise(exception: Value, message: *const c_char);
45    // VALUE
46    // rb_require(const char *fname)
47    pub fn rb_require(name: *const c_char) -> Value;
48    // void
49    // rb_set_errinfo(VALUE err)
50    pub fn rb_set_errinfo(err: Value);
51    // VALUE
52    // rb_protect(VALUE (* proc) (VALUE), VALUE data, int *pstate)
53    pub fn rb_protect(func: CallbackPtr, args: *const c_void, state: *mut c_int) -> Value;
54    // VALUE
55    // rb_funcallv(VALUE recv, ID mid, int argc, const VALUE *argv)
56    pub fn rb_funcallv(receiver: Value, method: Id, argc: Argc, argv: *const Value) -> Value;
57    // VALUE
58    // rb_funcallv_public(VALUE recv, ID mid, int argc, const VALUE *argv)
59    pub fn rb_funcallv_public(receiver: Value, method: Id, argc: Argc, argv: *const Value)
60        -> Value;
61    // VALUE
62    // rb_block_call(VALUE obj, ID mid, int argc, const VALUE * argv,
63    //               VALUE (*bl_proc) (ANYARGS), VALUE data2)
64    pub fn rb_block_call(
65        obj: Value,
66        method_id: Id,
67        argc: Argc,
68        argv: *const Value,
69        block: extern "C" fn(Value, Value, Argc, *const Value) -> Value,
70        outer_scope: Value,
71    ) -> Value;
72    // VALUE
73    // rb_yield_splat(VALUE values)
74    pub fn rb_yield_splat(values: Value) -> Value;
75    // VALUE
76    // rb_yield(VALUE val)
77    pub fn rb_yield(value: Value) -> Value;
78    // VALUE
79    // rb_call_super(int argc, const VALUE *argv)
80    pub fn rb_call_super(argc: Argc, argv: *const Value) -> Value;
81}