[gjs: 1/3] GObject: Don't autogenerate accessors for CONSTRUCT_ONLY properties
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 1/3] GObject: Don't autogenerate accessors for CONSTRUCT_ONLY properties
- Date: Mon, 22 Mar 2021 18:02:47 +0000 (UTC)
commit 1572849a875632a84bec664b2acb41fee54a72c2
Author: Philip Chimento <philip chimento gmail com>
Date: Sun Mar 21 11:32:52 2021 -0700
GObject: Don't autogenerate accessors for CONSTRUCT_ONLY properties
Since we redefine CONSTRUCT_ONLY properties as readonly data properties
when they are set, the autogenerated accessors would be wrong.
See: #391
installed-tests/js/testGObjectClass.js | 7 +++++++
modules/core/_common.js | 2 ++
2 files changed, 9 insertions(+)
---
diff --git a/installed-tests/js/testGObjectClass.js b/installed-tests/js/testGObjectClass.js
index 4cf3a867..f0a57a84 100644
--- a/installed-tests/js/testGObjectClass.js
+++ b/installed-tests/js/testGObjectClass.js
@@ -766,6 +766,10 @@ describe('Auto accessor generation', function () {
'Long-named property', GObject.ParamFlags.READWRITE, 0, 100, 48),
'construct': GObject.ParamSpec.int('construct', 'Construct', 'Construct',
GObject.ParamFlags.READWRITE | GObject.ParamFlags.CONSTRUCT, 0, 100, 96),
+ 'construct-only': GObject.ParamSpec.int('construct-only', 'Construct only',
+ 'Construct-only property',
+ GObject.ParamFlags.READWRITE | GObject.ParamFlags.CONSTRUCT_ONLY,
+ 0, 100, 80),
'snake-name': GObject.ParamSpec.int('snake-name', 'Snake name',
'Snake-cased property', GObject.ParamFlags.READWRITE, 0, 100, 36),
'camel-name': GObject.ParamSpec.int('camel-name', 'Camel name',
@@ -844,8 +848,11 @@ describe('Auto accessor generation', function () {
it("initial value is the param spec's default value", function () {
expect(a.simple).toEqual(24);
+ expect(a.long_long_name).toEqual(48);
+ expect(a.longLongName).toEqual(48);
expect(a['long-long-name']).toEqual(48);
expect(a.construct).toEqual(96);
+ expect(a.construct_only).toEqual(80);
});
it('notify when the property changes', function () {
diff --git a/modules/core/_common.js b/modules/core/_common.js
index 45bbefb7..edc70215 100644
--- a/modules/core/_common.js
+++ b/modules/core/_common.js
@@ -59,6 +59,8 @@ function _generateAccessors(pspec, propdesc, GObject) {
function _checkAccessors(proto, pspec, GObject) {
const {name, flags} = pspec;
+ if (flags & GObject.ParamFlags.CONSTRUCT_ONLY)
+ return;
const underscoreName = name.replace(/-/g, '_');
const camelName = name.replace(/-([a-z])/g, match => match[1].toUpperCase());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]