1 #ifndef INTERNAL_STRUCT_H /*-*-C-*-vi:se ft=c:*/
2 #define INTERNAL_STRUCT_H
5 * @author Ruby developers <ruby-core@ruby-lang.org>
6 * @copyright This file is a part of the programming language Ruby.
7 * Permission is hereby granted, to either redistribute and/or
8 * modify this file, provided that the conditions mentioned in the
9 * file COPYING are met. Consult the file for details.
10 * @brief Internal header for Struct.
12 #include "ruby/impl/stdbool.h" /* for bool */
13 #include "internal/gc.h" /* for RB_OBJ_WRITE */
14 #include "ruby/ruby.h" /* for struct RBasic */
17 RSTRUCT_EMBED_LEN_MAX
= RVALUE_EMBED_LEN_MAX
,
18 RSTRUCT_EMBED_LEN_MASK
= (RUBY_FL_USER2
|RUBY_FL_USER1
),
19 RSTRUCT_EMBED_LEN_SHIFT
= (RUBY_FL_USHIFT
+1),
20 RSTRUCT_TRANSIENT_FLAG
= FL_USER3
,
30 const VALUE ary
[RSTRUCT_EMBED_LEN_MAX
];
34 #define RSTRUCT(obj) (R_CAST(RStruct)(obj))
52 #define RSTRUCT_LEN internal_RSTRUCT_LEN
53 #define RSTRUCT_SET internal_RSTRUCT_SET
54 #define RSTRUCT_GET internal_RSTRUCT_GET
57 VALUE
rb_struct_init_copy(VALUE copy
, VALUE s
);
58 VALUE
rb_struct_lookup(VALUE s
, VALUE idx
);
59 VALUE
rb_struct_s_keyword_init(VALUE klass
);
60 static inline const VALUE
*rb_struct_const_heap_ptr(VALUE st
);
61 static inline bool RSTRUCT_TRANSIENT_P(VALUE st
);
62 static inline void RSTRUCT_TRANSIENT_SET(VALUE st
);
63 static inline void RSTRUCT_TRANSIENT_UNSET(VALUE st
);
64 static inline long RSTRUCT_EMBED_LEN(VALUE st
);
65 static inline long RSTRUCT_LEN(VALUE st
);
66 static inline int RSTRUCT_LENINT(VALUE st
);
67 static inline const VALUE
*RSTRUCT_CONST_PTR(VALUE st
);
68 static inline void RSTRUCT_SET(VALUE st
, long k
, VALUE v
);
69 static inline VALUE
RSTRUCT_GET(VALUE st
, long k
);
72 RSTRUCT_TRANSIENT_P(VALUE st
)
74 #if USE_TRANSIENT_HEAP
75 return FL_TEST_RAW(st
, RSTRUCT_TRANSIENT_FLAG
);