From 9ecde79739a382470a9cf1fa102413b0ec9acc3c Mon Sep 17 00:00:00 2001 From: Jan-Willem Harmannij Date: Thu, 14 Nov 2024 22:01:38 +0100 Subject: [PATCH] Add support for doc-stability gir element --- .../jwharm/javagi/gir/DocStability.java | 45 +++++++++++++++++++ .../jwharm/javagi/gir/Documentation.java | 2 +- .../github/jwharm/javagi/gir/GirElement.java | 4 +- .../github/jwharm/javagi/gir/GirParser.java | 1 + .../jwharm/javagi/gir/InfoElements.java | 4 +- 5 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 generator/src/main/java/io/github/jwharm/javagi/gir/DocStability.java diff --git a/generator/src/main/java/io/github/jwharm/javagi/gir/DocStability.java b/generator/src/main/java/io/github/jwharm/javagi/gir/DocStability.java new file mode 100644 index 00000000..22147769 --- /dev/null +++ b/generator/src/main/java/io/github/jwharm/javagi/gir/DocStability.java @@ -0,0 +1,45 @@ +/* Java-GI - Java language bindings for GObject-Introspection-based libraries + * Copyright (C) 2022-2024 the Java-GI developers + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +package io.github.jwharm.javagi.gir; + +public final class DocStability extends GirElement implements Documentation { + + private final String text; + + public DocStability(String text) { + this.text = text; + } + + public String text() { + return text; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) + return true; + return obj != null && obj.getClass() == this.getClass(); + } + + @Override + public int hashCode() { + return 1; + } +} diff --git a/generator/src/main/java/io/github/jwharm/javagi/gir/Documentation.java b/generator/src/main/java/io/github/jwharm/javagi/gir/Documentation.java index 3f54df3a..6d0a4478 100644 --- a/generator/src/main/java/io/github/jwharm/javagi/gir/Documentation.java +++ b/generator/src/main/java/io/github/jwharm/javagi/gir/Documentation.java @@ -21,7 +21,7 @@ public sealed interface Documentation extends Node - permits Doc, DocDeprecated, DocVersion { + permits Doc, DocDeprecated, DocVersion, DocStability { String text(); Namespace namespace(); diff --git a/generator/src/main/java/io/github/jwharm/javagi/gir/GirElement.java b/generator/src/main/java/io/github/jwharm/javagi/gir/GirElement.java index f80e7ee4..2b9ba63a 100644 --- a/generator/src/main/java/io/github/jwharm/javagi/gir/GirElement.java +++ b/generator/src/main/java/io/github/jwharm/javagi/gir/GirElement.java @@ -97,8 +97,8 @@ public CallableAttrs callableAttrs() { public InfoElements infoElements() { return new InfoElements( - attr("doc-version"), - attr("doc-stability"), + findAny(children, DocVersion.class), + findAny(children, DocStability.class), findAny(children, Doc.class), findAny(children, DocDeprecated.class), findAny(children, SourcePosition.class), diff --git a/generator/src/main/java/io/github/jwharm/javagi/gir/GirParser.java b/generator/src/main/java/io/github/jwharm/javagi/gir/GirParser.java index 448b8552..6e7f42ec 100644 --- a/generator/src/main/java/io/github/jwharm/javagi/gir/GirParser.java +++ b/generator/src/main/java/io/github/jwharm/javagi/gir/GirParser.java @@ -234,6 +234,7 @@ && qname(event.asEndElement().getName()).equals(elemName)) { case "doc" -> new Doc(attributes, contents.toString().trim()); case "docsection" -> new Docsection(attributes, children); case "doc-deprecated" -> new DocDeprecated(contents.toString().trim()); + case "doc-stability" -> new DocStability(contents.toString().trim()); case "doc-version" -> new DocVersion(contents.toString().trim()); case "enumeration" -> new Enumeration(attributes, children, platform); case "field" -> new Field(attributes, children); diff --git a/generator/src/main/java/io/github/jwharm/javagi/gir/InfoElements.java b/generator/src/main/java/io/github/jwharm/javagi/gir/InfoElements.java index 7867ee8e..b9582398 100644 --- a/generator/src/main/java/io/github/jwharm/javagi/gir/InfoElements.java +++ b/generator/src/main/java/io/github/jwharm/javagi/gir/InfoElements.java @@ -23,8 +23,8 @@ import java.util.List; public record InfoElements( - String docVersion, - String docStability, + DocVersion docVersion, + DocStability docStability, Doc doc, DocDeprecated docDeprecated, SourcePosition sourcePosition,