Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
fdf87b7a
Commit
fdf87b7a
authored
Apr 03, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:mruby/mruby
parents
19c3c957
6b6f8937
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
4 deletions
+17
-4
include/mruby/khash.h
include/mruby/khash.h
+2
-3
mrbgems/mruby-array-ext/test/array.rb
mrbgems/mruby-array-ext/test/array.rb
+6
-1
mrbgems/mruby-objectspace/src/mruby_objectspace.c
mrbgems/mruby-objectspace/src/mruby_objectspace.c
+1
-0
mrbgems/mruby-objectspace/test/objectspace.rb
mrbgems/mruby-objectspace/test/objectspace.rb
+2
-0
tasks/mrbgems_test.rake
tasks/mrbgems_test.rake
+4
-0
test/no_mrb_open_test_dummy.rb
test/no_mrb_open_test_dummy.rb
+2
-0
No files found.
include/mruby/khash.h
View file @
fdf87b7a
...
@@ -46,6 +46,7 @@ static const uint8_t __m_either[] = {0x03, 0x0c, 0x30, 0xc0};
...
@@ -46,6 +46,7 @@ static const uint8_t __m_either[] = {0x03, 0x0c, 0x30, 0xc0};
} while (0)
} while (0)
#define khash_mask(h) ((h)->n_buckets-1)
#define khash_mask(h) ((h)->n_buckets-1)
#define khash_inc(h) ((h)->n_buckets/2-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
/* declare struct kh_xxx and kh_xxx_funcs
...
@@ -59,7 +60,6 @@ static const uint8_t __m_either[] = {0x03, 0x0c, 0x30, 0xc0};
...
@@ -59,7 +60,6 @@ static const uint8_t __m_either[] = {0x03, 0x0c, 0x30, 0xc0};
khint_t n_buckets; \
khint_t n_buckets; \
khint_t size; \
khint_t size; \
khint_t n_occupied; \
khint_t n_occupied; \
khint_t upper_bound; \
uint8_t *ed_flags; \
uint8_t *ed_flags; \
khkey_t *keys; \
khkey_t *keys; \
khval_t *vals; \
khval_t *vals; \
...
@@ -99,7 +99,6 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
...
@@ -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); \
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); \
uint8_t *p = (uint8_t*)mrb_malloc(mrb, sizeof(uint8_t)*sz/4+len*sz); \
h->size = h->n_occupied = 0; \
h->size = h->n_occupied = 0; \
h->upper_bound = UPPER_BOUND(sz); \
h->keys = (khkey_t *)p; \
h->keys = (khkey_t *)p; \
h->vals = kh_is_map ? (khval_t *)(p+sizeof(khkey_t)*sz) : NULL; \
h->vals = kh_is_map ? (khval_t *)(p+sizeof(khkey_t)*sz) : NULL; \
h->ed_flags = p+len*sz; \
h->ed_flags = p+len*sz; \
...
@@ -170,7 +169,7 @@ kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
...
@@ -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 kh_put_##name(mrb_state *mrb, kh_##name##_t *h, khkey_t key) \
{ \
{ \
khint_t k; \
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); \
kh_resize_##name(mrb, h, h->n_buckets*2); \
} \
} \
k = __hash_func(mrb,key) & khash_mask(h); \
k = __hash_func(mrb,key) & khash_mask(h); \
...
...
mrbgems/mruby-array-ext/test/array.rb
View file @
fdf87b7a
...
@@ -139,5 +139,10 @@ assert("Array#reverse_each") do
...
@@ -139,5 +139,10 @@ assert("Array#reverse_each") do
b
<<
i
b
<<
i
end
end
assert_equal
[
"d"
,
"c"
,
"b"
,
"a"
],
b
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
end
mrbgems/mruby-objectspace/src/mruby_objectspace.c
View file @
fdf87b7a
...
@@ -90,6 +90,7 @@ os_count_objects(mrb_state *mrb, mrb_value self)
...
@@ -90,6 +90,7 @@ os_count_objects(mrb_state *mrb, mrb_value self)
COUNT_TYPE
(
T_FILE
);
COUNT_TYPE
(
T_FILE
);
COUNT_TYPE
(
T_ENV
);
COUNT_TYPE
(
T_ENV
);
COUNT_TYPE
(
T_DATA
);
COUNT_TYPE
(
T_DATA
);
COUNT_TYPE
(
T_FIBER
);
#undef COUNT_TYPE
#undef COUNT_TYPE
default:
default:
type
=
mrb_fixnum_value
(
i
);
break
;
type
=
mrb_fixnum_value
(
i
);
break
;
...
...
mrbgems/mruby-objectspace/test/objectspace.rb
View file @
fdf87b7a
assert
(
'ObjectSpace.count_objects'
)
do
assert
(
'ObjectSpace.count_objects'
)
do
h
=
{}
h
=
{}
f
=
Fiber
.
new
{}
if
Object
.
const_defined?
:Fiber
ObjectSpace
.
count_objects
(
h
)
ObjectSpace
.
count_objects
(
h
)
assert_kind_of
(
Hash
,
h
)
assert_kind_of
(
Hash
,
h
)
assert_true
(
h
.
keys
.
all?
{
|
x
|
x
.
is_a?
(
Symbol
)
||
x
.
is_a?
(
Integer
)
})
assert_true
(
h
.
keys
.
all?
{
|
x
|
x
.
is_a?
(
Symbol
)
||
x
.
is_a?
(
Integer
)
})
...
@@ -7,6 +8,7 @@ assert('ObjectSpace.count_objects') do
...
@@ -7,6 +8,7 @@ assert('ObjectSpace.count_objects') do
assert_true
(
h
.
has_key?
(
:TOTAL
))
assert_true
(
h
.
has_key?
(
:TOTAL
))
assert_true
(
h
.
has_key?
(
:FREE
))
assert_true
(
h
.
has_key?
(
:FREE
))
assert_true
(
h
.
has_key?
(
:T_FIBER
))
if
Object
.
const_defined?
:Fiber
h
=
ObjectSpace
.
count_objects
h
=
ObjectSpace
.
count_objects
assert_kind_of
(
Hash
,
h
)
assert_kind_of
(
Hash
,
h
)
...
...
tasks/mrbgems_test.rake
View file @
fdf87b7a
...
@@ -111,6 +111,10 @@ MRuby.each_target do
...
@@ -111,6 +111,10 @@ MRuby.each_target do
no_mrb_open_test_rbfiles
=
no_mrb_open_test_gem
.
reduce
([])
{
|
res
,
v
|
no_mrb_open_test_rbfiles
=
no_mrb_open_test_gem
.
reduce
([])
{
|
res
,
v
|
res
+=
v
.
test_rbfiles
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
}
.o"
=>
"
#{
no_mrb_open_test
}
.c"
file
"
#{
no_mrb_open_test
}
.c"
=>
no_mrb_open_test_rbfiles
do
|
t
|
file
"
#{
no_mrb_open_test
}
.c"
=>
no_mrb_open_test_rbfiles
do
|
t
|
open
(
t
.
name
,
'w'
)
do
|
f
|
open
(
t
.
name
,
'w'
)
do
|
f
|
...
...
test/no_mrb_open_test_dummy.rb
0 → 100644
View file @
fdf87b7a
#dummy
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment