sereal 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/sereal/buffer.h +8 -2
- data/ext/sereal/decode.c +1 -1
- data/ext/sereal/encode.c +13 -11
- data/ext/sereal/sereal.c +2 -1
- data/ext/sereal/sereal.h +1 -1
- metadata +19 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50eec33dee006e2986b5ef0bb2b5c8b0718dd8da
|
4
|
+
data.tar.gz: 495d916c5921970104274bb1f156f7e63551de53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db64209177c66c89f9d81ccd1feb2375e5b5bc2f4e09aef1b8aa2312f31d63cc129170f3ef90489797c8efe660c83410c152694b8e990f2c71d255197871ca1c
|
7
|
+
data.tar.gz: e596221d097d6187a92edfc0321287d32d28dbc67e04d3bd76298285d7a4a4a65675fc8661528dd640696194dead242a3dbdc0089956d00c93e7d863c7128aa9
|
data/ext/sereal/buffer.h
CHANGED
@@ -14,7 +14,7 @@ static inline void s_init_tracker(sereal_t *s) {
|
|
14
14
|
if (s->tracked == Qnil) {
|
15
15
|
SD(s,"initializing tracker");
|
16
16
|
s->tracked = rb_hash_new();
|
17
|
-
|
17
|
+
rb_gc_register_address(&s->tracked);
|
18
18
|
}
|
19
19
|
}
|
20
20
|
|
@@ -27,7 +27,7 @@ static inline void s_reset_tracker(sereal_t *s) {
|
|
27
27
|
static inline void s_init_copy(sereal_t *s) {
|
28
28
|
if (s->copy == Qnil) {
|
29
29
|
s->copy = rb_hash_new();
|
30
|
-
|
30
|
+
rb_gc_register_address(&s->tracked);
|
31
31
|
}
|
32
32
|
}
|
33
33
|
|
@@ -35,6 +35,12 @@ static inline void s_destroy(sereal_t *s) {
|
|
35
35
|
if (!s)
|
36
36
|
return;
|
37
37
|
s_reset_tracker(s);
|
38
|
+
if (s->tracked != Qnil)
|
39
|
+
rb_gc_unregister_address(&s->tracked);
|
40
|
+
|
41
|
+
if (s->copy != Qnil)
|
42
|
+
rb_gc_unregister_address(&s->copy);
|
43
|
+
|
38
44
|
s_free_data_if_not_mine(s);
|
39
45
|
free(s);
|
40
46
|
}
|
data/ext/sereal/decode.c
CHANGED
@@ -245,7 +245,7 @@ static VALUE s_read_object_freeze(sereal_t *s, u8 tag) {
|
|
245
245
|
MUST_BE_SOMETHING(s_klass,T_STRING);
|
246
246
|
|
247
247
|
// hash it?
|
248
|
-
VALUE klass =
|
248
|
+
VALUE klass = rb_path_to_class(s_klass);
|
249
249
|
if (!rb_obj_respond_to(klass,THAW,0))
|
250
250
|
s_raise(s,rb_eTypeError,"class: %s does not respond to THAW",
|
251
251
|
rb_obj_classname(s_klass));
|
data/ext/sereal/encode.c
CHANGED
@@ -27,13 +27,16 @@
|
|
27
27
|
#define W_SIZE T_FALSE
|
28
28
|
#elif T_NIL > W_SIZE
|
29
29
|
#define W_SIZE T_NIL
|
30
|
+
#elif T_DATA > W_SIZE
|
31
|
+
#define W_SIZE T_DATA
|
30
32
|
#endif
|
31
33
|
#define COMPLEX(object) \
|
32
34
|
(TYPE(object) == T_ARRAY || \
|
33
35
|
TYPE(object) == T_HASH || \
|
34
36
|
TYPE(object) == T_SYMBOL || \
|
35
37
|
TYPE(object) == T_OBJECT || \
|
36
|
-
TYPE(object) == T_STRING
|
38
|
+
TYPE(object) == T_STRING || \
|
39
|
+
TYPE(object) == T_DATA)
|
37
40
|
|
38
41
|
/* function pointer array */
|
39
42
|
void (*WRITER[W_SIZE])(sereal_t *,VALUE);
|
@@ -74,6 +77,7 @@ void s_init_writers(void) {
|
|
74
77
|
WRITER[T_TRUE] = s_append_true;
|
75
78
|
WRITER[T_FALSE] = s_append_false;
|
76
79
|
WRITER[T_NIL] = s_append_nil;
|
80
|
+
WRITER[T_DATA] = s_append_object;
|
77
81
|
}
|
78
82
|
|
79
83
|
static void s_default_writer(sereal_t *s, VALUE object) {
|
@@ -180,14 +184,14 @@ static VALUE s_copy_or_keep_in_mind(sereal_t *s, VALUE object) {
|
|
180
184
|
*/
|
181
185
|
static void s_append_object(sereal_t *s, VALUE object) {
|
182
186
|
if (s->flags & __THAW && rb_obj_respond_to(object,FREEZE,0)) {
|
183
|
-
VALUE klass =
|
187
|
+
VALUE klass = rb_class_path(CLASS_OF(object));
|
184
188
|
VALUE copy = s_copy_or_keep_in_mind(s,klass);
|
185
189
|
if (copy != Qnil) {
|
186
190
|
s_append_u8(s,SRL_HDR_OBJECTV_FREEZE);
|
187
191
|
s_append_copy(s,copy);
|
188
192
|
} else {
|
189
193
|
s_append_u8(s,SRL_HDR_OBJECT_FREEZE);
|
190
|
-
s_append_rb_string(s,
|
194
|
+
s_append_rb_string(s,klass);
|
191
195
|
}
|
192
196
|
VALUE frozen = rb_funcall(object,FREEZE,1,ID2SYM(SEREAL));
|
193
197
|
if (TYPE(frozen) != T_ARRAY)
|
@@ -289,15 +293,13 @@ static void rb_object_to_sereal(sereal_t *s, VALUE object) {
|
|
289
293
|
if (COMPLEX(object)) {
|
290
294
|
VALUE stored;
|
291
295
|
if (s->tracked != Qnil) {
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
goto out;
|
298
|
-
}
|
299
|
-
rb_hash_aset(s->tracked,id,INT2FIX(pos));
|
296
|
+
VALUE id = rb_obj_id(object);
|
297
|
+
stored = rb_hash_lookup(s->tracked,id);
|
298
|
+
if (stored != Qnil) {
|
299
|
+
s_append_refp(s,stored);
|
300
|
+
goto out;
|
300
301
|
}
|
302
|
+
rb_hash_aset(s->tracked,id,INT2FIX(pos));
|
301
303
|
}
|
302
304
|
stored = s_copy_or_keep_in_mind(s,object);
|
303
305
|
if (stored != Qnil) {
|
data/ext/sereal/sereal.c
CHANGED
@@ -270,7 +270,8 @@ void Init_sereal() {
|
|
270
270
|
* object: String: john { p: 14, s: 14, l: 2, h: 6 } sereal_to_rb_object()
|
271
271
|
* object: Array: ["john", "john"] { p: 14, s: 14, l: 1, h: 6 } sereal_to_rb_object()
|
272
272
|
*
|
273
|
-
*/
|
273
|
+
*/
|
274
|
+
rb_define_const(Sereal, "DEBUG",INT2NUM(__DEBUG));
|
274
275
|
rb_define_const(Sereal, "DEBUG",INT2NUM(__DEBUG));
|
275
276
|
|
276
277
|
s_init_writers();
|
data/ext/sereal/sereal.h
CHANGED
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sereal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
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-
|
11
|
+
date: 2014-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
description: Sereal encoder/decoder (https://github.com/Sereal/Sereal)
|
@@ -33,44 +33,44 @@ extensions:
|
|
33
33
|
extra_rdoc_files:
|
34
34
|
- ext/sereal/sereal.c
|
35
35
|
files:
|
36
|
+
- bin/rsrl
|
37
|
+
- ext/sereal/buffer.h
|
36
38
|
- ext/sereal/decode.c
|
39
|
+
- ext/sereal/decode.h
|
37
40
|
- ext/sereal/encode.c
|
38
|
-
- ext/sereal/
|
39
|
-
- ext/sereal/
|
41
|
+
- ext/sereal/encode.h
|
42
|
+
- ext/sereal/extconf.rb
|
43
|
+
- ext/sereal/proto.h
|
40
44
|
- ext/sereal/sereal.c
|
41
45
|
- ext/sereal/sereal.h
|
42
|
-
- ext/sereal/buffer.h
|
43
|
-
- ext/sereal/snappy/csnappy_internal.h
|
44
46
|
- ext/sereal/snappy/csnappy.h
|
45
|
-
- ext/sereal/snappy/csnappy_internal_userspace.h
|
46
47
|
- ext/sereal/snappy/csnappy_compat.h
|
47
|
-
- ext/sereal/
|
48
|
-
- ext/sereal/
|
49
|
-
- ext/sereal/
|
50
|
-
- ext/sereal/
|
51
|
-
- bin/rsrl
|
48
|
+
- ext/sereal/snappy/csnappy_compress.c
|
49
|
+
- ext/sereal/snappy/csnappy_decompress.c
|
50
|
+
- ext/sereal/snappy/csnappy_internal.h
|
51
|
+
- ext/sereal/snappy/csnappy_internal_userspace.h
|
52
52
|
homepage: https://github.com/Sereal/Sereal
|
53
53
|
licenses: []
|
54
54
|
metadata: {}
|
55
55
|
post_install_message:
|
56
56
|
rdoc_options:
|
57
|
-
- --exclude
|
58
|
-
-
|
57
|
+
- "--exclude"
|
58
|
+
- ".*\\.so"
|
59
59
|
require_paths:
|
60
60
|
- lib
|
61
61
|
required_ruby_version: !ruby/object:Gem::Requirement
|
62
62
|
requirements:
|
63
|
-
- -
|
63
|
+
- - ">="
|
64
64
|
- !ruby/object:Gem::Version
|
65
65
|
version: '0'
|
66
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - ">="
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
72
|
rubyforge_project:
|
73
|
-
rubygems_version: 2.0
|
73
|
+
rubygems_version: 2.2.0
|
74
74
|
signing_key:
|
75
75
|
specification_version: 4
|
76
76
|
summary: Sereal encoder/decoder
|