[macruby-changes] [5117] MacRuby/trunk/bridgesupport.cpp

source_changes at macosforge.org source_changes at macosforge.org
Tue Jan 4 21:50:19 PST 2011


Revision: 5117
          http://trac.macosforge.org/projects/ruby/changeset/5117
Author:   lsansonetti at apple.com
Date:     2011-01-04 21:50:15 -0800 (Tue, 04 Jan 2011)
Log Message:
-----------
add #size class method on struct classes

Modified Paths:
--------------
    MacRuby/trunk/bridgesupport.cpp

Modified: MacRuby/trunk/bridgesupport.cpp
===================================================================
--- MacRuby/trunk/bridgesupport.cpp	2011-01-05 05:49:05 UTC (rev 5116)
+++ MacRuby/trunk/bridgesupport.cpp	2011-01-05 05:50:15 UTC (rev 5117)
@@ -582,6 +582,16 @@
 }
 
 static VALUE
+rb_boxed_size(VALUE rcv, SEL sel)
+{
+    rb_vm_bs_boxed_t *bs_boxed = locate_bs_boxed(rcv);
+    if (bs_boxed->bs_type == BS_ELEMENT_STRUCT) {
+	return LONG2NUM(GET_CORE()->get_sizeof(bs_boxed->as.s->type));
+    }
+    return Qnil;
+}
+
+static VALUE
 rb_vm_opaque_new(VALUE rcv, SEL sel)
 {
     // XXX instead of doing this, we should perhaps simply delete the new
@@ -639,6 +649,8 @@
 	// Define other utility methods.
 	rb_objc_define_method(*(VALUE *)boxed->klass, "fields",
 		(void *)rb_boxed_fields, 0);
+	rb_objc_define_method(*(VALUE *)boxed->klass, "size",
+		(void *)rb_boxed_size, 0);
 	rb_objc_define_method(boxed->klass, "dup",
 		(void *)rb_vm_struct_dup, 0);
 	rb_objc_define_method(boxed->klass, "clone",
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20110104/2a530a9b/attachment.html>


More information about the macruby-changes mailing list