From 93c755ffe482996bbdae2c90bcdbde2062d451dd Mon Sep 17 00:00:00 2001 From: piexel Date: Tue, 6 Oct 2026 12:06:46 +0200 Subject: [PATCH] Add FeatureRegistry.registerSettings and the @Ref annotation for value references Modules register settings types that no stage names in when(...) explicitly; the id must be the module's id or below it, and repeating it or also naming the type in when(...) changes nothing. A type its owner registered may be named by any module. OptionsMetadata.Option now carries its field and @Ref reference. --- src/main/java/com/volmit/FeatureRegistry.java | 10 +++ .../com/volmit/config/OptionsMetadata.java | 21 +++++-- src/main/java/com/volmit/config/Ref.java | 13 ++++ .../java/com/volmit/config/Reference.java | 29 +++++++++ .../java/com/volmit/host/LoadedModules.java | 2 +- .../java/com/volmit/host/ModuleRegistry.java | 35 +++++++++-- .../com/volmit/host/StageGraphBuilder.java | 13 ++-- .../com/volmit/host/ModuleRegistryTest.java | 62 +++++++++++++++++-- .../java/com/volmit/host/StageGraphTest.java | 2 +- 9 files changed, 164 insertions(+), 23 deletions(-) create mode 100644 src/main/java/com/volmit/config/Ref.java create mode 100644 src/main/java/com/volmit/config/Reference.java diff --git a/src/main/java/com/volmit/FeatureRegistry.java b/src/main/java/com/volmit/FeatureRegistry.java index aa923f97e..d7a5f0d63 100644 --- a/src/main/java/com/volmit/FeatureRegistry.java +++ b/src/main/java/com/volmit/FeatureRegistry.java @@ -4,6 +4,7 @@ import com.volmit.mantle.MantleCodec; import com.volmit.mantle.MantleKey; import com.volmit.mantle.MantleLifetime; import com.volmit.object.ObjectGeneratorFactory; +import com.volmit.stage.StageGraph; /** Host implementation collects non-stage registrations before loading pack configuration. * Feature IDs must be unique. JSON fields must be unique per attachment target, including the @@ -20,4 +21,13 @@ public interface FeatureRegistry { void registerMantle(MantleKey key, MantleLifetime lifetime, MantleCodec codec); void registerObject(Class featureType, ObjectGeneratorFactory factory); + + /** Catalogs a settings type that no stage names in {@code when(...)}, such as one read only + * through {@link com.volmit.config.FeatureSettings#at}, so the host decodes it and studio + * describes it. Settings that a stage names are catalogued without this; registering them as + * well changes nothing. The type's feature id must be this module's id or start with it and + * {@code /}. Once registered, other modules may name the type in {@code when(...)} (see + * {@link StageGraph}). + */ + void registerSettings(Class settingsType); } diff --git a/src/main/java/com/volmit/config/OptionsMetadata.java b/src/main/java/com/volmit/config/OptionsMetadata.java index 3b4c6ec26..4274e26fe 100644 --- a/src/main/java/com/volmit/config/OptionsMetadata.java +++ b/src/main/java/com/volmit/config/OptionsMetadata.java @@ -1,5 +1,6 @@ package com.volmit.config; +import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.lang.reflect.Type; import java.util.ArrayList; @@ -12,8 +13,17 @@ public record OptionsMetadata(String description, String snippet, List