-
Type: Improvement
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:ubuntu 9.10 64 bit rubinius 1.0 rc2
mongo_ext doesn"t compile on rubinius because it uses the RBASIC macro
This is the error message when compiling:
$ gem install mongo_ext
Building native extensions. This could take a while...
ERROR: Error installing mongo_ext:
ERROR: Failed to build gem native extension.
/Users/mseeger/.rvm/rubies/rbx-1.0.0-rc2/bin/rbx extconf.rb
checking for asprintf()... yes
checking for ruby/st.h... yes
checking for ruby/regex.h... yes
checking for ruby/encoding.h... no
creating Makefile
make
gcc -I. -I. -I/Users/mseeger/.rvm/rubies/rbx-1.0.0-rc2/include -I. -DHAVE_ASPRINTF -DHAVE_RUBY_ST_H -DHAVE_RUBY_REGEX_H -ggdb3 -O2 -c buffer.c
gcc -I. -I. -I/Users/mseeger/.rvm/rubies/rbx-1.0.0-rc2/include -I. -DHAVE_ASPRINTF -DHAVE_RUBY_ST_H -DHAVE_RUBY_REGEX_H -ggdb3 -O2 -c cbson.c
cbson.c: In function 'write_element':
cbson.c:278: error: invalid type argument of '->'
cbson.c:322: error: invalid type argument of '->'
cbson.c:400: error: invalid type argument of '->'
cbson.c:419: error: invalid type argument of '->'
cbson.c:419: error: invalid type argument of '->'
cbson.c:420: error: invalid type argument of '->'
cbson.c:455: error: invalid type argument of '->'
cbson.c: In function 'write_doc':
cbson.c:498: error: invalid type argument of '->'
cbson.c:515: error: invalid type argument of '->'
make: *** [cbson.o] Error 1
This is what Rubinius says:
*
- Rules for better ruby C extensions:
* - Never use the R<TYPE> macros directly, always use R<TYPE>_<FIELD>
* - Never compare with RBASIC(obj)->klass, always use
- rb_obj_is_instance_of()
* - Never use RHASH(obj)->tbl or RHASH_TBL().
*
*/
quoting #mongodb:
[09:37am cremes: rubinius supports most of the "safe" portions of the c api; anything that directly accesses memory is disallowed
[09:37am] cremes: they also support FFI which is really the direction most extensions should be going; where FFI doesn't work then it should be enhanced
[09:38am] cremes: ah, found something in the rubinius source; they don't allow RBASIC; check here: http://gist.github.com/335225
[09:37am] cremes: basically, change RBASIC to rb_obj_is_instance_of()