-
Notifications
You must be signed in to change notification settings - Fork 0
/
header.py
57 lines (43 loc) · 1.49 KB
/
header.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# class_implementation/classes/header.py
class HeaderFile:
def __init__(self, name):
self.name = name
self.macros = []
self.types = []
self.enumerations = []
self.objects = []
self.functions = []
self.includes = []
def add_macro(self, macro):
self.macros.append(macro)
def add_type(self, type_):
self.types.append(type_)
def add_enumeration(self, enumeration):
self.enumerations.append(enumeration)
def add_object(self, object):
self.objects.append(object)
def add_function(self, function):
self.functions.append(function)
def add_include(self, include):
self.includes.append(include)
def __str__(self):
content = [""]
for include in self.includes:
content.append(str(include))
for macro in self.macros:
content.append(str(macro))
for type_ in self.types:
content.append(str(type_))
if self.enumerations:
content.append("enum {")
for enum in self.enumerations:
content.append(f"\t{str(enum)},")
content.append("};")
content.append("__BEGIN_C_DECLS\n")
for function in self.functions:
content.append(str(function))
content.append("")
for object in self.objects:
content.append(str(object))
content.append("__END_C_DECLS\n")
return "\n".join(content)