14 #include "internal/class.h"
15 #include "internal/error.h"
16 #include "internal/hash.h"
17 #include "internal/object.h"
18 #include "internal/proc.h"
19 #include "internal/struct.h"
20 #include "internal/symbol.h"
27 AREF_HASH_THRESHOLD = 10
34 static VALUE rb_cData;
35 static ID id_members, id_back_members, id_keyword_init;
61 rb_struct_s_keyword_init(
VALUE klass)
63 return struct_ivar_get(klass, id_keyword_init);
69 VALUE members = struct_ivar_get(klass, id_members);
93 struct_member_pos_ideal(
VALUE name,
long mask)
96 return (
SYM2ID(name) >> (ID_SCOPE_SHIFT - 1)) & mask;
100 struct_member_pos_probe(
long prev,
long mask)
103 return (prev * AREF_HASH_UNIT + 2) & mask;
107 struct_set_members(
VALUE klass,
VALUE members)
110 const long members_length =
RARRAY_LEN(members);
112 if (members_length <= AREF_HASH_THRESHOLD) {
116 long i, j, mask = 64;
119 while (mask < members_length * AREF_HASH_UNIT) mask *= 2;
125 for (i=0; i < members_length; i++) {
128 j = struct_member_pos_ideal(name, mask);
136 j = struct_member_pos_probe(j, mask);
153 if (UNLIKELY(
NIL_P(back))) {
162 if (mask <= AREF_HASH_THRESHOLD) {
165 "struct size differs (%ld required %ld given)",
168 for (j = 0; j < mask; j++) {
181 j = struct_member_pos_ideal(name, mask);
190 j = struct_member_pos_probe(j, mask);
206 rb_struct_s_members_m(
VALUE klass)
226 rb_struct_members_m(
VALUE obj)
235 int i = struct_member_pos(obj, slot);
239 rb_name_err_raise(
"'%1$s' is not a struct member", obj,
ID2SYM(
id));
245 rb_struct_modify(
VALUE s)
251 anonymous_struct(
VALUE klass)
256 rb_make_metaclass(nstr,
RBASIC(klass)->klass);
267 if (!rb_is_const_name(name)) {
268 rb_name_err_raise(
"identifier %1$s needs to be constant",
273 rb_warn(
"redefining constant %"PRIsVALUE
"::%"PRIsVALUE, super, name);
276 return rb_define_class_id_under_no_pin(super,
id, super);
279 NORETURN(
static void invalid_struct_pos(
VALUE s,
VALUE idx));
284 rb_add_method_optimized(nstr,
SYM2ID(name), OPTIMIZED_METHOD_TYPE_STRUCT_AREF,
FIX2UINT(
off), METHOD_VISI_PUBLIC);
290 rb_add_method_optimized(nstr,
SYM2ID(name), OPTIMIZED_METHOD_TYPE_STRUCT_ASET,
FIX2UINT(
off), METHOD_VISI_PUBLIC);
294 rb_struct_s_inspect(
VALUE klass)
297 if (
RTEST(rb_struct_s_keyword_init(klass))) {
304 rb_data_s_new(
int argc,
const VALUE *argv,
VALUE klass)
308 rb_error_arity(argc, 0, 0);
313 VALUE members = struct_ivar_get(klass, id_members);
317 VALUE arg_hash = rb_hash_new_with_size(argc);
318 for (
long i=0; i<argc; i++) {
344 rb_struct_s_keyword_init_p(
VALUE obj)
349 #define rb_struct_s_keyword_init_p rb_struct_s_keyword_init
356 members = struct_set_members(nstr, members);
366 for (i=0; i<
len; i++) {
371 define_aref_method(nstr, sym,
off);
383 members = struct_set_members(subclass, members);
394 for (i=0; i<
len; i++) {
398 define_aref_method(subclass, sym,
off);
407 return struct_alloc(klass);
411 struct_make_members_list(va_list ar)
414 VALUE ary, list = rb_ident_hash_new();
415 RBASIC_CLEAR_CLASS(list);
416 while ((mem = va_arg(ar,
char*)) != 0) {
417 VALUE sym = rb_sym_intern_ascii_cstr(mem);
418 if (
RTEST(rb_hash_has_key(list, sym))) {
423 ary = rb_hash_keys(list);
424 RBASIC_CLEAR_CLASS(ary);
443 klass = anonymous_struct(super);
446 struct_set_members(klass, members);
465 members = struct_make_members_list(ar);
468 return struct_define_without_accessor(outer, class_name, super, alloc, members);
478 members = struct_make_members_list(ar);
481 return struct_define_without_accessor(0, class_name, super, alloc, members);
491 ary = struct_make_members_list(ar);
499 rb_vm_register_global_object(st);
501 return setup_struct(st, ary);
511 ary = struct_make_members_list(ar);
642 rb_struct_s_def(
int argc,
VALUE *argv,
VALUE klass)
650 if (argc >= 1 && !
SYMBOL_P(argv[0])) {
657 static ID keyword_ids[1];
659 if (!keyword_ids[0]) {
660 keyword_ids[0] =
rb_intern(
"keyword_init");
663 if (UNDEF_P(keyword_init)) {
666 else if (
RTEST(keyword_init)) {
667 keyword_init =
Qtrue;
671 rest = rb_ident_hash_new();
672 RBASIC_CLEAR_CLASS(rest);
673 for (i=0; i<argc; i++) {
675 if (rb_is_attrset_sym(mem)) {
678 if (
RTEST(rb_hash_has_key(rest, mem))) {
683 rest = rb_hash_keys(rest);
684 RBASIC_CLEAR_CLASS(rest);
687 st = anonymous_struct(klass);
690 st = new_struct(name, klass);
692 setup_struct(st, rest);
702 num_members(
VALUE klass)
705 members = struct_ivar_get(klass, id_members);
717 VALUE unknown_keywords;
720 static int rb_struct_pos(
VALUE s,
VALUE *name);
726 int i = rb_struct_pos(args->self, &key);
728 if (
NIL_P(args->unknown_keywords)) {
734 rb_struct_modify(args->self);
741 rb_struct_initialize_m(
int argc,
const VALUE *argv,
VALUE self)
744 rb_struct_modify(
self);
745 long n = num_members(klass);
751 bool keyword_init =
false;
752 switch (rb_struct_s_keyword_init(klass)) {
755 rb_error_arity(argc, 0, 0);
772 arg.unknown_keywords =
Qnil;
774 if (arg.unknown_keywords !=
Qnil) {
783 for (
long i=0; i<argc; i++) {
803 struct_heap_alloc(
VALUE st,
size_t len)
809 struct_alloc(
VALUE klass)
811 long n = num_members(klass);
812 size_t embedded_size = offsetof(
struct RStruct, as.ary) + (
sizeof(
VALUE) * n);
815 if (n > 0 && rb_gc_size_allocatable_p(embedded_size)) {
816 flags |= n << RSTRUCT_EMBED_LEN_SHIFT;
818 NEWOBJ_OF(st,
struct RStruct, klass, flags, embedded_size, 0);
825 NEWOBJ_OF(st,
struct RStruct, klass, flags,
sizeof(
struct RStruct), 0);
827 st->as.heap.ptr = struct_heap_alloc((
VALUE)st, n);
844 VALUE tmpargs[16], *mem = tmpargs;
849 if (size > numberof(tmpargs)) {
853 va_start(args, klass);
854 for (i=0; i<size; i++) {
855 mem[i] = va_arg(args,
VALUE);
891 rb_struct_each(
VALUE s)
926 rb_struct_each_pair(
VALUE s)
933 if (rb_block_pair_yield_optimizable()) {
951 inspect_struct(
VALUE s,
VALUE prefix,
int recur)
959 if (recur || first !=
'#') {
969 for (i=0; i<
len; i++) {
976 else if (first !=
'#') {
1008 rb_struct_inspect(
VALUE s)
1027 rb_struct_to_a(
VALUE s)
1056 rb_struct_to_h(
VALUE s)
1091 rb_struct_deconstruct_keys(
VALUE s,
VALUE keys)
1097 return rb_struct_to_h(s);
1101 "wrong argument type %"PRIsVALUE
" (expected Array or nil)",
1106 return rb_hash_new_with_size(0);
1111 int i = rb_struct_pos(s, &key);
1145 return struct_member_pos(s, idx);
1149 if (
NIL_P(idx))
return -1;
1150 return struct_member_pos(s, idx);
1163 else if (
len <= i) {
1186 rb_name_err_raise(
"no member '%1$s' in struct", s, idx);
1219 int i = rb_struct_pos(s, &idx);
1220 if (i < 0) invalid_struct_pos(s, idx);
1257 int i = rb_struct_pos(s, &idx);
1258 if (i < 0) invalid_struct_pos(s, idx);
1259 rb_struct_modify(s);
1270 return rb_struct_lookup_default(s, idx,
Qnil);
1276 int i = rb_struct_pos(s, &idx);
1277 if (i < 0)
return notfound;
1282 struct_entry(
VALUE s,
long n)
1323 rb_struct_values_at(
int argc,
VALUE *argv,
VALUE s)
1347 rb_struct_select(
int argc,
VALUE *argv,
VALUE s)
1365 recursive_equal(
VALUE s,
VALUE s2,
int recur)
1369 if (recur)
return Qtrue;
1371 for (i=0; i<
len; i++) {
1401 if (s == s2)
return Qtrue;
1405 rb_bug(
"inconsistent struct");
1431 rb_struct_hash(
VALUE s)
1439 for (i = 0; i <
len; i++) {
1452 if (recur)
return Qtrue;
1454 for (i=0; i<
len; i++) {
1482 if (s == s2)
return Qtrue;
1486 rb_bug(
"inconsistent struct");
1543 rb_struct_dig(
int argc,
VALUE *argv,
VALUE self)
1546 self = rb_struct_lookup(
self, *argv);
1547 if (!--argc)
return self;
1549 return rb_obj_dig(argc, argv,
self,
Qnil);
1668 rb_data_s_def(
int argc,
VALUE *argv,
VALUE klass)
1674 rest = rb_ident_hash_new();
1675 RBASIC_CLEAR_CLASS(rest);
1676 for (i=0; i<argc; i++) {
1678 if (rb_is_attrset_sym(mem)) {
1681 if (
RTEST(rb_hash_has_key(rest, mem))) {
1686 rest = rb_hash_keys(rest);
1687 RBASIC_CLEAR_CLASS(rest);
1689 data_class = anonymous_struct(klass);
1690 setup_data(data_class, rest);
1703 va_start(ar, super);
1704 ary = struct_make_members_list(ar);
1706 if (!super) super = rb_cData;
1707 VALUE klass = setup_data(anonymous_struct(super), ary);
1708 rb_vm_register_global_object(klass);
1723 #define rb_data_s_members_m rb_struct_s_members_m
1776 rb_data_initialize_m(
int argc,
const VALUE *argv,
VALUE self)
1779 rb_struct_modify(
self);
1780 VALUE members = struct_ivar_get(klass, id_members);
1784 if (num_members > 0) {
1785 rb_exc_raise(rb_keyword_error_new(
"missing", members));
1790 rb_error_arity(argc, 0, 0);
1794 VALUE missing = rb_ary_diff(members, rb_hash_keys(argv[0]));
1795 rb_exc_raise(rb_keyword_error_new(
"missing", missing));
1801 arg.unknown_keywords =
Qnil;
1806 if (arg.unknown_keywords !=
Qnil) {
1807 rb_exc_raise(rb_keyword_error_new(
"unknown", arg.unknown_keywords));
1816 copy = rb_struct_init_copy(copy, s);
1852 rb_data_with(
int argc,
const VALUE *argv,
VALUE self)
1856 if (
NIL_P(kwargs)) {
1860 VALUE h = rb_struct_to_h(
self);
1885 rb_data_inspect(
VALUE s)
1911 #define rb_data_equal rb_struct_equal
1931 #define rb_data_eql rb_struct_eql
1955 #define rb_data_hash rb_struct_hash
1985 #define rb_data_to_h rb_struct_to_h
2000 #define rb_data_members_m rb_struct_members_m
2031 #define rb_data_deconstruct rb_struct_to_a
2063 #define rb_data_deconstruct_keys rb_struct_deconstruct_keys
2237 rb_define_method(rb_cData,
"deconstruct_keys", rb_data_deconstruct_keys, 1);
2247 id_back_members =
rb_intern(
"__members_back__");
2248 id_keyword_init =
rb_intern(
"__keyword_init__");
#define RUBY_ASSERT(...)
Asserts that the given expression is truthy if and only if RUBY_DEBUG is truthy.
#define rb_define_singleton_method(klass, mid, func, arity)
Defines klass.mid.
#define RB_OBJ_FREEZE
Just another name of rb_obj_freeze_inline.
void rb_include_module(VALUE klass, VALUE module)
Includes a module to a class.
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
VALUE rb_class_new(VALUE super)
Creates a new, anonymous class.
VALUE rb_singleton_class(VALUE obj)
Finds or creates the singleton class of the passed object.
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
VALUE rb_define_class_id_under(VALUE outer, ID id, VALUE super)
Identical to rb_define_class_under(), except it takes the name in ID instead of C's string.
VALUE rb_class_inherited(VALUE super, VALUE klass)
Calls Class::inherited.
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
void rb_undef_method(VALUE klass, const char *name)
Defines an undef of a method.
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
Retrieves argument from argc and argv to given VALUE references according to the format string.
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a method.
int rb_keyword_given_p(void)
Determines if the current method is given a keyword argument.
int rb_block_given_p(void)
Determines if the current method is given a block.
int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *values)
Keyword argument deconstructor.
#define rb_str_new2
Old name of rb_str_new_cstr.
#define OBJ_INIT_COPY(obj, orig)
Old name of RB_OBJ_INIT_COPY.
#define T_STRING
Old name of RUBY_T_STRING.
#define INT2FIX
Old name of RB_INT2FIX.
#define ID2SYM
Old name of RB_ID2SYM.
#define T_STRUCT
Old name of RUBY_T_STRUCT.
#define OBJ_FREEZE
Old name of RB_OBJ_FREEZE.
#define UNREACHABLE_RETURN
Old name of RBIMPL_UNREACHABLE_RETURN.
#define SYM2ID
Old name of RB_SYM2ID.
#define FIX2UINT
Old name of RB_FIX2UINT.
#define CLASS_OF
Old name of rb_class_of.
#define rb_ary_new4
Old name of rb_ary_new_from_values.
#define LONG2FIX
Old name of RB_INT2FIX.
#define FIX2INT
Old name of RB_FIX2INT.
#define T_HASH
Old name of RUBY_T_HASH.
#define ALLOC_N
Old name of RB_ALLOC_N.
#define LONG2NUM
Old name of RB_LONG2NUM.
#define Qtrue
Old name of RUBY_Qtrue.
#define ST2FIX
Old name of RB_ST2FIX.
#define Qnil
Old name of RUBY_Qnil.
#define Qfalse
Old name of RUBY_Qfalse.
#define T_ARRAY
Old name of RUBY_T_ARRAY.
#define NIL_P
Old name of RB_NIL_P.
#define FL_WB_PROTECTED
Old name of RUBY_FL_WB_PROTECTED.
#define T_CLASS
Old name of RUBY_T_CLASS.
#define NUM2LONG
Old name of RB_NUM2LONG.
#define FIXNUM_P
Old name of RB_FIXNUM_P.
#define SYMBOL_P
Old name of RB_SYMBOL_P.
void rb_raise(VALUE exc, const char *fmt,...)
Exception entry point.
void rb_exc_raise(VALUE mesg)
Raises an exception in the current thread.
void rb_bug(const char *fmt,...)
Interpreter panic switch.
VALUE rb_eTypeError
TypeError exception.
void rb_warn(const char *fmt,...)
Identical to rb_warning(), except it reports unless $VERBOSE is nil.
VALUE rb_eArgError
ArgumentError exception.
VALUE rb_eIndexError
IndexError exception.
VALUE rb_class_superclass(VALUE klass)
Queries the parent of the given class.
VALUE rb_class_new_instance(int argc, const VALUE *argv, VALUE klass)
Allocates, then initialises an instance of the given class.
VALUE rb_class_new_instance_kw(int argc, const VALUE *argv, VALUE klass, int kw_splat)
Identical to rb_class_new_instance(), except you can specify how to handle the last element of the gi...
VALUE rb_mEnumerable
Enumerable module.
VALUE rb_cStruct
Struct class.
VALUE rb_class_new_instance_pass_kw(int argc, const VALUE *argv, VALUE klass)
Identical to rb_class_new_instance(), except it passes the passed keywords if any to the #initialize ...
int rb_eql(VALUE lhs, VALUE rhs)
Checks for equality of the passed objects, in terms of Object#eql?.
VALUE rb_obj_class(VALUE obj)
Queries the class of an object.
VALUE rb_inspect(VALUE obj)
Generates a human-readable textual representation of the given object.
VALUE rb_equal(VALUE lhs, VALUE rhs)
This function is an optimised version of calling #==.
VALUE rb_obj_is_kind_of(VALUE obj, VALUE klass)
Queries if the given object is an instance (of possibly descendants) of the given class.
#define RGENGC_WB_PROTECTED_STRUCT
This is a compile-time flag to enable/disable write barrier for struct RStruct.
Defines RBIMPL_HAS_BUILTIN.
VALUE rb_ary_dup(VALUE ary)
Duplicates an array.
VALUE rb_get_values_at(VALUE obj, long olen, int argc, const VALUE *argv, VALUE(*func)(VALUE obj, long oidx))
This was a generalisation of Array#values_at, Struct#values_at, and MatchData#values_at.
VALUE rb_ary_new(void)
Allocates a new, empty array.
VALUE rb_ary_hidden_new(long capa)
Allocates a hidden (no class) empty array.
VALUE rb_ary_push(VALUE ary, VALUE elem)
Special case of rb_ary_cat() that it adds only one element.
VALUE rb_ary_entry(VALUE ary, long off)
Queries an element of an array.
VALUE rb_assoc_new(VALUE car, VALUE cdr)
Identical to rb_ary_new_from_values(), except it expects exactly two parameters.
void rb_mem_clear(VALUE *buf, long len)
Fills the memory region with a series of RUBY_Qnil.
VALUE rb_ary_join(VALUE ary, VALUE sep)
Recursively stringises the elements of the passed array, flattens that result, then joins the sequenc...
void rb_ary_store(VALUE ary, long key, VALUE val)
Destructively stores the passed value to the passed array's passed index.
#define RETURN_SIZED_ENUMERATOR(obj, argc, argv, size_fn)
This roughly resembles return enum_for(__callee__) unless block_given?.
#define UNLIMITED_ARGUMENTS
This macro is used in conjunction with rb_check_arity().
static int rb_check_arity(int argc, int min, int max)
Ensures that the passed integer is in the passed range.
void rb_hash_foreach(VALUE hash, int(*func)(VALUE key, VALUE val, VALUE arg), VALUE arg)
Iterates over a hash.
VALUE rb_hash_update_by(VALUE hash1, VALUE hash2, rb_hash_update_func *func)
Destructively merges two hash tables into one.
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
Inserts or replaces ("upsert"s) the objects into the given hash table.
VALUE rb_hash(VALUE obj)
Calculates a message authentication code of the passed object.
int rb_is_const_id(ID id)
Classifies the given ID, then sees if it is a constant.
ID rb_id_attrset(ID id)
Calculates an ID of attribute writer.
int rb_is_local_id(ID id)
Classifies the given ID, then sees if it is a local variable.
#define rb_hash_uint(h, i)
Just another name of st_hash_uint.
#define rb_hash_end(h)
Just another name of st_hash_end.
VALUE rb_str_append(VALUE dst, VALUE src)
Identical to rb_str_buf_append(), except it converts the right hand side before concatenating.
VALUE rb_str_cat2(VALUE, const char *)
Just another name of rb_str_cat_cstr.
st_index_t rb_hash_start(st_index_t i)
Starts a series of hashing.
VALUE rb_str_cat_cstr(VALUE dst, const char *src)
Identical to rb_str_cat(), except it assumes the passed pointer is a pointer to a C string.
VALUE rb_struct_define_without_accessor_under(VALUE outer, const char *class_name, VALUE super, rb_alloc_func_t alloc,...)
Identical to rb_struct_define_without_accessor(), except it defines the class under the specified nam...
VALUE rb_struct_define_under(VALUE space, const char *name,...)
Identical to rb_struct_define(), except it defines the class under the specified namespace instead of...
VALUE rb_struct_new(VALUE klass,...)
Creates an instance of the given struct.
VALUE rb_struct_initialize(VALUE self, VALUE values)
Mass-assigns a struct's fields.
VALUE rb_struct_define_without_accessor(const char *name, VALUE super, rb_alloc_func_t func,...)
Identical to rb_struct_define(), except it does not define accessor methods.
VALUE rb_struct_define(const char *name,...)
Defines a struct class.
VALUE rb_struct_alloc(VALUE klass, VALUE values)
Identical to rb_struct_new(), except it takes the field values as a Ruby array.
VALUE rb_data_define(VALUE super,...)
Defines an anonymous data class.
VALUE rb_struct_alloc_noinit(VALUE klass)
Allocates an instance of the given class.
VALUE rb_struct_s_members(VALUE klass)
Queries the list of the names of the fields of the given struct class.
VALUE rb_struct_members(VALUE self)
Queries the list of the names of the fields of the class of the given struct object.
VALUE rb_struct_getmember(VALUE self, ID key)
Identical to rb_struct_aref(), except it takes ID instead of VALUE.
VALUE rb_exec_recursive(VALUE(*f)(VALUE g, VALUE h, int r), VALUE g, VALUE h)
"Recursion" API entry point.
VALUE rb_exec_recursive_paired(VALUE(*f)(VALUE g, VALUE h, int r), VALUE g, VALUE p, VALUE h)
Identical to rb_exec_recursive(), except it checks for the recursion on the ordered pair of { g,...
VALUE rb_attr_get(VALUE obj, ID name)
Identical to rb_ivar_get()
VALUE rb_ivar_set(VALUE obj, ID name, VALUE val)
Identical to rb_iv_set(), except it accepts the name as an ID instead of a C string.
VALUE rb_mod_remove_const(VALUE space, VALUE name)
Resembles Module#remove_const.
VALUE rb_class_name(VALUE obj)
Queries the name of the given object's class.
int rb_const_defined_at(VALUE space, ID name)
Identical to rb_const_defined(), except it doesn't look for parent classes.
VALUE rb_class_path(VALUE mod)
Identical to rb_mod_name(), except it returns #<Class: ...> style inspection for anonymous modules.
VALUE(* rb_alloc_func_t)(VALUE klass)
This is the type of functions that ruby calls when trying to allocate an object.
void rb_undef_alloc_func(VALUE klass)
Deletes the allocator function of a class.
VALUE rb_mod_module_eval(int argc, const VALUE *argv, VALUE mod)
Identical to rb_obj_instance_eval(), except it evaluates within the context of module.
void rb_define_alloc_func(VALUE klass, rb_alloc_func_t func)
Sets the allocator function of a class.
VALUE rb_check_symbol(volatile VALUE *namep)
Identical to rb_check_id(), except it returns an instance of rb_cSymbol instead.
ID rb_intern(const char *name)
Finds or creates a symbol of the given name.
VALUE rb_to_symbol(VALUE name)
Identical to rb_intern_str(), except it generates a dynamic symbol if necessary.
ID rb_to_id(VALUE str)
Identical to rb_intern(), except it takes an instance of rb_cString.
VALUE rb_id2str(ID id)
Identical to rb_id2name(), except it returns a Ruby's String instead of C's.
int off
Offset inside of ptr.
int len
Length of the buffer.
VALUE rb_yield_values(int n,...)
Identical to rb_yield(), except it takes variadic number of parameters and pass them to the block.
VALUE rb_yield(VALUE val)
Yields the block.
#define rb_long2int
Just another name of rb_long2int_inline.
#define RB_GC_GUARD(v)
Prevents premature destruction of local objects.
static VALUE * RARRAY_PTR(VALUE ary)
Wild use of a C pointer.
#define RARRAY_LEN
Just another name of rb_array_len.
static int RARRAY_LENINT(VALUE ary)
Identical to rb_array_len(), except it differs for the return type.
#define RARRAY_AREF(a, i)
#define RARRAY_CONST_PTR
Just another name of rb_array_const_ptr.
#define RBASIC(obj)
Convenient casting macro.
#define RHASH_SIZE(h)
Queries the size of the hash.
static char * RSTRING_PTR(VALUE str)
Queries the contents pointer of the string.
VALUE rb_str_to_str(VALUE obj)
Identical to rb_check_string_type(), except it raises exceptions in case of conversion failures.
static long RSTRUCT_LEN(VALUE st)
Returns the number of struct members.
static VALUE RSTRUCT_SET(VALUE st, int k, VALUE v)
Resembles Struct#[]=.
static VALUE RSTRUCT_GET(VALUE st, int k)
Resembles Struct#[].
VALUE rb_struct_aset(VALUE st, VALUE k, VALUE v)
Resembles Struct#[]=.
VALUE rb_struct_size(VALUE st)
Returns the number of struct members.
VALUE rb_struct_aref(VALUE st, VALUE k)
Resembles Struct#[].
#define InitVM(ext)
This macro is for internal use.
#define RB_PASS_KEYWORDS
Pass keywords, final argument should be a hash of keywords.
#define RTEST
This is an old name of RB_TEST.
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
uintptr_t VALUE
Type that represents a Ruby object.
static bool RB_TYPE_P(VALUE obj, enum ruby_value_type t)
Queries if the given object is of given type.