aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcode.scm31
-rw-r--r--guile_interface.h2
-rw-r--r--guile_interface.scm.c14
3 files changed, 27 insertions, 20 deletions
diff --git a/code.scm b/code.scm
index ec92c347..5ad6ad6c 100755
--- a/code.scm
+++ b/code.scm
@@ -5,26 +5,33 @@
(begin
;; Supurflous begin block here to make sourcing into geiser easier.
(setenv "LD_LIBRARY_PATH" (getcwd))
- (load-extension "libguile-calendar" "init_vcomponent"))
+ (load-extension "libguile-calendar" "init_lib"))
+
+(define make-vcomponent %vcomponent-make)
+(define children %vcomponent-children)
+(define set-attr! %vcomponent-set-attribute!)
+(define get-attr %vcomponent-get-attribute)
(define root (make-vcomponent "testcal/d1-b.ics"))
-(define cal (car (vcomponent-children root)))
+(define cal (car (children root)))
;; TODO flatten all calendars into root
(use-modules (srfi srfi-19)
(srfi srfi-26))
-(for-each (lambda (ev)
- (vcomponent-set-attribute!
- ev "DTSTART"
- ((cut string->date <> "~Y~m~dT~H~M~S")
- (vcomponent-get-attribute ev "DTSTART"))))
- (vcomponent-children cal))
+(define (mutate-attr! ev field transformer)
+ (set-attr! ev field
+ (transformer
+ (get-attr ev field))))
+
+(for-each (cut mutate-attr! <> "DTSTART"
+ (cut string->date <> "~Y~m~dT~H~M~S"))
+ (children cal))
-(display (vcomponent-get-attribute (car (vcomponent-children cal))
- "DTSTART"))
+(display (get-attr (car (children cal))
+ "DTSTART"))
(newline)
-(display (vcomponent-get-attribute (car (vcomponent-children cal))
- "DTSTART"))
+(display (get-attr (car (children cal))
+ "DTSTART"))
(newline)
diff --git a/guile_interface.h b/guile_interface.h
index 3776d88c..ab86850c 100644
--- a/guile_interface.h
+++ b/guile_interface.h
@@ -13,7 +13,7 @@
* The protection markers stop the GC from doing its thing.
*/
-void init_vcomponent ();
+void init_lib (void);
void init_vcomponent_type (void);
SCM make_vcomponent (SCM);
diff --git a/guile_interface.scm.c b/guile_interface.scm.c
index 725d16e6..537224f6 100644
--- a/guile_interface.scm.c
+++ b/guile_interface.scm.c
@@ -13,7 +13,7 @@ void init_vcomponent_type (void) {
vcomponent_type = scm_make_foreign_object_type(name, slots, NULL);
}
-SCM_DEFINE (make_vcomponent, "make-vcomponent", 1, 0, 0,
+SCM_DEFINE (make_vcomponent, "%vcomponent-make", 1, 0, 0,
(SCM path),
"Loads a vdir iCalendar from the given path.")
{
@@ -34,7 +34,7 @@ SCM_DEFINE (make_vcomponent, "make-vcomponent", 1, 0, 0,
/*
* Returns a line from a component.
*/
-SCM_DEFINE (vcomponent_get_attribute, "vcomponent-get-attribute", 2, 0, 0,
+SCM_DEFINE (vcomponent_get_attribute, "%vcomponent-get-attribute", 2, 0, 0,
(SCM calendar, SCM attr),
"Retuns the given attribute from the vevent object at index in calendar.")
{
@@ -60,7 +60,7 @@ SCM_DEFINE (vcomponent_get_attribute, "vcomponent-get-attribute", 2, 0, 0,
}
}
-SCM_DEFINE (vcomponent_set_attr_x, "vcomponent-set-attribute!", 3, 0, 0,
+SCM_DEFINE (vcomponent_set_attr_x, "%vcomponent-set-attribute!", 3, 0, 0,
(SCM component, SCM attr, SCM new_value),
"")
{
@@ -78,7 +78,7 @@ SCM_DEFINE (vcomponent_set_attr_x, "vcomponent-set-attribute!", 3, 0, 0,
return SCM_UNSPECIFIED;
}
-SCM_DEFINE (vcomponent_child_count, "vcomponent-child-count", 1, 0, 0,
+SCM_DEFINE (vcomponent_child_count, "%vcomponent-child-count", 1, 0, 0,
(SCM component),
"Returns number of child components.")
{
@@ -87,7 +87,7 @@ SCM_DEFINE (vcomponent_child_count, "vcomponent-child-count", 1, 0, 0,
return scm_from_size_t (SIZE(VECT(vcomponent))(&c->components));
}
-SCM_DEFINE(vcomponent_children, "vcomponent-children", 1, 0, 0,
+SCM_DEFINE(vcomponent_children, "%vcomponent-children", 1, 0, 0,
(SCM component),
"")
{
@@ -96,7 +96,7 @@ SCM_DEFINE(vcomponent_children, "vcomponent-children", 1, 0, 0,
return scm_from_vector(&cal->components, vcomponent_type);
}
-SCM_DEFINE(vcomponent_typeof, "vcomponent-typeof", 1, 0, 0,
+SCM_DEFINE(vcomponent_typeof, "%vcomponent-type", 1, 0, 0,
(SCM component),
"Returns type of vcomponent")
{
@@ -105,7 +105,7 @@ SCM_DEFINE(vcomponent_typeof, "vcomponent-typeof", 1, 0, 0,
return scm_from_utf8_symbol(comp->type);
}
-void init_vcomponent () {
+void init_lib (void) {
init_vcomponent_type();
#ifndef SCM_MAGIC_SNARFER