ruby display “./b.rb”, at the beginning of the line, because it has called
ruby_script(“./b.rb”)
Weird… I don’t see any “embed” in my backtraces?
./a.out -e ‘puts “hello”; raise “out”’
hello
-e:1: out (RuntimeError)
less main.cpp #include <ruby.h>
int main(int argc, char *argv) {
ruby_init();
ruby_init_loadpath();
ruby_script(“embed”); // seems not to have any effect ?
ruby_options(argc, argv);
ruby_run();
}
When you are doing embedding are you then supposed to
call ruby_script() ?
When ruby compile a script (or a string) it store in each node the name of
the file and the line number. These are these values that it display when it
print an error.
Because you have used -e the string 'puts "hello"; raise "out"' was
compiled with the name '-e' and when it display the error it use this
name.
I think I got that… But what Im not understanding is
when you are doing rb_require() that “embed” is not written out?
Is’nt “embed” supposed to be outputted in the backtrace?
···
On Sun, 13 Apr 2003 23:46:40 +0900, ts wrote:
./a.out -e ‘puts “hello”; raise “out”’
When ruby compile a script (or a string) it store in each node the name of
the file and the line number. These are these values that it display when it
print an error.
Because you have used -e the string ‘puts “hello”; raise “out”’ was
compiled with the name ‘-e’ and when it display the error it use this
name.
Is’nt “embed” supposed to be outputted in the backtrace?
The backtrace are outputted for each frame created, when you write
[snip]
ruby create a frame only for rb_require() (rb_laod(), none of the
commands ruby_init(), ruby_init_loadpath(), rb_protect() create a frame.
I see… only rb_require(). BTW what is a frame?
Im writing a tutorial on embedding. The section on “initialization”.
What should I write: use ruby_script() it does something ? http://metaeditor.sourceforge.net/embed/
I tried rb_load() … but I don’t see “embed” in the backtrace, why ?
./a.out
hello
from ./test.rb:2
ERROR #<RuntimeError: out>
cat main.cpp #include <ruby.h> #include
using namespace std;
VALUE myfunc(VALUE) {
//rb_require(“test.rb”, 0);
rb_load(rb_str_new2(“test.rb”), Qtrue); // no “embed” backtrace?
return Qnil;
}
-------------------- Start SpamAssassin results ----------------------
This mail is probably spam. The original message has been altered
so you can recognise or block similar unwanted mail in future.
See Apache SpamAssassin: Welcome for more details.
I must take care : SpamAssassin think that you are a spammer :-)))
I see… only rb_require(). BTW what is a frame?
Well, it’s the internal of ruby : not important
I tried rb_load() … but I don’t see “embed” in the backtrace, why ?
rb_load() is what ruby call when you make a rb_require() on a script file
(not a dynamic library).
This is rb_load() which create the frame : because ruby has a frame it
display the backtrace only for these frames. Your program has never
created a frame (except for rb_load()) this is why ruby don’t display its
name
-------------------- Start SpamAssassin results ----------------------
This mail is probably spam. The original message has been altered
so you can recognise or block similar unwanted mail in future.
See Apache SpamAssassin: Welcome for more details.
I must take care : SpamAssassin think that you are a spammer :-)))
Exactly… I’ve converted to the dark side and im very dangerous!!
I see… only rb_require(). BTW what is a frame?
[snip ruby-internals]
Thanks (ts, nobu) for your efforts.
Im not that much confused any longer
Still I don’t know what to write in that tutorial about initialization ???
Suggestions is welcome