[4192] MacRuby/trunk/ext/json/rubyext.c
Revision: 4192 http://trac.macosforge.org/projects/ruby/changeset/4192 Author: lsansonetti@apple.com Date: 2010-06-01 21:29:32 -0700 (Tue, 01 Jun 2010) Log Message: ----------- port to the new dispatcher Modified Paths: -------------- MacRuby/trunk/ext/json/rubyext.c Modified: MacRuby/trunk/ext/json/rubyext.c =================================================================== --- MacRuby/trunk/ext/json/rubyext.c 2010-06-02 04:14:57 UTC (rev 4191) +++ MacRuby/trunk/ext/json/rubyext.c 2010-06-02 04:29:32 UTC (rev 4192) @@ -90,13 +90,6 @@ static SEL sel_to_s; static SEL sel_to_json; -static struct mcache* parse_cache = NULL; -static struct mcache* encode_cache = NULL; -static struct mcache* keys_cache = NULL; -static struct mcache* to_s_cache = NULL; -static struct mcache* to_json_cache = NULL; - - static VALUE rb_json_parser_alloc(VALUE klass, SEL sel) { @@ -393,10 +386,10 @@ switch (TYPE(obj)) { case T_HASH: status = yajl_gen_map_open(gen->generator); - keys = rb_vm_call_with_cache(keys_cache, obj, sel_keys, 0, 0); + keys = rb_vm_call(obj, sel_keys, 0, 0); for(i = 0, len = RARRAY_LEN(keys); i < len; i++) { entry = rb_ary_entry(keys, i); - keyStr = rb_vm_call_with_cache(to_s_cache, entry, sel_to_s, 0, 0); + keyStr = rb_vm_call(entry, sel_to_s, 0, 0); json_encode_part(gen, keyStr); json_encode_part(gen, rb_hash_aref(obj, entry)); } @@ -422,7 +415,7 @@ case T_FIXNUM: case T_FLOAT: case T_BIGNUM: - str = rb_vm_call_with_cache(to_s_cache, obj, sel_to_s, 0, 0); + str = rb_vm_call(obj, sel_to_s, 0, 0); cptr = RSTRING_PTR(str); if (!strcmp(cptr, "NaN") || !strcmp(cptr, "Infinity") || !strcmp(cptr, "-Infinity")) { rb_raise(rb_cEncodeError, "'%s' is an invalid number", cptr); @@ -439,11 +432,11 @@ break; default: if (rb_respond_to(obj, id_to_json)) { - str = rb_vm_call_with_cache(to_json_cache, obj, sel_to_json, 0, 0); + str = rb_vm_call(obj, sel_to_json, 0, 0); quote_strings = 0; } else { - str = rb_vm_call_with_cache(to_s_cache, obj, sel_to_s, 0, 0); + str = rb_vm_call(obj, sel_to_s, 0, 0); } cptr = RSTRING_PTR(str); status = yajl_gen_string(gen->generator, (const unsigned char*)cptr, (unsigned int)strlen(cptr), quote_strings); @@ -467,7 +460,7 @@ rb_obj_call_init(parser, 1, &opts); } - return rb_vm_call_with_cache(parse_cache, parser, sel_parse, 1, &str); + return rb_vm_call(parser, sel_parse, 1, &str); } static VALUE @@ -485,7 +478,7 @@ rb_obj_call_init(generator, 1, &opts); } - return rb_vm_call_with_cache(encode_cache, generator, sel_encode, 1, &obj); + return rb_vm_call(generator, sel_encode, 1, &obj); } static VALUE @@ -515,13 +508,13 @@ rb_obj_call_init(generator, 0, 0); } - return rb_vm_call_with_cache(encode_cache, generator, sel_encode, 1, &self); + return rb_vm_call(generator, sel_encode, 1, &self); } static VALUE rb_object_to_json(VALUE self, SEL sel, int argc, VALUE* argv) { - VALUE str = rb_vm_call_with_cache(to_s_cache, self, sel_to_s, 0, 0); + VALUE str = rb_vm_call(self, sel_to_s, 0, 0); VALUE buf = rb_str_new2("\""); rb_str_concat(buf, str); @@ -549,12 +542,6 @@ sel_to_s = sel_registerName("to_s"); sel_to_json = sel_registerName("to_json"); - parse_cache = rb_vm_get_call_cache(sel_parse); - encode_cache = rb_vm_get_call_cache(sel_encode); - keys_cache = rb_vm_get_call_cache(sel_keys); - to_s_cache = rb_vm_get_call_cache(sel_to_s); - to_json_cache = rb_vm_get_call_cache(sel_to_json); - rb_mJSON = rb_define_module("JSON"); rb_cParseError = rb_define_class_under(rb_mJSON, "ParseError", rb_eStandardError);
participants (1)
-
source_changes@macosforge.org