From 8a88e17575762e7a0ed33d4779cd18a6f9f43ebe Mon Sep 17 00:00:00 2001 From: ydah Date: Wed, 7 Oct 2026 23:05:27 +0900 Subject: [PATCH] Fix RFC 8785 number formatter spelling --- ext/json/ext/generator/generator.c | 18 +++++++++--------- java/src/json/ext/Generator.java | 2 +- java/src/json/ext/GeneratorState.java | 8 ++++---- lib/json/ext.rb | 2 +- lib/json/truffle_ruby/generator.rb | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ext/json/ext/generator/generator.c b/ext/json/ext/generator/generator.c index b2a35bcb..bdc34b71 100644 --- a/ext/json/ext/generator/generator.c +++ b/ext/json/ext/generator/generator.c @@ -32,7 +32,7 @@ typedef struct JSON_Generator_StateStruct { } JSON_Generator_State; static VALUE mJSON, cState, cFragment, eGeneratorError, eNestingError, Encoding_UTF_8, default_sort_keys_proc, - rfc8785_number_formater_proc, rfc8785_sort_keys_proc; + rfc8785_number_formatter_proc, rfc8785_sort_keys_proc; static ID i_to_s, i_to_json, i_new, i_encode; static VALUE sym_indent, sym_space, sym_space_before, sym_object_nl, sym_array_nl, sym_max_nesting, sym_allow_nan, sym_allow_duplicate_key, @@ -1171,7 +1171,7 @@ static void generate_json_float(FBuffer *buffer, struct generate_json_data *data } if (RB_UNLIKELY(data->state->rfc8785)) { - VALUE str = rb_proc_call_with_block(rfc8785_number_formater_proc, 1, &obj, Qnil); + VALUE str = rb_proc_call_with_block(rfc8785_number_formatter_proc, 1, &obj, Qnil); Check_Type(str, T_STRING); fbuffer_append_str(buffer, str); return; @@ -1754,15 +1754,15 @@ static VALUE cState_set_default_sort_keys_proc(VALUE self, VALUE proc) return default_sort_keys_proc = proc; } -static VALUE cState_set_rfc8785_number_formater_proc(VALUE self, VALUE proc) +static VALUE cState_set_rfc8785_number_formatter_proc(VALUE self, VALUE proc) { if (!rb_obj_is_proc(proc)) { - rb_raise(rb_eTypeError, "rfc8785_number_formater_proc must be a Proc"); + rb_raise(rb_eTypeError, "rfc8785_number_formatter_proc must be a Proc"); } - if (rfc8785_number_formater_proc) { - rb_raise(rb_eArgError, "rfc8785_number_formater_proc can only be set once"); + if (rfc8785_number_formatter_proc) { + rb_raise(rb_eArgError, "rfc8785_number_formatter_proc can only be set once"); } - return rfc8785_number_formater_proc = proc; + return rfc8785_number_formatter_proc = proc; } static VALUE cState_set_rfc8785_sort_keys_proc(VALUE self, VALUE proc) @@ -2036,7 +2036,7 @@ void Init_generator(void) VALUE mGenerator = rb_define_module_under(mExt, "Generator"); rb_global_variable(&default_sort_keys_proc); - rb_global_variable(&rfc8785_number_formater_proc); + rb_global_variable(&rfc8785_number_formatter_proc); rb_global_variable(&rfc8785_sort_keys_proc); rb_global_variable(&eGeneratorError); @@ -2049,7 +2049,7 @@ void Init_generator(void) rb_define_alloc_func(cState, cState_s_allocate); rb_define_singleton_method(cState, "from_state", cState_from_state_s, 1); rb_define_singleton_method(cState, "default_sort_keys_proc=", cState_set_default_sort_keys_proc, 1); - rb_define_singleton_method(cState, "rfc8785_number_formater_proc=", cState_set_rfc8785_number_formater_proc, 1); + rb_define_singleton_method(cState, "rfc8785_number_formatter_proc=", cState_set_rfc8785_number_formatter_proc, 1); rb_define_singleton_method(cState, "rfc8785_sort_keys_proc=", cState_set_rfc8785_sort_keys_proc, 1); rb_define_method(cState, "initialize", cState_initialize, -1); diff --git a/java/src/json/ext/Generator.java b/java/src/json/ext/Generator.java index a38c31d8..0f6bc824 100644 --- a/java/src/json/ext/Generator.java +++ b/java/src/json/ext/Generator.java @@ -421,7 +421,7 @@ static void generateFloat(ThreadContext context, Session session, RubyFloat obje } if (state.rfc8785()) { - RubyProc numberProc = (RubyProc)GeneratorState.rfc8785NumberFormaterProc; + RubyProc numberProc = (RubyProc)GeneratorState.rfc8785NumberFormatterProc; RubyString numberString = (RubyString)Helpers.invoke(context, numberProc, "call", object); buffer.write(numberString.toString().getBytes(UTF_8)); } else { diff --git a/java/src/json/ext/GeneratorState.java b/java/src/json/ext/GeneratorState.java index 97809134..d702ae8a 100644 --- a/java/src/json/ext/GeneratorState.java +++ b/java/src/json/ext/GeneratorState.java @@ -37,7 +37,7 @@ public class GeneratorState extends RubyObject { private boolean allowDuplicateKey = false; private static IRubyObject defaultSortKeyProc; - public static IRubyObject rfc8785NumberFormaterProc; + public static IRubyObject rfc8785NumberFormatterProc; public static IRubyObject rfc8785SortKeysProc; /** @@ -176,9 +176,9 @@ public static IRubyObject setDefaultSortKeyProc(IRubyObject klass, IRubyObject p return proc; } - @JRubyMethod(meta=true, name="rfc8785_number_formater_proc=") - public static IRubyObject setRfc8785NumberFormaterProc(IRubyObject klass, IRubyObject proc) { - rfc8785NumberFormaterProc = proc; + @JRubyMethod(meta=true, name="rfc8785_number_formatter_proc=") + public static IRubyObject setRfc8785NumberFormatterProc(IRubyObject klass, IRubyObject proc) { + rfc8785NumberFormatterProc = proc; return proc; } diff --git a/lib/json/ext.rb b/lib/json/ext.rb index 1c7965d0..c87f236a 100644 --- a/lib/json/ext.rb +++ b/lib/json/ext.rb @@ -59,7 +59,7 @@ def shareable_lambda(block) # :nodoc: }) # Directly lifted from Gregg Kellogg's json-canonicalization - generator::State.rfc8785_number_formater_proc = shareable_lambda(->(num) { + generator::State.rfc8785_number_formatter_proc = shareable_lambda(->(num) { if num.zero? "0" else diff --git a/lib/json/truffle_ruby/generator.rb b/lib/json/truffle_ruby/generator.rb index 6a755659..852ad4e5 100644 --- a/lib/json/truffle_ruby/generator.rb +++ b/lib/json/truffle_ruby/generator.rb @@ -112,7 +112,7 @@ def self.valid_utf8?(string) # while generating a JSON text from a Ruby data structure. class State singleton_class.attr_accessor :default_sort_keys_proc # :nodoc: - singleton_class.attr_accessor :rfc8785_number_formater_proc # :nodoc: + singleton_class.attr_accessor :rfc8785_number_formatter_proc # :nodoc: singleton_class.attr_accessor :rfc8785_sort_keys_proc # :nodoc: def self.generate(obj, opts = nil, io = nil) @@ -728,7 +728,7 @@ def to_json(state = nil, *args) raise GeneratorError.new("#{self} not allowed in JSON", self) end elsif state.rfc8785? - State.rfc8785_number_formater_proc.call(self) + State.rfc8785_number_formatter_proc.call(self) else to_s end