Ruby: load.c File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Data Structures | Macros | Typedefs | Enumerations | Functions
load.c File Reference
`#include "dln.h"`
`#include "eval_intern.h"`
`#include "internal.h"`
`#include "internal/dir.h"`
`#include "internal/error.h"`
`#include "internal/file.h"`
`#include "internal/load.h"`
`#include "internal/parse.h"`
`#include "internal/thread.h"`
`#include "internal/variable.h"`
`#include "iseq.h"`
`#include "probes.h"`
`#include "ruby/encoding.h"`
`#include "ruby/util.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)

## Typedefs
typedef int(* | feature_func) (const char *feature, const char *ext, int rb, int expanded, const char **fn)

## Enumerations
enum | expand_type { EXPAND_ALL , EXPAND_RELATIVE , EXPAND_HOME , EXPAND_NON_CACHE }

## Functions
VALUE | rb_get_expanded_load_path (void)
int | rb_provided (const char *feature)
int | rb_feature_provided (const char *feature, const char **loading)
void | rb_provide (const char *feature)
void | rb_load (VALUE fname, int wrap)
void | rb_load_protect (VALUE fname, int wrap, int *pstate)
VALUE | rb_f_require (VALUE obj, VALUE fname)
VALUE | rb_f_require_relative (VALUE obj, VALUE fname)
VALUE | rb_resolve_feature_path (VALUE klass, VALUE fname)
void | rb_ext_ractor_safe (bool flag)
int | rb_require_internal (VALUE fname)
int | ruby_require_internal (const char *fname, unsigned int len)
VALUE | rb_require_string (VALUE fname)
VALUE | rb_require (const char *fname)
void | ruby_init_ext (const char *name, void(*init)(void))
void | Init_load (void)

## Macro Definition Documentation

## ◆ IS_DLEXT

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

Definition at line 27 of file load.c.

## ◆ IS_RBEXT

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

Definition at line 22 of file load.c.

## ◆ IS_SOEXT

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

Definition at line 23 of file load.c.

## Typedef Documentation

## ◆ feature_func

typedef int(* feature_func) (const char *feature, const char *ext, int rb, int expanded, const char **fn)

Definition at line 904 of file load.c.

## Enumeration Type Documentation

## ◆ expand_type

enum expand_type

Enumerator
EXPAND_ALL |
EXPAND_RELATIVE |
EXPAND_HOME |
EXPAND_NON_CACHE |

Definition at line 43 of file load.c.

## Function Documentation

## ◆ Init_load()

void Init_load | ( | void |  | ) |

Definition at line 1336 of file load.c.

References rb_vm_struct::expanded_load_path, rb_vm_struct::load_path, rb_vm_struct::load_path_check_cache, rb_vm_struct::load_path_snapshot, rb_vm_struct::loaded_features, rb_vm_struct::loaded_features_index, rb_vm_struct::loaded_features_snapshot, rb_alias_variable(), rb_ary_new(), rb_ary_tmp_new(), rb_cModule, rb_define_global_function, ruby::backward::cxxanyargs::rb_define_hooked_variable(), rb_define_method, rb_define_singleton_method, ruby::backward::cxxanyargs::rb_define_virtual_variable(), rb_f_require(), rb_f_require_relative(), rb_gc_register_mark_object(), rb_gvar_readonly_setter, rb_intern2(), rb_resolve_feature_path(), and st_init_numtable.

## ◆ rb_ext_ractor_safe()

void rb_ext_ractor_safe | ( | bool | flag | ) |

Definition at line 1058 of file load.c.

Referenced by Init_bigdecimal(), Init_cparse(), Init_escape(), Init_generator(), Init_monitor(), Init_openssl(), Init_parser(), Init_pathname(), Init_socket(), Init_stringio(), Init_strscan(), Init_zlib(), InitVM_digest(), and ruby_Init_Fiber_as_Coroutine().

## ◆ rb_f_require()

VALUE rb_f_require | ( | VALUE | obj,
|  | VALUE | fname
| ) |  |

Definition at line 880 of file load.c.

References rb_require_string().

Referenced by Init_load().

## ◆ rb_f_require_relative()

VALUE rb_f_require_relative | ( | VALUE | obj,
|  | VALUE | fname
| ) |  |

Definition at line 894 of file load.c.

References NIL_P, rb_current_realfilepath(), rb_file_absolute_path(), rb_file_dirname(), rb_loaderror(), and rb_require_string().

Referenced by Init_load().

## ◆ rb_feature_provided()

int rb_feature_provided | ( | const char * | feature,
|  | const char ** | loading
| ) |  |

Definition at line 571 of file load.c.

References FALSE, IS_DLEXT, IS_RBEXT, IS_SOEXT, Qnil, rb_file_expand_path_fast(), RB_GC_GUARD, rb_get_path(), rb_str_new2, RSTRING_PTR, strchr(), strrchr(), and TRUE.

Referenced by rb_provided().

## ◆ rb_get_expanded_load_path()

VALUE rb_get_expanded_load_path | ( | void |  | ) |

Definition at line 104 of file load.c.

References EXPAND_ALL, EXPAND_HOME, EXPAND_NON_CACHE, EXPAND_RELATIVE, rb_vm_struct::expanded_load_path, rb_vm_struct::load_path, rb_vm_struct::load_path_check_cache, rb_vm_struct::load_path_snapshot, Qtrue, rb_ary_shared_with_p(), rb_dir_getwd_ospath(), and rb_str_equal().

Referenced by rb_find_file(), and rb_find_file_ext().

## ◆ rb_load()

void rb_load | ( | VALUE | fname,
|  | int | wrap
| ) |  |

Definition at line 702 of file load.c.

References FilePathValue, and rb_find_file().

Referenced by rb_load_protect().

## ◆ rb_load_protect()

void rb_load_protect | ( | VALUE | fname,
|  | int | wrap,
|  | int * | pstate
| ) |  |

Definition at line 710 of file load.c.

References EC_EXEC_TAG, EC_POP_TAG, EC_PUSH_TAG, rb_load(), and TAG_NONE.

## ◆ rb_provide()

void rb_provide | ( | const char * | feature | ) |

Definition at line 616 of file load.c.

References rb_fstring_cstr.

Referenced by Init_Complex(), Init_Rational(), Init_version(), and InitVM_Enumerator().

## ◆ rb_provided()

int rb_provided | ( | const char * | feature | ) |

Definition at line 565 of file load.c.

References rb_feature_provided().

Referenced by ruby_init_ext().

## ◆ rb_require()

VALUE rb_require | ( | const char * | fname | ) |

Definition at line 1199 of file load.c.

References rb_require_string(), and rb_str_new_cstr.

Referenced by Init_bubblebabble(), Init_generator(), Init_parser(), and Init_psych_parser().

## ◆ rb_require_internal()

int rb_require_internal | ( | VALUE | fname | ) |

Definition at line 1165 of file load.c.

## ◆ rb_require_string()

VALUE rb_require_string | ( | VALUE | fname | ) |

Definition at line 1183 of file load.c.

References EC_JUMP_TAG, Qfalse, Qtrue, and TAG_RETURN.

Referenced by rb_f_require(), rb_f_require_relative(), and rb_require().

## ◆ rb_resolve_feature_path()

VALUE rb_resolve_feature_path | ( | VALUE | klass,
|  | VALUE | fname
| ) |  |

Definition at line 1020 of file load.c.

References ID2SYM, rb_ary_new_from_args, rb_get_path(), rb_intern(), rb_str_encode_ospath(), and sym.

Referenced by Init_load().

## ◆ ruby_init_ext()

void ruby_init_ext | ( | const char * | name,
|  | void(*)(void) | init
| ) |  |

Definition at line 1220 of file load.c.

References name, rb_provided(), and st_update.

## ◆ ruby_require_internal()

int ruby_require_internal | ( | const char * | fname,
|  | unsigned int | len
| ) |  |

Definition at line 1172 of file load.c.

References len, Qnil, rb_set_errinfo(), rb_setup_fake_str(), str, and TAG_RETURN.