1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
use crate::rubysys::types::{c_char, c_double, c_int, Argc, Id, Value};
#[cfg_attr(rutie_dllimport, link(name = "rutie_ruby"))]
extern "C" {
// VALUE
// rb_Array(VALUE val)
pub fn rb_Array(object: Value) -> Value;
// VALUE
// rb_check_funcall(VALUE recv, ID mid, int argc, const VALUE *argv)
//
// Returns `Qundef` when `recv` does not respond to `mid`.
pub fn rb_check_funcall(receiver: Value, method: Id, argc: Argc, argv: *const Value) -> Value;
// VALUE
// rb_Float(VALUE val)
pub fn rb_Float(object: Value) -> Value;
// VALUE
// rb_hash(VALUE obj)
pub fn rb_hash(object: Value) -> Value;
// VALUE
// rb_Hash(VALUE val)
pub fn rb_Hash(object: Value) -> Value;
// VALUE
// rb_inspect(VALUE obj)
pub fn rb_inspect(object: Value) -> Value;
// VALUE
// rb_Integer(VALUE val)
pub fn rb_Integer(object: Value) -> Value;
// VALUE
// rb_ivar_defined(VALUE obj, ID id)
pub fn rb_ivar_defined(object: Value, name: Id) -> Value;
// VALUE
// rb_obj_as_string(VALUE obj)
pub fn rb_obj_as_string(object: Value) -> Value;
// VALUE
// rb_obj_clone(VALUE obj)
pub fn rb_obj_clone(object: Value) -> Value;
// VALUE
// rb_obj_dup(VALUE obj)
pub fn rb_obj_dup(object: Value) -> Value;
// VALUE
// rb_obj_id(VALUE obj)
pub fn rb_obj_id(object: Value) -> Value;
// VALUE
// rb_obj_instance_eval(int argc, const VALUE *argv, VALUE self)
pub fn rb_obj_instance_eval(argc: Argc, argv: *const Value, object: Value) -> Value;
// VALUE
// rb_obj_instance_variables(VALUE obj)
pub fn rb_obj_instance_variables(object: Value) -> Value;
// VALUE
// rb_obj_is_instance_of(VALUE obj, VALUE c)
pub fn rb_obj_is_instance_of(object: Value, klass: Value) -> Value;
// VALUE
// rb_obj_method(VALUE obj, VALUE vid)
pub fn rb_obj_method(object: Value, name: Value) -> Value;
// VALUE
// rb_obj_remove_instance_variable(VALUE obj, VALUE name)
pub fn rb_obj_remove_instance_variable(object: Value, name: Value) -> Value;
// void
// rb_p(VALUE obj)
pub fn rb_p(object: Value);
// VALUE
// rb_str_format(int argc, const VALUE *argv, VALUE fmt)
pub fn rb_str_format(argc: c_int, argv: *const Value, format: Value) -> Value;
// VALUE
// rb_String(VALUE val)
pub fn rb_String(object: Value) -> Value;
}
#[cfg_attr(rutie_dllimport, link(name = "rutie_ruby"))]
extern "C" {
// VALUE
// rb_any_to_s(VALUE obj)
//
// The default `#<ClassName:0x...>` form of `Kernel#to_s`.
pub fn rb_any_to_s(object: Value) -> Value;
// VALUE
// rb_check_convert_type(VALUE val, int type, const char *name, const char *mid)
//
// `nil` when `val` does not respond to `mid`; raises `TypeError` when
// `mid` returns something not of `type`.
pub fn rb_check_convert_type(
object: Value,
value_type: c_int,
class_name: *const c_char,
method: *const c_char,
) -> Value;
// VALUE
// rb_check_to_float(VALUE val)
//
// `nil` unless `val` is a `Numeric` that converts with `to_f`.
pub fn rb_check_to_float(object: Value) -> Value;
// VALUE
// rb_check_to_int(VALUE val)
//
// `nil` unless `to_int` returns an `Integer`.
pub fn rb_check_to_int(object: Value) -> Value;
// VALUE
// rb_check_to_integer(VALUE val, const char *mid)
//
// `nil` unless `mid` returns an `Integer`.
pub fn rb_check_to_integer(object: Value, method: *const c_char) -> Value;
// VALUE
// rb_convert_type(VALUE val, int type, const char *name, const char *mid)
//
// Raises `TypeError` when `val` cannot be converted.
pub fn rb_convert_type(
object: Value,
value_type: c_int,
class_name: *const c_char,
method: *const c_char,
) -> Value;
// double
// rb_cstr_to_dbl(const char *str, int mode)
//
// `0` parses as much of `str` as it can. A nonzero `mode` (badcheck)
// should raise `ArgumentError` for malformed input, but Ruby 4.0 crashes
// there instead (it builds the message with a null encoding), so only
// pass `0`, or use `rb_str_to_dbl`.
pub fn rb_cstr_to_dbl(string: *const c_char, badcheck: c_int) -> c_double;
// VALUE
// rb_obj_init_copy(VALUE src, VALUE dst)
//
// `Kernel#initialize_copy`: raises unless `dst` is unfrozen and of the
// same class as `src`.
pub fn rb_obj_init_copy(object: Value, original: Value) -> Value;
// VALUE
// rb_to_int(VALUE val)
//
// Raises `TypeError` unless `to_int` returns an `Integer`.
pub fn rb_to_int(object: Value) -> Value;
// int
// rb_obj_respond_to(VALUE obj, ID mid, int private_p)
pub fn rb_obj_respond_to(object: Value, method: Id, include_private: c_int) -> c_int;
// VALUE
// rb_obj_instance_exec(int argc, const VALUE *argv, VALUE recv)
//
// Needs a Ruby block.
pub fn rb_obj_instance_exec(argc: Argc, argv: *const Value, object: Value) -> Value;
// VALUE
// rb_check_funcall_kw(VALUE recv, ID mid, int argc, const VALUE *argv, int kw_splat)
//
// Returns `Qundef` when `recv` does not respond to `mid`.
pub fn rb_check_funcall_kw(
receiver: Value,
method: Id,
argc: Argc,
argv: *const Value,
kw_splat: c_int,
) -> Value;
// VALUE
// rb_apply(VALUE recv, ID mid, VALUE args)
//
// Calls `mid` with the elements of the `Array` `args`.
pub fn rb_apply(receiver: Value, method: Id, arguments: Value) -> Value;
}