You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Annotate nullable pointer fields in config.yml with optional: true (#70)
Some C struct pointer fields can be NULL (super_class when no parent
class, comment when no doc comment). This metadata allows our Rust
codegen to generate Option<T> return types for these accessors instead
of unconditionally wrapping potentially NULL pointers.
Copy file name to clipboardExpand all lines: config.yml
+38Lines changed: 38 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -25,12 +25,14 @@ nodes:
25
25
c_type: rbs_node_list
26
26
- name: super_class
27
27
c_type: rbs_ast_declarations_class_super
28
+
optional: true # NULL when no superclass (e.g., `class Foo end` vs `class Foo < Bar end`)
28
29
- name: members
29
30
c_type: rbs_node_list
30
31
- name: annotations
31
32
c_type: rbs_node_list
32
33
- name: comment
33
34
c_type: rbs_ast_comment
35
+
optional: true # NULL when no comment precedes the declaration
34
36
- name: RBS::AST::Declarations::Class::Super
35
37
rust_name: ClassSuperNode
36
38
fields:
@@ -47,6 +49,7 @@ nodes:
47
49
c_type: rbs_type_name
48
50
- name: comment
49
51
c_type: rbs_ast_comment
52
+
optional: true # NULL when no comment precedes the declaration
50
53
- name: annotations
51
54
c_type: rbs_node_list
52
55
- name: RBS::AST::Declarations::Constant
@@ -58,6 +61,7 @@ nodes:
58
61
c_type: rbs_node
59
62
- name: comment
60
63
c_type: rbs_ast_comment
64
+
optional: true # NULL when no comment precedes the declaration
61
65
- name: annotations
62
66
c_type: rbs_node_list
63
67
- name: RBS::AST::Declarations::Global
@@ -69,6 +73,7 @@ nodes:
69
73
c_type: rbs_node
70
74
- name: comment
71
75
c_type: rbs_ast_comment
76
+
optional: true # NULL when no comment precedes the declaration
72
77
- name: annotations
73
78
c_type: rbs_node_list
74
79
- name: RBS::AST::Declarations::Interface
@@ -84,6 +89,7 @@ nodes:
84
89
c_type: rbs_node_list
85
90
- name: comment
86
91
c_type: rbs_ast_comment
92
+
optional: true # NULL when no comment precedes the declaration
87
93
- name: RBS::AST::Declarations::Module
88
94
rust_name: ModuleNode
89
95
fields:
@@ -99,6 +105,7 @@ nodes:
99
105
c_type: rbs_node_list
100
106
- name: comment
101
107
c_type: rbs_ast_comment
108
+
optional: true # NULL when no comment precedes the declaration
102
109
- name: RBS::AST::Declarations::Module::Self
103
110
rust_name: ModuleSelfNode
104
111
fields:
@@ -115,6 +122,7 @@ nodes:
115
122
c_type: rbs_type_name
116
123
- name: comment
117
124
c_type: rbs_ast_comment
125
+
optional: true # NULL when no comment precedes the declaration
118
126
- name: annotations
119
127
c_type: rbs_node_list
120
128
- name: RBS::AST::Declarations::TypeAlias
@@ -130,6 +138,7 @@ nodes:
130
138
c_type: rbs_node_list
131
139
- name: comment
132
140
c_type: rbs_ast_comment
141
+
optional: true # NULL when no comment precedes the declaration
133
142
- name: RBS::AST::Directives::Use
134
143
rust_name: UseNode
135
144
fields:
@@ -142,6 +151,7 @@ nodes:
142
151
c_type: rbs_type_name
143
152
- name: new_name
144
153
c_type: rbs_ast_symbol
154
+
optional: true # NULL when no alias (e.g., `use Foo::Bar` vs `use Foo::Bar as Baz`)
145
155
- name: RBS::AST::Directives::Use::WildcardClause
146
156
rust_name: UseWildcardClauseNode
147
157
fields:
@@ -161,6 +171,7 @@ nodes:
161
171
c_type: rbs_node_list
162
172
- name: comment
163
173
c_type: rbs_ast_comment
174
+
optional: true # NULL when no comment precedes the declaration
164
175
- name: RBS::AST::Members::AttrAccessor
165
176
rust_name: AttrAccessorNode
166
177
fields:
@@ -170,14 +181,17 @@ nodes:
170
181
c_type: rbs_node
171
182
- name: ivar_name
172
183
c_type: rbs_node # rbs_ast_symbol_t, NULL or rbs_ast_bool_new(false)
184
+
optional: true # NULL when omitted (`attr_accessor foo: T`); Symbol when named (`attr_accessor foo (@bar): T`); Bool(false) when empty parens (`attr_accessor foo (): T`)
173
185
- name: kind
174
186
c_type: rbs_keyword
175
187
- name: annotations
176
188
c_type: rbs_node_list
177
189
- name: comment
178
190
c_type: rbs_ast_comment
191
+
optional: true # NULL when no comment precedes the declaration
179
192
- name: visibility
180
193
c_type: rbs_keyword
194
+
optional: true # NULL when no visibility prefix (e.g., `attr_accessor foo: T` vs `private attr_accessor foo: T`)
181
195
- name: RBS::AST::Members::AttrReader
182
196
rust_name: AttrReaderNode
183
197
fields:
@@ -187,14 +201,17 @@ nodes:
187
201
c_type: rbs_node
188
202
- name: ivar_name
189
203
c_type: rbs_node # rbs_ast_symbol_t, NULL or rbs_ast_bool_new(false)
204
+
optional: true # NULL when omitted (`attr_reader foo: T`); Symbol when named (`attr_reader foo (@bar): T`); Bool(false) when empty parens (`attr_reader foo (): T`)
190
205
- name: kind
191
206
c_type: rbs_keyword
192
207
- name: annotations
193
208
c_type: rbs_node_list
194
209
- name: comment
195
210
c_type: rbs_ast_comment
211
+
optional: true # NULL when no comment precedes the declaration
196
212
- name: visibility
197
213
c_type: rbs_keyword
214
+
optional: true # NULL when no visibility prefix (e.g., `attr_reader foo: T` vs `private attr_reader foo: T`)
198
215
- name: RBS::AST::Members::AttrWriter
199
216
rust_name: AttrWriterNode
200
217
fields:
@@ -204,14 +221,17 @@ nodes:
204
221
c_type: rbs_node
205
222
- name: ivar_name
206
223
c_type: rbs_node # rbs_ast_symbol_t, NULL or rbs_ast_bool_new(false)
224
+
optional: true # NULL when omitted (`attr_writer foo: T`); Symbol when named (`attr_writer foo (@bar): T`); Bool(false) when empty parens (`attr_writer foo (): T`)
207
225
- name: kind
208
226
c_type: rbs_keyword
209
227
- name: annotations
210
228
c_type: rbs_node_list
211
229
- name: comment
212
230
c_type: rbs_ast_comment
231
+
optional: true # NULL when no comment precedes the declaration
213
232
- name: visibility
214
233
c_type: rbs_keyword
234
+
optional: true # NULL when no visibility prefix (e.g., `attr_writer foo: T` vs `private attr_writer foo: T`)
215
235
- name: RBS::AST::Members::ClassInstanceVariable
216
236
rust_name: ClassInstanceVariableNode
217
237
fields:
@@ -221,6 +241,7 @@ nodes:
221
241
c_type: rbs_node
222
242
- name: comment
223
243
c_type: rbs_ast_comment
244
+
optional: true # NULL when no comment precedes the declaration
224
245
- name: RBS::AST::Members::ClassVariable
225
246
rust_name: ClassVariableNode
226
247
fields:
@@ -230,6 +251,7 @@ nodes:
230
251
c_type: rbs_node
231
252
- name: comment
232
253
c_type: rbs_ast_comment
254
+
optional: true # NULL when no comment precedes the declaration
233
255
- name: RBS::AST::Members::Extend
234
256
rust_name: ExtendNode
235
257
fields:
@@ -241,6 +263,7 @@ nodes:
241
263
c_type: rbs_node_list
242
264
- name: comment
243
265
c_type: rbs_ast_comment
266
+
optional: true # NULL when no comment precedes the declaration
244
267
- name: RBS::AST::Members::Include
245
268
rust_name: IncludeNode
246
269
fields:
@@ -252,6 +275,7 @@ nodes:
252
275
c_type: rbs_node_list
253
276
- name: comment
254
277
c_type: rbs_ast_comment
278
+
optional: true # NULL when no comment precedes the declaration
255
279
- name: RBS::AST::Members::InstanceVariable
256
280
rust_name: InstanceVariableNode
257
281
fields:
@@ -261,6 +285,7 @@ nodes:
261
285
c_type: rbs_node
262
286
- name: comment
263
287
c_type: rbs_ast_comment
288
+
optional: true # NULL when no comment precedes the declaration
264
289
- name: RBS::AST::Members::MethodDefinition
265
290
rust_name: MethodDefinitionNode
266
291
fields:
@@ -274,10 +299,12 @@ nodes:
274
299
c_type: rbs_node_list
275
300
- name: comment
276
301
c_type: rbs_ast_comment
302
+
optional: true # NULL when no comment precedes the declaration
277
303
- name: overloading
278
304
c_type: bool
279
305
- name: visibility
280
306
c_type: rbs_keyword
307
+
optional: true # NULL when no visibility prefix (e.g., `def foo: ...` vs `private def foo: ...`)
0 commit comments