From: Yoshiki Tsunesada Date: 2005-01-28T01:04:50+09:00 Subject: Re: How to correctly create ruby objects from C extensions. On Thu, 27 Jan 2005 23:52:48 +0900, Brian Schr�der wrote: > Hello Group, > > I'm asking myself what is the way to create a ruby object correctly from > a C extension. As I've extracted from ruby.h and README.EXT the things I > can come up with are: See for example http://www.ruby-doc.org/doxygen/1.8.1/index.html > rb_eval_string(constructing_string) > // Which is ugly because of eval and because of C string functions. To get char* pointer from Ruby string, char *p; p = StringValuePtr(rubyString); To create Ruby string from C string, return rb_str_new( (char pointer), (length)); or return rb_str_new2("a string"); or with rb_str_new3(), 4(), 5() and other functions.