Ruby  2.1.10p492(2016-04-01revision54464)
Macros | Functions | Variables
struct.c File Reference
#include "ruby/ruby.h"
#include "internal.h"

Go to the source code of this file.

Macros

#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)
 
static VALUE struct_define_without_accessor (VALUE outer, const char *class_name, VALUE super, rb_alloc_func_t alloc, VALUE members)
 
VALUE rb_struct_define_without_accessor_under (VALUE outer, const char *class_name, VALUE super, rb_alloc_func_t alloc,...)
 
VALUE rb_struct_define_without_accessor (const char *class_name, VALUE super, rb_alloc_func_t alloc,...)
 
VALUE rb_struct_define (const char *name,...)
 
VALUE rb_struct_define_under (VALUE outer, 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, const 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 struct_enum_size (VALUE s, VALUE args, VALUE eobj)
 
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 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)
 

Macro Definition Documentation

#define N_REF_FUNC   numberof(ref_func)

Definition at line 132 of file struct.c.

Referenced by rb_struct_new(), and setup_struct().

Function Documentation

static VALUE anonymous_struct ( VALUE  klass)
static
void Init_Struct ( void  )
static VALUE inspect_struct ( VALUE  s,
VALUE  dummy,
int  recur 
)
static
static VALUE new_struct ( VALUE  name,
VALUE  super 
)
static
NORETURN ( static void   not_a_memberID id)
static void not_a_member ( ID  id)
static

Definition at line 91 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
VALUE rb_struct_alloc ( VALUE  klass,
VALUE  values 
)

Definition at line 494 of file struct.c.

References RARRAY_LENINT, RARRAY_PTR(), and rb_class_new_instance().

VALUE rb_struct_alloc_noinit ( VALUE  klass)

Definition at line 235 of file struct.c.

References struct_alloc().

Referenced by Init_thread(), and range_alloc().

VALUE rb_struct_aref ( VALUE  s,
VALUE  idx 
)
static VALUE rb_struct_aref_id ( VALUE  s,
ID  id 
)
static
VALUE rb_struct_aset ( VALUE  s,
VALUE  idx,
VALUE  val 
)
static VALUE rb_struct_aset_id ( VALUE  s,
ID  id,
VALUE  val 
)
static
VALUE rb_struct_define ( const char *  name,
  ... 
)
VALUE rb_struct_define_under ( VALUE  outer,
const char *  name,
  ... 
)
VALUE rb_struct_define_without_accessor ( const char *  class_name,
VALUE  super,
rb_alloc_func_t  alloc,
  ... 
)
VALUE rb_struct_define_without_accessor_under ( VALUE  outer,
const char *  class_name,
VALUE  super,
rb_alloc_func_t  alloc,
  ... 
)
static VALUE rb_struct_each ( VALUE  s)
static

Definition at line 549 of file struct.c.

References i, rb_yield(), RETURN_SIZED_ENUMERATOR, RSTRUCT_GET, RSTRUCT_LEN, s, and struct_enum_size().

Referenced by Init_Struct().

static VALUE rb_struct_each_pair ( VALUE  s)
static
static VALUE rb_struct_eql ( VALUE  s,
VALUE  s2 
)
static
static VALUE rb_struct_equal ( VALUE  s,
VALUE  s2 
)
static
VALUE rb_struct_getmember ( VALUE  obj,
ID  id 
)

Definition at line 97 of file struct.c.

References i, ID2SYM, len, not_a_member(), RARRAY_AREF, RARRAY_LEN, rb_struct_members(), RSTRUCT_GET, and UNREACHABLE.

Referenced by rb_struct_ref().

static VALUE rb_struct_hash ( VALUE  s)
static
VALUE rb_struct_init_copy ( VALUE  copy,
VALUE  s 
)

Definition at line 707 of file struct.c.

References i, len, OBJ_INIT_COPY, rb_eTypeError, rb_raise(), RSTRUCT_GET, RSTRUCT_LEN, and RSTRUCT_SET.

Referenced by Init_Struct(), and range_initialize_copy().

VALUE rb_struct_initialize ( VALUE  self,
VALUE  values 
)

Definition at line 466 of file struct.c.

References RARRAY_CONST_PTR, RARRAY_LENINT, and rb_struct_initialize_m().

Referenced by r_object0().

static VALUE rb_struct_initialize_m ( int  argc,
const VALUE argv,
VALUE  self 
)
static
static VALUE rb_struct_inspect ( VALUE  s)
static

Definition at line 658 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)
static VALUE rb_struct_members_m ( VALUE  obj)
static

Definition at line 84 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
VALUE rb_struct_new ( VALUE  klass,
  ... 
)
static VALUE rb_struct_ref ( VALUE  obj)
static

Definition at line 116 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 121 of file struct.c.

References RSTRUCT_GET.

static VALUE rb_struct_ref1 ( VALUE  obj)
static

Definition at line 122 of file struct.c.

References RSTRUCT_GET.

static VALUE rb_struct_ref2 ( VALUE  obj)
static

Definition at line 123 of file struct.c.

References RSTRUCT_GET.

static VALUE rb_struct_ref3 ( VALUE  obj)
static

Definition at line 124 of file struct.c.

References RSTRUCT_GET.

static VALUE rb_struct_ref4 ( VALUE  obj)
static

Definition at line 125 of file struct.c.

References RSTRUCT_GET.

static VALUE rb_struct_ref5 ( VALUE  obj)
static

Definition at line 126 of file struct.c.

References RSTRUCT_GET.

static VALUE rb_struct_ref6 ( VALUE  obj)
static

Definition at line 127 of file struct.c.

References RSTRUCT_GET.

static VALUE rb_struct_ref7 ( VALUE  obj)
static

Definition at line 128 of file struct.c.

References RSTRUCT_GET.

static VALUE rb_struct_ref8 ( VALUE  obj)
static

Definition at line 129 of file struct.c.

References RSTRUCT_GET.

static VALUE rb_struct_ref9 ( VALUE  obj)
static

Definition at line 130 of file struct.c.

References RSTRUCT_GET.

static VALUE rb_struct_s_def ( int  argc,
VALUE argv,
VALUE  klass 
)
static
VALUE rb_struct_s_members ( VALUE  klass)
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
static VALUE rb_struct_set ( VALUE  obj,
VALUE  val 
)
static
static VALUE rb_struct_size ( VALUE  s)
static

Definition at line 1037 of file struct.c.

References LONG2FIX, and RSTRUCT_LEN.

Referenced by Init_Struct(), and struct_enum_size().

static VALUE rb_struct_to_a ( VALUE  s)
static

Definition at line 676 of file struct.c.

References rb_ary_new4, RSTRUCT_CONST_PTR, and RSTRUCT_LEN.

Referenced by Init_Struct().

static VALUE rb_struct_to_h ( VALUE  s)
static

Definition at line 693 of file struct.c.

References i, rb_ary_entry(), rb_hash_aset(), rb_hash_new(), rb_struct_members(), RSTRUCT_GET, and RSTRUCT_LEN.

Referenced by Init_Struct().

static VALUE rb_struct_values_at ( int  argc,
VALUE argv,
VALUE  s 
)
static

Definition at line 879 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 987 of file struct.c.

References i, len, ptr, Qfalse, Qtrue, rb_eql(), RSTRUCT_CONST_PTR, and RSTRUCT_LEN.

Referenced by rb_struct_eql().

static VALUE recursive_equal ( VALUE  s,
VALUE  s2,
int  recur 
)
static

Definition at line 917 of file struct.c.

References i, len, ptr, Qfalse, Qtrue, rb_equal(), RSTRUCT_CONST_PTR, and RSTRUCT_LEN.

Referenced by rb_struct_equal().

static VALUE setup_struct ( VALUE  nstr,
VALUE  members 
)
static
static VALUE struct_alloc ( VALUE  klass)
static
static VALUE struct_define_without_accessor ( VALUE  outer,
const char *  class_name,
VALUE  super,
rb_alloc_func_t  alloc,
VALUE  members 
)
static
static VALUE struct_entry ( VALUE  s,
long  n 
)
static

Definition at line 859 of file struct.c.

References LONG2NUM, and rb_struct_aref().

Referenced by rb_struct_values_at().

static VALUE struct_enum_size ( VALUE  s,
VALUE  args,
VALUE  eobj 
)
static

Definition at line 524 of file struct.c.

References rb_struct_size().

Referenced by rb_struct_each(), rb_struct_each_pair(), and rb_struct_select().

static VALUE struct_ivar_get ( VALUE  c,
ID  id 
)
inlinestatic

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().

Variable Documentation

ID id_members
static
VALUE rb_cStruct

Definition at line 15 of file struct.c.

VALUE(*const ref_func[])(VALUE)
static
Initial value:
= {
}
static VALUE rb_struct_ref3(VALUE obj)
Definition: struct.c:124
static VALUE rb_struct_ref0(VALUE obj)
Definition: struct.c:121
static VALUE rb_struct_ref2(VALUE obj)
Definition: struct.c:123
static VALUE rb_struct_ref6(VALUE obj)
Definition: struct.c:127
static VALUE rb_struct_ref8(VALUE obj)
Definition: struct.c:129
static VALUE rb_struct_ref9(VALUE obj)
Definition: struct.c:130
static VALUE rb_struct_ref4(VALUE obj)
Definition: struct.c:125
static VALUE rb_struct_ref7(VALUE obj)
Definition: struct.c:128
static VALUE rb_struct_ref1(VALUE obj)
Definition: struct.c:122
static VALUE rb_struct_ref5(VALUE obj)
Definition: struct.c:126

Definition at line 134 of file struct.c.

Referenced by setup_struct().