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

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

Typedefs | Functions | Variables
variable.h File Reference

C-function backended Ruby-global variables. More...

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

Go to the source code of this file.

## Typedefs
typedef VALUE | rb_gvar_getter_t(ID id, VALUE *data)
typedef void | rb_gvar_setter_t(VALUE val, ID id, VALUE *data)
typedef void | rb_gvar_marker_t(VALUE *var)

## Functions
void | rb_define_variable (const char *, VALUE *)
void | rb_define_virtual_variable (const char *, rb_gvar_getter_t *, rb_gvar_setter_t *)
void | rb_define_hooked_variable (const char *, VALUE *, rb_gvar_getter_t *, rb_gvar_setter_t *)
void | rb_define_readonly_variable (const char *, const VALUE *)
void | rb_define_const (VALUE, const char *, VALUE)
void | rb_define_global_const (const char *, VALUE)
VALUE | rb_gv_set (const char *, VALUE)
VALUE | rb_gv_get (const char *)
VALUE | rb_iv_get (VALUE, const char *)
VALUE | rb_iv_set (VALUE, const char *, VALUE)

## Variables
rb_gvar_getter_t | rb_gvar_undef_getter
rb_gvar_setter_t | rb_gvar_undef_setter
rb_gvar_marker_t | rb_gvar_undef_marker
rb_gvar_getter_t | rb_gvar_val_getter
rb_gvar_setter_t | rb_gvar_val_setter
rb_gvar_marker_t | rb_gvar_val_marker
rb_gvar_getter_t | rb_gvar_var_getter
rb_gvar_setter_t | rb_gvar_var_setter
rb_gvar_marker_t | rb_gvar_var_marker
rb_gvar_setter_t | rb_gvar_readonly_setter

## Detailed Description

C-function backended Ruby-global variables.

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.

## Typedef Documentation

## ◆ rb_gvar_getter_t

typedef VALUE rb_gvar_getter_t(ID id, VALUE *data)

Definition at line 29 of file variable.h.

## ◆ rb_gvar_marker_t

typedef void rb_gvar_marker_t(VALUE *var)

Definition at line 31 of file variable.h.

## ◆ rb_gvar_setter_t

typedef void rb_gvar_setter_t(VALUE val, ID id, VALUE *data)

Definition at line 30 of file variable.h.

## Function Documentation

## ◆ rb_define_const()

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

Definition at line 3150 of file variable.c.

References name, rb_const_set(), rb_gc_register_mark_object(), rb_intern(), rb_is_const_id(), and rb_warn().

Referenced by exp2(), Init_bigdecimal(), Init_Bignum(), Init_Complex(), Init_cparse(), Init_date_core(), Init_dbm(), Init_etc(), Init_fcntl(), Init_fiddle(), Init_fiddle_function(), Init_fiddle_handle(), Init_fiddle_pointer(), Init_File(), Init_GC(), Init_gdbm(), Init_IO(), Init_limits(), Init_nkf(), Init_Numeric(), Init_openssl(), Init_ossl_asn1(), Init_ossl_config(), Init_ossl_ec(), Init_ossl_ocsp(), Init_ossl_pkcs7(), Init_ossl_ssl(), Init_ossl_ts(), Init_ossl_x509name(), Init_psych_parser(), Init_readline(), Init_Regexp(), Init_sizeof(), Init_stringio(), Init_Thread(), Init_VM(), Init_win32ole(), Init_win32ole_variant(), Init_win32ole_variant_m(), Init_zlib(), InitVM_process(), InitVM_Random(), InitVM_transcode(), rb_define_global_const(), and rb_file_const().

## ◆ rb_define_global_const()

void rb_define_global_const | ( | const char * | name,
|  | VALUE | val
| ) |  |

Definition at line 3162 of file variable.c.

References name, rb_cObject, and rb_define_const().

Referenced by Init_Hash(), Init_IO(), Init_ruby_description(), Init_version(), Init_VM(), and ruby_prog_init().

## ◆ rb_define_hooked_variable()

void rb_define_hooked_variable | ( | const char * | name,
|  | VALUE * | var,
|  | rb_gvar_getter_t * | getter,
|  | rb_gvar_setter_t * | setter
| ) |  |

Definition at line 562 of file variable.c.

References rb_global_variable::data, rb_global_variable::getter, rb_global_variable::marker, name, Qnil, RB_GC_GUARD, rb_gvar_var_getter, rb_gvar_var_marker, rb_gvar_var_setter, rb_global_variable::setter, and rb_global_entry::var.

Referenced by rb_define_readonly_variable(), rb_define_variable(), and rb_define_virtual_variable().

## ◆ rb_define_readonly_variable()

void rb_define_readonly_variable | ( | const char * | name,
|  | const VALUE * | var
| ) |  |

Definition at line 587 of file variable.c.

References name, rb_define_hooked_variable(), and rb_gvar_readonly_setter.

Referenced by Init_IO().

## ◆ rb_define_variable()

void rb_define_variable | ( | const char * | name,
|  | VALUE * | var
| ) |  |

Definition at line 581 of file variable.c.

References name, and rb_define_hooked_variable().

## ◆ rb_define_virtual_variable()

void rb_define_virtual_variable | ( | const char * | name,
|  | rb_gvar_getter_t * | getter,
|  | rb_gvar_setter_t * | setter
| ) |  |

Definition at line 593 of file variable.c.

References rb_global_variable::getter, name, rb_define_hooked_variable(), rb_gvar_readonly_setter, rb_gvar_val_getter, and rb_global_variable::setter.

## ◆ rb_gv_get()

VALUE rb_gv_get | ( | const char * | name | ) |

Definition at line 768 of file variable.c.

References name, Qnil, rb_gvar_get(), and rb_warning().

## ◆ rb_gv_set()

VALUE rb_gv_set | ( | const char * | name,
|  | VALUE | val
| ) |  |

Definition at line 754 of file variable.c.

References name, and rb_gvar_set().

## ◆ rb_iv_get()

VALUE rb_iv_get | ( | VALUE | obj,
|  | const char * | name
| ) |  |

Definition at line 3569 of file variable.c.

References name, Qnil, rb_check_id_cstr(), rb_ivar_get(), rb_usascii_encoding(), and strlen().

## ◆ rb_iv_set()

VALUE rb_iv_set | ( | VALUE | obj,
|  | const char * | name,
|  | VALUE | val
| ) |  |

Definition at line 3580 of file variable.c.

References name, rb_intern(), and rb_ivar_set().

Referenced by Init_md5(), Init_rmd160(), and Init_sha1().

## Variable Documentation

## ◆ rb_gvar_readonly_setter

rb_gvar_setter_t rb_gvar_readonly_setter

Definition at line 46 of file variable.h.

Referenced by Init_IO(), Init_load(), rb_define_readonly_variable(), rb_define_virtual_variable(), and ruby_prog_init().

## ◆ rb_gvar_undef_getter

rb_gvar_getter_t rb_gvar_undef_getter

Definition at line 33 of file variable.h.

Referenced by rb_gvar_defined().

## ◆ rb_gvar_undef_marker

rb_gvar_marker_t rb_gvar_undef_marker

Definition at line 35 of file variable.h.

## ◆ rb_gvar_undef_setter

rb_gvar_setter_t rb_gvar_undef_setter

Definition at line 34 of file variable.h.

## ◆ rb_gvar_val_getter

rb_gvar_getter_t rb_gvar_val_getter

Definition at line 37 of file variable.h.

Referenced by rb_define_virtual_variable(), and rb_gvar_undef_setter().

## ◆ rb_gvar_val_marker

rb_gvar_marker_t rb_gvar_val_marker

Definition at line 39 of file variable.h.

Referenced by rb_gvar_undef_setter().

## ◆ rb_gvar_val_setter

rb_gvar_setter_t rb_gvar_val_setter

Definition at line 38 of file variable.h.

Referenced by rb_gvar_undef_setter().

## ◆ rb_gvar_var_getter

rb_gvar_getter_t rb_gvar_var_getter

Definition at line 41 of file variable.h.

Referenced by rb_define_hooked_variable().

## ◆ rb_gvar_var_marker

rb_gvar_marker_t rb_gvar_var_marker

Definition at line 43 of file variable.h.

Referenced by rb_define_hooked_variable().

## ◆ rb_gvar_var_setter

rb_gvar_setter_t rb_gvar_var_setter

Definition at line 42 of file variable.h.

Referenced by rb_define_hooked_variable().