(tree, cur="", indent=0)
| 72 | |
| 73 | |
| 74 | def print_class(tree, cur="", indent=0): |
| 75 | firstInstance = True |
| 76 | for k in tree.keys(): |
| 77 | if isinstance(tree[k], dict): |
| 78 | if indent > 0: |
| 79 | indentp("private:", indent - 1) |
| 80 | if cur == "proxy": |
| 81 | indentp("friend class cripts::Context; // Needed to set the state", indent) |
| 82 | print() |
| 83 | indentp("class {}".format(k.title()), indent) |
| 84 | indentp("{", indent) |
| 85 | print_class(tree[k], k, indent + 1) |
| 86 | else: |
| 87 | if firstInstance: |
| 88 | indentp("public:", indent - 1) |
| 89 | firstInstance = False |
| 90 | if tree[k][1] == "TS_RECORDDATATYPE_INT": |
| 91 | indentp("cripts::IntConfig {}{{\"{}\"}};".format(k, tree[k][2]), indent) |
| 92 | elif tree[k][1] == "TS_RECORDDATATYPE_FLOAT": |
| 93 | indentp("cripts::FloatConfig {}{{\"{}\"}};".format(k, tree[k][2]), indent) |
| 94 | elif tree[k][1] == "TS_RECORDDATATYPE_STRING": |
| 95 | indentp("cripts::StringConfig {}{{\"{}\"}};".format(k, tree[k][2]), indent) |
| 96 | else: |
| 97 | print("The source file has a bad configuration data type: {}".format(tree[k][1])) |
| 98 | if cur: |
| 99 | indentp("}}; // End class {}".format(cur.title()), indent - 1) |
| 100 | print() |
| 101 | if cur != "proxy": |
| 102 | indentp("public:", indent - 2) |
| 103 | indentp("{} {};".format(cur.title(), cur), indent - 1) |
| 104 | print() |
| 105 | |
| 106 | |
| 107 | lines = list(fileinput.input()) |
no test coverage detected