summaryrefslogtreecommitdiff
path: root/struct.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-12-07 09:25:55 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-12-07 09:25:55 +0000
commitc18d3740a925e8752c3b93acea6087fb0e03be53 (patch)
tree433875ec298641b66886505abab4d16b7b555cd6 /struct.c
parentdee96209bfbb957538c7adeb01a65f3830749179 (diff)
991207
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'struct.c')
-rw-r--r--struct.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/struct.c b/struct.c
index 50b273b..b14b820 100644
--- a/struct.c
+++ b/struct.c
@@ -547,6 +547,13 @@ rb_struct_hash(s)
return INT2FIX(h);
}
+static VALUE
+rb_struct_size(s)
+ VALUE s;
+{
+ return INT2FIX(RSTRUCT(s)->len);
+}
+
void
Init_Struct()
{
@@ -566,6 +573,8 @@ Init_Struct()
rb_define_method(rb_cStruct, "inspect", rb_struct_inspect, 0);
rb_define_method(rb_cStruct, "to_a", rb_struct_to_a, 0);
rb_define_method(rb_cStruct, "values", rb_struct_to_a, 0);
+ rb_define_method(rb_cStruct, "size", rb_struct_size, 0);
+ rb_define_method(rb_cStruct, "length", rb_struct_size, 0);
rb_define_method(rb_cStruct, "each", rb_struct_each, 0);
rb_define_method(rb_cStruct, "[]", rb_struct_aref, 1);