rbs 3.9.3 → 4.0.0.dev.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/.github/workflows/ruby.yml +1 -1
- data/.github/workflows/windows.yml +1 -1
- data/CHANGELOG.md +0 -19
- data/Rakefile +28 -21
- data/Steepfile +1 -0
- data/config.yml +232 -62
- data/ext/rbs_extension/ast_translation.c +1149 -0
- data/ext/rbs_extension/ast_translation.h +30 -0
- data/{src/constants.c → ext/rbs_extension/class_constants.c} +15 -1
- data/{include/rbs/constants.h → ext/rbs_extension/class_constants.h} +10 -1
- data/ext/rbs_extension/extconf.rb +3 -1
- data/ext/rbs_extension/{location.c → legacy_location.c} +25 -34
- data/ext/rbs_extension/legacy_location.h +40 -0
- data/ext/rbs_extension/main.c +402 -8
- data/ext/rbs_extension/rbs_extension.h +3 -21
- data/ext/rbs_extension/rbs_string_bridging.c +9 -0
- data/ext/rbs_extension/rbs_string_bridging.h +20 -0
- data/include/rbs/ast.h +748 -0
- data/include/rbs/defines.h +60 -0
- data/{ext/rbs_extension → include/rbs}/lexer.h +40 -32
- data/include/rbs/location.h +59 -0
- data/include/rbs/parser.h +151 -0
- data/include/rbs/string.h +49 -0
- data/include/rbs/util/rbs_allocator.h +38 -0
- data/include/rbs/util/rbs_assert.h +9 -0
- data/include/rbs/util/rbs_buffer.h +83 -0
- data/include/rbs/util/rbs_constant_pool.h +3 -64
- data/include/rbs/util/rbs_encoding.h +280 -0
- data/include/rbs/util/rbs_unescape.h +23 -0
- data/include/rbs.h +1 -2
- data/lib/rbs/annotate/formatter.rb +3 -13
- data/lib/rbs/annotate/rdoc_annotator.rb +3 -1
- data/lib/rbs/annotate/rdoc_source.rb +1 -1
- data/lib/rbs/ast/ruby/annotations.rb +119 -0
- data/lib/rbs/ast/ruby/comment_block.rb +221 -0
- data/lib/rbs/ast/ruby/declarations.rb +86 -0
- data/lib/rbs/ast/ruby/helpers/constant_helper.rb +24 -0
- data/lib/rbs/ast/ruby/helpers/location_helper.rb +15 -0
- data/lib/rbs/ast/ruby/members.rb +213 -0
- data/lib/rbs/buffer.rb +104 -24
- data/lib/rbs/cli/validate.rb +39 -34
- data/lib/rbs/cli.rb +4 -5
- data/lib/rbs/definition.rb +6 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +63 -60
- data/lib/rbs/definition_builder/method_builder.rb +45 -30
- data/lib/rbs/definition_builder.rb +44 -9
- data/lib/rbs/environment/class_entry.rb +69 -0
- data/lib/rbs/environment/module_entry.rb +66 -0
- data/lib/rbs/environment.rb +185 -154
- data/lib/rbs/environment_loader.rb +2 -2
- data/lib/rbs/errors.rb +4 -3
- data/lib/rbs/inline_parser/comment_association.rb +117 -0
- data/lib/rbs/inline_parser.rb +206 -0
- data/lib/rbs/location_aux.rb +35 -3
- data/lib/rbs/parser_aux.rb +11 -1
- data/lib/rbs/prototype/runtime.rb +2 -2
- data/lib/rbs/source.rb +99 -0
- data/lib/rbs/subtractor.rb +4 -3
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +12 -0
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +2 -2
- data/rbs.gemspec +1 -0
- data/sig/ancestor_builder.rbs +1 -1
- data/sig/annotate/formatter.rbs +2 -2
- data/sig/annotate/rdoc_annotater.rbs +1 -1
- data/sig/ast/ruby/annotations.rbs +110 -0
- data/sig/ast/ruby/comment_block.rbs +119 -0
- data/sig/ast/ruby/declarations.rbs +60 -0
- data/sig/ast/ruby/helpers/constant_helper.rbs +11 -0
- data/sig/ast/ruby/helpers/location_helper.rbs +15 -0
- data/sig/ast/ruby/members.rbs +72 -0
- data/sig/buffer.rbs +63 -5
- data/sig/definition.rbs +1 -0
- data/sig/definition_builder.rbs +1 -1
- data/sig/environment/class_entry.rbs +50 -0
- data/sig/environment/module_entry.rbs +50 -0
- data/sig/environment.rbs +22 -76
- data/sig/errors.rbs +13 -6
- data/sig/inline_parser/comment_association.rbs +71 -0
- data/sig/inline_parser.rbs +87 -0
- data/sig/location.rbs +32 -7
- data/sig/method_builder.rbs +7 -4
- data/sig/parser.rbs +16 -0
- data/sig/source.rbs +48 -0
- data/src/ast.c +1345 -0
- data/src/lexer.c +2867 -0
- data/src/lexer.re +151 -0
- data/{ext/rbs_extension → src}/lexstate.c +58 -42
- data/src/location.c +71 -0
- data/src/parser.c +3739 -0
- data/src/string.c +89 -0
- data/src/util/rbs_allocator.c +149 -0
- data/src/util/rbs_assert.c +19 -0
- data/src/util/rbs_buffer.c +54 -0
- data/src/util/rbs_constant_pool.c +13 -81
- data/src/util/rbs_encoding.c +5273 -0
- data/src/util/rbs_unescape.c +130 -0
- data/stdlib/rdoc/0/code_object.rbs +2 -2
- data/stdlib/rdoc/0/comment.rbs +2 -0
- data/stdlib/rdoc/0/options.rbs +76 -0
- data/stdlib/rdoc/0/rdoc.rbs +6 -4
- data/stdlib/rdoc/0/store.rbs +1 -1
- metadata +70 -17
- data/ext/rbs_extension/lexer.c +0 -2728
- data/ext/rbs_extension/lexer.re +0 -147
- data/ext/rbs_extension/location.h +0 -85
- data/ext/rbs_extension/parser.c +0 -2982
- data/ext/rbs_extension/parser.h +0 -18
- data/ext/rbs_extension/parserstate.c +0 -411
- data/ext/rbs_extension/parserstate.h +0 -163
- data/ext/rbs_extension/unescape.c +0 -32
- data/include/rbs/ruby_objs.h +0 -72
- data/src/ruby_objs.c +0 -799
@@ -0,0 +1,30 @@
|
|
1
|
+
/*----------------------------------------------------------------------------*/
|
2
|
+
/* This file is generated by the templates/template.rb script and should not */
|
3
|
+
/* be modified manually. */
|
4
|
+
/* To change the template see */
|
5
|
+
/* templates/ext/rbs_extension/ast_translation.h.erb */
|
6
|
+
/*----------------------------------------------------------------------------*/
|
7
|
+
|
8
|
+
#ifndef RBS_EXTENSION_AST_TRANSLATION_H
|
9
|
+
#define RBS_EXTENSION_AST_TRANSLATION_H
|
10
|
+
|
11
|
+
#include "ruby.h"
|
12
|
+
#include "ruby/encoding.h"
|
13
|
+
|
14
|
+
#include "rbs/ast.h"
|
15
|
+
#include "rbs/location.h"
|
16
|
+
|
17
|
+
/// A bag of values needed when copying RBS C structs into Ruby objects.
|
18
|
+
typedef struct rbs_translation_context {
|
19
|
+
rbs_constant_pool_t *constant_pool;
|
20
|
+
VALUE buffer;
|
21
|
+
rb_encoding *encoding;
|
22
|
+
} rbs_translation_context_t;
|
23
|
+
|
24
|
+
rbs_translation_context_t rbs_translation_context_create(rbs_constant_pool_t *, VALUE buffer_string, rb_encoding *ruby_encoding);
|
25
|
+
|
26
|
+
VALUE rbs_node_list_to_ruby_array(rbs_translation_context_t, rbs_node_list_t *list);
|
27
|
+
VALUE rbs_hash_to_ruby_hash(rbs_translation_context_t, rbs_hash_t *hash);
|
28
|
+
VALUE rbs_struct_to_ruby_value(rbs_translation_context_t, rbs_node_t *instance);
|
29
|
+
|
30
|
+
#endif
|
@@ -2,7 +2,7 @@
|
|
2
2
|
/* This file is generated by the templates/template.rb script and should not */
|
3
3
|
/* be modified manually. */
|
4
4
|
/* To change the template see */
|
5
|
-
/* templates/
|
5
|
+
/* templates/ext/rbs_extension/class_constants.c.erb */
|
6
6
|
/*----------------------------------------------------------------------------*/
|
7
7
|
|
8
8
|
#include "rbs_extension.h"
|
@@ -14,6 +14,8 @@ VALUE RBS_AST;
|
|
14
14
|
VALUE RBS_AST_Declarations;
|
15
15
|
VALUE RBS_AST_Directives;
|
16
16
|
VALUE RBS_AST_Members;
|
17
|
+
VALUE RBS_AST_Ruby;
|
18
|
+
VALUE RBS_AST_Ruby_Annotations;
|
17
19
|
VALUE RBS_Parser;
|
18
20
|
VALUE RBS_Types;
|
19
21
|
VALUE RBS_Types_Bases;
|
@@ -47,6 +49,11 @@ VALUE RBS_AST_Members_MethodDefinition_Overload;
|
|
47
49
|
VALUE RBS_AST_Members_Prepend;
|
48
50
|
VALUE RBS_AST_Members_Private;
|
49
51
|
VALUE RBS_AST_Members_Public;
|
52
|
+
VALUE RBS_AST_Ruby_Annotations_ColonMethodTypeAnnotation;
|
53
|
+
VALUE RBS_AST_Ruby_Annotations_MethodTypesAnnotation;
|
54
|
+
VALUE RBS_AST_Ruby_Annotations_NodeTypeAssertion;
|
55
|
+
VALUE RBS_AST_Ruby_Annotations_ReturnTypeAnnotation;
|
56
|
+
VALUE RBS_AST_Ruby_Annotations_SkipAnnotation;
|
50
57
|
VALUE RBS_AST_TypeParam;
|
51
58
|
VALUE RBS_MethodType;
|
52
59
|
VALUE RBS_Namespace;
|
@@ -89,6 +96,8 @@ void rbs__init_constants(void) {
|
|
89
96
|
IMPORT_CONSTANT(RBS_AST_Declarations, RBS_AST, "Declarations");
|
90
97
|
IMPORT_CONSTANT(RBS_AST_Directives, RBS_AST, "Directives");
|
91
98
|
IMPORT_CONSTANT(RBS_AST_Members, RBS_AST, "Members");
|
99
|
+
IMPORT_CONSTANT(RBS_AST_Ruby, RBS_AST, "Ruby");
|
100
|
+
IMPORT_CONSTANT(RBS_AST_Ruby_Annotations, RBS_AST_Ruby, "Annotations");
|
92
101
|
IMPORT_CONSTANT(RBS_Types, RBS, "Types");
|
93
102
|
IMPORT_CONSTANT(RBS_Types_Bases, RBS_Types, "Bases");
|
94
103
|
|
@@ -121,6 +130,11 @@ void rbs__init_constants(void) {
|
|
121
130
|
IMPORT_CONSTANT(RBS_AST_Members_Prepend, RBS_AST_Members, "Prepend");
|
122
131
|
IMPORT_CONSTANT(RBS_AST_Members_Private, RBS_AST_Members, "Private");
|
123
132
|
IMPORT_CONSTANT(RBS_AST_Members_Public, RBS_AST_Members, "Public");
|
133
|
+
IMPORT_CONSTANT(RBS_AST_Ruby_Annotations_ColonMethodTypeAnnotation, RBS_AST_Ruby_Annotations, "ColonMethodTypeAnnotation");
|
134
|
+
IMPORT_CONSTANT(RBS_AST_Ruby_Annotations_MethodTypesAnnotation, RBS_AST_Ruby_Annotations, "MethodTypesAnnotation");
|
135
|
+
IMPORT_CONSTANT(RBS_AST_Ruby_Annotations_NodeTypeAssertion, RBS_AST_Ruby_Annotations, "NodeTypeAssertion");
|
136
|
+
IMPORT_CONSTANT(RBS_AST_Ruby_Annotations_ReturnTypeAnnotation, RBS_AST_Ruby_Annotations, "ReturnTypeAnnotation");
|
137
|
+
IMPORT_CONSTANT(RBS_AST_Ruby_Annotations_SkipAnnotation, RBS_AST_Ruby_Annotations, "SkipAnnotation");
|
124
138
|
IMPORT_CONSTANT(RBS_AST_TypeParam, RBS_AST, "TypeParam");
|
125
139
|
IMPORT_CONSTANT(RBS_MethodType, RBS, "MethodType");
|
126
140
|
IMPORT_CONSTANT(RBS_Namespace, RBS, "Namespace");
|
@@ -2,18 +2,22 @@
|
|
2
2
|
/* This file is generated by the templates/template.rb script and should not */
|
3
3
|
/* be modified manually. */
|
4
4
|
/* To change the template see */
|
5
|
-
/* templates/
|
5
|
+
/* templates/ext/rbs_extension/class_constants.h.erb */
|
6
6
|
/*----------------------------------------------------------------------------*/
|
7
7
|
|
8
8
|
#ifndef RBS__CONSTANTS_H
|
9
9
|
#define RBS__CONSTANTS_H
|
10
10
|
|
11
|
+
#include "ruby.h"
|
12
|
+
|
11
13
|
extern VALUE RBS;
|
12
14
|
|
13
15
|
extern VALUE RBS_AST;
|
14
16
|
extern VALUE RBS_AST_Declarations;
|
15
17
|
extern VALUE RBS_AST_Directives;
|
16
18
|
extern VALUE RBS_AST_Members;
|
19
|
+
extern VALUE RBS_AST_Ruby;
|
20
|
+
extern VALUE RBS_AST_Ruby_Annotations;
|
17
21
|
extern VALUE RBS_Types;
|
18
22
|
extern VALUE RBS_Types_Bases;
|
19
23
|
extern VALUE RBS_ParsingError;
|
@@ -47,6 +51,11 @@ extern VALUE RBS_AST_Members_MethodDefinition_Overload;
|
|
47
51
|
extern VALUE RBS_AST_Members_Prepend;
|
48
52
|
extern VALUE RBS_AST_Members_Private;
|
49
53
|
extern VALUE RBS_AST_Members_Public;
|
54
|
+
extern VALUE RBS_AST_Ruby_Annotations_ColonMethodTypeAnnotation;
|
55
|
+
extern VALUE RBS_AST_Ruby_Annotations_MethodTypesAnnotation;
|
56
|
+
extern VALUE RBS_AST_Ruby_Annotations_NodeTypeAssertion;
|
57
|
+
extern VALUE RBS_AST_Ruby_Annotations_ReturnTypeAnnotation;
|
58
|
+
extern VALUE RBS_AST_Ruby_Annotations_SkipAnnotation;
|
50
59
|
extern VALUE RBS_AST_TypeParam;
|
51
60
|
extern VALUE RBS_MethodType;
|
52
61
|
extern VALUE RBS_Namespace;
|
@@ -11,5 +11,7 @@ root_dir = File.expand_path('../../../', __FILE__)
|
|
11
11
|
$srcs = Dir.glob("#{root_dir}/src/**/*.c") +
|
12
12
|
Dir.glob("#{root_dir}/ext/rbs_extension/*.c")
|
13
13
|
|
14
|
-
append_cflags ['-std=gnu99']
|
14
|
+
append_cflags ['-std=gnu99', '-Wimplicit-fallthrough', '-Wunused-result']
|
15
|
+
append_cflags ['-O0', '-g'] if ENV['DEBUG']
|
16
|
+
|
15
17
|
create_makefile 'rbs_extension'
|
@@ -1,3 +1,4 @@
|
|
1
|
+
#include "legacy_location.h"
|
1
2
|
#include "rbs_extension.h"
|
2
3
|
|
3
4
|
#define RBS_LOC_REQUIRED_P(loc, i) ((loc)->children->required_p & (1 << (i)))
|
@@ -8,17 +9,15 @@
|
|
8
9
|
rbs_loc_range RBS_LOC_NULL_RANGE = { -1, -1 };
|
9
10
|
VALUE RBS_Location;
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
return pos;
|
12
|
+
rbs_position_t rbs_loc_position(int char_pos) {
|
13
|
+
return (rbs_position_t) { 0, char_pos, -1, -1 };
|
14
14
|
}
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
return pos;
|
16
|
+
rbs_position_t rbs_loc_position3(int char_pos, int line, int column) {
|
17
|
+
return (rbs_position_t) { 0, char_pos, line, column };
|
19
18
|
}
|
20
19
|
|
21
|
-
rbs_loc_range rbs_new_loc_range(
|
20
|
+
static rbs_loc_range rbs_new_loc_range(rbs_range_t rg) {
|
22
21
|
rbs_loc_range r = { rg.start.char_pos, rg.end.char_pos };
|
23
22
|
return r;
|
24
23
|
}
|
@@ -30,7 +29,7 @@ static void check_children_max(unsigned short n) {
|
|
30
29
|
}
|
31
30
|
}
|
32
31
|
|
33
|
-
void
|
32
|
+
void rbs_loc_legacy_alloc_children(rbs_loc *loc, unsigned short cap) {
|
34
33
|
check_children_max(cap);
|
35
34
|
|
36
35
|
size_t s = RBS_LOC_CHILDREN_SIZE(cap);
|
@@ -46,7 +45,7 @@ void rbs_loc_alloc_children(rbs_loc *loc, unsigned short cap) {
|
|
46
45
|
|
47
46
|
static void check_children_cap(rbs_loc *loc) {
|
48
47
|
if (loc->children == NULL) {
|
49
|
-
|
48
|
+
rbs_loc_legacy_alloc_children(loc, 1);
|
50
49
|
} else {
|
51
50
|
if (loc->children->len == loc->children->cap) {
|
52
51
|
check_children_max(loc->children->cap + 1);
|
@@ -56,14 +55,7 @@ static void check_children_cap(rbs_loc *loc) {
|
|
56
55
|
}
|
57
56
|
}
|
58
57
|
|
59
|
-
void
|
60
|
-
rbs_loc_add_optional_child(loc, name, r);
|
61
|
-
|
62
|
-
unsigned short last_index = loc->children->len - 1;
|
63
|
-
loc->children->required_p |= 1 << last_index;
|
64
|
-
}
|
65
|
-
|
66
|
-
void rbs_loc_add_optional_child(rbs_loc *loc, rbs_constant_id_t name, range r) {
|
58
|
+
void rbs_loc_legacy_add_optional_child(rbs_loc *loc, rbs_constant_id_t name, rbs_range_t r) {
|
67
59
|
check_children_cap(loc);
|
68
60
|
|
69
61
|
unsigned short i = loc->children->len++;
|
@@ -73,6 +65,13 @@ void rbs_loc_add_optional_child(rbs_loc *loc, rbs_constant_id_t name, range r) {
|
|
73
65
|
};
|
74
66
|
}
|
75
67
|
|
68
|
+
void rbs_loc_legacy_add_required_child(rbs_loc *loc, rbs_constant_id_t name, rbs_range_t r) {
|
69
|
+
rbs_loc_legacy_add_optional_child(loc, name, r);
|
70
|
+
|
71
|
+
unsigned short last_index = loc->children->len - 1;
|
72
|
+
loc->children->required_p |= 1 << last_index;
|
73
|
+
}
|
74
|
+
|
76
75
|
void rbs_loc_init(rbs_loc *loc, VALUE buffer, rbs_loc_range rg) {
|
77
76
|
*loc = (rbs_loc) {
|
78
77
|
.buffer = buffer,
|
@@ -146,7 +145,7 @@ static VALUE location_initialize_copy(VALUE self, VALUE other) {
|
|
146
145
|
};
|
147
146
|
|
148
147
|
if (other_loc->children != NULL) {
|
149
|
-
|
148
|
+
rbs_loc_legacy_alloc_children(self_loc, other_loc->children->cap);
|
150
149
|
memcpy(self_loc->children, other_loc->children, RBS_LOC_CHILDREN_SIZE(other_loc->children->cap));
|
151
150
|
}
|
152
151
|
|
@@ -180,11 +179,11 @@ static rbs_constant_id_t rbs_constant_pool_insert_ruby_symbol(VALUE symbol) {
|
|
180
179
|
static VALUE location_add_required_child(VALUE self, VALUE name, VALUE start, VALUE end) {
|
181
180
|
rbs_loc *loc = rbs_check_location(self);
|
182
181
|
|
183
|
-
|
182
|
+
rbs_range_t rg;
|
184
183
|
rg.start = rbs_loc_position(FIX2INT(start));
|
185
184
|
rg.end = rbs_loc_position(FIX2INT(end));
|
186
185
|
|
187
|
-
|
186
|
+
rbs_loc_legacy_add_required_child(loc, rbs_constant_pool_insert_ruby_symbol(name), rg);
|
188
187
|
|
189
188
|
return Qnil;
|
190
189
|
}
|
@@ -192,11 +191,11 @@ static VALUE location_add_required_child(VALUE self, VALUE name, VALUE start, VA
|
|
192
191
|
static VALUE location_add_optional_child(VALUE self, VALUE name, VALUE start, VALUE end) {
|
193
192
|
rbs_loc *loc = rbs_check_location(self);
|
194
193
|
|
195
|
-
|
194
|
+
rbs_range_t rg;
|
196
195
|
rg.start = rbs_loc_position(FIX2INT(start));
|
197
196
|
rg.end = rbs_loc_position(FIX2INT(end));
|
198
197
|
|
199
|
-
|
198
|
+
rbs_loc_legacy_add_optional_child(loc, rbs_constant_pool_insert_ruby_symbol(name), rg);
|
200
199
|
|
201
200
|
return Qnil;
|
202
201
|
}
|
@@ -204,12 +203,12 @@ static VALUE location_add_optional_child(VALUE self, VALUE name, VALUE start, VA
|
|
204
203
|
static VALUE location_add_optional_no_child(VALUE self, VALUE name) {
|
205
204
|
rbs_loc *loc = rbs_check_location(self);
|
206
205
|
|
207
|
-
|
206
|
+
rbs_loc_legacy_add_optional_child(loc, rbs_constant_pool_insert_ruby_symbol(name), NULL_RANGE);
|
208
207
|
|
209
208
|
return Qnil;
|
210
209
|
}
|
211
210
|
|
212
|
-
VALUE rbs_new_location(VALUE buffer,
|
211
|
+
VALUE rbs_new_location(VALUE buffer, rbs_range_t rg) {
|
213
212
|
rbs_loc *loc;
|
214
213
|
VALUE obj = TypedData_Make_Struct(RBS_Location, rbs_loc, &location_type, loc);
|
215
214
|
|
@@ -300,22 +299,14 @@ static VALUE location_required_keys(VALUE self) {
|
|
300
299
|
return keys;
|
301
300
|
}
|
302
301
|
|
303
|
-
VALUE rbs_location_pp(VALUE buffer, const position *start_pos, const position *end_pos) {
|
304
|
-
range rg = { *start_pos, *end_pos };
|
305
|
-
rg.start = *start_pos;
|
306
|
-
rg.end = *end_pos;
|
307
|
-
|
308
|
-
return rbs_new_location(buffer, rg);
|
309
|
-
}
|
310
|
-
|
311
302
|
void rbs__init_location(void) {
|
312
303
|
RBS_Location = rb_define_class_under(RBS, "Location", rb_cObject);
|
313
304
|
rb_define_alloc_func(RBS_Location, location_s_allocate);
|
314
305
|
rb_define_private_method(RBS_Location, "initialize", location_initialize, 3);
|
315
306
|
rb_define_private_method(RBS_Location, "initialize_copy", location_initialize_copy, 1);
|
316
307
|
rb_define_method(RBS_Location, "buffer", location_buffer, 0);
|
317
|
-
rb_define_method(RBS_Location, "
|
318
|
-
rb_define_method(RBS_Location, "
|
308
|
+
rb_define_method(RBS_Location, "_start_pos", location_start_pos, 0);
|
309
|
+
rb_define_method(RBS_Location, "_end_pos", location_end_pos, 0);
|
319
310
|
rb_define_method(RBS_Location, "_add_required_child", location_add_required_child, 3);
|
320
311
|
rb_define_method(RBS_Location, "_add_optional_child", location_add_optional_child, 3);
|
321
312
|
rb_define_method(RBS_Location, "_add_optional_no_child", location_add_optional_no_child, 1);
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#ifndef RBS_LOCATION_H
|
2
|
+
#define RBS_LOCATION_H
|
3
|
+
|
4
|
+
#include "ruby.h"
|
5
|
+
#include "rbs.h"
|
6
|
+
|
7
|
+
/**
|
8
|
+
* RBS::Location class
|
9
|
+
* */
|
10
|
+
extern VALUE RBS_Location;
|
11
|
+
|
12
|
+
typedef struct {
|
13
|
+
VALUE buffer;
|
14
|
+
rbs_loc_range rg;
|
15
|
+
rbs_loc_children *children; // NULL when no children is allocated
|
16
|
+
} rbs_loc;
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Returns new RBS::Location object, with given buffer and range.
|
20
|
+
* */
|
21
|
+
VALUE rbs_new_location(VALUE buffer, rbs_range_t rg);
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Return rbs_loc associated with the RBS::Location object.
|
25
|
+
* */
|
26
|
+
rbs_loc *rbs_check_location(VALUE location);
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Allocate memory for child locations.
|
30
|
+
*
|
31
|
+
* Do not call twice for the same location.
|
32
|
+
* */
|
33
|
+
void rbs_loc_legacy_alloc_children(rbs_loc *loc, unsigned short cap);
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Define RBS::Location class.
|
37
|
+
* */
|
38
|
+
void rbs__init_location();
|
39
|
+
|
40
|
+
#endif
|