diff options
| -rw-r--r-- | include/mruby/hash.h | 1 | ||||
| -rw-r--r-- | src/hash.c | 6 | ||||
| -rw-r--r-- | tasks/mrbgems_test.rake | 12 | ||||
| -rw-r--r-- | tools/mrbc/mrbc.rake | 2 |
4 files changed, 14 insertions, 7 deletions
diff --git a/include/mruby/hash.h b/include/mruby/hash.h index bb12962ca..acb9de93b 100644 --- a/include/mruby/hash.h +++ b/include/mruby/hash.h @@ -29,6 +29,7 @@ mrb_value mrb_hash_fetch(mrb_state *mrb, mrb_value hash, mrb_value key, mrb_valu mrb_value mrb_hash_delete_key(mrb_state *mrb, mrb_value hash, mrb_value key); mrb_value mrb_hash(mrb_state *mrb, mrb_value obj); mrb_value mrb_hash_keys(mrb_state *mrb, mrb_value hash); +mrb_value mrb_check_hash_type(mrb_state *mrb, mrb_value hash); /* RHASH_TBL allocates st_table if not available. */ #define RHASH(obj) ((struct RHash*)((obj).value.p)) diff --git a/src/hash.c b/src/hash.c index c7a419250..26d9b78b0 100644 --- a/src/hash.c +++ b/src/hash.c @@ -187,6 +187,12 @@ mrb_hash_modify_check(mrb_state *mrb, mrb_value hash) //if (OBJ_FROZEN(hash)) mrb_error_frozen("hash"); } +mrb_value +mrb_check_hash_type(mrb_state *mrb, mrb_value hash) +{ + return mrb_check_convert_type(mrb, hash, MRB_TT_HASH, "Hash", "to_hash"); +} + khash_t(ht) * mrb_hash_tbl(mrb_state *mrb, mrb_value hash) { diff --git a/tasks/mrbgems_test.rake b/tasks/mrbgems_test.rake index f247718a0..bbdc0169f 100644 --- a/tasks/mrbgems_test.rake +++ b/tasks/mrbgems_test.rake @@ -19,10 +19,10 @@ MRuby.each_target do end f.puts %Q[void mrb_#{g.funcname}_gem_test(mrb_state *mrb);] unless g.test_objs.empty? f.puts %Q[void GENERATED_TMP_mrb_#{g.funcname}_gem_test(mrb_state *mrb) {] - f.puts %Q[ mrb_state *mrb2;] - f.puts %Q[ mrb_value val1, val2, ary1, ary2;] - f.puts %Q[ int ai;] unless g.test_rbfiles.empty? + f.puts %Q[ mrb_state *mrb2;] + f.puts %Q[ mrb_value val1, val2, ary1, ary2;] + f.puts %Q[ int ai;] g.test_rbfiles.count.times do |i| f.puts %Q[ ai = mrb_gc_arena_save(mrb);] f.puts %Q[ mrb2 = mrb_open();] @@ -43,9 +43,9 @@ MRuby.each_target do f.puts %Q[ ] %w(ok_test ko_test kill_test).each do |vname| - f.puts %Q[ val1 = mrb_gv_get(mrb2, mrb_intern(mrb, "$#{vname}"));] - f.puts %Q[ if(mrb_fixnum_p(val1)) {] - f.puts %Q[ val2 = mrb_gv_get(mrb, mrb_intern(mrb, "$#{vname}"));] + f.puts %Q[ val2 = mrb_gv_get(mrb2, mrb_intern(mrb2, "$#{vname}"));] + f.puts %Q[ if(mrb_fixnum_p(val2)) {] + f.puts %Q[ val1 = mrb_gv_get(mrb, mrb_intern(mrb, "$#{vname}"));] f.puts %Q[ mrb_gv_set(mrb, mrb_intern(mrb, "$#{vname}"), mrb_fixnum_value(mrb_fixnum(val1) + mrb_fixnum(val2)));] f.puts %Q[ }\n] end diff --git a/tools/mrbc/mrbc.rake b/tools/mrbc/mrbc.rake index bff88312a..74e04bed5 100644 --- a/tools/mrbc/mrbc.rake +++ b/tools/mrbc/mrbc.rake @@ -6,7 +6,7 @@ MRuby.each_target do objs = Dir.glob("#{dir}/*.{c}").map { |f| f.pathmap("#{build_dir}/%X.o") } file exec => objs + ["#{build_dir}/lib/libmruby_core.a"] do |t| - link t.name, t.prerequisites, [], gems.map { |g| g.mruby_libs } + link t.name, t.prerequisites end end end |
