aboutsummaryrefslogtreecommitdiff
path: root/src/pair.inc.h
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-03-22 20:11:11 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-03-22 20:17:52 +0100
commitd46183860c1f3f10095e95023adcb79b1896ab0e (patch)
treedd331a0efe9777bfe84160139da1e39df3226b71 /src/pair.inc.h
parentAdd stuff to test.scm. (diff)
downloadcalp-d46183860c1f3f10095e95023adcb79b1896ab0e.tar.gz
calp-d46183860c1f3f10095e95023adcb79b1896ab0e.tar.xz
Move C and Scheme code into subdirs.
Diffstat (limited to 'src/pair.inc.h')
-rw-r--r--src/pair.inc.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/pair.inc.h b/src/pair.inc.h
new file mode 100644
index 00000000..c42b2dfd
--- /dev/null
+++ b/src/pair.inc.h
@@ -0,0 +1,34 @@
+#if ! (defined(T) && defined(V))
+#error "Both T and V must be defiend here"
+#else
+
+INIT_F(PAIR(T, V)) {
+ INIT(T, &self->key);
+ INIT(V, &self->val);
+
+ return 0;
+}
+
+FREE_F(PAIR(T, V)) {
+ FREE(T)(&self->key);
+ FREE(V)(&self->val);
+
+ return 0;
+}
+
+FMT_F(PAIR(T, V)) {
+ char lbuf[0x100];
+ char rbuf[0x1000];
+ FMT(T)(&self->key, lbuf);
+ FMT(V)(&self->val, rbuf);
+
+ return sprintf(buf, "<%s, %s>", lbuf, rbuf);
+}
+
+int DEEP_COPY(PAIR(T, V)) (PAIR(T, V)* dest, PAIR(T, V)* src) {
+ DEEP_COPY(T)(&dest->key, &src->key);
+ DEEP_COPY(V)(&dest->val, &src->val);
+ return 0;
+}
+
+#endif /* T & V */