70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'ext/cbor/unpacker_class.c', line 70
static VALUE Unpacker_initialize(int argc, VALUE* argv, VALUE self)
{
VALUE io = Qnil;
VALUE options = Qnil;
if(argc == 0 || (argc == 1 && argv[0] == Qnil)) {
/* Qnil */
} else if(argc == 1) {
VALUE v = argv[0];
if(rb_type(v) == T_HASH) {
options = v;
} else {
io = v;
}
} else if(argc == 2) {
io = argv[0];
options = argv[1];
if(rb_type(options) != T_HASH) {
rb_raise(rb_eArgError, "expected Hash but found %s.", rb_obj_classname(options));
}
} else {
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0..1)", argc);
}
UNPACKER(self, uk);
if(io != Qnil || options != Qnil) {
MessagePack_Buffer_initialize(UNPACKER_BUFFER_(uk), io, options);
if (options != Qnil) {
VALUE v;
v = rb_hash_aref(options, ID2SYM(rb_intern("symbolize_keys")));
uk->keys_as_symbols = RTEST(v);
}
}
// TODO options
return self;
}
|