Skip to content

Commit 45c86e1

Browse files
committed
Cleanup useless ifdef
The json gem now requires Ruby 2.3, so there is no point keeping compatibility code for older releases that don't have the TypedData API.
1 parent 4f876a8 commit 45c86e1

File tree

5 files changed

+15
-37
lines changed

5 files changed

+15
-37
lines changed

ext/json/ext/generator/generator.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -636,16 +636,12 @@ static size_t State_memsize(const void *ptr)
636636
# define RUBY_TYPED_FROZEN_SHAREABLE 0
637637
#endif
638638

639-
#ifdef NEW_TYPEDDATA_WRAPPER
640639
static const rb_data_type_t JSON_Generator_State_type = {
641640
"JSON/Generator/State",
642641
{NULL, State_free, State_memsize,},
643-
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
644642
0, 0,
645-
RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE,
646-
#endif
643+
RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE,
647644
};
648-
#endif
649645

650646
static VALUE cState_s_allocate(VALUE klass)
651647
{

ext/json/ext/generator/generator.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,7 @@ static inline void *ruby_zalloc(size_t n)
166166
return p;
167167
}
168168
#endif
169-
#ifdef TypedData_Make_Struct
169+
170170
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
176171

177172
#endif

ext/json/ext/parser/parser.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,12 +2097,12 @@ case 9:
20972097
static void JSON_mark(void *ptr)
20982098
{
20992099
JSON_Parser *json = ptr;
2100-
rb_gc_mark_maybe(json->Vsource);
2101-
rb_gc_mark_maybe(json->create_id);
2102-
rb_gc_mark_maybe(json->object_class);
2103-
rb_gc_mark_maybe(json->array_class);
2104-
rb_gc_mark_maybe(json->decimal_class);
2105-
rb_gc_mark_maybe(json->match_string);
2100+
rb_gc_mark(json->Vsource);
2101+
rb_gc_mark(json->create_id);
2102+
rb_gc_mark(json->object_class);
2103+
rb_gc_mark(json->array_class);
2104+
rb_gc_mark(json->decimal_class);
2105+
rb_gc_mark(json->match_string);
21062106
}
21072107

21082108
static void JSON_free(void *ptr)
@@ -2118,16 +2118,12 @@ static size_t JSON_memsize(const void *ptr)
21182118
return sizeof(*json) + FBUFFER_CAPA(json->fbuffer);
21192119
}
21202120

2121-
#ifdef NEW_TYPEDDATA_WRAPPER
21222121
static const rb_data_type_t JSON_Parser_type = {
21232122
"JSON/Parser",
21242123
{JSON_mark, JSON_free, JSON_memsize,},
2125-
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
21262124
0, 0,
21272125
RUBY_TYPED_FREE_IMMEDIATELY,
2128-
#endif
21292126
};
2130-
#endif
21312127

21322128
static VALUE cJSON_parser_s_allocate(VALUE klass)
21332129
{

ext/json/ext/parser/parser.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,7 @@ static inline void *ruby_zalloc(size_t n)
8585
return p;
8686
}
8787
#endif
88-
#ifdef TypedData_Make_Struct
88+
8989
static const rb_data_type_t JSON_Parser_type;
90-
#define NEW_TYPEDDATA_WRAPPER 1
91-
#else
92-
#define TypedData_Make_Struct(klass, type, ignore, json) Data_Make_Struct(klass, type, NULL, JSON_free, json)
93-
#define TypedData_Get_Struct(self, JSON_Parser, ignore, json) Data_Get_Struct(self, JSON_Parser, json)
94-
#endif
9590

9691
#endif

ext/json/ext/parser/parser.rl

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -857,12 +857,12 @@ static VALUE cParser_parse(VALUE self)
857857
static void JSON_mark(void *ptr)
858858
{
859859
JSON_Parser *json = ptr;
860-
rb_gc_mark_maybe(json->Vsource);
861-
rb_gc_mark_maybe(json->create_id);
862-
rb_gc_mark_maybe(json->object_class);
863-
rb_gc_mark_maybe(json->array_class);
864-
rb_gc_mark_maybe(json->decimal_class);
865-
rb_gc_mark_maybe(json->match_string);
860+
rb_gc_mark(json->Vsource);
861+
rb_gc_mark(json->create_id);
862+
rb_gc_mark(json->object_class);
863+
rb_gc_mark(json->array_class);
864+
rb_gc_mark(json->decimal_class);
865+
rb_gc_mark(json->match_string);
866866
}
867867

868868
static void JSON_free(void *ptr)
@@ -878,16 +878,12 @@ static size_t JSON_memsize(const void *ptr)
878878
return sizeof(*json) + FBUFFER_CAPA(json->fbuffer);
879879
}
880880

881-
#ifdef NEW_TYPEDDATA_WRAPPER
882881
static const rb_data_type_t JSON_Parser_type = {
883882
"JSON/Parser",
884883
{JSON_mark, JSON_free, JSON_memsize,},
885-
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
886884
0, 0,
887885
RUBY_TYPED_FREE_IMMEDIATELY,
888-
#endif
889886
};
890-
#endif
891887

892888
static VALUE cJSON_parser_s_allocate(VALUE klass)
893889
{

0 commit comments

Comments
 (0)