#include "ruby/ruby.h"#include "internal.h"Go to the source code of this file.
Defines | |
| #define | numberof(array) (int)(sizeof(array) / sizeof((array)[0])) |
| #define | N_REF_FUNC numberof(ref_func) |
Functions | |
| static VALUE | struct_alloc (VALUE) |
| static VALUE | struct_ivar_get (VALUE c, ID id) |
| VALUE | rb_struct_iv_get (VALUE c, const char *name) |
| VALUE | rb_struct_s_members (VALUE klass) |
| VALUE | rb_struct_members (VALUE s) |
| static VALUE | rb_struct_s_members_m (VALUE klass) |
| static VALUE | rb_struct_members_m (VALUE obj) |
| NORETURN (static void not_a_member(ID id)) | |
| static void | not_a_member (ID id) |
| VALUE | rb_struct_getmember (VALUE obj, ID id) |
| static VALUE | rb_struct_ref (VALUE obj) |
| static VALUE | rb_struct_ref0 (VALUE obj) |
| static VALUE | rb_struct_ref1 (VALUE obj) |
| static VALUE | rb_struct_ref2 (VALUE obj) |
| static VALUE | rb_struct_ref3 (VALUE obj) |
| static VALUE | rb_struct_ref4 (VALUE obj) |
| static VALUE | rb_struct_ref5 (VALUE obj) |
| static VALUE | rb_struct_ref6 (VALUE obj) |
| static VALUE | rb_struct_ref7 (VALUE obj) |
| static VALUE | rb_struct_ref8 (VALUE obj) |
| static VALUE | rb_struct_ref9 (VALUE obj) |
| static void | rb_struct_modify (VALUE s) |
| static VALUE | rb_struct_set (VALUE obj, VALUE val) |
| static VALUE | anonymous_struct (VALUE klass) |
| static VALUE | new_struct (VALUE name, VALUE super) |
| static VALUE | setup_struct (VALUE nstr, VALUE members) |
| VALUE | rb_struct_alloc_noinit (VALUE klass) |
| VALUE | rb_struct_define_without_accessor (const char *class_name, VALUE super, rb_alloc_func_t alloc,...) |
| VALUE | rb_struct_define (const char *name,...) |
| static VALUE | rb_struct_s_def (int argc, VALUE *argv, VALUE klass) |
| static long | num_members (VALUE klass) |
| static VALUE | rb_struct_initialize_m (int argc, VALUE *argv, VALUE self) |
| VALUE | rb_struct_initialize (VALUE self, VALUE values) |
| VALUE | rb_struct_alloc (VALUE klass, VALUE values) |
| VALUE | rb_struct_new (VALUE klass,...) |
| static VALUE | rb_struct_size (VALUE s) |
| static VALUE | rb_struct_each (VALUE s) |
| static VALUE | rb_struct_each_pair (VALUE s) |
| static VALUE | inspect_struct (VALUE s, VALUE dummy, int recur) |
| static VALUE | rb_struct_inspect (VALUE s) |
| static VALUE | rb_struct_to_a (VALUE s) |
| static VALUE | rb_struct_to_h (VALUE s) |
| VALUE | rb_struct_init_copy (VALUE copy, VALUE s) |
| static VALUE | rb_struct_aref_id (VALUE s, ID id) |
| VALUE | rb_struct_aref (VALUE s, VALUE idx) |
| static VALUE | rb_struct_aset_id (VALUE s, ID id, VALUE val) |
| VALUE | rb_struct_aset (VALUE s, VALUE idx, VALUE val) |
| static VALUE | struct_entry (VALUE s, long n) |
| static VALUE | rb_struct_values_at (int argc, VALUE *argv, VALUE s) |
| static VALUE | rb_struct_select (int argc, VALUE *argv, VALUE s) |
| static VALUE | recursive_equal (VALUE s, VALUE s2, int recur) |
| static VALUE | rb_struct_equal (VALUE s, VALUE s2) |
| static VALUE | recursive_hash (VALUE s, VALUE dummy, int recur) |
| static VALUE | rb_struct_hash (VALUE s) |
| static VALUE | recursive_eql (VALUE s, VALUE s2, int recur) |
| static VALUE | rb_struct_eql (VALUE s, VALUE s2) |
| void | Init_Struct (void) |
Variables | |
| VALUE | rb_cStruct |
| static ID | id_members |
| static VALUE(*const | ref_func [])(VALUE) |
| #define N_REF_FUNC numberof(ref_func) |
Definition at line 136 of file struct.c.
Referenced by rb_struct_new(), and setup_struct().
| #define numberof | ( | array | ) | (int)(sizeof(array) / sizeof((array)[0])) |
| static VALUE anonymous_struct | ( | VALUE | klass | ) | [static] |
Definition at line 182 of file struct.c.
References rb_class_inherited(), rb_class_new(), rb_make_metaclass(), and RBASIC.
Referenced by rb_struct_define(), rb_struct_define_without_accessor(), and rb_struct_s_def().
| void Init_Struct | ( | void | ) |
Definition at line 1014 of file struct.c.
References id_members, rb_cObject, rb_cStruct, rb_define_alias(), rb_define_class(), rb_define_method(), rb_define_singleton_method(), rb_include_module(), rb_intern, rb_mEnumerable, rb_struct_aref(), rb_struct_aset(), rb_struct_each(), rb_struct_each_pair(), rb_struct_eql(), rb_struct_equal(), rb_struct_hash(), rb_struct_init_copy(), rb_struct_initialize_m(), rb_struct_inspect(), rb_struct_members_m(), rb_struct_s_def(), rb_struct_select(), rb_struct_size(), rb_struct_to_a(), rb_struct_to_h(), rb_struct_values_at(), and rb_undef_alloc_func().
| static VALUE inspect_struct | ( | VALUE | s, | |
| VALUE | dummy, | |||
| int | recur | |||
| ) | [static] |
Definition at line 542 of file struct.c.
References id, OBJ_INFECT, RARRAY_PTR, rb_class_name(), rb_id2str(), rb_inspect(), rb_is_const_id(), rb_is_local_id(), rb_obj_class(), rb_str_append(), rb_str_cat2(), rb_str_new2, rb_struct_members(), RSTRING_PTR, RSTRUCT_LEN, RSTRUCT_PTR, and SYM2ID.
Referenced by rb_struct_inspect().
| static VALUE new_struct | ( | VALUE | name, | |
| VALUE | super | |||
| ) | [static] |
Definition at line 193 of file struct.c.
References id, ID2SYM, PRIsVALUE, QUOTE, rb_const_defined_at(), rb_define_class_id_under(), rb_is_const_name(), rb_mod_remove_const(), rb_name_error_str(), rb_str_to_str(), rb_to_id(), and rb_warn().
Referenced by rb_struct_define(), and rb_struct_s_def().
| NORETURN | ( | static void | not_a_memberID id | ) |
| static void not_a_member | ( | ID | id | ) | [static] |
Definition at line 92 of file struct.c.
References PRIsVALUE, QUOTE_ID, and rb_name_error().
Referenced by rb_struct_getmember(), and rb_struct_set().
| static long num_members | ( | VALUE | klass | ) | [static] |
Definition at line 382 of file struct.c.
References id_members, RARRAY_LEN, rb_eTypeError, rb_raise(), RB_TYPE_P, struct_ivar_get(), and T_ARRAY.
Referenced by rb_struct_initialize_m(), rb_struct_new(), and struct_alloc().
| VALUE rb_struct_alloc | ( | VALUE | klass, | |
| VALUE | values | |||
| ) |
Definition at line 442 of file struct.c.
References RARRAY_LENINT, RARRAY_PTR, and rb_class_new_instance().
| VALUE rb_struct_alloc_noinit | ( | VALUE | klass | ) |
| VALUE rb_struct_aref | ( | VALUE | s, | |
| VALUE | idx | |||
| ) |
Definition at line 698 of file struct.c.
References NUM2LONG, PRIsVALUE, QUOTE, rb_check_id(), rb_eIndexError, rb_name_error_str(), rb_raise(), rb_struct_aref_id(), RB_TYPE_P, RSTRUCT_LEN, RSTRUCT_PTR, SYM2ID, T_STRING, and T_SYMBOL.
Referenced by Init_Struct(), and struct_entry().
| static VALUE rb_struct_aref_id | ( | VALUE | s, | |
| ID | id | |||
| ) | [static] |
Definition at line 659 of file struct.c.
References RARRAY_LEN, RARRAY_PTR, rb_id2name(), rb_name_error(), rb_struct_members(), RSTRUCT_PTR, SYM2ID, and UNREACHABLE.
Referenced by rb_struct_aref().
| VALUE rb_struct_aset | ( | VALUE | s, | |
| VALUE | idx, | |||
| VALUE | val | |||
| ) |
Definition at line 773 of file struct.c.
References NUM2LONG, PRIsVALUE, QUOTE, rb_check_id(), rb_eIndexError, rb_name_error_str(), rb_raise(), rb_struct_aset_id(), rb_struct_modify(), RB_TYPE_P, RSTRUCT_LEN, RSTRUCT_PTR, SYM2ID, T_STRING, and T_SYMBOL.
Referenced by Init_Struct().
| static VALUE rb_struct_aset_id | ( | VALUE | s, | |
| ID | id, | |||
| VALUE | val | |||
| ) | [static] |
Definition at line 726 of file struct.c.
References RARRAY_LEN, RARRAY_PTR, rb_eTypeError, rb_id2name(), rb_name_error(), rb_raise(), rb_struct_members(), rb_struct_modify(), RSTRUCT_LEN, RSTRUCT_PTR, SYM2ID, and UNREACHABLE.
Referenced by rb_struct_aset().
| VALUE rb_struct_define | ( | const char * | name, | |
| ... | ||||
| ) |
Definition at line 279 of file struct.c.
References anonymous_struct(), ID2SYM, new_struct(), rb_ary_push(), rb_ary_tmp_new(), rb_cStruct, rb_intern, rb_str_new2, and setup_struct().
Referenced by Init_etc(), and Init_process().
| VALUE rb_struct_define_without_accessor | ( | const char * | class_name, | |
| VALUE | super, | |||
| rb_alloc_func_t | alloc, | |||
| ... | ||||
| ) |
Definition at line 246 of file struct.c.
References anonymous_struct(), ID2SYM, id_members, name, NULL, OBJ_FREEZE, rb_ary_push(), rb_ary_tmp_new(), rb_define_alloc_func(), rb_define_class(), rb_intern, rb_ivar_set(), and struct_alloc().
Referenced by Init_Range().
| static VALUE rb_struct_each | ( | VALUE | s | ) | [static] |
Definition at line 493 of file struct.c.
References rb_struct_size(), rb_yield(), RETURN_SIZED_ENUMERATOR, RSTRUCT_LEN, and RSTRUCT_PTR.
Referenced by Init_Struct().
| static VALUE rb_struct_each_pair | ( | VALUE | s | ) | [static] |
Definition at line 526 of file struct.c.
References key, rb_ary_entry(), rb_assoc_new(), rb_struct_members(), rb_struct_size(), rb_yield(), RETURN_SIZED_ENUMERATOR, RSTRUCT_LEN, and RSTRUCT_PTR.
Referenced by Init_Struct().
| static VALUE rb_struct_eql | ( | VALUE | s, | |
| VALUE | s2 | |||
| ) | [static] |
Definition at line 968 of file struct.c.
References Qfalse, Qtrue, rb_bug(), rb_exec_recursive_paired(), rb_obj_class(), RB_TYPE_P, recursive_eql(), RSTRUCT_LEN, and T_STRUCT.
Referenced by Init_Struct().
| static VALUE rb_struct_equal | ( | VALUE | s, | |
| VALUE | s2 | |||
| ) | [static] |
Definition at line 898 of file struct.c.
References Qfalse, Qtrue, rb_bug(), rb_exec_recursive_paired(), rb_obj_class(), RB_TYPE_P, recursive_equal(), RSTRUCT_LEN, and T_STRUCT.
Referenced by Init_Struct().
| VALUE rb_struct_getmember | ( | VALUE | obj, | |
| ID | id | |||
| ) |
Definition at line 98 of file struct.c.
References ID2SYM, not_a_member(), RARRAY_LEN, RARRAY_PTR, rb_struct_members(), RSTRUCT_PTR, and UNREACHABLE.
Referenced by rb_struct_ref().
| static VALUE rb_struct_hash | ( | VALUE | s | ) | [static] |
Definition at line 938 of file struct.c.
References rb_exec_recursive_outer(), and recursive_hash().
Referenced by Init_Struct().
| VALUE rb_struct_init_copy | ( | VALUE | copy, | |
| VALUE | s | |||
| ) |
Definition at line 647 of file struct.c.
References MEMCPY, OBJ_INIT_COPY, rb_eTypeError, rb_raise(), RSTRUCT_LEN, and RSTRUCT_PTR.
Referenced by Init_Struct().
| VALUE rb_struct_initialize | ( | VALUE | self, | |
| VALUE | values | |||
| ) |
Definition at line 414 of file struct.c.
References RARRAY_LENINT, RARRAY_PTR, and rb_struct_initialize_m().
Referenced by r_object0().
| static VALUE rb_struct_initialize_m | ( | int | argc, | |
| VALUE * | argv, | |||
| VALUE | self | |||
| ) | [static] |
Definition at line 396 of file struct.c.
References MEMCPY, num_members(), Qnil, rb_eArgError, rb_mem_clear(), rb_obj_class(), rb_raise(), rb_struct_modify(), and RSTRUCT_PTR.
Referenced by Init_Struct(), and rb_struct_initialize().
| static VALUE rb_struct_inspect | ( | VALUE | s | ) | [static] |
Definition at line 597 of file struct.c.
References inspect_struct(), and rb_exec_recursive().
Referenced by Init_Struct().
| VALUE rb_struct_iv_get | ( | VALUE | c, | |
| const char * | name | |||
| ) |
Definition at line 33 of file struct.c.
References rb_intern, and struct_ivar_get().
| VALUE rb_struct_members | ( | VALUE | s | ) |
Definition at line 53 of file struct.c.
References RARRAY_LEN, rb_eTypeError, rb_obj_class(), rb_raise(), rb_struct_s_members(), and RSTRUCT_LEN.
Referenced by inspect_struct(), rb_struct_aref_id(), rb_struct_aset_id(), rb_struct_each_pair(), rb_struct_getmember(), rb_struct_set(), rb_struct_to_h(), and w_object().
| static VALUE rb_struct_members_m | ( | VALUE | obj | ) | [static] |
Definition at line 85 of file struct.c.
References rb_obj_class(), and rb_struct_s_members_m().
Referenced by Init_Struct().
| static void rb_struct_modify | ( | VALUE | s | ) | [static] |
Definition at line 152 of file struct.c.
References rb_check_frozen, and rb_check_trusted.
Referenced by rb_struct_aset(), rb_struct_aset_id(), rb_struct_initialize_m(), and rb_struct_set().
| VALUE rb_struct_new | ( | VALUE | klass, | |
| ... | ||||
| ) |
Definition at line 448 of file struct.c.
References args, N_REF_FUNC, num_members(), numberof, RARRAY_PTR, rb_ary_tmp_new(), rb_class_new_instance(), rb_long2int, and size.
| static VALUE rb_struct_ref | ( | VALUE | obj | ) | [static] |
Definition at line 119 of file struct.c.
References rb_frame_this_func(), and rb_struct_getmember().
Referenced by setup_struct().
| static VALUE rb_struct_ref0 | ( | VALUE | obj | ) | [static] |
Definition at line 124 of file struct.c.
References RSTRUCT_PTR.
| static VALUE rb_struct_ref1 | ( | VALUE | obj | ) | [static] |
Definition at line 125 of file struct.c.
References RSTRUCT_PTR.
| static VALUE rb_struct_ref2 | ( | VALUE | obj | ) | [static] |
Definition at line 126 of file struct.c.
References RSTRUCT_PTR.
| static VALUE rb_struct_ref3 | ( | VALUE | obj | ) | [static] |
Definition at line 127 of file struct.c.
References RSTRUCT_PTR.
| static VALUE rb_struct_ref4 | ( | VALUE | obj | ) | [static] |
Definition at line 128 of file struct.c.
References RSTRUCT_PTR.
| static VALUE rb_struct_ref5 | ( | VALUE | obj | ) | [static] |
Definition at line 129 of file struct.c.
References RSTRUCT_PTR.
| static VALUE rb_struct_ref6 | ( | VALUE | obj | ) | [static] |
Definition at line 130 of file struct.c.
References RSTRUCT_PTR.
| static VALUE rb_struct_ref7 | ( | VALUE | obj | ) | [static] |
Definition at line 131 of file struct.c.
References RSTRUCT_PTR.
| static VALUE rb_struct_ref8 | ( | VALUE | obj | ) | [static] |
Definition at line 132 of file struct.c.
References RSTRUCT_PTR.
| static VALUE rb_struct_ref9 | ( | VALUE | obj | ) | [static] |
Definition at line 133 of file struct.c.
References RSTRUCT_PTR.
| static VALUE rb_struct_s_def | ( | int | argc, | |
| VALUE * | argv, | |||
| VALUE | klass | |||
| ) | [static] |
Definition at line 345 of file struct.c.
References anonymous_struct(), id, ID2SYM, name, new_struct(), NIL_P, Qnil, RARRAY_PTR, rb_ary_set_len(), rb_ary_tmp_new(), rb_block_given_p(), rb_check_arity, rb_mod_module_eval(), rb_to_id(), setup_struct(), SYMBOL_P, and UNLIMITED_ARGUMENTS.
Referenced by Init_Struct().
| VALUE rb_struct_s_members | ( | VALUE | klass | ) |
Definition at line 39 of file struct.c.
References id_members, NIL_P, rb_eTypeError, rb_raise(), RB_TYPE_P, struct_ivar_get(), and T_ARRAY.
Referenced by r_object0(), rb_struct_members(), and rb_struct_s_members_m().
| static VALUE rb_struct_s_members_m | ( | VALUE | klass | ) | [static] |
Definition at line 65 of file struct.c.
References rb_ary_dup(), and rb_struct_s_members().
Referenced by rb_struct_members_m(), and setup_struct().
| static VALUE rb_struct_select | ( | int | argc, | |
| VALUE * | argv, | |||
| VALUE | s | |||
| ) | [static] |
Definition at line 847 of file struct.c.
References rb_ary_new(), rb_ary_push(), rb_check_arity, rb_struct_size(), rb_yield(), result, RETURN_SIZED_ENUMERATOR, RSTRUCT_LEN, RSTRUCT_PTR, and RTEST.
Referenced by Init_Struct().
| static VALUE rb_struct_set | ( | VALUE | obj, | |
| VALUE | val | |||
| ) | [static] |
Definition at line 159 of file struct.c.
References not_a_member(), RARRAY_LEN, RARRAY_PTR, rb_frame_this_func(), rb_id_attrset(), rb_struct_members(), rb_struct_modify(), RSTRUCT_PTR, SYM2ID, and UNREACHABLE.
Referenced by setup_struct().
| static VALUE rb_struct_size | ( | VALUE | s | ) | [static] |
Definition at line 993 of file struct.c.
References LONG2FIX, and RSTRUCT_LEN.
Referenced by Init_Struct(), rb_struct_each(), rb_struct_each_pair(), and rb_struct_select().
| static VALUE rb_struct_to_a | ( | VALUE | s | ) | [static] |
Definition at line 615 of file struct.c.
References rb_ary_new4(), RSTRUCT_LEN, and RSTRUCT_PTR.
Referenced by Init_Struct().
| static VALUE rb_struct_to_h | ( | VALUE | s | ) | [static] |
Definition at line 633 of file struct.c.
References rb_ary_entry(), rb_hash_new(), rb_struct_members(), RSTRUCT_LEN, and RSTRUCT_PTR.
Referenced by Init_Struct().
| static VALUE rb_struct_values_at | ( | int | argc, | |
| VALUE * | argv, | |||
| VALUE | s | |||
| ) | [static] |
Definition at line 826 of file struct.c.
References rb_get_values_at(), RSTRUCT_LEN, and struct_entry().
Referenced by Init_Struct().
| static VALUE recursive_eql | ( | VALUE | s, | |
| VALUE | s2, | |||
| int | recur | |||
| ) | [static] |
Definition at line 944 of file struct.c.
References Qfalse, Qtrue, rb_eql(), RSTRUCT_LEN, and RSTRUCT_PTR.
Referenced by rb_struct_eql().
| static VALUE recursive_equal | ( | VALUE | s, | |
| VALUE | s2, | |||
| int | recur | |||
| ) | [static] |
Definition at line 865 of file struct.c.
References Qfalse, Qtrue, rb_equal(), RSTRUCT_LEN, and RSTRUCT_PTR.
Referenced by rb_struct_equal().
| static VALUE recursive_hash | ( | VALUE | s, | |
| VALUE | dummy, | |||
| int | recur | |||
| ) | [static] |
Definition at line 911 of file struct.c.
References INT2FIX, NUM2LONG, rb_hash(), rb_hash_end, rb_hash_start(), rb_hash_uint, rb_obj_class(), RSTRUCT_LEN, and RSTRUCT_PTR.
Referenced by rb_struct_hash().
| static VALUE setup_struct | ( | VALUE | nstr, | |
| VALUE | members | |||
| ) | [static] |
Definition at line 211 of file struct.c.
References id_members, N_REF_FUNC, OBJ_FREEZE, RARRAY_LEN, RARRAY_PTR, rb_class_new_instance(), rb_define_alloc_func(), rb_define_method_id(), rb_define_singleton_method(), rb_id_attrset(), rb_ivar_set(), rb_struct_ref(), rb_struct_s_members_m(), rb_struct_set(), ref_func, struct_alloc(), and SYM2ID.
Referenced by rb_struct_define(), and rb_struct_s_def().
| static VALUE struct_alloc | ( | VALUE | klass | ) | [static] |
Definition at line 420 of file struct.c.
References ALLOC_N, NEWOBJ_OF, num_members(), rb_mem_clear(), RBASIC, RSTRUCT_EMBED_LEN_MASK, RSTRUCT_EMBED_LEN_MAX, RSTRUCT_EMBED_LEN_SHIFT, and T_STRUCT.
Referenced by rb_struct_alloc_noinit(), rb_struct_define_without_accessor(), and setup_struct().
| static VALUE struct_entry | ( | VALUE | s, | |
| long | n | |||
| ) | [static] |
Definition at line 804 of file struct.c.
References LONG2NUM, and rb_struct_aref().
Referenced by rb_struct_values_at().
| static VALUE struct_ivar_get | ( | VALUE | c, | |
| ID | id | |||
| ) | [inline, static] |
Definition at line 21 of file struct.c.
References Qnil, rb_cStruct, rb_ivar_defined(), rb_ivar_get(), and RCLASS_SUPER.
Referenced by num_members(), rb_struct_iv_get(), and rb_struct_s_members().
ID id_members [static] |
Definition at line 16 of file struct.c.
Referenced by Init_Struct(), num_members(), rb_struct_define_without_accessor(), rb_struct_s_members(), and setup_struct().
| VALUE rb_cStruct |
Definition at line 15 of file struct.c.
Referenced by Init_Struct(), rb_struct_define(), and struct_ivar_get().
VALUE(*const ref_func[])(VALUE) [static] |
{
rb_struct_ref0,
rb_struct_ref1,
rb_struct_ref2,
rb_struct_ref3,
rb_struct_ref4,
rb_struct_ref5,
rb_struct_ref6,
rb_struct_ref7,
rb_struct_ref8,
rb_struct_ref9,
}
Referenced by setup_struct().
1.6.1