Skip to content

Instantly share code, notes, and snippets.

@ferrous26
Created June 13, 2011 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ferrous26/66da73fa9f138ff49882 to your computer and use it in GitHub Desktop.
Save ferrous26/66da73fa9f138ff49882 to your computer and use it in GitHub Desktop.
MacRuby issue with nested modules that use the names of objective-c classes with the C API
mJSON = rb_define_module("JSON");
rb_define_module_under(mJSON, "NSString");
// TypeError: JSON::NSString:Class is not a module
// This seems to happen because a call to rb_const_defined_at will always resolve NSString
mJSON = rb_define_module("JSON");
rb_define_module_under(mJSON, "String");
// This will work, and is a reduction of how json is coded right
module JSON
module NSString
end
end
p JSON::NSString.class
p JSON::NSString::NSString.class
# this works as expected, and is how json/pure is patched (changed module from String to NSString)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment