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
|
From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= <mail@3v1n0.net>
Date: Fri, 12 Sep 2025 00:31:30 +0200
Subject: overrides/Gio: Use Platform prefix for platform-only symbols
In previous versions of GLib, platform-specific symbols such as
GUnixMountMonitor were mapped in the Gio namespace as Gio.UnixMountMonitor,
while since commit 05656829 we create wrappers such as
Gio.MountMonitor.
This is not correct, and does not serve the initial purpose of providing
a backward compatible wrapper.
So, use the same logic that we had before: if the GType of a symbol starts
with G{Unix,Win32} we use the platform specific name as prefix of the
wrapper type, so that it will be Gio.{Unix,Win32}TypeName
---
modules/core/overrides/Gio.js | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/modules/core/overrides/Gio.js b/modules/core/overrides/Gio.js
index f5c24fc..e16e8fd 100644
--- a/modules/core/overrides/Gio.js
+++ b/modules/core/overrides/Gio.js
@@ -496,23 +496,30 @@ function _init() {
} catch {}
}
+ const platformName = `${GioPlatform?.__name__?.slice(3 /* 'Gio'.length */)}`;
Object.entries(Object.getOwnPropertyDescriptors(GioPlatform)).forEach(([prop, desc]) => {
- if (Object.hasOwn(Gio, prop)) {
- console.debug(`Gio already contains property ${prop}`);
- Gio[prop] = GioPlatform[prop];
+ let genericProp = prop;
+
+ const originalValue = GioPlatform[prop];
+ const gtypeName = originalValue.$gtype?.name;
+ if (gtypeName?.startsWith(`G${platformName}`))
+ genericProp = `${platformName}${prop}`;
+
+ if (Object.hasOwn(Gio, genericProp)) {
+ console.debug(`Gio already contains property ${genericProp}`);
+ Gio[genericProp] = originalValue;
return;
}
- const newDesc = {
+ Object.defineProperty(Gio, genericProp, {
enumerable: true,
configurable: false,
get() {
warnDeprecatedOncePerCallsite(PLATFORM_SPECIFIC_TYPELIB,
- `Gio.${prop}`, `${GioPlatform.__name__}.${prop}`);
+ `Gio.${genericProp}`, `${GioPlatform.__name__}.${prop}`);
return desc.get?.() ?? desc.value;
},
- };
- Object.defineProperty(Gio, prop, newDesc);
+ });
});
Gio.DBus = {
|