Ruby 2.0.0p353(2013-11-22revision43784)

- Main Page
- Modules
- Data Structures
- Files

Modules | Macros | Functions
CRuby Embedding APIs

CRuby interpreter APIs. More...

Collaboration diagram for CRuby Embedding APIs:

## 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)
int | ruby_cleanup (volatile int)
| Destructs the VM. More...
void | ruby_finalize (void)
| Runs the VM finalization processes. More...
| NORETURN (void ruby_stop(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 extention library API. Extension libraries of Ruby should not depend on these functions.

## Macro Definition Documentation

#define Init_stack | ( |  | addr | ) | ruby_init_stack(addr)

Definition at line 1700 of file ruby.h.

## Function Documentation

NORETURN | ( | void | ruby_stopint | ) |

int ruby_cleanup | ( | volatile int |  | ) |

Destructs the VM.

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

Parameters

  ex | Default value to the return value.

Returns
  If an error occured returns a non-zero. If otherwise, returns the given ex.

Note
  This function does not raise any exception.

Definition at line 155 of file eval.c.

References err, rb_thread_struct::errinfo, error_handle(), ex, EXEC_TAG, EXIT_FAILURE, EXIT_SUCCESS, GET_THREAD(), GET_VM, NUM2INT, numberof, POP_TAG, PUSH_TAG, rb_eSignal, rb_eSystemExit, rb_iv_get(), rb_obj_is_kind_of(), rb_thread_stop_timer_thread(), rb_thread_terminate_all(), rb_threadptr_check_signal(), rb_threadptr_interrupt(), rb_threadptr_unlock_all_locking_mutexes(), RB_TYPE_P, RTEST, ruby_default_signal(), ruby_finalize_0(), ruby_finalize_1(), ruby_init_stack(), RUBY_VM_CHECK_INTS, ruby_vm_destruct(), rb_thread_struct::safe_level, SAVE_ROOT_JMPBUF, STACK_UPPER, state, rb_thread_struct::status, sysexit_status(), T_NODE, th, and THREAD_KILLED.

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

int ruby_exec_node | ( | void * | n | ) |

Runs the given compiled source.

Definition at line 312 of file eval.c.

References ruby_exec_internal(), and ruby_init_stack().

Referenced by ruby_run_node().

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 138 of file eval.c.

References ruby_finalize_0(), and ruby_finalize_1().

Referenced by rb_exit(), and rescue_callback().

void ruby_incpush | ( | const char * |  | ) |

Definition at line 336 of file ruby.c.

References locale_path(), and ruby_push_include().

Referenced by init_loadpath().

void ruby_init_loadpath | ( | void |  | ) |

Definition at line 379 of file ruby.c.

References ruby_init_loadpath_safe().

void ruby_init_stack | ( | volatile VALUE * |  | ) |

Referenced by Init_stack(), ruby_cleanup(), ruby_exec_node(), ruby_options(), and ruby_setup().

void * ruby_process_options | ( | int | ,
|  | char ** |
| ) |  |

Definition at line 1897 of file ruby.c.

References cmdline_options_init(), process_options(), rb_gc_register_mark_object(), rb_progname, rb_str_new4, ruby_script(), and cmdline_options::script_name.

Referenced by ruby_options().

void ruby_prog_init | ( | void |  | ) |

Defines built-in variables.

Definition at line 1853 of file ruby.c.

References opt_W_getter(), rb_argv, rb_define_global_const(), rb_define_hooked_variable(), rb_define_variable(), rb_gvar_readonly_setter(), rb_progname, ruby_debug, ruby_verbose, set_arg0(), and verbose_setter().

Referenced by ruby_setup().

void ruby_script | ( | const char * | name | ) |

Sets the current script name to this value.

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

Definition at line 1782 of file ruby.c.

References rb_external_str_new(), rb_progname, rb_vm_set_progname(), and strlen().

Referenced by ruby_process_options().

void ruby_set_argv | ( | int | ,
|  | char ** |
| ) |  |

Definition at line 1876 of file ruby.c.

References arg, argc, av, i, OBJ_FREEZE, origarg, rb_argv, rb_ary_clear(), rb_ary_push(), and rb_external_str_new_cstr().

Referenced by process_options().

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 1795 of file ruby.c.

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

Referenced by load_file_internal(), and process_options().

void ruby_set_stack_size | ( | size_t |  | ) |

int ruby_setup | ( | void |  | ) |

Definition at line 42 of file eval.c.

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

Referenced by ruby_init().

void ruby_sig_finalize | ( | void |  | ) |

Definition at line 1080 of file signal.c.

References ruby_signal, sighandler(), and SIGINT.

Referenced by ruby_finalize_1().

int ruby_stack_check | ( | void |  | ) |

Definition at line 2307 of file gc.c.

References stack_check(), and STACKFRAME_FOR_CALL_CFUNC.

Referenced by stack_check().

size_t ruby_stack_length | ( | VALUE ** |  | ) |

Definition at line 2278 of file gc.c.

References GET_THREAD(), SET_STACK_END, STACK_END, STACK_LENGTH, STACK_START, STACK_UPPER, and th.