Commit e4a0cab31da3919d3b2ce1170e0bbe84f4b3066c

Thomas de Grivel 2024-08-01T17:22:48

fix test http 04

diff --git a/lib/kc3/0.1/buf.kc3 b/lib/kc3/0.1/buf.kc3
index 3e495df..d5cec08 100644
--- a/lib/kc3/0.1/buf.kc3
+++ b/lib/kc3/0.1/buf.kc3
@@ -5,6 +5,7 @@ defmodule Buf do
              free: false,
              line: (Sw) 0,
              ptr: (Ptr) 0,
+             read_only: false,
              refill: (Ptr) 0,
              rpos: (Uw) 0,
              save: (Ptr) 0,
diff --git a/lib/kc3/0.1/http/request.kc3 b/lib/kc3/0.1/http/request.kc3
index f33ffbb..1debeed 100644
--- a/lib/kc3/0.1/http/request.kc3
+++ b/lib/kc3/0.1/http/request.kc3
@@ -7,6 +7,6 @@ defmodule HTTP.Request do
 
   dlopen(__DIR__ + "../http.so")
 
-  def buf_parse = cfn HTTP.Request "http_request_buf_parse" (Result, Ptr)
+  def buf_parse = cfn HTTP.Request "http_request_buf_parse" (Result, Buf)
 
 end
diff --git a/lib/kc3/0.1/http/response.kc3 b/lib/kc3/0.1/http/response.kc3
index 10664e7..8630e6b 100644
--- a/lib/kc3/0.1/http/response.kc3
+++ b/lib/kc3/0.1/http/response.kc3
@@ -12,6 +12,6 @@ defmodule HTTP.Response do
                           {(U16) 404, "Not Found"},
                           {(U16) 500, "Internal Server Error"}]
 
-  def buf_write = cfn Sw "http_response_buf_write" (HTTP.Response, Ptr)
+  def buf_write = cfn Sw "http_response_buf_write" (HTTP.Response, Buf)
 
 end
diff --git a/libkc3/buf.c b/libkc3/buf.c
index 057dd91..225cca0 100644
--- a/libkc3/buf.c
+++ b/libkc3/buf.c
@@ -640,10 +640,10 @@ sw buf_peek_u64 (s_buf *buf, u64 *p)
 
 sw buf_read_1 (s_buf *buf, const char *p)
 {
-  s_str stra;
+  s_str str;
   assert(buf);
-  str_init_1(&stra, NULL, p);
-  return buf_read_str(buf, &stra);
+  str_init_1(&str, NULL, p);
+  return buf_read_str(buf, &str);
 }
 
 sw buf_read_character_utf8 (s_buf *buf, character *p)
diff --git a/libkc3/tag.c b/libkc3/tag.c
index b095949..e69203d 100644
--- a/libkc3/tag.c
+++ b/libkc3/tag.c
@@ -1006,72 +1006,6 @@ bool tag_to_ffi_pointer (s_tag *tag, const s_sym *type, void **dest)
       return true;
     }
     goto invalid_cast;
-  case TAG_RATIO:
-    if (type == &g_sym_Ratio) {
-      *dest = &tag->data.ratio;
-      return true;
-    }
-    goto invalid_cast;
-  case TAG_SW:
-    if (type == &g_sym_Sw) {
-      *dest = &tag->data.sw;
-      return true;
-    }
-    goto invalid_cast;
-  case TAG_S64:
-    if (type == &g_sym_S64) {
-      *dest = &tag->data.s64;
-      return true;
-    }
-    goto invalid_cast;
-  case TAG_S32:
-    if (type == &g_sym_S32) {
-      *dest = &tag->data.s32;
-      return true;
-    }
-    goto invalid_cast;
-  case TAG_S16:
-    if (type == &g_sym_S16) {
-      *dest = &tag->data.s16;
-      return true;
-    }
-    goto invalid_cast;
-  case TAG_S8:
-    if (type == &g_sym_S8) {
-      *dest = &tag->data.s8;
-      return true;
-    }
-    goto invalid_cast;
-  case TAG_U8:
-    if (type == &g_sym_U8) {
-      *dest = &tag->data.u8;
-      return true;
-    }
-    goto invalid_cast;
-  case TAG_U16:
-    if (type == &g_sym_U16) {
-      *dest = &tag->data.u16;
-      return true;
-    }
-    goto invalid_cast;
-  case TAG_U32:
-    if (type == &g_sym_U32) {
-      *dest = &tag->data.u32;
-      return true;
-    }
-    goto invalid_cast;
-  case TAG_U64:
-    if (type == &g_sym_U64) {
-      *dest = &tag->data.u64;
-      return true;
-    }
-    goto invalid_cast;
-  case TAG_UW:
-    if (type == &g_sym_Uw) {
-      *dest = &tag->data.uw;
-      return true;
-    }
-    goto invalid_cast;
   case TAG_LIST:
     if (type == &g_sym_List) {
       *dest = &tag->data.list;
@@ -1095,23 +1029,25 @@ bool tag_to_ffi_pointer (s_tag *tag, const s_sym *type, void **dest)
       *dest = &tag->data.ptr.p;
       return true;
     }
-    goto invalid_cast;
+    *dest = tag->data.ptr.p;
+    return true;
   case TAG_PTR_FREE:
     if (type == &g_sym_Ptr ||
         type == &g_sym_PtrFree) {
       *dest = &tag->data.ptr_free.p;
       return true;
     }
-    goto invalid_cast;
+    *dest = tag->data.ptr.p;
+    return true;
   case TAG_QUOTE:
     if (type == &g_sym_Quote) {
       *dest = &tag->data.quote;
       return true;
     }
     goto invalid_cast;
-  case TAG_UNQUOTE:
-    if (type == &g_sym_Unquote) {
-      *dest = &tag->data.unquote;
+  case TAG_RATIO:
+    if (type == &g_sym_Ratio) {
+      *dest = &tag->data.ratio;
       return true;
     }
     goto invalid_cast;
@@ -1142,6 +1078,12 @@ bool tag_to_ffi_pointer (s_tag *tag, const s_sym *type, void **dest)
       return true;
     }
     goto invalid_cast;
+  case TAG_SW:
+    if (type == &g_sym_Sw) {
+      *dest = &tag->data.sw;
+      return true;
+    }
+    goto invalid_cast;
   case TAG_SYM:
     if (type == &g_sym_Sym) {
       *dest = (void *) &tag->data.sym;
@@ -1156,12 +1098,72 @@ bool tag_to_ffi_pointer (s_tag *tag, const s_sym *type, void **dest)
       return true;
     }
     goto invalid_cast;
+  case TAG_S8:
+    if (type == &g_sym_S8) {
+      *dest = &tag->data.s8;
+      return true;
+    }
+    goto invalid_cast;
+  case TAG_S16:
+    if (type == &g_sym_S16) {
+      *dest = &tag->data.s16;
+      return true;
+    }
+    goto invalid_cast;
+  case TAG_S32:
+    if (type == &g_sym_S32) {
+      *dest = &tag->data.s32;
+      return true;
+    }
+    goto invalid_cast;
+  case TAG_S64:
+    if (type == &g_sym_S64) {
+      *dest = &tag->data.s64;
+      return true;
+    }
+    goto invalid_cast;
   case TAG_TUPLE:
     if (type == &g_sym_Tuple) {
       *dest = &tag->data.tuple;
       return true;
     }
     goto invalid_cast;
+  case TAG_U8:
+    if (type == &g_sym_U8) {
+      *dest = &tag->data.u8;
+      return true;
+    }
+    goto invalid_cast;
+  case TAG_U16:
+    if (type == &g_sym_U16) {
+      *dest = &tag->data.u16;
+      return true;
+    }
+    goto invalid_cast;
+  case TAG_U32:
+    if (type == &g_sym_U32) {
+      *dest = &tag->data.u32;
+      return true;
+    }
+    goto invalid_cast;
+  case TAG_U64:
+    if (type == &g_sym_U64) {
+      *dest = &tag->data.u64;
+      return true;
+    }
+    goto invalid_cast;
+  case TAG_UNQUOTE:
+    if (type == &g_sym_Unquote) {
+      *dest = &tag->data.unquote;
+      return true;
+    }
+    goto invalid_cast;
+  case TAG_UW:
+    if (type == &g_sym_Uw) {
+      *dest = &tag->data.uw;
+      return true;
+    }
+    goto invalid_cast;
   case TAG_VAR:
     if (type == &g_sym_Tag) {
       *dest = tag;