Last change
on this file since 445 was 439, checked in by coas-nagasima, 4 years ago |
mrubyを2.1.1に更新
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-csrc;charset=UTF-8
|
File size:
666 bytes
|
Rev | Line | |
---|
[270] | 1 | /*
|
---|
| 2 | ** enum.c - Enumerable module
|
---|
| 3 | **
|
---|
| 4 | ** See Copyright Notice in mruby.h
|
---|
| 5 | */
|
---|
| 6 |
|
---|
[331] | 7 | #include <mruby.h>
|
---|
[439] | 8 | #include <mruby/proc.h>
|
---|
[270] | 9 |
|
---|
[439] | 10 | /* internal method `__update_hash(oldhash, index, itemhash)` */
|
---|
| 11 | static mrb_value
|
---|
| 12 | enum_update_hash(mrb_state *mrb, mrb_value self)
|
---|
| 13 | {
|
---|
| 14 | mrb_int hash;
|
---|
| 15 | mrb_int index;
|
---|
| 16 | mrb_int hv;
|
---|
| 17 |
|
---|
| 18 | mrb_get_args(mrb, "iii", &hash, &index, &hv);
|
---|
| 19 | hash ^= ((uint32_t)hv << (index % 16));
|
---|
| 20 |
|
---|
| 21 | return mrb_fixnum_value(hash);
|
---|
| 22 | }
|
---|
| 23 |
|
---|
[270] | 24 | void
|
---|
| 25 | mrb_init_enumerable(mrb_state *mrb)
|
---|
| 26 | {
|
---|
[439] | 27 | struct RClass *enumerable;
|
---|
| 28 | enumerable = mrb_define_module(mrb, "Enumerable"); /* 15.3.2 */
|
---|
| 29 | mrb_define_module_function(mrb, enumerable, "__update_hash", enum_update_hash, MRB_ARGS_REQ(3));
|
---|
[270] | 30 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.