Class: Method

Inherits:
Object show all
Defined in:
lib/getsource.rb

Defined Under Namespace

Classes: Node

Instance Method Summary collapse

Instance Method Details

#bodyObject

The node that acts as body of the method



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'ext/getsource_base/getsource_base.c', line 52

VALUE rb_method_body(VALUE self) {

//	VALUE name = rb_funcall(self, intern_name, 0);
//	VALUE sym = rb_funcall(name, intern_sym, 0);
//	VALUE owner = rb_funcall(self, intern_owner, 0);
//	NODE* body = rb_method_node(owner, SYM2ID(sym) );

	struct METHOD* method;
	Data_Get_Struct(self,struct METHOD,method);

	if (method->body == 0) return Qnil;

	// nd_defn is only present in ruby_1.8
	if (method->body->nd_defn != 0) {
		return Data_Wrap_Struct(rb_cNode, 0, 0, method->body->nd_defn);
	}

	return Data_Wrap_Struct(rb_cNode, 0, 0, method->body);
}