Revision: 2850 http://trac.macosforge.org/projects/ruby/changeset/2850 Author: lsansonetti@apple.com Date: 2009-10-18 20:28:40 -0700 (Sun, 18 Oct 2009) Log Message: ----------- expose a new API (to be used by a future patch) Modified Paths: -------------- MacRuby/trunk/objc.h MacRuby/trunk/objc.m Modified: MacRuby/trunk/objc.h =================================================================== --- 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 =================================================================== --- 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;