aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/datatypes.h
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-12-07 21:42:45 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-12-07 21:42:45 -0500
commit544b1fb6a70d55bf368b827136cf0f37a26e8288 (patch)
tree52886c54934fed676263611bdb401dbeb80aac63 /src/stdlib/datatypes.h
parentefbdf7b13e4b559958ed5b1b9ca9d772ae77d702 (diff)
Change Paths to be an enum of their different types.
Diffstat (limited to 'src/stdlib/datatypes.h')
-rw-r--r--src/stdlib/datatypes.h42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/stdlib/datatypes.h b/src/stdlib/datatypes.h
index fbd2ce73..49c4d835 100644
--- a/src/stdlib/datatypes.h
+++ b/src/stdlib/datatypes.h
@@ -75,8 +75,8 @@ typedef struct Present$$struct {
#define PRESENT_STRUCT ((Present$$type){})
typedef struct {
- bool has_value;
Present$$type value;
+ bool has_value;
} $OptionalPresent$$type;
#define NONE_PRESENT_STRUCT (($OptionalPresent$$type){.has_value = false})
@@ -111,14 +111,46 @@ typedef struct Text_s {
};
} Text_t;
-typedef enum PathEnum { PATHTYPE_NONE, PATHTYPE_RELATIVE, PATHTYPE_ABSOLUTE, PATHTYPE_HOME } PathType_t;
-#define OptionalPathType_t PathType_t
+typedef struct Path$AbsolutePath$$struct {
+ List_t components;
+} Path$AbsolutePath$$type;
typedef struct {
- PathType_t type;
+ Path$AbsolutePath$$type value;
+ bool has_value;
+} $OptionalPath$AbsolutePath$$type;
+
+typedef struct Path$RelativePath$$struct {
+ List_t components;
+} Path$RelativePath$$type;
+
+typedef struct {
+ Path$RelativePath$$type value;
+ bool has_value;
+} $OptionalPath$RelativePath$$type;
+
+typedef struct Path$HomePath$$struct {
List_t components;
+} Path$HomePath$$type;
+
+typedef struct {
+ Path$HomePath$$type value;
+ bool has_value;
+} $OptionalPath$HomePath$$type;
+
+#define Path$tagged$AbsolutePath(comps) ((Path_t){.$tag = Path$tag$AbsolutePath, .AbsolutePath.components = comps})
+#define Path$tagged$RelativePath(comps) ((Path_t){.$tag = Path$tag$RelativePath, .RelativePath.components = comps})
+#define Path$tagged$HomePath(comps) ((Path_t){.$tag = Path$tag$HomePath, .HomePath.components = comps})
+
+typedef struct {
+ enum { Path$tag$none, Path$tag$AbsolutePath, Path$tag$RelativePath, Path$tag$HomePath } $tag;
+ union {
+ Path$RelativePath$$type RelativePath;
+ Path$AbsolutePath$$type AbsolutePath;
+ Path$HomePath$$type HomePath;
+ List_t components;
+ };
} Path_t;
-#define OptionalPath_t Path_t
#define OptionalBool_t uint8_t
#define OptionalList_t List_t