[macruby-changes] [1714] MacRuby/branches/experimental/objc.m

source_changes at macosforge.org source_changes at macosforge.org
Wed Jun 3 17:47:52 PDT 2009


Revision: 1714
          http://trac.macosforge.org/projects/ruby/changeset/1714
Author:   lsansonetti at apple.com
Date:     2009-06-03 17:47:51 -0700 (Wed, 03 Jun 2009)
Log Message:
-----------
don't forget to reload class constants every time a new framework is loaded

Modified Paths:
--------------
    MacRuby/branches/experimental/objc.m

Modified: MacRuby/branches/experimental/objc.m
===================================================================
--- MacRuby/branches/experimental/objc.m	2009-06-03 22:24:14 UTC (rev 1713)
+++ MacRuby/branches/experimental/objc.m	2009-06-04 00:47:51 UTC (rev 1714)
@@ -221,6 +221,33 @@
 }
 
 static void
+reload_class_constants(void)
+{
+    static int class_count = 0;
+    int i, count;
+    Class *buf;
+
+    count = objc_getClassList(NULL, 0);
+    if (count == class_count)
+	return;
+
+    buf = (Class *)alloca(sizeof(Class) * count);
+    objc_getClassList(buf, count);
+
+    for (i = 0; i < count; i++) {
+	const char *name = class_getName(buf[i]);
+	if (name[0] != '_') {
+	    ID name_id = rb_intern(name);
+	    if (!rb_const_defined(rb_cObject, name_id)) {
+		rb_const_set(rb_cObject, name_id, (VALUE)buf[i]);
+	    }
+	}
+    }
+
+    class_count = count;
+}
+
+static void
 reload_protocols(void)
 {
 #if 0
@@ -357,6 +384,7 @@
     }
 
     rb_objc_search_and_load_bridge_support(cstr);
+    reload_class_constants();
     reload_protocols();
 
     return Qtrue;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090603/9fbf5ae4/attachment.html>


More information about the macruby-changes mailing list