(namespace)
| 126 | } |
| 127 | |
| 128 | function _createWrappersForPlatformSpecificNamespace(namespace) { |
| 129 | // Redefine namespace properties with platform-specific implementations to |
| 130 | // be backward compatible with gi-repository 1.0, however when possible we |
| 131 | // notify a deprecation warning, to ensure that the surrounding code is |
| 132 | // updated. |
| 133 | |
| 134 | let platformNamespace; |
| 135 | let platformName; |
| 136 | const namespaceName = namespace.__name__; |
| 137 | try { |
| 138 | platformName = 'Unix'; |
| 139 | platformNamespace = imports.gi[`${namespaceName}${platformName}`]; |
| 140 | } catch { |
| 141 | try { |
| 142 | platformName = 'Win32'; |
| 143 | platformNamespace = imports.gi[`${namespaceName}${platformName}`]; |
| 144 | } catch { |
| 145 | return; |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | const platformNameLower = platformName.toLowerCase(); |
| 150 | Object.entries(Object.getOwnPropertyDescriptors(platformNamespace)).forEach(([prop, desc]) => { |
| 151 | let genericProp = prop; |
| 152 | |
| 153 | const originalValue = platformNamespace[prop]; |
| 154 | const gtypeName = originalValue.$gtype?.name; |
| 155 | if (gtypeName?.startsWith(`G${platformName}`)) |
| 156 | genericProp = `${platformName}${prop}`; |
| 157 | else if (originalValue instanceof Function && |
| 158 | originalValue.name.startsWith(`g_${platformNameLower}_`)) |
| 159 | genericProp = `${platformNameLower}_${prop}`; |
| 160 | else if (originalValue instanceof Object && |
| 161 | (!gtypeName || gtypeName === 'void') && |
| 162 | (!originalValue.name || originalValue.name.startsWith( |
| 163 | `${namespaceName}${platformName}_`))) |
| 164 | genericProp = `${platformName}${prop}`; |
| 165 | |
| 166 | if (Object.hasOwn(namespace, genericProp)) { |
| 167 | console.log(`${namespaceName} already contains property ${genericProp}`); |
| 168 | namespace[genericProp] = originalValue; |
| 169 | return; |
| 170 | } |
| 171 | |
| 172 | _defineDeprecatedWrapperForDescriptor( |
| 173 | namespace, platformNamespace, genericProp, prop, desc, |
| 174 | PLATFORM_SPECIFIC_TYPELIB); |
| 175 | }); |
| 176 | } |
| 177 | |
| 178 | function _defineDeprecatedWrapperForDescriptor( |
| 179 | namespace, newNamespace, oldName, newName, desc, deprecationReason = RENAMED) { |
no test coverage detected