Skip to content
Create a gist now

Instantly share code, notes, and snippets.

@ferrous26 /broken.c secret
Created Jun 13, 2011

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
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
Something went wrong with that request. Please try again.