source: EcnlProtoTool/trunk/mruby-2.1.1/src/enum.c@ 439

Last change on this file since 439 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
Line 
1/*
2** enum.c - Enumerable module
3**
4** See Copyright Notice in mruby.h
5*/
6
7#include <mruby.h>
8#include <mruby/proc.h>
9
10/* internal method `__update_hash(oldhash, index, itemhash)` */
11static mrb_value
12enum_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
24void
25mrb_init_enumerable(mrb_state *mrb)
26{
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));
30}
Note: See TracBrowser for help on using the repository browser.