sereal 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50eec33dee006e2986b5ef0bb2b5c8b0718dd8da
4
- data.tar.gz: 495d916c5921970104274bb1f156f7e63551de53
3
+ metadata.gz: be6217bfe2c81f0f7d3629fa097268a8f2c6733d
4
+ data.tar.gz: 9fe57e2249069b77131d74a804690bb1c7c552b3
5
5
  SHA512:
6
- metadata.gz: db64209177c66c89f9d81ccd1feb2375e5b5bc2f4e09aef1b8aa2312f31d63cc129170f3ef90489797c8efe660c83410c152694b8e990f2c71d255197871ca1c
7
- data.tar.gz: e596221d097d6187a92edfc0321287d32d28dbc67e04d3bd76298285d7a4a4a65675fc8661528dd640696194dead242a3dbdc0089956d00c93e7d863c7128aa9
6
+ metadata.gz: cc6658e1080248464d912bfc794c7d0d42a1e825ff25f5ef513b39a9b1e00861278fec81089c2d0a940afd446f827ada673c906b5e4c1628d6b2d5c3d96efe68
7
+ data.tar.gz: 220da226733dcb0ef43a96f5505d0de35165468685a3cbf592a8df523cc035b2ce106117cd3f3026451019fff249587551d579ba12d97f0868af04504ac25ca7
@@ -189,7 +189,7 @@ static VALUE s_read_ref(sereal_t *s, u8 tag) {
189
189
  u32 offset = s_get_varint_bang(s) - 1; \
190
190
  __stored = s->pos; \
191
191
  s->pos = offset + s->hdr_end; \
192
- SD(s,"going back offset: %d, stored position: %d (tag: %d)",offset,stored_pos,tag); \
192
+ SD(s,"going back offset: %d, stored position: %d (tag: %d) new pos: %d",offset,stored_pos,tag,s->pos); \
193
193
  } while(0)
194
194
  #define BACK(s,__stored) \
195
195
  do { \
@@ -237,9 +237,9 @@ static VALUE s_read_object_freeze(sereal_t *s, u8 tag) {
237
237
  s_raise(s,rb_eTypeError,"object_freeze received, but decoder is initialized without Sereal::THAW option");
238
238
 
239
239
  u32 stored_pos = 0;
240
- if (tag == SRL_HDR_OBJECTV_FREEZE)
240
+ if (tag == SRL_HDR_OBJECTV_FREEZE) {
241
241
  TRAVEL(s,stored_pos);
242
-
242
+ }
243
243
  VALUE s_klass = sereal_to_rb_object(s);
244
244
  BACK(s,stored_pos);
245
245
  MUST_BE_SOMETHING(s_klass,T_STRING);
@@ -160,18 +160,18 @@ static void s_append_symbol(sereal_t *s, VALUE object) {
160
160
  s_append_rb_string(s,string);
161
161
  }
162
162
 
163
- static void s_append_copy(sereal_t *s, VALUE object) {
163
+ static void s_append_copy(sereal_t *s, u8 tag,VALUE object) {
164
164
  u32 pos = FIX2LONG(object);
165
- s_append_hdr_with_varint(s,SRL_HDR_COPY,pos - s->hdr_end + 1);
165
+ s_append_hdr_with_varint(s,tag,pos - s->hdr_end + 1);
166
166
  }
167
167
 
168
- static VALUE s_copy_or_keep_in_mind(sereal_t *s, VALUE object) {
168
+ static VALUE s_copy_or_keep_in_mind(sereal_t *s, VALUE object, u8 offset) {
169
169
  if (s->copy == Qnil)
170
170
  return Qnil;
171
171
 
172
172
  VALUE stored_position = rb_hash_lookup(s->copy,object);
173
173
  if (stored_position == Qnil)
174
- rb_hash_aset(s->copy,object,INT2FIX(s->pos));
174
+ rb_hash_aset(s->copy,object,INT2FIX(s->pos + offset));
175
175
  return stored_position;
176
176
  }
177
177
 
@@ -185,10 +185,12 @@ static VALUE s_copy_or_keep_in_mind(sereal_t *s, VALUE object) {
185
185
  static void s_append_object(sereal_t *s, VALUE object) {
186
186
  if (s->flags & __THAW && rb_obj_respond_to(object,FREEZE,0)) {
187
187
  VALUE klass = rb_class_path(CLASS_OF(object));
188
- VALUE copy = s_copy_or_keep_in_mind(s,klass);
188
+ // keep in mind with offset + 1
189
+ // because of the SRL_HDR_OBJECT_FREEZE header taking 1 byte
190
+ // and we want to point to the next string
191
+ VALUE copy = s_copy_or_keep_in_mind(s,klass,1);
189
192
  if (copy != Qnil) {
190
- s_append_u8(s,SRL_HDR_OBJECTV_FREEZE);
191
- s_append_copy(s,copy);
193
+ s_append_copy(s,SRL_HDR_OBJECTV_FREEZE,copy);
192
194
  } else {
193
195
  s_append_u8(s,SRL_HDR_OBJECT_FREEZE);
194
196
  s_append_rb_string(s,klass);
@@ -301,9 +303,9 @@ static void rb_object_to_sereal(sereal_t *s, VALUE object) {
301
303
  }
302
304
  rb_hash_aset(s->tracked,id,INT2FIX(pos));
303
305
  }
304
- stored = s_copy_or_keep_in_mind(s,object);
306
+ stored = s_copy_or_keep_in_mind(s,object,0);
305
307
  if (stored != Qnil) {
306
- s_append_copy(s,stored);
308
+ s_append_copy(s,SRL_HDR_COPY,stored);
307
309
  goto out;
308
310
  }
309
311
  }
@@ -272,7 +272,6 @@ void Init_sereal() {
272
272
  *
273
273
  */
274
274
  rb_define_const(Sereal, "DEBUG",INT2NUM(__DEBUG));
275
- rb_define_const(Sereal, "DEBUG",INT2NUM(__DEBUG));
276
275
 
277
276
  s_init_writers();
278
277
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sereal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Borislav Nikolov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-02 00:00:00.000000000 Z
11
+ date: 2014-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler