From 773c3febb37536f77eb4ccb7c7457775ce0c7e0f Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 27 Jun 2026 20:27:43 +0100 Subject: Add skeleton for Rust types generator --- .../hobgoblin/compiler/config/ProjectConfig.java | 4 +++ .../generators/rusttypes/RustTypesGenerator.java | 35 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttypes/RustTypesGenerator.java (limited to 'src') diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/config/ProjectConfig.java b/src/main/java/org/zwobble/hobgoblin/compiler/config/ProjectConfig.java index fda2e15..132a89d 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/config/ProjectConfig.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/config/ProjectConfig.java @@ -4,6 +4,7 @@ import org.zwobble.hobgoblin.compiler.output.generators.Generator; import org.zwobble.hobgoblin.compiler.output.generators.errors.UnknownGeneratorError; import org.zwobble.hobgoblin.compiler.output.generators.javapreciselymatchers.JavaPreciselyMatchersGenerator; import org.zwobble.hobgoblin.compiler.output.generators.javatypes.JavaTypesGenerator; +import org.zwobble.hobgoblin.compiler.output.generators.rusttypes.RustTypesGenerator; import org.zwobble.hobgoblin.compiler.sources.FileFragmentSource; import org.zwobble.json5.reader.Json5ObjectReader; import org.zwobble.sourcetext.SourceText; @@ -42,6 +43,9 @@ public record ProjectConfig( case JavaPreciselyMatchersGenerator.NAME -> JavaPreciselyMatchersGenerator.parseOutputConfig(projectRoot, outputJson); + case RustTypesGenerator.NAME -> + RustTypesGenerator.parseOutputConfig(projectRoot, outputJson); + default -> throw new UnknownGeneratorError( generatorName.value(), diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttypes/RustTypesGenerator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttypes/RustTypesGenerator.java new file mode 100644 index 0000000..c93be76 --- /dev/null +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttypes/RustTypesGenerator.java @@ -0,0 +1,35 @@ +package org.zwobble.hobgoblin.compiler.output.generators.rusttypes; + +import org.zwobble.hobgoblin.compiler.ast.typed.TypedNamespaceNode; +import org.zwobble.hobgoblin.compiler.config.OutputConfig; +import org.zwobble.hobgoblin.compiler.output.generators.Generator; +import org.zwobble.hobgoblin.compiler.typechecker.TypesInfo; +import org.zwobble.json5.reader.Json5ObjectReader; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.List; + +public class RustTypesGenerator implements Generator { + public static final String NAME = "rust-types"; + + public static OutputConfig parseOutputConfig(Path projectRoot, Json5ObjectReader output) { + return () -> { + var relativeOutputPath = output.getString("path").value(); + var outputPath = projectRoot.resolve(relativeOutputPath); + + return new RustTypesGenerator(outputPath); + }; + } + + private final Path outputPath; + + private RustTypesGenerator(Path outputPath) { + this.outputPath = outputPath; + } + + @Override + public void generate(List namespaces, TypesInfo typesInfo) throws IOException { + + } +} -- cgit v1.2.3