aboutsummaryrefslogtreecommitdiff
path: root/src/guile_interface.scm.c
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-03-24 23:24:15 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-03-24 23:46:48 +0100
commitee1abd5ada9b670791f7dd2d306bdbf9228fa439 (patch)
tree67c530a4918506b3c0389ec403c3abbf0a606868 /src/guile_interface.scm.c
parentSet up better test for recurring events. (diff)
downloadcalp-ee1abd5ada9b670791f7dd2d306bdbf9228fa439.tar.gz
calp-ee1abd5ada9b670791f7dd2d306bdbf9228fa439.tar.xz
Add VIRTUAL vcomponents.
VIRTUAL vcomponents are vcomponents created without a source. Their primiary purpose is for creating brand new events, which will later be dumped to the proper files. They can however also be used in testing for great effect.
Diffstat (limited to '')
-rw-r--r--src/guile_interface.scm.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/guile_interface.scm.c b/src/guile_interface.scm.c
index 7c6fee6f..a9485b38 100644
--- a/src/guile_interface.scm.c
+++ b/src/guile_interface.scm.c
@@ -12,18 +12,23 @@ void init_vcomponent_type (void) {
vcomponent_type = scm_make_foreign_object_type(name, slots, NULL);
}
-SCM_DEFINE (make_vcomponent, "%vcomponent-make", 1, 0, 0,
+SCM_DEFINE (make_vcomponent, "%vcomponent-make", 0, 1, 0,
(SCM path),
"Loads a vdir iCalendar from the given path.")
{
vcomponent* cal =
(vcomponent*) scm_gc_malloc (
sizeof(*cal), "vcomponent");
- INIT(vcomponent, cal, "ROOT");
- char* p = scm_to_utf8_stringn(path, NULL);
- read_vcalendar(cal, p);
- free(p);
+ if (SCM_UNBNDP(path)) {
+ INIT(vcomponent, cal);
+ } else {
+ INIT(vcomponent, cal, "ROOT");
+
+ char* p = scm_to_utf8_stringn(path, NULL);
+ read_vcalendar(cal, p);
+ free(p);
+ }
return scm_from_vcomponent (cal);
}
@@ -171,7 +176,7 @@ SCM_DEFINE (vcomponent_parent, "%vcomponent-parent", 1, 0, 0,
}
}
-SCM_DEFINE(vcomponent_typeof, "%vcomponent-type", 1, 0, 0,
+SCM_DEFINE(vcomponent_typeof, "%vcomponent-get-type", 1, 0, 0,
(SCM component),
"Returns type of vcomponent")
{
@@ -180,6 +185,22 @@ SCM_DEFINE(vcomponent_typeof, "%vcomponent-type", 1, 0, 0,
return scm_from_utf8_symbol(comp->type);
}
+SCM_DEFINE(vcomponent_set_type_x, "%vcomponent-set-type!", 2, 0, 0,
+ (SCM component, SCM type),
+ "Replace current type of vcomponent")
+{
+ scm_assert_foreign_object_type (vcomponent_type, component);
+ vcomponent* comp = scm_foreign_object_ref (component, 0);
+
+ if (comp->type) free (comp->type);
+
+ char* ntype = scm_to_utf8_stringn (type, NULL);
+ comp->type = calloc(sizeof(*ntype), strlen(ntype) + 1);
+ strcpy(comp->type, ntype);
+
+ return SCM_UNSPECIFIED;
+}
+
SCM scm_from_vcomponent(vcomponent* v) {
if (v->scm == NULL) {
v->scm = scm_make_foreign_object_1 (vcomponent_type, v);