Ruby  1.9.3p429(2013-05-15revision40747)
Data Structures | Macros | Functions | Variables
load.c File Reference
#include "ruby/ruby.h"
#include "ruby/util.h"
#include "internal.h"
#include "dln.h"
#include "eval_intern.h"

Go to the source code of this file.

Data Structures

struct  loaded_feature_searching
 

Macros

#define IS_RBEXT(e)   (strcmp((e), ".rb") == 0)
 
#define IS_SOEXT(e)   (strcmp((e), ".so") == 0 || strcmp((e), ".o") == 0)
 
#define IS_DLEXT(e)   (strcmp((e), DLEXT) == 0)
 
#define rb_intern(str)   rb_intern2((str), strlen(str))
 

Functions

VALUE rb_get_load_path (void)
 
VALUE rb_get_expanded_load_path (void)
 
static VALUE load_path_getter (ID id, rb_vm_t *vm)
 
static VALUE get_loaded_features (void)
 
static st_tableget_loading_table (void)
 
static VALUE loaded_feature_path (const char *name, long vlen, const char *feature, long len, int type, VALUE load_path)
 
static int loaded_feature_path_i (st_data_t v, st_data_t b, st_data_t f)
 
static int rb_feature_p (const char *feature, const char *ext, int rb, int expanded, const char **fn)
 
int rb_provided (const char *feature)
 
int rb_feature_provided (const char *feature, const char **loading)
 
static void rb_provide_feature (VALUE feature)
 
void rb_provide (const char *feature)
 
 NORETURN (static void load_failed(VALUE))
 
static void rb_load_internal (VALUE fname, int wrap)
 
void rb_load (VALUE fname, int wrap)
 
void rb_load_protect (VALUE fname, int wrap, int *state)
 
static VALUE rb_f_load (int argc, VALUE *argv)
 
static char * load_lock (const char *ftptr)
 
static void load_unlock (const char *ftptr, int done)
 
VALUE rb_f_require (VALUE obj, VALUE fname)
 
VALUE rb_f_require_relative (VALUE obj, VALUE fname)
 
static int search_required (VALUE fname, volatile VALUE *path, int safe_level)
 
static void load_failed (VALUE fname)
 
static VALUE load_ext (VALUE path)
 
VALUE rb_require_safe (VALUE fname, int safe)
 
VALUE rb_require (const char *fname)
 
static VALUE init_ext_call (VALUE arg)
 
RUBY_FUNC_EXPORTED void ruby_init_ext (const char *name, void(*init)(void))
 
static VALUE rb_mod_autoload (VALUE mod, VALUE sym, VALUE file)
 
static VALUE rb_mod_autoload_p (VALUE mod, VALUE sym)
 
static VALUE rb_f_autoload (VALUE obj, VALUE sym, VALUE file)
 
static VALUE rb_f_autoload_p (VALUE obj, VALUE sym)
 
void Init_load ()
 

Variables

VALUE ruby_dln_librefs
 
static const char *const loadable_ext []
 

Macro Definition Documentation

#define IS_DLEXT (   e)    (strcmp((e), DLEXT) == 0)

Definition at line 18 of file load.c.

Referenced by loaded_feature_path(), rb_feature_p(), rb_feature_provided(), and search_required().

#define IS_RBEXT (   e)    (strcmp((e), ".rb") == 0)

Definition at line 13 of file load.c.

Referenced by loaded_feature_path(), rb_feature_p(), rb_feature_provided(), and search_required().

#define IS_SOEXT (   e)    (strcmp((e), ".so") == 0 || strcmp((e), ".o") == 0)

Definition at line 14 of file load.c.

Referenced by rb_feature_p(), rb_feature_provided(), and search_required().

#define rb_intern (   str)    rb_intern2((str), strlen(str))

Function Documentation

static VALUE get_loaded_features ( void  )
static

Definition at line 61 of file load.c.

References GET_VM.

Referenced by Init_load(), rb_feature_p(), and rb_provide_feature().

static st_table* get_loading_table ( void  )
static

Definition at line 67 of file load.c.

References GET_VM.

Referenced by load_lock(), load_unlock(), and rb_feature_p().

static VALUE init_ext_call ( VALUE  arg)
static

Definition at line 660 of file load.c.

References arg, NOEX_PUBLIC, Qnil, and SCOPE_SET.

Referenced by ruby_init_ext().

void Init_load ( )
static VALUE load_ext ( VALUE  path)
static

Definition at line 584 of file load.c.

References dln_load(), NOEX_PUBLIC, RSTRING_PTR, and SCOPE_SET.

Referenced by rb_require_safe().

static void load_failed ( VALUE  fname)
static
static char* load_lock ( const char *  ftptr)
static
static VALUE load_path_getter ( ID  id,
rb_vm_t vm 
)
static

Definition at line 55 of file load.c.

References rb_vm_struct::load_path.

Referenced by Init_load().

static void load_unlock ( const char *  ftptr,
int  done 
)
static

Definition at line 413 of file load.c.

References get_loading_table(), key, rb_barrier_destroy(), rb_barrier_release(), st_delete, and xfree().

Referenced by rb_require_safe(), and ruby_init_ext().

static VALUE loaded_feature_path ( const char *  name,
long  vlen,
const char *  feature,
long  len,
int  type,
VALUE  load_path 
)
static

Definition at line 73 of file load.c.

References i, IS_DLEXT, IS_RBEXT, p, RARRAY_LEN, RARRAY_PTR, RSTRING_LEN, and StringValuePtr.

Referenced by loaded_feature_path_i(), and rb_feature_p().

static int loaded_feature_path_i ( st_data_t  v,
st_data_t  b,
st_data_t  f 
)
static
NORETURN ( static void   load_failedVALUE)
static VALUE rb_f_autoload ( VALUE  obj,
VALUE  sym,
VALUE  file 
)
static

Definition at line 733 of file load.c.

References NIL_P, rb_class_real(), rb_eTypeError, rb_mod_autoload(), rb_raise(), and rb_vm_cbase().

Referenced by Init_load().

static VALUE rb_f_autoload_p ( VALUE  obj,
VALUE  sym 
)
static

Definition at line 754 of file load.c.

References NIL_P, Qnil, rb_mod_autoload_p(), and rb_vm_cbase().

Referenced by Init_load().

static VALUE rb_f_load ( int  argc,
VALUE argv 
)
static
VALUE rb_f_require ( VALUE  obj,
VALUE  fname 
)

Definition at line 464 of file load.c.

References rb_require_safe(), and rb_safe_level.

Referenced by Init_load().

VALUE rb_f_require_relative ( VALUE  obj,
VALUE  fname 
)
static int rb_feature_p ( const char *  feature,
const char *  ext,
int  rb,
int  expanded,
const char **  fn 
)
static
int rb_feature_provided ( const char *  feature,
const char **  loading 
)
VALUE rb_get_expanded_load_path ( void  )
VALUE rb_get_load_path ( void  )

Definition at line 31 of file load.c.

References GET_VM.

Referenced by rb_feature_p(), rb_find_file_ext_safe(), rb_find_file_safe(), and rb_get_expanded_load_path().

void rb_load ( VALUE  fname,
int  wrap 
)

Definition at line 337 of file load.c.

References FilePathValue, load_failed(), rb_find_file(), and rb_load_internal().

Referenced by rb_load_protect().

static void rb_load_internal ( VALUE  fname,
int  wrap 
)
static
void rb_load_protect ( VALUE  fname,
int  wrap,
int *  state 
)

Definition at line 345 of file load.c.

References EXEC_TAG, POP_TAG, PUSH_TAG, and rb_load().

static VALUE rb_mod_autoload ( VALUE  mod,
VALUE  sym,
VALUE  file 
)
static

Definition at line 693 of file load.c.

References FilePathValue, Qnil, rb_autoload(), rb_to_id(), and RSTRING_PTR.

Referenced by Init_load(), and rb_f_autoload().

static VALUE rb_mod_autoload_p ( VALUE  mod,
VALUE  sym 
)
static

Definition at line 716 of file load.c.

References rb_autoload_p(), and rb_to_id().

Referenced by Init_load(), and rb_f_autoload_p().

void rb_provide ( const char *  feature)

Definition at line 265 of file load.c.

References rb_provide_feature(), and rb_usascii_str_new2().

Referenced by Init_Enumerator(), and ruby_init_ext().

static void rb_provide_feature ( VALUE  feature)
static

Definition at line 255 of file load.c.

References get_loaded_features(), OBJ_FROZEN, rb_ary_push(), rb_eRuntimeError, and rb_raise().

Referenced by rb_provide(), and rb_require_safe().

int rb_provided ( const char *  feature)

Definition at line 223 of file load.c.

References rb_feature_provided().

VALUE rb_require ( const char *  fname)
VALUE rb_require_safe ( VALUE  fname,
int  safe 
)
RUBY_FUNC_EXPORTED void ruby_init_ext ( const char *  name,
void(*)(void)  init 
)
static int search_required ( VALUE  fname,
volatile VALUE path,
int  safe_level 
)
static

Variable Documentation

const char* const loadable_ext[]
static
Initial value:
= {
".rb", DLEXT,
0
}

Definition at line 22 of file load.c.

Referenced by rb_feature_p(), and search_required().

VALUE ruby_dln_librefs

Definition at line 11 of file load.c.

Referenced by Init_load(), and rb_require_safe().