diff --git a/lib/kc3/0.1/facts.kc3 b/lib/kc3/0.1/facts.kc3
index d7b563b..67f64e9 100644
--- a/lib/kc3/0.1/facts.kc3
+++ b/lib/kc3/0.1/facts.kc3
@@ -12,7 +12,7 @@ defmodule Facts do
rwlock_thread: (Ptr) 0,
transaction: (Ptr) 0]
- def add_tags = cfn Fact "facts_add_tags" (Facts, Tag, Tag, Tag, Result)
+ def add_tags = cfn FactW "kc3_facts_add_tags" (Facts, Tag, Tag, Tag, Result)
def cast = cfn Tag "tag_init_cast_struct" (Result, Sym, Tag)
diff --git a/libkc3/kc3.c b/libkc3/kc3.c
index 4ade011..784db72 100644
--- a/libkc3/kc3.c
+++ b/libkc3/kc3.c
@@ -27,6 +27,8 @@
#include "buf_parse.h"
#include "call.h"
#include "env.h"
+#include "fact.h"
+#include "facts.h"
#include "facts_cursor.h"
#include "fd.h"
#include "kc3_main.h"
@@ -207,6 +209,17 @@ s_tag * kc3_fact_from_ptr (s_tag *tag, u_ptr_w *ptr)
return tag_init_struct_with_data(tag, &g_sym_Fact, ptr->p, false);
}
+s_fact_w * kc3_facts_add_tags (s_facts *facts, const s_tag *subject,
+ const s_tag *predicate,
+ const s_tag *object,
+ s_fact_w *dest)
+{
+ const s_fact *fact;
+ if (! (fact = facts_add_tags(facts, subject, predicate, object)))
+ return NULL;
+ return fact_w_init_fact(dest, fact);
+}
+
s_tag * kc3_facts_collect_with_tags (s_facts *facts,
s_tag *subject,
s_tag *predicate,
diff --git a/test/ikc3/facts.kc3 b/test/ikc3/facts.kc3
index f38d239..096383a 100644
--- a/test/ikc3/facts.kc3
+++ b/test/ikc3/facts.kc3
@@ -1,8 +1,10 @@
quote %Fact{}
%Fact{}
-quote %Set.Tag{}
-%Set.Tag{}
-quote %Set.Fact{}
-%Set.Fact{}
-quote %Facts{}
-%Facts{}
+quote db = Facts.database() ; void
+db = Facts.database() ; void
+quote Facts.add_tags(db, 1, 2, 3)
+Facts.add_tags(db, 1, 2, 3)
+quote Facts.add_tags(db, 4, 5, 6)
+Facts.add_tags(db, 4, 5, 6)
+quote Facts.with_tags(db, s = ?, p = ?, o = ?, fn (fact) { puts(fact); :ok })
+Facts.with_tags(db, s = ?, p = ?, o = ?, fn (fact) { puts(fact); :ok })
diff --git a/test/ikc3/facts.out.expected b/test/ikc3/facts.out.expected
index c4000f2..cac7d62 100644
--- a/test/ikc3/facts.out.expected
+++ b/test/ikc3/facts.out.expected
@@ -3,31 +3,25 @@
predicate: (Ptr) 0x0,
object: (Ptr) 0x0,
id: (Uw) 0}
-%Set.Tag{}
-%Set.Tag{collisions: (Uw) 0,
- count: (Uw) 0,
- items: (Ptr) 0x0,
- max: (Uw) 0}
-%Set.Fact{}
-%Set.Fact{collisions: (Uw) 0,
- count: (Uw) 0,
- items: (Ptr) 0x0,
- max: (Uw) 0}
-%Facts{}
-%Facts{tags: %Set.Tag{collisions: (Uw) 0,
- count: (Uw) 0,
- items: (Ptr) 0x0,
- max: (Uw) 0},
- facts: %Set.Fact{collisions: (Uw) 0,
- count: (Uw) 0,
- items: (Ptr) 0x0,
- max: (Uw) 0},
- index_spo: (Ptr) 0x0,
- index_pos: (Ptr) 0x0,
- index_osp: (Ptr) 0x0,
- log: (Ptr) 0x0,
- next_id: (Uw) 0,
- rwlock: (Ptr) 0x0,
- rwlock_count: (Sw) 0,
- rwlock_thread: (Ptr) 0x0,
- transaction: (Ptr) 0x0}
+db = Facts.database() ; void
+void
+Facts.add_tags(db, 1, 2, 3)
+%FactW{subject: 1,
+ predicate: 2,
+ object: 3,
+ id: (Uw) 0}
+Facts.add_tags(db, 4, 5, 6)
+%FactW{subject: 4,
+ predicate: 5,
+ object: 6,
+ id: (Uw) 0}
+Facts.with_tags(db, s = ?, p = ?, o = ?, fn (fact) { puts(fact) ; :ok })
+%FactW{subject: 1,
+ predicate: 2,
+ object: 3,
+ id: (Uw) 0}
+%FactW{subject: 4,
+ predicate: 5,
+ object: 6,
+ id: (Uw) 0}
+:ok