oj-introspect 0.6.0 → 0.7.1
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/extconf.rb +16 -0
- data/ext/oj-introspect/introspect.c +20 -11
- data/ext/oj-introspect/oj.sym +3 -0
- data/lib/oj/introspect/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74ab6b62802075f9e3c9d9efc7fb13a2eca6d61c6da2f58e1b5f853fe08841c8
|
4
|
+
data.tar.gz: 13874ca3c2afea6ba3fb9de442f904b1dd8fe24131f7c4430ee496c01b6fd627
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7bfa4f6a854ae76136e01f102b63c231b055c06b3fbe5941b98b0c3a00b6d79653fad56afde069fc2907e693164ac1385ef4c3363e817cb48fb12592a99da4d
|
7
|
+
data.tar.gz: b151a7bbc3f00291110db4c30f5bfb2cbdbcfdc3ac150062ba98f07f58598cd71eaced956bca86a40fb6fce83c529a2599a2b6948d95495b6fe8e665b0b13658
|
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.1)
|
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
|
|
@@ -7,6 +7,22 @@ oj_version_file_path = Pathname.new(oj_version_file)
|
|
7
7
|
|
8
8
|
OJ_HEADERS = oj_version_file_path.join('..', '..', '..', 'ext', 'oj').to_s
|
9
9
|
|
10
|
+
cc_version = `#{RbConfig.expand("$(CC) --version".dup)}`
|
11
|
+
if cc_version.match?(/clang/i)
|
12
|
+
# Ignore symbols loaded from Oj in case Ruby is compiled without
|
13
|
+
# "-Wl,-undefined,dynamic_lookup" (related to https://bugs.ruby-lang.org/issues/19005)
|
14
|
+
symfile = File.join(__dir__, 'oj.sym')
|
15
|
+
dynamic_symbols = File.readlines(symfile)
|
16
|
+
dynamic_symbols.each do |sym|
|
17
|
+
$DLDFLAGS << " -Wl,-U,#{sym.strip}"
|
18
|
+
end
|
19
|
+
|
20
|
+
# Needed for Ruby 3.2 ABI check: https://github.com/ruby/ruby/pull/5474
|
21
|
+
if RUBY_VERSION >= "3.2"
|
22
|
+
$LDFLAGS << " -Wl,-exported_symbol,_ruby_abi_version"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
10
26
|
dir_config('oj', [OJ_HEADERS], [])
|
11
27
|
|
12
28
|
create_makefile("oj/introspect/introspect_ext")
|
@@ -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.1
|
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-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -47,6 +47,7 @@ files:
|
|
47
47
|
- bin/test_run
|
48
48
|
- ext/oj-introspect/extconf.rb
|
49
49
|
- ext/oj-introspect/introspect.c
|
50
|
+
- ext/oj-introspect/oj.sym
|
50
51
|
- lib/oj/introspect.rb
|
51
52
|
- lib/oj/introspect/version.rb
|
52
53
|
- oj-introspect.gemspec
|