aboutsummaryrefslogtreecommitdiffstats
path: root/build-aux/qmi-codegen/TypeFactory.py
blob: 0e1e0f8c2197ab3fb0d04b116a522e6d039d22b8 (plain)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env python
# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil -*-
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright (C) 2012 Lanedo GmbH
#


"""
List to keep track of types already emitted to the source/header files.
"""
emitted_types = []

"""
Checks whether a given type has already been emitted.
"""
def is_type_emitted(type_name):
    for i in emitted_types:
        if i == type_name:
            return True
    else:
        return False

"""
Sets the given type as already emitted.
"""
def set_type_emitted(type_name):
    if is_type_emitted(type_name):
        return False
    else:
        emitted_types.append(type_name)
        return True



"""
List to keep track of type-specific helper methods already emitted to
the source/header files.
"""
emitted_helpers = []

"""
Checks whether a given type-specific helpers have already been emitted.
"""
def helpers_emitted(type_name):
    for i in emitted_helpers:
        if i == type_name:
            return True
    else:
        return False

"""
Sets the given type-specific get_printable() as already emitted.
"""
def set_helpers_emitted(type_name):
    if helpers_emitted(type_name):
        return False
    else:
        emitted_helpers.append(type_name)
        return True


"""
List to keep track of sections already emitted to the source/header files.
"""
emitted_sections = []

"""
Checks whether a given section has already been emitted.
"""
def is_section_emitted(section_name):
    for i in emitted_sections:
        if i == section_name:
            return True
    else:
        return False

"""
Sets the given section as already emitted.
"""
def set_section_emitted(section_name):
    if is_section_emitted(section_name):
        return False
    else:
        emitted_sections.append(section_name)
        return True