Skip to content

Commit

Permalink
Follow MacRuby style guidelines with stack-passing blocks in struct.c
Browse files Browse the repository at this point in the history
  • Loading branch information
macrotis committed May 30, 2012
1 parent e80a075 commit 3c06b54
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions struct.c
Expand Up @@ -166,19 +166,19 @@ make_struct(VALUE name, VALUE members, VALUE klass)
ID id = SYM2ID(RARRAY_AT(members, i));
if (rb_is_local_id(id) || rb_is_const_id(id)) {
long j = i; /* Needed for block data reference. */
/* Struct attribute reader */
rb_objc_define_method(nstr, rb_id2name(id),
pl_imp_implementationWithBlock(^(VALUE obj) {
return RSTRUCT_PTR(obj)[j];
}), 0);
/* Struct attribute writer */
rb_objc_define_method(nstr, rb_id2name(rb_id_attrset(id)),
pl_imp_implementationWithBlock(^(VALUE obj, VALUE val) {
VALUE *ptr = RSTRUCT_PTR(obj);
rb_struct_modify(obj);
GC_WB(&ptr[i], val);
return val;
}), 1);
/* Struct attribute reader */
rb_objc_define_method(nstr, rb_id2name(id),
pl_imp_implementationWithBlock(^(VALUE obj) {
return RSTRUCT_PTR(obj)[j];
}), 0);
/* Struct attribute writer */
rb_objc_define_method(nstr, rb_id2name(rb_id_attrset(id)),
pl_imp_implementationWithBlock(^(VALUE obj, VALUE val) {
VALUE *ptr = RSTRUCT_PTR(obj);
rb_struct_modify(obj);
GC_WB(&ptr[i], val);
return val;
}), 1);
}
}

Expand Down

0 comments on commit 3c06b54

Please sign in to comment.