datadog-ruby_core_source 3.4.0 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.datadog.md +4 -0
- data/README.md +8 -5
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/ccan/build_assert/build_assert.h +40 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/ccan/check_type/check_type.h +63 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/ccan/container_of/container_of.h +142 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/ccan/list/list.h +791 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/ccan/str/str.h +17 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/id.h +352 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/id_table.h +39 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/array.h +152 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/basic_operators.h +65 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/bignum.h +244 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/bits.h +650 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/class.h +283 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/cmdlineopt.h +61 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/compar.h +29 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/compile.h +34 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/compilers.h +107 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/complex.h +29 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/cont.h +35 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/dir.h +16 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/enc.h +19 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/encoding.h +38 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/enum.h +18 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/enumerator.h +21 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/error.h +244 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/eval.h +33 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/file.h +38 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/fixnum.h +185 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/gc.h +333 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/hash.h +193 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/imemo.h +257 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/inits.h +47 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/io.h +143 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/load.h +18 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/loadpath.h +16 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/math.h +23 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/missing.h +19 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/numeric.h +274 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/object.h +63 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/parse.h +131 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/proc.h +30 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/process.h +124 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/ractor.h +10 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/random.h +17 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/range.h +40 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/rational.h +71 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/re.h +28 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/ruby_parser.h +102 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/sanitizers.h +330 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/serial.h +23 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/signal.h +24 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/st.h +11 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/static_assert.h +16 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/string.h +199 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/struct.h +119 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/symbol.h +47 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/thread.h +108 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/time.h +37 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/transcode.h +23 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/util.h +27 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/variable.h +70 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/vm.h +137 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal/warnings.h +16 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/internal.h +108 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/iseq.h +351 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/method.h +258 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/node.h +122 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/parser_st.h +162 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/parser_value.h +106 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/ast.h +7964 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/defines.h +260 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/diagnostic.h +451 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/encoding.h +283 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/extension.h +19 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/node.h +129 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/options.h +442 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/pack.h +163 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/parser.h +933 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/prettyprint.h +34 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/prism.h +383 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/regexp.h +43 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/static_literals.h +121 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/util/pm_buffer.h +228 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/util/pm_char.h +204 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/util/pm_constant_pool.h +218 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/util/pm_integer.h +126 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/util/pm_list.h +97 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/util/pm_memchr.h +29 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/util/pm_newline_list.h +113 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/util/pm_string.h +190 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/util/pm_strncasecmp.h +32 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/util/pm_strpbrk.h +46 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism/version.h +29 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/prism_compile.h +105 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/ractor_core.h +382 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/ruby_assert.h +14 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/ruby_atomic.h +23 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/rubyparser.h +1380 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/shape.h +234 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/thread_none.h +21 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/thread_pthread.h +167 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/vm_core.h +2235 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/vm_debug.h +124 -0
- data/lib/datadog/ruby_core_source/ruby-3.5.0-preview1/vm_opts.h +67 -0
- data/lib/datadog/ruby_core_source/version.rb +1 -1
- metadata +105 -2
@@ -0,0 +1,258 @@
|
|
1
|
+
#ifndef RUBY_METHOD_H
|
2
|
+
#define RUBY_METHOD_H 1
|
3
|
+
/**********************************************************************
|
4
|
+
|
5
|
+
method.h -
|
6
|
+
|
7
|
+
$Author$
|
8
|
+
created at: Wed Jul 15 20:02:33 2009
|
9
|
+
|
10
|
+
Copyright (C) 2009 Koichi Sasada
|
11
|
+
|
12
|
+
**********************************************************************/
|
13
|
+
|
14
|
+
#include "internal.h"
|
15
|
+
#include "internal/imemo.h"
|
16
|
+
#include "internal/compilers.h"
|
17
|
+
#include "internal/static_assert.h"
|
18
|
+
#include "ruby/atomic.h"
|
19
|
+
|
20
|
+
#ifndef END_OF_ENUMERATION
|
21
|
+
# if defined(__GNUC__) &&! defined(__STRICT_ANSI__)
|
22
|
+
# define END_OF_ENUMERATION(key)
|
23
|
+
# else
|
24
|
+
# define END_OF_ENUMERATION(key) END_OF_##key##_PLACEHOLDER = 0
|
25
|
+
# endif
|
26
|
+
#endif
|
27
|
+
|
28
|
+
/* cref */
|
29
|
+
|
30
|
+
typedef enum {
|
31
|
+
METHOD_VISI_UNDEF = 0x00,
|
32
|
+
METHOD_VISI_PUBLIC = 0x01,
|
33
|
+
METHOD_VISI_PRIVATE = 0x02,
|
34
|
+
METHOD_VISI_PROTECTED = 0x03,
|
35
|
+
|
36
|
+
METHOD_VISI_MASK = 0x03
|
37
|
+
} rb_method_visibility_t;
|
38
|
+
|
39
|
+
typedef struct rb_scope_visi_struct {
|
40
|
+
BITFIELD(rb_method_visibility_t, method_visi, 3);
|
41
|
+
unsigned int module_func : 1;
|
42
|
+
} rb_scope_visibility_t;
|
43
|
+
|
44
|
+
/*! CREF (Class REFerence) */
|
45
|
+
typedef struct rb_cref_struct {
|
46
|
+
VALUE flags;
|
47
|
+
VALUE refinements;
|
48
|
+
VALUE klass_or_self;
|
49
|
+
struct rb_cref_struct * next;
|
50
|
+
const rb_scope_visibility_t scope_visi;
|
51
|
+
} rb_cref_t;
|
52
|
+
|
53
|
+
/* method data type */
|
54
|
+
|
55
|
+
typedef struct rb_method_entry_struct {
|
56
|
+
VALUE flags;
|
57
|
+
VALUE defined_class;
|
58
|
+
struct rb_method_definition_struct * const def;
|
59
|
+
ID called_id;
|
60
|
+
VALUE owner;
|
61
|
+
} rb_method_entry_t;
|
62
|
+
|
63
|
+
typedef struct rb_callable_method_entry_struct { /* same fields with rb_method_entry_t */
|
64
|
+
VALUE flags;
|
65
|
+
const VALUE defined_class;
|
66
|
+
struct rb_method_definition_struct * const def;
|
67
|
+
ID called_id;
|
68
|
+
const VALUE owner;
|
69
|
+
} rb_callable_method_entry_t;
|
70
|
+
|
71
|
+
#define METHOD_ENTRY_VISI(me) (rb_method_visibility_t)(((me)->flags & (IMEMO_FL_USER0 | IMEMO_FL_USER1)) >> (IMEMO_FL_USHIFT+0))
|
72
|
+
#define METHOD_ENTRY_BASIC(me) (int) (((me)->flags & (IMEMO_FL_USER2 )) >> (IMEMO_FL_USHIFT+2))
|
73
|
+
#define METHOD_ENTRY_COMPLEMENTED(me) ((me)->flags & IMEMO_FL_USER3)
|
74
|
+
#define METHOD_ENTRY_COMPLEMENTED_SET(me) ((me)->flags |= IMEMO_FL_USER3)
|
75
|
+
#define METHOD_ENTRY_CACHED(me) ((me)->flags & IMEMO_FL_USER4)
|
76
|
+
#define METHOD_ENTRY_CACHED_SET(me) ((me)->flags |= IMEMO_FL_USER4)
|
77
|
+
#define METHOD_ENTRY_INVALIDATED(me) ((me)->flags & IMEMO_FL_USER5)
|
78
|
+
#define METHOD_ENTRY_INVALIDATED_SET(me) ((me)->flags |= IMEMO_FL_USER5)
|
79
|
+
|
80
|
+
static inline void
|
81
|
+
METHOD_ENTRY_VISI_SET(rb_method_entry_t *me, rb_method_visibility_t visi)
|
82
|
+
{
|
83
|
+
VM_ASSERT((int)visi >= 0 && visi <= 3);
|
84
|
+
me->flags = (me->flags & ~(IMEMO_FL_USER0 | IMEMO_FL_USER1)) | (visi << (IMEMO_FL_USHIFT+0));
|
85
|
+
}
|
86
|
+
static inline void
|
87
|
+
METHOD_ENTRY_BASIC_SET(rb_method_entry_t *me, unsigned int basic)
|
88
|
+
{
|
89
|
+
VM_ASSERT(basic <= 1);
|
90
|
+
me->flags = (me->flags & ~(IMEMO_FL_USER2 )) | (basic << (IMEMO_FL_USHIFT+2));
|
91
|
+
}
|
92
|
+
static inline void
|
93
|
+
METHOD_ENTRY_FLAGS_SET(rb_method_entry_t *me, rb_method_visibility_t visi, unsigned int basic)
|
94
|
+
{
|
95
|
+
VM_ASSERT((int)visi >= 0 && visi <= 3);
|
96
|
+
VM_ASSERT(basic <= 1);
|
97
|
+
me->flags =
|
98
|
+
(me->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
|
99
|
+
((visi << (IMEMO_FL_USHIFT+0)) | (basic << (IMEMO_FL_USHIFT+2)));
|
100
|
+
}
|
101
|
+
static inline void
|
102
|
+
METHOD_ENTRY_FLAGS_COPY(rb_method_entry_t *dst, const rb_method_entry_t *src)
|
103
|
+
{
|
104
|
+
dst->flags =
|
105
|
+
(dst->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2
|
106
|
+
|IMEMO_FL_USER3)) |
|
107
|
+
(src->flags & (IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2|IMEMO_FL_USER3));
|
108
|
+
}
|
109
|
+
|
110
|
+
typedef enum {
|
111
|
+
VM_METHOD_TYPE_ISEQ, /*!< Ruby method */
|
112
|
+
VM_METHOD_TYPE_CFUNC, /*!< C method */
|
113
|
+
VM_METHOD_TYPE_ATTRSET, /*!< attr_writer or attr_accessor */
|
114
|
+
VM_METHOD_TYPE_IVAR, /*!< attr_reader or attr_accessor */
|
115
|
+
VM_METHOD_TYPE_BMETHOD,
|
116
|
+
VM_METHOD_TYPE_ZSUPER,
|
117
|
+
VM_METHOD_TYPE_ALIAS,
|
118
|
+
VM_METHOD_TYPE_UNDEF,
|
119
|
+
VM_METHOD_TYPE_NOTIMPLEMENTED,
|
120
|
+
VM_METHOD_TYPE_OPTIMIZED, /*!< Kernel#send, Proc#call, etc */
|
121
|
+
VM_METHOD_TYPE_MISSING, /*!< wrapper for method_missing(id) */
|
122
|
+
VM_METHOD_TYPE_REFINED, /*!< refinement */
|
123
|
+
|
124
|
+
END_OF_ENUMERATION(VM_METHOD_TYPE)
|
125
|
+
} rb_method_type_t;
|
126
|
+
#define VM_METHOD_TYPE_MINIMUM_BITS 4
|
127
|
+
STATIC_ASSERT(VM_METHOD_TYPE_MINIMUM_BITS,
|
128
|
+
VM_METHOD_TYPE_REFINED <= (1<<VM_METHOD_TYPE_MINIMUM_BITS));
|
129
|
+
|
130
|
+
#ifndef rb_iseq_t
|
131
|
+
typedef struct rb_iseq_struct rb_iseq_t;
|
132
|
+
#define rb_iseq_t rb_iseq_t
|
133
|
+
#endif
|
134
|
+
|
135
|
+
typedef struct rb_method_iseq_struct {
|
136
|
+
const rb_iseq_t * iseqptr; /*!< iseq pointer, should be separated from iseqval */
|
137
|
+
rb_cref_t * cref; /*!< class reference, should be marked */
|
138
|
+
} rb_method_iseq_t; /* check rb_add_method_iseq() when modify the fields */
|
139
|
+
|
140
|
+
typedef VALUE (*rb_cfunc_t)(ANYARGS);
|
141
|
+
typedef struct rb_method_cfunc_struct {
|
142
|
+
rb_cfunc_t func;
|
143
|
+
VALUE (*invoker)(VALUE recv, int argc, const VALUE *argv, VALUE (*func)(ANYARGS));
|
144
|
+
int argc;
|
145
|
+
} rb_method_cfunc_t;
|
146
|
+
|
147
|
+
typedef struct rb_method_attr_struct {
|
148
|
+
ID id;
|
149
|
+
VALUE location; /* should be marked */
|
150
|
+
} rb_method_attr_t;
|
151
|
+
|
152
|
+
typedef struct rb_method_alias_struct {
|
153
|
+
struct rb_method_entry_struct * original_me; /* original_me->klass is original owner */
|
154
|
+
} rb_method_alias_t;
|
155
|
+
|
156
|
+
typedef struct rb_method_refined_struct {
|
157
|
+
struct rb_method_entry_struct * orig_me;
|
158
|
+
} rb_method_refined_t;
|
159
|
+
|
160
|
+
typedef struct rb_method_bmethod_struct {
|
161
|
+
VALUE proc; /* should be marked */
|
162
|
+
struct rb_hook_list_struct *hooks;
|
163
|
+
VALUE defined_ractor;
|
164
|
+
} rb_method_bmethod_t;
|
165
|
+
|
166
|
+
enum method_optimized_type {
|
167
|
+
OPTIMIZED_METHOD_TYPE_SEND,
|
168
|
+
OPTIMIZED_METHOD_TYPE_CALL,
|
169
|
+
OPTIMIZED_METHOD_TYPE_BLOCK_CALL,
|
170
|
+
OPTIMIZED_METHOD_TYPE_STRUCT_AREF,
|
171
|
+
OPTIMIZED_METHOD_TYPE_STRUCT_ASET,
|
172
|
+
OPTIMIZED_METHOD_TYPE__MAX
|
173
|
+
};
|
174
|
+
|
175
|
+
typedef struct rb_method_optimized {
|
176
|
+
enum method_optimized_type type;
|
177
|
+
unsigned int index;
|
178
|
+
} rb_method_optimized_t;
|
179
|
+
|
180
|
+
struct rb_method_definition_struct {
|
181
|
+
BITFIELD(rb_method_type_t, type, VM_METHOD_TYPE_MINIMUM_BITS);
|
182
|
+
unsigned int iseq_overload: 1;
|
183
|
+
unsigned int no_redef_warning: 1;
|
184
|
+
unsigned int aliased : 1;
|
185
|
+
|
186
|
+
rb_atomic_t reference_count;
|
187
|
+
|
188
|
+
union {
|
189
|
+
rb_method_iseq_t iseq;
|
190
|
+
rb_method_cfunc_t cfunc;
|
191
|
+
rb_method_attr_t attr;
|
192
|
+
rb_method_alias_t alias;
|
193
|
+
rb_method_refined_t refined;
|
194
|
+
rb_method_bmethod_t bmethod;
|
195
|
+
rb_method_optimized_t optimized;
|
196
|
+
} body;
|
197
|
+
|
198
|
+
ID original_id;
|
199
|
+
uintptr_t method_serial;
|
200
|
+
};
|
201
|
+
|
202
|
+
struct rb_id_table;
|
203
|
+
|
204
|
+
typedef struct rb_method_definition_struct rb_method_definition_t;
|
205
|
+
STATIC_ASSERT(sizeof_method_def, offsetof(rb_method_definition_t, body) <= 8);
|
206
|
+
|
207
|
+
#define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
|
208
|
+
#define UNDEFINED_REFINED_METHOD_P(def) \
|
209
|
+
((def)->type == VM_METHOD_TYPE_REFINED && \
|
210
|
+
UNDEFINED_METHOD_ENTRY_P((def)->body.refined.orig_me))
|
211
|
+
|
212
|
+
void rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_visibility_t visi);
|
213
|
+
void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_visibility_t visi);
|
214
|
+
void rb_add_method_iseq(VALUE klass, ID mid, const rb_iseq_t *iseq, rb_cref_t *cref, rb_method_visibility_t visi);
|
215
|
+
void rb_add_method_optimized(VALUE klass, ID mid, enum method_optimized_type, unsigned int index, rb_method_visibility_t visi);
|
216
|
+
void rb_add_refined_method_entry(VALUE refined_class, ID mid);
|
217
|
+
|
218
|
+
rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_visibility_t noex);
|
219
|
+
rb_method_entry_t *rb_method_entry_create(ID called_id, VALUE klass, rb_method_visibility_t visi, rb_method_definition_t *def);
|
220
|
+
|
221
|
+
const rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id);
|
222
|
+
|
223
|
+
const rb_method_entry_t *rb_method_entry(VALUE klass, ID id);
|
224
|
+
const rb_method_entry_t *rb_method_entry_with_refinements(VALUE klass, ID id, VALUE *defined_class);
|
225
|
+
const rb_method_entry_t *rb_method_entry_without_refinements(VALUE klass, ID id, VALUE *defined_class);
|
226
|
+
const rb_method_entry_t *rb_resolve_refined_method(VALUE refinements, const rb_method_entry_t *me);
|
227
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
228
|
+
const rb_method_entry_t *rb_resolve_me_location(const rb_method_entry_t *, VALUE[5]);
|
229
|
+
RUBY_SYMBOL_EXPORT_END
|
230
|
+
|
231
|
+
const rb_callable_method_entry_t *rb_callable_method_entry(VALUE klass, ID id);
|
232
|
+
const rb_callable_method_entry_t *rb_callable_method_entry_or_negative(VALUE klass, ID id);
|
233
|
+
const rb_callable_method_entry_t *rb_callable_method_entry_with_refinements(VALUE klass, ID id, VALUE *defined_class);
|
234
|
+
const rb_callable_method_entry_t *rb_callable_method_entry_without_refinements(VALUE klass, ID id, VALUE *defined_class);
|
235
|
+
|
236
|
+
int rb_method_entry_arity(const rb_method_entry_t *me);
|
237
|
+
int rb_method_entry_eq(const rb_method_entry_t *m1, const rb_method_entry_t *m2);
|
238
|
+
st_index_t rb_hash_method_entry(st_index_t hash, const rb_method_entry_t *me);
|
239
|
+
|
240
|
+
VALUE rb_method_entry_location(const rb_method_entry_t *me);
|
241
|
+
|
242
|
+
void rb_free_method_entry_vm_weak_references(const rb_method_entry_t *me);
|
243
|
+
void rb_free_method_entry(const rb_method_entry_t *me);
|
244
|
+
|
245
|
+
const rb_method_entry_t *rb_method_entry_clone(const rb_method_entry_t *me);
|
246
|
+
const rb_callable_method_entry_t *rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID called_id, VALUE defined_class);
|
247
|
+
void rb_method_entry_copy(rb_method_entry_t *dst, const rb_method_entry_t *src);
|
248
|
+
|
249
|
+
void rb_method_table_insert(VALUE klass, struct rb_id_table *table, ID method_id, const rb_method_entry_t *me);
|
250
|
+
|
251
|
+
void rb_scope_visibility_set(rb_method_visibility_t);
|
252
|
+
|
253
|
+
VALUE rb_unnamed_parameters(int arity);
|
254
|
+
|
255
|
+
void rb_clear_method_cache(VALUE klass_or_module, ID mid);
|
256
|
+
void rb_clear_all_refinement_method_cache(void);
|
257
|
+
|
258
|
+
#endif /* RUBY_METHOD_H */
|
@@ -0,0 +1,122 @@
|
|
1
|
+
#ifndef RUBY_NODE_H
|
2
|
+
#define RUBY_NODE_H 1
|
3
|
+
/**********************************************************************
|
4
|
+
|
5
|
+
node.h -
|
6
|
+
|
7
|
+
$Author$
|
8
|
+
created at: Fri May 28 15:14:02 JST 1993
|
9
|
+
|
10
|
+
Copyright (C) 1993-2007 Yukihiro Matsumoto
|
11
|
+
|
12
|
+
**********************************************************************/
|
13
|
+
|
14
|
+
#include <stdbool.h>
|
15
|
+
#include "rubyparser.h"
|
16
|
+
#include "ruby/backward/2/attributes.h"
|
17
|
+
|
18
|
+
typedef void (*bug_report_func)(const char *fmt, ...) RUBYPARSER_ATTRIBUTE_FORMAT(1, 2);
|
19
|
+
typedef struct node_buffer_elem_struct {
|
20
|
+
struct node_buffer_elem_struct *next;
|
21
|
+
long len; /* Length of nodes */
|
22
|
+
size_t allocated; /* Total memory size of allocated buf */
|
23
|
+
size_t used; /* Current usage of buf */
|
24
|
+
NODE **nodes; /* Array of node pointers */
|
25
|
+
NODE *buf[FLEX_ARY_LEN];
|
26
|
+
} node_buffer_elem_t;
|
27
|
+
|
28
|
+
typedef struct {
|
29
|
+
node_buffer_elem_t *head;
|
30
|
+
node_buffer_elem_t *last;
|
31
|
+
} node_buffer_list_t;
|
32
|
+
|
33
|
+
struct node_buffer_struct {
|
34
|
+
node_buffer_list_t buffer_list;
|
35
|
+
struct rb_ast_local_table_link *local_tables;
|
36
|
+
// - id (sequence number)
|
37
|
+
// - token_type
|
38
|
+
// - text of token
|
39
|
+
// - location info
|
40
|
+
// Array, whose entry is array
|
41
|
+
rb_parser_ary_t *tokens;
|
42
|
+
};
|
43
|
+
|
44
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
45
|
+
|
46
|
+
#ifdef UNIVERSAL_PARSER
|
47
|
+
rb_ast_t *rb_ast_new(const rb_parser_config_t *config);
|
48
|
+
#else
|
49
|
+
rb_ast_t *rb_ast_new(void);
|
50
|
+
#endif
|
51
|
+
size_t rb_ast_memsize(const rb_ast_t*);
|
52
|
+
void rb_ast_dispose(rb_ast_t*);
|
53
|
+
const char *ruby_node_name(int node);
|
54
|
+
void rb_node_init(NODE *n, enum node_type type);
|
55
|
+
|
56
|
+
void rb_ast_update_references(rb_ast_t*);
|
57
|
+
void rb_ast_free(rb_ast_t*);
|
58
|
+
NODE *rb_ast_newnode(rb_ast_t*, enum node_type type, size_t size, size_t alignment);
|
59
|
+
void rb_ast_delete_node(rb_ast_t*, NODE *n);
|
60
|
+
rb_ast_id_table_t *rb_ast_new_local_table(rb_ast_t*, int);
|
61
|
+
rb_ast_id_table_t *rb_ast_resize_latest_local_table(rb_ast_t*, int);
|
62
|
+
|
63
|
+
VALUE rb_parser_dump_tree(const NODE *node, int comment);
|
64
|
+
|
65
|
+
const struct kwtable *rb_reserved_word(const char *, unsigned int);
|
66
|
+
|
67
|
+
struct parser_params;
|
68
|
+
PRINTF_ARGS(void rb_parser_printf(struct parser_params *parser, const char *fmt, ...), 2, 3);
|
69
|
+
VALUE rb_node_set_type(NODE *n, enum node_type t);
|
70
|
+
enum node_type rb_node_get_type(const NODE *n);
|
71
|
+
|
72
|
+
RUBY_SYMBOL_EXPORT_END
|
73
|
+
|
74
|
+
#define NODE_LSHIFT (NODE_TYPESHIFT+7)
|
75
|
+
#define NODE_LMASK (((SIGNED_VALUE)1<<(sizeof(VALUE)*CHAR_BIT-NODE_LSHIFT))-1)
|
76
|
+
|
77
|
+
static inline int
|
78
|
+
nd_line(const NODE *n)
|
79
|
+
{
|
80
|
+
if (!n) return -1;
|
81
|
+
SIGNED_VALUE flags = (SIGNED_VALUE)n->flags;
|
82
|
+
return (int)(flags >> NODE_LSHIFT);
|
83
|
+
}
|
84
|
+
|
85
|
+
static inline void
|
86
|
+
nd_set_line(NODE *n, SIGNED_VALUE l)
|
87
|
+
{
|
88
|
+
n->flags &= ~(~(VALUE)0 << NODE_LSHIFT);
|
89
|
+
n->flags |= ((VALUE)(l & NODE_LMASK) << NODE_LSHIFT);
|
90
|
+
}
|
91
|
+
|
92
|
+
#define NODE_SPECIAL_REQUIRED_KEYWORD ((NODE *)-1)
|
93
|
+
#define NODE_REQUIRED_KEYWORD_P(node) ((node) == NODE_SPECIAL_REQUIRED_KEYWORD)
|
94
|
+
#define NODE_SPECIAL_NO_NAME_REST ((NODE *)-1)
|
95
|
+
#define NODE_NAMED_REST_P(node) ((node) != NODE_SPECIAL_NO_NAME_REST)
|
96
|
+
#define NODE_SPECIAL_EXCESSIVE_COMMA ((ID)1)
|
97
|
+
#define NODE_SPECIAL_NO_REST_KEYWORD ((NODE *)-1)
|
98
|
+
|
99
|
+
#define nd_code_loc(n) (&RNODE(n)->nd_loc)
|
100
|
+
#define nd_first_column(n) ((int)(RNODE(n)->nd_loc.beg_pos.column))
|
101
|
+
#define nd_set_first_column(n, v) (RNODE(n)->nd_loc.beg_pos.column = (v))
|
102
|
+
#define nd_first_lineno(n) ((int)(RNODE(n)->nd_loc.beg_pos.lineno))
|
103
|
+
#define nd_set_first_lineno(n, v) (RNODE(n)->nd_loc.beg_pos.lineno = (v))
|
104
|
+
#define nd_first_loc(n) (RNODE(n)->nd_loc.beg_pos)
|
105
|
+
#define nd_set_first_loc(n, v) (nd_first_loc(n) = (v))
|
106
|
+
|
107
|
+
#define nd_last_column(n) ((int)(RNODE(n)->nd_loc.end_pos.column))
|
108
|
+
#define nd_set_last_column(n, v) (RNODE(n)->nd_loc.end_pos.column = (v))
|
109
|
+
#define nd_last_lineno(n) ((int)(RNODE(n)->nd_loc.end_pos.lineno))
|
110
|
+
#define nd_set_last_lineno(n, v) (RNODE(n)->nd_loc.end_pos.lineno = (v))
|
111
|
+
#define nd_last_loc(n) (RNODE(n)->nd_loc.end_pos)
|
112
|
+
#define nd_set_last_loc(n, v) (nd_last_loc(n) = (v))
|
113
|
+
#define nd_node_id(n) (RNODE(n)->node_id)
|
114
|
+
#define nd_set_node_id(n,id) (RNODE(n)->node_id = (id))
|
115
|
+
|
116
|
+
static inline bool
|
117
|
+
nd_type_p(const NODE *n, enum node_type t)
|
118
|
+
{
|
119
|
+
return (enum node_type)nd_type(n) == t;
|
120
|
+
}
|
121
|
+
|
122
|
+
#endif /* RUBY_NODE_H */
|
@@ -0,0 +1,162 @@
|
|
1
|
+
/* This is a public domain general purpose hash table package
|
2
|
+
originally written by Peter Moore @ UCB.
|
3
|
+
|
4
|
+
The hash table data structures were redesigned and the package was
|
5
|
+
rewritten by Vladimir Makarov <vmakarov@redhat.com>. */
|
6
|
+
|
7
|
+
#ifndef RUBY_ST2_H
|
8
|
+
#define RUBY_ST2_H 1
|
9
|
+
|
10
|
+
#if defined(__cplusplus)
|
11
|
+
extern "C" {
|
12
|
+
#if 0
|
13
|
+
} /* satisfy cc-mode */
|
14
|
+
#endif
|
15
|
+
#endif
|
16
|
+
|
17
|
+
#include <stddef.h>
|
18
|
+
#include <stdint.h>
|
19
|
+
#include "ruby/config.h"
|
20
|
+
#include "ruby/backward/2/long_long.h"
|
21
|
+
#include "ruby/defines.h"
|
22
|
+
|
23
|
+
RUBY_SYMBOL_EXPORT_BEGIN
|
24
|
+
|
25
|
+
#if SIZEOF_LONG == SIZEOF_VOIDP
|
26
|
+
typedef unsigned long parser_st_data_t;
|
27
|
+
#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
|
28
|
+
typedef unsigned LONG_LONG parser_st_data_t;
|
29
|
+
#else
|
30
|
+
# error ---->> parser_st.c requires sizeof(void*) == sizeof(long) or sizeof(LONG_LONG) to be compiled. <<----
|
31
|
+
#endif
|
32
|
+
#define ST2_DATA_T_DEFINED
|
33
|
+
|
34
|
+
#ifndef CHAR_BIT
|
35
|
+
# ifdef HAVE_LIMITS_H
|
36
|
+
# include <limits.h>
|
37
|
+
# else
|
38
|
+
# define CHAR_BIT 8
|
39
|
+
# endif
|
40
|
+
#endif
|
41
|
+
#ifndef _
|
42
|
+
# define _(args) args
|
43
|
+
#endif
|
44
|
+
#ifndef ANYARGS
|
45
|
+
# ifdef __cplusplus
|
46
|
+
# define ANYARGS ...
|
47
|
+
# else
|
48
|
+
# define ANYARGS
|
49
|
+
# endif
|
50
|
+
#endif
|
51
|
+
|
52
|
+
typedef struct parser_st_table parser_st_table;
|
53
|
+
|
54
|
+
typedef parser_st_data_t parser_st_index_t;
|
55
|
+
|
56
|
+
/* Maximal value of unsigned integer type parser_st_index_t. */
|
57
|
+
#define MAX_ST2_INDEX_VAL (~(parser_st_index_t) 0)
|
58
|
+
|
59
|
+
typedef int parser_st_compare_func(parser_st_data_t, parser_st_data_t);
|
60
|
+
typedef parser_st_index_t parser_st_hash_func(parser_st_data_t);
|
61
|
+
|
62
|
+
typedef char st_check_for_sizeof_parser_st_index_t[SIZEOF_VOIDP == (int)sizeof(parser_st_index_t) ? 1 : -1];
|
63
|
+
#define SIZEOF_ST_INDEX_T SIZEOF_VOIDP
|
64
|
+
|
65
|
+
struct parser_st_hash_type {
|
66
|
+
int (*compare)(parser_st_data_t, parser_st_data_t); /* parser_st_compare_func* */
|
67
|
+
parser_st_index_t (*hash)(parser_st_data_t); /* parser_st_hash_func* */
|
68
|
+
};
|
69
|
+
|
70
|
+
#define ST_INDEX_BITS (SIZEOF_ST_INDEX_T * CHAR_BIT)
|
71
|
+
|
72
|
+
#if defined(HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR) && defined(HAVE_BUILTIN___BUILTIN_TYPES_COMPATIBLE_P)
|
73
|
+
# define ST2_DATA_COMPATIBLE_P(type) \
|
74
|
+
__builtin_choose_expr(__builtin_types_compatible_p(type, parser_st_data_t), 1, 0)
|
75
|
+
#else
|
76
|
+
# define ST2_DATA_COMPATIBLE_P(type) 0
|
77
|
+
#endif
|
78
|
+
|
79
|
+
typedef struct parser_st_table_entry parser_st_table_entry;
|
80
|
+
|
81
|
+
struct parser_st_table_entry; /* defined in parser_st.c */
|
82
|
+
|
83
|
+
struct parser_st_table {
|
84
|
+
/* Cached features of the table -- see st.c for more details. */
|
85
|
+
unsigned char entry_power, bin_power, size_ind;
|
86
|
+
/* How many times the table was rebuilt. */
|
87
|
+
unsigned int rebuilds_num;
|
88
|
+
const struct parser_st_hash_type *type;
|
89
|
+
/* Number of entries currently in the table. */
|
90
|
+
parser_st_index_t num_entries;
|
91
|
+
/* Array of bins used for access by keys. */
|
92
|
+
parser_st_index_t *bins;
|
93
|
+
/* Start and bound index of entries in array entries.
|
94
|
+
entries_starts and entries_bound are in interval
|
95
|
+
[0,allocated_entries]. */
|
96
|
+
parser_st_index_t entries_start, entries_bound;
|
97
|
+
/* Array of size 2^entry_power. */
|
98
|
+
parser_st_table_entry *entries;
|
99
|
+
};
|
100
|
+
|
101
|
+
#define parser_st_is_member(table,key) rb_parser_st_lookup((table),(key),(parser_st_data_t *)0)
|
102
|
+
|
103
|
+
enum parser_st_retval {ST2_CONTINUE, ST2_STOP, ST2_DELETE, ST2_CHECK, ST2_REPLACE};
|
104
|
+
|
105
|
+
size_t rb_parser_st_table_size(const struct parser_st_table *tbl);
|
106
|
+
parser_st_table *rb_parser_st_init_table(const struct parser_st_hash_type *);
|
107
|
+
parser_st_table *rb_parser_st_init_table_with_size(const struct parser_st_hash_type *, parser_st_index_t);
|
108
|
+
parser_st_table *rb_parser_st_init_existing_table_with_size(parser_st_table *, const struct parser_st_hash_type *, parser_st_index_t);
|
109
|
+
parser_st_table *rb_parser_st_init_numtable(void);
|
110
|
+
parser_st_table *rb_parser_st_init_numtable_with_size(parser_st_index_t);
|
111
|
+
parser_st_table *rb_parser_st_init_strtable(void);
|
112
|
+
parser_st_table *rb_parser_st_init_strtable_with_size(parser_st_index_t);
|
113
|
+
parser_st_table *rb_parser_st_init_strcasetable(void);
|
114
|
+
parser_st_table *rb_parser_st_init_strcasetable_with_size(parser_st_index_t);
|
115
|
+
int rb_parser_st_delete(parser_st_table *, parser_st_data_t *, parser_st_data_t *); /* returns 0:notfound 1:deleted */
|
116
|
+
int rb_parser_st_delete_safe(parser_st_table *, parser_st_data_t *, parser_st_data_t *, parser_st_data_t);
|
117
|
+
int rb_parser_st_shift(parser_st_table *, parser_st_data_t *, parser_st_data_t *); /* returns 0:notfound 1:deleted */
|
118
|
+
int rb_parser_st_insert(parser_st_table *, parser_st_data_t, parser_st_data_t);
|
119
|
+
int rb_parser_st_insert2(parser_st_table *, parser_st_data_t, parser_st_data_t, parser_st_data_t (*)(parser_st_data_t));
|
120
|
+
int rb_parser_st_lookup(parser_st_table *, parser_st_data_t, parser_st_data_t *);
|
121
|
+
int rb_parser_st_get_key(parser_st_table *, parser_st_data_t, parser_st_data_t *);
|
122
|
+
typedef int parser_st_update_callback_func(parser_st_data_t *key, parser_st_data_t *value, parser_st_data_t arg, int existing);
|
123
|
+
/* *key may be altered, but must equal to the old key, i.e., the
|
124
|
+
* results of hash() are same and compare() returns 0, otherwise the
|
125
|
+
* behavior is undefined */
|
126
|
+
int rb_parser_st_update(parser_st_table *table, parser_st_data_t key, parser_st_update_callback_func *func, parser_st_data_t arg);
|
127
|
+
typedef int parser_st_foreach_callback_func(parser_st_data_t, parser_st_data_t, parser_st_data_t);
|
128
|
+
typedef int parser_st_foreach_check_callback_func(parser_st_data_t, parser_st_data_t, parser_st_data_t, int);
|
129
|
+
int rb_parser_st_foreach_with_replace(parser_st_table *tab, parser_st_foreach_check_callback_func *func, parser_st_update_callback_func *replace, parser_st_data_t arg);
|
130
|
+
int rb_parser_st_foreach(parser_st_table *, parser_st_foreach_callback_func *, parser_st_data_t);
|
131
|
+
int rb_parser_st_foreach_check(parser_st_table *, parser_st_foreach_check_callback_func *, parser_st_data_t, parser_st_data_t);
|
132
|
+
parser_st_index_t rb_parser_st_keys(parser_st_table *table, parser_st_data_t *keys, parser_st_index_t size);
|
133
|
+
parser_st_index_t rb_parser_st_keys_check(parser_st_table *table, parser_st_data_t *keys, parser_st_index_t size, parser_st_data_t never);
|
134
|
+
parser_st_index_t rb_parser_st_values(parser_st_table *table, parser_st_data_t *values, parser_st_index_t size);
|
135
|
+
parser_st_index_t rb_parser_st_values_check(parser_st_table *table, parser_st_data_t *values, parser_st_index_t size, parser_st_data_t never);
|
136
|
+
void rb_parser_st_add_direct(parser_st_table *, parser_st_data_t, parser_st_data_t);
|
137
|
+
void rb_parser_st_free_table(parser_st_table *);
|
138
|
+
void rb_parser_st_cleanup_safe(parser_st_table *, parser_st_data_t);
|
139
|
+
void rb_parser_st_clear(parser_st_table *);
|
140
|
+
parser_st_table *rb_parser_st_replace(parser_st_table *, parser_st_table *);
|
141
|
+
parser_st_table *rb_parser_st_copy(parser_st_table *);
|
142
|
+
CONSTFUNC(int rb_parser_st_numcmp(parser_st_data_t, parser_st_data_t));
|
143
|
+
CONSTFUNC(parser_st_index_t rb_parser_st_numhash(parser_st_data_t));
|
144
|
+
PUREFUNC(int rb_parser_st_locale_insensitive_strcasecmp(const char *s1, const char *s2));
|
145
|
+
PUREFUNC(int rb_parser_st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n));
|
146
|
+
PUREFUNC(size_t rb_parser_st_memsize(const parser_st_table *));
|
147
|
+
PUREFUNC(parser_st_index_t rb_parser_st_hash(const void *ptr, size_t len, parser_st_index_t h));
|
148
|
+
CONSTFUNC(parser_st_index_t rb_parser_st_hash_uint32(parser_st_index_t h, uint32_t i));
|
149
|
+
CONSTFUNC(parser_st_index_t rb_parser_st_hash_uint(parser_st_index_t h, parser_st_index_t i));
|
150
|
+
CONSTFUNC(parser_st_index_t rb_parser_st_hash_end(parser_st_index_t h));
|
151
|
+
CONSTFUNC(parser_st_index_t rb_parser_st_hash_start(parser_st_index_t h));
|
152
|
+
|
153
|
+
RUBY_SYMBOL_EXPORT_END
|
154
|
+
|
155
|
+
#if defined(__cplusplus)
|
156
|
+
#if 0
|
157
|
+
{ /* satisfy cc-mode */
|
158
|
+
#endif
|
159
|
+
} /* extern "C" { */
|
160
|
+
#endif
|
161
|
+
|
162
|
+
#endif /* RUBY_ST2_H */
|
@@ -0,0 +1,106 @@
|
|
1
|
+
#ifndef EXTERNAL_VALUE_H
|
2
|
+
#define EXTERNAL_VALUE_H
|
3
|
+
|
4
|
+
#include "ruby/config.h"
|
5
|
+
|
6
|
+
#if defined(__DOXYGEN__)
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Type that represents a Ruby object. It is an unsigned integer of some kind,
|
10
|
+
* depending on platforms.
|
11
|
+
*
|
12
|
+
* ```CXX
|
13
|
+
* VALUE value = rb_eval_string("ARGF.readlines.map.with_index");
|
14
|
+
* ```
|
15
|
+
*
|
16
|
+
* @warning ::VALUE is not a pointer.
|
17
|
+
* @warning ::VALUE can be wider than `long`.
|
18
|
+
*/
|
19
|
+
typedef uintptr_t VALUE;
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Type that represents a Ruby identifier such as a variable name.
|
23
|
+
*
|
24
|
+
* ```CXX
|
25
|
+
* ID method = rb_intern("method");
|
26
|
+
* VALUE result = rb_funcall(obj, method, 0);
|
27
|
+
* ```
|
28
|
+
*
|
29
|
+
* @note ::rb_cSymbol is a Ruby-level data type for the same thing.
|
30
|
+
*/
|
31
|
+
typedef uintptr_t ID;
|
32
|
+
|
33
|
+
/**
|
34
|
+
* A signed integer type that has the same width with ::VALUE.
|
35
|
+
*
|
36
|
+
* @internal
|
37
|
+
*
|
38
|
+
* @shyouhei wonders: is it guaranteed that `uintptr_t` and `intptr_t` are the
|
39
|
+
* same width? As far as I read ISO/IEC 9899:2018 section 7.20.1.4 paragraph 1
|
40
|
+
* no such description is given... or defined elsewhere?
|
41
|
+
*/
|
42
|
+
typedef intptr_t SIGNED_VALUE;
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Identical to `sizeof(VALUE)`, except it is a macro that can also be used
|
46
|
+
* inside of preprocessor directives such as `#if`. Handy on occasions.
|
47
|
+
*/
|
48
|
+
#define SIZEOF_VALUE SIZEOF_UINTPTR_T
|
49
|
+
|
50
|
+
/**
|
51
|
+
* @private
|
52
|
+
*
|
53
|
+
* A compile-time constant of type ::VALUE whose value is 0.
|
54
|
+
*/
|
55
|
+
#define RBIMPL_VALUE_NULL UINTPTR_C(0)
|
56
|
+
|
57
|
+
/**
|
58
|
+
* @private
|
59
|
+
*
|
60
|
+
* A compile-time constant of type ::VALUE whose value is 1.
|
61
|
+
*/
|
62
|
+
#define RBIMPL_VALUE_ONE UINTPTR_C(1)
|
63
|
+
|
64
|
+
/**
|
65
|
+
* @private
|
66
|
+
*
|
67
|
+
* Maximum possible value that a ::VALUE can take.
|
68
|
+
*/
|
69
|
+
#define RBIMPL_VALUE_FULL UINTPTR_MAX
|
70
|
+
|
71
|
+
#elif defined HAVE_UINTPTR_T && 0
|
72
|
+
typedef uintptr_t VALUE;
|
73
|
+
typedef uintptr_t ID;
|
74
|
+
# define SIGNED_VALUE intptr_t
|
75
|
+
# define SIZEOF_VALUE SIZEOF_UINTPTR_T
|
76
|
+
# undef PRI_VALUE_PREFIX
|
77
|
+
# define RBIMPL_VALUE_NULL UINTPTR_C(0)
|
78
|
+
# define RBIMPL_VALUE_ONE UINTPTR_C(1)
|
79
|
+
# define RBIMPL_VALUE_FULL UINTPTR_MAX
|
80
|
+
|
81
|
+
#elif SIZEOF_LONG == SIZEOF_VOIDP
|
82
|
+
typedef unsigned long VALUE;
|
83
|
+
typedef unsigned long ID;
|
84
|
+
# define SIGNED_VALUE long
|
85
|
+
# define SIZEOF_VALUE SIZEOF_LONG
|
86
|
+
# define PRI_VALUE_PREFIX "l"
|
87
|
+
# define RBIMPL_VALUE_NULL 0UL
|
88
|
+
# define RBIMPL_VALUE_ONE 1UL
|
89
|
+
# define RBIMPL_VALUE_FULL ULONG_MAX
|
90
|
+
|
91
|
+
#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
|
92
|
+
typedef unsigned LONG_LONG VALUE;
|
93
|
+
typedef unsigned LONG_LONG ID;
|
94
|
+
# define SIGNED_VALUE LONG_LONG
|
95
|
+
# define LONG_LONG_VALUE 1
|
96
|
+
# define SIZEOF_VALUE SIZEOF_LONG_LONG
|
97
|
+
# define PRI_VALUE_PREFIX PRI_LL_PREFIX
|
98
|
+
# define RBIMPL_VALUE_NULL 0ULL
|
99
|
+
# define RBIMPL_VALUE_ONE 1ULL
|
100
|
+
# define RBIMPL_VALUE_FULL ULLONG_MAX
|
101
|
+
|
102
|
+
#else
|
103
|
+
# error ---->> ruby requires sizeof(void*) == sizeof(long) or sizeof(LONG_LONG) to be compiled. <<----
|
104
|
+
#endif
|
105
|
+
|
106
|
+
#endif /* EXTERNAL_VALUE_H */
|