Create the code code "__constants.c" and "__constants.h" files. This needs to create code to make all global constants (used in more than one module) and create them.
()
| 83 | |
| 84 | |
| 85 | def getConstantsDefinitionCode(): |
| 86 | """Create the code code "__constants.c" and "__constants.h" files. |
| 87 | |
| 88 | This needs to create code to make all global constants (used in more |
| 89 | than one module) and create them. |
| 90 | |
| 91 | """ |
| 92 | # Somewhat detail rich, pylint: disable=too-many-locals |
| 93 | |
| 94 | constant_accessor = GlobalConstantAccessor( |
| 95 | data_filename="__constants.const", top_level_name="global_constants" |
| 96 | ) |
| 97 | |
| 98 | lines = [] |
| 99 | |
| 100 | for constant_value in getConstantDefaultPopulation(): |
| 101 | identifier = constant_accessor.getConstantCode(constant_value) |
| 102 | |
| 103 | assert "[" in identifier, (identifier, constant_value) |
| 104 | |
| 105 | lines.append("// %s" % repr(constant_value)) |
| 106 | lines.append( |
| 107 | "#define const_%s %s" % (namifyConstant(constant_value), identifier) |
| 108 | ) |
| 109 | |
| 110 | sys_executable = None |
| 111 | |
| 112 | if not shallMakeModule(): |
| 113 | if isStandaloneMode(): |
| 114 | # The directory is added back at run time. |
| 115 | sys_executable = constant_accessor.getConstantCode( |
| 116 | os.path.basename(sys.executable) |
| 117 | ) |
| 118 | else: |
| 119 | sys_executable = constant_accessor.getConstantCode(sys.executable) |
| 120 | |
| 121 | sys_prefix = None |
| 122 | sys_base_prefix = None |
| 123 | sys_exec_prefix = None |
| 124 | sys_base_exec_prefix = None |
| 125 | |
| 126 | # TODO: This part is needed for main program only, so do it there? |
| 127 | if not shallMakeModule() and not isStandaloneMode(): |
| 128 | sys_prefix = constant_accessor.getConstantCode(sys.prefix) |
| 129 | sys_exec_prefix = constant_accessor.getConstantCode(sys.exec_prefix) |
| 130 | |
| 131 | if python_version >= 0x300: |
| 132 | sys_base_prefix = constant_accessor.getConstantCode(sys.base_prefix) |
| 133 | sys_base_exec_prefix = constant_accessor.getConstantCode( |
| 134 | sys.base_exec_prefix |
| 135 | ) |
| 136 | |
| 137 | runtime_metadata_values = tuple( |
| 138 | ( |
| 139 | distribution_name, |
| 140 | ( |
| 141 | metadata_value.module_name, |
| 142 | metadata_value.metadata, |
no test coverage detected
searching dependent graphs…