[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Embedding 1.9

Yukihiro Matsumoto

1/8/2008 3:37:00 AM

Hi,

In message "Re: Embedding 1.9"
on Tue, 8 Jan 2008 06:44:08 +0900, Dave Thomas <dave@pragprog.com> writes:

|Folks:
|
|I'm working on the "Extending Ruby" chapter (now an appendix) for the
|third PickAxe, and I'm finding a whole bunch of conflicting
|information. Reading the source, it seems like there's no canonical
|way of embedding Ruby in a C application. I have lots of alternatives
|that _seem_ to work, but I want to be more authoritative than that.
|
|Does anyone have any pointers to stuff that would help?

Perhaps "authoritative" means "information from the original author"
but I don't remember I wrote such document (sigh).

Basically, you have to call:

ruby_sysinit() for command line argument initialization (optional)
RUBY_INIT_STACK() for GC stack initialization
ruby_init() for ruby interpreter initialization

and wrap ruby calls with rb_protect() for initialize exception frame.
You can load Ruby programs with rb_load(). You can call ruby programs
from string via rb_eval_string().

matz.

2 Answers

Dave Thomas

1/8/2008 4:22:00 AM

0


On Jan 7, 2008, at 9:36 PM, Yukihiro Matsumoto wrote:

>
> Perhaps "authoritative" means "information from the original author"
> but I don't remember I wrote such document (sigh).
>
> Basically, you have to call:
>
> ruby_sysinit() for command line argument initialization (optional)
> RUBY_INIT_STACK() for GC stack initialization
> ruby_init() for ruby interpreter initialization
>
> and wrap ruby calls with rb_protect() for initialize exception frame.
> You can load Ruby programs with rb_load(). You can call ruby programs
> from string via rb_eval_string().


In 1.9, do we also now need to call set_locale()?


Dave

Edwin Pratomo

1/9/2008 9:46:00 AM

0

On Tuesday 08 January 2008 10:36:56 am Yukihiro Matsumoto wrote:
>
> Basically, you have to call:
>
> ruby_sysinit() for command line argument initialization (optional)
> RUBY_INIT_STACK() for GC stack initialization
> ruby_init() for ruby interpreter initialization
>
> and wrap ruby calls with rb_protect() for initialize exception frame.
> You can load Ruby programs with rb_load(). You can call ruby programs
> from string via rb_eval_string().
>
> matz.

good day all,

while it's still hot talking about embedding, let me ask a related question
here: is there any way to do reflection from ruby C API?

rgds,
Edwin.