rubydex 0.1.0.beta11 → 0.1.0.beta13
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/LICENSE.txt +23 -23
- data/README.md +125 -125
- data/THIRD_PARTY_LICENSES.html +2018 -945
- data/exe/rdx +47 -47
- data/ext/rubydex/declaration.c +453 -388
- data/ext/rubydex/declaration.h +23 -23
- data/ext/rubydex/definition.c +284 -197
- data/ext/rubydex/definition.h +28 -28
- data/ext/rubydex/diagnostic.c +6 -6
- data/ext/rubydex/diagnostic.h +11 -11
- data/ext/rubydex/document.c +97 -98
- data/ext/rubydex/document.h +10 -10
- data/ext/rubydex/extconf.rb +146 -127
- data/ext/rubydex/graph.c +701 -512
- data/ext/rubydex/graph.h +10 -10
- data/ext/rubydex/handle.h +44 -44
- data/ext/rubydex/location.c +22 -22
- data/ext/rubydex/location.h +15 -15
- data/ext/rubydex/reference.c +123 -104
- data/ext/rubydex/reference.h +15 -16
- data/ext/rubydex/rubydex.c +22 -22
- data/ext/rubydex/utils.c +108 -86
- data/ext/rubydex/utils.h +34 -28
- data/lib/rubydex/comment.rb +17 -17
- data/lib/rubydex/declaration.rb +11 -0
- data/lib/rubydex/diagnostic.rb +21 -21
- data/lib/rubydex/failures.rb +15 -15
- data/lib/rubydex/graph.rb +98 -92
- data/lib/rubydex/keyword.rb +17 -0
- data/lib/rubydex/keyword_parameter.rb +13 -0
- data/lib/rubydex/location.rb +90 -90
- data/lib/rubydex/mixin.rb +22 -0
- data/lib/rubydex/version.rb +5 -5
- data/lib/rubydex.rb +24 -20
- data/rbi/rubydex.rbi +425 -310
- data/rust/Cargo.lock +1851 -1851
- data/rust/Cargo.toml +29 -29
- data/rust/about.toml +10 -10
- data/rust/{about.hbs → about_templates/about.hbs} +81 -78
- data/rust/about_templates/mingw_licenses.hbs +1071 -0
- data/rust/rubydex/Cargo.toml +42 -42
- data/rust/rubydex/src/compile_assertions.rs +13 -13
- data/rust/rubydex/src/diagnostic.rs +110 -109
- data/rust/rubydex/src/errors.rs +28 -28
- data/rust/rubydex/src/indexing/local_graph.rs +224 -224
- data/rust/rubydex/src/indexing/rbs_indexer.rs +1551 -1554
- data/rust/rubydex/src/indexing/ruby_indexer.rs +2329 -6753
- data/rust/rubydex/src/indexing/ruby_indexer_tests.rs +4962 -0
- data/rust/rubydex/src/indexing.rs +210 -210
- data/rust/rubydex/src/integrity.rs +279 -278
- data/rust/rubydex/src/job_queue.rs +199 -205
- data/rust/rubydex/src/lib.rs +17 -17
- data/rust/rubydex/src/listing.rs +371 -272
- data/rust/rubydex/src/main.rs +160 -160
- data/rust/rubydex/src/model/built_in.rs +83 -0
- data/rust/rubydex/src/model/comment.rs +24 -24
- data/rust/rubydex/src/model/declaration.rs +679 -588
- data/rust/rubydex/src/model/definitions.rs +1682 -1602
- data/rust/rubydex/src/model/document.rs +222 -252
- data/rust/rubydex/src/model/encoding.rs +22 -22
- data/rust/rubydex/src/model/graph.rs +3782 -3556
- data/rust/rubydex/src/model/id.rs +110 -110
- data/rust/rubydex/src/model/identity_maps.rs +58 -58
- data/rust/rubydex/src/model/ids.rs +60 -38
- data/rust/rubydex/src/model/keywords.rs +256 -256
- data/rust/rubydex/src/model/name.rs +298 -298
- data/rust/rubydex/src/model/references.rs +111 -111
- data/rust/rubydex/src/model/string_ref.rs +50 -50
- data/rust/rubydex/src/model/visibility.rs +41 -41
- data/rust/rubydex/src/model.rs +15 -14
- data/rust/rubydex/src/offset.rs +147 -147
- data/rust/rubydex/src/position.rs +6 -6
- data/rust/rubydex/src/query.rs +1841 -1700
- data/rust/rubydex/src/resolution.rs +1852 -5895
- data/rust/rubydex/src/resolution_tests.rs +4701 -0
- data/rust/rubydex/src/stats/memory.rs +71 -71
- data/rust/rubydex/src/stats/orphan_report.rs +264 -263
- data/rust/rubydex/src/stats/timer.rs +127 -127
- data/rust/rubydex/src/stats.rs +11 -11
- data/rust/rubydex/src/test_utils/context.rs +226 -226
- data/rust/rubydex/src/test_utils/graph_test.rs +730 -679
- data/rust/rubydex/src/test_utils/local_graph_test.rs +602 -602
- data/rust/rubydex/src/test_utils.rs +52 -52
- data/rust/rubydex/src/visualization/dot.rs +192 -176
- data/rust/rubydex/src/visualization.rs +6 -6
- data/rust/rubydex/tests/cli.rs +185 -167
- data/rust/rubydex-mcp/Cargo.toml +28 -28
- data/rust/rubydex-mcp/src/main.rs +48 -48
- data/rust/rubydex-mcp/src/server.rs +1145 -1145
- data/rust/rubydex-mcp/src/tools.rs +49 -49
- data/rust/rubydex-mcp/tests/mcp.rs +302 -302
- data/rust/rubydex-sys/Cargo.toml +20 -20
- data/rust/rubydex-sys/build.rs +14 -14
- data/rust/rubydex-sys/cbindgen.toml +12 -12
- data/rust/rubydex-sys/src/declaration_api.rs +485 -469
- data/rust/rubydex-sys/src/definition_api.rs +443 -352
- data/rust/rubydex-sys/src/diagnostic_api.rs +99 -99
- data/rust/rubydex-sys/src/document_api.rs +85 -54
- data/rust/rubydex-sys/src/graph_api.rs +1017 -700
- data/rust/rubydex-sys/src/lib.rs +79 -9
- data/rust/rubydex-sys/src/location_api.rs +79 -79
- data/rust/rubydex-sys/src/name_api.rs +187 -135
- data/rust/rubydex-sys/src/reference_api.rs +267 -195
- data/rust/rubydex-sys/src/utils.rs +70 -70
- data/rust/rustfmt.toml +2 -2
- metadata +16 -9
- data/lib/rubydex/librubydex_sys.so +0 -0
data/ext/rubydex/declaration.h
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
#ifndef RUBYDEX_DECLARATION_H
|
|
2
|
-
#define RUBYDEX_DECLARATION_H
|
|
3
|
-
|
|
4
|
-
#include "ruby.h"
|
|
5
|
-
#include "rustbindings.h"
|
|
6
|
-
|
|
7
|
-
extern VALUE cDeclaration;
|
|
8
|
-
extern VALUE cNamespace;
|
|
9
|
-
extern VALUE cClass;
|
|
10
|
-
extern VALUE cModule;
|
|
11
|
-
extern VALUE cSingletonClass;
|
|
12
|
-
extern VALUE cTodo;
|
|
13
|
-
extern VALUE cConstant;
|
|
14
|
-
extern VALUE cConstantAlias;
|
|
15
|
-
extern VALUE cMethod;
|
|
16
|
-
extern VALUE cGlobalVariable;
|
|
17
|
-
extern VALUE cInstanceVariable;
|
|
18
|
-
extern VALUE cClassVariable;
|
|
19
|
-
|
|
20
|
-
VALUE rdxi_declaration_class_for_kind(CDeclarationKind kind);
|
|
21
|
-
void rdxi_initialize_declaration(VALUE mRubydex);
|
|
22
|
-
|
|
23
|
-
#endif // RUBYDEX_DECLARATION_H
|
|
1
|
+
#ifndef RUBYDEX_DECLARATION_H
|
|
2
|
+
#define RUBYDEX_DECLARATION_H
|
|
3
|
+
|
|
4
|
+
#include "ruby.h"
|
|
5
|
+
#include "rustbindings.h"
|
|
6
|
+
|
|
7
|
+
extern VALUE cDeclaration;
|
|
8
|
+
extern VALUE cNamespace;
|
|
9
|
+
extern VALUE cClass;
|
|
10
|
+
extern VALUE cModule;
|
|
11
|
+
extern VALUE cSingletonClass;
|
|
12
|
+
extern VALUE cTodo;
|
|
13
|
+
extern VALUE cConstant;
|
|
14
|
+
extern VALUE cConstantAlias;
|
|
15
|
+
extern VALUE cMethod;
|
|
16
|
+
extern VALUE cGlobalVariable;
|
|
17
|
+
extern VALUE cInstanceVariable;
|
|
18
|
+
extern VALUE cClassVariable;
|
|
19
|
+
|
|
20
|
+
VALUE rdxi_declaration_class_for_kind(CDeclarationKind kind);
|
|
21
|
+
void rdxi_initialize_declaration(VALUE mRubydex);
|
|
22
|
+
|
|
23
|
+
#endif // RUBYDEX_DECLARATION_H
|
data/ext/rubydex/definition.c
CHANGED
|
@@ -1,197 +1,284 @@
|
|
|
1
|
-
#include "definition.h"
|
|
2
|
-
#include "graph.h"
|
|
3
|
-
#include "handle.h"
|
|
4
|
-
#include "location.h"
|
|
5
|
-
#include "
|
|
6
|
-
#include "
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
VALUE
|
|
10
|
-
VALUE
|
|
11
|
-
VALUE
|
|
12
|
-
VALUE
|
|
13
|
-
VALUE
|
|
14
|
-
VALUE
|
|
15
|
-
VALUE
|
|
16
|
-
VALUE
|
|
17
|
-
VALUE
|
|
18
|
-
VALUE
|
|
19
|
-
VALUE
|
|
20
|
-
VALUE
|
|
21
|
-
VALUE
|
|
22
|
-
VALUE
|
|
23
|
-
VALUE
|
|
24
|
-
VALUE
|
|
25
|
-
VALUE
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
VALUE
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
1
|
+
#include "definition.h"
|
|
2
|
+
#include "graph.h"
|
|
3
|
+
#include "handle.h"
|
|
4
|
+
#include "location.h"
|
|
5
|
+
#include "reference.h"
|
|
6
|
+
#include "ruby/internal/scan_args.h"
|
|
7
|
+
#include "rustbindings.h"
|
|
8
|
+
|
|
9
|
+
static VALUE mRubydex;
|
|
10
|
+
static VALUE cInclude;
|
|
11
|
+
static VALUE cPrepend;
|
|
12
|
+
static VALUE cExtend;
|
|
13
|
+
VALUE cComment;
|
|
14
|
+
VALUE cDefinition;
|
|
15
|
+
VALUE cClassDefinition;
|
|
16
|
+
VALUE cSingletonClassDefinition;
|
|
17
|
+
VALUE cModuleDefinition;
|
|
18
|
+
VALUE cConstantDefinition;
|
|
19
|
+
VALUE cConstantAliasDefinition;
|
|
20
|
+
VALUE cConstantVisibilityDefinition;
|
|
21
|
+
VALUE cMethodVisibilityDefinition;
|
|
22
|
+
VALUE cMethodDefinition;
|
|
23
|
+
VALUE cAttrAccessorDefinition;
|
|
24
|
+
VALUE cAttrReaderDefinition;
|
|
25
|
+
VALUE cAttrWriterDefinition;
|
|
26
|
+
VALUE cGlobalVariableDefinition;
|
|
27
|
+
VALUE cInstanceVariableDefinition;
|
|
28
|
+
VALUE cClassVariableDefinition;
|
|
29
|
+
VALUE cMethodAliasDefinition;
|
|
30
|
+
VALUE cGlobalVariableAliasDefinition;
|
|
31
|
+
|
|
32
|
+
// Keep this in sync with definition.rs
|
|
33
|
+
VALUE rdxi_definition_class_for_kind(DefinitionKind kind) {
|
|
34
|
+
switch (kind) {
|
|
35
|
+
case DefinitionKind_Class:
|
|
36
|
+
return cClassDefinition;
|
|
37
|
+
case DefinitionKind_SingletonClass:
|
|
38
|
+
return cSingletonClassDefinition;
|
|
39
|
+
case DefinitionKind_Module:
|
|
40
|
+
return cModuleDefinition;
|
|
41
|
+
case DefinitionKind_Constant:
|
|
42
|
+
return cConstantDefinition;
|
|
43
|
+
case DefinitionKind_ConstantAlias:
|
|
44
|
+
return cConstantAliasDefinition;
|
|
45
|
+
case DefinitionKind_ConstantVisibility:
|
|
46
|
+
return cConstantVisibilityDefinition;
|
|
47
|
+
case DefinitionKind_MethodVisibility:
|
|
48
|
+
return cMethodVisibilityDefinition;
|
|
49
|
+
case DefinitionKind_Method:
|
|
50
|
+
return cMethodDefinition;
|
|
51
|
+
case DefinitionKind_AttrAccessor:
|
|
52
|
+
return cAttrAccessorDefinition;
|
|
53
|
+
case DefinitionKind_AttrReader:
|
|
54
|
+
return cAttrReaderDefinition;
|
|
55
|
+
case DefinitionKind_AttrWriter:
|
|
56
|
+
return cAttrWriterDefinition;
|
|
57
|
+
case DefinitionKind_GlobalVariable:
|
|
58
|
+
return cGlobalVariableDefinition;
|
|
59
|
+
case DefinitionKind_InstanceVariable:
|
|
60
|
+
return cInstanceVariableDefinition;
|
|
61
|
+
case DefinitionKind_ClassVariable:
|
|
62
|
+
return cClassVariableDefinition;
|
|
63
|
+
case DefinitionKind_MethodAlias:
|
|
64
|
+
return cMethodAliasDefinition;
|
|
65
|
+
case DefinitionKind_GlobalVariableAlias:
|
|
66
|
+
return cGlobalVariableAliasDefinition;
|
|
67
|
+
default:
|
|
68
|
+
rb_raise(rb_eRuntimeError, "Unknown DefinitionKind: %d", kind);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Definition#location -> Rubydex::Location
|
|
73
|
+
static VALUE rdxr_definition_location(VALUE self) {
|
|
74
|
+
HandleData *data;
|
|
75
|
+
TypedData_Get_Struct(self, HandleData, &handle_type, data);
|
|
76
|
+
|
|
77
|
+
void *graph;
|
|
78
|
+
TypedData_Get_Struct(data->graph_obj, void *, &graph_type, graph);
|
|
79
|
+
|
|
80
|
+
Location *loc = rdx_definition_location(graph, data->id);
|
|
81
|
+
VALUE location = rdxi_build_location_value(loc);
|
|
82
|
+
rdx_location_free(loc);
|
|
83
|
+
|
|
84
|
+
return location;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Definition#comments -> [Rubydex::Comment]
|
|
88
|
+
static VALUE rdxr_definition_comments(VALUE self) {
|
|
89
|
+
HandleData *data;
|
|
90
|
+
TypedData_Get_Struct(self, HandleData, &handle_type, data);
|
|
91
|
+
|
|
92
|
+
void *graph;
|
|
93
|
+
TypedData_Get_Struct(data->graph_obj, void *, &graph_type, graph);
|
|
94
|
+
|
|
95
|
+
CommentArray *arr = rdx_definition_comments(graph, data->id);
|
|
96
|
+
if (arr == NULL || arr->len == 0) {
|
|
97
|
+
if (arr != NULL) {
|
|
98
|
+
rdx_definition_comments_free(arr);
|
|
99
|
+
}
|
|
100
|
+
return rb_ary_new();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
VALUE ary = rb_ary_new_capa((long)arr->len);
|
|
104
|
+
for (size_t i = 0; i < arr->len; i++) {
|
|
105
|
+
CommentEntry entry = arr->items[i];
|
|
106
|
+
|
|
107
|
+
VALUE string = rb_utf8_str_new_cstr(entry.string);
|
|
108
|
+
|
|
109
|
+
Location *loc = entry.location;
|
|
110
|
+
VALUE location = rdxi_build_location_value(loc);
|
|
111
|
+
|
|
112
|
+
VALUE comment_kwargs = rb_hash_new();
|
|
113
|
+
rb_hash_aset(comment_kwargs, ID2SYM(rb_intern("string")), string);
|
|
114
|
+
rb_hash_aset(comment_kwargs, ID2SYM(rb_intern("location")), location);
|
|
115
|
+
VALUE comment = rb_class_new_instance_kw(1, &comment_kwargs, cComment, RB_PASS_KEYWORDS);
|
|
116
|
+
|
|
117
|
+
rb_ary_push(ary, comment);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Free the array and all inner allocations on the Rust side
|
|
121
|
+
rdx_definition_comments_free(arr);
|
|
122
|
+
return ary;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Definition#name -> String
|
|
126
|
+
static VALUE rdxr_definition_name(VALUE self) {
|
|
127
|
+
HandleData *data;
|
|
128
|
+
TypedData_Get_Struct(self, HandleData, &handle_type, data);
|
|
129
|
+
|
|
130
|
+
void *graph;
|
|
131
|
+
TypedData_Get_Struct(data->graph_obj, void *, &graph_type, graph);
|
|
132
|
+
|
|
133
|
+
const char *name = rdx_definition_name(graph, data->id);
|
|
134
|
+
if (name == NULL) {
|
|
135
|
+
return Qnil;
|
|
136
|
+
}
|
|
137
|
+
VALUE str = rb_utf8_str_new_cstr(name);
|
|
138
|
+
free_c_string(name);
|
|
139
|
+
return str;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Definition#deprecated? -> bool
|
|
143
|
+
static VALUE rdxr_definition_deprecated(VALUE self) {
|
|
144
|
+
HandleData *data;
|
|
145
|
+
TypedData_Get_Struct(self, HandleData, &handle_type, data);
|
|
146
|
+
|
|
147
|
+
void *graph;
|
|
148
|
+
TypedData_Get_Struct(data->graph_obj, void *, &graph_type, graph);
|
|
149
|
+
|
|
150
|
+
bool deprecated = rdx_definition_is_deprecated(graph, data->id);
|
|
151
|
+
return deprecated ? Qtrue : Qfalse;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Definition#name_location -> Rubydex::Location or nil
|
|
155
|
+
// For class, module, and singleton class definitions, returns the location of just the name
|
|
156
|
+
// (e.g., "Bar" in "class Foo::Bar"). For other definition types, returns nil.
|
|
157
|
+
static VALUE rdxr_definition_name_location(VALUE self) {
|
|
158
|
+
HandleData *data;
|
|
159
|
+
TypedData_Get_Struct(self, HandleData, &handle_type, data);
|
|
160
|
+
|
|
161
|
+
void *graph;
|
|
162
|
+
TypedData_Get_Struct(data->graph_obj, void *, &graph_type, graph);
|
|
163
|
+
|
|
164
|
+
Location *loc = rdx_definition_name_location(graph, data->id);
|
|
165
|
+
if (loc == NULL) {
|
|
166
|
+
return Qnil;
|
|
167
|
+
}
|
|
168
|
+
VALUE location = rdxi_build_location_value(loc);
|
|
169
|
+
rdx_location_free(loc);
|
|
170
|
+
|
|
171
|
+
return location;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
static VALUE rdxi_build_constant_reference(VALUE graph_obj, const CConstantReference *cref) {
|
|
175
|
+
VALUE ref_class = (cref->declaration_id == 0)
|
|
176
|
+
? cUnresolvedConstantReference
|
|
177
|
+
: cResolvedConstantReference;
|
|
178
|
+
|
|
179
|
+
VALUE argv[] = {graph_obj, ULL2NUM(cref->id)};
|
|
180
|
+
return rb_class_new_instance(2, argv, ref_class);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// ClassDefinition#superclass -> ConstantReference?
|
|
184
|
+
static VALUE rdxr_class_definition_superclass(VALUE self) {
|
|
185
|
+
HandleData *data;
|
|
186
|
+
TypedData_Get_Struct(self, HandleData, &handle_type, data);
|
|
187
|
+
|
|
188
|
+
void *graph;
|
|
189
|
+
TypedData_Get_Struct(data->graph_obj, void *, &graph_type, graph);
|
|
190
|
+
|
|
191
|
+
const CConstantReference *ref = rdx_class_definition_superclass(graph, data->id);
|
|
192
|
+
if (ref == NULL) {
|
|
193
|
+
return Qnil;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
VALUE result = rdxi_build_constant_reference(data->graph_obj, ref);
|
|
197
|
+
free_c_constant_reference(ref);
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
static VALUE rdxi_mixin_class_for_kind(MixinKind kind) {
|
|
202
|
+
switch (kind) {
|
|
203
|
+
case MixinKind_Include:
|
|
204
|
+
return cInclude;
|
|
205
|
+
case MixinKind_Prepend:
|
|
206
|
+
return cPrepend;
|
|
207
|
+
case MixinKind_Extend:
|
|
208
|
+
return cExtend;
|
|
209
|
+
default:
|
|
210
|
+
rb_raise(rb_eRuntimeError, "Unknown MixinKind: %d", kind);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Definition#mixins -> [Rubydex::Mixin]
|
|
215
|
+
static VALUE rdxr_definition_mixins(VALUE self) {
|
|
216
|
+
HandleData *data;
|
|
217
|
+
TypedData_Get_Struct(self, HandleData, &handle_type, data);
|
|
218
|
+
|
|
219
|
+
void *graph;
|
|
220
|
+
TypedData_Get_Struct(data->graph_obj, void *, &graph_type, graph);
|
|
221
|
+
|
|
222
|
+
MixinsIter *iter = rdx_definition_mixins(graph, data->id);
|
|
223
|
+
if (iter == NULL) {
|
|
224
|
+
rb_raise(rb_eRuntimeError, "Tried to get mixins for a definition that isn't a namespace");
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
size_t len = rdx_mixins_iter_len(iter);
|
|
228
|
+
VALUE ary = rb_ary_new_capa((long)len);
|
|
229
|
+
|
|
230
|
+
CMixin entry;
|
|
231
|
+
while (rdx_mixins_iter_next(iter, &entry)) {
|
|
232
|
+
VALUE constant_ref = rdxi_build_constant_reference(data->graph_obj, &entry.constant_reference);
|
|
233
|
+
VALUE mixin_class = rdxi_mixin_class_for_kind(entry.kind);
|
|
234
|
+
VALUE mixin = rb_class_new_instance(1, &constant_ref, mixin_class);
|
|
235
|
+
rb_ary_push(ary, mixin);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
rdx_mixins_iter_free(iter);
|
|
239
|
+
return ary;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
void rdxi_initialize_definition(VALUE mod) {
|
|
243
|
+
mRubydex = mod;
|
|
244
|
+
|
|
245
|
+
cInclude = rb_const_get(mRubydex, rb_intern("Include"));
|
|
246
|
+
cPrepend = rb_const_get(mRubydex, rb_intern("Prepend"));
|
|
247
|
+
cExtend = rb_const_get(mRubydex, rb_intern("Extend"));
|
|
248
|
+
|
|
249
|
+
cComment = rb_define_class_under(mRubydex, "Comment", rb_cObject);
|
|
250
|
+
|
|
251
|
+
cDefinition = rb_define_class_under(mRubydex, "Definition", rb_cObject);
|
|
252
|
+
rb_define_alloc_func(cDefinition, rdxr_handle_alloc);
|
|
253
|
+
rb_define_method(cDefinition, "initialize", rdxr_handle_initialize, 2);
|
|
254
|
+
rb_funcall(rb_singleton_class(cDefinition), rb_intern("private"), 1, ID2SYM(rb_intern("new")));
|
|
255
|
+
rb_define_method(cDefinition, "location", rdxr_definition_location, 0);
|
|
256
|
+
rb_define_method(cDefinition, "comments", rdxr_definition_comments, 0);
|
|
257
|
+
rb_define_method(cDefinition, "name", rdxr_definition_name, 0);
|
|
258
|
+
rb_define_method(cDefinition, "deprecated?", rdxr_definition_deprecated, 0);
|
|
259
|
+
rb_define_method(cDefinition, "name_location", rdxr_definition_name_location, 0);
|
|
260
|
+
|
|
261
|
+
cClassDefinition = rb_define_class_under(mRubydex, "ClassDefinition", cDefinition);
|
|
262
|
+
rb_define_method(cClassDefinition, "superclass", rdxr_class_definition_superclass, 0);
|
|
263
|
+
rb_define_method(cClassDefinition, "mixins", rdxr_definition_mixins, 0);
|
|
264
|
+
|
|
265
|
+
cSingletonClassDefinition = rb_define_class_under(mRubydex, "SingletonClassDefinition", cDefinition);
|
|
266
|
+
rb_define_method(cSingletonClassDefinition, "mixins", rdxr_definition_mixins, 0);
|
|
267
|
+
|
|
268
|
+
cModuleDefinition = rb_define_class_under(mRubydex, "ModuleDefinition", cDefinition);
|
|
269
|
+
rb_define_method(cModuleDefinition, "mixins", rdxr_definition_mixins, 0);
|
|
270
|
+
|
|
271
|
+
cConstantDefinition = rb_define_class_under(mRubydex, "ConstantDefinition", cDefinition);
|
|
272
|
+
cConstantAliasDefinition = rb_define_class_under(mRubydex, "ConstantAliasDefinition", cDefinition);
|
|
273
|
+
cConstantVisibilityDefinition = rb_define_class_under(mRubydex, "ConstantVisibilityDefinition", cDefinition);
|
|
274
|
+
cMethodVisibilityDefinition = rb_define_class_under(mRubydex, "MethodVisibilityDefinition", cDefinition);
|
|
275
|
+
cMethodDefinition = rb_define_class_under(mRubydex, "MethodDefinition", cDefinition);
|
|
276
|
+
cAttrAccessorDefinition = rb_define_class_under(mRubydex, "AttrAccessorDefinition", cDefinition);
|
|
277
|
+
cAttrReaderDefinition = rb_define_class_under(mRubydex, "AttrReaderDefinition", cDefinition);
|
|
278
|
+
cAttrWriterDefinition = rb_define_class_under(mRubydex, "AttrWriterDefinition", cDefinition);
|
|
279
|
+
cGlobalVariableDefinition = rb_define_class_under(mRubydex, "GlobalVariableDefinition", cDefinition);
|
|
280
|
+
cInstanceVariableDefinition = rb_define_class_under(mRubydex, "InstanceVariableDefinition", cDefinition);
|
|
281
|
+
cClassVariableDefinition = rb_define_class_under(mRubydex, "ClassVariableDefinition", cDefinition);
|
|
282
|
+
cMethodAliasDefinition = rb_define_class_under(mRubydex, "MethodAliasDefinition", cDefinition);
|
|
283
|
+
cGlobalVariableAliasDefinition = rb_define_class_under(mRubydex, "GlobalVariableAliasDefinition", cDefinition);
|
|
284
|
+
}
|
data/ext/rubydex/definition.h
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
#ifndef RUBYDEX_DEFINITION_H
|
|
2
|
-
#define RUBYDEX_DEFINITION_H
|
|
3
|
-
|
|
4
|
-
#include "ruby.h"
|
|
5
|
-
#include "rustbindings.h"
|
|
6
|
-
|
|
7
|
-
extern VALUE cDefinition;
|
|
8
|
-
extern VALUE cClassDefinition;
|
|
9
|
-
extern VALUE cSingletonClassDefinition;
|
|
10
|
-
extern VALUE cModuleDefinition;
|
|
11
|
-
extern VALUE cConstantDefinition;
|
|
12
|
-
extern VALUE cConstantAliasDefinition;
|
|
13
|
-
extern VALUE cMethodDefinition;
|
|
14
|
-
extern VALUE cAttrAccessorDefinition;
|
|
15
|
-
extern VALUE cAttrReaderDefinition;
|
|
16
|
-
extern VALUE cAttrWriterDefinition;
|
|
17
|
-
extern VALUE cGlobalVariableDefinition;
|
|
18
|
-
extern VALUE cInstanceVariableDefinition;
|
|
19
|
-
extern VALUE cClassVariableDefinition;
|
|
20
|
-
extern VALUE cMethodAliasDefinition;
|
|
21
|
-
extern VALUE cGlobalVariableAliasDefinition;
|
|
22
|
-
|
|
23
|
-
void rdxi_initialize_definition(VALUE mRubydex);
|
|
24
|
-
|
|
25
|
-
// Returns the Ruby class for a given DefinitionKind without calling back into Rust
|
|
26
|
-
VALUE rdxi_definition_class_for_kind(DefinitionKind kind);
|
|
27
|
-
|
|
28
|
-
#endif // RUBYDEX_DEFINITION_H
|
|
1
|
+
#ifndef RUBYDEX_DEFINITION_H
|
|
2
|
+
#define RUBYDEX_DEFINITION_H
|
|
3
|
+
|
|
4
|
+
#include "ruby.h"
|
|
5
|
+
#include "rustbindings.h"
|
|
6
|
+
|
|
7
|
+
extern VALUE cDefinition;
|
|
8
|
+
extern VALUE cClassDefinition;
|
|
9
|
+
extern VALUE cSingletonClassDefinition;
|
|
10
|
+
extern VALUE cModuleDefinition;
|
|
11
|
+
extern VALUE cConstantDefinition;
|
|
12
|
+
extern VALUE cConstantAliasDefinition;
|
|
13
|
+
extern VALUE cMethodDefinition;
|
|
14
|
+
extern VALUE cAttrAccessorDefinition;
|
|
15
|
+
extern VALUE cAttrReaderDefinition;
|
|
16
|
+
extern VALUE cAttrWriterDefinition;
|
|
17
|
+
extern VALUE cGlobalVariableDefinition;
|
|
18
|
+
extern VALUE cInstanceVariableDefinition;
|
|
19
|
+
extern VALUE cClassVariableDefinition;
|
|
20
|
+
extern VALUE cMethodAliasDefinition;
|
|
21
|
+
extern VALUE cGlobalVariableAliasDefinition;
|
|
22
|
+
|
|
23
|
+
void rdxi_initialize_definition(VALUE mRubydex);
|
|
24
|
+
|
|
25
|
+
// Returns the Ruby class for a given DefinitionKind without calling back into Rust
|
|
26
|
+
VALUE rdxi_definition_class_for_kind(DefinitionKind kind);
|
|
27
|
+
|
|
28
|
+
#endif // RUBYDEX_DEFINITION_H
|
data/ext/rubydex/diagnostic.c
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#include "diagnostic.h"
|
|
2
|
-
#include "rustbindings.h"
|
|
3
|
-
|
|
4
|
-
VALUE cDiagnostic;
|
|
5
|
-
|
|
6
|
-
void rdxi_initialize_diagnostic(VALUE mRubydex) { cDiagnostic = rb_define_class_under(mRubydex, "Diagnostic", rb_cObject); }
|
|
1
|
+
#include "diagnostic.h"
|
|
2
|
+
#include "rustbindings.h"
|
|
3
|
+
|
|
4
|
+
VALUE cDiagnostic;
|
|
5
|
+
|
|
6
|
+
void rdxi_initialize_diagnostic(VALUE mRubydex) { cDiagnostic = rb_define_class_under(mRubydex, "Diagnostic", rb_cObject); }
|
data/ext/rubydex/diagnostic.h
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
#ifndef RUBYDEX_DIAGNOSTIC_H
|
|
2
|
-
#define RUBYDEX_DIAGNOSTIC_H
|
|
3
|
-
|
|
4
|
-
#include "ruby.h"
|
|
5
|
-
#include "rustbindings.h"
|
|
6
|
-
|
|
7
|
-
extern VALUE cDiagnostic;
|
|
8
|
-
|
|
9
|
-
void rdxi_initialize_diagnostic(VALUE mRubydex);
|
|
10
|
-
|
|
11
|
-
#endif // RUBYDEX_DIAGNOSTIC_H
|
|
1
|
+
#ifndef RUBYDEX_DIAGNOSTIC_H
|
|
2
|
+
#define RUBYDEX_DIAGNOSTIC_H
|
|
3
|
+
|
|
4
|
+
#include "ruby.h"
|
|
5
|
+
#include "rustbindings.h"
|
|
6
|
+
|
|
7
|
+
extern VALUE cDiagnostic;
|
|
8
|
+
|
|
9
|
+
void rdxi_initialize_diagnostic(VALUE mRubydex);
|
|
10
|
+
|
|
11
|
+
#endif // RUBYDEX_DIAGNOSTIC_H
|