aboutsummaryrefslogtreecommitdiff
path: root/src/strbuf.c
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-04-10 00:51:35 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2019-04-10 00:51:35 +0200
commit124f8b42c01a440c6998a13ef13996ac1d312092 (patch)
treefc7faf2a6faa11fa6968f9b4a12e5467513bfe1f /src/strbuf.c
parentAdd {format,print}-recur-rule. (diff)
downloadcalp-124f8b42c01a440c6998a13ef13996ac1d312092.tar.gz
calp-124f8b42c01a440c6998a13ef13996ac1d312092.tar.xz
Rework how attributes and properties are accessed.
Made the fact that properties belong to an attribute shine through to scheme. This by setting the SCM field in the strbuf:ers in my vcomponents to a pair of their old SCM value, and a hash table representing the properties. This also meant that the primitive set-attribute! could be replaced by a set-car! on the pair returned by the primitive get-attribute. And that both set- and get-property now simple works on the hash table returned by get-attribute. The major problem with this release was that I for a while missed that DEEP_COPY(strbuf) now also needed to deep copy the SCM values. Without that attributes in a copied vcomponent would be shared with the original. This mainly lead to repeating events all being the same.
Diffstat (limited to '')
-rw-r--r--src/strbuf.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/strbuf.c b/src/strbuf.c
index c7e3f2b5..66fe2989 100644
--- a/src/strbuf.c
+++ b/src/strbuf.c
@@ -70,8 +70,13 @@ int DEEP_COPY(strbuf)(strbuf* dest, strbuf* src) {
}
if (src->scm != NULL) {
- /* The magic SCM type is copied when reassigned. */
- dest->scm = src->scm;
+ /*
+ * Upon Vcomponent binding into scheme I place all
+ * strings inside cons cells. This leads to a deep
+ * copy being required. copy-tree however returns
+ * the same object for atoms and scheme strings.
+ */
+ dest->scm = scm_copy_tree(src->scm);
/* NOTE This is a bit of a leaky abstraction. */
scm_gc_protect_object(dest->scm);
}