[macruby-changes] [2854] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Mon Oct 19 16:36:42 PDT 2009
Revision: 2854
http://trac.macosforge.org/projects/ruby/changeset/2854
Author: eloy.de.enige at gmail.com
Date: 2009-10-19 16:36:38 -0700 (Mon, 19 Oct 2009)
Log Message:
-----------
Replace method implementation with a stub when remove_method is used. This is later used to check if we should lookup the method in the ancestor chain.
Modified Paths:
--------------
MacRuby/trunk/dispatcher.cpp
MacRuby/trunk/vm.h
MacRuby/trunk/vm_method.c
Modified: MacRuby/trunk/dispatcher.cpp
===================================================================
--- MacRuby/trunk/dispatcher.cpp 2009-10-19 23:06:34 UTC (rev 2853)
+++ MacRuby/trunk/dispatcher.cpp 2009-10-19 23:36:38 UTC (rev 2854)
@@ -350,6 +350,14 @@
return NULL; // never reached
}
+extern "C"
+void *
+rb_vm_removed_imp(void *rcv, SEL sel)
+{
+ method_missing((VALUE)rcv, sel, NULL, NULL, NULL, METHOD_MISSING_DEFAULT);
+ return NULL; // never reached
+}
+
static force_inline VALUE
__rb_vm_ruby_dispatch(VALUE top, VALUE self, SEL sel,
rb_vm_method_node_t *node, unsigned char opt,
@@ -551,6 +559,14 @@
// Method was undefined.
goto call_method_missing;
}
+ else if (REMOVED_IMP(imp)) {
+ // Method was removed, let's see if any of the ancestors does
+ // implement the method.
+ method = rb_vm_super_lookup((VALUE)klass, sel);
+ if (method == NULL) {
+ goto call_method_missing;
+ }
+ }
rb_vm_method_node_t *node = GET_CORE()->method_node_get(method);
Modified: MacRuby/trunk/vm.h
===================================================================
--- MacRuby/trunk/vm.h 2009-10-19 23:06:34 UTC (rev 2853)
+++ MacRuby/trunk/vm.h 2009-10-19 23:36:38 UTC (rev 2854)
@@ -284,6 +284,8 @@
bool rb_vm_resolve_method(Class klass, SEL sel);
void *rb_vm_undefined_imp(void *rcv, SEL sel);
#define UNDEFINED_IMP(imp) (imp == NULL || imp == (IMP)rb_vm_undefined_imp)
+void *rb_vm_removed_imp(void *rcv, SEL sel);
+#define REMOVED_IMP(imp) (imp == (IMP)rb_vm_removed_imp)
void rb_vm_define_attr(Class klass, const char *name, bool read, bool write);
void rb_vm_undef_method(Class klass, ID name, bool must_exist);
void rb_vm_alias(VALUE klass, ID name, ID def);
Modified: MacRuby/trunk/vm_method.c
===================================================================
--- MacRuby/trunk/vm_method.c 2009-10-19 23:06:34 UTC (rev 2853)
+++ MacRuby/trunk/vm_method.c 2009-10-19 23:36:38 UTC (rev 2854)
@@ -147,7 +147,7 @@
rb_warn("removing pure Objective-C method `%s' may cause serious " \
"problem", rb_id2name(mid));
}
- method_setImplementation(m, NULL);
+ method_setImplementation(m, (IMP)rb_vm_removed_imp);
if (RCLASS_SINGLETON(klass)) {
rb_funcall(rb_iv_get(klass, "__attached__"), singleton_removed, 1,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20091019/371424bc/attachment.html>
More information about the macruby-changes
mailing list