From 9f156be0fe40f57e4a5727904d5c2b761fa2cef2 Mon Sep 17 00:00:00 2001 From: Florian Frank Date: Tue, 3 Aug 2010 03:47:48 +0200 Subject: use rb_funcall for duping rbx doesn't support rb_obj_dup :-( --- ext/json/ext/generator/generator.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'ext') diff --git a/ext/json/ext/generator/generator.c b/ext/json/ext/generator/generator.c index 761274b..7658acd 100644 --- a/ext/json/ext/generator/generator.c +++ b/ext/json/ext/generator/generator.c @@ -14,7 +14,7 @@ static VALUE mJSON, mExt, mGenerator, cState, mGeneratorMethods, mObject, static ID i_to_s, i_to_json, i_new, i_indent, i_space, i_space_before, i_object_nl, i_array_nl, i_max_nesting, i_allow_nan, i_ascii_only, i_pack, i_unpack, i_create_id, i_extend, i_key_p, i_aref, i_send, - i_respond_to_p, i_match; + i_respond_to_p, i_match, i_keys, i_dup; /* * Copyright 2001-2004 Unicode, Inc. @@ -1017,7 +1017,6 @@ static VALUE cState_initialize(int argc, VALUE *argv, VALUE self) { VALUE opts; GET_STATE(self); - MEMZERO(state, JSON_Generator_State, 1); state->max_nesting = 19; rb_scan_args(argc, argv, "01", &opts); if (!NIL_P(opts)) cState_configure(self, opts); @@ -1067,7 +1066,7 @@ static VALUE cState_from_state_s(VALUE self, VALUE opts) if (NIL_P(CJSON_SAFE_STATE_PROTOTYPE)) { CJSON_SAFE_STATE_PROTOTYPE = rb_const_get(mJSON, rb_intern("SAFE_STATE_PROTOTYPE")); } - return rb_obj_dup(CJSON_SAFE_STATE_PROTOTYPE); + return rb_funcall(CJSON_SAFE_STATE_PROTOTYPE, i_dup, 0); } } @@ -1384,6 +1383,8 @@ void Init_generator() i_send = rb_intern("__send__"); i_respond_to_p = rb_intern("respond_to?"); i_match = rb_intern("match"); + i_keys = rb_intern("keys"); + i_dup = rb_intern("dup"); #ifdef HAVE_RUBY_ENCODING_H CEncoding_UTF_8 = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-8")); i_encoding = rb_intern("encoding"); -- cgit v1.2.1