aboutsummaryrefslogtreecommitdiff
path: root/src/value.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/value.h')
-rw-r--r--src/value.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/value.h b/src/value.h
new file mode 100644
index 0000000..60d2c43
--- /dev/null
+++ b/src/value.h
@@ -0,0 +1,62 @@
+#ifndef LITERAL_H
+#define LITERAL_H
+
+typedef struct value *value_t;
+
+struct literal {
+ enum literal_type {
+ LITERAL_STRING,
+ LITERAL_NUM_INT,
+ LITERAL_NUM_FLOAT
+ } type;
+
+ union {
+ char *string;
+ long num_int;
+ float num_float;
+ };
+};
+
+// struct pair {
+// };
+// struct proc {
+// };
+
+struct value {
+ enum value_type {
+ VALUE_SYMBOL,
+ VALUE_LITERAL,
+ VALUE_PAIR,
+ VALUE_LIST,
+ VALUE_PROC,
+ VALUE_TYPES
+ } type;
+
+ int references;
+
+ union {
+ char *symbol;
+ struct literal literal;
+ // struct pair pair;
+ // struct pari list;
+ // struct proc_t proc;
+ };
+};
+
+// try to save data as a literal
+// returns a value_t on success and NULL on fail
+// ret is set to: 0 on sucess, > 0 on fail (data isnt this type),
+// and < 0 on error
+value_t value_create(enum value_type type, void *data, int *ret);
+
+// returns a value_t on success
+value_t value_copy(value_t value);
+
+// destroys a value
+void value_destroy(value_t value);
+
+// copy a string version of the value the buf[buf_sz]
+// returns buf on success
+char *value_string(value_t value, char *buf, size_t buf_sz);
+
+#endif