-
Notifications
You must be signed in to change notification settings - Fork 172
Expand file tree
/
Copy pathc_visitor_impl.py
More file actions
39 lines (29 loc) · 939 Bytes
/
c_visitor_impl.py
File metadata and controls
39 lines (29 loc) · 939 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Copyright (c) 2015-present, Facebook, Inc.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import print_function
from casing import snake
from license import C_LICENSE_COMMENT
class Printer(object):
'''Printer for a simple list of types to be visited by the C visitor.
'''
def __init__(self):
self._types = []
def start_file(self):
print(C_LICENSE_COMMENT + '/** @generated */')
print('#define FOR_EACH_CONCRETE_TYPE(MACRO) \\')
def start_type(self, name):
self._types.append(name)
def field(self, type, name, nullable, plural):
pass
def end_type(self, name):
pass
def end_file(self):
print(' \\\n'.join('MACRO(%s, %s)' % (name, snake(name)) for name in self._types))
def start_union(self, name):
pass
def union_option(self, option):
pass
def end_union(self, name):
pass