Hi. Having googled extensively, I understand that I can host a Ruby
environment in C using the ruby_init(), ruby_run() and ruby_finalize()
calls.
The problem I’m having concerns injecting the actual code. It would
appear that I can provide a .rb file using rb_load_file(), or a single
line of code using rb_eval_string(). What I want to do, however, is
provide a whole script as a string.
Presumably rb_eval_string() wouldn’t accept a whole script at once? And
I don’t want to write a temporary file. Maybe I could call
rb_eval_string() once with each line of the script…would the
variables and such persist across multiple calls?
I’d prefer to pass the entire script all at once, if possible.
FYI, the purpose of all this is to essentially compile a script, by
appending said script to the end of a simple C executable, which reads
the script out of its own backside and executes it from memory.
C is pretty much the most well-known programming language in the world.
Some coders might not like using it, but they should still know how it’s
done. Like me and Java: Java is a godawfully bad language, but you still
need a vague understanding of it.
Thanks, I’ll try Stack Overflow.
Robert H. wrote in post #1178823:
S. B. wrote in post #1178453:
Well? Nobody’s had any idea how to solve this in three damn months?
Not everyone knows C.
Additionally old threads/mails quickly phase away.
You could give stackoverflow a try, their system is usually better in
the long run due to archiving + karma/upvotes.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.