Commit b66d2972207454af99fc186d72c68a4f98fc6166

Thomas de Grivel 2024-10-25T15:06:34

struct_put for s_time

diff --git a/ikc3/.ikc3_history b/ikc3/.ikc3_history
index b271fb3..4367de1 100644
--- a/ikc3/.ikc3_history
+++ b/ikc3/.ikc3_history
@@ -1,7 +1,3 @@
-type(10000000000000000000000000000000000000000000000000)
-type(1)
-type(255)
-type(256)
 quote fn (x) { x * x }
 quote if true do if false do 1 else fn (x) { x * x } end end
 quote if true do if false do 1 else fn (x) do x * x end end end
@@ -97,3 +93,7 @@ Map.put(%{}, :a, 1)
 Struct.put(%KC3.Operator{}, :sym, :plop)
 type(%KC3.Operator{})
 Struct.put(%KC3.Operator{}, :sym, :plop)
+%Time{}
+a = %Time{}
+a.tv_sec
+a.tv_nsec
diff --git a/libkc3/kc3.c b/libkc3/kc3.c
index bf508e2..b02f0b0 100644
--- a/libkc3/kc3.c
+++ b/libkc3/kc3.c
@@ -57,6 +57,7 @@ void kc3_system_pipe_exec (s32 pipe_fd, char **argv,
 s_tag * kc3_access (const s_tag *tag, const s_list * const *key,
                     s_tag *dest)
 {
+  s_struct s = {0};
   assert(tag);
   assert(key);
   assert(dest);
@@ -75,6 +76,12 @@ s_tag * kc3_access (const s_tag *tag, const s_list * const *key,
     return map_access(&tag->data.map, key, dest);
   case TAG_STRUCT:
     return struct_access(&tag->data.struct_, key, dest);
+  case TAG_TIME:
+    if (! struct_init_with_data(&s, &g_sym_Time,
+                                (s_time *) &tag->data.time,
+                                false))
+      return NULL;
+    return struct_access(&s, key, dest);
   default:
     break;
   }