json_pure 2.4.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +27 -5
- data/README.md +3 -3
- data/VERSION +1 -1
- data/json_pure.gemspec +43 -21
- data/lib/json/common.rb +34 -13
- data/lib/json/pure/parser.rb +1 -1
- data/lib/json/version.rb +1 -1
- data/lib/json.rb +1 -1
- metadata +14 -123
- data/.gitignore +0 -18
- data/.travis.yml +0 -23
- data/Gemfile +0 -14
- data/README-json-jruby.md +0 -33
- data/Rakefile +0 -334
- data/diagrams/.keep +0 -0
- data/ext/json/ext/fbuffer/fbuffer.h +0 -187
- data/ext/json/ext/generator/depend +0 -1
- data/ext/json/ext/generator/extconf.rb +0 -4
- data/ext/json/ext/generator/generator.c +0 -1612
- data/ext/json/ext/generator/generator.h +0 -174
- data/ext/json/ext/parser/depend +0 -1
- data/ext/json/ext/parser/extconf.rb +0 -31
- data/ext/json/ext/parser/parser.c +0 -2164
- data/ext/json/ext/parser/parser.h +0 -92
- data/ext/json/ext/parser/parser.rl +0 -924
- data/ext/json/extconf.rb +0 -3
- data/install.rb +0 -23
- data/java/src/json/ext/ByteListTranscoder.java +0 -166
- data/java/src/json/ext/Generator.java +0 -447
- data/java/src/json/ext/GeneratorMethods.java +0 -231
- data/java/src/json/ext/GeneratorService.java +0 -42
- data/java/src/json/ext/GeneratorState.java +0 -520
- data/java/src/json/ext/OptionsReader.java +0 -113
- data/java/src/json/ext/Parser.java +0 -2374
- data/java/src/json/ext/Parser.rl +0 -905
- data/java/src/json/ext/ParserService.java +0 -34
- data/java/src/json/ext/RuntimeInfo.java +0 -116
- data/java/src/json/ext/StringDecoder.java +0 -166
- data/java/src/json/ext/StringEncoder.java +0 -117
- data/java/src/json/ext/Utils.java +0 -88
- data/json-java.gemspec +0 -38
- data/json.gemspec +0 -140
- data/lib/json/ext/.keep +0 -0
- data/references/rfc7159.txt +0 -899
- data/tests/fixtures/fail10.json +0 -1
- data/tests/fixtures/fail11.json +0 -1
- data/tests/fixtures/fail12.json +0 -1
- data/tests/fixtures/fail13.json +0 -1
- data/tests/fixtures/fail14.json +0 -1
- data/tests/fixtures/fail18.json +0 -1
- data/tests/fixtures/fail19.json +0 -1
- data/tests/fixtures/fail2.json +0 -1
- data/tests/fixtures/fail20.json +0 -1
- data/tests/fixtures/fail21.json +0 -1
- data/tests/fixtures/fail22.json +0 -1
- data/tests/fixtures/fail23.json +0 -1
- data/tests/fixtures/fail24.json +0 -1
- data/tests/fixtures/fail25.json +0 -1
- data/tests/fixtures/fail27.json +0 -2
- data/tests/fixtures/fail28.json +0 -2
- data/tests/fixtures/fail3.json +0 -1
- data/tests/fixtures/fail4.json +0 -1
- data/tests/fixtures/fail5.json +0 -1
- data/tests/fixtures/fail6.json +0 -1
- data/tests/fixtures/fail7.json +0 -1
- data/tests/fixtures/fail8.json +0 -1
- data/tests/fixtures/fail9.json +0 -1
- data/tests/fixtures/obsolete_fail1.json +0 -1
- data/tests/fixtures/pass1.json +0 -56
- data/tests/fixtures/pass15.json +0 -1
- data/tests/fixtures/pass16.json +0 -1
- data/tests/fixtures/pass17.json +0 -1
- data/tests/fixtures/pass2.json +0 -1
- data/tests/fixtures/pass26.json +0 -1
- data/tests/fixtures/pass3.json +0 -6
- data/tests/json_addition_test.rb +0 -199
- data/tests/json_common_interface_test.rb +0 -169
- data/tests/json_encoding_test.rb +0 -107
- data/tests/json_ext_parser_test.rb +0 -15
- data/tests/json_fixtures_test.rb +0 -40
- data/tests/json_generator_test.rb +0 -432
- data/tests/json_generic_object_test.rb +0 -82
- data/tests/json_parser_test.rb +0 -497
- data/tests/json_string_matching_test.rb +0 -38
- data/tests/test_helper.rb +0 -17
- data/tools/diff.sh +0 -18
- data/tools/fuzz.rb +0 -131
- data/tools/server.rb +0 -62
@@ -1,174 +0,0 @@
|
|
1
|
-
#ifndef _GENERATOR_H_
|
2
|
-
#define _GENERATOR_H_
|
3
|
-
|
4
|
-
#include <math.h>
|
5
|
-
#include <ctype.h>
|
6
|
-
|
7
|
-
#include "ruby.h"
|
8
|
-
|
9
|
-
#ifdef HAVE_RUBY_RE_H
|
10
|
-
#include "ruby/re.h"
|
11
|
-
#else
|
12
|
-
#include "re.h"
|
13
|
-
#endif
|
14
|
-
|
15
|
-
#ifndef rb_intern_str
|
16
|
-
#define rb_intern_str(string) SYM2ID(rb_str_intern(string))
|
17
|
-
#endif
|
18
|
-
|
19
|
-
#ifndef rb_obj_instance_variables
|
20
|
-
#define rb_obj_instance_variables(object) rb_funcall(object, rb_intern("instance_variables"), 0)
|
21
|
-
#endif
|
22
|
-
|
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 escape_slash);
|
53
|
-
static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string, char escape_slash);
|
54
|
-
static char *fstrndup(const char *ptr, unsigned long len);
|
55
|
-
|
56
|
-
/* ruby api and some helpers */
|
57
|
-
|
58
|
-
typedef struct JSON_Generator_StateStruct {
|
59
|
-
char *indent;
|
60
|
-
long indent_len;
|
61
|
-
char *space;
|
62
|
-
long space_len;
|
63
|
-
char *space_before;
|
64
|
-
long space_before_len;
|
65
|
-
char *object_nl;
|
66
|
-
long object_nl_len;
|
67
|
-
char *array_nl;
|
68
|
-
long array_nl_len;
|
69
|
-
FBuffer *array_delim;
|
70
|
-
FBuffer *object_delim;
|
71
|
-
FBuffer *object_delim2;
|
72
|
-
long max_nesting;
|
73
|
-
char allow_nan;
|
74
|
-
char ascii_only;
|
75
|
-
char escape_slash;
|
76
|
-
long depth;
|
77
|
-
long buffer_initial_length;
|
78
|
-
} JSON_Generator_State;
|
79
|
-
|
80
|
-
#define GET_STATE_TO(self, state) \
|
81
|
-
TypedData_Get_Struct(self, JSON_Generator_State, &JSON_Generator_State_type, state)
|
82
|
-
|
83
|
-
#define GET_STATE(self) \
|
84
|
-
JSON_Generator_State *state; \
|
85
|
-
GET_STATE_TO(self, state)
|
86
|
-
|
87
|
-
#define GENERATE_JSON(type) \
|
88
|
-
FBuffer *buffer; \
|
89
|
-
VALUE Vstate; \
|
90
|
-
JSON_Generator_State *state; \
|
91
|
-
\
|
92
|
-
rb_scan_args(argc, argv, "01", &Vstate); \
|
93
|
-
Vstate = cState_from_state_s(cState, Vstate); \
|
94
|
-
TypedData_Get_Struct(Vstate, JSON_Generator_State, &JSON_Generator_State_type, state); \
|
95
|
-
buffer = cState_prepare_buffer(Vstate); \
|
96
|
-
generate_json_##type(buffer, Vstate, state, self); \
|
97
|
-
return fbuffer_to_s(buffer)
|
98
|
-
|
99
|
-
static VALUE mHash_to_json(int argc, VALUE *argv, VALUE self);
|
100
|
-
static VALUE mArray_to_json(int argc, VALUE *argv, VALUE self);
|
101
|
-
#ifdef RUBY_INTEGER_UNIFICATION
|
102
|
-
static VALUE mInteger_to_json(int argc, VALUE *argv, VALUE self);
|
103
|
-
#else
|
104
|
-
static VALUE mFixnum_to_json(int argc, VALUE *argv, VALUE self);
|
105
|
-
static VALUE mBignum_to_json(int argc, VALUE *argv, VALUE self);
|
106
|
-
#endif
|
107
|
-
static VALUE mFloat_to_json(int argc, VALUE *argv, VALUE self);
|
108
|
-
static VALUE mString_included_s(VALUE self, VALUE modul);
|
109
|
-
static VALUE mString_to_json(int argc, VALUE *argv, VALUE self);
|
110
|
-
static VALUE mString_to_json_raw_object(VALUE self);
|
111
|
-
static VALUE mString_to_json_raw(int argc, VALUE *argv, VALUE self);
|
112
|
-
static VALUE mString_Extend_json_create(VALUE self, VALUE o);
|
113
|
-
static VALUE mTrueClass_to_json(int argc, VALUE *argv, VALUE self);
|
114
|
-
static VALUE mFalseClass_to_json(int argc, VALUE *argv, VALUE self);
|
115
|
-
static VALUE mNilClass_to_json(int argc, VALUE *argv, VALUE self);
|
116
|
-
static VALUE mObject_to_json(int argc, VALUE *argv, VALUE self);
|
117
|
-
static void State_free(void *state);
|
118
|
-
static VALUE cState_s_allocate(VALUE klass);
|
119
|
-
static VALUE cState_configure(VALUE self, VALUE opts);
|
120
|
-
static VALUE cState_to_h(VALUE self);
|
121
|
-
static void generate_json(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
122
|
-
static void generate_json_object(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
123
|
-
static void generate_json_array(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
124
|
-
static void generate_json_string(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
125
|
-
static void generate_json_null(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
126
|
-
static void generate_json_false(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
127
|
-
static void generate_json_true(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
128
|
-
#ifdef RUBY_INTEGER_UNIFICATION
|
129
|
-
static void generate_json_integer(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
130
|
-
#endif
|
131
|
-
static void generate_json_fixnum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
132
|
-
static void generate_json_bignum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
133
|
-
static void generate_json_float(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
|
134
|
-
static VALUE cState_partial_generate(VALUE self, VALUE obj);
|
135
|
-
static VALUE cState_generate(VALUE self, VALUE obj);
|
136
|
-
static VALUE cState_initialize(int argc, VALUE *argv, VALUE self);
|
137
|
-
static VALUE cState_from_state_s(VALUE self, VALUE opts);
|
138
|
-
static VALUE cState_indent(VALUE self);
|
139
|
-
static VALUE cState_indent_set(VALUE self, VALUE indent);
|
140
|
-
static VALUE cState_space(VALUE self);
|
141
|
-
static VALUE cState_space_set(VALUE self, VALUE space);
|
142
|
-
static VALUE cState_space_before(VALUE self);
|
143
|
-
static VALUE cState_space_before_set(VALUE self, VALUE space_before);
|
144
|
-
static VALUE cState_object_nl(VALUE self);
|
145
|
-
static VALUE cState_object_nl_set(VALUE self, VALUE object_nl);
|
146
|
-
static VALUE cState_array_nl(VALUE self);
|
147
|
-
static VALUE cState_array_nl_set(VALUE self, VALUE array_nl);
|
148
|
-
static VALUE cState_max_nesting(VALUE self);
|
149
|
-
static VALUE cState_max_nesting_set(VALUE self, VALUE depth);
|
150
|
-
static VALUE cState_allow_nan_p(VALUE self);
|
151
|
-
static VALUE cState_ascii_only_p(VALUE self);
|
152
|
-
static VALUE cState_depth(VALUE self);
|
153
|
-
static VALUE cState_depth_set(VALUE self, VALUE depth);
|
154
|
-
static VALUE cState_escape_slash(VALUE self);
|
155
|
-
static VALUE cState_escape_slash_set(VALUE self, VALUE depth);
|
156
|
-
static FBuffer *cState_prepare_buffer(VALUE self);
|
157
|
-
#ifndef ZALLOC
|
158
|
-
#define ZALLOC(type) ((type *)ruby_zalloc(sizeof(type)))
|
159
|
-
static inline void *ruby_zalloc(size_t n)
|
160
|
-
{
|
161
|
-
void *p = ruby_xmalloc(n);
|
162
|
-
memset(p, 0, n);
|
163
|
-
return p;
|
164
|
-
}
|
165
|
-
#endif
|
166
|
-
#ifdef TypedData_Make_Struct
|
167
|
-
static const rb_data_type_t JSON_Generator_State_type;
|
168
|
-
#define NEW_TYPEDDATA_WRAPPER 1
|
169
|
-
#else
|
170
|
-
#define TypedData_Make_Struct(klass, type, ignore, json) Data_Make_Struct(klass, type, NULL, State_free, json)
|
171
|
-
#define TypedData_Get_Struct(self, JSON_Generator_State, ignore, json) Data_Get_Struct(self, JSON_Generator_State, json)
|
172
|
-
#endif
|
173
|
-
|
174
|
-
#endif
|
data/ext/json/ext/parser/depend
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
parser.o: parser.c parser.h $(srcdir)/../fbuffer/fbuffer.h
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
require 'mkmf'
|
3
|
-
|
4
|
-
have_func("rb_enc_raise", "ruby.h")
|
5
|
-
|
6
|
-
# checking if String#-@ (str_uminus) dedupes... '
|
7
|
-
begin
|
8
|
-
a = -(%w(t e s t).join)
|
9
|
-
b = -(%w(t e s t).join)
|
10
|
-
if a.equal?(b)
|
11
|
-
$CFLAGS << ' -DSTR_UMINUS_DEDUPE=1 '
|
12
|
-
else
|
13
|
-
$CFLAGS << ' -DSTR_UMINUS_DEDUPE=0 '
|
14
|
-
end
|
15
|
-
rescue NoMethodError
|
16
|
-
$CFLAGS << ' -DSTR_UMINUS_DEDUPE=0 '
|
17
|
-
end
|
18
|
-
|
19
|
-
# checking if String#-@ (str_uminus) directly interns frozen strings... '
|
20
|
-
begin
|
21
|
-
s = rand.to_s.freeze
|
22
|
-
if (-s).equal?(s) && (-s.dup).equal?(s)
|
23
|
-
$CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=1 '
|
24
|
-
else
|
25
|
-
$CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=0 '
|
26
|
-
end
|
27
|
-
rescue NoMethodError
|
28
|
-
$CFLAGS << ' -DSTR_UMINUS_DEDUPE_FROZEN=0 '
|
29
|
-
end
|
30
|
-
|
31
|
-
create_makefile 'json/ext/parser'
|