[macruby-changes] [3937] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Apr 16 16:59:46 PDT 2010
Revision: 3937
http://trac.macosforge.org/projects/ruby/changeset/3937
Author: lsansonetti at apple.com
Date: 2010-04-16 16:59:45 -0700 (Fri, 16 Apr 2010)
Log Message:
-----------
force class initialization upon lazy lookup
Modified Paths:
--------------
MacRuby/trunk/objc.h
MacRuby/trunk/objc.m
MacRuby/trunk/object.c
MacRuby/trunk/variable.c
Modified: MacRuby/trunk/objc.h
===================================================================
--- MacRuby/trunk/objc.h 2010-04-15 02:02:19 UTC (rev 3936)
+++ MacRuby/trunk/objc.h 2010-04-16 23:59:45 UTC (rev 3937)
@@ -234,6 +234,7 @@
void rb_objc_exception_raise(const char *name, const char *message);
bool rb_objc_ignore_sel(SEL sel);
+void rb_objc_force_class_initialize(Class klass);
#if defined(__cplusplus)
}
Modified: MacRuby/trunk/objc.m
===================================================================
--- MacRuby/trunk/objc.m 2010-04-15 02:02:19 UTC (rev 3936)
+++ MacRuby/trunk/objc.m 2010-04-16 23:59:45 UTC (rev 3937)
@@ -640,13 +640,20 @@
bool
rb_objc_ignore_sel(SEL sel)
{
- return sel == @selector(retain)
- || sel == @selector(release)
- || sel == @selector(autorelease)
- || sel == @selector(retainCount)
- || sel == @selector(dealloc);
+ return sel == @selector(retain)
+ || sel == @selector(release)
+ || sel == @selector(autorelease)
+ || sel == @selector(retainCount)
+ || sel == @selector(dealloc);
}
+void
+rb_objc_force_class_initialize(Class klass)
+{
+ // This forces +initialize to be called.
+ class_getMethodImplementation(klass, @selector(initialize));
+}
+
size_t
rb_objc_type_size(const char *type)
{
Modified: MacRuby/trunk/object.c
===================================================================
--- MacRuby/trunk/object.c 2010-04-15 02:02:19 UTC (rev 3936)
+++ MacRuby/trunk/object.c 2010-04-16 23:59:45 UTC (rev 3937)
@@ -1843,8 +1843,7 @@
static bool initialized = false;
if (!initialized) {
initialized = true;
- // force initialize
- class_getMethodImplementation((Class)module, sel);
+ rb_objc_force_class_initialize((Class)module);
initialized = false;
if (rb_block_given_p()) {
Modified: MacRuby/trunk/variable.c
===================================================================
--- MacRuby/trunk/variable.c 2010-04-15 02:02:19 UTC (rev 3936)
+++ MacRuby/trunk/variable.c 2010-04-16 23:59:45 UTC (rev 3937)
@@ -12,6 +12,7 @@
#include "ruby/util.h"
#include "id.h"
#include "vm.h"
+#include "objc.h"
st_table *rb_global_tbl;
st_table *rb_class_tbl;
@@ -1524,6 +1525,7 @@
if (k != 0 && !RCLASS_RUBY(k)) {
// Set the constant. Only if the returned class is a pure
// Objective-C class, to avoid namespace conflicts in Ruby land.
+ rb_objc_force_class_initialize((Class)k);
rb_const_set(klass, name, k);
return k;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100416/afba527a/attachment.html>
More information about the macruby-changes
mailing list