LCOV - code coverage report
Current view: top level - modules/core/overrides - GObject.js (source / functions) Coverage Total Hit
Test: gjs- Code Coverage Lines: 93.0 % 471 438
Test Date: 2024-04-29 05:18:28 Functions: 80.0 % 75 60
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 71.7 % 226 162

             Branch data     Line data    Source code
       1                 :          47 : /* exported _init, interfaces, properties, registerClass, requires, signals */
       2                 :             : // SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
       3                 :             : // SPDX-FileCopyrightText: 2011 Jasper St. Pierre
       4                 :             : // SPDX-FileCopyrightText: 2017 Philip Chimento <philip.chimento@gmail.com>, <philip@endlessm.com>
       5                 :             : 
       6                 :          47 : const Gi = imports._gi;
       7                 :          47 : const {GjsPrivate, GLib} = imports.gi;
       8                 :          47 : const {_checkAccessors, _registerType} = imports._common;
       9                 :          47 : const Legacy = imports._legacy;
      10                 :             : 
      11                 :          47 : let GObject;
      12                 :             : 
      13                 :          47 : var GTypeName = Symbol('GType name');
      14                 :          47 : var GTypeFlags = Symbol('GType flags');
      15                 :          47 : var interfaces = Symbol('GObject interfaces');
      16                 :          47 : var properties = Symbol('GObject properties');
      17                 :          47 : var requires = Symbol('GObject interface requires');
      18                 :          47 : var signals = Symbol('GObject signals');
      19                 :             : 
      20                 :             : // These four will be aliased to GTK
      21                 :          47 : var _gtkChildren = Symbol('GTK widget template children');
      22                 :          47 : var _gtkCssName = Symbol('GTK widget CSS name');
      23                 :          47 : var _gtkInternalChildren = Symbol('GTK widget template internal children');
      24                 :          47 : var _gtkTemplate = Symbol('GTK widget template');
      25                 :             : 
      26                 :          96 : function registerClass(...args) {
      27                 :          96 :     let klass = args[0];
      28         [ +  + ]:          96 :     if (args.length === 2) {
      29                 :             :         // The two-argument form is the convenient syntax without ESnext
      30                 :             :         // decorators and class data properties. The first argument is an
      31                 :             :         // object with meta info such as properties and signals. The second
      32                 :             :         // argument is the class expression for the class itself.
      33                 :             :         //
      34                 :             :         //     var MyClass = GObject.registerClass({
      35                 :             :         //         Properties: { ... },
      36                 :             :         //         Signals: { ... },
      37                 :             :         //     }, class MyClass extends GObject.Object {
      38                 :             :         //         _init() { ... }
      39                 :             :         //     });
      40                 :             :         //
      41                 :             :         // When decorators and class data properties become part of the JS
      42                 :             :         // standard, this function can be used directly as a decorator.
      43                 :          66 :         let metaInfo = args[0];
      44                 :          66 :         klass = args[1];
      45         [ +  + ]:          66 :         if ('GTypeName' in metaInfo)
      46                 :           6 :             klass[GTypeName] = metaInfo.GTypeName;
      47         [ +  + ]:          66 :         if ('GTypeFlags' in metaInfo)
      48                 :           1 :             klass[GTypeFlags] = metaInfo.GTypeFlags;
      49         [ +  + ]:          66 :         if ('Implements' in metaInfo)
      50                 :          25 :             klass[interfaces] = metaInfo.Implements;
      51         [ +  + ]:          66 :         if ('Properties' in metaInfo)
      52                 :          27 :             klass[properties] = metaInfo.Properties;
      53         [ +  + ]:          66 :         if ('Signals' in metaInfo)
      54                 :           8 :             klass[signals] = metaInfo.Signals;
      55         [ +  + ]:          66 :         if ('Requires' in metaInfo)
      56                 :           3 :             klass[requires] = metaInfo.Requires;
      57         [ +  + ]:          66 :         if ('CssName' in metaInfo)
      58                 :           2 :             klass[_gtkCssName] = metaInfo.CssName;
      59         [ +  + ]:          66 :         if ('Template' in metaInfo)
      60                 :          11 :             klass[_gtkTemplate] = metaInfo.Template;
      61         [ +  + ]:          66 :         if ('Children' in metaInfo)
      62                 :           8 :             klass[_gtkChildren] = metaInfo.Children;
      63         [ +  + ]:          66 :         if ('InternalChildren' in metaInfo)
      64                 :           8 :             klass[_gtkInternalChildren] = metaInfo.InternalChildren;
      65                 :             :     }
      66                 :             : 
      67         [ +  + ]:          96 :     if (!(klass.prototype instanceof GObject.Object) &&
      68         [ +  + ]:           8 :         !(klass.prototype instanceof GObject.Interface)) {
      69                 :          10 :         throw new TypeError('GObject.registerClass() used with invalid base ' +
      70                 :           5 :             `class (is ${Object.getPrototypeOf(klass).name})`);
      71                 :             :     }
      72                 :             : 
      73         [ +  + ]:          91 :     if ('_classInit' in klass) {
      74                 :          90 :         klass = klass._classInit(klass);
      75                 :             :     } else {
      76                 :             :         // Lang.Class compatibility.
      77                 :           1 :         klass = _resolveLegacyClassFunction(klass, '_classInit')(klass);
      78                 :             :     }
      79                 :             : 
      80                 :          84 :     return klass;
      81                 :          84 : }
      82                 :             : 
      83                 :           2 : function _resolveLegacyClassFunction(klass, func) {
      84                 :             :     // Find the "least derived" class with a _classInit static function; there
      85                 :             :     // definitely is one, since this class must inherit from GObject
      86                 :           2 :     let initclass = klass;
      87         [ +  + ]:           6 :     while (typeof initclass[func] === 'undefined')
      88                 :           4 :         initclass = Object.getPrototypeOf(initclass.prototype).constructor;
      89                 :           2 :     return initclass[func];
      90                 :           2 : }
      91                 :             : 
      92                 :          90 : function _defineGType(klass, giPrototype, registeredType) {
      93                 :          90 :     const config = {
      94                 :          90 :         enumerable: false,
      95                 :          90 :         configurable: false,
      96                 :             :     };
      97                 :             : 
      98                 :             :     /**
      99                 :             :      * class Example {
     100                 :             :      *     // The JS object for this class' ObjectPrototype
     101                 :             :      *     static [Gi.gobject_prototype_symbol] = ...
     102                 :             :      *     static get $gtype () {
     103                 :             :      *         return ...;
     104                 :             :      *     }
     105                 :             :      * }
     106                 :             :      *
     107                 :             :      * // Equal to the same property on the constructor
     108                 :             :      * Example.prototype[Gi.gobject_prototype_symbol] = ...
     109                 :             :      */
     110                 :             : 
     111                 :         180 :     Object.defineProperty(klass, '$gtype', {
     112                 :          90 :         ...config,
     113                 :          90 :         get() {
     114                 :         349 :             return registeredType;
     115                 :             :         },
     116                 :             :     });
     117                 :             : 
     118                 :         180 :     Object.defineProperty(klass.prototype, Gi.gobject_prototype_symbol, {
     119                 :          90 :         ...config,
     120                 :          90 :         writable: false,
     121                 :          90 :         value: giPrototype,
     122                 :             :     });
     123                 :             : }
     124                 :             : 
     125                 :             : // Some common functions between GObject.Class and GObject.Interface
     126                 :             : 
     127                 :          90 : function _createSignals(gtype, sigs) {
     128         [ +  + ]:         111 :     for (let signalName in sigs) {
     129                 :          21 :         let obj = sigs[signalName];
     130         [ +  + ]:          21 :         let flags = obj.flags !== undefined ? obj.flags : GObject.SignalFlags.RUN_FIRST;
     131         [ +  + ]:          21 :         let accumulator = obj.accumulator !== undefined ? obj.accumulator : GObject.AccumulatorType.NONE;
     132         [ +  + ]:          21 :         let rtype = obj.return_type !== undefined ? obj.return_type : GObject.TYPE_NONE;
     133         [ +  + ]:          21 :         let paramtypes = obj.param_types !== undefined ? obj.param_types : [];
     134                 :             : 
     135                 :          21 :         try {
     136                 :          21 :             obj.signal_id = Gi.signal_new(gtype, signalName, flags, accumulator, rtype, paramtypes);
     137                 :           0 :         } catch (e) {
     138                 :           0 :             throw new TypeError(`Invalid signal ${signalName}: ${e.message}`);
     139                 :             :         }
     140                 :             :     }
     141                 :             : }
     142                 :             : 
     143                 :           2 : function _getCallerBasename() {
     144                 :           2 :     const stackLines = new Error().stack.trim().split('\n');
     145                 :           2 :     const lineRegex = new RegExp(/@(.+:\/\/)?(.*\/)?(.+)\.js:\d+(:[\d]+)?$/);
     146                 :           2 :     let thisFile = null;
     147                 :           2 :     let thisDir = null;
     148                 :             : 
     149         [ +  + ]:          12 :     for (let line of stackLines) {
     150                 :          12 :         let match = line.match(lineRegex);
     151         [ -  + ]:          12 :         if (match) {
     152                 :          12 :             let scriptDir = match[2];
     153                 :          12 :             let scriptBasename = match[3];
     154                 :             : 
     155         [ +  + ]:          12 :             if (!thisFile) {
     156                 :           2 :                 thisDir = scriptDir;
     157                 :           2 :                 thisFile = scriptBasename;
     158                 :           2 :                 continue;
     159                 :             :             }
     160                 :             : 
     161 [ +  + ][ +  + ]:          10 :             if (scriptDir === thisDir && scriptBasename === thisFile)
     162                 :           8 :                 continue;
     163                 :             : 
     164 [ -  + ][ +  - ]:           2 :             if (scriptDir && scriptDir.startsWith('/org/gnome/gjs/'))
     165                 :           0 :                 continue;
     166                 :             : 
     167                 :           2 :             let basename = scriptBasename;
     168         [ -  + ]:           2 :             if (scriptDir) {
     169                 :           2 :                 scriptDir = scriptDir.replace(/^\/|\/$/g, '');
     170                 :           2 :                 basename = `${scriptDir.split('/').reverse()[0]}_${basename}`;
     171                 :             :             }
     172                 :           2 :             return basename;
     173                 :             :         }
     174                 :             :     }
     175                 :             : 
     176                 :           0 :     return null;
     177                 :           2 : }
     178                 :             : 
     179                 :          91 : function _createGTypeName(klass) {
     180                 :         182 :     const sanitizeGType = s => s.replace(/[^a-z0-9+_-]/gi, '_');
     181                 :             : 
     182         [ +  + ]:          91 :     if (Object.hasOwn(klass, GTypeName)) {
     183                 :           6 :         let sanitized = sanitizeGType(klass[GTypeName]);
     184         [ +  + ]:           6 :         if (sanitized !== klass[GTypeName]) {
     185                 :           2 :             logError(new RangeError(`Provided GType name '${klass[GTypeName]}' ` +
     186                 :           1 :                 `is not valid; automatically sanitized to '${sanitized}'`));
     187                 :             :         }
     188                 :           6 :         return sanitized;
     189                 :             :     }
     190                 :             : 
     191                 :          85 :     let gtypeClassName = klass.name;
     192         [ +  + ]:          85 :     if (GObject.gtypeNameBasedOnJSPath) {
     193                 :           2 :         let callerBasename = _getCallerBasename();
     194         [ -  + ]:           2 :         if (callerBasename)
     195                 :           2 :             gtypeClassName = `${callerBasename}_${gtypeClassName}`;
     196                 :             :     }
     197                 :             : 
     198         [ +  + ]:          85 :     if (gtypeClassName === '')
     199                 :           3 :         gtypeClassName = `anonymous_${GLib.uuid_string_random()}`;
     200                 :             : 
     201                 :          85 :     return sanitizeGType(`Gjs_${gtypeClassName}`);
     202                 :          91 : }
     203                 :             : 
     204                 :          91 : function _propertiesAsArray(klass) {
     205                 :          91 :     let propertiesArray = [];
     206         [ +  + ]:          91 :     if (Object.hasOwn(klass, properties)) {
     207         [ +  + ]:          81 :         for (let prop in klass[properties])
     208                 :          52 :             propertiesArray.push(klass[properties][prop]);
     209                 :             :     }
     210                 :          91 :     return propertiesArray;
     211                 :          91 : }
     212                 :             : 
     213                 :          50 : function _copyInterfacePrototypeDescriptors(targetPrototype, sourceInterface) {
     214                 :          50 :     Object.entries(Object.getOwnPropertyDescriptors(sourceInterface))
     215 [ +  - ][ +  - ]:         266 :         .filter(([key, descriptor]) =>
         [ +  - ][ +  - ]
     216                 :             :             // Don't attempt to copy the constructor or toString implementations
     217         [ +  + ]:         216 :             !['constructor', 'toString'].includes(key) &&
     218                 :             :             // Ignore properties starting with __
     219 [ -  + ][ +  + ]:         175 :             (typeof key !== 'string' || !key.startsWith('__')) &&
     220                 :             :             // Don't override an implementation on the target
     221         [ +  + ]:         171 :             !Object.hasOwn(targetPrototype, key) &&
     222         [ -  + ]:          60 :             descriptor &&
     223                 :             :             // Only copy if the descriptor has a getter, is a function, or is enumerable.
     224 [ +  - ][ #  # ]:          60 :             (typeof descriptor.value === 'function' || descriptor.get || descriptor.enumerable))
     225 [ +  - ][ +  - ]:         110 :         .forEach(([key, descriptor]) => {
         [ +  - ][ +  - ]
     226                 :          60 :             Object.defineProperty(targetPrototype, key, descriptor);
     227                 :             :         });
     228                 :             : }
     229                 :             : 
     230                 :          17 : function _interfacePresent(required, klass) {
     231         [ +  + ]:          17 :     if (!klass[interfaces])
     232                 :           7 :         return false;
     233         [ +  + ]:          10 :     if (klass[interfaces].includes(required))
     234                 :           2 :         return true;  // implemented here
     235                 :             :     // Might be implemented on a parent class
     236                 :           8 :     return _interfacePresent(required, Object.getPrototypeOf(klass));
     237                 :             : }
     238                 :             : 
     239                 :          24 : function _checkInterface(iface, proto) {
     240                 :             :     // Checks for specific interfaces
     241                 :             : 
     242                 :             :     // Default vfunc_async_init() will run vfunc_init() in a thread and crash.
     243                 :             :     // Change error message when https://gitlab.gnome.org/GNOME/gjs/issues/72
     244                 :             :     // has been solved.
     245         [ +  + ]:          24 :     if (iface.$gtype.name === 'GAsyncInitable' &&
     246         [ +  + ]:           1 :         !Object.getOwnPropertyNames(proto).includes('vfunc_init_async'))
     247                 :           1 :         throw new Error("It's not currently possible to implement Gio.AsyncInitable.");
     248                 :             : 
     249                 :             :     // Check that proto implements all of this interface's required interfaces.
     250                 :             :     // "proto" refers to the object's prototype (which implements the interface)
     251                 :             :     // whereas "iface.prototype" is the interface's prototype (which may still
     252                 :             :     // contain unimplemented methods.)
     253         [ +  + ]:          23 :     if (typeof iface[requires] === 'undefined')
     254                 :          14 :         return;
     255                 :             : 
     256                 :          18 :     let unfulfilledReqs = iface[requires].filter(required => {
     257                 :             :         // Either the interface is not present or it is not listed before the
     258                 :             :         // interface that requires it or the class does not inherit it. This is
     259                 :             :         // so that required interfaces don't copy over properties from other
     260                 :             :         // interfaces that require them.
     261                 :           9 :         let ifaces = proto.constructor[interfaces];
     262         [ +  + ]:           9 :         return (!_interfacePresent(required, proto.constructor) ||
     263         [ +  + ]:           2 :             ifaces.indexOf(required) > ifaces.indexOf(iface)) &&
     264                 :           7 :             !(proto instanceof required);
     265                 :          18 :     }).map(required =>
     266                 :             :         // required.name will be present on JS classes, but on introspected
     267                 :             :         // GObjects it will be the C name. The alternative is just so that
     268                 :             :         // we print something if there is garbage in Requires.
     269         [ #  # ]:           0 :         required.name || required);
     270         [ +  - ]:           9 :     if (unfulfilledReqs.length > 0) {
     271                 :           0 :         throw new Error('The following interfaces must be implemented before ' +
     272                 :           0 :             `${iface.name}: ${unfulfilledReqs.join(', ')}`);
     273                 :             :     }
     274                 :          14 : }
     275                 :             : 
     276                 :          88 : function _registerGObjectType(klass) {
     277                 :          88 :     const gtypename = _createGTypeName(klass);
     278         [ +  + ]:          88 :     const gflags = Object.hasOwn(klass, GTypeFlags) ? klass[GTypeFlags] : 0;
     279         [ +  + ]:          88 :     const gobjectInterfaces = Object.hasOwn(klass, interfaces) ? klass[interfaces] : [];
     280                 :          88 :     const propertiesArray = _propertiesAsArray(klass);
     281                 :          88 :     const parent = Object.getPrototypeOf(klass);
     282         [ +  + ]:          88 :     const gobjectSignals = Object.hasOwn(klass, signals) ? klass[signals] : [];
     283                 :             : 
     284                 :             :     // Default to the GObject-specific prototype, fallback on the JS prototype
     285                 :             :     // for GI native classes.
     286         [ +  + ]:          88 :     const parentPrototype = parent.prototype[Gi.gobject_prototype_symbol] ?? parent.prototype;
     287                 :             : 
     288 [ +  - ][ +  - ]:         176 :     const [giPrototype, registeredType] = Gi.register_type_with_class(klass,
         [ +  - ][ +  - ]
     289                 :          88 :         parentPrototype, gtypename, gflags, gobjectInterfaces, propertiesArray);
     290                 :             : 
     291                 :          87 :     _defineGType(klass, giPrototype, registeredType);
     292                 :          87 :     _createSignals(klass.$gtype, gobjectSignals);
     293                 :             : 
     294                 :             :     // Reverse the interface array to give the last required interface
     295                 :             :     // precedence over the first.
     296         [ +  + ]:          87 :     const requiredInterfaces = [...gobjectInterfaces].reverse();
     297                 :          87 :     requiredInterfaces.forEach(iface =>
     298                 :          25 :         _copyInterfacePrototypeDescriptors(klass, iface));
     299                 :          87 :     requiredInterfaces.forEach(iface =>
     300                 :          25 :         _copyInterfacePrototypeDescriptors(klass.prototype, iface.prototype));
     301                 :             : 
     302                 :          87 :     Object.getOwnPropertyNames(klass.prototype)
     303         [ +  + ]:         422 :     .filter(name => name.startsWith('vfunc_') || name.startsWith('on_'))
     304                 :         153 :     .forEach(name => {
     305                 :          66 :         let descr = Object.getOwnPropertyDescriptor(klass.prototype, name);
     306         [ +  - ]:          66 :         if (typeof descr.value !== 'function')
     307                 :           0 :             return;
     308                 :             : 
     309                 :          66 :         let func = klass.prototype[name];
     310                 :             : 
     311         [ +  + ]:          66 :         if (name.startsWith('vfunc_')) {
     312                 :          60 :             giPrototype[Gi.hook_up_vfunc_symbol](name.slice(6), func);
     313         [ -  + ]:           6 :         } else if (name.startsWith('on_')) {
     314                 :          12 :             let id = GObject.signal_lookup(name.slice(3).replace('_', '-'),
     315                 :           6 :                 klass.$gtype);
     316         [ -  + ]:           6 :             if (id !== 0) {
     317                 :          22 :                 GObject.signal_override_class_closure(id, klass.$gtype, function (...argArray) {
     318                 :          16 :                     let emitter = argArray.shift();
     319                 :             : 
     320                 :          16 :                     return func.apply(emitter, argArray);
     321                 :          16 :                 });
     322                 :             :             }
     323                 :             :         }
     324                 :           0 :     });
     325                 :             : 
     326                 :         107 :     gobjectInterfaces.forEach(iface => _checkInterface(iface, klass.prototype));
     327                 :             : 
     328                 :             :     // Lang.Class parent classes don't support static inheritance
     329         [ +  - ]:          82 :     if (!('implements' in klass))
     330                 :           0 :         klass.implements = GObject.Object.implements;
     331                 :             : }
     332                 :             : 
     333                 :          18 : function _interfaceInstanceOf(instance) {
     334 [ +  + ][ +  + ]:          18 :     if (instance && typeof instance === 'object' &&
     335         [ +  + ]:          12 :         GObject.Interface.prototype.isPrototypeOf(this.prototype))
     336                 :          12 :         return GObject.type_is_a(instance, this);
     337                 :             : 
     338                 :           6 :     return false;
     339                 :             : }
     340                 :             : 
     341                 :           3 : function _registerInterfaceType(klass) {
     342                 :           3 :     const gtypename = _createGTypeName(klass);
     343         [ -  + ]:           3 :     const gobjectInterfaces = Object.hasOwn(klass, requires) ? klass[requires] : [];
     344                 :           3 :     const props = _propertiesAsArray(klass);
     345         [ +  + ]:           3 :     const gobjectSignals = Object.hasOwn(klass, signals) ? klass[signals] : [];
     346                 :             : 
     347 [ +  - ][ +  - ]:           6 :     const [giPrototype, registeredType] = Gi.register_interface_with_class(
         [ +  - ][ +  - ]
     348                 :           3 :         klass, gtypename, gobjectInterfaces, props);
     349                 :             : 
     350                 :           3 :     _defineGType(klass, giPrototype, registeredType);
     351                 :           3 :     _createSignals(klass.$gtype, gobjectSignals);
     352                 :             : 
     353                 :           6 :     Object.defineProperty(klass, Symbol.hasInstance, {
     354                 :           3 :         value: _interfaceInstanceOf,
     355                 :             :     });
     356                 :             : }
     357                 :             : 
     358                 :          88 : function _checkProperties(klass) {
     359         [ +  + ]:          88 :     if (!Object.hasOwn(klass, properties))
     360                 :          60 :         return;
     361                 :             : 
     362         [ +  + ]:          79 :     for (let pspec of Object.values(klass[properties]))
     363                 :          51 :         _checkAccessors(klass.prototype, pspec, GObject);
     364                 :             : }
     365                 :             : 
     366                 :          47 : function _init() {
     367                 :          47 :     GObject = this;
     368                 :             : 
     369                 :         564 :     function _makeDummyClass(obj, name, upperName, gtypeName, actual) {
     370                 :         564 :         let gtype = GObject.type_from_name(gtypeName);
     371                 :         564 :         obj[`TYPE_${upperName}`] = gtype;
     372                 :         564 :         obj[name] = function (v) {
     373                 :           6 :             return actual(v);
     374                 :             :         };
     375                 :         564 :         obj[name].$gtype = gtype;
     376                 :             :     }
     377                 :             : 
     378                 :          47 :     GObject.gtypeNameBasedOnJSPath = false;
     379                 :             : 
     380                 :          47 :     _makeDummyClass(GObject, 'VoidType', 'NONE', 'void', function () {});
     381                 :          47 :     _makeDummyClass(GObject, 'Char', 'CHAR', 'gchar', Number);
     382                 :          47 :     _makeDummyClass(GObject, 'UChar', 'UCHAR', 'guchar', Number);
     383                 :          47 :     _makeDummyClass(GObject, 'Unichar', 'UNICHAR', 'gint', String);
     384                 :             : 
     385                 :          47 :     GObject.TYPE_BOOLEAN = GObject.type_from_name('gboolean');
     386                 :          47 :     GObject.Boolean = Boolean;
     387                 :          47 :     Boolean.$gtype = GObject.TYPE_BOOLEAN;
     388                 :             : 
     389                 :          47 :     _makeDummyClass(GObject, 'Int', 'INT', 'gint', Number);
     390                 :          47 :     _makeDummyClass(GObject, 'UInt', 'UINT', 'guint', Number);
     391                 :          47 :     _makeDummyClass(GObject, 'Long', 'LONG', 'glong', Number);
     392                 :          47 :     _makeDummyClass(GObject, 'ULong', 'ULONG', 'gulong', Number);
     393                 :          47 :     _makeDummyClass(GObject, 'Int64', 'INT64', 'gint64', Number);
     394                 :          47 :     _makeDummyClass(GObject, 'UInt64', 'UINT64', 'guint64', Number);
     395                 :             : 
     396                 :          47 :     GObject.TYPE_ENUM = GObject.type_from_name('GEnum');
     397                 :          47 :     GObject.TYPE_FLAGS = GObject.type_from_name('GFlags');
     398                 :             : 
     399                 :          47 :     _makeDummyClass(GObject, 'Float', 'FLOAT', 'gfloat', Number);
     400                 :          47 :     GObject.TYPE_DOUBLE = GObject.type_from_name('gdouble');
     401                 :          47 :     GObject.Double = Number;
     402                 :          47 :     Number.$gtype = GObject.TYPE_DOUBLE;
     403                 :             : 
     404                 :          47 :     GObject.TYPE_STRING = GObject.type_from_name('gchararray');
     405                 :          47 :     GObject.String = String;
     406                 :          47 :     String.$gtype = GObject.TYPE_STRING;
     407                 :             : 
     408                 :          47 :     GObject.TYPE_JSOBJECT = GObject.type_from_name('JSObject');
     409                 :          47 :     GObject.JSObject = Object;
     410                 :          47 :     Object.$gtype = GObject.TYPE_JSOBJECT;
     411                 :             : 
     412                 :          47 :     GObject.TYPE_POINTER = GObject.type_from_name('gpointer');
     413                 :          47 :     GObject.TYPE_BOXED = GObject.type_from_name('GBoxed');
     414                 :          47 :     GObject.TYPE_PARAM = GObject.type_from_name('GParam');
     415                 :          47 :     GObject.TYPE_INTERFACE = GObject.type_from_name('GInterface');
     416                 :          47 :     GObject.TYPE_OBJECT = GObject.type_from_name('GObject');
     417                 :          47 :     GObject.TYPE_VARIANT = GObject.type_from_name('GVariant');
     418                 :             : 
     419                 :          47 :     _makeDummyClass(GObject, 'Type', 'GTYPE', 'GType', GObject.type_from_name);
     420                 :             : 
     421                 :          47 :     GObject.ParamSpec.char = function (name, nick, blurb, flags, minimum, maximum, defaultValue) {
     422                 :           0 :         return GObject.param_spec_char(name, nick, blurb, minimum, maximum, defaultValue, flags);
     423                 :             :     };
     424                 :             : 
     425                 :          47 :     GObject.ParamSpec.uchar = function (name, nick, blurb, flags, minimum, maximum, defaultValue) {
     426                 :           0 :         return GObject.param_spec_uchar(name, nick, blurb, minimum, maximum, defaultValue, flags);
     427                 :             :     };
     428                 :             : 
     429                 :          47 :     GObject.ParamSpec.int = function (name, nick, blurb, flags, minimum, maximum, defaultValue) {
     430                 :          19 :         return GObject.param_spec_int(name, nick, blurb, minimum, maximum, defaultValue, flags);
     431                 :             :     };
     432                 :             : 
     433                 :          47 :     GObject.ParamSpec.uint = function (name, nick, blurb, flags, minimum, maximum, defaultValue) {
     434                 :           3 :         return GObject.param_spec_uint(name, nick, blurb, minimum, maximum, defaultValue, flags);
     435                 :             :     };
     436                 :             : 
     437                 :          47 :     GObject.ParamSpec.long = function (name, nick, blurb, flags, minimum, maximum, defaultValue) {
     438                 :           0 :         return GObject.param_spec_long(name, nick, blurb, minimum, maximum, defaultValue, flags);
     439                 :             :     };
     440                 :             : 
     441                 :          47 :     GObject.ParamSpec.ulong = function (name, nick, blurb, flags, minimum, maximum, defaultValue) {
     442                 :           0 :         return GObject.param_spec_ulong(name, nick, blurb, minimum, maximum, defaultValue, flags);
     443                 :             :     };
     444                 :             : 
     445                 :          47 :     GObject.ParamSpec.int64 = function (name, nick, blurb, flags, minimum, maximum, defaultValue) {
     446                 :           6 :         return GObject.param_spec_int64(name, nick, blurb, minimum, maximum, defaultValue, flags);
     447                 :             :     };
     448                 :             : 
     449                 :          47 :     GObject.ParamSpec.uint64 = function (name, nick, blurb, flags, minimum, maximum, defaultValue) {
     450                 :           5 :         return GObject.param_spec_uint64(name, nick, blurb, minimum, maximum, defaultValue, flags);
     451                 :             :     };
     452                 :             : 
     453                 :          47 :     GObject.ParamSpec.float = function (name, nick, blurb, flags, minimum, maximum, defaultValue) {
     454                 :           0 :         return GObject.param_spec_float(name, nick, blurb, minimum, maximum, defaultValue, flags);
     455                 :             :     };
     456                 :             : 
     457                 :          47 :     GObject.ParamSpec.boolean = function (name, nick, blurb, flags, defaultValue) {
     458                 :           4 :         return GObject.param_spec_boolean(name, nick, blurb, defaultValue, flags);
     459                 :             :     };
     460                 :             : 
     461                 :          47 :     GObject.ParamSpec.flags = function (name, nick, blurb, flags, flagsType, defaultValue) {
     462                 :           3 :         return GObject.param_spec_flags(name, nick, blurb, flagsType, defaultValue, flags);
     463                 :             :     };
     464                 :             : 
     465                 :          47 :     GObject.ParamSpec.enum = function (name, nick, blurb, flags, enumType, defaultValue) {
     466                 :           3 :         return GObject.param_spec_enum(name, nick, blurb, enumType, defaultValue, flags);
     467                 :             :     };
     468                 :             : 
     469                 :          47 :     GObject.ParamSpec.double = function (name, nick, blurb, flags, minimum, maximum, defaultValue) {
     470                 :           0 :         return GObject.param_spec_double(name, nick, blurb, minimum, maximum, defaultValue, flags);
     471                 :             :     };
     472                 :             : 
     473                 :          47 :     GObject.ParamSpec.string = function (name, nick, blurb, flags, defaultValue) {
     474                 :          26 :         return GObject.param_spec_string(name, nick, blurb, defaultValue, flags);
     475                 :             :     };
     476                 :             : 
     477                 :          47 :     GObject.ParamSpec.boxed = function (name, nick, blurb, flags, boxedType) {
     478                 :           0 :         return GObject.param_spec_boxed(name, nick, blurb, boxedType, flags);
     479                 :             :     };
     480                 :             : 
     481                 :          47 :     GObject.ParamSpec.object = function (name, nick, blurb, flags, objectType) {
     482                 :           5 :         return GObject.param_spec_object(name, nick, blurb, objectType, flags);
     483                 :             :     };
     484                 :             : 
     485                 :          47 :     GObject.ParamSpec.jsobject = function (name, nick, blurb, flags) {
     486                 :           5 :         return GObject.param_spec_boxed(name, nick, blurb, Object.$gtype, flags);
     487                 :             :     };
     488                 :             : 
     489                 :          47 :     GObject.ParamSpec.param = function (name, nick, blurb, flags, paramType) {
     490                 :           0 :         return GObject.param_spec_param(name, nick, blurb, paramType, flags);
     491                 :             :     };
     492                 :             : 
     493                 :          47 :     GObject.ParamSpec.override = Gi.override_property;
     494                 :             : 
     495                 :          94 :     Object.defineProperties(GObject.ParamSpec.prototype, {
     496                 :          47 :         'name': {
     497                 :          47 :             configurable: false,
     498                 :          47 :             enumerable: false,
     499                 :          47 :             get() {
     500                 :         112 :                 return this.get_name();
     501                 :             :             },
     502                 :             :         },
     503                 :          47 :         '_nick': {
     504                 :          47 :             configurable: false,
     505                 :          47 :             enumerable: false,
     506                 :          47 :             get() {
     507                 :           9 :                 return this.get_nick();
     508                 :             :             },
     509                 :             :         },
     510                 :          47 :         'nick': {
     511                 :          47 :             configurable: false,
     512                 :          47 :             enumerable: false,
     513                 :          47 :             get() {
     514                 :           2 :                 return this.get_nick();
     515                 :             :             },
     516                 :             :         },
     517                 :          47 :         '_blurb': {
     518                 :          47 :             configurable: false,
     519                 :          47 :             enumerable: false,
     520                 :          47 :             get() {
     521                 :           9 :                 return this.get_blurb();
     522                 :             :             },
     523                 :             :         },
     524                 :          47 :         'blurb': {
     525                 :          47 :             configurable: false,
     526                 :          47 :             enumerable: false,
     527                 :          47 :             get() {
     528                 :           2 :                 return this.get_blurb();
     529                 :             :             },
     530                 :             :         },
     531                 :          47 :         'default_value': {
     532                 :          47 :             configurable: false,
     533                 :          47 :             enumerable: false,
     534                 :          47 :             get() {
     535                 :          12 :                 return this.get_default_value();
     536                 :             :             },
     537                 :             :         },
     538                 :          47 :         'flags': {
     539                 :          47 :             configurable: false,
     540                 :          47 :             enumerable: false,
     541                 :          47 :             get() {
     542                 :         110 :                 return GjsPrivate.param_spec_get_flags(this);
     543                 :             :             },
     544                 :             :         },
     545                 :          47 :         'value_type': {
     546                 :          47 :             configurable: false,
     547                 :          47 :             enumerable: false,
     548                 :          47 :             get() {
     549                 :           2 :                 return GjsPrivate.param_spec_get_value_type(this);
     550                 :             :             },
     551                 :             :         },
     552                 :          47 :         'owner_type': {
     553                 :          47 :             configurable: false,
     554                 :          47 :             enumerable: false,
     555                 :          47 :             get() {
     556                 :           0 :                 return GjsPrivate.param_spec_get_owner_type(this);
     557                 :             :             },
     558                 :             :         },
     559                 :             :     });
     560                 :             : 
     561                 :          47 :     let {GObjectMeta, GObjectInterface} = Legacy.defineGObjectLegacyObjects(GObject);
     562                 :          47 :     GObject.Class = GObjectMeta;
     563                 :          47 :     GObject.Interface = GObjectInterface;
     564                 :          47 :     GObject.Object.prototype.__metaclass__ = GObject.Class;
     565                 :             : 
     566                 :             :     // For compatibility with Lang.Class... we need a _construct
     567                 :             :     // or the Lang.Class constructor will fail.
     568                 :          47 :     GObject.Object.prototype._construct = function (...args) {
     569 [ #  # ][ #  # ]:           0 :         this._init(...args);
     570                 :           0 :         return this;
     571                 :             :     };
     572                 :             : 
     573                 :          47 :     GObject.registerClass = registerClass;
     574                 :             : 
     575         [ +  + ]:          58 :     GObject.Object.new = function (gtype, props = {}) {
     576                 :          11 :         const constructor = Gi.lookupConstructor(gtype);
     577                 :             : 
     578         [ +  - ]:          11 :         if (!constructor)
     579                 :           0 :             throw new Error(`Constructor for gtype ${gtype} not found`);
     580                 :          11 :         return new constructor(props);
     581                 :           7 :     };
     582                 :             : 
     583                 :          56 :     GObject.Object.new_with_properties = function (gtype, names, values) {
     584 [ +  + ][ +  + ]:           9 :         if (!Array.isArray(names) || !Array.isArray(values))
     585                 :           3 :             throw new Error('new_with_properties takes two arrays (names, values)');
     586         [ +  + ]:           6 :         if (names.length !== values.length)
     587                 :           1 :             throw new Error('Arrays passed to new_with_properties must be the same length');
     588                 :             : 
     589                 :          10 :         const props = Object.fromEntries(names.map((name, ix) => [name, values[ix]]));
     590                 :           5 :         return GObject.Object.new(gtype, props);
     591                 :           3 :     };
     592                 :             : 
     593                 :          47 :     GObject.Object._classInit = function (klass) {
     594                 :          88 :         _checkProperties(klass);
     595                 :             : 
     596         [ +  + ]:          88 :         if (_registerType in klass)
     597                 :          87 :             klass[_registerType](klass);
     598                 :             :         else
     599                 :           1 :             _resolveLegacyClassFunction(klass, _registerType)(klass);
     600                 :             : 
     601                 :          81 :         return klass;
     602                 :             :     };
     603                 :             : 
     604                 :             :     // For backwards compatibility only. Use instanceof instead.
     605                 :          47 :     GObject.Object.implements = function (iface) {
     606         [ -  + ]:           2 :         if (iface.$gtype)
     607                 :           2 :             return GObject.type_is_a(this, iface.$gtype);
     608                 :           0 :         return false;
     609                 :             :     };
     610                 :             : 
     611                 :          94 :     Object.defineProperty(GObject.Object, _registerType, {
     612                 :          47 :         value: _registerGObjectType,
     613                 :          47 :         writable: false,
     614                 :          47 :         configurable: false,
     615                 :          47 :         enumerable: false,
     616                 :             :     });
     617                 :             : 
     618                 :          94 :     Object.defineProperty(GObject.Interface, _registerType, {
     619                 :          47 :         value: _registerInterfaceType,
     620                 :          47 :         writable: false,
     621                 :          47 :         configurable: false,
     622                 :          47 :         enumerable: false,
     623                 :             :     });
     624                 :             : 
     625                 :          47 :     GObject.Interface._classInit = function (klass) {
     626         [ -  + ]:           3 :         if (_registerType in klass)
     627                 :           3 :             klass[_registerType](klass);
     628                 :             :         else
     629                 :           0 :             _resolveLegacyClassFunction(klass, _registerType)(klass);
     630                 :             : 
     631                 :           3 :         Object.getOwnPropertyNames(klass.prototype)
     632                 :           9 :         .filter(key => key !== 'constructor')
     633                 :           3 :         .concat(Object.getOwnPropertySymbols(klass.prototype))
     634                 :           9 :         .forEach(key => {
     635                 :           6 :             let descr = Object.getOwnPropertyDescriptor(klass.prototype, key);
     636                 :             : 
     637                 :             :             // Create wrappers on the interface object so that generics work (e.g.
     638                 :             :             // SomeInterface.some_function(this, blah) instead of
     639                 :             :             // SomeInterface.prototype.some_function.call(this, blah)
     640         [ +  + ]:           6 :             if (typeof descr.value === 'function') {
     641                 :           3 :                 let interfaceProto = klass.prototype;  // capture in closure
     642                 :           7 :                 klass[key] = function (thisObj, ...args) {
     643         [ +  - ]:           4 :                     return interfaceProto[key].call(thisObj, ...args);
     644                 :             :                 };
     645                 :             :             }
     646                 :             : 
     647                 :           6 :             Object.defineProperty(klass.prototype, key, descr);
     648                 :             :         });
     649                 :             : 
     650                 :           3 :         return klass;
     651                 :             :     };
     652                 :             : 
     653                 :             :     /**
     654                 :             :      * Use this to signify a function that must be overridden in an
     655                 :             :      * implementation of the interface.
     656                 :             :      */
     657         [ -  + ]:          48 :     GObject.NotImplementedError = class NotImplementedError extends Error {
     658                 :          47 :         get name() {
     659                 :           0 :             return 'NotImplementedError';
     660                 :             :         }
     661                 :             :     };
     662                 :             : 
     663                 :             :     // These will be copied in the Gtk overrides
     664                 :             :     // Use __X__ syntax to indicate these variables should not be used publicly.
     665                 :             : 
     666                 :          47 :     GObject.__gtkCssName__ = _gtkCssName;
     667                 :          47 :     GObject.__gtkTemplate__ = _gtkTemplate;
     668                 :          47 :     GObject.__gtkChildren__ = _gtkChildren;
     669                 :          47 :     GObject.__gtkInternalChildren__ = _gtkInternalChildren;
     670                 :             : 
     671                 :             :     // Expose GObject static properties for ES6 classes
     672                 :             : 
     673                 :          47 :     GObject.GTypeName = GTypeName;
     674                 :          47 :     GObject.requires = requires;
     675                 :          47 :     GObject.interfaces = interfaces;
     676                 :          47 :     GObject.properties = properties;
     677                 :          47 :     GObject.signals = signals;
     678                 :             : 
     679                 :             :     // Replacement for non-introspectable g_object_set()
     680                 :          47 :     GObject.Object.prototype.set = function (params) {
     681                 :           1 :         Object.assign(this, params);
     682                 :             :     };
     683                 :             : 
     684                 :          48 :     GObject.Object.prototype.bind_property_full = function (...args) {
     685         [ +  + ]:           1 :         return GjsPrivate.g_object_bind_property_full(this, ...args);
     686                 :             :     };
     687                 :             : 
     688         [ -  + ]:          47 :     if (GObject.BindingGroup !== undefined) {
     689                 :          48 :         GObject.BindingGroup.prototype.bind_full = function (...args) {
     690         [ +  + ]:           1 :             return GjsPrivate.g_binding_group_bind_full(this, ...args);
     691                 :             :         };
     692                 :             :     }
     693                 :             : 
     694                 :             :     // fake enum for signal accumulators, keep in sync with gi/object.c
     695                 :          47 :     GObject.AccumulatorType = {
     696                 :          47 :         NONE: 0,
     697                 :          47 :         FIRST_WINS: 1,
     698                 :          47 :         TRUE_HANDLED: 2,
     699                 :             :     };
     700                 :             : 
     701                 :          47 :     GObject.Object.prototype.disconnect = function (id) {
     702                 :          99 :         return GObject.signal_handler_disconnect(this, id);
     703                 :             :     };
     704                 :          47 :     GObject.Object.prototype.block_signal_handler = function (id) {
     705                 :           0 :         return GObject.signal_handler_block(this, id);
     706                 :             :     };
     707                 :          47 :     GObject.Object.prototype.unblock_signal_handler = function (id) {
     708                 :           0 :         return GObject.signal_handler_unblock(this, id);
     709                 :             :     };
     710                 :          47 :     GObject.Object.prototype.stop_emission_by_name = function (detailedName) {
     711                 :           0 :         return GObject.signal_stop_emission_by_name(this, detailedName);
     712                 :             :     };
     713                 :             : 
     714                 :             :     // A simple workaround if you have a class with .connect, .disconnect or .emit
     715                 :             :     // methods (such as Gio.Socket.connect or NMClient.Device.disconnect)
     716                 :             :     // The original g_signal_* functions are not introspectable anyway, because
     717                 :             :     // we need our own handling of signal argument marshalling
     718                 :          47 :     GObject.signal_connect = function (object, name, handler) {
     719                 :           2 :         return GObject.Object.prototype.connect.call(object, name, handler);
     720                 :             :     };
     721                 :          47 :     GObject.signal_connect_after = function (object, name, handler) {
     722                 :           0 :         return GObject.Object.prototype.connect_after.call(object, name, handler);
     723                 :             :     };
     724                 :          50 :     GObject.signal_emit_by_name = function (object, ...nameAndArgs) {
     725                 :           3 :         return GObject.Object.prototype.emit.apply(object, nameAndArgs);
     726                 :             :     };
     727                 :             : 
     728                 :             :     // Replacements for signal_handler_find() and similar functions, which can't
     729                 :             :     // work normally since we connect private closures
     730                 :          47 :     GObject._real_signal_handler_find = GObject.signal_handler_find;
     731                 :          47 :     GObject._real_signal_handlers_block_matched = GObject.signal_handlers_block_matched;
     732                 :          47 :     GObject._real_signal_handlers_unblock_matched = GObject.signal_handlers_unblock_matched;
     733                 :          47 :     GObject._real_signal_handlers_disconnect_matched = GObject.signal_handlers_disconnect_matched;
     734                 :             : 
     735                 :             :     /**
     736                 :             :      * Finds the first signal handler that matches certain selection criteria.
     737                 :             :      * The criteria are passed as properties of a match object.
     738                 :             :      * The match object has to be non-empty for successful matches.
     739                 :             :      * If no handler was found, a falsy value is returned.
     740                 :             :      *
     741                 :             :      * @function
     742                 :             :      * @param {GObject.Object} instance - the instance owning the signal handler
     743                 :             :      *   to be found.
     744                 :             :      * @param {object} match - a properties object indicating whether to match
     745                 :             :      *   by signal ID, detail, or callback function.
     746                 :             :      * @param {string} [match.signalId] - signal the handler has to be connected
     747                 :             :      *   to.
     748                 :             :      * @param {string} [match.detail] - signal detail the handler has to be
     749                 :             :      *   connected to.
     750                 :             :      * @param {Function} [match.func] - the callback function the handler will
     751                 :             :      *   invoke.
     752                 :             :      * @returns {number | bigint | object | null} A valid non-0 signal handler ID for
     753                 :             :      *   a successful match.
     754                 :             :      */
     755                 :          47 :     GObject.signal_handler_find = function (instance, match) {
     756                 :             :         // For backwards compatibility
     757         [ +  - ]:          12 :         if (arguments.length === 7)
     758                 :             :             // eslint-disable-next-line prefer-rest-params
     759 [ #  # ][ #  # ]:           0 :             return GObject._real_signal_handler_find(...arguments);
     760                 :          12 :         return instance[Gi.signal_find_symbol](match);
     761                 :             :     };
     762                 :             :     /**
     763                 :             :      * Blocks all handlers on an instance that match certain selection criteria.
     764                 :             :      * The criteria are passed as properties of a match object.
     765                 :             :      * The match object has to have at least `func` for successful matches.
     766                 :             :      * If no handlers were found, 0 is returned, the number of blocked handlers
     767                 :             :      * otherwise.
     768                 :             :      *
     769                 :             :      * @function
     770                 :             :      * @param {GObject.Object} instance - the instance owning the signal handler
     771                 :             :      *   to be found.
     772                 :             :      * @param {object} match - a properties object indicating whether to match
     773                 :             :      *   by signal ID, detail, or callback function.
     774                 :             :      * @param {string} [match.signalId] - signal the handler has to be connected
     775                 :             :      *   to.
     776                 :             :      * @param {string} [match.detail] - signal detail the handler has to be
     777                 :             :      *   connected to.
     778                 :             :      * @param {Function} match.func - the callback function the handler will
     779                 :             :      *   invoke.
     780                 :             :      * @returns {number} The number of handlers that matched.
     781                 :             :      */
     782                 :          47 :     GObject.signal_handlers_block_matched = function (instance, match) {
     783                 :             :         // For backwards compatibility
     784         [ +  - ]:           3 :         if (arguments.length === 7)
     785                 :             :             // eslint-disable-next-line prefer-rest-params
     786 [ #  # ][ #  # ]:           0 :             return GObject._real_signal_handlers_block_matched(...arguments);
     787                 :           3 :         return instance[Gi.signals_block_symbol](match);
     788                 :             :     };
     789                 :             :     /**
     790                 :             :      * Unblocks all handlers on an instance that match certain selection
     791                 :             :      * criteria.
     792                 :             :      * The criteria are passed as properties of a match object.
     793                 :             :      * The match object has to have at least `func` for successful matches.
     794                 :             :      * If no handlers were found, 0 is returned, the number of unblocked
     795                 :             :      * handlers otherwise.
     796                 :             :      * The match criteria should not apply to any handlers that are not
     797                 :             :      * currently blocked.
     798                 :             :      *
     799                 :             :      * @function
     800                 :             :      * @param {GObject.Object} instance - the instance owning the signal handler
     801                 :             :      *   to be found.
     802                 :             :      * @param {object} match - a properties object indicating whether to match
     803                 :             :      *   by signal ID, detail, or callback function.
     804                 :             :      * @param {string} [match.signalId] - signal the handler has to be connected
     805                 :             :      *   to.
     806                 :             :      * @param {string} [match.detail] - signal detail the handler has to be
     807                 :             :      *   connected to.
     808                 :             :      * @param {Function} match.func - the callback function the handler will
     809                 :             :      *   invoke.
     810                 :             :      * @returns {number} The number of handlers that matched.
     811                 :             :      */
     812                 :          47 :     GObject.signal_handlers_unblock_matched = function (instance, match) {
     813                 :             :         // For backwards compatibility
     814         [ +  - ]:           3 :         if (arguments.length === 7)
     815                 :             :             // eslint-disable-next-line prefer-rest-params
     816 [ #  # ][ #  # ]:           0 :             return GObject._real_signal_handlers_unblock_matched(...arguments);
     817                 :           3 :         return instance[Gi.signals_unblock_symbol](match);
     818                 :             :     };
     819                 :             :     /**
     820                 :             :      * Disconnects all handlers on an instance that match certain selection
     821                 :             :      * criteria.
     822                 :             :      * The criteria are passed as properties of a match object.
     823                 :             :      * The match object has to have at least `func` for successful matches.
     824                 :             :      * If no handlers were found, 0 is returned, the number of disconnected
     825                 :             :      * handlers otherwise.
     826                 :             :      *
     827                 :             :      * @function
     828                 :             :      * @param {GObject.Object} instance - the instance owning the signal handler
     829                 :             :      *   to be found.
     830                 :             :      * @param {object} match - a properties object indicating whether to match
     831                 :             :      *   by signal ID, detail, or callback function.
     832                 :             :      * @param {string} [match.signalId] - signal the handler has to be connected
     833                 :             :      *   to.
     834                 :             :      * @param {string} [match.detail] - signal detail the handler has to be
     835                 :             :      *   connected to.
     836                 :             :      * @param {Function} match.func - the callback function the handler will
     837                 :             :      *   invoke.
     838                 :             :      * @returns {number} The number of handlers that matched.
     839                 :             :      */
     840                 :          47 :     GObject.signal_handlers_disconnect_matched = function (instance, match) {
     841                 :             :         // For backwards compatibility
     842         [ +  - ]:           3 :         if (arguments.length === 7)
     843                 :             :             // eslint-disable-next-line prefer-rest-params
     844 [ #  # ][ #  # ]:           0 :             return GObject._real_signal_handlers_disconnect_matched(...arguments);
     845                 :           3 :         return instance[Gi.signals_disconnect_symbol](match);
     846                 :             :     };
     847                 :             : 
     848                 :             :     // Also match the macros used in C APIs, even though they're not introspected
     849                 :             : 
     850                 :             :     /**
     851                 :             :      * Blocks all handlers on an instance that match `func`.
     852                 :             :      *
     853                 :             :      * @function
     854                 :             :      * @param {GObject.Object} instance - the instance to block handlers from.
     855                 :             :      * @param {Function} func - the callback function the handler will invoke.
     856                 :             :      * @returns {number} The number of handlers that matched.
     857                 :             :      */
     858                 :          47 :     GObject.signal_handlers_block_by_func = function (instance, func) {
     859                 :           3 :         return instance[Gi.signals_block_symbol]({func});
     860                 :             :     };
     861                 :             :     /**
     862                 :             :      * Unblocks all handlers on an instance that match `func`.
     863                 :             :      *
     864                 :             :      * @function
     865                 :             :      * @param {GObject.Object} instance - the instance to unblock handlers from.
     866                 :             :      * @param {Function} func - the callback function the handler will invoke.
     867                 :             :      * @returns {number} The number of handlers that matched.
     868                 :             :      */
     869                 :          47 :     GObject.signal_handlers_unblock_by_func = function (instance, func) {
     870                 :           3 :         return instance[Gi.signals_unblock_symbol]({func});
     871                 :             :     };
     872                 :             :     /**
     873                 :             :      * Disconnects all handlers on an instance that match `func`.
     874                 :             :      *
     875                 :             :      * @function
     876                 :             :      * @param {GObject.Object} instance - the instance to remove handlers from.
     877                 :             :      * @param {Function} func - the callback function the handler will invoke.
     878                 :             :      * @returns {number} The number of handlers that matched.
     879                 :             :      */
     880                 :          47 :     GObject.signal_handlers_disconnect_by_func = function (instance, func) {
     881                 :           3 :         return instance[Gi.signals_disconnect_symbol]({func});
     882                 :             :     };
     883                 :          47 :     GObject.signal_handlers_disconnect_by_data = function () {
     884                 :           1 :         throw new Error('GObject.signal_handlers_disconnect_by_data() is not \
     885                 :             : introspectable. Use GObject.signal_handlers_disconnect_by_func() instead.');
     886                 :             :     };
     887                 :             : 
     888                 :           5 :     function unsupportedDataMethod() {
     889                 :           5 :         throw new Error('Data access methods are unsupported. Use normal JS properties instead.');
     890                 :             :     }
     891                 :          47 :     GObject.Object.prototype.get_data = unsupportedDataMethod;
     892                 :          47 :     GObject.Object.prototype.get_qdata = unsupportedDataMethod;
     893                 :          47 :     GObject.Object.prototype.set_data = unsupportedDataMethod;
     894                 :          47 :     GObject.Object.prototype.steal_data = unsupportedDataMethod;
     895                 :          47 :     GObject.Object.prototype.steal_qdata = unsupportedDataMethod;
     896                 :             : 
     897                 :           4 :     function unsupportedRefcountingMethod() {
     898                 :           4 :         throw new Error("Don't modify an object's reference count in JS.");
     899                 :             :     }
     900                 :          47 :     GObject.Object.prototype.force_floating = unsupportedRefcountingMethod;
     901                 :          47 :     GObject.Object.prototype.ref = unsupportedRefcountingMethod;
     902                 :          47 :     GObject.Object.prototype.ref_sink = unsupportedRefcountingMethod;
     903                 :          47 :     GObject.Object.prototype.unref = unsupportedRefcountingMethod;
     904                 :             : }
        

Generated by: LCOV version 2.0-1