Last change
on this file since 331 was 331, checked in by coas-nagasima, 6 years ago |
prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-csrc;charset=UTF-8
|
File size:
1.0 KB
|
Line | |
---|
1 | /*
|
---|
2 | ** hash.c - Hash class
|
---|
3 | **
|
---|
4 | ** See Copyright Notice in mruby.h
|
---|
5 | */
|
---|
6 |
|
---|
7 | #include <mruby.h>
|
---|
8 | #include <mruby/array.h>
|
---|
9 | #include <mruby/hash.h>
|
---|
10 |
|
---|
11 | /*
|
---|
12 | * call-seq:
|
---|
13 | * hsh.values_at(key, ...) -> array
|
---|
14 | *
|
---|
15 | * Return an array containing the values associated with the given keys.
|
---|
16 | * Also see <code>Hash.select</code>.
|
---|
17 | *
|
---|
18 | * h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" }
|
---|
19 | * h.values_at("cow", "cat") #=> ["bovine", "feline"]
|
---|
20 | */
|
---|
21 |
|
---|
22 | static mrb_value
|
---|
23 | hash_values_at(mrb_state *mrb, mrb_value hash)
|
---|
24 | {
|
---|
25 | mrb_value *argv, result;
|
---|
26 | mrb_int argc, i;
|
---|
27 | int ai;
|
---|
28 |
|
---|
29 | mrb_get_args(mrb, "*", &argv, &argc);
|
---|
30 | result = mrb_ary_new_capa(mrb, argc);
|
---|
31 | ai = mrb_gc_arena_save(mrb);
|
---|
32 | for (i = 0; i < argc; i++) {
|
---|
33 | mrb_ary_push(mrb, result, mrb_hash_get(mrb, hash, argv[i]));
|
---|
34 | mrb_gc_arena_restore(mrb, ai);
|
---|
35 | }
|
---|
36 | return result;
|
---|
37 | }
|
---|
38 |
|
---|
39 | void
|
---|
40 | mrb_mruby_hash_ext_gem_init(mrb_state *mrb)
|
---|
41 | {
|
---|
42 | struct RClass *h;
|
---|
43 |
|
---|
44 | h = mrb->hash_class;
|
---|
45 | mrb_define_method(mrb, h, "values_at", hash_values_at, MRB_ARGS_ANY());
|
---|
46 | }
|
---|
47 |
|
---|
48 | void
|
---|
49 | mrb_mruby_hash_ext_gem_final(mrb_state *mrb)
|
---|
50 | {
|
---|
51 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.