Beispiel #1
0
static VALUE fcgi_stream_puts(int argc, VALUE *argv, VALUE out)
{
  int i;
  VALUE line;

  /* if no argument given, print newline. */
  if (argc == 0) {
    fcgi_stream_write(out, rb_default_rs);
    return Qnil;
  }
  for (i=0; i<argc; i++) {
    switch (TYPE(argv[i])) {
    case T_NIL:
      line = rb_str_new2("nil");
      break;
    case T_ARRAY:
      rb_exec_recursive(fcgi_stream_puts_ary, argv[i], out);
      continue;
    default:
      line = argv[i];
      break;
    }
    line = rb_obj_as_string(line);
    fcgi_stream_write(out, line);
    if (RSTRING_PTR(line)[RSTRING_LEN(line)-1] != '\n') {
      fcgi_stream_write(out, rb_default_rs);
    }
  }

  return Qnil;
}
Beispiel #2
0
static VALUE
hash_equal(VALUE hash1, VALUE hash2, bool eql)
{
    if (hash1 == hash2) {
	return Qtrue;
    }
    if (TYPE(hash2) != T_HASH) {
	if (!rb_respond_to(hash2, rb_intern("to_hash"))) {
	    return Qfalse;
	}
	if (eql) {
	    return rb_eql(hash2, hash1);
	}
	else {
	    return rb_equal(hash2, hash1);
	}
    }
    if (RHASH_SIZE(hash1) != RHASH_SIZE(hash2)) {
	return Qfalse;
    }
    if (IS_RHASH(hash2)) {
	struct equal_data data;
	data.tbl = RHASH(hash2)->tbl;
	data.eql = eql;
	return rb_exec_recursive(recursive_eql, hash1, (VALUE)&data);
    }
    else {
	return CFEqual((CFTypeRef)hash1, (CFTypeRef)hash2) ? Qtrue : Qfalse;
    }
}
Beispiel #3
0
static VALUE
rhash_inspect(VALUE hash, SEL sel)
{
    if (RHASH_EMPTY_P(hash)) {
	return rb_usascii_str_new2("{}");
    }
    return rb_exec_recursive(inspect_hash, hash, 0);
}
Beispiel #4
0
static VALUE do_rec(VALUE obj, VALUE arg, int is_rec) {
  if(is_rec) {
    return obj;
  } else if(arg == Qtrue) {
    return rb_exec_recursive(do_rec, obj, Qnil);
  } else {
    return Qnil;
  }
}
Beispiel #5
0
static VALUE
range_eql(VALUE range, SEL sel, VALUE obj)
{
    if (range == obj) {
	return Qtrue;
    }
    if (!rb_obj_is_kind_of(obj, rb_cRange)) {
	return Qfalse;
    }
    return rb_exec_recursive(recursive_eql, range, obj);
}
Beispiel #6
0
VALUE
rb_invcmp(VALUE x, VALUE y)
{
    VALUE invcmp = rb_exec_recursive(invcmp_recursive, x, y);
    if (invcmp == Qundef || NIL_P(invcmp)) {
	return Qnil;
    }
    else {
	int result = -rb_cmpint(invcmp, x, y);
	return INT2FIX(result);
    }
}
Beispiel #7
0
static VALUE
rb_struct_eql(VALUE s, SEL sel, VALUE s2)
{
    if (s == s2) {
	return Qtrue;
    }
    if (TYPE(s2) != T_STRUCT) {
	return Qfalse;
    }
    if (rb_obj_class(s) != rb_obj_class(s2)) {
	return Qfalse;
    }
    if (RSTRUCT_LEN(s) != RSTRUCT_LEN(s2)) {
	rb_bug("inconsistent struct"); /* should never happen */
    }
    return rb_exec_recursive(rb_struct_eql_r, s, s2);
}
Beispiel #8
0
static VALUE
rg_puts(int argc, VALUE *argv, VALUE self)
{
    int i;
    VALUE line;

    /* if no argument given, print newline. */
    if (argc == 0) {
        rg_write(self, default_rs);
        return Qnil;
    }
    for (i=0; i<argc; i++) {
        if (NIL_P(argv[i])) {
            line = rb_str_new2("nil");
        }
        else {
          line = rbg_check_array_type(argv[i]);
          if (!NIL_P(line)) {
#ifdef HAVE_RB_EXEC_RECURSIVE
            rb_exec_recursive(ioc_puts_ary, line, self);
#else
            rb_protect_inspect(ioc_puts_ary, line, self);
#endif
            continue;
          }
          line = rb_obj_as_string(argv[i]);
        }
        rg_write(self, line);
        if (RSTRING_LEN(line) == 0 ||
            RSTRING_PTR(line)[RSTRING_LEN(line)-1] != '\n') {
            rg_write(self, default_rs);
        }
    }

    return Qnil;
}
Beispiel #9
0
static VALUE
enumerator_inspect(VALUE obj)
{
    return rb_exec_recursive(inspect_enumerator, obj, 0);
}
Beispiel #10
0
static VALUE
safe_inspect(VALUE obj)
{
    return rb_exec_recursive(inspect_exec, obj, 0);
}
Beispiel #11
0
static VALUE
range_inspect(VALUE range, SEL sel)
{
    return rb_exec_recursive(inspect_range, range, 0);
}
Beispiel #12
0
static VALUE
rb_struct_inspect(VALUE s)
{
    return rb_exec_recursive(inspect_struct, s, 0);
}
Beispiel #13
0
static VALUE kernel_spec_rb_exec_recursive(VALUE self, VALUE obj) {
  return rb_exec_recursive(do_rec, obj, Qtrue);
}
Beispiel #14
0
static VALUE
rb_struct_hash(VALUE s, SEL sel)
{
    return rb_exec_recursive(rb_struct_hash_r, s, Qnil);
}