method
validate_object
v2_6_3 -
Show latest stable
-
0 notes -
Class: Object
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125
- 1_9_3_392
- 2_1_10
- 2_2_9
- 2_4_6
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
validate_object(p1)
public
Hide source
static VALUE ripper_validate_object(VALUE self, VALUE x) { if (x == Qfalse) return x; if (x == Qtrue) return x; if (x == Qnil) return x; if (x == Qundef) rb_raise(rb_eArgError, "Qundef given"); if (FIXNUM_P(x)) return x; if (SYMBOL_P(x)) return x; if (!rb_is_pointer_to_heap(x)) rb_raise(rb_eArgError, "invalid pointer: %p", x); switch (BUILTIN_TYPE(x)) { case T_STRING: case T_OBJECT: case T_ARRAY: case T_BIGNUM: case T_FLOAT: case T_COMPLEX: case T_RATIONAL: return x; case T_NODE: if (nd_type(x) != NODE_RIPPER) { rb_raise(rb_eArgError, "NODE given: %p", x); } return ((NODE *)x)->nd_rval; default: rb_raise(rb_eArgError, "wrong type of ruby object: %p (%s)", x, rb_obj_classname(x)); } return x; }