Project

General

Profile

« Previous | Next » 

Revision 8c9a453f

Added by yugui (Yuki Sonoda) almost 13 years ago

Embedding CRuby interpreter without internal headers has been difficult
for few years because:

  • NODE is no longer accessible.
  • rb_iseq_eval_main crashes without preparing with rb_thread_t.
  • some existing APIs calls exit(3) without giving the opportunity to
    finalize or handle errors to the client.
  • No general-purpose function to compile a source to an iseq are
    published in the public headers.

This commit solves the problems.

    * include/ruby/ruby.h: Grouped APIs for embedding CRuby interpreter.
      (ruby_setup, ruby_compile_main_from_file,
      ruby_compile_main_from_string, ruby_eval_main,
      ruby_set_script_name): new APIs to embed CRuby.
      (ruby_opaque_t) Opaque pointer to an internal data, to NODE or iseq
      in particular.

    * eval.c (ruby_setup): Similar to ruby_init but returns an error code
      instead of exit(3) on error.
      (ruby_eval_main): Similar to ruby_exec_node but returns the
      evaluation result.
      (ruby_eval_main_internal): renamed from ruby_exec_internal.

    * ruby.c (toplevel_context): new helper function.
      (PREPARE_EVAL_MAIN): moved.
      (process_options): refactored with new functions.
      (parse_and_compile_main) new helper funciton.
      (ruby_compile_main_from_file, ruby_compile_main_from_string) new API
      (ruby_set_script_name): new API.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e