ext/attribute_builder/attribute_builder.c in faml-0.3.3 vs ext/attribute_builder/attribute_builder.c in faml-0.3.4

- old
+ new

@@ -8,10 +8,12 @@ #else # define RARRAY_AREF(a, i) RARRAY_PTR(a)[i] # define rb_ary_new_capa rb_ary_new2 #endif +#define FOREACH_FUNC(func) ((int (*)(ANYARGS))(func)) + VALUE rb_mAttributeBuilder; static ID id_keys, id_sort_bang, id_uniq_bang, id_merge_bang; static ID id_id, id_class, id_underscore, id_hyphen, id_space, id_equal; static void @@ -41,11 +43,11 @@ static VALUE stringify_keys(VALUE hash) { VALUE h = rb_hash_new(); - rb_hash_foreach(hash, stringify_keys_i, h); + rb_hash_foreach(hash, FOREACH_FUNC(stringify_keys_i), h); return h; } struct normalize_data_i2_arg { VALUE key, normalized; @@ -99,11 +101,11 @@ if (RB_TYPE_P(value, T_HASH)) { struct normalize_data_i2_arg arg; arg.key = key; arg.normalized = normalized; - rb_hash_foreach(normalize_data(value), normalize_data_i2, (VALUE)(&arg)); + rb_hash_foreach(normalize_data(value), FOREACH_FUNC(normalize_data_i2), (VALUE)(&arg)); } else if (RB_TYPE_P(value, T_TRUE)) { /* Keep Qtrue value */ rb_hash_aset(normalized, key, value); } else if (RB_TYPE_P(value, T_FALSE) || NIL_P(value)) { /* Delete falsey values */ @@ -118,11 +120,11 @@ { VALUE normalized; Check_Type(data, T_HASH); normalized = rb_hash_new(); - rb_hash_foreach(data, normalize_data_i, normalized); + rb_hash_foreach(data, FOREACH_FUNC(normalize_data_i), normalized); return normalized; } static int put_data_attribute(VALUE key, VALUE val, VALUE hash) @@ -149,10 +151,10 @@ if (RB_TYPE_P(value, T_HASH) && RSTRING_LEN(key) == 4 && memcmp(RSTRING_PTR(key), "data", 4) == 0) { VALUE data; rb_hash_delete(hash, key); data = normalize_data(value); - rb_hash_foreach(data, put_data_attribute, hash); + rb_hash_foreach(data, FOREACH_FUNC(put_data_attribute), hash); } else if (RB_TYPE_P(value, T_TRUE)) { /* Keep Qtrue value */ } else if (RB_TYPE_P(value, T_FALSE) || NIL_P(value)) { rb_hash_delete(hash, key); } else {