#Trying to implement rb_call_super() for more RMagick fun.
First try
VALUE rb_call_super(int nargs, VALUE *args) {
CTX;
VALUE obj;
obj = NEW_HANDLE(ctx, ctx->fc->self);
return rb_funcall2(obj, rb_intern("super"), nargs, args);
}
Results
#This fails. super() isn't a "real" method, so rubinius complains
#that it cannot find the method.
New approach
VALUE rb_call_super(int nargs, VALUE *args) {
CTX;
VALUE obj;
obj = NEW_HANDLE(ctx, class_get_superclass(ctx->fc->self->klass));
return _push_and_call(obj, (ID)ctx->fc->method, nargs, args);
}
Results
#This fails. Replacing (ID)ctx->fc->method with
#rb_intern("real method to call") also fails, as obj appears
#to be pointing to the metaclass instead of the class itself.
#Roughly, obj.metaclass.superclass.superclass. But
#(ID)ctx->fc->method appears to be wrong anyway, it's not
#pointing to what I expected it to point to. It's an OBJECT
#rather than an ID, and casting it doesn't appear to be the
#right thing.
#I suppose I could go through a string based eval but clearly
#at this point in the code, we know our current object and
#should be able to figure out the method lookup table of the
#parent object and make the appropriate call. But I can't
#get it. Help?