From 2d89630737f9e044d5b66f3afaaecc490bd22711 Mon Sep 17 00:00:00 2001
From: badcel <1218031+badcel@users.noreply.github.com>
Date: Sun, 3 Dec 2023 14:35:38 +0100
Subject: [PATCH] GirModel: Add field writable property
---
src/Generation/GirLoader/Output/Field.GirModel.cs | 1 +
src/Generation/GirLoader/Output/Field.cs | 9 ++++++---
src/Generation/GirLoader/Output/FieldFactory.cs | 2 ++
src/Generation/GirModel/Field.cs | 1 +
4 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/Generation/GirLoader/Output/Field.GirModel.cs b/src/Generation/GirLoader/Output/Field.GirModel.cs
index c80d71041..82de7681a 100644
--- a/src/Generation/GirLoader/Output/Field.GirModel.cs
+++ b/src/Generation/GirLoader/Output/Field.GirModel.cs
@@ -6,6 +6,7 @@ public partial class Field : GirModel.Field
{
string GirModel.Field.Name => Name;
bool GirModel.Field.IsReadable => Readable;
+ bool GirModel.Field.IsWritable => Writable;
bool GirModel.Field.IsPrivate => Private;
bool GirModel.Field.IsPointer => TypeReference.CTypeReference?.IsPointer ?? false;
bool GirModel.Field.Introspectable => Introspectable;
diff --git a/src/Generation/GirLoader/Output/Field.cs b/src/Generation/GirLoader/Output/Field.cs
index 55bb43d7f..ab92bd1b0 100644
--- a/src/Generation/GirLoader/Output/Field.cs
+++ b/src/Generation/GirLoader/Output/Field.cs
@@ -7,6 +7,7 @@ public partial class Field
public Callback? Callback { get; }
public bool Readable { get; }
+ public bool Writable { get; }
public bool Private { get; }
public bool Introspectable { get; }
@@ -18,19 +19,21 @@ public partial class Field
///
/// Optional: If set it is expected that the callback belongs to the given symbol reference.
///
+ ///
///
///
- public Field(string name, TypeReference typeReference, bool introspectable, bool readable = true, bool @private = false)
+ public Field(string name, TypeReference typeReference, bool introspectable, bool readable = true, bool writable = false, bool @private = false)
{
Name = name;
TypeReference = typeReference;
Readable = readable;
+ Writable = writable;
Private = @private;
Introspectable = introspectable;
}
- public Field(string name, ResolveableTypeReference resolveableTypeReference, Callback callback, bool introspectable, bool readable = true, bool @private = false)
- : this(name, resolveableTypeReference, introspectable, readable, @private)
+ public Field(string name, ResolveableTypeReference resolveableTypeReference, Callback callback, bool introspectable, bool readable = true, bool writable = false, bool @private = false)
+ : this(name, resolveableTypeReference, introspectable, readable, writable, @private)
{
Callback = callback;
resolveableTypeReference.ResolveAs(Callback);
diff --git a/src/Generation/GirLoader/Output/FieldFactory.cs b/src/Generation/GirLoader/Output/FieldFactory.cs
index f8fcb3b7a..7d3e9b803 100644
--- a/src/Generation/GirLoader/Output/FieldFactory.cs
+++ b/src/Generation/GirLoader/Output/FieldFactory.cs
@@ -30,6 +30,7 @@ public Field Create(Input.Field info, Repository repository)
resolveableTypeReference: _typeReferenceFactory.CreateResolveable(info.Callback.Name, info.Callback.Type),
callback: _callbackFactory.Create(info.Callback, repository),
readable: info.Readable,
+ writable: info.Writeable,
@private: info.Private,
introspectable: info.Introspectable
);
@@ -39,6 +40,7 @@ public Field Create(Input.Field info, Repository repository)
name: info.Name,
typeReference: _typeReferenceFactory.Create(info),
readable: info.Readable,
+ writable: info.Writeable,
@private: info.Private,
introspectable: info.Introspectable
);
diff --git a/src/Generation/GirModel/Field.cs b/src/Generation/GirModel/Field.cs
index 2c7942599..aeac9265d 100644
--- a/src/Generation/GirModel/Field.cs
+++ b/src/Generation/GirModel/Field.cs
@@ -6,6 +6,7 @@ public interface Field
{
string Name { get; }
bool IsReadable { get; }
+ bool IsWritable { get; }
bool IsPrivate { get; }
bool IsPointer { get; }
bool Introspectable { get; }