Ruby  1.9.3p484(2013-11-22revision43786)
Macros | Functions | Variables
range.c File Reference
#include "ruby/ruby.h"
#include "ruby/encoding.h"
#include "internal.h"

Go to the source code of this file.

Macros

#define RANGE_BEG(r)   (RSTRUCT(r)->as.ary[0])
 
#define RANGE_END(r)   (RSTRUCT(r)->as.ary[1])
 
#define RANGE_EXCL(r)   (RSTRUCT(r)->as.ary[2])
 
#define EXCL(r)   RTEST(RANGE_EXCL(r))
 
#define SET_EXCL(r, v)   (RSTRUCT(r)->as.ary[2] = (v) ? Qtrue : Qfalse)
 
#define range_initialize_copy   rb_struct_init_copy /* :nodoc: */
 
#define rb_intern(str)   rb_intern_const(str)
 

Functions

static VALUE range_failed (void)
 
static VALUE range_check (VALUE *args)
 
static void range_init (VALUE range, VALUE beg, VALUE end, int exclude_end)
 
VALUE rb_range_new (VALUE beg, VALUE end, int exclude_end)
 
static VALUE range_initialize (int argc, VALUE *argv, VALUE range)
 
static VALUE range_exclude_end_p (VALUE range)
 
static VALUE recursive_equal (VALUE range, VALUE obj, int recur)
 
static VALUE range_eq (VALUE range, VALUE obj)
 
static int r_lt (VALUE a, VALUE b)
 
static int r_le (VALUE a, VALUE b)
 
static VALUE recursive_eql (VALUE range, VALUE obj, int recur)
 
static VALUE range_eql (VALUE range, VALUE obj)
 
static VALUE recursive_hash (VALUE range, VALUE dummy, int recur)
 
static VALUE range_hash (VALUE range)
 
static void range_each_func (VALUE range, VALUE(*func)(VALUE, void *), void *arg)
 
static VALUE sym_step_i (VALUE i, void *arg)
 
static VALUE step_i (VALUE i, void *arg)
 
static int discrete_object_p (VALUE obj)
 
static VALUE range_step (int argc, VALUE *argv, VALUE range)
 
static VALUE each_i (VALUE v, void *arg)
 
static VALUE sym_each_i (VALUE v, void *arg)
 
static VALUE range_each (VALUE range)
 
static VALUE range_begin (VALUE range)
 
static VALUE range_end (VALUE range)
 
static VALUE first_i (VALUE i, VALUE *ary)
 
static VALUE range_first (int argc, VALUE *argv, VALUE range)
 
static VALUE range_last (int argc, VALUE *argv, VALUE range)
 
static VALUE range_min (VALUE range)
 
static VALUE range_max (VALUE range)
 
int rb_range_values (VALUE range, VALUE *begp, VALUE *endp, int *exclp)
 
VALUE rb_range_beg_len (VALUE range, long *begp, long *lenp, long len, int err)
 
static VALUE range_to_s (VALUE range)
 
static VALUE inspect_range (VALUE range, VALUE dummy, int recur)
 
static VALUE range_inspect (VALUE range)
 
static VALUE range_eqq (VALUE range, VALUE val)
 
static VALUE range_include (VALUE range, VALUE val)
 
static VALUE range_cover (VALUE range, VALUE val)
 
static VALUE range_dumper (VALUE range)
 
static VALUE range_loader (VALUE range, VALUE obj)
 
static VALUE range_alloc (VALUE klass)
 
void Init_Range (void)
 

Variables

VALUE rb_cRange
 
static ID id_cmp
 
static ID id_succ
 
static ID id_beg
 
static ID id_end
 
static ID id_excl
 

Macro Definition Documentation

#define EXCL (   r)    RTEST(RANGE_EXCL(r))
#define RANGE_BEG (   r)    (RSTRUCT(r)->as.ary[0])
#define RANGE_END (   r)    (RSTRUCT(r)->as.ary[1])
#define RANGE_EXCL (   r)    (RSTRUCT(r)->as.ary[2])

Definition at line 21 of file range.c.

Referenced by range_dumper(), and range_initialize().

#define range_initialize_copy   rb_struct_init_copy /* :nodoc: */

Definition at line 92 of file range.c.

Referenced by Init_Range().

#define rb_intern (   str)    rb_intern_const(str)
#define SET_EXCL (   r,
  v 
)    (RSTRUCT(r)->as.ary[2] = (v) ? Qtrue : Qfalse)

Definition at line 24 of file range.c.

Referenced by range_init().

Function Documentation

static int discrete_object_p ( VALUE  obj)
static

Definition at line 309 of file range.c.

References FALSE, id_succ, rb_cTime, rb_obj_is_kind_of(), and rb_respond_to().

Referenced by range_each(), and range_step().

static VALUE each_i ( VALUE  v,
void *  arg 
)
static

Definition at line 440 of file range.c.

References Qnil, and rb_yield().

Referenced by range_each().

static VALUE first_i ( VALUE  i,
VALUE ary 
)
static

Definition at line 555 of file range.c.

References INT2NUM(), NUM2LONG(), Qnil, rb_ary_push(), and rb_iter_break().

Referenced by range_first().

void Init_Range ( void  )
static VALUE inspect_range ( VALUE  range,
VALUE  dummy,
int  recur 
)
static
static int r_le ( VALUE  a,
VALUE  b 
)
static

Definition at line 160 of file range.c.

References id_cmp, INT2FIX, NIL_P, Qfalse, Qtrue, rb_cmpint(), and rb_funcall().

Referenced by range_cover(), range_each_func(), and range_include().

static int r_lt ( VALUE  a,
VALUE  b 
)
static

Definition at line 148 of file range.c.

References id_cmp, NIL_P, Qfalse, Qtrue, rb_cmpint(), and rb_funcall().

Referenced by range_cover(), range_each_func(), and range_include().

static VALUE range_alloc ( VALUE  klass)
static

Definition at line 953 of file range.c.

References rb_struct_alloc_noinit().

Referenced by Init_Range().

static VALUE range_begin ( VALUE  range)
static

Definition at line 530 of file range.c.

References RANGE_BEG.

Referenced by Init_Range().

static VALUE range_check ( VALUE args)
static

Definition at line 34 of file range.c.

References id_cmp, and rb_funcall().

Referenced by range_init().

static VALUE range_cover ( VALUE  range,
VALUE  val 
)
static

Definition at line 905 of file range.c.

References EXCL, Qfalse, Qtrue, r_le(), r_lt(), RANGE_BEG, and RANGE_END.

Referenced by Init_Range().

static VALUE range_dumper ( VALUE  range)
static

Definition at line 925 of file range.c.

References id_beg, id_end, id_excl, NEWOBJ, OBJSETUP, RANGE_BEG, RANGE_END, RANGE_EXCL, rb_cObject, rb_ivar_set(), T_OBJECT, and v.

Referenced by Init_Range().

static VALUE range_each ( VALUE  range)
static
static void range_each_func ( VALUE  range,
VALUE(*)(VALUE, void *)  func,
void *  arg 
)
static

Definition at line 249 of file range.c.

References arg, EXCL, id_succ, INT2FIX, Qfalse, r_le(), r_lt(), RANGE_BEG, RANGE_END, rb_funcall(), and v.

Referenced by range_each(), and range_step().

static VALUE range_end ( VALUE  range)
static

Definition at line 548 of file range.c.

References RANGE_END.

Referenced by Init_Range().

static VALUE range_eq ( VALUE  range,
VALUE  obj 
)
static

Definition at line 137 of file range.c.

References Qfalse, Qtrue, rb_cRange, rb_exec_recursive_paired(), rb_obj_is_kind_of(), and recursive_equal().

Referenced by Init_Range().

static VALUE range_eql ( VALUE  range,
VALUE  obj 
)
static

Definition at line 205 of file range.c.

References Qfalse, Qtrue, rb_cRange, rb_exec_recursive_paired(), rb_obj_is_kind_of(), and recursive_eql().

Referenced by Init_Range().

static VALUE range_eqq ( VALUE  range,
VALUE  val 
)
static

Definition at line 825 of file range.c.

References rb_funcall(), and rb_intern.

Referenced by Init_Range().

static VALUE range_exclude_end_p ( VALUE  range)
static

Definition at line 102 of file range.c.

References EXCL, Qfalse, and Qtrue.

Referenced by Init_Range().

static VALUE range_failed ( void  )
static

Definition at line 27 of file range.c.

References Qnil, rb_eArgError, and rb_raise().

Referenced by range_init().

static VALUE range_first ( int  argc,
VALUE argv,
VALUE  range 
)
static

Definition at line 577 of file range.c.

References first_i(), NUM2LONG(), RANGE_BEG, rb_ary_new2(), rb_block_call, rb_intern, and rb_scan_args().

Referenced by Init_Range().

static VALUE range_hash ( VALUE  range)
static

Definition at line 243 of file range.c.

References rb_exec_recursive_outer(), and recursive_hash().

Referenced by Init_Range().

static VALUE range_include ( VALUE  range,
VALUE  val 
)
static
static void range_init ( VALUE  range,
VALUE  beg,
VALUE  end,
int  exclude_end 
)
static

Definition at line 40 of file range.c.

References args, FIXNUM_P, NIL_P, range_check(), range_failed(), rb_rescue(), RSTRUCT, SET_EXCL, and v.

Referenced by range_initialize(), and rb_range_new().

static VALUE range_initialize ( int  argc,
VALUE argv,
VALUE  range 
)
static

Definition at line 79 of file range.c.

References Qnil, RANGE_EXCL, range_init(), rb_intern, rb_name_error(), rb_scan_args(), and RTEST.

Referenced by Init_Range().

static VALUE range_inspect ( VALUE  range)
static

Definition at line 799 of file range.c.

References inspect_range(), and rb_exec_recursive().

Referenced by Init_Range().

static VALUE range_last ( int  argc,
VALUE argv,
VALUE  range 
)
static

Definition at line 601 of file range.c.

References RANGE_END, rb_Array(), and rb_ary_last().

Referenced by Init_Range().

static VALUE range_loader ( VALUE  range,
VALUE  obj 
)
static

Definition at line 940 of file range.c.

References id_beg, id_end, id_excl, range, rb_cObject, rb_eTypeError, rb_ivar_get(), rb_raise(), RBASIC, RSTRUCT, T_OBJECT, and TYPE.

Referenced by Init_Range().

static VALUE range_max ( VALUE  range)
static
static VALUE range_min ( VALUE  range)
static

Definition at line 621 of file range.c.

References EXCL, id_cmp, Qnil, RANGE_BEG, RANGE_END, rb_block_given_p(), rb_call_super(), rb_cmpint(), and rb_funcall().

Referenced by Init_Range().

static VALUE range_step ( int  argc,
VALUE argv,
VALUE  range 
)
static
static VALUE range_to_s ( VALUE  range)
static

Definition at line 756 of file range.c.

References EXCL, OBJ_INFECT, RANGE_BEG, RANGE_END, rb_obj_as_string(), rb_str_append(), rb_str_cat(), and rb_str_dup().

Referenced by Init_Range().

VALUE rb_range_beg_len ( VALUE  range,
long begp,
long lenp,
long  len,
int  err 
)
VALUE rb_range_new ( VALUE  beg,
VALUE  end,
int  exclude_end 
)

Definition at line 61 of file range.c.

References range, range_init(), rb_cRange, and rb_obj_alloc().

Referenced by fixup_nodes().

int rb_range_values ( VALUE  range,
VALUE begp,
VALUE endp,
int *  exclp 
)
static VALUE recursive_eql ( VALUE  range,
VALUE  obj,
int  recur 
)
static

Definition at line 177 of file range.c.

References EXCL, Qfalse, Qtrue, RANGE_BEG, RANGE_END, and rb_eql().

Referenced by range_eql().

static VALUE recursive_equal ( VALUE  range,
VALUE  obj,
int  recur 
)
static

Definition at line 108 of file range.c.

References EXCL, Qfalse, Qtrue, RANGE_BEG, RANGE_END, and rb_equal().

Referenced by range_eq().

static VALUE recursive_hash ( VALUE  range,
VALUE  dummy,
int  recur 
)
static

Definition at line 215 of file range.c.

References EXCL, hash(), LONG2FIX, NUM2LONG(), RANGE_BEG, RANGE_END, rb_hash(), rb_hash_end(), rb_hash_start(), rb_hash_uint(), and v.

Referenced by range_hash().

static VALUE step_i ( VALUE  i,
void *  arg 
)
static

Definition at line 291 of file range.c.

References arg, FIXNUM_FLAG, FIXNUM_P, INT2FIX, Qnil, rb_funcall(), and rb_yield().

Referenced by range_step().

static VALUE sym_each_i ( VALUE  v,
void *  arg 
)
static

Definition at line 447 of file range.c.

References Qnil, rb_str_intern(), and rb_yield().

Referenced by range_each().

static VALUE sym_step_i ( VALUE  i,
void *  arg 
)
static

Definition at line 273 of file range.c.

References arg, FIXNUM_FLAG, FIXNUM_P, INT2FIX, Qnil, rb_funcall(), rb_str_intern(), and rb_yield().

Referenced by range_step().

Variable Documentation

ID id_beg
static

Definition at line 17 of file range.c.

Referenced by Init_Range(), range_dumper(), range_loader(), and rb_range_values().

ID id_cmp
static

Definition at line 17 of file range.c.

Referenced by Init_Range(), r_le(), r_lt(), range_check(), range_max(), and range_min().

ID id_end
static

Definition at line 17 of file range.c.

Referenced by Init_Range(), range_dumper(), range_loader(), and rb_range_values().

ID id_excl
static

Definition at line 17 of file range.c.

Referenced by Init_Range(), range_dumper(), and range_loader().

ID id_succ
static

Definition at line 17 of file range.c.

Referenced by discrete_object_p(), Init_Range(), and range_each_func().

VALUE rb_cRange

Definition at line 16 of file range.c.