Modified: MacRuby/trunk/objc.h (2849 => 2850)
--- MacRuby/trunk/objc.h 2009-10-18 19:40:00 UTC (rev 2849)
+++ MacRuby/trunk/objc.h 2009-10-19 03:28:40 UTC (rev 2850)
@@ -80,6 +80,8 @@
id rb_rb2oc_exception(VALUE exc);
VALUE rb_oc2rb_exception(id exc);
+size_t rb_objc_type_size(const char *type);
+
static inline int
SubtypeUntil(const char *type, char end)
{
Modified: MacRuby/trunk/objc.m (2849 => 2850)
--- MacRuby/trunk/objc.m 2009-10-18 19:40:00 UTC (rev 2849)
+++ MacRuby/trunk/objc.m 2009-10-19 03:28:40 UTC (rev 2850)
@@ -643,6 +643,21 @@
return rb_exc_new2(rb_eRuntimeError, buf);
}
+size_t
+rb_objc_type_size(const char *type)
+{
+ @try {
+ NSUInteger size, align;
+ NSGetSizeAndAlignment(type, &size, &align);
+ return size;
+ }
+ @catch (id ex) {
+ rb_raise(rb_eRuntimeError, "can't get the size of type `%s': %s",
+ type, [[ex description] UTF8String]);
+ }
+ return 0; // never reached
+}
+
void *placeholder_String = NULL;
void *placeholder_Dictionary = NULL;
void *placeholder_Array = NULL;