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
ba8a8e75
Commit
ba8a8e75
authored
Feb 14, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1702 from cremno/hash-hash-ext-changes
hash / hash-ext: various small changes
parents
69eaaa14
4ffea85b
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
285 deletions
+13
-285
mrbgems/mruby-hash-ext/src/hash-ext.c
mrbgems/mruby-hash-ext/src/hash-ext.c
+8
-19
src/hash.c
src/hash.c
+5
-266
No files found.
mrbgems/mruby-hash-ext/src/hash-ext.c
View file @
ba8a8e75
...
...
@@ -7,7 +7,6 @@
#include "mruby.h"
#include "mruby/array.h"
#include "mruby/hash.h"
#include "mruby/khash.h"
/*
* call-seq:
...
...
@@ -20,27 +19,18 @@
* h.values_at("cow", "cat") #=> ["bovine", "feline"]
*/
mrb_value
mrb_hash_values_at
(
mrb_state
*
mrb
,
int
argc
,
mrb_value
*
argv
,
mrb_value
hash
)
{
mrb_value
result
=
mrb_ary_new_capa
(
mrb
,
argc
);
long
i
;
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
mrb_ary_push
(
mrb
,
result
,
mrb_hash_get
(
mrb
,
hash
,
argv
[
i
]));
}
return
result
;
}
static
mrb_value
hash_values_at
(
mrb_state
*
mrb
,
mrb_value
hash
)
{
mrb_value
*
argv
;
int
argc
;
mrb_value
*
argv
,
result
;
int
argc
,
i
;
mrb_get_args
(
mrb
,
"*"
,
&
argv
,
&
argc
);
return
mrb_hash_values_at
(
mrb
,
argc
,
argv
,
hash
);
result
=
mrb_ary_new_capa
(
mrb
,
argc
);
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
mrb_ary_push
(
mrb
,
result
,
mrb_hash_get
(
mrb
,
hash
,
argv
[
i
]));
}
return
result
;
}
void
...
...
@@ -49,7 +39,6 @@ mrb_mruby_hash_ext_gem_init(mrb_state *mrb)
struct
RClass
*
h
;
h
=
mrb
->
hash_class
;
mrb_define_method
(
mrb
,
h
,
"values_at"
,
hash_values_at
,
MRB_ARGS_ANY
());
}
...
...
src/hash.c
View file @
ba8a8e75
This diff is collapsed.
Click to expand it.
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