]> git.lizzy.rs Git - uwu-lang.git/blob - api/str.c
Update capitalization of Turing in the README (#1)
[uwu-lang.git] / api / str.c
1 #include <string.h>
2 #include <stdlib.h>
3 #include "str.h"
4
5 UwUVMValue uwustr_create(const char *value)
6 {
7         return (UwUVMValue) {
8                 .type = &uwustr_type,
9                 .data = strdup(value),
10         };
11 }
12
13 char *uwustr_get(UwUVMValue vm_value)
14 {
15         return uwuvm_print_value(vm_value);
16 }
17
18 static void *uwustr_clone(void *data)
19 {
20         return strdup(data);
21 }
22
23 static char *uwustr_print(void *data)
24 {
25         return strdup(data);
26 }
27
28 UwUVMType uwustr_type = {
29         .clone = &uwustr_clone,
30         .delet = &free,
31         .print = &uwustr_print,
32 };