Ruby: internal/object.h Source File

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

object.h
Go to the documentation of this file.
1#ifndef INTERNAL_OBJECT_H /*-*-C-*-vi:se ft=c:*/
2#define INTERNAL_OBJECT_H
12#include "ruby/ruby.h" /* for VALUE */
13#include "internal/class.h" /* for RCLASS_IV_INDEX_TBL */
14
15#ifdef ROBJECT_IV_INDEX_TBL
16# undef ROBJECT_IV_INDEX_TBL
17#endif
18
19/* object.c */
20 VALUE rb_class_search_ancestor(VALUE klass, VALUE super);
21 NORETURN(void rb_undefined_alloc(VALUE klass));
22double rb_num_to_dbl(VALUE val);
23 VALUE rb_obj_dig(int argc, VALUE *argv, VALUE self, VALUE notfound);
24 VALUE rb_immutable_obj_clone(int, VALUE *, VALUE);
25 VALUE rb_check_convert_type_with_id(VALUE,int,const char*,ID);
26int rb_bool_expected(VALUE, const char *);
27static inline void RBASIC_CLEAR_CLASS(VALUE obj);
28static inline void RBASIC_SET_CLASS_RAW(VALUE obj, VALUE klass);
29static inline void RBASIC_SET_CLASS(VALUE obj, VALUE klass);
30static inline struct st_table *ROBJECT_IV_INDEX_TBL_inline(VALUE obj);
31
32RUBY_SYMBOL_EXPORT_BEGIN
33/* object.c (export) */
34int rb_opts_exception_p(VALUE opts, int default_value);
35RUBY_SYMBOL_EXPORT_END
36
37 MJIT_SYMBOL_EXPORT_BEGIN
38 CONSTFUNC(VALUE rb_obj_equal(VALUE obj1, VALUE obj2));
39 CONSTFUNC(VALUE rb_obj_not(VALUE obj));
40 VALUE rb_obj_not_equal(VALUE obj1, VALUE obj2);
41void rb_obj_copy_ivar(VALUE dest, VALUE obj);
42 VALUE rb_false(VALUE obj);
43 VALUE rb_convert_type_with_id(VALUE v, int t, const char* nam, ID mid);
44 VALUE rb_obj_size(VALUE self, VALUE args, VALUE obj);
45 MJIT_SYMBOL_EXPORT_END
46
47static inline void
48RBASIC_SET_CLASS_RAW(VALUE obj, VALUE klass)
49{
50 struct { VALUE flags; VALUE klass; } *ptr = (void *)obj;
51 ptr->klass = klass;
52}
53
54static inline void
55RBASIC_CLEAR_CLASS(VALUE obj)
56{
57 RBASIC_SET_CLASS_RAW(obj, 0);
58}
59
60static inline void
61RBASIC_SET_CLASS(VALUE obj, VALUE klass)
62{
63 VALUE oldv = RBASIC_CLASS(obj);
64 RBASIC_SET_CLASS_RAW(obj, klass);
65 RB_OBJ_WRITTEN(obj, oldv, klass);
66}
67
68 RBIMPL_ATTR_PURE()
69static inline struct st_table *
70ROBJECT_IV_INDEX_TBL_inline(VALUE obj)
71{
72 if (RB_FL_ANY_RAW(obj, ROBJECT_EMBED)) {
73 VALUE klass = rb_obj_class(obj);
74 return RCLASS_IV_INDEX_TBL(klass);
75 }
76 else {
77 const struct RObject *const ptr = ROBJECT(obj);
78 return ptr->as.heap.iv_index_tbl;
79 }
80}
81#define ROBJECT_IV_INDEX_TBL ROBJECT_IV_INDEX_TBL_inline
82
83#endif /* INTERNAL_OBJECT_H */
CONSTFUNC
#define CONSTFUNC(x)
Definition: attributes.h:51
NORETURN
#define NORETURN(x)
Definition: attributes.h:152
ptr
struct RIMemo * ptr
Definition: debug.c:88
MJIT_SYMBOL_EXPORT_END
#define MJIT_SYMBOL_EXPORT_END
Definition: dllexport.h:63
MJIT_SYMBOL_EXPORT_BEGIN
#define MJIT_SYMBOL_EXPORT_BEGIN
Definition: dllexport.h:62
rb_obj_not_equal
VALUE rb_obj_not_equal(VALUE obj1, VALUE obj2)
Definition: object.c:220
rb_obj_dig
VALUE rb_obj_dig(int argc, VALUE *argv, VALUE self, VALUE notfound)
Definition: object.c:3812
rb_opts_exception_p
int rb_opts_exception_p(VALUE opts, int default_value)
Definition: object.c:3157
rb_num_to_dbl
double rb_num_to_dbl(VALUE val)
Definition: object.c:3593
rb_bool_expected
int rb_bool_expected(VALUE, const char *)
Definition: object.c:3144
rb_obj_equal
VALUE rb_obj_equal(VALUE obj1, VALUE obj2)
Definition: object.c:197
rb_undefined_alloc
void rb_undefined_alloc(VALUE klass)
Definition: object.c:1803
rb_obj_class
VALUE rb_obj_class(VALUE)
Definition: object.c:245
rb_obj_size
VALUE rb_obj_size(VALUE self, VALUE args, VALUE obj)
Definition: object.c:499
rb_check_convert_type_with_id
VALUE rb_check_convert_type_with_id(VALUE, int, const char *, ID)
Definition: object.c:2987
rb_convert_type_with_id
VALUE rb_convert_type_with_id(VALUE v, int t, const char *nam, ID mid)
Definition: object.c:2944
rb_obj_not
VALUE rb_obj_not(VALUE obj)
Definition: object.c:210
rb_immutable_obj_clone
VALUE rb_immutable_obj_clone(int, VALUE *, VALUE)
Definition: object.c:360
rb_class_search_ancestor
VALUE rb_class_search_ancestor(VALUE klass, VALUE super)
Definition: object.c:745
rb_false
VALUE rb_false(VALUE obj)
Definition: object.c:1395
rb_obj_copy_ivar
void rb_obj_copy_ivar(VALUE dest, VALUE obj)
Definition: object.c:275
class.h
Internal header for Class.
RCLASS_IV_INDEX_TBL
#define RCLASS_IV_INDEX_TBL(c)
Definition: class.h:86
RBIMPL_ATTR_PURE
#define RBIMPL_ATTR_PURE()
Wraps (or simulates) __attribute__((pure))
Definition: pure.h:33
RBASIC_CLASS
#define RBASIC_CLASS
Definition: rbasic.h:35
RB_OBJ_WRITTEN
#define RB_OBJ_WRITTEN(a, oldv, b)
WB for new reference from ‘a’ to ‘b’.
Definition: rgengc.h:114
ROBJECT
#define ROBJECT(obj)
Definition: robject.h:37
ROBJECT_EMBED
#define ROBJECT_EMBED
Definition: robject.h:39
ruby.h
argc
int argc
Definition: ruby.c:240
argv
char ** argv
Definition: ruby.c:241
RObject
Definition: robject.h:52
st_table
Definition: st.h:79
t
#define t
Definition: symbol.c:253
VALUE
unsigned long VALUE
Definition: value.h:38
ID
unsigned long ID
Definition: value.h:39