aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-03-08 10:12:04 +0100
committerHugo Hörnquist <hugo@hornquist.se>2019-03-08 10:12:04 +0100
commitd89343bf6959e8a0f9bf891a8773daf6b8a9825b (patch)
tree1dfe746619bf4b044fcae3eddec6fbcaa081feeb
parentRemove C hash library. (diff)
downloadcalp-d89343bf6959e8a0f9bf891a8773daf6b8a9825b.tar.gz
calp-d89343bf6959e8a0f9bf891a8773daf6b8a9825b.tar.xz
Add copy-vevent.
-rw-r--r--guile_interface.scm.c17
-rw-r--r--vcal.h15
-rw-r--r--vcalendar.scm3
-rw-r--r--vcalendar/primitive.scm4
4 files changed, 36 insertions, 3 deletions
diff --git a/guile_interface.scm.c b/guile_interface.scm.c
index 2dcff513..a134848d 100644
--- a/guile_interface.scm.c
+++ b/guile_interface.scm.c
@@ -177,6 +177,23 @@ SCM_DEFINE(vcomponent_attr_list, "%vcomponent-attribute-list", 1, 0, 0,
return llist;
}
+SCM_DEFINE(vcomponent_shallow_copy, "%vcomponent-shallow-copy", 1, 0, 0,
+ (SCM component),
+ "Creates a shallow copy of the given component.")
+{
+ scm_assert_foreign_object_type (vcomponent_type, component);
+ vcomponent* src = scm_foreign_object_ref (component, 0);
+
+ vcomponent* dest =
+ (vcomponent*) scm_gc_malloc (
+ sizeof(*dest), "vcomponent");
+ INIT(vcomponent, dest, src->type, NULL);
+
+ vcomponent_copy (dest, src);
+ return scm_make_foreign_object_1
+ (vcomponent_type, dest);
+}
+
void init_lib (void) {
init_vcomponent_type();
diff --git a/vcal.h b/vcal.h
index 798a00a1..1dfc5b17 100644
--- a/vcal.h
+++ b/vcal.h
@@ -73,6 +73,11 @@ struct s_vcomponent {
TRIE(content_line) clines;
LLIST(vcomponent) components;
+ /*
+ * Holds a Guile representation of this object. Used to always
+ * return the same foreign (for guile) object for the same
+ * vcomponent.
+ */
SCM scm;
};
@@ -96,8 +101,18 @@ char* vcomponent_get_val (vcomponent*, const char* key);
*/
int PUSH(vcomponent)(vcomponent*, vcomponent*);
+/*
+ * Deep copy is currently not implemented for vcomponentes.
+ * The reason for this method being here is since some
+ * generic methods in other places complain otherwise.
+ */
int DEEP_COPY(vcomponent)(vcomponent*, vcomponent*);
+/*
+ * "Shallow" copy of vcomponent.
+ */
+int vcomponent_copy(vcomponent*, vcomponent*);
+
FMT_F(vcomponent);
#endif /* VCAL_H */
diff --git a/vcalendar.scm b/vcalendar.scm
index 603aefea..89dd682b 100644
--- a/vcalendar.scm
+++ b/vcalendar.scm
@@ -59,5 +59,4 @@
(transformer (attr ev field))))
-
-
+(define-public copy-vcomponent %vcomponent-shallow-copy)
diff --git a/vcalendar/primitive.scm b/vcalendar/primitive.scm
index b4ba1f38..e575115c 100644
--- a/vcalendar/primitive.scm
+++ b/vcalendar/primitive.scm
@@ -12,7 +12,9 @@
%vcomponent-set-attribute!
%vcomponent-get-attribute
- %vcomponent-attribute-list))
+ %vcomponent-attribute-list
+
+ %vcomponent-shallow-copy))
(setenv "LD_LIBRARY_PATH" (dirname (dirname (current-filename))))
(load-extension "libguile-calendar" "init_lib")