Revision
2792
Author
lsansonetti@apple.com
Date
2009-10-13 22:12:15 -0700 (Tue, 13 Oct 2009)

Log Message

implement rb_provided()

Modified Paths

Diff

Modified: MacRuby/trunk/load.c (2791 => 2792)


--- MacRuby/trunk/load.c	2009-10-14 02:11:51 UTC (rev 2791)
+++ MacRuby/trunk/load.c	2009-10-14 05:12:15 UTC (rev 2792)
@@ -35,7 +35,14 @@
 int
 rb_provided(const char *feature)
 {
-    // TODO
+    VALUE ary = get_loaded_features();
+    for (int i = 0, count = RARRAY_LEN(ary); i < count; i++) {
+	VALUE path = RARRAY_AT(ary, i);
+	// TODO: this is very naive
+	if (strstr(RSTRING_PTR(path), feature) != NULL) {
+	    return true;
+	}
+    }
     return false;
 }