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

Ruby 3.3.7p123 (2025-01-15 revision be31f993d7fa0219d85f7b3c694d454da4ecc10b)

newobj.h
Go to the documentation of this file.
1#ifndef RBIMPL_NEWOBJ_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_NEWOBJ_H
23#include "ruby/internal/attr/deprecated.h"
24#include "ruby/internal/cast.h"
25#include "ruby/internal/core/rbasic.h"
26#include "ruby/internal/dllexport.h"
27#include "ruby/internal/fl_type.h"
28#include "ruby/internal/special_consts.h"
29#include "ruby/internal/value.h"
30#include "ruby/assert.h"
31
45#define RB_NEWOBJ(obj,type) type *(obj) = RBIMPL_CAST((type *)rb_newobj())
46
58#define RB_NEWOBJ_OF(obj,type,klass,flags) type *(obj) = RBIMPL_CAST((type *)rb_newobj_of(klass, flags))
59
60#define NEWOBJ RB_NEWOBJ
61#define NEWOBJ_OF RB_NEWOBJ_OF
62#define OBJSETUP rb_obj_setup
63#define CLONESETUP rb_clone_setup
64#define DUPSETUP rb_dup_setup
65
66 RBIMPL_SYMBOL_EXPORT_BEGIN()
73 VALUE rb_newobj(void);
74
83 VALUE rb_newobj_of(VALUE klass, VALUE flags);
84
106 VALUE rb_obj_setup(VALUE obj, VALUE klass, VALUE type);
107
116 VALUE rb_obj_class(VALUE obj);
117
131 VALUE rb_singleton_class_clone(VALUE obj);
132
145void rb_singleton_class_attached(VALUE klass, VALUE obj);
146
158void rb_copy_generic_ivar(VALUE clone, VALUE obj);
159 RBIMPL_SYMBOL_EXPORT_END()
160
161 RBIMPL_ATTR_DEPRECATED(("This is no longer how Object#clone works."))
172static inline void
173rb_clone_setup(VALUE clone, VALUE obj)
174{
175 (void)clone;
176 (void)obj;
177 return;
178}
179
180 RBIMPL_ATTR_DEPRECATED(("This is no longer how Object#dup works."))
191static inline void
192rb_dup_setup(VALUE dup, VALUE obj)
193{
194 (void)dup;
195 (void)obj;
196 return;
197}
198
199#endif /* RBIMPL_NEWOBJ_H */
assert.h
deprecated.h
Defines RBIMPL_ATTR_DEPRECATED.
RBIMPL_ATTR_DEPRECATED
#define RBIMPL_ATTR_DEPRECATED(msg)
Wraps (or simulates) [[deprecated]]
Definition deprecated.h:64
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
fl_type.h
Defines enum ruby_fl_type.
rb_singleton_class_clone
VALUE rb_singleton_class_clone(VALUE obj)
Clones a singleton class.
Definition class.c:636
rb_singleton_class_attached
void rb_singleton_class_attached(VALUE klass, VALUE obj)
Attaches a singleton class to its corresponding object.
Definition class.c:700
rb_obj_class
VALUE rb_obj_class(VALUE obj)
Queries the class of an object.
Definition object.c:215
rb_obj_setup
VALUE rb_obj_setup(VALUE obj, VALUE klass, VALUE type)
Fills common fields in the object.
Definition object.c:120
rb_copy_generic_ivar
void rb_copy_generic_ivar(VALUE clone, VALUE obj)
Copies the list of instance variables.
Definition variable.c:2031
rb_clone_setup
static void rb_clone_setup(VALUE clone, VALUE obj)
Definition newobj.h:173
rb_dup_setup
static void rb_dup_setup(VALUE dup, VALUE obj)
Definition newobj.h:192
inline
#define inline
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
Definition defines.h:66
rbasic.h
Defines struct RBasic.
special_consts.h
Defines enum ruby_special_consts.
value.h
Defines VALUE and ID.
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40