mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge branch 'master' of github.com:mruby/mruby
This commit is contained in:
@@ -46,6 +46,7 @@ static const uint8_t __m_either[] = {0x03, 0x0c, 0x30, 0xc0};
|
||||
} while (0)
|
||||
#define khash_mask(h) ((h)->n_buckets-1)
|
||||
#define khash_inc(h) ((h)->n_buckets/2-1)
|
||||
#define khash_upper_bound(h) (UPPER_BOUND((h)->n_buckets))
|
||||
|
||||
/* declare struct kh_xxx and kh_xxx_funcs
|
||||
|
||||
@@ -59,7 +60,6 @@ static const uint8_t __m_either[] = {0x03, 0x0c, 0x30, 0xc0};
|
||||
khint_t n_buckets; \
|
||||
khint_t size; \
|
||||
khint_t n_occupied; \
|
||||
khint_t upper_bound; \
|
||||
uint8_t *ed_flags; \
|
||||
khkey_t *keys; \
|
||||
khval_t *vals; \
|
||||
@@ -99,7 +99,6 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
|
||||
size_t len = sizeof(khkey_t) + (kh_is_map ? sizeof(khval_t) : 0); \
|
||||
uint8_t *p = (uint8_t*)mrb_malloc(mrb, sizeof(uint8_t)*sz/4+len*sz); \
|
||||
h->size = h->n_occupied = 0; \
|
||||
h->upper_bound = UPPER_BOUND(sz); \
|
||||
h->keys = (khkey_t *)p; \
|
||||
h->vals = kh_is_map ? (khval_t *)(p+sizeof(khkey_t)*sz) : NULL; \
|
||||
h->ed_flags = p+len*sz; \
|
||||
@@ -170,7 +169,7 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
|
||||
khint_t kh_put_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key) \
|
||||
{ \
|
||||
khint_t k; \
|
||||
if (h->n_occupied >= h->upper_bound) { \
|
||||
if (h->n_occupied >= khash_upper_bound(h)) { \
|
||||
kh_resize_##name(mrb, h, h->n_buckets*2); \
|
||||
} \
|
||||
k = __hash_func(mrb,key) & khash_mask(h); \
|
||||
|
||||
@@ -139,5 +139,10 @@ assert("Array#reverse_each") do
|
||||
b << i
|
||||
end
|
||||
assert_equal [ "d", "c", "b", "a" ], b
|
||||
assert_equal [ "d", "c", "b", "a" ], a.reverse_each.to_a
|
||||
|
||||
if Object.const_defined?(:Enumerator)
|
||||
assert_equal [ "d", "c", "b", "a" ], a.reverse_each.to_a
|
||||
else
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -90,6 +90,7 @@ os_count_objects(mrb_state *mrb, mrb_value self)
|
||||
COUNT_TYPE(T_FILE);
|
||||
COUNT_TYPE(T_ENV);
|
||||
COUNT_TYPE(T_DATA);
|
||||
COUNT_TYPE(T_FIBER);
|
||||
#undef COUNT_TYPE
|
||||
default:
|
||||
type = mrb_fixnum_value(i); break;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
assert('ObjectSpace.count_objects') do
|
||||
h = {}
|
||||
f = Fiber.new {} if Object.const_defined? :Fiber
|
||||
ObjectSpace.count_objects(h)
|
||||
assert_kind_of(Hash, h)
|
||||
assert_true(h.keys.all? {|x| x.is_a?(Symbol) || x.is_a?(Integer) })
|
||||
@@ -7,6 +8,7 @@ assert('ObjectSpace.count_objects') do
|
||||
|
||||
assert_true(h.has_key?(:TOTAL))
|
||||
assert_true(h.has_key?(:FREE))
|
||||
assert_true(h.has_key?(:T_FIBER)) if Object.const_defined? :Fiber
|
||||
|
||||
h = ObjectSpace.count_objects
|
||||
assert_kind_of(Hash, h)
|
||||
|
||||
@@ -111,6 +111,10 @@ MRuby.each_target do
|
||||
no_mrb_open_test_rbfiles = no_mrb_open_test_gem.reduce([]) { |res, v|
|
||||
res += v.test_rbfiles
|
||||
}
|
||||
if no_mrb_open_test_rbfiles.empty?
|
||||
no_mrb_open_test_rbfiles << "#{MRUBY_ROOT}/test/no_mrb_open_test_dummy.rb"
|
||||
end
|
||||
|
||||
file "#{no_mrb_open_test}.o" => "#{no_mrb_open_test}.c"
|
||||
file "#{no_mrb_open_test}.c" => no_mrb_open_test_rbfiles do |t|
|
||||
open(t.name, 'w') do |f|
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
#dummy
|
||||
|
||||
Reference in New Issue
Block a user