Ruby  2.0.0p247(2013-06-27revision41674)
Data Structures | Defines | Enumerations | Functions | Variables
load.c File Reference
#include "ruby/ruby.h"
#include "ruby/util.h"
#include "internal.h"
#include "dln.h"
#include "eval_intern.h"
#include "probes.h"

Go to the source code of this file.

Data Structures

struct  loaded_feature_searching

Defines

#define numberof(array)   (int)(sizeof(array) / sizeof((array)[0]))
#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))

Enumerations

enum  expand_type { EXPAND_ALL, EXPAND_RELATIVE, EXPAND_HOME, EXPAND_NON_CACHE }

Functions

VALUE rb_get_load_path (void)
static void rb_construct_expanded_load_path (int type, int *has_relative, int *has_non_cache)
static VALUE load_path_getcwd (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 void reset_loaded_features_snapshot (void)
static struct st_tableget_loaded_features_index_raw (void)
static st_tableget_loading_table (void)
static void features_index_add_single (VALUE short_feature, VALUE offset)
static void features_index_add (VALUE feature, VALUE offset)
static int loaded_features_index_clear_i (st_data_t key, st_data_t val, st_data_t arg)
static st_tableget_loaded_features_index (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 int release_thread_shield (st_data_t *key, st_data_t *value, st_data_t done, int existing)
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 []

Define Documentation

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

Definition at line 21 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 16 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 17 of file load.c.

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

#define numberof (   array)    (int)(sizeof(array) / sizeof((array)[0]))

Definition at line 14 of file load.c.

Referenced by features_index_add_single().

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

Enumeration Type Documentation

Enumerator:
EXPAND_ALL 
EXPAND_RELATIVE 
EXPAND_HOME 
EXPAND_NON_CACHE 

Definition at line 39 of file load.c.


Function Documentation

static void features_index_add ( VALUE  feature,
VALUE  offset 
) [static]
static void features_index_add_single ( VALUE  short_feature,
VALUE  offset 
) [static]
static VALUE get_loaded_features ( void  ) [static]

Definition at line 162 of file load.c.

References GET_VM.

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

static st_table* get_loaded_features_index ( void  ) [static]
static struct st_table* get_loaded_features_index_raw ( void  ) [static, read]

Definition at line 175 of file load.c.

References GET_VM.

Referenced by features_index_add_single().

static st_table* get_loading_table ( void  ) [static]

Definition at line 181 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 1005 of file load.c.

References NOEX_PUBLIC, Qnil, and SCOPE_SET.

Referenced by ruby_init_ext().

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

Definition at line 904 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]

Definition at line 898 of file load.c.

References rb_load_fail().

Referenced by rb_f_load(), rb_load(), and rb_require_safe().

static char* load_lock ( const char *  ftptr) [static]
static VALUE load_path_getcwd ( void  ) [static]

Definition at line 101 of file load.c.

References my_getcwd, rb_filesystem_str_new_cstr(), and xfree().

Referenced by rb_get_expanded_load_path().

static VALUE load_path_getter ( ID  id,
rb_vm_t vm 
) [static]

Definition at line 156 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 738 of file load.c.

References get_loading_table(), key, release_thread_shield(), and st_update().

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 309 of file load.c.

References IS_DLEXT, IS_RBEXT, 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]
static int loaded_features_index_clear_i ( st_data_t  key,
st_data_t  val,
st_data_t  arg 
) [static]

Definition at line 265 of file load.c.

References ST_DELETE, and xfree().

Referenced by get_loaded_features_index().

NORETURN ( static void   load_failedVALUE)
static void rb_construct_expanded_load_path ( int  type,
int *  has_relative,
int *  has_non_cache 
) [static]
static VALUE rb_f_autoload ( VALUE  obj,
VALUE  sym,
VALUE  file 
) [static]

Definition at line 1083 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 1104 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 786 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_load_path ( void  )

Definition at line 33 of file load.c.

References GET_VM.

void rb_load ( VALUE  fname,
int  wrap 
)

Definition at line 626 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 634 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 1039 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 1062 of file load.c.

References Qnil, rb_autoload_p(), and rb_check_id().

Referenced by Init_load(), and rb_f_autoload_p().

void rb_provide ( const char *  feature)

Definition at line 554 of file load.c.

References rb_provide_feature(), and rb_usascii_str_new2().

Referenced by InitVM_Enumerator(), and ruby_init_ext().

static void rb_provide_feature ( VALUE  feature) [static]
int rb_provided ( const char *  feature)

Definition at line 505 of file load.c.

References rb_feature_provided().

VALUE rb_require ( const char *  fname)
VALUE rb_require_safe ( VALUE  fname,
int  safe 
)
static int release_thread_shield ( st_data_t key,
st_data_t value,
st_data_t  done,
int  existing 
) [static]

Definition at line 725 of file load.c.

References rb_thread_shield_destroy(), rb_thread_shield_release(), ST_CONTINUE, ST_DELETE, ST_STOP, and xfree().

Referenced by load_unlock().

static void reset_loaded_features_snapshot ( void  ) [static]
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 24 of file load.c.

Referenced by rb_feature_p(), and search_required().

Definition at line 12 of file load.c.

Referenced by Init_load(), and rb_require_safe().