Permalink
Browse files

Fix #1313 with a little redirection

  • Loading branch information...
1 parent f04df77 commit 3809805cfe11db21d96fca60b06f62f11e2d2b30 @ferrous26 ferrous26 committed Jun 23, 2011
Showing with 12 additions and 5 deletions.
  1. +3 −4 ext/json/generator/generator.c
  2. +9 −1 ext/json/lib/json/common.rb
@@ -1375,10 +1375,9 @@ void Init_generator()
rb_define_method(cState, "generate", cState_generate, 1);
mGeneratorMethods = rb_define_module_under(mGenerator, "GeneratorMethods");
- // TODO : TypeError occurs when require 'json'
- // "JSON::Ext::Generator::GeneratorMethods::Class is not a module (TypeError)"
- //mObject = rb_define_module_under(mGeneratorMethods, "Object");
- //rb_define_method(mObject, "to_json", mObject_to_json, -1);
+ // XXX MACRUBY Change Object ot LOLObject until ticket #1326 is resolved
+ mObject = rb_define_module_under(mGeneratorMethods, "JSONObject");
+ rb_define_method(mObject, "to_json", mObject_to_json, -1);
mHash = rb_define_module_under(mGeneratorMethods, "Hash");
rb_define_method(mHash, "to_json", mHash_to_json, -1);
mArray = rb_define_module_under(mGeneratorMethods, "Array");
@@ -52,7 +52,15 @@ def generator=(generator) # :nodoc:
@generator = generator
generator_methods = generator::GeneratorMethods
for const in generator_methods.constants
- klass = deep_const_get(const)
+ # XXX MACRUBY Hijack const to mix into Cocoa classes instead
+ real_const = case const
+ when :Array then :NSArray
+ when :Hash then :NSDictionary
+ when :String then :NSString
+ when :JSONObject then :Object
+ else const
+ end
+ klass = deep_const_get(real_const)
modul = generator_methods.const_get(const)
klass.class_eval do
instance_methods(false).each do |m|

0 comments on commit 3809805

Please sign in to comment.