Skip to content

Commit 8364dbd

Browse files
committed
Revert use of RUBY_TYPED_EMBEDDABLE
1 parent 4e2173d commit 8364dbd

File tree

5 files changed

+19
-23
lines changed

5 files changed

+19
-23
lines changed

ext/json/ext/generator/extconf.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
File.write('Makefile', dummy_makefile("").join)
66
else
77
append_cflags("-std=c99")
8-
have_const("RUBY_TYPED_EMBEDDABLE", "ruby.h") # RUBY_VERSION >= 3.3
9-
108
$defs << "-DJSON_GENERATOR"
119
$defs << "-DJSON_DEBUG" if ENV.fetch("JSON_DEBUG", "0") != "0"
1210

ext/json/ext/generator/generator.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -722,20 +722,27 @@ static void State_compact(void *ptr)
722722
state->as_json = rb_gc_location(state->as_json);
723723
}
724724

725+
static void State_free(void *ptr)
726+
{
727+
JSON_Generator_State *state = ptr;
728+
ruby_xfree(state);
729+
}
730+
725731
static size_t State_memsize(const void *ptr)
726732
{
727733
return sizeof(JSON_Generator_State);
728734
}
729735

730736
static const rb_data_type_t JSON_Generator_State_type = {
731-
.wrap_struct_name = "JSON/Generator/State",
732-
.function = {
737+
"JSON/Generator/State",
738+
{
733739
.dmark = State_mark,
734-
.dfree = RUBY_DEFAULT_FREE,
740+
.dfree = State_free,
735741
.dsize = State_memsize,
736742
.dcompact = State_compact,
737743
},
738-
.flags = RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE | RUBY_TYPED_EMBEDDABLE,
744+
0, 0,
745+
RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_FROZEN_SHAREABLE,
739746
};
740747

741748
static void state_init(JSON_Generator_State *state)

ext/json/ext/json.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ typedef unsigned char _Bool;
5454
# define RUBY_TYPED_FROZEN_SHAREABLE 0
5555
#endif
5656

57-
#ifndef RUBY_TYPED_EMBEDDABLE
58-
# define RUBY_TYPED_EMBEDDABLE 0
59-
#endif
60-
6157
#ifndef NORETURN
6258
#if defined(__has_attribute) && __has_attribute(noreturn)
6359
#define NORETURN(x) __attribute__((noreturn)) x
@@ -106,6 +102,4 @@ typedef unsigned char _Bool;
106102
#define JSON_CPU_LITTLE_ENDIAN_64BITS 0
107103
#endif
108104

109-
110-
111105
#endif // _JSON_H_

ext/json/ext/parser/extconf.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
have_func("rb_str_to_interned_str", "ruby.h") # RUBY_VERSION >= 3.0
77
have_func("rb_hash_new_capa", "ruby.h") # RUBY_VERSION >= 3.2
88
have_func("rb_hash_bulk_insert", "ruby.h") # Missing on TruffleRuby
9-
have_const("RUBY_TYPED_EMBEDDABLE", "ruby.h") # RUBY_VERSION >= 3.3
109

1110
append_cflags("-std=c99")
1211

ext/json/ext/parser/parser.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,7 @@ static void rvalue_stack_free(void *ptr)
251251
rvalue_stack *stack = (rvalue_stack *)ptr;
252252
if (stack) {
253253
ruby_xfree(stack->ptr);
254-
#ifndef HAVE_RUBY_TYPED_EMBEDDABLE
255254
ruby_xfree(stack);
256-
#endif
257255
}
258256
}
259257

@@ -264,13 +262,14 @@ static size_t rvalue_stack_memsize(const void *ptr)
264262
}
265263

266264
static const rb_data_type_t JSON_Parser_rvalue_stack_type = {
267-
.wrap_struct_name = "JSON::Ext::Parser/rvalue_stack",
268-
.function = {
265+
"JSON::Ext::Parser/rvalue_stack",
266+
{
269267
.dmark = rvalue_stack_mark,
270268
.dfree = rvalue_stack_free,
271269
.dsize = rvalue_stack_memsize,
272270
},
273-
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_EMBEDDABLE,
271+
0, 0,
272+
RUBY_TYPED_FREE_IMMEDIATELY,
274273
};
275274

276275
static rvalue_stack *rvalue_stack_spill(rvalue_stack *old_stack, VALUE *handle, rvalue_stack **stack_ref)
@@ -1609,9 +1608,7 @@ static void JSON_ParserConfig_mark(void *ptr)
16091608
static void JSON_ParserConfig_free(void *ptr)
16101609
{
16111610
JSON_ParserConfig *config = ptr;
1612-
#ifndef HAVE_RUBY_TYPED_EMBEDDABLE
16131611
ruby_xfree(config);
1614-
#endif
16151612
}
16161613

16171614
static size_t JSON_ParserConfig_memsize(const void *ptr)
@@ -1620,13 +1617,14 @@ static size_t JSON_ParserConfig_memsize(const void *ptr)
16201617
}
16211618

16221619
static const rb_data_type_t JSON_ParserConfig_type = {
1623-
.wrap_struct_name = "JSON::Ext::Parser/ParserConfig",
1624-
.function = {
1620+
"JSON::Ext::Parser/ParserConfig",
1621+
{
16251622
JSON_ParserConfig_mark,
16261623
JSON_ParserConfig_free,
16271624
JSON_ParserConfig_memsize,
16281625
},
1629-
.flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE | RUBY_TYPED_EMBEDDABLE,
1626+
0, 0,
1627+
RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FROZEN_SHAREABLE,
16301628
};
16311629

16321630
static VALUE cJSON_parser_s_allocate(VALUE klass)

0 commit comments

Comments
 (0)