From: Marvin Gülker on 4 Jun 2010 17:24 Tim Pease wrote: > On Jun 4, 2010, at 9:19 AM, Tim Pease wrote: > >>>> VALUE eval _((VALUE,VALUE,VALUE,const char*,int)); >> > On second thought, use the rb_funcall method ... > > rb_funcall(rb_mKernel, rb_intern("eval"), ... ) > > That should do what you are trying to accomplish. > > Blessings, > TwP Why not directly use rb_eval_string? From the README.EXT from 1.9.1-p378: -------------------------------------------------- 2.2.1 Evaluate Ruby Programs in a String The easiest way to use Ruby's functionality from a C program is to evaluate the string as Ruby program. This function will do the job: VALUE rb_eval_string(const char *str) Evaluation is done under the current context, thus current local variables of the innermost method (which is defined by Ruby) can be accessed. Note that the evaluation can raise an exception. There is a safer function: VALUE rb_eval_string_protect(const char *str, int *state) It returns nil when an error occur. And *state is zero if str was successfully evaluated, or nonzero otherwise. Marvin -- Posted via http://www.ruby-forum.com/.
|
Pages: 1 Prev: Ruby Mendicant University Next: Broken pipe (Errno::EPIPE) |