@@ -13,105 +13,13 @@ class JsonPatches < CommonPatches
13
13
gem : 'json' ,
14
14
patches : {
15
15
[ 'parser' , 'parser.c' ] => [
16
- *read_write_field ( 'json' , 'Vsource' , false ) ,
17
- *read_write_field ( 'json' , 'create_id' , false ) ,
18
- *read_write_field ( 'json' , 'object_class' , false ) ,
19
- *read_write_field ( 'json' , 'array_class' , false ) ,
20
- *read_write_field ( 'json' , 'decimal_class' , false ) ,
21
- *read_write_field ( 'json' , 'match_string' , false ) ,
22
- { # cParser_initialize
23
- match : /if \( rb_tr_managed_from_handle\( json->Vsource\) \) / ,
24
- replacement : 'if (json->Vsource)'
25
- } ,
26
- { # cParser_parse
27
- match : /VALUE result = Qnil;/ ,
28
- replacement : "VALUE result_array_for_address[1];\n result_array_for_address[0] = Qnil;"
29
- } ,
30
- { # cParser_parse
31
- match : /char \* np = JSON_parse_value\( json, p, pe, &result, 0\) ;/ ,
32
- replacement : 'char *np = JSON_parse_value(json, p, pe, result_array_for_address, 0);'
33
- } ,
34
- {
35
- match : /if \( cs >= JSON_first_final && p == pe\) {\s +return result;/m ,
36
- replacement : "if (cs >= JSON_first_final && p == pe) {\n return result_array_for_address[0];"
37
- } ,
38
- { # JSON_parse_object
39
- match : /VALUE last_name = Qnil;/ ,
40
- replacement : "VALUE last_name_array_for_address[1];\n last_name_array_for_address[0] = Qnil;"
41
- } ,
42
- { # JSON_parse_object
43
- match : /VALUE v = Qnil;/ ,
44
- replacement : "VALUE v_array_for_address[1];\n v_array_for_address[0] = Qnil;"
45
- } ,
46
- { # JSON_parse_object
47
- match : /np = JSON_parse_string\( json, p, pe, &last_name\) ;/ ,
48
- replacement : 'np = JSON_parse_string(json, p, pe, last_name_array_for_address);'
49
- } ,
50
- { # JSON_parse_object
51
- match : /rb_hash_aset\( \* result, last_name, v\) ;/ ,
52
- replacement : 'rb_hash_aset(*result, last_name_array_for_address[0], v_array_for_address[0]);'
53
- } ,
54
- { # JSON_parse_object
55
- match : /rb_funcall\( \* result, i_aset, 2, last_name, v\) ;/ ,
56
- replacement : 'rb_funcall(*result, i_aset, 2, last_name_array_for_address[0], v_array_for_address[0]);'
57
- } ,
58
- { # JSON_parse_object
59
- match : /char \* np = JSON_parse_value\( json, p, pe, &v, current_nesting\) ;/ ,
60
- replacement : 'char *np = JSON_parse_value(json, p, pe, v_array_for_address, current_nesting);'
61
- } ,
62
- { # JSON_parse_object
63
- match : /rb_ary_push\( \* result, v\) ;/ ,
64
- replacement : 'rb_ary_push(*result, v_array_for_address[0]);'
65
- } ,
66
- { # JSON_parse_object
67
- match : /rb_funcall\( \* result, i_leftshift, 1, v\) ;/ ,
68
- replacement : 'rb_funcall(*result, i_leftshift, 1, v_array_for_address[0]);'
69
- } ,
70
- { # JSON_parse_object
71
- match : /char \* np = JSON_parse_value\( json, p, pe, &v\) ;/ ,
72
- replacement : 'char *np = JSON_parse_value(json, p, pe, v_array_for_address);'
73
- } ,
74
- { # JSON_parse_string
75
- match : /if \( json->create_additions && RTEST\( match_string = rb_tr_managed_from_handle\( json->match_string\) \) \) {/ ,
76
- replacement : 'if (json->create_additions && RTEST(match_string = rb_tr_managed_from_handle_or_null(json->match_string))) {'
77
- } ,
78
16
{ # JSON_parse_string
79
17
# Work around a bug in the json extension where it tries to call `rb_str_resize` on non-String objects.
80
18
# We remove it entirely because the string resize is an MRI-optimization to reduce large preallocated strings
81
19
# to embedded strings. We don't have that distinction in our implementation and the resize would be a wasteful operation.
82
20
match : /rb_str_resize\( \* result, RSTRING_LEN\( \* result\) \) ;/ ,
83
21
replacement : ''
84
22
} ,
85
- { # cParser_parse_strict
86
- match : /np = JSON_parse_array\( json, p, pe, &result\) ;/ ,
87
- replacement : 'np = JSON_parse_array(json, p, pe, result_array_for_address);'
88
- } ,
89
- { # cParser_parse_strict
90
- match : /np = JSON_parse_object\( json, p, pe, &result\) ;/ ,
91
- replacement : 'np = JSON_parse_object(json, p, pe, result_array_for_address);'
92
- } ,
93
- { # cParser_parse_quirks_mode
94
- match : /if \( cs >= JSON_quirks_mode_first_final && p == pe\) {\s +return result;/m ,
95
- replacement : "if (cs >= JSON_quirks_mode_first_final && p == pe) {\n return result_array_for_address[0];"
96
- } ,
97
- { # cParser_parse_quirks_mode
98
- match : /char \* np = JSON_parse_value\( json, p, pe, &result\) ;/ ,
99
- replacement : 'char *np = JSON_parse_value(json, p, pe, result_array_for_address);'
100
- }
101
- ] ,
102
- [ 'generator' , 'generator.c' ] => [
103
- { # generate_json
104
- match : /if \( obj == Qnil\) / ,
105
- replacement : 'if (NIL_P(obj))'
106
- } ,
107
- { # generate_json
108
- match : /if \( obj == Qfalse\) / ,
109
- replacement : 'if (rb_tr_obj_equal(Qfalse, obj))'
110
- } ,
111
- { # generate_json
112
- match : /if \( obj == Qtrue\) / ,
113
- replacement : 'if (rb_tr_obj_equal(Qtrue, obj))'
114
- }
115
23
]
116
24
}
117
25
}
0 commit comments