diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-04-06 19:04:28 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-04-06 19:04:33 +0200 |
commit | ee3d463024179514f09d80d962d1b9765462dd6b (patch) | |
tree | 4b7c4916d30fcd7df88f9452b601658d18de7320 | |
parent | Rename get_property to get_attributes. (diff) | |
download | calp-ee3d463024179514f09d80d962d1b9765462dd6b.tar.gz calp-ee3d463024179514f09d80d962d1b9765462dd6b.tar.xz |
Add temporary set-attributes!
Diffstat (limited to '')
-rw-r--r-- | module/vcalendar.scm | 13 | ||||
-rw-r--r-- | module/vcalendar/primitive.scm | 1 | ||||
-rw-r--r-- | src/guile_interface.scm.c | 19 | ||||
-rw-r--r-- | src/vcal.h | 2 |
4 files changed, 32 insertions, 3 deletions
diff --git a/module/vcalendar.scm b/module/vcalendar.scm index 0f1a3c57..ab404a1a 100644 --- a/module/vcalendar.scm +++ b/module/vcalendar.scm @@ -45,8 +45,17 @@ (as-string attr) (as-string prop))) -;; TODO replace this with procedure-with-setter -(define-public prop get-property) +(define (set-property! component attr prop val) + (%vcomponent-set-property! + component + (as-string attr) + (as-string prop) + val)) + +(define-public prop + (make-procedure-with-setter + get-property + set-property!)) (define-public (properties component attr) (%vcomponent-property-list component (as-string attr))) diff --git a/module/vcalendar/primitive.scm b/module/vcalendar/primitive.scm index f41a7803..400750c9 100644 --- a/module/vcalendar/primitive.scm +++ b/module/vcalendar/primitive.scm @@ -15,6 +15,7 @@ %vcomponent-get-attribute %vcomponent-get-property + %vcomponent-set-property! %vcomponent-property-list %vcomponent-attribute-list diff --git a/src/guile_interface.scm.c b/src/guile_interface.scm.c index 1a843f4a..036e9e9c 100644 --- a/src/guile_interface.scm.c +++ b/src/guile_interface.scm.c @@ -90,6 +90,25 @@ SCM_DEFINE (vcomponent_get_property, "%vcomponent-get-property", 3, 0, 0, return llist; } +SCM_DEFINE (vcomponent_set_property_x, "%vcomponent-set-property!", 4, 0, 0, + (SCM component, SCM attr, SCM prop, SCM val), + "") +{ + scm_assert_foreign_object_type (vcomponent_type, component); + vcomponent* comp = scm_foreign_object_ref (component, 0); + + char* key = scm_to_utf8_stringn(scm_string_upcase(attr), NULL); + char* prop_key = scm_to_utf8_stringn(scm_string_upcase(prop), NULL); + content_line* cl = get_attributes (comp, key); + free(key); + + TRIE(param_set)* tt = &cl->cval->val; + LLIST(strbuf)* vals = GET(TRIE(param_set))(tt, prop_key); + vals->cval->scm = val; + + return SCM_UNSPECIFIED; +} + SCM_DEFINE (vcomponent_set_attr_x, "%vcomponent-set-attribute!", 3, 0, 0, (SCM component, SCM attr, SCM new_value), "") @@ -14,7 +14,7 @@ /* * content_line: - * a mapping between a top level key, and everything it contains. + * (a mapping) between a top level key, and everything it contains. * content_set: * A top level value, along with a list of kv pairs for all its * possible parameters. |