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

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

variable.h
Go to the documentation of this file.
1#ifndef RBIMPL_VARIABLE_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_VARIABLE_H
23#include "ruby/internal/dllexport.h"
24#include "ruby/internal/value.h"
25#include "ruby/internal/attr/nonnull.h"
26#include "ruby/internal/attr/noreturn.h"
27
28 RBIMPL_SYMBOL_EXPORT_BEGIN()
29
30
37typedef VALUE rb_gvar_getter_t(ID id, VALUE *data);
38
46typedef void rb_gvar_setter_t(VALUE val, ID id, VALUE *data);
47
53typedef void rb_gvar_marker_t(VALUE *var);
54
62 rb_gvar_getter_t rb_gvar_undef_getter;
63
71 rb_gvar_setter_t rb_gvar_undef_setter;
72
80 rb_gvar_marker_t rb_gvar_undef_marker;
81
87 rb_gvar_getter_t rb_gvar_val_getter;
88
94 rb_gvar_setter_t rb_gvar_val_setter;
95
101 rb_gvar_marker_t rb_gvar_val_marker;
102
110 rb_gvar_getter_t rb_gvar_var_getter;
111
119 rb_gvar_setter_t rb_gvar_var_setter;
120
128 rb_gvar_marker_t rb_gvar_var_marker;
129
130 RBIMPL_ATTR_NORETURN()
135 rb_gvar_setter_t rb_gvar_readonly_setter;
136
137 RBIMPL_ATTR_NONNULL(())
162void rb_define_variable(const char *name, VALUE *var);
163
164 RBIMPL_ATTR_NONNULL((1))
181void rb_define_virtual_variable(const char *name, rb_gvar_getter_t *getter, rb_gvar_setter_t *setter);
182
183 RBIMPL_ATTR_NONNULL((1))
202void rb_define_hooked_variable(const char *name, VALUE *var, rb_gvar_getter_t *getter, rb_gvar_setter_t *setter);
203
204 RBIMPL_ATTR_NONNULL(())
217void rb_define_readonly_variable(const char *name, const VALUE *var);
218
219 RBIMPL_ATTR_NONNULL(())
239void rb_define_const(VALUE klass, const char *name, VALUE val);
240
241 RBIMPL_ATTR_NONNULL(())
256void rb_define_global_const(const char *name, VALUE val);
257
258 RBIMPL_ATTR_NONNULL(())
269void rb_deprecate_constant(VALUE mod, const char *name);
270
271 RBIMPL_ATTR_NONNULL(())
286 VALUE rb_gv_set(const char *name, VALUE val);
287
288 RBIMPL_ATTR_NONNULL(())
300 VALUE rb_gv_get(const char *name);
301
302 RBIMPL_ATTR_NONNULL(())
312 VALUE rb_iv_get(VALUE obj, const char *name);
313
314 RBIMPL_ATTR_NONNULL(())
333 VALUE rb_iv_set(VALUE obj, const char *name, VALUE val);
334
335 RBIMPL_SYMBOL_EXPORT_END()
336
337#endif /* RBIMPL_VARIABLE_H */
dllexport.h
Tweaking visibility of C variables/functions.
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:106
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:97
rb_gvar_var_setter
rb_gvar_setter_t rb_gvar_var_setter
Definition variable.h:119
rb_gvar_var_marker
rb_gvar_marker_t rb_gvar_var_marker
Definition variable.h:128
rb_define_global_const
void rb_define_global_const(const char *name, VALUE val)
Identical to rb_define_const(), except it defines that of "global", i.e.
Definition variable.c:3452
rb_gv_get
VALUE rb_gv_get(const char *name)
Obtains a global variable.
Definition variable.c:785
rb_define_variable
void rb_define_variable(const char *name, VALUE *var)
"Shares" a global variable between Ruby and C.
Definition variable.c:598
rb_gvar_marker_t
void rb_gvar_marker_t(VALUE *var)
Type that represents a global variable marker function.
Definition variable.h:53
rb_deprecate_constant
void rb_deprecate_constant(VALUE mod, const char *name)
Asserts that the given constant is deprecated.
Definition variable.c:3500
rb_gvar_setter_t
void rb_gvar_setter_t(VALUE val, ID id, VALUE *data)
Type that represents a global variable setter function.
Definition variable.h:46
rb_gvar_val_setter
rb_gvar_setter_t rb_gvar_val_setter
This is the setter function that backs global variables defined from a ruby script.
Definition variable.h:94
rb_gvar_undef_marker
rb_gvar_marker_t rb_gvar_undef_marker
Definition variable.h:80
rb_define_readonly_variable
void rb_define_readonly_variable(const char *name, const VALUE *var)
Identical to rb_define_variable(), except it does not allow Ruby programs to assign values to such gl...
Definition variable.c:604
rb_gvar_readonly_setter
rb_gvar_setter_t rb_gvar_readonly_setter
This function just raises rb_eNameError.
Definition variable.h:135
rb_gvar_undef_getter
rb_gvar_getter_t rb_gvar_undef_getter
Definition variable.h:62
rb_gv_set
VALUE rb_gv_set(const char *name, VALUE val)
Assigns to a global variable.
Definition variable.c:771
rb_gvar_val_marker
rb_gvar_marker_t rb_gvar_val_marker
This is the setter function that backs global variables defined from a ruby script.
Definition variable.h:101
rb_define_virtual_variable
void rb_define_virtual_variable(const char *name, rb_gvar_getter_t *getter, rb_gvar_setter_t *setter)
Defines a global variable that is purely function-backended.
Definition variable.c:610
rb_define_const
void rb_define_const(VALUE klass, const char *name, VALUE val)
Defines a Ruby level constant under a namespace.
Definition variable.c:3440
rb_gvar_getter_t
VALUE rb_gvar_getter_t(ID id, VALUE *data)
Type that represents a global variable getter function.
Definition variable.h:37
rb_iv_get
VALUE rb_iv_get(VALUE obj, const char *name)
Obtains an instance variable.
Definition variable.c:3936
rb_gvar_undef_setter
rb_gvar_setter_t rb_gvar_undef_setter
Definition variable.h:71
rb_gvar_val_getter
rb_gvar_getter_t rb_gvar_val_getter
This is the getter function that backs global variables defined from a ruby script.
Definition variable.h:87
rb_iv_set
VALUE rb_iv_set(VALUE obj, const char *name, VALUE val)
Assigns to an instance variable.
Definition variable.c:3947
rb_define_hooked_variable
void rb_define_hooked_variable(const char *name, VALUE *var, rb_gvar_getter_t *getter, rb_gvar_setter_t *setter)
Identical to rb_define_virtual_variable(), but can also specify a storage.
Definition variable.c:579
rb_gvar_var_getter
rb_gvar_getter_t rb_gvar_var_getter
Definition variable.h:110
nonnull.h
Defines RBIMPL_ATTR_NONNULL.
RBIMPL_ATTR_NONNULL
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Definition nonnull.h:30
noreturn.h
Defines RBIMPL_ATTR_NORETURN.
RBIMPL_ATTR_NORETURN
#define RBIMPL_ATTR_NORETURN()
Wraps (or simulates) [[noreturn]]
Definition noreturn.h:38
value.h
Defines VALUE and ID.
ID
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
Definition value.h:52
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40