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
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'ext/msgpack/packer_class.c', line 81
VALUE MessagePack_Packer_initialize(int argc, VALUE* argv, VALUE self)
{
if(argc > 2) {
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0..2)", argc);
}
VALUE io = Qnil;
VALUE options = Qnil;
if(argc >= 1) {
io = argv[0];
}
if(argc == 2) {
options = argv[1];
}
if (options == Qnil && rb_type(io) == T_HASH) {
options = io;
io = Qnil;
}
if(options != Qnil) {
Check_Type(options, T_HASH);
}
msgpack_packer_t *pk = MessagePack_Packer_get(self);
msgpack_packer_ext_registry_init(self, &pk->ext_registry);
pk->buffer_ref = MessagePack_Buffer_wrap(PACKER_BUFFER_(pk), self);
MessagePack_Buffer_set_options(PACKER_BUFFER_(pk), io, options);
if(options != Qnil) {
VALUE v;
v = rb_hash_aref(options, sym_compatibility_mode);
msgpack_packer_set_compat(pk, RTEST(v));
}
return self;
}
|