oj-introspect 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +3 -3
- data/ext/oj-introspect/introspect.c +26 -21
- data/lib/oj/introspect/version.rb +1 -1
- data/oj-introspect.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 718229e62c9fde37495f36cb674b79025c626a934d188698a0e2c87937566809
|
4
|
+
data.tar.gz: 490a556129f5d13bc29c1b422e0af6cded6d97c88ead6b953ada4abf06ada594
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92ddcdc95170deef8d6854a879c5c910181ab6a16bbdb175e8d92ab67169ca80ee36d7ddfdcbf3aa45c036955c60d6642c53e45d9bbed3f3584aac61335c83cf
|
7
|
+
data.tar.gz: a45c33ee35937db46ee01819b25264b9d7e9336a014a93edaba0cf878b5ad5d3a4a3303f8357b9848253d2953a50c2679469cc52e62ceabeb462da2616f43338
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
oj-introspect (0.
|
5
|
-
oj (>= 3.13.
|
4
|
+
oj-introspect (0.6.0)
|
5
|
+
oj (>= 3.13.23)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
@@ -11,7 +11,7 @@ GEM
|
|
11
11
|
coderay (1.1.3)
|
12
12
|
diff-lcs (1.5.0)
|
13
13
|
method_source (1.0.0)
|
14
|
-
oj (3.13.
|
14
|
+
oj (3.13.23)
|
15
15
|
pry (0.14.1)
|
16
16
|
coderay (~> 1.1)
|
17
17
|
method_source (~> 1.0)
|
@@ -26,6 +26,8 @@ typedef struct _introspect_S {
|
|
26
26
|
void (*delegated_open_object_key_func)(struct _ojParser *p);
|
27
27
|
void (*delegated_open_array_key_func)(struct _ojParser *p);
|
28
28
|
void (*delegated_close_object_func)(struct _ojParser *p);
|
29
|
+
void (*delegated_close_object_key_func)(struct _ojParser *p);
|
30
|
+
void (*delegated_close_array_key_func)(struct _ojParser *p);
|
29
31
|
} * IntrospectDelegate;
|
30
32
|
|
31
33
|
static void dfree(ojParser p) {
|
@@ -61,6 +63,7 @@ static VALUE option(ojParser p, const char *key, VALUE value) {
|
|
61
63
|
IntrospectDelegate d = (IntrospectDelegate)p->ctx;
|
62
64
|
|
63
65
|
if(strcmp(key, "filter=") == 0) {
|
66
|
+
Check_Type(value, T_STRING);
|
64
67
|
copy_ruby_str(&d->filter, value); // We need to copy the value as GC can free it later.
|
65
68
|
|
66
69
|
return Qtrue;
|
@@ -144,8 +147,6 @@ static void set_introspection_values(ojParser p) {
|
|
144
147
|
|
145
148
|
if(!d->introspect) return;
|
146
149
|
|
147
|
-
switch_introspection(d);
|
148
|
-
|
149
150
|
volatile VALUE obj = rb_hash_new();
|
150
151
|
rb_hash_aset(obj, ID2SYM(rb_intern("start_byte")), INT2FIX(pop(p)));
|
151
152
|
rb_hash_aset(obj, ID2SYM(rb_intern("end_byte")), INT2FIX(p->cur));
|
@@ -159,6 +160,24 @@ static void close_object_introspected(ojParser p) {
|
|
159
160
|
set_introspection_values(p);
|
160
161
|
}
|
161
162
|
|
163
|
+
// We switch introspection off only for object and array keys.
|
164
|
+
static void close_object_key_introspected(ojParser p) {
|
165
|
+
IntrospectDelegate d = (IntrospectDelegate)p->ctx;
|
166
|
+
d->delegated_close_object_func(p);
|
167
|
+
|
168
|
+
if(d->introspect) {
|
169
|
+
set_introspection_values(p);
|
170
|
+
switch_introspection(d);
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
174
|
+
static void close_array_key_introspected(ojParser p) {
|
175
|
+
IntrospectDelegate d = (IntrospectDelegate)p->ctx;
|
176
|
+
d->delegated_close_array_key_func(p);
|
177
|
+
|
178
|
+
if(d->introspect) switch_introspection(d);
|
179
|
+
}
|
180
|
+
|
162
181
|
static void init_introspect_parser(ojParser p, VALUE ropts) {
|
163
182
|
IntrospectDelegate d = ALLOC(struct _introspect_S);
|
164
183
|
|
@@ -174,12 +193,7 @@ static void init_introspect_parser(ojParser p, VALUE ropts) {
|
|
174
193
|
d->delegated_option_func = p->option;
|
175
194
|
p->option = option;
|
176
195
|
|
177
|
-
//
|
178
|
-
// _usual is the first member of struct _introspect the cast to Usual in the
|
179
|
-
// usual.c mark() function should still work just fine.
|
180
|
-
|
181
|
-
// PCO - do you need the location of sub-objects and arrays or just top
|
182
|
-
// level objects?
|
196
|
+
// Wrap original functions to collect byte offsets
|
183
197
|
Funcs f = &p->funcs[TOP_FUN];
|
184
198
|
d->delegated_open_object_func = f->open_object;
|
185
199
|
d->delegated_close_object_func = f->close_object;
|
@@ -193,9 +207,12 @@ static void init_introspect_parser(ojParser p, VALUE ropts) {
|
|
193
207
|
f = &p->funcs[OBJECT_FUN];
|
194
208
|
d->delegated_open_array_key_func = f->open_array;
|
195
209
|
d->delegated_open_object_key_func = f->open_object;
|
210
|
+
d->delegated_close_array_key_func = f->close_array;
|
211
|
+
d->delegated_close_object_key_func = f->close_object;
|
196
212
|
f->open_array = open_array_key_introspected;
|
197
213
|
f->open_object = open_object_key_introspected;
|
198
|
-
f->
|
214
|
+
f->close_array = close_array_key_introspected;
|
215
|
+
f->close_object = close_object_key_introspected;
|
199
216
|
|
200
217
|
// Init stack
|
201
218
|
d->byte_offsets.current = 0;
|
@@ -208,18 +225,6 @@ static void init_introspect_parser(ojParser p, VALUE ropts) {
|
|
208
225
|
oj_parser_set_option(p, ropts);
|
209
226
|
}
|
210
227
|
|
211
|
-
VALUE oj_get_parser_introspect() {
|
212
|
-
VALUE oj_parser = oj_parser_new();
|
213
|
-
struct _ojParser *p;
|
214
|
-
Data_Get_Struct(oj_parser, struct _ojParser, p);
|
215
|
-
|
216
|
-
init_introspect_parser(p, Qnil);
|
217
|
-
|
218
|
-
rb_gc_register_address(&oj_parser);
|
219
|
-
|
220
|
-
return oj_parser;
|
221
|
-
}
|
222
|
-
|
223
228
|
static VALUE rb_new_introspect_parser(int argc, VALUE *argv, VALUE self) {
|
224
229
|
rb_check_arity(argc, 0, 1);
|
225
230
|
|
data/oj-introspect.gemspec
CHANGED
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.6.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-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.13.
|
19
|
+
version: 3.13.23
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.13.
|
26
|
+
version: 3.13.23
|
27
27
|
description: Embeds start and end byte offsets of JSON objects into generated Ruby
|
28
28
|
hashes.
|
29
29
|
email:
|