oj-introspect 0.6.0 → 0.7.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 718229e62c9fde37495f36cb674b79025c626a934d188698a0e2c87937566809
4
- data.tar.gz: 490a556129f5d13bc29c1b422e0af6cded6d97c88ead6b953ada4abf06ada594
3
+ metadata.gz: a8344e4ea03bb224e5911727d82641178d51384929ec66d40518b44b9d06cf1a
4
+ data.tar.gz: 6cd47873367c3d0305b40022ca35e46f22060df2fa3d5997927161150cf6996c
5
5
  SHA512:
6
- metadata.gz: 92ddcdc95170deef8d6854a879c5c910181ab6a16bbdb175e8d92ab67169ca80ee36d7ddfdcbf3aa45c036955c60d6642c53e45d9bbed3f3584aac61335c83cf
7
- data.tar.gz: a45c33ee35937db46ee01819b25264b9d7e9336a014a93edaba0cf878b5ad5d3a4a3303f8357b9848253d2953a50c2679469cc52e62ceabeb462da2616f43338
6
+ metadata.gz: c6c63c1724ed3b9295eef1b7858f78ff926042a3bef6d558648822a7a144dd2426ad2e884f8173f576a23c484c2e50c2170c90d905aefe4efa0a4c56b6eccc58
7
+ data.tar.gz: 50992a4c4cc58fe8589afc32669ea6bbb34a699078112e853299b707389f4883ee9e82f1fc0370ee87f61fb9847edb111e2d0540205378b88f9fc05ec008672f
data/Gemfile CHANGED
@@ -5,6 +5,6 @@ gemspec
5
5
 
6
6
  gem "benchmark-ips"
7
7
  gem "pry"
8
- gem "rake", "~> 12.0"
8
+ gem "rake", "~> 13.0"
9
9
  gem "rspec", "~> 3.0"
10
10
  gem "rake-compiler"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- oj-introspect (0.6.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 (12.3.3)
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 (~> 12.0)
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
- size_t len = RSTRING_LEN(source);
60
+ const char *ruby_str = StringValueCStr(source);
61
+ size_t len = strlen(ruby_str);
62
+
57
63
  *target = ALLOC_N(char, len + 1);
58
- memcpy(*target, RSTRING_PTR(source), len);
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, ID2SYM(rb_intern("start_byte")), INT2FIX(pop(p)));
152
- rb_hash_aset(obj, ID2SYM(rb_intern("end_byte")), INT2FIX(p->cur));
153
- rb_hash_aset(*(d->usual.vtail - 1), ID2SYM(rb_intern("__oj_introspection")), obj);
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, (Usual)d);
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
  }
@@ -1,5 +1,5 @@
1
1
  module Oj
2
2
  class Introspect
3
- VERSION = "0.6.0"
3
+ VERSION = "0.7.0"
4
4
  end
5
5
  end
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.6.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-06 00:00:00.000000000 Z
11
+ date: 2022-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj