Ruby: include/ruby/internal/intern/struct.h Source File

Ruby 4.0.6p0 (2026-07-14 revision 03b6d3f8898a28604fe6cb00eae3226b821168f4)

struct.h
Go to the documentation of this file.
1#ifndef RBIMPL_INTERN_STRUCT_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_INTERN_STRUCT_H
23#include "ruby/internal/attr/nonnull.h"
24#include "ruby/internal/dllexport.h"
25#include "ruby/internal/intern/vm.h" /* rb_alloc_func_t */
26#include "ruby/internal/value.h"
27
28 RBIMPL_SYMBOL_EXPORT_BEGIN()
29
30/* struct.c */
31
32
42 VALUE rb_struct_new(VALUE klass, ...);
43
65 VALUE rb_struct_define(const char *name, ...);
66
67 RBIMPL_ATTR_NONNULL((2))
86 VALUE rb_struct_define_under(VALUE space, const char *name, ...);
87
98 VALUE rb_struct_alloc(VALUE klass, VALUE values);
99
107 VALUE rb_struct_initialize(VALUE self, VALUE values);
108
118 VALUE rb_struct_getmember(VALUE self, ID key);
119
126 VALUE rb_struct_s_members(VALUE klass);
127
142 VALUE rb_struct_members(VALUE self);
143
152 VALUE rb_struct_alloc_noinit(VALUE klass);
153
180 VALUE rb_struct_define_without_accessor(const char *name, VALUE super, rb_alloc_func_t func, ...);
181
182 RBIMPL_ATTR_NONNULL((2))
205 VALUE rb_struct_define_without_accessor_under(VALUE outer, const char *class_name, VALUE super, rb_alloc_func_t alloc, ...);
206
221 VALUE rb_data_define(VALUE super, ...);
222
223 RBIMPL_SYMBOL_EXPORT_END()
224
225#endif /* RBIMPL_INTERN_STRUCT_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:74
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:65
rb_struct_define_without_accessor_under
VALUE rb_struct_define_without_accessor_under(VALUE outer, const char *class_name, VALUE super, rb_alloc_func_t alloc,...)
Identical to rb_struct_define_without_accessor(), except it defines the class under the specified nam...
Definition struct.c:460
rb_struct_define_under
VALUE rb_struct_define_under(VALUE space, const char *name,...)
Identical to rb_struct_define(), except it defines the class under the specified namespace instead of...
Definition struct.c:506
rb_struct_new
VALUE rb_struct_new(VALUE klass,...)
Creates an instance of the given struct.
Definition struct.c:877
rb_struct_initialize
VALUE rb_struct_initialize(VALUE self, VALUE values)
Mass-assigns a struct's fields.
Definition struct.c:806
rb_struct_define_without_accessor
VALUE rb_struct_define_without_accessor(const char *name, VALUE super, rb_alloc_func_t func,...)
Identical to rb_struct_define(), except it does not define accessor methods.
Definition struct.c:473
rb_struct_define
VALUE rb_struct_define(const char *name,...)
Defines a struct class.
Definition struct.c:486
rb_struct_alloc
VALUE rb_struct_alloc(VALUE klass, VALUE values)
Identical to rb_struct_new(), except it takes the field values as a Ruby array.
Definition struct.c:871
rb_data_define
VALUE rb_data_define(VALUE super,...)
Defines an anonymous data class.
Definition struct.c:1740
rb_struct_alloc_noinit
VALUE rb_struct_alloc_noinit(VALUE klass)
Allocates an instance of the given class.
Definition struct.c:406
rb_struct_s_members
VALUE rb_struct_s_members(VALUE klass)
Queries the list of the names of the fields of the given struct class.
Definition struct.c:68
rb_struct_members
VALUE rb_struct_members(VALUE self)
Queries the list of the names of the fields of the class of the given struct object.
Definition struct.c:82
rb_struct_getmember
VALUE rb_struct_getmember(VALUE self, ID key)
Identical to rb_struct_aref(), except it takes ID instead of VALUE.
Definition struct.c:233
vm.h
Public APIs related to rb_cRubyVM.
rb_alloc_func_t
VALUE(* rb_alloc_func_t)(VALUE klass)
This is the type of functions that ruby calls when trying to allocate an object.
Definition vm.h:219
nonnull.h
Defines RBIMPL_ATTR_NONNULL.
RBIMPL_ATTR_NONNULL
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull)).
Definition nonnull.h:30
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