@@ -52,7 +52,7 @@ def on_include(self, state: State, filename: str) -> None:
52
52
Called once for each ``#include`` directive encountered
53
53
"""
54
54
55
- def on_empty_block_start (self , state : EmptyBlockState ) -> None :
55
+ def on_empty_block_start (self , state : EmptyBlockState ) -> typing . Optional [ bool ] :
56
56
"""
57
57
Called when a ``{`` is encountered that isn't associated with or
58
58
consumed by other declarations.
@@ -62,31 +62,39 @@ def on_empty_block_start(self, state: EmptyBlockState) -> None:
62
62
{
63
63
// stuff
64
64
}
65
+
66
+ If this function returns False, the visitor will not be called for any
67
+ items inside this block (including on_empty_block_end)
65
68
"""
66
69
67
70
def on_empty_block_end (self , state : EmptyBlockState ) -> None :
68
71
"""
69
72
Called when an empty block ends
70
73
"""
71
74
72
- def on_extern_block_start (self , state : ExternBlockState ) -> None :
75
+ def on_extern_block_start (self , state : ExternBlockState ) -> typing . Optional [ bool ] :
73
76
"""
74
77
.. code-block:: c++
75
78
76
79
extern "C" {
77
80
78
81
}
79
82
83
+ If this function returns False, the visitor will not be called for any
84
+ items inside this block (including on_extern_block_end)
80
85
"""
81
86
82
87
def on_extern_block_end (self , state : ExternBlockState ) -> None :
83
88
"""
84
89
Called when an extern block ends
85
90
"""
86
91
87
- def on_namespace_start (self , state : NamespaceBlockState ) -> None :
92
+ def on_namespace_start (self , state : NamespaceBlockState ) -> typing . Optional [ bool ] :
88
93
"""
89
94
Called when a ``namespace`` directive is encountered
95
+
96
+ If this function returns False, the visitor will not be called for any
97
+ items inside this namespace (including on_namespace_end)
90
98
"""
91
99
92
100
def on_namespace_end (self , state : NamespaceBlockState ) -> None :
@@ -186,7 +194,7 @@ def on_enum(self, state: State, enum: EnumDecl) -> None:
186
194
# Class/union/struct
187
195
#
188
196
189
- def on_class_start (self , state : ClassBlockState ) -> None :
197
+ def on_class_start (self , state : ClassBlockState ) -> typing . Optional [ bool ] :
190
198
"""
191
199
Called when a class/struct/union is encountered
192
200
@@ -199,6 +207,9 @@ def on_class_start(self, state: ClassBlockState) -> None:
199
207
This is called first, followed by on_typedef for each typedef instance
200
208
encountered. The compound type object is passed as the type to the
201
209
typedef.
210
+
211
+ If this function returns False, the visitor will not be called for any
212
+ items inside this class (including on_class_end)
202
213
"""
203
214
204
215
def on_class_field (self , state : ClassBlockState , f : Field ) -> None :
@@ -231,3 +242,87 @@ def on_class_end(self, state: ClassBlockState) -> None:
231
242
Then ``on_class_start``, .. ``on_class_end`` are emitted, along with
232
243
``on_variable`` for each instance declared.
233
244
"""
245
+
246
+
247
+ class NullVisitor :
248
+ """
249
+ This visitor does nothing
250
+ """
251
+
252
+ def on_parse_start (self , state : NamespaceBlockState ) -> None :
253
+ return None
254
+
255
+ def on_pragma (self , state : State , content : Value ) -> None :
256
+ return None
257
+
258
+ def on_include (self , state : State , filename : str ) -> None :
259
+ return None
260
+
261
+ def on_empty_block_start (self , state : EmptyBlockState ) -> typing .Optional [bool ]:
262
+ return None
263
+
264
+ def on_empty_block_end (self , state : EmptyBlockState ) -> None :
265
+ return None
266
+
267
+ def on_extern_block_start (self , state : ExternBlockState ) -> typing .Optional [bool ]:
268
+ return None
269
+
270
+ def on_extern_block_end (self , state : ExternBlockState ) -> None :
271
+ return None
272
+
273
+ def on_namespace_start (self , state : NamespaceBlockState ) -> typing .Optional [bool ]:
274
+ return None
275
+
276
+ def on_namespace_end (self , state : NamespaceBlockState ) -> None :
277
+ return None
278
+
279
+ def on_namespace_alias (self , state : State , alias : NamespaceAlias ) -> None :
280
+ return None
281
+
282
+ def on_forward_decl (self , state : State , fdecl : ForwardDecl ) -> None :
283
+ return None
284
+
285
+ def on_template_inst (self , state : State , inst : TemplateInst ) -> None :
286
+ return None
287
+
288
+ def on_variable (self , state : State , v : Variable ) -> None :
289
+ return None
290
+
291
+ def on_function (self , state : State , fn : Function ) -> None :
292
+ return None
293
+
294
+ def on_method_impl (self , state : State , method : Method ) -> None :
295
+ return None
296
+
297
+ def on_typedef (self , state : State , typedef : Typedef ) -> None :
298
+ return None
299
+
300
+ def on_using_namespace (self , state : State , namespace : typing .List [str ]) -> None :
301
+ return None
302
+
303
+ def on_using_alias (self , state : State , using : UsingAlias ) -> None :
304
+ return None
305
+
306
+ def on_using_declaration (self , state : State , using : UsingDecl ) -> None :
307
+ return None
308
+
309
+ def on_enum (self , state : State , enum : EnumDecl ) -> None :
310
+ return None
311
+
312
+ def on_class_start (self , state : ClassBlockState ) -> typing .Optional [bool ]:
313
+ return None
314
+
315
+ def on_class_field (self , state : ClassBlockState , f : Field ) -> None :
316
+ return None
317
+
318
+ def on_class_friend (self , state : ClassBlockState , friend : FriendDecl ) -> None :
319
+ return None
320
+
321
+ def on_class_method (self , state : ClassBlockState , method : Method ) -> None :
322
+ return None
323
+
324
+ def on_class_end (self , state : ClassBlockState ) -> None :
325
+ return None
326
+
327
+
328
+ null_visitor = NullVisitor ()
0 commit comments