J
James Masters
Hi all,
I am wrapping a C++ API using SWIG for Ruby and in some cases strings
need to be allocated and passed to the wrapped function where the
value of the string itself will need to be modified within the C/C++
code generated by SWIG. Specifically, I need the String#object_id to
stay the same and just have the contents change.
How can I do this with the Ruby C API? I looked at rb_str_replace in
string.c; however, that is not a public function in the C API. After
searching I found a few postings on this topic, I found that
rb_funcall could be initiated but this seems to add some overhead
which affects performance.
I'm really just looking for a way to take a Ruby string VALUE and
replace the contents of that object with a C string in the most
efficient method possible. Can someone help me in doing this or at
least point me in the right direction?
Thanks,
-James
I am wrapping a C++ API using SWIG for Ruby and in some cases strings
need to be allocated and passed to the wrapped function where the
value of the string itself will need to be modified within the C/C++
code generated by SWIG. Specifically, I need the String#object_id to
stay the same and just have the contents change.
How can I do this with the Ruby C API? I looked at rb_str_replace in
string.c; however, that is not a public function in the C API. After
searching I found a few postings on this topic, I found that
rb_funcall could be initiated but this seems to add some overhead
which affects performance.
I'm really just looking for a way to take a Ruby string VALUE and
replace the contents of that object with a C string in the most
efficient method possible. Can someone help me in doing this or at
least point me in the right direction?
Thanks,
-James