diff options
author | Hugo Hörnquist <hugo@hornquist.se> | 2019-03-08 10:12:04 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@hornquist.se> | 2019-03-08 10:12:04 +0100 |
commit | d89343bf6959e8a0f9bf891a8773daf6b8a9825b (patch) | |
tree | 1dfe746619bf4b044fcae3eddec6fbcaa081feeb | |
parent | Remove C hash library. (diff) | |
download | calp-d89343bf6959e8a0f9bf891a8773daf6b8a9825b.tar.gz calp-d89343bf6959e8a0f9bf891a8773daf6b8a9825b.tar.xz |
Add copy-vevent.
Diffstat (limited to '')
-rw-r--r-- | guile_interface.scm.c | 17 | ||||
-rw-r--r-- | vcal.h | 15 | ||||
-rw-r--r-- | vcalendar.scm | 3 | ||||
-rw-r--r-- | vcalendar/primitive.scm | 4 |
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(); @@ -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") |