Ruby 4.1.0dev (2026-09-27 revision 7fb3844370953f355e3b469109b7f435d6c0d29a)
variable.h
Go to the documentation of this file.
1#ifndef RBIMPL_INTERN_VARIABLE_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_INTERN_VARIABLE_H
26#include "ruby/internal/value.h"
27#include "ruby/st.h"
28
30
31/* variable.c */
32
33
41
50
60
70void rb_set_class_path(VALUE klass, VALUE space, const char *name);
71
81void rb_set_class_path_string(VALUE klass, VALUE space, VALUE name);
82
93
103VALUE rb_path2class(const char *path);
104
112
131VALUE rb_autoload_load(VALUE space, ID name);
132
141VALUE rb_autoload_p(VALUE space, ID name);
142
155VALUE rb_f_trace_var(int argc, const VALUE *argv);
156
170VALUE rb_f_untrace_var(int argc, const VALUE *argv);
171
182
202void rb_alias_variable(ID dst, ID src);
203
219
229VALUE rb_ivar_get(VALUE obj, ID name);
230
244VALUE rb_ivar_set(VALUE obj, ID name, VALUE val);
245
255VALUE rb_ivar_defined(VALUE obj, ID name);
256
264void rb_ivar_foreach(VALUE obj, int (*func)(ID name, VALUE val, st_data_t arg), st_data_t arg);
265
272st_index_t rb_ivar_count(VALUE obj);
273
286VALUE rb_attr_get(VALUE obj, ID name);
287
297
307
317void *rb_mod_const_at(VALUE, void*);
318
324void *rb_mod_const_of(VALUE, void*);
325
332VALUE rb_const_list(void*);
333
347VALUE rb_mod_constants(int argc, const VALUE *argv, VALUE recv);
348
362
376int rb_const_defined(VALUE space, ID name);
377
394int rb_const_defined_at(VALUE space, ID name);
395
412int rb_const_defined_from(VALUE space, ID name);
413
426VALUE rb_const_get(VALUE space, ID name);
427
442VALUE rb_const_get_at(VALUE space, ID name);
443
458VALUE rb_const_get_from(VALUE space, ID name);
459
474void rb_const_set(VALUE space, ID name, VALUE val);
475
489VALUE rb_const_remove(VALUE space, ID name);
490
491#if 0 /* EXPERIMENTAL: remove if no problem */
500VALUE rb_mod_const_missing(VALUE space, VALUE name);
501#endif
502
516VALUE rb_cvar_defined(VALUE klass, ID name);
517
530void rb_cvar_set(VALUE klass, ID name, VALUE val);
531
545VALUE rb_cvar_get(VALUE klass, ID name);
546
566VALUE rb_cvar_find(VALUE klass, ID name, VALUE *front);
567
577void rb_cv_set(VALUE klass, const char *name, VALUE val);
578
589VALUE rb_cv_get(VALUE klass, const char *name);
590
599void rb_define_class_variable(VALUE, const char*, VALUE);
600
615VALUE rb_mod_class_variables(int argc, const VALUE *argv, VALUE recv);
616
626
628
629#endif /* RBIMPL_INTERN_VARIABLE_H */
#define RBIMPL_ATTR_DEPRECATED(msg)
Wraps (or simulates) [[deprecated]]
Definition deprecated.h:64
Tweaking visibility of C variables/functions.
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:74
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:65
Defines RBIMPL_ATTR_NONNULL.
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Definition nonnull.h:30
VALUE rb_mod_remove_cvar(VALUE mod, VALUE name)
Resembles Module#remove_class_variable.
Definition variable.c:4538
VALUE rb_obj_instance_variables(VALUE obj)
Resembles Object#instance_variables.
Definition variable.c:2530
VALUE rb_f_untrace_var(int argc, const VALUE *argv)
Deletes the passed tracer from the passed global variable, or if omitted, deletes everything.
Definition variable.c:959
VALUE rb_const_get(VALUE space, ID name)
Identical to rb_const_defined(), except it returns the actual defined value.
Definition variable.c:3505
VALUE rb_const_list(void *)
This is another mysterious API that comes with no documents at all.
Definition variable.c:3750
VALUE rb_path2class(const char *path)
Resolves a Q::W::E::R-style path string to the actual class it points.
Definition variable.c:512
VALUE rb_autoload_p(VALUE space, ID name)
Queries if an autoload is defined at a point.
Definition variable.c:3373
void rb_set_class_path(VALUE klass, VALUE space, const char *name)
Names a class.
Definition variable.c:459
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.
Definition variable.c:2141
VALUE rb_mod_remove_const(VALUE space, VALUE name)
Resembles Module#remove_const.
Definition variable.c:3610
VALUE rb_class_path_cached(VALUE mod)
Just another name of rb_mod_name.
Definition variable.c:407
VALUE rb_f_trace_var(int argc, const VALUE *argv)
Traces a global variable.
Definition variable.c:913
void rb_cvar_set(VALUE klass, ID name, VALUE val)
Assigns a value to a class variable.
Definition variable.c:4294
VALUE rb_cvar_get(VALUE klass, ID name)
Obtains a value from a class variable.
Definition variable.c:4373
VALUE rb_mod_constants(int argc, const VALUE *argv, VALUE recv)
Resembles Module#constants.
Definition variable.c:3782
VALUE rb_cvar_find(VALUE klass, ID name, VALUE *front)
Identical to rb_cvar_get(), except it takes additional "front" pointer.
Definition variable.c:4354
VALUE rb_path_to_class(VALUE path)
Identical to rb_path2class(), except it accepts the path as Ruby's string instead of C's.
Definition variable.c:467
VALUE rb_ivar_get(VALUE obj, ID name)
Identical to rb_iv_get(), except it accepts the name as an ID instead of a C string.
Definition variable.c:1641
void rb_ivar_foreach(VALUE obj, int(*func)(ID name, VALUE val, st_data_t arg), st_data_t arg)
Iterates over an object's instance variables.
void rb_const_set(VALUE space, ID name, VALUE val)
Names a constant.
Definition variable.c:3984
VALUE rb_autoload_load(VALUE space, ID name)
Kicks the autoload procedure as if it was "touched".
Definition variable.c:3335
VALUE rb_mod_name(VALUE mod)
Queries the name of a module.
Definition variable.c:152
VALUE rb_class_name(VALUE obj)
Queries the name of the given object's class.
Definition variable.c:518
VALUE rb_const_get_at(VALUE space, ID name)
Identical to rb_const_defined_at(), except it returns the actual defined value.
Definition variable.c:3511
void rb_set_class_path_string(VALUE klass, VALUE space, VALUE name)
Identical to rb_set_class_path(), except it accepts the name as Ruby's string instead of C's.
Definition variable.c:441
void rb_alias_variable(ID dst, ID src)
Aliases a global variable.
Definition variable.c:1232
void rb_define_class_variable(VALUE, const char *, VALUE)
Just another name of rb_cv_set.
Definition variable.c:4413
VALUE rb_obj_remove_instance_variable(VALUE obj, VALUE name)
Resembles Object#remove_instance_variable.
Definition variable.c:2582
void * rb_mod_const_of(VALUE, void *)
This is a variant of rb_mod_const_at().
Definition variable.c:3728
st_index_t rb_ivar_count(VALUE obj)
Number of instance variables defined on an object.
Definition variable.c:2478
void * rb_mod_const_at(VALUE, void *)
This API is mysterious.
Definition variable.c:3713
VALUE rb_const_remove(VALUE space, ID name)
Identical to rb_mod_remove_const(), except it takes the name as ID instead of VALUE.
Definition variable.c:3623
VALUE rb_const_get_from(VALUE space, ID name)
Identical to rb_const_defined_at(), except it returns the actual defined value.
Definition variable.c:3499
VALUE rb_ivar_defined(VALUE obj, ID name)
Queries if the instance variable is defined at the object.
Definition variable.c:2201
VALUE rb_cv_get(VALUE klass, const char *name)
Identical to rb_cvar_get(), except it accepts C's string instead of ID.
Definition variable.c:4406
int rb_const_defined_at(VALUE space, ID name)
Identical to rb_const_defined(), except it doesn't look for parent classes.
Definition variable.c:3844
void rb_cv_set(VALUE klass, const char *name, VALUE val)
Identical to rb_cvar_set(), except it accepts C's string instead of ID.
Definition variable.c:4399
VALUE rb_mod_class_variables(int argc, const VALUE *argv, VALUE recv)
Resembles Module#class_variables.
Definition variable.c:4503
VALUE rb_f_global_variables(void)
Queries the list of global variables.
Definition variable.c:1199
VALUE rb_cvar_defined(VALUE klass, ID name)
Queries if the given class has the given class variable.
Definition variable.c:4380
VALUE rb_class_path(VALUE mod)
Identical to rb_mod_name(), except it returns #<Class: ...> style inspection for anonymous modules.
Definition variable.c:398
int rb_const_defined_from(VALUE space, ID name)
Identical to rb_const_defined(), except it returns false for private constants.
Definition variable.c:3832
int rb_const_defined(VALUE space, ID name)
Queries if the constant is defined at the namespace.
Definition variable.c:3838
void rb_free_generic_ivar(VALUE obj)
Frees the list of instance variables.
Definition variable.c:1444
Defines RBIMPL_ATTR_NORETURN.
#define RBIMPL_ATTR_NORETURN()
Wraps (or simulates) [[noreturn]]
Definition noreturn.h:38
Defines VALUE and ID.
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
Definition value.h:52
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40