json 2.7.1 → 2.7.3.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,51 +6,23 @@
6
6
 
7
7
  #include "ruby.h"
8
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))
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
- #ifndef ZALLOC
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: false
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'