4#include "internal/class.h"
5#include "internal/eval.h"
6#include "internal/error.h"
7#include "internal/file.h"
8#include "internal/gc.h"
9#include "internal/hash.h"
10#include "internal/load.h"
11#include "internal/namespace.h"
12#include "internal/st.h"
13#include "internal/variable.h"
21VALUE rb_cNamespaceEntry = 0;
23VALUE rb_mNamespaceLoader = 0;
33static rb_namespace_t *
const builtin_namespace = &builtin_namespace_data;
36static bool tmp_dir_has_dirsep;
38#define NAMESPACE_TMP_PREFIX "_ruby_ns_"
41# define MAXPATHLEN 1024
50bool ruby_namespace_enabled =
false;
51bool ruby_namespace_init_done =
false;
59rb_namespace_init_done(
void)
61 ruby_namespace_init_done =
true;
65rb_namespace_enable_builtin(
void)
67 VALUE require_stack = GET_VM()->require_stack;
74rb_namespace_disable_builtin(
void)
76 VALUE require_stack = GET_VM()->require_stack;
85 VALUE require_stack = GET_VM()->require_stack;
92 VALUE require_stack = GET_VM()->require_stack;
95 rb_bug(
"popping on the empty require_stack");
97 if (latest != ns->ns_object)
98 rb_bug(
"Inconsistent loading namespace");
103rb_root_namespace(
void)
105 return root_namespace;
109rb_builtin_namespace(
void)
115rb_main_namespace(
void)
117 return main_namespace;
123 if (!NAMESPACE_BUILTIN_P(ns)) {
130 if (def->type == VM_METHOD_TYPE_ISEQ) {
131 ID mid = def->original_id;
132 const char *path = RSTRING_PTR(pathobj_path(def->body.iseq.
iseqptr->body->location.pathobj));
133 if (strcmp(path,
"<internal:kernel>") == 0) {
134 if (mid == rb_intern(
"class") || mid == rb_intern(
"clone") ||
135 mid == rb_intern(
"tag") || mid == rb_intern(
"then") ||
136 mid == rb_intern(
"yield_self") || mid == rb_intern(
"loop") ||
137 mid == rb_intern(
"Float") || mid == rb_intern(
"Integer")
142 else if (strcmp(path,
"<internal:warning>") == 0) {
143 if (mid == rb_intern(
"warn")) {
147 else if (strcmp(path,
"<internal:marshal>") == 0) {
148 if (mid == rb_intern(
"load"))
156block_proc_namespace(
const VALUE procval)
161 GetProcPtr(procval, proc);
170current_namespace(
bool permit_calling_builtin)
183 if (!rb_namespace_available())
186 if (th->namespaces &&
RARRAY_LEN(th->namespaces) > 0) {
194 if (VM_FRAME_NS_SWITCH_P(cfp)) {
195 bh = rb_vm_frame_block_handler(cfp);
196 if (bh && vm_block_handler_type(bh) == block_handler_type_proc) {
197 proc_ns = block_proc_namespace(VM_BH_TO_PROC(bh));
198 if (permit_calling_builtin || NAMESPACE_USER_P(proc_ns))
202 cme = rb_vm_frame_method_entry(cfp);
203 if (cme && cme->def) {
208 if (!namespace_ignore_builtin_primitive_methods_p(ns, cme->def)) {
209 if (permit_calling_builtin || (proc_ns && NAMESPACE_USER_P(proc_ns)))
213 cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
224 if (!main_namespace) {
226 return root_namespace;
228 return main_namespace;
232rb_current_namespace(
void)
234 return current_namespace(
true);
238rb_loading_namespace(
void)
242 VALUE require_stack = GET_VM()->require_stack;
244 if (!rb_namespace_available())
247 if (!require_stack) {
248 return current_namespace(
false);
251 return current_namespace(
false);
255 rb_bug(
"require_stack is not an array: %s", rb_type_str(
BUILTIN_TYPE(require_stack)));
258 return rb_get_namespace_t(
namespace);
262rb_definition_namespace(
void)
265 if (NAMESPACE_BUILTIN_P(ns)) {
266 return root_namespace;
271static long namespace_id_counter = 0;
274namespace_generate_id(
void)
278 id = ++namespace_id_counter;
294 ns->expanded_load_path =
rb_ary_dup(vm->expanded_load_path);
296 ns->load_path_check_cache = 0;
297 ns->loaded_features =
rb_ary_dup(vm->loaded_features);
299 ns->loaded_features_index = st_init_numtable();
300 ns->loaded_features_realpaths = rb_hash_dup(vm->loaded_features_realpaths);
301 ns->loaded_features_realpath_map = rb_hash_dup(vm->loaded_features_realpath_map);
302 ns->loading_table = st_init_strtable();
303 ns->ruby_dln_libmap = rb_hash_new_with_size(0);
304 ns->gvar_tbl = rb_hash_new_with_size(0);
306 ns->is_builtin =
false;
308 ns->is_optional =
true;
311void rb_namespace_gc_update_references(
void *ptr)
314 if (!
NIL_P(ns->ns_object))
315 ns->ns_object = rb_gc_location(ns->ns_object);
316 ns->top_self = rb_gc_location(ns->top_self);
317 ns->load_path = rb_gc_location(ns->load_path);
318 ns->expanded_load_path = rb_gc_location(ns->expanded_load_path);
319 ns->load_path_snapshot = rb_gc_location(ns->load_path_snapshot);
320 if (ns->load_path_check_cache) {
321 ns->load_path_check_cache = rb_gc_location(ns->load_path_check_cache);
323 ns->loaded_features = rb_gc_location(ns->loaded_features);
324 ns->loaded_features_snapshot = rb_gc_location(ns->loaded_features_snapshot);
325 ns->loaded_features_realpaths = rb_gc_location(ns->loaded_features_realpaths);
326 ns->loaded_features_realpath_map = rb_gc_location(ns->loaded_features_realpath_map);
327 ns->ruby_dln_libmap = rb_gc_location(ns->ruby_dln_libmap);
328 ns->gvar_tbl = rb_gc_location(ns->gvar_tbl);
332rb_namespace_entry_mark(
void *ptr)
335 rb_gc_mark(ns->ns_object);
336 rb_gc_mark(ns->top_self);
337 rb_gc_mark(ns->load_path);
338 rb_gc_mark(ns->expanded_load_path);
339 rb_gc_mark(ns->load_path_snapshot);
340 rb_gc_mark(ns->load_path_check_cache);
341 rb_gc_mark(ns->loaded_features);
342 rb_gc_mark(ns->loaded_features_snapshot);
343 rb_gc_mark(ns->loaded_features_realpaths);
344 rb_gc_mark(ns->loaded_features_realpath_map);
345 if (ns->loading_table) {
346 rb_mark_tbl(ns->loading_table);
348 rb_gc_mark(ns->ruby_dln_libmap);
349 rb_gc_mark(ns->gvar_tbl);
352#define namespace_entry_free RUBY_TYPED_DEFAULT_FREE
355namespace_entry_memsize(
const void *ptr)
363 rb_namespace_entry_mark,
364 namespace_entry_free,
365 namespace_entry_memsize,
366 rb_namespace_gc_update_references,
368 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
372rb_namespace_entry_alloc(
VALUE klass)
376 namespace_entry_initialize(entry);
381get_namespace_struct_internal(
VALUE entry)
389rb_get_namespace_t(
VALUE namespace)
392 ID id_namespace_entry;
395 return root_namespace;
396 if (
NIL_P(
namespace))
397 return builtin_namespace;
399 CONST_ID(id_namespace_entry,
"__namespace_entry__");
400 entry = rb_attr_get(
namespace, id_namespace_entry);
401 return get_namespace_struct_internal(entry);
409 return ns->ns_object;
415namespace_initialize(
VALUE namespace)
420 ID id_namespace_entry;
421 CONST_ID(id_namespace_entry,
"__namespace_entry__");
423 if (!rb_namespace_available()) {
424 rb_raise(
rb_eRuntimeError,
"Namespace is disabled. Set RUBY_NAMESPACE=1 environment variable to use Namespace.");
428 ns = get_namespace_struct_internal(entry);
430 ns->ns_object =
namespace;
431 ns->ns_id = namespace_generate_id();
432 ns->load_path =
rb_ary_dup(GET_VM()->load_path);
439 RCLASS_SET_PRIME_CLASSEXT_WRITABLE(
namespace,
true);
443 object_classext = RCLASS_EXT_WRITABLE_IN_NS(rb_cObject, ns);
444 RCLASS_SET_CONST_TBL(
namespace, RCLASSEXT_CONST_TBL(object_classext),
true);
448 setup_pushing_loading_namespace(ns);
454rb_namespace_s_getenabled(
VALUE namespace)
456 return RBOOL(rb_namespace_available());
460rb_namespace_current(
VALUE klass)
463 if (NAMESPACE_USER_P(ns)) {
464 return ns->ns_object;
466 if (NAMESPACE_BUILTIN_P(ns)) {
473rb_namespace_s_is_builtin_p(
VALUE namespace,
VALUE klass)
475 if (RCLASS_PRIME_CLASSEXT_READABLE_P(klass) && !RCLASS_PRIME_CLASSEXT_WRITABLE_P(klass))
481rb_namespace_load_path(
VALUE namespace)
483 return rb_get_namespace_t(
namespace)->load_path;
487UINT rb_w32_system_tmpdir(WCHAR *path, UINT
len);
492system_default_tmpdir(
void)
496 WCHAR tmppath[_MAX_PATH];
497 UINT
len = rb_w32_system_tmpdir(tmppath, numberof(tmppath));
499 int blen = WideCharToMultiByte(CP_UTF8, 0, tmppath,
len, NULL, 0, NULL, NULL);
500 char *tmpdir =
xmalloc(blen + 1);
501 WideCharToMultiByte(CP_UTF8, 0, tmppath,
len, tmpdir, blen, NULL, NULL);
505#elif defined _CS_DARWIN_USER_TEMP_DIR
506 char path[MAXPATHLEN];
507 size_t len = confstr(_CS_DARWIN_USER_TEMP_DIR, path,
sizeof(path));
510 if (
len >
sizeof(path)) {
511 confstr(_CS_DARWIN_USER_TEMP_DIR, tmpdir,
len);
514 memcpy(tmpdir, path,
len);
523check_tmpdir(
const char *dir)
527 if (!dir)
return FALSE;
528 if (stat(dir, &st))
return FALSE;
530# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
532 if (!S_ISDIR(st.st_mode))
return FALSE;
537 if (st.st_mode & S_IWOTH) {
539 if (!(st.st_mode & S_ISVTX))
return FALSE;
544 if (access(dir, W_OK))
return FALSE;
553# define RETURN_ENV(name) \
554 if (check_tmpdir(tmpdir = getenv(name))) return ruby_strdup(tmpdir)
555 RETURN_ENV(
"TMPDIR");
557 tmpdir = system_default_tmpdir();
558 if (check_tmpdir(tmpdir))
return tmpdir;
566sprint_ext_filename(
char *str,
size_t size,
long namespace_id,
const char *prefix,
const char *basename)
568 if (tmp_dir_has_dirsep) {
569 return snprintf(str, size,
"%s%sp%"PRI_PIDT_PREFIX"u_%ld_%s", tmp_dir, prefix, getpid(), namespace_id, basename);
571 return snprintf(str, size,
"%s%s%sp%"PRI_PIDT_PREFIX"u_%ld_%s", tmp_dir, DIRSEP, prefix, getpid(), namespace_id, basename);
576copy_ext_file_error(
char *message,
size_t size)
578 int error = GetLastError();
580 size_t len = snprintf(message, size,
"%d: ", error);
582#define format_message(sublang) FormatMessage(\
583 FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, \
584 NULL, error, MAKELANGID(LANG_NEUTRAL, (sublang)), \
585 message + len, size - len, NULL)
586 if (format_message(SUBLANG_ENGLISH_US) == 0)
587 format_message(SUBLANG_DEFAULT);
588 for (p = message +
len; *p; p++) {
589 if (*p ==
'\n' || *p ==
'\r')
596copy_ext_file_error(
char *message,
size_t size,
int copy_retvalue,
char *src_path,
char *dst_path)
598 switch (copy_retvalue) {
600 snprintf(message, size,
"can't open the extension path: %s", src_path);
602 snprintf(message, size,
"can't open the file to write: %s", dst_path);
604 snprintf(message, size,
"failed to read the extension path: %s", src_path);
606 snprintf(message, size,
"failed to write the extension path: %s", dst_path);
608 rb_bug(
"unknown return value of copy_ext_file: %d", copy_retvalue);
615copy_ext_file(
char *src_path,
char *dst_path)
620 WCHAR *w_src = rb_w32_mbstr_to_wstr(CP_UTF8, src_path, -1, NULL);
621 WCHAR *w_dst = rb_w32_mbstr_to_wstr(CP_UTF8, dst_path, -1, NULL);
622 if (!w_src || !w_dst) {
626 rvalue = CopyFileW(w_src, w_dst, FALSE) ? 0 : 1;
633 size_t read = 0, wrote, written = 0;
634 size_t maxread =
sizeof(buffer);
639 src = fopen(src_path,
"rb");
643 dst = fopen(dst_path,
"wb");
649 read = fread(buffer, 1,
sizeof(buffer), src);
653 wrote = fwrite(buffer+written, 1, read-written, dst);
654 if (wrote < read-written) {
668 if (read < maxread) {
669 if (clean_read && feof(src)) {
673 else if (ferror(src)) {
686#if defined __CYGWIN__ || defined DOSISH
687#define isdirsep(x) ((x) == '/' || (x) == '\\')
689#define isdirsep(x) ((x) == '/')
692#define IS_SOEXT(e) (strcmp((e), ".so") == 0 || strcmp((e), ".o") == 0)
693#define IS_DLEXT(e) (strcmp((e), DLEXT) == 0)
696fname_without_suffix(
char *fname,
char *rvalue)
699 strcpy(rvalue, fname);
700 for (pos = rvalue + strlen(fname); pos > rvalue; pos--) {
701 if (IS_SOEXT(pos) || IS_DLEXT(pos)) {
709escaped_basename(
char *path,
char *fname,
char *rvalue)
711 char *pos, *leaf, *found;
714 while ((found = strstr(leaf + 1, fname)) != NULL) {
717 strcpy(rvalue, leaf);
718 for (pos = rvalue; *pos; pos++) {
719 if (isdirsep(*pos)) {
728 char ext_path[MAXPATHLEN], fname2[MAXPATHLEN], basename[MAXPATHLEN];
729 int copy_error, wrote;
730 char *src_path = RSTRING_PTR(path), *fname_ptr = RSTRING_PTR(fname);
733 fname_without_suffix(fname_ptr, fname2);
734 escaped_basename(src_path, fname2, basename);
736 wrote = sprint_ext_filename(ext_path,
sizeof(ext_path), ns->ns_id, NAMESPACE_TMP_PREFIX, basename);
737 if (wrote >= (
int)
sizeof(ext_path)) {
738 rb_bug(
"Extension file path in namespace was too long");
740 copy_error = copy_ext_file(src_path, ext_path);
744 copy_ext_file_error(message,
sizeof(message));
746 copy_ext_file_error(message,
sizeof(message), copy_error, src_path, ext_path);
748 rb_raise(
rb_eLoadError,
"can't prepare the extension file for namespaces (%s from %s): %s", ext_path, src_path, message);
761 if (
RTEST(th->namespaces)) {
765 th->namespaces = rb_ary_new_from_args(1,
namespace);
767 th->ns = rb_get_namespace_t(
namespace);
771namespace_pop(
VALUE th_value)
776 VALUE namespaces = th->namespaces;
778 rb_bug(
"Too many namespace pops");
782 if (stack_len == 0) {
784 th->ns = main_namespace;
788 th->ns = rb_get_namespace_t(upper_ns);
797 namespace_push(th, ns ? ns->ns_object :
Qnil);
807namespace_both_pop(
VALUE arg)
810 namespace_pop((
VALUE) data->th);
811 rb_namespace_pop_loading_namespace(data->ns);
816rb_namespace_load(
int argc,
VALUE *argv,
VALUE namespace)
824 VALUE args = rb_ary_new_from_args(2, fname, wrap);
825 namespace_push(th,
namespace);
826 rb_namespace_push_loading_namespace(ns);
831 return rb_ensure(rb_load_entrypoint, args, namespace_both_pop, (
VALUE)&arg);
835rb_namespace_require(
VALUE namespace,
VALUE fname)
839 namespace_push(th,
namespace);
840 rb_namespace_push_loading_namespace(ns);
849rb_namespace_require_relative(
VALUE namespace,
VALUE fname)
853 namespace_push(th,
namespace);
854 rb_namespace_push_loading_namespace(ns);
859 return rb_ensure(rb_require_relative_entrypoint, fname, namespace_both_pop, (
VALUE)&arg);
863rb_namespace_eval_string(
VALUE str)
875 namespace_push(th,
namespace);
876 return rb_ensure(rb_namespace_eval_string, str, namespace_pop, (
VALUE)th);
879static int namespace_experimental_warned = 0;
882rb_initialize_main_namespace(
void)
889 if (!namespace_experimental_warned) {
891 "Namespace is experimental, and the behavior may change in the future!\n"
892 "See doc/namespace.md for known issues, etc.");
893 namespace_experimental_warned = 1;
897 ns = rb_get_namespace_t(main_ns);
898 ns->ns_object = main_ns;
899 ns->ns_id = namespace_generate_id();
900 ns->is_builtin =
false;
902 ns->is_optional =
false;
906 vm->main_namespace = th->ns = main_namespace = ns;
910rb_namespace_inspect(
VALUE obj)
918 ns = rb_get_namespace_t(obj);
921 if (NAMESPACE_BUILTIN_P(ns)) {
924 if (NAMESPACE_USER_P(ns)) {
927 if (NAMESPACE_MAIN_P(ns)) {
930 else if (NAMESPACE_OPTIONAL_P(ns)) {
943namespace_builtin_refiner_calling_super(
VALUE arg)
950namespace_builtin_refiner_loading_func_ensure(
VALUE _)
953 if (!vm->require_stack)
954 rb_bug(
"require_stack is not ready but the namespace refiner is called");
955 rb_namespace_disable_builtin();
960rb_namespace_builtin_refiner_loading_func(
int argc,
VALUE *argv,
VALUE _self)
963 if (!vm->require_stack)
964 rb_bug(
"require_stack is not ready but the namespace refiner is called");
965 rb_namespace_enable_builtin();
972 return rb_ensure(namespace_builtin_refiner_calling_super, (
VALUE)&data,
973 namespace_builtin_refiner_loading_func_ensure,
Qnil);
977setup_builtin_refinement(
VALUE mod)
981 rb_define_method(data.refinement,
"require", rb_namespace_builtin_refiner_loading_func, -1);
982 rb_define_method(data.refinement,
"require_relative", rb_namespace_builtin_refiner_loading_func, -1);
983 rb_define_method(data.refinement,
"load", rb_namespace_builtin_refiner_loading_func, -1);
987namespace_user_loading_func_calling_super(
VALUE arg)
994namespace_user_loading_func_ensure(
VALUE arg)
997 rb_namespace_pop_loading_namespace(ns);
1002rb_namespace_user_loading_func(
int argc,
VALUE *argv,
VALUE _self)
1006 if (!vm->require_stack)
1007 rb_bug(
"require_stack is not ready but require/load is called in user namespaces");
1008 ns = rb_current_namespace();
1009 VM_ASSERT(rb_namespace_available() || !ns);
1010 rb_namespace_push_loading_namespace(ns);
1015 return rb_ensure(namespace_user_loading_func_calling_super, (
VALUE)&data,
1016 namespace_user_loading_func_ensure, (
VALUE)ns);
1020setup_pushing_loading_namespace_include(
VALUE mod)
1029 rb_namespace_exec(ns, setup_pushing_loading_namespace_include, rb_mNamespaceLoader);
1033namespace_define_loader_method(
const char *name)
1040Init_enable_namespace(
void)
1042 const char *env = getenv(
"RUBY_NAMESPACE");
1043 if (env && strlen(env) == 1 && env[0] ==
'1') {
1044 ruby_namespace_enabled =
true;
1047 ruby_namespace_init_done =
true;
1054 tmp_dir = system_tmpdir();
1055 tmp_dir_has_dirsep = (strcmp(tmp_dir + (strlen(tmp_dir) - strlen(DIRSEP)), DIRSEP) == 0);
1064 if (rb_namespace_available()) {
1069 namespace_define_loader_method(
"require");
1070 namespace_define_loader_method(
"require_relative");
1071 namespace_define_loader_method(
"load");
#define rb_define_method(klass, mid, func, arity)
Defines klass#mid.
#define rb_define_singleton_method(klass, mid, func, arity)
Defines klass.mid.
#define rb_define_private_method(klass, mid, func, arity)
Defines klass#mid and makes it private.
Ruby-level global variables / constants, visible from C.
void rb_include_module(VALUE klass, VALUE module)
Includes a module to a class.
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
VALUE rb_define_module_under(VALUE outer, const char *name)
Defines a module under the namespace of outer.
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
Retrieves argument from argc and argv to given VALUE references according to the format string.
#define xmalloc
Old name of ruby_xmalloc.
#define LONG2NUM
Old name of RB_LONG2NUM.
#define Qtrue
Old name of RUBY_Qtrue.
#define Qnil
Old name of RUBY_Qnil.
#define Qfalse
Old name of RUBY_Qfalse.
#define T_ARRAY
Old name of RUBY_T_ARRAY.
#define NIL_P
Old name of RB_NIL_P.
#define BUILTIN_TYPE
Old name of RB_BUILTIN_TYPE.
#define CONST_ID
Old name of RUBY_CONST_ID.
void rb_category_warn(rb_warning_category_t category, const char *fmt,...)
Identical to rb_category_warning(), except it reports unless $VERBOSE is nil.
VALUE rb_eLoadError
LoadError exception.
VALUE rb_eRuntimeError
RuntimeError exception.
@ RB_WARN_CATEGORY_EXPERIMENTAL
Warning is for experimental features.
VALUE rb_mKernel
Kernel module.
VALUE rb_cNamespace
Namespace class.
VALUE rb_class_new_instance_pass_kw(int argc, const VALUE *argv, VALUE klass)
Identical to rb_class_new_instance(), except it passes the passed keywords if any to the #initialize ...
VALUE rb_cModule
Module class.
VALUE rb_mNamespaceRefiner
Namespace::Refiner module.
VALUE rb_funcall(VALUE recv, ID mid, int n,...)
Calls a method.
VALUE rb_eval_string(const char *str)
Evaluates the given string.
VALUE rb_call_super(int argc, const VALUE *argv)
This resembles ruby's super.
VALUE rb_ary_dup(VALUE ary)
Duplicates an array.
VALUE rb_ary_new(void)
Allocates a new, empty array.
VALUE rb_ary_pop(VALUE ary)
Destructively deletes an element from the end of the passed array and returns what was deleted.
VALUE rb_ary_push(VALUE ary, VALUE elem)
Special case of rb_ary_cat() that it adds only one element.
VALUE rb_require_string(VALUE feature)
Finds and loads the given feature, if absent.
VALUE rb_str_concat(VALUE dst, VALUE src)
Identical to rb_str_append(), except it also accepts an integer as a codepoint.
#define rb_str_cat_cstr(buf, str)
Identical to rb_str_cat(), except it assumes the passed pointer is a pointer to a C string.
#define rb_str_new_cstr(str)
Identical to rb_str_new, except it assumes the passed pointer is a pointer to a C string.
VALUE rb_ivar_set(VALUE obj, ID name, VALUE val)
Identical to rb_iv_set(), except it accepts the name as an ID instead of a C string.
void rb_const_set(VALUE space, ID name, VALUE val)
Names a constant.
void rb_define_alloc_func(VALUE klass, rb_alloc_func_t func)
Sets the allocator function of a class.
int len
Length of the buffer.
char * ruby_strdup(const char *str)
This is our own version of strdup(3) that uses ruby_xmalloc() instead of system malloc (benefits our ...
VALUE rb_ensure(type *q, VALUE w, type *e, VALUE r)
An equivalent of ensure clause.
#define PRI_PIDT_PREFIX
A rb_sprintf() format prefix to be used for a pid_t parameter.
#define RARRAY_LEN
Just another name of rb_array_len.
#define RARRAY_AREF(a, i)
#define StringValue(v)
Ensures that the parameter object is a String.
#define TypedData_Get_Struct(obj, type, data_type, sval)
Obtains a C struct from inside of a wrapper Ruby object.
#define TypedData_Make_Struct(klass, type, data_type, sval)
Identical to TypedData_Wrap_Struct, except it allocates a new data region internally instead of takin...
#define RTEST
This is an old name of RB_TEST.
#define _(args)
This was a transition path from K&R to ANSI.
This is the struct that holds necessary info for a struct.
const rb_iseq_t * iseqptr
iseq pointer, should be separated from iseqval
Internal header for Namespace.
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
uintptr_t VALUE
Type that represents a Ruby object.
static bool RB_TYPE_P(VALUE obj, enum ruby_value_type t)
Queries if the given object is of given type.