Ruby: include/ruby/internal/intern/variable.h File Reference

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

Functions
variable.h File Reference

Public APIs related to names inside of a Ruby program. More...

`#include "ruby/internal/attr/nonnull.h"`
`#include "ruby/internal/attr/noreturn.h"`
`#include "ruby/internal/dllexport.h"`
`#include "ruby/internal/value.h"`
`#include "ruby/st.h"`

Go to the source code of this file.

## Functions
VALUE | rb_mod_name (VALUE mod)
| Queries the name of a module.
VALUE | rb_class_path (VALUE mod)
| Identical to rb_mod_name(), except it returns `#<Class: ...>` style inspection for anonymous modules.
VALUE | rb_class_path_cached (VALUE mod)
| Just another name of rb_mod_name.
void | rb_set_class_path (VALUE klass, VALUE space, const char *name)
| Names a class.
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.
VALUE | rb_path_to_class (VALUE path)
| Identical to rb_path2class(), except it accepts the path as Ruby's string instead of C's.
VALUE | rb_path2class (const char *path)
| Resolves a `Q::W::E::R`-style path string to the actual class it points.
VALUE | rb_class_name (VALUE obj)
| Queries the name of the given object's class.
VALUE | rb_autoload_load (VALUE space, ID name)
| Kicks the autoload procedure as if it was "touched".
VALUE | rb_autoload_p (VALUE space, ID name)
| Queries if an autoload is defined at a point.
VALUE | rb_f_trace_var (int argc, const VALUE *argv)
| Traces a global variable.
VALUE | rb_f_untrace_var (int argc, const VALUE *argv)
| Deletes the passed tracer from the passed global variable, or if omitted, deletes everything.
VALUE | rb_f_global_variables (void)
| Queries the list of global variables.
void | rb_alias_variable (ID dst, ID src)
| Aliases a global variable.
void | rb_free_generic_ivar (VALUE obj)
| Frees the list of instance variables.
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.
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.
VALUE | rb_ivar_defined (VALUE obj, ID name)
| Queries if the instance variable is defined at the object.
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.
st_index_t | rb_ivar_count (VALUE obj)
| Number of instance variables defined on an object.
VALUE | rb_attr_get (VALUE obj, ID name)
| Identical to rb_ivar_get()
VALUE | rb_obj_instance_variables (VALUE obj)
| Resembles `Object#instance_variables`.
VALUE | rb_obj_remove_instance_variable (VALUE obj, VALUE name)
| Resembles `Object#remove_instance_variable`.
void * | rb_mod_const_at (VALUE, void *)
| This API is mysterious.
void * | rb_mod_const_of (VALUE, void *)
| This is a variant of rb_mod_const_at().
VALUE | rb_const_list (void *)
| This is another mysterious API that comes with no documents at all.
VALUE | rb_mod_constants (int argc, const VALUE *argv, VALUE recv)
| Resembles `Module#constants`.
VALUE | rb_mod_remove_const (VALUE space, VALUE name)
| Resembles `Module#remove_const`.
int | rb_const_defined (VALUE space, ID name)
| Queries if the constant is defined at the namespace.
int | rb_const_defined_at (VALUE space, ID name)
| Identical to rb_const_defined(), except it doesn't look for parent classes.
int | rb_const_defined_from (VALUE space, ID name)
| Identical to rb_const_defined(), except it returns false for private constants.
VALUE | rb_const_get (VALUE space, ID name)
| Identical to rb_const_defined(), except it returns the actual defined value.
VALUE | rb_const_get_at (VALUE space, ID name)
| Identical to rb_const_defined_at(), except it returns the actual defined value.
VALUE | rb_const_get_from (VALUE space, ID name)
| Identical to rb_const_defined_at(), except it returns the actual defined value.
void | rb_const_set (VALUE space, ID name, VALUE val)
| Names a constant.
VALUE | rb_const_remove (VALUE space, ID name)
| Identical to rb_mod_remove_const(), except it takes the name as ID instead of VALUE.
VALUE | rb_cvar_defined (VALUE klass, ID name)
| Queries if the given class has the given class variable.
void | rb_cvar_set (VALUE klass, ID name, VALUE val)
| Assigns a value to a class variable.
VALUE | rb_cvar_get (VALUE klass, ID name)
| Obtains a value from a class variable.
VALUE | rb_cvar_find (VALUE klass, ID name, VALUE *front)
| Identical to rb_cvar_get(), except it takes additional "front" pointer.
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.
VALUE | rb_cv_get (VALUE klass, const char *name)
| Identical to rb_cvar_get(), except it accepts C's string instead of ID.
void | rb_define_class_variable (VALUE, const char *, VALUE)
| Just another name of rb_cv_set.
VALUE | rb_mod_class_variables (int argc, const VALUE *argv, VALUE recv)
| Resembles `Module#class_variables`.
VALUE | rb_mod_remove_cvar (VALUE mod, VALUE name)
| Resembles `Module#remove_class_variable`.

## Detailed Description

Public APIs related to names inside of a Ruby program.

Author
  Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Copyright
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

Warning
  Symbols prefixed with either `RBIMPL` or `rbimpl` are implementation details. Don't take them as canon. They could rapidly appear then vanish. The name (path) of this header file is also an implementation detail. Do not expect it to persist at the place it is now. Developers are free to move it anywhere anytime at will.

Note
  To ruby-core: remember that this header can be possibly recursively included from extension libraries written in C++. Do not expect for instance `__VA_ARGS__` is always available. We assume C99 for ruby itself but we don't assume languages of extension libraries. They could be written in C++98.

Definition in file variable.h.

## Function Documentation

## ◆ rb_alias_variable()

void rb_alias_variable | ( | ID | dst,
|  | ID | src )

Aliases a global variable.

Did you know that you can alias a global variable? It is like aliasing methods:

alias $dst $src

This C function does the same thing.

Parameters

  [in] | dst | Destination name.
  [in] | src | Source name.

Postcondition
  A global variable named `dst` is defined to be an alias of a global variable named `src`.

Definition at line 859 of file variable.c.

Referenced by rb_alias_variable().

## ◆ rb_attr_get()

VALUE rb_attr_get | ( | VALUE | obj,
|  | ID | name )

Identical to rb_ivar_get()

Parameters

  [in] | obj | Target object.
  [in] | name | Target instance variable to query.

Return values

  RUBY_nil | No such instance variable.
  otherwise | The value assigned to the instance variable.

Definition at line 1226 of file variable.c.

Referenced by rb_class_attached_object(), rb_error_frozen_object(), and rb_singleton_class_get().

## ◆ rb_autoload_load()

VALUE rb_autoload_load | ( | VALUE | space,
|  | ID | name )

Kicks the autoload procedure as if it was "touched".

Parameters

  [out] | space | Namespace where autoload is defined.
  [in] | name | Name of the autoloaded constant.

Return values

  RUBY_Qfalse | No such autoload.
  RUBY_Qtrue | Autoload successfully initiated.

Note
  As an autoloaded library is expected to define `space::name`, it is a nature of this function to have process-global side effects.
  Multiple threads can simultaneously call this API. It blocks then. That must not last indefinitely but can take longer than you expect.

Definition at line 2731 of file variable.c.

Referenced by rb_autoload_load().

## ◆ rb_autoload_p()

VALUE rb_autoload_p | ( | VALUE | space,
|  | ID | name )

Queries if an autoload is defined at a point.

Parameters

  [in] | space | Namespace where autoload is defined.
  [in] | name | Name of the autoloaded constant.

Return values

  RUBY_Qnil | No such autoload.
  otherwise | The feature (path) registered at `space::name`.

Definition at line 2769 of file variable.c.

Referenced by rb_autoload_p().

## ◆ rb_class_name()

VALUE rb_class_name | ( | VALUE | obj | ) |

Queries the name of the given object's class.

Parameters

  [in] | obj | Arbitrary object.

Returns
  An instance of rb_cString representing `obj`'s class' path.

Definition at line 310 of file variable.c.

Referenced by rb_any_to_s().

## ◆ rb_class_path()

VALUE rb_class_path | ( | VALUE | mod | ) |

Identical to rb_mod_name(), except it returns `#<Class: ...>` style inspection for anonymous modules.

Parameters

  [in] | mod | An instance of rb_cModule.

Returns
  An instance of rb_cString representing `mod`'s path.

Definition at line 188 of file variable.c.

Referenced by rb_class_name(), and rb_profile_frame_classpath().

## ◆ rb_class_path_cached()

VALUE rb_class_path_cached | ( | VALUE | mod | ) |

Just another name of rb_mod_name.

Definition at line 197 of file variable.c.

## ◆ rb_const_defined()

int rb_const_defined | ( | VALUE | space,
|  | ID | name )

Queries if the constant is defined at the namespace.

Parameters

  [in] | space | Target namespace.
  [in] | name | Target name to query.

Return values

  RUBY_Qtrue | There is a constant.
  RUBY_Qfalse | No such constant.

Definition at line 3204 of file variable.c.

Referenced by rb_define_class(), and rb_define_module().

## ◆ rb_const_defined_at()

int rb_const_defined_at | ( | VALUE | space,
|  | ID | name )

Identical to rb_const_defined(), except it doesn't look for parent classes.

For instance `Array` is a toplevel constant, which is visible from everywhere. But this function does not take such things into account. It concerns only what is directly defined inside of the given namespace.

Parameters

  [in] | space | Target namespace.
  [in] | name | Target name to query.

Return values

  RUBY_Qtrue | There is a constant.
  RUBY_Qfalse | No such constant.

Definition at line 3210 of file variable.c.

Referenced by rb_const_remove(), and rb_define_module_id_under().

## ◆ rb_const_defined_from()

int rb_const_defined_from | ( | VALUE | space,
|  | ID | name )

Identical to rb_const_defined(), except it returns false for private constants.

Parameters

  [in] | space | Target namespace.
  [in] | name | Target name to query.

Return values

  RUBY_Qtrue | There is a constant.
  RUBY_Qfalse | No such constant.

Definition at line 3198 of file variable.c.

## ◆ rb_const_get()

VALUE rb_const_get | ( | VALUE | space,
|  | ID | name )

Identical to rb_const_defined(), except it returns the actual defined value.

Parameters

  [in] | space | Target namespace.
  [in] | name | Target name to query.

Exceptions

  rb_eNameError | No such constant.

Returns
  The defined constant.

Definition at line 2896 of file variable.c.

Referenced by rb_const_get(), and rb_define_class().

## ◆ rb_const_get_at()

VALUE rb_const_get_at | ( | VALUE | space,
|  | ID | name )

Identical to rb_const_defined_at(), except it returns the actual defined value.

It can also be seen as a routine identical to rb_const_get(), except it doesn't look for parent classes.

Parameters

  [in] | space | Target namespace.
  [in] | name | Target name to query.

Exceptions

  rb_eNameError | No such constant.

Returns
  The defined constant.

Definition at line 2902 of file variable.c.

Referenced by rb_const_get_at().

## ◆ rb_const_get_from()

VALUE rb_const_get_from | ( | VALUE | space,
|  | ID | name )

Identical to rb_const_defined_at(), except it returns the actual defined value.

It can also be seen as a routine identical to rb_const_get(), except it doesn't return a private constant.

Parameters

  [in] | space | Target namespace.
  [in] | name | Target name to query.

Exceptions

  rb_eNameError | No such constant.

Returns
  The defined constant.

Definition at line 2890 of file variable.c.

Referenced by rb_const_get_from().

## ◆ rb_const_list()

VALUE rb_const_list | ( | void * | data | ) |

This is another mysterious API that comes with no documents at all.

It seems it expects some specific data structure for the passed pointer. But the details has never been made explicit. It seems nobody should use this API.

Definition at line 3116 of file variable.c.

Referenced by rb_mod_constants().

## ◆ rb_const_remove()

VALUE rb_const_remove | ( | VALUE | space,
|  | ID | name )

Identical to rb_mod_remove_const(), except it takes the name as ID instead of VALUE.

Parameters

  [out] | space | Target namespace.
  [in] | name | Variable name to remove, either in Symbol or String.

Returns
  What was removed.

Precondition
  Constant named `space::name` is deleted.

Note
  In case what was removed was in fact a module or a class, this operation does not affect its name. Which means when people for instance look at it using `p` etc., it still introduces itself using the deleted name. Can confuse people.

Definition at line 2999 of file variable.c.

Referenced by rb_const_remove(), and rb_mod_remove_const().

## ◆ rb_const_set()

void rb_const_set | ( | VALUE | space,
|  | ID | name,
|  | VALUE | val )

Names a constant.

Parameters

  [out] | space | Target namespace.
  [in] | name | Target name to query.
  [in] | val | Value to define.

Exceptions

  rb_eTypeError | `space` is not a module.

Postcondition
  `name` is a constant under `space`, whose value is `val`.

Note
  You can reassign.

Definition at line 3346 of file variable.c.

Referenced by Init_class_hierarchy(), rb_const_set(), rb_define_class(), rb_define_const(), rb_define_module(), rb_define_module_id_under(), and ruby_init_loadpath().

## ◆ rb_cv_get()

VALUE rb_cv_get | ( | VALUE | klass,
|  | const char * | name )

Identical to rb_cvar_get(), except it accepts C's string instead of ID.

Parameters

  [in] | klass | Target class.
  [in] | name | Variable name.

Exceptions

  rb_eNameError | Uninitialised class variable.
  rb_eRuntimeError | `[Bug#14541]` situation.

Returns
  Class variable named `name` under `klass`.

Definition at line 3780 of file variable.c.

## ◆ rb_cv_set()

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.

Parameters

  [out] | klass | Target class.
  [in] | name | Variable name.
  [in] | val | Value to be assigned.

Postcondition
  `klass` has a class variable named `name` whose value is `val`.

Definition at line 3773 of file variable.c.

Referenced by rb_define_class_variable().

## ◆ rb_cvar_defined()

VALUE rb_cvar_defined | ( | VALUE | klass,
|  | ID | name )

Queries if the given class has the given class variable.

Parameters

  [in] | klass | Target class.
  [in] | name | Name to query.

Returns
  RUBY_Qtrue Yes there is.
  RUBY_Qfalse No there isn't.

Precondition
  `klass` must be an instance of rb_cModule.

Definition at line 3754 of file variable.c.

Referenced by rb_mod_remove_cvar().

## ◆ rb_cvar_find()

VALUE rb_cvar_find | ( | VALUE | klass,
|  | ID | name,
|  | VALUE * | front )

Identical to rb_cvar_get(), except it takes additional "front" pointer.

This extra parameter is a buffer, which will have the class where the queried class variable actually resides.

Parameters

  [in] | klass | Target class.
  [in] | name | Variable name.
  [out] | front | Return buffer.

Exceptions

  rb_eNameError | Uninitialised class variable.
  rb_eRuntimeError | `[Bug#14541]` situation.

Returns
  Class variable named `name` under `klass`.

Postcondition
  `front` has the class object, which is an ancestor of `klass`, where the queried class variable actually resides.

Definition at line 3732 of file variable.c.

Referenced by rb_cvar_get().

## ◆ rb_cvar_get()

VALUE rb_cvar_get | ( | VALUE | klass,
|  | ID | name )

Obtains a value from a class variable.

Parameters

  [in] | klass | Target class.
  [in] | name | Variable name.

Exceptions

  rb_eNameError | Uninitialised class variable.
  rb_eRuntimeError | `[Bug#14541]` situation.

Returns
  Class variable named `name` under `klass`.

Definition at line 3747 of file variable.c.

Referenced by rb_cv_get().

## ◆ rb_cvar_set()

void rb_cvar_set | ( | VALUE | klass,
|  | ID | name,
|  | VALUE | val )

Assigns a value to a class variable.

Parameters

  [out] | klass | Target class.
  [in] | name | Variable name.
  [in] | val | Value to be assigned.

Postcondition
  `klass` has a class variable named `name` whose value is `val`.

Definition at line 3677 of file variable.c.

Referenced by rb_cv_set(), and rb_cvar_set().

## ◆ rb_define_class_variable()

void rb_define_class_variable | ( | VALUE | klass,
|  | const char * | name,
|  | VALUE | val )

Just another name of rb_cv_set.

Definition at line 3787 of file variable.c.

## ◆ rb_f_global_variables()

VALUE rb_f_global_variables | ( | void |  | ) |

Queries the list of global variables.

Returns
  The list of the name of the global variables.

Definition at line 827 of file variable.c.

Referenced by rb_f_global_variables().

## ◆ rb_f_trace_var()

VALUE rb_f_trace_var | ( | int | argc,
|  | const VALUE * | argv )

Traces a global variable.

Parameters

  [in] | argc | Either 1 or 2.
  [in] | argv | Variable name, optionally a Proc.

Return values

  RUBY_Qnil | No previous tracers.
  otherwise | Previous tracers.

Definition at line 627 of file variable.c.

Referenced by rb_f_trace_var().

## ◆ rb_f_untrace_var()

VALUE rb_f_untrace_var | ( | int | argc,
|  | const VALUE * | argv )

Deletes the passed tracer from the passed global variable, or if omitted, deletes everything.

Parameters

  [in] | argc | Either 1 or 2.
  [in] | argv | Variable name, optionally a Proc.

Return values

  RUBY_Qnil | No previous tracers.
  otherwise | Deleted tracers.

Definition at line 673 of file variable.c.

Referenced by rb_f_trace_var(), and rb_f_untrace_var().

## ◆ rb_free_generic_ivar()

void rb_free_generic_ivar | ( | VALUE | obj | ) |

Frees the list of instance variables.

3rd parties need not know, but there are several ways to store an object's instance variables, depending on its internal structure. This function makes sense when the passed objects is using so-called "generic" backend storage. People need not be aware of this working behind-the-scenes.

Parameters

  [out] | obj | The object in question.

Definition at line 1065 of file variable.c.

Referenced by rb_copy_generic_ivar().

## ◆ rb_ivar_count()

st_index_t rb_ivar_count | ( | VALUE | obj | ) |

Number of instance variables defined on an object.

Parameters

  [in] | obj | Target object.

Returns
  Number of instance variables defined on `obj`.

Definition at line 1838 of file variable.c.

## ◆ rb_ivar_defined()

VALUE rb_ivar_defined | ( | VALUE | obj,
|  | ID | name )

Queries if the instance variable is defined at the object.

This roughly resembles `defined?(@name)` in `obj`'s context.

Parameters

  [in] | obj | Target object.
  [in] | name | Target instance variable to query.

Return values

  RUBY_Qtrue | There is an instance variable.
  RUBY_Qfalse | No such instance variable.

Definition at line 1623 of file variable.c.

## ◆ rb_ivar_foreach()

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.

Parameters

  [in] | obj | Target object.
  [in] | func | Callback function.
  [in] | arg | Passed as-is to the last argument of `func`.

## ◆ rb_ivar_get()

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.

Parameters

  [in] | obj | Target object.
  [in] | name | Target instance variable to query.

Return values

  RUBY_nil | No such instance variable.
  otherwise | The value assigned to the instance variable.

Definition at line 1218 of file variable.c.

Referenced by rb_class_modify_check(), rb_iv_get(), and rb_profile_frame_classpath().

## ◆ rb_ivar_set()

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.

Parameters

  [out] | obj | Target object.
  [in] | name | Target instance variable.
  [in] | val | Value to assign.

Exceptions

  rb_eFrozenError | Can't modify `obj`.
  rb_eArgError | `obj` has too many instance variables.

Returns
  Passed value.

Postcondition
  An instance variable named `name` is defined if absent on `obj`, whose value is set to `val`.

Definition at line 1606 of file variable.c.

Referenced by rb_error_frozen_object(), rb_frozen_error_raise(), rb_iv_set(), rb_memory_view_register(), rb_set_class_path_string(), and ruby_init_loadpath().

## ◆ rb_mod_class_variables()

VALUE rb_mod_class_variables | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | recv )

Resembles `Module#class_variables`.

List up the variables defined at the receiver. This includes the names of constants in any included modules, unless `argv[0]` is RUBY_Qfalse.

The implementation makes no guarantees about the order in which the constants are yielded.

Parameters

  [in] | argc | Either 0 or 1.
  [in] | argv | Pointer to RUBY_Qfalse, if `argc == 1`.
  [in] | recv | Target class.

Returns
  An array of symbols, which are class variable names under `recv`.

Definition at line 3878 of file variable.c.

## ◆ rb_mod_const_at()

void * rb_mod_const_at | ( | VALUE | mod,
|  | void * | data )

This API is mysterious.

It has been there since the initial revision. No single bits of documents has ever been written. The function name doesn't describe anything. What should be passed to the argument, or what should be the return value, are not obvious. Yet it has evolved over time. The source code is written in counter-intuitive way (as of 3.0).

Simply put, don't try to understand this API.

Definition at line 3077 of file variable.c.

Referenced by rb_mod_const_of().

## ◆ rb_mod_const_of()

void * rb_mod_const_of | ( | VALUE | mod,
|  | void * | data )

This is a variant of rb_mod_const_at().

As a result, it is also mysterious. It seems it iterates over the ancestry tree of the module. But what that means is beyond a human brain.

Definition at line 3094 of file variable.c.

Referenced by rb_mod_constants().

## ◆ rb_mod_constants()

VALUE rb_mod_constants | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | recv )

Resembles `Module#constants`.

List up the constants defined at the receiver. This includes the names of constants in any included modules, unless `argv[0]` is RUBY_Qfalse.

The implementation makes no guarantees about the order in which the constants are yielded.

Parameters

  [in] | argc | Either 0 or 1.
  [in] | argv | Pointer to RUBY_Qfalse, if `argc == 1`.
  [in] | recv | Target namespace.

Returns
  An array of symbols, which are constant names under `recv`.

Definition at line 3148 of file variable.c.

## ◆ rb_mod_name()

VALUE rb_mod_name | ( | VALUE | mod | ) |

Queries the name of a module.

Parameters

  [in] | mod | An instance of rb_cModule.

Return values

  RUBY_Qnil | `mod` is anonymous.
  otherwise | `mod` is onymous.

Definition at line 137 of file variable.c.

Referenced by rb_class_path_cached().

## ◆ rb_mod_remove_const()

VALUE rb_mod_remove_const | ( | VALUE | space,
|  | VALUE | name )

Resembles `Module#remove_const`.

Parameters

  [out] | space | Target namespace.
  [in] | name | Variable name to remove, either in Symbol or String.

Returns
  What was removed.

Precondition
  Constant named `space::name` is deleted.

Note
  In case what was removed was in fact a module or a class, this operation does not affect its name. Which means when people for instance look at it using `p` etc., it still introduces itself using the deleted name. Can confuse people.

Definition at line 2988 of file variable.c.

Referenced by rb_mod_remove_const().

## ◆ rb_mod_remove_cvar()

VALUE rb_mod_remove_cvar | ( | VALUE | mod,
|  | VALUE | name )

Resembles `Module#remove_class_variable`.

Parameters

  [out] | mod | Target class.
  [in] | name | Variable name to remove, either in Symbol or String.

Returns
  What was removed.

Precondition
  Instance variable named `name` is deleted from `obj`.

Definition at line 3913 of file variable.c.

## ◆ rb_obj_instance_variables()

VALUE rb_obj_instance_variables | ( | VALUE | obj | ) |

Resembles `Object#instance_variables`.

Parameters

  [in] | obj | Target object to query.

Returns
  An array of instance variable names for the receiver.

Note
  Simply defining an accessor does not create the corresponding instance variable.

Definition at line 1922 of file variable.c.

## ◆ rb_obj_remove_instance_variable()

VALUE rb_obj_remove_instance_variable | ( | VALUE | obj,
|  | VALUE | name )

Resembles `Object#remove_instance_variable`.

Parameters

  [out] | obj | Target object.
  [in] | name | Variable name to remove, either in Symbol or String.

Returns
  What was removed.

Precondition
  Instance variable named `name` is deleted from `obj`.

Definition at line 1977 of file variable.c.

## ◆ rb_path2class()

VALUE rb_path2class | ( | const char * | path | ) |

Resolves a `Q::W::E::R`-style path string to the actual class it points.

Parameters

  [in] | path | Path to query.

Exceptions

  rb_eArgError | No such constant.
  rb_eTypeError | The path resolved to a non-module.

Returns
  Resolved class.

Definition at line 304 of file variable.c.

## ◆ rb_path_to_class()

VALUE rb_path_to_class | ( | VALUE | path | ) |

Identical to rb_path2class(), except it accepts the path as Ruby's string instead of C's.

Parameters

  [in] | path | Path to query.

Exceptions

  rb_eArgError | No such constant.
  rb_eTypeError | The path resolved to a non-module.

Returns
  Resolved class.

Definition at line 259 of file variable.c.

Referenced by rb_path2class().

## ◆ rb_set_class_path()

void rb_set_class_path | ( | VALUE | klass,
|  | VALUE | space,
|  | const char * | name )

Names a class.

Parameters

  [out] | klass | Target module to name.
  [out] | space | Namespace that `klass` shall reside.
  [in] | name | Name of `klass`.

Postcondition
  `klass` has `space::klass` name.

Definition at line 251 of file variable.c.

## ◆ rb_set_class_path_string()

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.

Parameters

  [out] | klass | Target module to name.
  [out] | space | Namespace that `klass` shall reside.
  [in] | name | Name of `klass`.

Postcondition
  `klass` has `space::klass` name.

Definition at line 231 of file variable.c.

Referenced by Init_class_hierarchy(), rb_define_module_id_under(), and rb_set_class_path().