oj-introspect 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +3 -3
- data/ext/oj-introspect/introspect.c +20 -11
- data/lib/oj/introspect/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8344e4ea03bb224e5911727d82641178d51384929ec66d40518b44b9d06cf1a
|
4
|
+
data.tar.gz: 6cd47873367c3d0305b40022ca35e46f22060df2fa3d5997927161150cf6996c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6c63c1724ed3b9295eef1b7858f78ff926042a3bef6d558648822a7a144dd2426ad2e884f8173f576a23c484c2e50c2170c90d905aefe4efa0a4c56b6eccc58
|
7
|
+
data.tar.gz: 50992a4c4cc58fe8589afc32669ea6bbb34a699078112e853299b707389f4883ee9e82f1fc0370ee87f61fb9847edb111e2d0540205378b88f9fc05ec008672f
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
oj-introspect (0.
|
4
|
+
oj-introspect (0.7.0)
|
5
5
|
oj (>= 3.13.23)
|
6
6
|
|
7
7
|
GEM
|
@@ -15,7 +15,7 @@ GEM
|
|
15
15
|
pry (0.14.1)
|
16
16
|
coderay (~> 1.1)
|
17
17
|
method_source (~> 1.0)
|
18
|
-
rake (
|
18
|
+
rake (13.0.6)
|
19
19
|
rake-compiler (1.2.0)
|
20
20
|
rake
|
21
21
|
rspec (3.12.0)
|
@@ -39,7 +39,7 @@ DEPENDENCIES
|
|
39
39
|
benchmark-ips
|
40
40
|
oj-introspect!
|
41
41
|
pry
|
42
|
-
rake (~>
|
42
|
+
rake (~> 13.0)
|
43
43
|
rake-compiler
|
44
44
|
rspec (~> 3.0)
|
45
45
|
|
@@ -30,6 +30,10 @@ typedef struct _introspect_S {
|
|
30
30
|
void (*delegated_close_array_key_func)(struct _ojParser *p);
|
31
31
|
} * IntrospectDelegate;
|
32
32
|
|
33
|
+
static VALUE introspection_key;
|
34
|
+
static VALUE start_byte_key;
|
35
|
+
static VALUE end_byte_key;
|
36
|
+
|
33
37
|
static void dfree(ojParser p) {
|
34
38
|
IntrospectDelegate d = (IntrospectDelegate)p->ctx;
|
35
39
|
|
@@ -53,10 +57,11 @@ static void start(ojParser p) {
|
|
53
57
|
}
|
54
58
|
|
55
59
|
static void copy_ruby_str(char **target, VALUE source) {
|
56
|
-
|
60
|
+
const char *ruby_str = StringValueCStr(source);
|
61
|
+
size_t len = strlen(ruby_str);
|
62
|
+
|
57
63
|
*target = ALLOC_N(char, len + 1);
|
58
|
-
|
59
|
-
(*target)[len] = '\0'; // Parantheses are important as it means => (*target + sizeof(char) * len)
|
64
|
+
strncpy(*target, ruby_str, len + 1);
|
60
65
|
}
|
61
66
|
|
62
67
|
static VALUE option(ojParser p, const char *key, VALUE value) {
|
@@ -148,9 +153,9 @@ static void set_introspection_values(ojParser p) {
|
|
148
153
|
if(!d->introspect) return;
|
149
154
|
|
150
155
|
volatile VALUE obj = rb_hash_new();
|
151
|
-
rb_hash_aset(obj,
|
152
|
-
rb_hash_aset(obj,
|
153
|
-
rb_hash_aset(*(d->usual.vtail - 1),
|
156
|
+
rb_hash_aset(obj, start_byte_key, INT2FIX(pop(p)));
|
157
|
+
rb_hash_aset(obj, end_byte_key, INT2FIX(p->cur));
|
158
|
+
rb_hash_aset(*(d->usual.vtail - 1), introspection_key, obj);
|
154
159
|
}
|
155
160
|
|
156
161
|
static void close_object_introspected(ojParser p) {
|
@@ -181,7 +186,7 @@ static void close_array_key_introspected(ojParser p) {
|
|
181
186
|
static void init_introspect_parser(ojParser p, VALUE ropts) {
|
182
187
|
IntrospectDelegate d = ALLOC(struct _introspect_S);
|
183
188
|
|
184
|
-
oj_init_usual(p,
|
189
|
+
oj_init_usual(p, &d->usual);
|
185
190
|
|
186
191
|
// now function mangling...
|
187
192
|
d->delegated_free_func = p->free;
|
@@ -245,10 +250,6 @@ static VALUE rb_new_introspect_parser(int argc, VALUE *argv, VALUE self) {
|
|
245
250
|
|
246
251
|
init_introspect_parser(p, options);
|
247
252
|
|
248
|
-
// This locks the object in memory and is never recovered. Best to let the
|
249
|
-
// mark function handle it.
|
250
|
-
// rb_gc_register_address(&oj_parser);
|
251
|
-
|
252
253
|
return oj_parser;
|
253
254
|
}
|
254
255
|
|
@@ -272,6 +273,14 @@ void Init_introspect_ext() {
|
|
272
273
|
VALUE parser_module = rb_const_get(oj_module, rb_intern("Parser"));
|
273
274
|
VALUE introspection_class = rb_define_class_under(oj_module, "Introspect", rb_cObject);
|
274
275
|
|
276
|
+
introspection_key = ID2SYM(rb_intern("__oj_introspection"));
|
277
|
+
rb_gc_register_address(&introspection_key);
|
278
|
+
start_byte_key = ID2SYM(rb_intern("start_byte"));
|
279
|
+
rb_gc_register_address(&start_byte_key);
|
280
|
+
end_byte_key = ID2SYM(rb_intern("end_byte"));
|
281
|
+
rb_gc_register_address(&end_byte_key);
|
282
|
+
|
283
|
+
rb_const_set(introspection_class, rb_intern("KEY"), introspection_key);
|
275
284
|
rb_define_singleton_method(parser_module, "introspect", rb_get_default_introspect_parser, 0);
|
276
285
|
rb_define_singleton_method(introspection_class, "new", rb_new_introspect_parser, -1);
|
277
286
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oj-introspect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mehmet Emin INAC
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|