json 2.7.2 → 2.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/BSDL +22 -0
- data/CHANGES.md +44 -17
- data/LEGAL +60 -0
- data/README.md +13 -165
- data/ext/json/ext/fbuffer/fbuffer.h +21 -62
- data/ext/json/ext/generator/extconf.rb +8 -2
- data/ext/json/ext/generator/generator.c +462 -653
- data/ext/json/ext/generator/generator.h +16 -64
- data/ext/json/ext/parser/extconf.rb +3 -1
- data/ext/json/ext/parser/parser.c +279 -253
- data/ext/json/ext/parser/parser.h +4 -40
- data/ext/json/ext/parser/parser.rl +208 -182
- data/json.gemspec +42 -49
- data/lib/json/add/bigdecimal.rb +1 -1
- data/lib/json/add/complex.rb +1 -1
- data/lib/json/add/core.rb +1 -1
- data/lib/json/add/date.rb +1 -1
- data/lib/json/add/date_time.rb +1 -1
- data/lib/json/add/exception.rb +1 -1
- data/lib/json/add/ostruct.rb +1 -1
- data/lib/json/add/range.rb +1 -1
- data/lib/json/add/rational.rb +1 -1
- data/lib/json/add/regexp.rb +1 -1
- data/lib/json/add/struct.rb +1 -1
- data/lib/json/add/symbol.rb +1 -2
- data/lib/json/add/time.rb +3 -10
- data/lib/json/common.rb +74 -43
- data/lib/json/ext/generator/state.rb +135 -0
- data/lib/json/ext.rb +15 -5
- data/lib/json/generic_object.rb +1 -1
- data/lib/json/pure/generator.rb +89 -22
- data/lib/json/pure/parser.rb +27 -33
- data/lib/json/pure.rb +1 -0
- data/lib/json/version.rb +3 -7
- data/lib/json.rb +1 -1
- metadata +17 -15
- data/ext/json/ext/generator/depend +0 -1
- data/ext/json/ext/parser/depend +0 -1
- data/ext/json/extconf.rb +0 -3
- /data/{LICENSE → COPYING} +0 -0
@@ -6,51 +6,23 @@
|
|
6
6
|
|
7
7
|
#include "ruby.h"
|
8
8
|
|
9
|
-
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
|
15
|
-
#
|
16
|
-
#
|
9
|
+
/* This is the fallback definition from Ruby 3.4 */
|
10
|
+
#ifndef RBIMPL_STDBOOL_H
|
11
|
+
#if defined(__cplusplus)
|
12
|
+
# if defined(HAVE_STDBOOL_H) && (__cplusplus >= 201103L)
|
13
|
+
# include <cstdbool>
|
14
|
+
# endif
|
15
|
+
#elif defined(HAVE_STDBOOL_H)
|
16
|
+
# include <stdbool.h>
|
17
|
+
#elif !defined(HAVE__BOOL)
|
18
|
+
typedef unsigned char _Bool;
|
19
|
+
# define bool _Bool
|
20
|
+
# define true ((_Bool)+1)
|
21
|
+
# define false ((_Bool)+0)
|
22
|
+
# define __bool_true_false_are_defined
|
17
23
|
#endif
|
18
|
-
|
19
|
-
#ifndef rb_obj_instance_variables
|
20
|
-
#define rb_obj_instance_variables(object) rb_funcall(object, rb_intern("instance_variables"), 0)
|
21
24
|
#endif
|
22
25
|
|
23
|
-
#define option_given_p(opts, key) RTEST(rb_funcall(opts, i_key_p, 1, key))
|
24
|
-
|
25
|
-
/* unicode definitions */
|
26
|
-
|
27
|
-
#define UNI_STRICT_CONVERSION 1
|
28
|
-
|
29
|
-
typedef unsigned long UTF32; /* at least 32 bits */
|
30
|
-
typedef unsigned short UTF16; /* at least 16 bits */
|
31
|
-
typedef unsigned char UTF8; /* typically 8 bits */
|
32
|
-
|
33
|
-
#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
|
34
|
-
#define UNI_MAX_BMP (UTF32)0x0000FFFF
|
35
|
-
#define UNI_MAX_UTF16 (UTF32)0x0010FFFF
|
36
|
-
#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF
|
37
|
-
#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF
|
38
|
-
|
39
|
-
#define UNI_SUR_HIGH_START (UTF32)0xD800
|
40
|
-
#define UNI_SUR_HIGH_END (UTF32)0xDBFF
|
41
|
-
#define UNI_SUR_LOW_START (UTF32)0xDC00
|
42
|
-
#define UNI_SUR_LOW_END (UTF32)0xDFFF
|
43
|
-
|
44
|
-
static const int halfShift = 10; /* used for shifting by 10 bits */
|
45
|
-
|
46
|
-
static const UTF32 halfBase = 0x0010000UL;
|
47
|
-
static const UTF32 halfMask = 0x3FFUL;
|
48
|
-
|
49
|
-
static unsigned char isLegalUTF8(const UTF8 *source, unsigned long length);
|
50
|
-
static void unicode_escape(char *buf, UTF16 character);
|
51
|
-
static void unicode_escape_to_buffer(FBuffer *buffer, char buf[6], UTF16 character);
|
52
|
-
static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string, char script_safe);
|
53
|
-
static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string, char script_safe);
|
54
26
|
static char *fstrndup(const char *ptr, unsigned long len);
|
55
27
|
|
56
28
|
/* ruby api and some helpers */
|
@@ -66,9 +38,6 @@ typedef struct JSON_Generator_StateStruct {
|
|
66
38
|
long object_nl_len;
|
67
39
|
char *array_nl;
|
68
40
|
long array_nl_len;
|
69
|
-
FBuffer *array_delim;
|
70
|
-
FBuffer *object_delim;
|
71
|
-
FBuffer *object_delim2;
|
72
41
|
long max_nesting;
|
73
42
|
char allow_nan;
|
74
43
|
char ascii_only;
|
@@ -92,7 +61,7 @@ typedef struct JSON_Generator_StateStruct {
|
|
92
61
|
\
|
93
62
|
rb_scan_args(argc, argv, "01", &Vstate); \
|
94
63
|
Vstate = cState_from_state_s(cState, Vstate); \
|
95
|
-
TypedData_Get_Struct(Vstate, JSON_Generator_State, &JSON_Generator_State_type, state);
|
64
|
+
TypedData_Get_Struct(Vstate, JSON_Generator_State, &JSON_Generator_State_type, state); \
|
96
65
|
buffer = cState_prepare_buffer(Vstate); \
|
97
66
|
generate_json_##type(buffer, Vstate, state, self); \
|
98
67
|
return fbuffer_to_s(buffer)
|
@@ -117,8 +86,6 @@ static VALUE mNilClass_to_json(int argc, VALUE *argv, VALUE self);
|
|
117
86
|
static VALUE mObject_to_json(int argc, VALUE *argv, VALUE self);
|
118
87
|
static void State_free(void *state);
|
119
88
|
static VALUE cState_s_allocate(VALUE klass);
|
120
|
-
static VALUE cState_configure(VALUE self, VALUE opts);
|
121
|
-
static VALUE cState_to_h(VALUE self);
|
122
89
|
static void generate_json(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
123
90
|
static void generate_json_object(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
124
91
|
static void generate_json_array(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
@@ -134,7 +101,6 @@ static void generate_json_bignum(FBuffer *buffer, VALUE Vstate, JSON_Generator_S
|
|
134
101
|
static void generate_json_float(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
135
102
|
static VALUE cState_partial_generate(VALUE self, VALUE obj);
|
136
103
|
static VALUE cState_generate(VALUE self, VALUE obj);
|
137
|
-
static VALUE cState_initialize(int argc, VALUE *argv, VALUE self);
|
138
104
|
static VALUE cState_from_state_s(VALUE self, VALUE opts);
|
139
105
|
static VALUE cState_indent(VALUE self);
|
140
106
|
static VALUE cState_indent_set(VALUE self, VALUE indent);
|
@@ -157,21 +123,7 @@ static VALUE cState_script_safe_set(VALUE self, VALUE depth);
|
|
157
123
|
static VALUE cState_strict(VALUE self);
|
158
124
|
static VALUE cState_strict_set(VALUE self, VALUE strict);
|
159
125
|
static FBuffer *cState_prepare_buffer(VALUE self);
|
160
|
-
|
161
|
-
#define ZALLOC(type) ((type *)ruby_zalloc(sizeof(type)))
|
162
|
-
static inline void *ruby_zalloc(size_t n)
|
163
|
-
{
|
164
|
-
void *p = ruby_xmalloc(n);
|
165
|
-
memset(p, 0, n);
|
166
|
-
return p;
|
167
|
-
}
|
168
|
-
#endif
|
169
|
-
#ifdef TypedData_Make_Struct
|
126
|
+
|
170
127
|
static const rb_data_type_t JSON_Generator_State_type;
|
171
|
-
#define NEW_TYPEDDATA_WRAPPER 1
|
172
|
-
#else
|
173
|
-
#define TypedData_Make_Struct(klass, type, ignore, json) Data_Make_Struct(klass, type, NULL, State_free, json)
|
174
|
-
#define TypedData_Get_Struct(self, JSON_Generator_State, ignore, json) Data_Get_Struct(self, JSON_Generator_State, json)
|
175
|
-
#endif
|
176
128
|
|
177
129
|
#endif
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
require 'mkmf'
|
3
3
|
|
4
4
|
have_func("rb_enc_raise", "ruby.h")
|
@@ -29,4 +29,6 @@ rescue NoMethodError
|
|
29
29
|
$CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=0 '
|
30
30
|
end
|
31
31
|
|
32
|
+
append_cflags("-std=c99")
|
33
|
+
|
32
34
|
create_makefile 'json/ext/parser'
|