Embedded Ruby

R

Rolando Abarca

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,
 
J

Jeremy Hinegardner

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?

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
 
R

Rolando Abarca

nevermind, rb_eval_string suits my needs :p

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,

regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top