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

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

Functions
class.h File Reference

Public APIs related to rb_cClass/rb_cModule. More...

`#include "ruby/internal/dllexport.h"`
`#include "ruby/internal/value.h"`
`#include "ruby/backward/2/stdarg.h"`

Go to the source code of this file.

## Functions
VALUE | rb_class_new (VALUE super)
| Creates a new, anonymous class.
VALUE | rb_mod_init_copy (VALUE clone, VALUE orig)
| The comment that comes with this function says `:nodoc:`.
void | rb_check_inheritable (VALUE super)
| Asserts that the given class can derive a child class.
VALUE | rb_define_class_id (ID id, VALUE super)
| This is a very badly designed API that creates an anonymous class.
VALUE | rb_define_class_id_under (VALUE outer, ID id, VALUE super)
| Identical to rb_define_class_under(), except it takes the name in ID instead of C's string.
VALUE | rb_module_new (void)
| Creates a new, anonymous module.
VALUE | rb_refinement_new (void)
| Creates a new, anonymous refinement.
VALUE | rb_define_module_id (ID id)
| This is a very badly designed API that creates an anonymous module.
VALUE | rb_define_module_id_under (VALUE outer, ID id)
| Identical to rb_define_module_under(), except it takes the name in ID instead of C's string.
VALUE | rb_mod_included_modules (VALUE mod)
| Queries the list of included modules.
VALUE | rb_mod_include_p (VALUE child, VALUE parent)
| Queries if the passed module is included by the module.
VALUE | rb_mod_ancestors (VALUE mod)
| Queries the module's ancestors.
VALUE | rb_class_descendants (VALUE klass)
| Queries the class's descendants.
VALUE | rb_class_subclasses (VALUE klass)
| Queries the class's direct descendants.
VALUE | rb_class_attached_object (VALUE klass)
| Returns the attached object for a singleton class.
VALUE | rb_class_instance_methods (int argc, const VALUE *argv, VALUE mod)
| Generates an array of symbols, which are the list of method names defined in the passed class.
VALUE | rb_class_public_instance_methods (int argc, const VALUE *argv, VALUE mod)
| Identical to rb_class_instance_methods(), except it returns names of methods that are public only.
VALUE | rb_class_protected_instance_methods (int argc, const VALUE *argv, VALUE mod)
| Identical to rb_class_instance_methods(), except it returns names of methods that are protected only.
VALUE | rb_class_private_instance_methods (int argc, const VALUE *argv, VALUE mod)
| Identical to rb_class_instance_methods(), except it returns names of methods that are private only.
VALUE | rb_obj_singleton_methods (int argc, const VALUE *argv, VALUE obj)
| Identical to rb_class_instance_methods(), except it returns names of singleton methods instead of instance methods.
void | rb_define_method_id (VALUE klass, ID mid, VALUE(*func)(ANYARGS), int arity)
| Identical to rb_define_method(), except it takes the name of the method in ID instead of C's string.
void | rb_undef (VALUE mod, ID mid)
| Inserts a method entry that hides previous method definition of the given name.
void | rb_define_protected_method (VALUE klass, const char *mid, VALUE(*func)(ANYARGS), int arity)
| Identical to rb_define_method(), except it defines a protected method.
void | rb_define_private_method (VALUE klass, const char *mid, VALUE(*func)(ANYARGS), int arity)
| Identical to rb_define_method(), except it defines a private method.
void | rb_define_singleton_method (VALUE obj, const char *mid, VALUE(*func)(ANYARGS), int arity)
| Identical to rb_define_method(), except it defines a singleton method.
VALUE | rb_singleton_class (VALUE obj)
| Finds or creates the singleton class of the passed object.

## Detailed Description

Public APIs related to rb_cClass/rb_cModule.

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 class.h.

## Function Documentation

## ◆ rb_class_descendants()

VALUE rb_class_descendants | ( | VALUE | klass | ) |

Queries the class's descendants.

This routine gathers classes that are subclasses of the given class (or subclasses of those subclasses, etc.), returning an array of classes that have the given class as an ancestor. The returned array does not include the given class or singleton classes.

Parameters

  [in] | klass | A class.

Returns
  An array of classes where `klass` is an ancestor.

## ◆ rb_undef()

void rb_undef | ( | VALUE | mod,
|  | ID | mid )

Inserts a method entry that hides previous method definition of the given name.

This is not a deletion of a method. Method of the same name defined in a parent class is kept invisible in this way.

Parameters

  [out] | mod | The module to insert an undef.
  [in] | mid | Name of the undef.

Exceptions

  rb_eTypeError | `klass` is a non-module.
  rb_eFrozenError | `klass` is frozen.
  rb_eNameError | No such method named `klassname`.

Postcondition
  `klass#name` is undefined.

See also
  rb_undef_method

Definition at line 1757 of file vm_method.c.