Ruby  2.5.0dev(2017-10-22revision60238)
Modules | Macros | Functions
CRuby Embedding APIs

CRuby interpreter APIs. More...

Modules

 ruby(1) implementation
 A part of the implementation of ruby(1) command.
 

Macros

#define Init_stack(addr)   ruby_init_stack(addr)
 

Functions

void ruby_init_stack (volatile VALUE *)
 
int ruby_setup (void)
 Initializes the Ruby VM and builtin libraries. More...
 
int ruby_cleanup (volatile int)
 Destructs the VM. More...
 
void ruby_finalize (void)
 Runs the VM finalization processes. More...
 
 NORETURN (void rb_exit(int))
 
void ruby_set_stack_size (size_t)
 
int ruby_stack_check (void)
 
size_t ruby_stack_length (VALUE **)
 
int ruby_exec_node (void *n)
 Runs the given compiled source. More...
 
void ruby_script (const char *name)
 Sets the current script name to this value. More...
 
void ruby_set_script_name (VALUE name)
 Sets the current script name to this value. More...
 
void ruby_prog_init (void)
 Defines built-in variables. More...
 
void ruby_set_argv (int, char **)
 
void * ruby_process_options (int, char **)
 
void ruby_init_loadpath (void)
 
void ruby_incpush (const char *)
 
void ruby_sig_finalize (void)
 

Detailed Description

CRuby interpreter APIs.

These are APIs to embed MRI interpreter into your program. These functions are not a part of Ruby extension library API. Extension libraries of Ruby should not depend on these functions.

Macro Definition Documentation

◆ Init_stack

#define Init_stack (   addr)    ruby_init_stack(addr)

Definition at line 2513 of file ruby.h.

Function Documentation

◆ NORETURN()

NORETURN ( void   rb_exitint)

◆ ruby_cleanup()

int ruby_cleanup ( volatile int  ex)

Destructs the VM.

Runs the VM finalization processes as well as ruby_finalize(), and frees resources used by the VM.

Parameters
exDefault value to the return value.
Returns
If an error occurred returns a non-zero. If otherwise, returns the given ex.
Note
This function does not raise any exception.

Definition at line 161 of file eval.c.

References rb_thread_struct::ec, rb_execution_context_struct::errinfo, EXEC_TAG, EXIT_SUCCESS, GET_THREAD, rb_threadptr_check_signal(), rb_threadptr_interrupt(), ruby_init_stack(), RUBY_VM_CHECK_INTS, rb_execution_context_struct::safe_level, SAVE_ROOT_JMPBUF, STACK_UPPER, TAG_NONE, and TH_PUSH_TAG.

Referenced by PPP_ShutdownModule(), ruby_run_node(), and ruby_stop().

◆ ruby_exec_node()

int ruby_exec_node ( void *  n)

Runs the given compiled source.

Definition at line 307 of file eval.c.

References ruby_init_stack().

Referenced by ruby_run_node().

◆ ruby_finalize()

void ruby_finalize ( void  )

Runs the VM finalization processes.

END{} and procs registered by Kernel.#at_exit are executed here. See the Ruby language spec for more details.

Note
This function is allowed to raise an exception if an error occurred.

Definition at line 144 of file eval.c.

◆ ruby_incpush()

void ruby_incpush ( const char *  )

Definition at line 369 of file ruby.c.

References ruby_push_include().

◆ ruby_init_loadpath()

void ruby_init_loadpath ( void  )

Definition at line 448 of file ruby.c.

References rb_str_new(), and ruby_init_loadpath_safe().

◆ ruby_init_stack()

void ruby_init_stack ( volatile VALUE )

◆ ruby_process_options()

void* ruby_process_options ( int  ,
char **   
)

Definition at line 2236 of file ruby.c.

References load_file_arg::opt, ruby_engine, and ruby_cmdline_options::script_name.

Referenced by ruby_options().

◆ ruby_prog_init()

void ruby_prog_init ( void  )

Defines built-in variables.

Definition at line 2190 of file ruby.c.

References rb_define_hooked_variable(), and ruby_verbose.

Referenced by ruby_setup().

◆ ruby_script()

void ruby_script ( const char *  name)

Sets the current script name to this value.

This is similar to $0 = name in Ruby level but also affects Method::location and others.

Definition at line 2119 of file ruby.c.

References rb_orig_progname, and rb_progname.

◆ ruby_set_argv()

void ruby_set_argv ( int  ,
char **   
)

Definition at line 2215 of file ruby.c.

References rb_argv.

◆ ruby_set_script_name()

void ruby_set_script_name ( VALUE  name)

Sets the current script name to this value.

Same as ruby_script() but accepts a VALUE.

Definition at line 2132 of file ruby.c.

References rb_orig_progname, rb_progname, rb_str_dup(), and rb_vm_set_progname().

◆ ruby_set_stack_size()

void ruby_set_stack_size ( size_t  )

◆ ruby_setup()

int ruby_setup ( void  )

Initializes the Ruby VM and builtin libraries.

Return values
0if succeeded.
non-zeroan error occurred.

Definition at line 47 of file eval.c.

References EXEC_TAG, GET_VM, Init_BareVM(), Init_heap(), Init_vm_objects(), POP_TAG, PUSH_TAG, rb_call_inits(), ruby_init_stack(), ruby_prog_init(), and TAG_NONE.

Referenced by ruby_init().

◆ ruby_sig_finalize()

void ruby_sig_finalize ( void  )

Definition at line 1438 of file signal.c.

References ruby_signal, sighandler_t, and SIGINT.

◆ ruby_stack_check()

int ruby_stack_check ( void  )

Definition at line 4053 of file gc.c.

◆ ruby_stack_length()

size_t ruby_stack_length ( VALUE **  )

Definition at line 4008 of file gc.c.

References GET_THREAD, SET_STACK_END, STACK_END, STACK_LENGTH, STACK_START, and STACK_UPPER.