usamin 7.7.7 → 7.7.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +43 -43
- data/ext/usamin/extconf.rb +10 -3
- data/ext/usamin/usamin.cpp +117 -85
- data/lib/usamin/version.rb +1 -1
- data/usamin.gemspec +3 -3
- metadata +15 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71c3b83f7f671964b34398dac52063e4619fcf69352a54a6b6d28c175d3c01ca
|
4
|
+
data.tar.gz: 60599d9808d0504dacb2a0fe96372072cb7e5c779cd84753353dff53ff309337
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e3ceb27b8f0c2f78ecc7c4fb1a4cad9d8d319ab1501e23fc804886a92ef6b6ec1b403bed9c7cbb59e03d1b78753535d8fd2d153622281924fa1ebf0e6c81668
|
7
|
+
data.tar.gz: 022e9d44c3be7e8f1e4f423d35837a0c31ef5ef3a32d801fd965c5d5ff25a76372d5ce41fda0d40576765a1d273fbe4a8fdad41543ee63e4301b5f127475c706
|
data/README.md
CHANGED
@@ -207,78 +207,78 @@ Usamin and JSON load the same data from 3 big json data in nativejson-benchmark.
|
|
207
207
|
|
208
208
|
### Performance
|
209
209
|
|
210
|
-
The values show the elapsed time for operating 20 times.
|
210
|
+
The values show the elapsed time for operating 20 times. SSE4.2 was enabled in these tests.
|
211
211
|
|
212
212
|
#### Parsing
|
213
213
|
|
214
214
|
```
|
215
215
|
nativejson-benchmark/data/canada.json
|
216
|
-
json 0.
|
217
|
-
oj 1.
|
218
|
-
usamin 0.
|
219
|
-
usamin (fast) 0.
|
220
|
-
usamin (load) 0.
|
221
|
-
usamin (load / fast) 0.
|
216
|
+
json 0.743695 0.005426 0.749121 ( 0.751004)
|
217
|
+
oj 1.779671 0.039642 1.819313 ( 1.824576)
|
218
|
+
usamin 0.510856 0.013166 0.524022 ( 0.525174)
|
219
|
+
usamin (fast) 0.258916 0.007298 0.266214 ( 0.267910)
|
220
|
+
usamin (load) 0.403337 0.010124 0.413461 ( 0.414023)
|
221
|
+
usamin (load / fast) 0.164099 0.020126 0.184225 ( 0.184817)
|
222
222
|
|
223
223
|
nativejson-benchmark/data/citm_catalog.json
|
224
|
-
json 0.
|
225
|
-
oj 0.
|
226
|
-
usamin 0.
|
227
|
-
usamin (fast) 0.
|
228
|
-
usamin (load) 0.
|
229
|
-
usamin (load / fast) 0.
|
224
|
+
json 0.481490 0.006217 0.487707 ( 0.490407)
|
225
|
+
oj 0.337618 0.002676 0.340294 ( 0.340697)
|
226
|
+
usamin 0.363082 0.005774 0.368856 ( 0.370124)
|
227
|
+
usamin (fast) 0.348798 0.005620 0.354418 ( 0.355544)
|
228
|
+
usamin (load) 0.114139 0.004866 0.119005 ( 0.119659)
|
229
|
+
usamin (load / fast) 0.101378 0.004685 0.106063 ( 0.106161)
|
230
230
|
|
231
231
|
nativejson-benchmark/data/twitter.json
|
232
|
-
json 0.
|
233
|
-
oj 0.
|
234
|
-
usamin 0.
|
235
|
-
usamin (fast) 0.
|
236
|
-
usamin (load) 0.
|
237
|
-
usamin (load / fast) 0.
|
232
|
+
json 0.242091 0.004512 0.246603 ( 0.246985)
|
233
|
+
oj 0.165441 0.000833 0.166274 ( 0.166517)
|
234
|
+
usamin 0.179744 0.000353 0.180097 ( 0.180320)
|
235
|
+
usamin (fast) 0.181126 0.000577 0.181703 ( 0.182080)
|
236
|
+
usamin (load) 0.061376 0.000944 0.062320 ( 0.062647)
|
237
|
+
usamin (load / fast) 0.064891 0.001240 0.066131 ( 0.067542)
|
238
238
|
```
|
239
239
|
|
240
240
|
#### Generating
|
241
241
|
|
242
242
|
```
|
243
243
|
nativejson-benchmark/data/canada.json
|
244
|
-
json 1.
|
245
|
-
oj 2.
|
246
|
-
usamin 0.
|
247
|
-
usamin (load) 0.
|
244
|
+
json 1.964397 0.024287 1.988684 ( 1.993397)
|
245
|
+
oj 2.070033 0.028986 2.099019 ( 2.107441)
|
246
|
+
usamin 0.247659 0.018489 0.266148 ( 0.266663)
|
247
|
+
usamin (load) 0.246872 0.027028 0.273900 ( 0.274989)
|
248
248
|
|
249
249
|
nativejson-benchmark/data/citm_catalog.json
|
250
|
-
json 0.
|
251
|
-
oj 0.
|
252
|
-
usamin 0.
|
253
|
-
usamin (load) 0.
|
250
|
+
json 0.244533 0.009066 0.253599 ( 0.255088)
|
251
|
+
oj 0.069532 0.008088 0.077620 ( 0.077661)
|
252
|
+
usamin 0.058047 0.009538 0.067585 ( 0.067694)
|
253
|
+
usamin (load) 0.038105 0.009722 0.047827 ( 0.047993)
|
254
254
|
|
255
255
|
nativejson-benchmark/data/twitter.json
|
256
|
-
json 0.
|
257
|
-
oj 0.
|
258
|
-
usamin 0.
|
259
|
-
usamin (load) 0.
|
256
|
+
json 0.160310 0.006469 0.166779 ( 0.167137)
|
257
|
+
oj 0.042114 0.004044 0.046158 ( 0.046254)
|
258
|
+
usamin 0.038971 0.004943 0.043914 ( 0.044313)
|
259
|
+
usamin (load) 0.029375 0.004385 0.033760 ( 0.033882)
|
260
260
|
```
|
261
261
|
|
262
262
|
#### Pretty Generating
|
263
263
|
|
264
264
|
```
|
265
265
|
nativejson-benchmark/data/canada.json
|
266
|
-
json 2.
|
267
|
-
oj 1.
|
268
|
-
usamin 0.
|
269
|
-
usamin (load) 0.
|
266
|
+
json 2.224924 0.089327 2.314251 ( 2.320405)
|
267
|
+
oj 1.624790 0.022204 1.646994 ( 1.650566)
|
268
|
+
usamin 0.356511 0.084944 0.441455 ( 0.442372)
|
269
|
+
usamin (load) 0.334884 0.076830 0.411714 ( 0.412275)
|
270
270
|
|
271
271
|
nativejson-benchmark/data/citm_catalog.json
|
272
|
-
json 0.
|
273
|
-
oj 0.
|
274
|
-
usamin 0.
|
275
|
-
usamin (load) 0.
|
272
|
+
json 0.302005 0.017108 0.319113 ( 0.322104)
|
273
|
+
oj 0.071386 0.008597 0.079983 ( 0.080194)
|
274
|
+
usamin 0.099413 0.021275 0.120688 ( 0.121417)
|
275
|
+
usamin (load) 0.060486 0.021065 0.081551 ( 0.081808)
|
276
276
|
|
277
277
|
nativejson-benchmark/data/twitter.json
|
278
|
-
json 0.
|
279
|
-
oj 0.
|
280
|
-
usamin 0.
|
281
|
-
usamin (load) 0.
|
278
|
+
json 0.170121 0.011923 0.182044 ( 0.182585)
|
279
|
+
oj 0.035700 0.006364 0.042064 ( 0.042099)
|
280
|
+
usamin 0.040141 0.006321 0.046462 ( 0.046556)
|
281
|
+
usamin (load) 0.036990 0.005729 0.042719 ( 0.042816)
|
282
282
|
```
|
283
283
|
|
284
284
|
## Contributing
|
data/ext/usamin/extconf.rb
CHANGED
@@ -5,7 +5,14 @@ have_library('stdc++')
|
|
5
5
|
dir_config('rapidjson')
|
6
6
|
append_cppflags('-O3')
|
7
7
|
append_cppflags('-Wall')
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
|
9
|
+
if checking_for("whether -march=native is accepted as CPPFLAGS"){try_cppflags('-march=native')}
|
10
|
+
if checking_for("whether -msse4.2 is accepted as CPPFLAGS"){try_cppflags('-msse4.2')}
|
11
|
+
$CPPFLAGS << ' -msse4.2 -march=native'
|
12
|
+
elsif checking_for("whether -msse2 is accepted as CPPFLAGS"){try_cppflags('-msse2')}
|
13
|
+
$CPPFLAGS << ' -msse2 -march=native'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
$CPPFLAGS << ' -std=c++11'
|
11
18
|
create_makefile('usamin/usamin')
|
data/ext/usamin/usamin.cpp
CHANGED
@@ -10,12 +10,32 @@
|
|
10
10
|
#include <rapidjson/writer.h>
|
11
11
|
#include <rapidjson/prettywriter.h>
|
12
12
|
#include <rapidjson/error/en.h>
|
13
|
-
#include <iostream>
|
14
13
|
|
15
14
|
#if SIZEOF_VALUE < SIZEOF_VOIDP
|
16
15
|
#error SIZEOF_VOIDP must not be greater than SIZEOF_VALUE.
|
17
16
|
#endif
|
18
17
|
|
18
|
+
class RubyCrtAllocator {
|
19
|
+
public:
|
20
|
+
static const bool kNeedFree = true;
|
21
|
+
void* Malloc(size_t size) {
|
22
|
+
if (size)
|
23
|
+
return ruby_xmalloc(size);
|
24
|
+
else
|
25
|
+
return nullptr;
|
26
|
+
}
|
27
|
+
void* Realloc(void* originalPtr, size_t, size_t newSize) {
|
28
|
+
if (newSize == 0) {
|
29
|
+
ruby_xfree(originalPtr);
|
30
|
+
return nullptr;
|
31
|
+
}
|
32
|
+
return ruby_xrealloc(originalPtr, newSize);
|
33
|
+
}
|
34
|
+
static void Free(void *ptr) { ruby_xfree(ptr); }
|
35
|
+
};
|
36
|
+
|
37
|
+
typedef rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<RubyCrtAllocator>> RubynizedValue;
|
38
|
+
typedef rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<RubyCrtAllocator>> RubynizedDocument;
|
19
39
|
|
20
40
|
rb_encoding *utf8;
|
21
41
|
int utf8index;
|
@@ -25,11 +45,11 @@ VALUE utf8value, sym_fast, sym_indent, sym_single_line_array;
|
|
25
45
|
|
26
46
|
class UsaminValue {
|
27
47
|
public:
|
28
|
-
|
48
|
+
RubynizedValue *value;
|
29
49
|
VALUE root_document;
|
30
50
|
bool free_flag;
|
31
51
|
|
32
|
-
UsaminValue(
|
52
|
+
UsaminValue(RubynizedValue *value = nullptr, const bool free_flag = false, const VALUE root_document = Qnil);
|
33
53
|
~UsaminValue();
|
34
54
|
};
|
35
55
|
|
@@ -54,7 +74,7 @@ static inline bool str_compare(const char* str1, const long len1, const char* st
|
|
54
74
|
return memcmp(str1, str2, len1) == 0;
|
55
75
|
}
|
56
76
|
|
57
|
-
static inline bool str_compare_xx(VALUE str1, const
|
77
|
+
static inline bool str_compare_xx(VALUE str1, const RubynizedValue &str2) {
|
58
78
|
if (RB_TYPE_P(str1, T_STRING))
|
59
79
|
str1 = get_utf8_str(str1);
|
60
80
|
else if (SYMBOL_P(str1))
|
@@ -95,7 +115,7 @@ static void usamin_mark(void *p) {
|
|
95
115
|
if (!p)
|
96
116
|
return;
|
97
117
|
UsaminValue **ptr = (UsaminValue**)p;
|
98
|
-
if (*ptr && (*ptr)->
|
118
|
+
if (*ptr && !((*ptr)->free_flag))
|
99
119
|
rb_gc_mark((*ptr)->root_document);
|
100
120
|
}
|
101
121
|
|
@@ -107,7 +127,7 @@ static size_t usamin_size(const void *p) {
|
|
107
127
|
if (*ptr) {
|
108
128
|
s += sizeof(UsaminValue);
|
109
129
|
if ((*ptr)->free_flag)
|
110
|
-
s += ((
|
130
|
+
s += ((RubynizedDocument*)(*ptr)->value)->GetAllocator().Capacity() + ((RubynizedDocument*)(*ptr)->value)->GetStackCapacity();
|
111
131
|
}
|
112
132
|
return s;
|
113
133
|
}
|
@@ -123,7 +143,7 @@ static VALUE usamin_alloc(const VALUE klass) {
|
|
123
143
|
|
124
144
|
|
125
145
|
static inline UsaminValue* get_value(VALUE value) {
|
126
|
-
UsaminValue**
|
146
|
+
UsaminValue **ptr;
|
127
147
|
TypedData_Get_Struct(value, UsaminValue*, &rb_usamin_value_type, ptr);
|
128
148
|
return *ptr;
|
129
149
|
}
|
@@ -134,30 +154,34 @@ static inline void set_value(VALUE value, UsaminValue *usamin) {
|
|
134
154
|
*ptr = usamin;
|
135
155
|
}
|
136
156
|
|
137
|
-
static inline VALUE make_hash(UsaminValue *value) {
|
157
|
+
static inline VALUE make_hash(UsaminValue *value, bool is_root = false) {
|
138
158
|
VALUE ret = rb_obj_alloc(rb_cUsaminHash);
|
139
159
|
set_value(ret, value);
|
160
|
+
if (is_root)
|
161
|
+
value->root_document = ret;
|
140
162
|
return ret;
|
141
163
|
}
|
142
164
|
|
143
|
-
static inline VALUE make_array(UsaminValue *value) {
|
165
|
+
static inline VALUE make_array(UsaminValue *value, bool is_root = false) {
|
144
166
|
VALUE ret = rb_obj_alloc(rb_cUsaminArray);
|
145
167
|
set_value(ret, value);
|
168
|
+
if (is_root)
|
169
|
+
value->root_document = ret;
|
146
170
|
return ret;
|
147
171
|
}
|
148
172
|
|
149
|
-
static inline rapidjson::ParseResult parse(
|
173
|
+
static inline rapidjson::ParseResult parse(RubynizedDocument &doc, const VALUE str, bool fast = false) {
|
150
174
|
volatile VALUE v = get_utf8_str(str);
|
151
175
|
return fast ? doc.Parse<kParseFastFlags>(RSTRING_PTR(v), RSTRING_LEN(v)) : doc.Parse(RSTRING_PTR(v), RSTRING_LEN(v));
|
152
176
|
}
|
153
177
|
|
154
178
|
|
155
|
-
static inline VALUE eval_num(
|
156
|
-
static inline VALUE eval_str(
|
157
|
-
static inline VALUE eval_object_r(
|
158
|
-
static inline VALUE eval_array_r(
|
179
|
+
static inline VALUE eval_num(RubynizedValue&);
|
180
|
+
static inline VALUE eval_str(RubynizedValue&);
|
181
|
+
static inline VALUE eval_object_r(RubynizedValue&);
|
182
|
+
static inline VALUE eval_array_r(RubynizedValue&);
|
159
183
|
|
160
|
-
static VALUE eval(
|
184
|
+
static VALUE eval(RubynizedValue &value, VALUE root_document) {
|
161
185
|
switch (value.GetType()) {
|
162
186
|
case rapidjson::kObjectType:
|
163
187
|
return make_hash(new UsaminValue(&value, false, root_document));
|
@@ -179,7 +203,7 @@ static VALUE eval(rapidjson::Value &value, VALUE root_document) {
|
|
179
203
|
}
|
180
204
|
}
|
181
205
|
|
182
|
-
static VALUE eval_r(
|
206
|
+
static VALUE eval_r(RubynizedValue &value) {
|
183
207
|
switch (value.GetType()) {
|
184
208
|
case rapidjson::kObjectType:
|
185
209
|
return eval_object_r(value);
|
@@ -201,7 +225,7 @@ static VALUE eval_r(rapidjson::Value &value) {
|
|
201
225
|
}
|
202
226
|
}
|
203
227
|
|
204
|
-
static inline VALUE eval_num(
|
228
|
+
static inline VALUE eval_num(RubynizedValue &value) {
|
205
229
|
if (value.IsInt())
|
206
230
|
return INT2FIX(value.GetInt());
|
207
231
|
else if (value.IsUint())
|
@@ -214,32 +238,32 @@ static inline VALUE eval_num(rapidjson::Value &value) {
|
|
214
238
|
return DBL2NUM(value.GetDouble());
|
215
239
|
}
|
216
240
|
|
217
|
-
static inline VALUE eval_str(
|
241
|
+
static inline VALUE eval_str(RubynizedValue &value) {
|
218
242
|
return new_utf8_str(value.GetString(), value.GetStringLength());
|
219
243
|
}
|
220
244
|
|
221
|
-
static inline VALUE eval_object(
|
245
|
+
static inline VALUE eval_object(RubynizedValue &value, const VALUE root_document) {
|
222
246
|
VALUE ret = rb_hash_new();
|
223
247
|
for (auto &m : value.GetObject())
|
224
248
|
rb_hash_aset(ret, eval_str(m.name), eval(m.value, root_document));
|
225
249
|
return ret;
|
226
250
|
}
|
227
251
|
|
228
|
-
static inline VALUE eval_object_r(
|
252
|
+
static inline VALUE eval_object_r(RubynizedValue &value) {
|
229
253
|
VALUE ret = rb_hash_new();
|
230
254
|
for (auto &m : value.GetObject())
|
231
255
|
rb_hash_aset(ret, eval_str(m.name), eval_r(m.value));
|
232
256
|
return ret;
|
233
257
|
}
|
234
258
|
|
235
|
-
static inline VALUE eval_array(
|
259
|
+
static inline VALUE eval_array(RubynizedValue &value, const VALUE root_document) {
|
236
260
|
VALUE ret = rb_ary_new2(value.Size());
|
237
261
|
for (auto &v : value.GetArray())
|
238
262
|
rb_ary_push(ret, eval(v, root_document));
|
239
263
|
return ret;
|
240
264
|
}
|
241
265
|
|
242
|
-
static inline VALUE eval_array_r(
|
266
|
+
static inline VALUE eval_array_r(RubynizedValue &value) {
|
243
267
|
VALUE ret = rb_ary_new2(value.Size());
|
244
268
|
for (auto &v : value.GetArray())
|
245
269
|
rb_ary_push(ret, eval_r(v));
|
@@ -356,7 +380,7 @@ template <class Writer> static inline void write_struct(Writer &writer, const VA
|
|
356
380
|
writer.EndObject();
|
357
381
|
}
|
358
382
|
|
359
|
-
template <class Writer> static void write_value(Writer &writer,
|
383
|
+
template <class Writer> static void write_value(Writer &writer, RubynizedValue &value) {
|
360
384
|
switch (value.GetType()) {
|
361
385
|
case rapidjson::kObjectType:
|
362
386
|
writer.StartObject();
|
@@ -412,7 +436,7 @@ template <class Writer> static inline void write_to_s(Writer &writer, const VALU
|
|
412
436
|
}
|
413
437
|
|
414
438
|
|
415
|
-
UsaminValue::UsaminValue(
|
439
|
+
UsaminValue::UsaminValue(RubynizedValue *value, const bool free_flag, const VALUE root_document) {
|
416
440
|
this->value = value;
|
417
441
|
this->free_flag = free_flag;
|
418
442
|
this->root_document = root_document;
|
@@ -420,7 +444,7 @@ UsaminValue::UsaminValue(rapidjson::Value *value, const bool free_flag, const VA
|
|
420
444
|
|
421
445
|
UsaminValue::~UsaminValue() {
|
422
446
|
if (value && free_flag)
|
423
|
-
delete (
|
447
|
+
delete (RubynizedDocument*)value;
|
424
448
|
}
|
425
449
|
|
426
450
|
/*
|
@@ -436,7 +460,7 @@ UsaminValue::~UsaminValue() {
|
|
436
460
|
static VALUE w_load(const int argc, const VALUE *argv, const VALUE self) {
|
437
461
|
VALUE source, options;
|
438
462
|
rb_scan_args(argc, argv, "1:", &source, &options);
|
439
|
-
|
463
|
+
RubynizedDocument *doc = new RubynizedDocument;
|
440
464
|
auto result = parse(*doc, source, argc > 1 && RTEST(rb_hash_lookup(options, sym_fast)));
|
441
465
|
if (!result) {
|
442
466
|
delete doc;
|
@@ -446,9 +470,9 @@ static VALUE w_load(const int argc, const VALUE *argv, const VALUE self) {
|
|
446
470
|
VALUE ret;
|
447
471
|
switch (doc->GetType()) {
|
448
472
|
case rapidjson::kObjectType:
|
449
|
-
return make_hash(new UsaminValue(doc, true));
|
473
|
+
return make_hash(new UsaminValue(doc, true), true);
|
450
474
|
case rapidjson::kArrayType:
|
451
|
-
return make_array(new UsaminValue(doc, true));
|
475
|
+
return make_array(new UsaminValue(doc, true), true);
|
452
476
|
case rapidjson::kNullType:
|
453
477
|
delete doc;
|
454
478
|
return Qnil;
|
@@ -484,7 +508,7 @@ static VALUE w_load(const int argc, const VALUE *argv, const VALUE self) {
|
|
484
508
|
static VALUE w_parse(const int argc, const VALUE *argv, const VALUE self) {
|
485
509
|
VALUE source, options;
|
486
510
|
rb_scan_args(argc, argv, "1:", &source, &options);
|
487
|
-
|
511
|
+
RubynizedDocument doc;
|
488
512
|
auto result = parse(doc, source, argc > 1 && RTEST(rb_hash_lookup(options, sym_fast)));
|
489
513
|
if (!result)
|
490
514
|
rb_raise(rb_eParserError, "%s Offset: %lu", GetParseError_En(result.Code()), result.Offset());
|
@@ -518,9 +542,9 @@ static VALUE w_value_eval(const VALUE self) {
|
|
518
542
|
UsaminValue *value = get_value(self);
|
519
543
|
check_value(value);
|
520
544
|
if (value->value->IsObject())
|
521
|
-
return eval_object(*(value->value),
|
545
|
+
return eval_object(*(value->value), value->root_document);
|
522
546
|
else if (value->value->IsArray())
|
523
|
-
return eval_array(*(value->value),
|
547
|
+
return eval_array(*(value->value), value->root_document);
|
524
548
|
else
|
525
549
|
return Qnil;
|
526
550
|
}
|
@@ -543,6 +567,17 @@ static VALUE w_value_isfrozen(const VALUE self) {
|
|
543
567
|
return Qtrue;
|
544
568
|
}
|
545
569
|
|
570
|
+
/*
|
571
|
+
* Returns root object.
|
572
|
+
*
|
573
|
+
* @return [UsaminValue]
|
574
|
+
*/
|
575
|
+
static VALUE w_value_root(const VALUE self) {
|
576
|
+
UsaminValue *value = get_value(self);
|
577
|
+
check_value(value);
|
578
|
+
return value->root_document;
|
579
|
+
}
|
580
|
+
|
546
581
|
/*
|
547
582
|
* Dumps data in JSON.
|
548
583
|
*
|
@@ -559,24 +594,24 @@ static VALUE w_value_marshal_dump(const VALUE self) {
|
|
559
594
|
|
560
595
|
/*
|
561
596
|
* Loads marshal data.
|
562
|
-
*
|
563
|
-
* @return [self]
|
564
597
|
*/
|
565
598
|
static VALUE w_value_marshal_load(const VALUE self, const VALUE source) {
|
566
599
|
Check_Type(source, T_STRING);
|
567
|
-
|
600
|
+
RubynizedDocument *doc = new RubynizedDocument();
|
568
601
|
rapidjson::ParseResult result = doc->Parse<rapidjson::kParseFullPrecisionFlag | rapidjson::kParseNanAndInfFlag>(RSTRING_PTR(source), RSTRING_LEN(source));
|
569
602
|
if (!result) {
|
570
603
|
delete doc;
|
571
604
|
rb_raise(rb_eParserError, "%s Offset: %lu", GetParseError_En(result.Code()), result.Offset());
|
572
605
|
}
|
573
606
|
if (doc->IsObject() || doc->IsArray()) {
|
574
|
-
|
575
|
-
|
607
|
+
UsaminValue *value = new UsaminValue(doc, true);
|
608
|
+
set_value(self, value);
|
609
|
+
value->root_document = self;
|
610
|
+
} else {
|
611
|
+
auto type = doc->GetType();
|
612
|
+
delete doc;
|
613
|
+
rb_raise(rb_eUsaminError, "Invalid Value Type for marshal_load: %d", type);
|
576
614
|
}
|
577
|
-
auto type = doc->GetType();
|
578
|
-
delete doc;
|
579
|
-
rb_raise(rb_eUsaminError, "Invalid Value Type for marshal_load: %d", type);
|
580
615
|
return Qnil;
|
581
616
|
}
|
582
617
|
|
@@ -591,7 +626,7 @@ static VALUE w_hash_operator_indexer(const VALUE self, const VALUE key) {
|
|
591
626
|
check_object(value);
|
592
627
|
for (auto &m : value->value->GetObject())
|
593
628
|
if (str_compare_xx(key, m.name))
|
594
|
-
return eval(m.value,
|
629
|
+
return eval(m.value, value->root_document);
|
595
630
|
return Qnil;
|
596
631
|
}
|
597
632
|
|
@@ -605,7 +640,7 @@ static VALUE w_hash_assoc(const VALUE self, const VALUE key) {
|
|
605
640
|
check_object(value);
|
606
641
|
for (auto &m : value->value->GetObject())
|
607
642
|
if (str_compare_xx(key, m.name))
|
608
|
-
return rb_assoc_new(eval_str(m.name), eval(m.value,
|
643
|
+
return rb_assoc_new(eval_str(m.name), eval(m.value, value->root_document));
|
609
644
|
return Qnil;
|
610
645
|
}
|
611
646
|
|
@@ -618,7 +653,7 @@ static VALUE w_hash_compact(const VALUE self) {
|
|
618
653
|
VALUE hash = rb_hash_new();
|
619
654
|
for (auto &m : value->value->GetObject())
|
620
655
|
if (!m.value.IsNull())
|
621
|
-
rb_hash_aset(hash, eval(m.name,
|
656
|
+
rb_hash_aset(hash, eval(m.name, value->root_document), eval(m.value, value->root_document));
|
622
657
|
return hash;
|
623
658
|
}
|
624
659
|
|
@@ -638,12 +673,12 @@ static VALUE w_hash_each(const VALUE self) {
|
|
638
673
|
RETURN_SIZED_ENUMERATOR(self, 0, nullptr, hash_enum_size);
|
639
674
|
if (rb_proc_arity(rb_block_proc()) > 1) {
|
640
675
|
for (auto &m : value->value->GetObject()) {
|
641
|
-
VALUE args[] = { eval_str(m.name), eval(m.value,
|
676
|
+
VALUE args[] = { eval_str(m.name), eval(m.value, value->root_document) };
|
642
677
|
rb_yield_values2(2, args);
|
643
678
|
}
|
644
679
|
} else {
|
645
680
|
for (auto &m : value->value->GetObject())
|
646
|
-
rb_yield(rb_assoc_new(eval_str(m.name), eval(m.value,
|
681
|
+
rb_yield(rb_assoc_new(eval_str(m.name), eval(m.value, value->root_document)));
|
647
682
|
}
|
648
683
|
return self;
|
649
684
|
}
|
@@ -671,7 +706,7 @@ static VALUE w_hash_each_value(const VALUE self) {
|
|
671
706
|
check_object(value);
|
672
707
|
RETURN_SIZED_ENUMERATOR(self, 0, nullptr, hash_enum_size);
|
673
708
|
for (auto &m : value->value->GetObject())
|
674
|
-
rb_yield(eval(m.value,
|
709
|
+
rb_yield(eval(m.value, value->root_document));
|
675
710
|
return self;
|
676
711
|
}
|
677
712
|
|
@@ -698,7 +733,7 @@ static VALUE w_hash_fetch(const int argc, const VALUE *argv, const VALUE self) {
|
|
698
733
|
check_object(value);
|
699
734
|
for (auto &m : value->value->GetObject())
|
700
735
|
if (str_compare_xx(argv[0], m.name))
|
701
|
-
return eval(m.value,
|
736
|
+
return eval(m.value, value->root_document);
|
702
737
|
return argc == 2 ? argv[1] : rb_block_given_p() ? rb_yield(argv[0]) : Qnil;
|
703
738
|
}
|
704
739
|
|
@@ -714,7 +749,7 @@ static VALUE w_hash_fetch_values(const int argc, VALUE *argv, const VALUE self)
|
|
714
749
|
bool found = false;
|
715
750
|
for (auto &m : value->value->GetObject()) {
|
716
751
|
if (str_compare_xx(argv[i], m.name)) {
|
717
|
-
rb_ary_push(ret, eval(m.value,
|
752
|
+
rb_ary_push(ret, eval(m.value, value->root_document));
|
718
753
|
found = true;
|
719
754
|
break;
|
720
755
|
}
|
@@ -794,7 +829,7 @@ static VALUE w_hash_rassoc(const VALUE self, const VALUE val) {
|
|
794
829
|
check_object(value);
|
795
830
|
for (auto &m : value->value->GetObject())
|
796
831
|
if (rb_funcall(val, rb_intern("=="), 1, eval_r(m.value)))
|
797
|
-
return rb_assoc_new(eval_str(m.name), eval(m.value,
|
832
|
+
return rb_assoc_new(eval_str(m.name), eval(m.value, value->root_document));
|
798
833
|
return Qnil;
|
799
834
|
}
|
800
835
|
|
@@ -811,14 +846,14 @@ static VALUE w_hash_select(const VALUE self) {
|
|
811
846
|
VALUE hash = rb_hash_new();
|
812
847
|
if (rb_proc_arity(rb_block_proc()) > 1) {
|
813
848
|
for (auto &m : value->value->GetObject()) {
|
814
|
-
VALUE args[] = { eval_str(m.name), eval(m.value,
|
849
|
+
VALUE args[] = { eval_str(m.name), eval(m.value, value->root_document) };
|
815
850
|
if (RTEST(rb_yield_values2(2, args)))
|
816
851
|
rb_hash_aset(hash, args[0], args[1]);
|
817
852
|
}
|
818
853
|
} else {
|
819
854
|
for (auto &m : value->value->GetObject()) {
|
820
855
|
VALUE key = eval_str(m.name);
|
821
|
-
VALUE val = eval(m.value,
|
856
|
+
VALUE val = eval(m.value, value->root_document);
|
822
857
|
if (RTEST(rb_yield(rb_assoc_new(key, val))))
|
823
858
|
rb_hash_aset(hash, key, val);
|
824
859
|
}
|
@@ -839,14 +874,14 @@ static VALUE w_hash_reject(const VALUE self) {
|
|
839
874
|
VALUE hash = rb_hash_new();
|
840
875
|
if (rb_proc_arity(rb_block_proc()) > 1) {
|
841
876
|
for (auto &m : value->value->GetObject()) {
|
842
|
-
VALUE args[] = { eval_str(m.name), eval(m.value,
|
877
|
+
VALUE args[] = { eval_str(m.name), eval(m.value, value->root_document) };
|
843
878
|
if (!RTEST(rb_yield_values2(2, args)))
|
844
879
|
rb_hash_aset(hash, args[0], args[1]);
|
845
880
|
}
|
846
881
|
} else {
|
847
882
|
for (auto &m : value->value->GetObject()) {
|
848
883
|
VALUE key = eval_str(m.name);
|
849
|
-
VALUE val = eval(m.value,
|
884
|
+
VALUE val = eval(m.value, value->root_document);
|
850
885
|
if (!RTEST(rb_yield(rb_assoc_new(key, val))))
|
851
886
|
rb_hash_aset(hash, key, val);
|
852
887
|
}
|
@@ -867,7 +902,7 @@ static VALUE w_hash_slice(const int argc, const VALUE *argv, const VALUE self) {
|
|
867
902
|
for (int i = 0; i < argc; i++)
|
868
903
|
for (auto &m : value->value->GetObject())
|
869
904
|
if (str_compare_xx(argv[i], m.name))
|
870
|
-
rb_hash_aset(hash, eval_str(m.name), eval(m.value,
|
905
|
+
rb_hash_aset(hash, eval_str(m.name), eval(m.value, value->root_document));
|
871
906
|
return hash;
|
872
907
|
}
|
873
908
|
|
@@ -879,19 +914,15 @@ static VALUE w_hash_slice(const int argc, const VALUE *argv, const VALUE self) {
|
|
879
914
|
static VALUE w_hash_eval(const VALUE self) {
|
880
915
|
UsaminValue *value = get_value(self);
|
881
916
|
check_object(value);
|
882
|
-
return eval_object(*(value->value),
|
917
|
+
return eval_object(*(value->value), value->root_document);
|
883
918
|
}
|
884
919
|
|
885
920
|
/*
|
886
|
-
* @return [::
|
921
|
+
* @return [::Hash]
|
887
922
|
*/
|
888
|
-
static VALUE
|
889
|
-
|
890
|
-
|
891
|
-
VALUE ret = rb_ary_new2(value->value->MemberCount());
|
892
|
-
for (auto &m : value->value->GetObject())
|
893
|
-
rb_ary_push(ret, rb_assoc_new(eval_str(m.name), eval(m.value, self)));
|
894
|
-
return ret;
|
923
|
+
static VALUE w_hash_merge(const int argc, const VALUE *argv, const VALUE self) {
|
924
|
+
static ID s = rb_intern("merge");
|
925
|
+
return rb_funcall2(w_hash_eval(self), s, argc, argv);
|
895
926
|
}
|
896
927
|
|
897
928
|
/*
|
@@ -902,7 +933,7 @@ static VALUE w_hash_values(const VALUE self) {
|
|
902
933
|
check_object(value);
|
903
934
|
VALUE ret = rb_ary_new2(value->value->MemberCount());
|
904
935
|
for (auto &m : value->value->GetObject())
|
905
|
-
rb_ary_push(ret, eval(m.value,
|
936
|
+
rb_ary_push(ret, eval(m.value, value->root_document));
|
906
937
|
return ret;
|
907
938
|
}
|
908
939
|
|
@@ -917,7 +948,7 @@ static VALUE w_hash_transform_keys(const VALUE self) {
|
|
917
948
|
RETURN_SIZED_ENUMERATOR(self, 0, nullptr, hash_enum_size);
|
918
949
|
VALUE hash = rb_hash_new();
|
919
950
|
for (auto &m : value->value->GetObject())
|
920
|
-
rb_hash_aset(hash, rb_yield(eval_str(m.name)), eval(m.value,
|
951
|
+
rb_hash_aset(hash, rb_yield(eval_str(m.name)), eval(m.value, value->root_document));
|
921
952
|
return hash;
|
922
953
|
}
|
923
954
|
|
@@ -932,7 +963,7 @@ static VALUE w_hash_transform_values(const VALUE self) {
|
|
932
963
|
RETURN_SIZED_ENUMERATOR(self, 0, nullptr, hash_enum_size);
|
933
964
|
VALUE hash = rb_hash_new();
|
934
965
|
for (auto &m : value->value->GetObject())
|
935
|
-
rb_hash_aset(hash, eval_str(m.name), rb_yield(eval(m.value,
|
966
|
+
rb_hash_aset(hash, eval_str(m.name), rb_yield(eval(m.value, value->root_document)));
|
936
967
|
return hash;
|
937
968
|
}
|
938
969
|
|
@@ -948,7 +979,7 @@ static VALUE w_hash_values_at(const int argc, const VALUE *argv, const VALUE sel
|
|
948
979
|
VALUE data = Qnil;
|
949
980
|
for (auto &m : value->value->GetObject()) {
|
950
981
|
if (str_compare_xx(argv[i], m.name)) {
|
951
|
-
data = eval(m.value,
|
982
|
+
data = eval(m.value, value->root_document);
|
952
983
|
break;
|
953
984
|
}
|
954
985
|
}
|
@@ -987,7 +1018,7 @@ static VALUE w_array_operator_indexer(const int argc, const VALUE *argv, const V
|
|
987
1018
|
end = sz;
|
988
1019
|
VALUE ret = rb_ary_new2(end - beg);
|
989
1020
|
for (rapidjson::SizeType i = static_cast<rapidjson::SizeType>(beg); i < end; i++)
|
990
|
-
rb_ary_push(ret, eval((*value->value)[i],
|
1021
|
+
rb_ary_push(ret, eval((*value->value)[i], value->root_document));
|
991
1022
|
return ret;
|
992
1023
|
}
|
993
1024
|
} else if (rb_obj_is_kind_of(argv[0], rb_cRange)) {
|
@@ -995,7 +1026,7 @@ static VALUE w_array_operator_indexer(const int argc, const VALUE *argv, const V
|
|
995
1026
|
if (rb_range_beg_len(argv[0], &beg, &len, sz, 0) == Qtrue) {
|
996
1027
|
VALUE ret = rb_ary_new2(len);
|
997
1028
|
for (rapidjson::SizeType i = static_cast<rapidjson::SizeType>(beg); i < beg + len; i++)
|
998
|
-
rb_ary_push(ret, eval((*value->value)[i],
|
1029
|
+
rb_ary_push(ret, eval((*value->value)[i], value->root_document));
|
999
1030
|
return ret;
|
1000
1031
|
}
|
1001
1032
|
} else {
|
@@ -1003,7 +1034,7 @@ static VALUE w_array_operator_indexer(const int argc, const VALUE *argv, const V
|
|
1003
1034
|
if (l < 0)
|
1004
1035
|
l += sz;
|
1005
1036
|
if (0 <= l && l < sz)
|
1006
|
-
return eval((*value->value)[static_cast<rapidjson::SizeType>(l)],
|
1037
|
+
return eval((*value->value)[static_cast<rapidjson::SizeType>(l)], value->root_document);
|
1007
1038
|
}
|
1008
1039
|
return Qnil;
|
1009
1040
|
}
|
@@ -1020,7 +1051,7 @@ static VALUE w_array_at(const VALUE self, const VALUE nth) {
|
|
1020
1051
|
if (l < 0)
|
1021
1052
|
l += sz;
|
1022
1053
|
if (0 <= l && l < sz)
|
1023
|
-
return eval((*value->value)[static_cast<rapidjson::SizeType>(l)],
|
1054
|
+
return eval((*value->value)[static_cast<rapidjson::SizeType>(l)], value->root_document);
|
1024
1055
|
return Qnil;
|
1025
1056
|
}
|
1026
1057
|
|
@@ -1033,7 +1064,7 @@ static VALUE w_array_compact(const VALUE self, const VALUE nth) {
|
|
1033
1064
|
VALUE ret = rb_ary_new2(value->value->Size());
|
1034
1065
|
for (auto &v : value->value->GetArray())
|
1035
1066
|
if (!v.IsNull())
|
1036
|
-
rb_ary_push(ret, eval(v,
|
1067
|
+
rb_ary_push(ret, eval(v, value->root_document));
|
1037
1068
|
return ret;
|
1038
1069
|
}
|
1039
1070
|
|
@@ -1050,7 +1081,7 @@ static VALUE w_array_each(const VALUE self) {
|
|
1050
1081
|
check_array(value);
|
1051
1082
|
RETURN_SIZED_ENUMERATOR(self, 0, nullptr, array_enum_size);
|
1052
1083
|
for (auto &v : value->value->GetArray())
|
1053
|
-
rb_yield(eval(v,
|
1084
|
+
rb_yield(eval(v, value->root_document));
|
1054
1085
|
return self;
|
1055
1086
|
}
|
1056
1087
|
|
@@ -1100,7 +1131,7 @@ static VALUE w_array_fetch(const int argc, const VALUE *argv, const VALUE self)
|
|
1100
1131
|
if (l < 0)
|
1101
1132
|
l += sz;
|
1102
1133
|
if (0 <= l && l < sz)
|
1103
|
-
return eval((*value->value)[static_cast<rapidjson::SizeType>(l)],
|
1134
|
+
return eval((*value->value)[static_cast<rapidjson::SizeType>(l)], value->root_document);
|
1104
1135
|
|
1105
1136
|
if (argc == 2)
|
1106
1137
|
return argv[1];
|
@@ -1136,7 +1167,7 @@ static VALUE w_array_find_index(const int argc, const VALUE *argv, const VALUE s
|
|
1136
1167
|
|
1137
1168
|
RETURN_SIZED_ENUMERATOR(self, 0, nullptr, array_enum_size);
|
1138
1169
|
for (rapidjson::SizeType i = 0; i < value->value->Size(); i++) {
|
1139
|
-
if (RTEST(rb_yield(eval((*value->value)[i],
|
1170
|
+
if (RTEST(rb_yield(eval((*value->value)[i], value->root_document))))
|
1140
1171
|
return UINT2NUM(i);
|
1141
1172
|
}
|
1142
1173
|
return Qnil;
|
@@ -1172,14 +1203,14 @@ static VALUE w_array_first(const int argc, const VALUE *argv, const VALUE self)
|
|
1172
1203
|
if (argc == 0) {
|
1173
1204
|
if (sz == 0)
|
1174
1205
|
return Qnil;
|
1175
|
-
return eval(*value->value->Begin(),
|
1206
|
+
return eval(*value->value->Begin(), value->root_document);
|
1176
1207
|
} else {
|
1177
1208
|
long l = FIX2LONG(argv[0]);
|
1178
1209
|
if (l > sz)
|
1179
1210
|
l = sz;
|
1180
1211
|
VALUE ret = rb_ary_new2(l);
|
1181
1212
|
for (auto v = value->value->Begin(); v < value->value->Begin() + l; v++)
|
1182
|
-
rb_ary_push(ret, eval(*v,
|
1213
|
+
rb_ary_push(ret, eval(*v, value->root_document));
|
1183
1214
|
return ret;
|
1184
1215
|
}
|
1185
1216
|
}
|
@@ -1210,14 +1241,14 @@ static VALUE w_array_last(const int argc, const VALUE *argv, const VALUE self) {
|
|
1210
1241
|
rapidjson::SizeType sz = value->value->Size();
|
1211
1242
|
|
1212
1243
|
if (argc == 0) {
|
1213
|
-
return sz > 0 ? eval(*(value->value->End() - 1),
|
1244
|
+
return sz > 0 ? eval(*(value->value->End() - 1), value->root_document) : Qnil;
|
1214
1245
|
} else {
|
1215
1246
|
long l = FIX2LONG(argv[0]);
|
1216
1247
|
if (l > sz)
|
1217
1248
|
l = sz;
|
1218
1249
|
VALUE ret = rb_ary_new2(l);
|
1219
1250
|
for (auto v = value->value->End() - l; v < value->value->End(); v++)
|
1220
|
-
rb_ary_push(ret, eval(*v,
|
1251
|
+
rb_ary_push(ret, eval(*v, value->root_document));
|
1221
1252
|
return ret;
|
1222
1253
|
}
|
1223
1254
|
}
|
@@ -1257,7 +1288,7 @@ static VALUE w_array_slice(const int argc, const VALUE *argv, const VALUE self)
|
|
1257
1288
|
static VALUE w_array_eval(const VALUE self) {
|
1258
1289
|
UsaminValue *value = get_value(self);
|
1259
1290
|
check_array(value);
|
1260
|
-
return eval_array(*(value->value),
|
1291
|
+
return eval_array(*(value->value), value->root_document);
|
1261
1292
|
}
|
1262
1293
|
|
1263
1294
|
|
@@ -1349,7 +1380,7 @@ extern "C" void Init_usamin(void) {
|
|
1349
1380
|
rb_define_module_function(rb_mUsamin, "pretty_generate", RUBY_METHOD_FUNC(w_pretty_generate), -1);
|
1350
1381
|
|
1351
1382
|
rb_cUsaminValue = rb_define_class_under(rb_mUsamin, "Value", rb_cObject);
|
1352
|
-
|
1383
|
+
rb_undef_alloc_func(rb_cUsaminValue);
|
1353
1384
|
rb_undef_method(rb_cUsaminValue, "initialize");
|
1354
1385
|
rb_define_method(rb_cUsaminValue, "array?", RUBY_METHOD_FUNC(w_value_isarray), 0);
|
1355
1386
|
rb_define_method(rb_cUsaminValue, "hash?", RUBY_METHOD_FUNC(w_value_isobject), 0);
|
@@ -1357,8 +1388,7 @@ extern "C" void Init_usamin(void) {
|
|
1357
1388
|
rb_define_method(rb_cUsaminValue, "eval", RUBY_METHOD_FUNC(w_value_eval), 0);
|
1358
1389
|
rb_define_method(rb_cUsaminValue, "eval_r", RUBY_METHOD_FUNC(w_value_eval_r), 0);
|
1359
1390
|
rb_define_method(rb_cUsaminValue, "frozen?", RUBY_METHOD_FUNC(w_value_isfrozen), 0);
|
1360
|
-
rb_define_method(rb_cUsaminValue, "
|
1361
|
-
rb_define_method(rb_cUsaminValue, "marshal_load", RUBY_METHOD_FUNC(w_value_marshal_load), 1);
|
1391
|
+
rb_define_method(rb_cUsaminValue, "root", RUBY_METHOD_FUNC(w_value_root), 0);
|
1362
1392
|
|
1363
1393
|
rb_cUsaminHash = rb_define_class_under(rb_mUsamin, "Hash", rb_cUsaminValue);
|
1364
1394
|
rb_include_module(rb_cUsaminHash, rb_mEnumerable);
|
@@ -1385,17 +1415,18 @@ extern "C" void Init_usamin(void) {
|
|
1385
1415
|
rb_define_method(rb_cUsaminHash, "keys", RUBY_METHOD_FUNC(w_hash_keys), 0);
|
1386
1416
|
rb_define_method(rb_cUsaminHash, "length", RUBY_METHOD_FUNC(w_hash_length), 0);
|
1387
1417
|
rb_define_method(rb_cUsaminHash, "size", RUBY_METHOD_FUNC(w_hash_length), 0);
|
1418
|
+
rb_define_method(rb_cUsaminHash, "merge", RUBY_METHOD_FUNC(w_hash_merge), -1);
|
1388
1419
|
rb_define_method(rb_cUsaminHash, "rassoc", RUBY_METHOD_FUNC(w_hash_rassoc), 1);
|
1389
1420
|
rb_define_method(rb_cUsaminHash, "reject", RUBY_METHOD_FUNC(w_hash_reject), 0);
|
1390
1421
|
rb_define_method(rb_cUsaminHash, "select", RUBY_METHOD_FUNC(w_hash_select), 0);
|
1391
1422
|
rb_define_method(rb_cUsaminHash, "slice", RUBY_METHOD_FUNC(w_hash_slice), -1);
|
1392
|
-
rb_define_method(rb_cUsaminHash, "to_a", RUBY_METHOD_FUNC(w_hash_to_a), 0);
|
1393
|
-
rb_define_method(rb_cUsaminHash, "to_h", RUBY_METHOD_FUNC(w_hash_eval), 0);
|
1394
1423
|
rb_define_method(rb_cUsaminHash, "to_hash", RUBY_METHOD_FUNC(w_hash_eval), 0);
|
1395
1424
|
rb_define_method(rb_cUsaminHash, "transform_keys", RUBY_METHOD_FUNC(w_hash_transform_keys), 0);
|
1396
1425
|
rb_define_method(rb_cUsaminHash, "transform_values", RUBY_METHOD_FUNC(w_hash_transform_values), 0);
|
1397
1426
|
rb_define_method(rb_cUsaminHash, "values", RUBY_METHOD_FUNC(w_hash_values), 0);
|
1398
1427
|
rb_define_method(rb_cUsaminHash, "values_at", RUBY_METHOD_FUNC(w_hash_values_at), -1);
|
1428
|
+
rb_define_method(rb_cUsaminHash, "marshal_dump", RUBY_METHOD_FUNC(w_value_marshal_dump), 0);
|
1429
|
+
rb_define_method(rb_cUsaminHash, "marshal_load", RUBY_METHOD_FUNC(w_value_marshal_load), 1);
|
1399
1430
|
|
1400
1431
|
rb_cUsaminArray = rb_define_class_under(rb_mUsamin, "Array", rb_cUsaminValue);
|
1401
1432
|
rb_include_module(rb_cUsaminArray, rb_mEnumerable);
|
@@ -1416,8 +1447,9 @@ extern "C" void Init_usamin(void) {
|
|
1416
1447
|
rb_define_method(rb_cUsaminArray, "length", RUBY_METHOD_FUNC(w_array_length), 0);
|
1417
1448
|
rb_define_method(rb_cUsaminArray, "size", RUBY_METHOD_FUNC(w_array_length), 0);
|
1418
1449
|
rb_define_method(rb_cUsaminArray, "slice", RUBY_METHOD_FUNC(w_array_slice), -1);
|
1419
|
-
rb_define_method(rb_cUsaminArray, "to_a", RUBY_METHOD_FUNC(w_array_eval), 0);
|
1420
1450
|
rb_define_method(rb_cUsaminArray, "to_ary", RUBY_METHOD_FUNC(w_array_eval), 0);
|
1451
|
+
rb_define_method(rb_cUsaminArray, "marshal_dump", RUBY_METHOD_FUNC(w_value_marshal_dump), 0);
|
1452
|
+
rb_define_method(rb_cUsaminArray, "marshal_load", RUBY_METHOD_FUNC(w_value_marshal_load), 1);
|
1421
1453
|
|
1422
1454
|
rb_eUsaminError = rb_define_class_under(rb_mUsamin, "UsaminError", rb_eStandardError);
|
1423
1455
|
rb_eParserError = rb_define_class_under(rb_mUsamin, "ParserError", rb_eUsaminError);
|
data/lib/usamin/version.rb
CHANGED
data/usamin.gemspec
CHANGED
@@ -22,8 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
spec.extensions = ["ext/usamin/extconf.rb"]
|
24
24
|
|
25
|
-
spec.add_development_dependency "bundler"
|
26
|
-
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "bundler"
|
26
|
+
spec.add_development_dependency "rake"
|
27
27
|
spec.add_development_dependency "rake-compiler"
|
28
|
-
spec.add_development_dependency "pry"
|
28
|
+
spec.add_development_dependency "pry"
|
29
29
|
end
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: usamin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.7.
|
4
|
+
version: 7.7.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ishotihadus
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
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
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake-compiler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0
|
68
|
+
version: '0'
|
69
69
|
description: A fast JSON serializer / deserializer for Ruby with RapidJSON.
|
70
70
|
email:
|
71
71
|
- hanachan.pao@gmail.com
|
@@ -107,8 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
109
|
requirements: []
|
110
|
-
|
111
|
-
rubygems_version: 2.7.3
|
110
|
+
rubygems_version: 3.0.1
|
112
111
|
signing_key:
|
113
112
|
specification_version: 4
|
114
113
|
summary: A RapidJSON Wrapper for Ruby
|