| 1 |
# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil -*- |
| 2 |
# |
| 3 |
# This program is free software; you can redistribute it and/or modify it under |
| 4 |
# the terms of the GNU Lesser General Public License as published by the Free |
| 5 |
# Software Foundation; either version 2 of the License, or (at your option) any |
| 6 |
# later version. |
| 7 |
# |
| 8 |
# This program is distributed in the hope that it will be useful, but WITHOUT |
| 9 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 10 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
| 11 |
# details. |
| 12 |
# |
| 13 |
# You should have received a copy of the GNU Lesser General Public License along |
| 14 |
# with this program; if not, write to the Free Software Foundation, Inc., 51 |
| 15 |
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 16 |
# |
| 17 |
# Copyright (C) 2012 Lanedo GmbH |
| 18 |
# Copyright (C) 2012-2022 Aleksander Morgado <[email protected]> |
| 19 |
# |
| 20 |
|
| 21 |
|
| 22 |
""" |
| 23 |
List to keep track of types already emitted to the source/header files. |
| 24 |
""" |
| 25 |
emitted_types = [] |
| 26 |
|
| 27 |
""" |
| 28 |
Checks whether a given type has already been emitted. |
| 29 |
""" |
| 30 |
def is_type_emitted(type_name): |
| 31 |
for i in emitted_types: |
| 32 |
if i == type_name: |
| 33 |
return True |
| 34 |
else: |
| 35 |
return False |
| 36 |
|
| 37 |
""" |
| 38 |
Sets the given type as already emitted. |
| 39 |
""" |
| 40 |
def set_type_emitted(type_name): |
| 41 |
if is_type_emitted(type_name): |
| 42 |
return False |
| 43 |
else: |
| 44 |
emitted_types.append(type_name) |
| 45 |
return True |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
""" |
| 50 |
List to keep track of type-specific helper methods already emitted to |
| 51 |
the source/header files. |
| 52 |
""" |
| 53 |
emitted_helpers = [] |
| 54 |
|
| 55 |
""" |
| 56 |
Checks whether a given type-specific helpers have already been emitted. |
| 57 |
""" |
| 58 |
def helpers_emitted(type_name): |
| 59 |
for i in emitted_helpers: |
| 60 |
if i == type_name: |
| 61 |
return True |
| 62 |
else: |
| 63 |
return False |
| 64 |
|
| 65 |
""" |
| 66 |
Sets the given type-specific get_printable() as already emitted. |
| 67 |
""" |
| 68 |
def set_helpers_emitted(type_name): |
| 69 |
if helpers_emitted(type_name): |
| 70 |
return False |
| 71 |
else: |
| 72 |
emitted_helpers.append(type_name) |
| 73 |
return True |
| 74 |
|
| 75 |
|
| 76 |
""" |
| 77 |
List to keep track of sections already emitted to the source/header files. |
| 78 |
""" |
| 79 |
emitted_sections = [] |
| 80 |
|
| 81 |
""" |
| 82 |
Checks whether a given section has already been emitted. |
| 83 |
""" |
| 84 |
def is_section_emitted(section_name): |
| 85 |
for i in emitted_sections: |
| 86 |
if i == section_name: |
| 87 |
return True |
| 88 |
else: |
| 89 |
return False |
| 90 |
|
| 91 |
""" |
| 92 |
Sets the given section as already emitted. |
| 93 |
""" |
| 94 |
def set_section_emitted(section_name): |
| 95 |
if is_section_emitted(section_name): |
| 96 |
return False |
| 97 |
else: |
| 98 |
emitted_sections.append(section_name) |
| 99 |
return True |