Defines | Functions | Variables

struct.c File Reference

#include "ruby/ruby.h"
Include dependency graph for struct.c:

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)
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 make_struct (VALUE name, VALUE members, VALUE klass)
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_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)
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)
static VALUE rb_struct_size (VALUE s)
void Init_Struct (void)

Variables

VALUE rb_cStruct
static ID id_members
static VALUE(*const ref_func [])(VALUE)

Define Documentation

#define N_REF_FUNC   numberof(ref_func)

Definition at line 136 of file struct.c.

Referenced by make_struct().

#define numberof (   array  )     (int)(sizeof(array) / sizeof((array)[0]))

Definition at line 135 of file struct.c.

Referenced by rb_struct_new().


Function Documentation

void Init_Struct ( void   ) 
static VALUE inspect_struct ( VALUE  s,
VALUE  dummy,
int  recur 
) [static]
static VALUE make_struct ( VALUE  name,
VALUE  members,
VALUE  klass 
) [static]
static long num_members ( VALUE  klass  )  [static]
VALUE rb_struct_alloc ( VALUE  klass,
VALUE  values 
)

Definition at line 416 of file struct.c.

References RARRAY_LENINT, RARRAY_PTR, and rb_class_new_instance().

VALUE rb_struct_alloc_noinit ( VALUE  klass  ) 

Definition at line 232 of file struct.c.

References struct_alloc().

Referenced by range_alloc().

VALUE rb_struct_aref ( VALUE  s,
VALUE  idx 
)
static VALUE rb_struct_aref_id ( VALUE  s,
ID  id 
) [static]

Definition at line 607 of file struct.c.

References len, RARRAY_LEN, RARRAY_PTR, rb_id2name(), rb_name_error(), rb_struct_members(), RSTRUCT_PTR, and SYM2ID.

Referenced by rb_struct_aref().

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

Definition at line 275 of file struct.c.

References ID2SYM, make_struct(), rb_ary_new(), rb_ary_push(), rb_cStruct, rb_intern, and rb_str_new2().

Referenced by Init_etc(), and Init_process().

VALUE rb_struct_define_without_accessor ( const char *  class_name,
VALUE  super,
rb_alloc_func_t  alloc,
  ... 
)
static VALUE rb_struct_each ( VALUE  s  )  [static]

Definition at line 464 of file struct.c.

References rb_yield(), RETURN_ENUMERATOR, RSTRUCT_LEN, and RSTRUCT_PTR.

Referenced by Init_Struct().

static VALUE rb_struct_each_pair ( VALUE  s  )  [static]
static VALUE rb_struct_eql ( VALUE  s,
VALUE  s2 
) [static]

Definition at line 899 of file struct.c.

References rb_bug(), rb_exec_recursive_paired(), rb_obj_class(), recursive_eql(), RSTRUCT_LEN, T_STRUCT, and TYPE.

Referenced by Init_Struct().

static VALUE rb_struct_equal ( VALUE  s,
VALUE  s2 
) [static]

Definition at line 829 of file struct.c.

References rb_bug(), rb_exec_recursive_paired(), rb_obj_class(), recursive_equal(), RSTRUCT_LEN, T_STRUCT, and TYPE.

Referenced by Init_Struct().

VALUE rb_struct_getmember ( VALUE  obj,
ID  id 
)

Definition at line 99 of file struct.c.

References ID2SYM, len, RARRAY_LEN, RARRAY_PTR, rb_id2name(), rb_name_error(), rb_struct_members(), and RSTRUCT_PTR.

Referenced by rb_struct_ref().

static VALUE rb_struct_hash ( VALUE  s  )  [static]

Definition at line 869 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 
)
VALUE rb_struct_initialize ( VALUE  self,
VALUE  values 
)

Definition at line 387 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]
static VALUE rb_struct_inspect ( VALUE  s  )  [static]

Definition at line 566 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 32 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 93 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 119 of file struct.c.

References rb_frame_this_func(), and rb_struct_getmember().

Referenced by make_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]
VALUE rb_struct_s_members ( VALUE  klass  ) 
static VALUE rb_struct_s_members_m ( VALUE  klass  )  [static]

Definition at line 64 of file struct.c.

References RARRAY_LEN, RARRAY_PTR, rb_ary_new2(), rb_ary_push(), and rb_struct_s_members().

Referenced by make_struct(), and rb_struct_members_m().

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 924 of file struct.c.

References LONG2FIX, and RSTRUCT_LEN.

Referenced by Init_Struct().

static VALUE rb_struct_to_a ( VALUE  s  )  [static]

Definition at line 584 of file struct.c.

References rb_ary_new4(), 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 755 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 875 of file struct.c.

References len, 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 796 of file struct.c.

References len, rb_equal(), RSTRUCT_LEN, and RSTRUCT_PTR.

Referenced by rb_struct_equal().

static VALUE recursive_hash ( VALUE  s,
VALUE  dummy,
int  recur 
) [static]
static VALUE struct_alloc ( VALUE  klass  )  [static]
static VALUE struct_entry ( VALUE  s,
long  n 
) [static]

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

References 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]

Definition at line 14 of file struct.c.

VALUE(*const ref_func[])(VALUE) [static]
Initial value:
 {
    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,
}

Definition at line 138 of file struct.c.

Referenced by make_struct().