Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
Macros | Functions
ruby(1) implementation

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

Macros

#define RUBY_INIT_STACK
 A convenience macro to call ruby_init_stack(). More...
 

Functions

void ruby_sysinit (int *argc, char ***argv)
 Initializes the process for libruby. More...
 
void ruby_init (void)
 Calls ruby_setup() and check error. More...
 
void * ruby_options (int argc, char **argv)
 Processes command line arguments and compiles the Ruby source to execute. More...
 
int ruby_executable_node (void *n, int *status)
 Checks the return value of ruby_options(). More...
 
int ruby_run_node (void *n)
 Runs the given compiled source and exits this process. More...
 
void ruby_show_version (void)
 Prints the version information of the CRuby interpreter to stdout. More...
 
void ruby_show_copyright (void)
 Prints the copyright notice of the CRuby interpreter to stdout. More...
 

Detailed Description

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

Other programs that embed Ruby interpreter do not always need to use these functions.

Macro Definition Documentation

◆ RUBY_INIT_STACK

#define RUBY_INIT_STACK
Value:
VALUE variable_in_this_stack_frame; \
ruby_init_stack(&variable_in_this_stack_frame);
unsigned long VALUE
Definition: value.h:38

A convenience macro to call ruby_init_stack().

Must be placed just after variable declarations

Definition at line 59 of file interpreter.h.

Function Documentation

◆ ruby_executable_node()

int ruby_executable_node ( void *  n,
int status 
)

Checks the return value of ruby_options().

Parameters
nreturn value of ruby_options().
statuspointer to the exit status of this process.

ruby_options() sometimes returns a special value to indicate this process should immediately exit. This function checks if the case. Also stores the exit status that the caller have to pass to exit(3) into *status.

Return values
non-zeroif the given opaque pointer is actually a compiled source.
0if the given value is such a special value.

Definition at line 345 of file eval.c.

References EXIT_FAILURE, EXIT_SUCCESS, FALSE, FIX2INT, FIXNUM_P, Qfalse, Qtrue, and TRUE.

Referenced by ruby_run_node().

◆ ruby_init()

void ruby_init ( void  )

Calls ruby_setup() and check error.

Prints errors and calls exit(3) if an error occurred.

Definition at line 108 of file eval.c.

References EXIT_FAILURE, RTEST, ruby_debug, and ruby_setup().

Referenced by main().

◆ ruby_options()

void * ruby_options ( int  argc,
char **  argv 
)

Processes command line arguments and compiles the Ruby source to execute.

This function does:

  • Processes the given command line flags and arguments for ruby(1)
  • compiles the source code from the given argument, -e or stdin, and
  • returns the compiled source as an opaque pointer to an internal data structure
Returns
an opaque pointer to the compiled source or an internal special value.
See also
ruby_executable_node().

Definition at line 129 of file eval.c.

References argc, argv, EC_EXEC_TAG, EC_POP_TAG, EC_PUSH_TAG, INT2FIX, rb_ec_clear_current_thread_trace_func(), ruby_init_stack(), ruby_process_options(), SAVE_ROOT_JMPBUF, and TAG_NONE.

◆ ruby_run_node()

int ruby_run_node ( void *  n)

Runs the given compiled source and exits this process.

Return values
0if successfully run the source
non-zeroif an error occurred.

Definition at line 366 of file eval.c.

References ruby_executable_node(), and ruby_init_stack().

◆ ruby_show_copyright()

void ruby_show_copyright ( void  )

Prints the copyright notice of the CRuby interpreter to stdout.

Definition at line 138 of file version.c.

References PRINT.

◆ ruby_show_version()

void ruby_show_version ( void  )

Prints the version information of the CRuby interpreter to stdout.

Definition at line 119 of file version.c.

References MJIT_OPTS_ON, and PRINT.

◆ ruby_sysinit()

void ruby_sysinit ( int argc,
char ***  argv 
)

Initializes the process for libruby.

This function assumes this process is ruby(1) and it has just started. Usually programs that embed CRuby interpreter may not call this function, and may do their own initialization. argc and argv cannot be NULL.

Definition at line 2655 of file ruby.c.

References argc, argv, and rb_w32_sysinit().

Referenced by main().