Forum: Ruby Embedded Ruby

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
79caabff3b239b1bee6de8c51bc7f78c?d=identicon&s=25 Rolando Abarca (Guest)
on 2008-12-18 18:54
(Received via mailing list)
Hello all,
I'm trying to embedd ruby, so far this is what I have:

  ruby_init();
  ruby_init_loadpath();
  ruby_script("embedded");
  rb_load_file("my_script.rb");
  ruby_run();
  /* rest of my app here */

However, ruby is taking control of my code after calling ruby_run,
since it will always call "exit" after executing the code... is there
a way to not exit after executing the ruby code?

thanks a lot,
Ae36591847393e58ff189704f5eb18f2?d=identicon&s=25 Jeremy Hinegardner (Guest)
on 2008-12-18 19:10
(Received via mailing list)
On Fri, Dec 19, 2008 at 02:46:12AM +0900, Rolando Abarca wrote:
> However, ruby is taking control of my code after calling ruby_run, since it
> will always call "exit" after executing the code... is there a way to not
> exit after executing the ruby code?
>

This is by design ruby_run() does not return.  I imagine what you want
to do is
execute your script via rb_protect().   You could take a look at
http://metaeditor.sourceforge.net/embed/ althought it is embedding ruby
in C++
much of what it talks about works for C.

How vim embedds ruby is good code to read too.  Download the vim source
code and look at if_ruby.c

enjoy,

-jeremy
79caabff3b239b1bee6de8c51bc7f78c?d=identicon&s=25 Rolando Abarca (Guest)
on 2008-12-18 19:11
(Received via mailing list)
nevermind, rb_eval_string suits my needs :-P

On Dec 18, 2008, at 2:46 PM, Rolando Abarca wrote:

> However, ruby is taking control of my code after calling ruby_run,
> since it will always call "exit" after executing the code... is
> there a way to not exit after executing the ruby code?
>
> thanks a lot,

regards,
This topic is locked and can not be replied to.