aboutsummaryrefslogtreecommitdiff
path: root/guile_type_helpers.c
blob: 485827a02c527291691e9ad1e440b8fe95244b81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "guile_type_helpers.h"

#include "macro.h"

SCM scm_from_strbuf(strbuf* s) {
	if (s->scm == NULL) {
		s->scm = scm_from_utf8_stringn (s->mem, s->len - 1);
	}

	return s->scm;
}

SCM scm_from_vector(VECT(vcomponent)* vect, SCM element_type) {
	SCM l = SCM_EOL;
	for (size_t i = 0; i < vect->length; i++) {
		l = scm_cons(
				scm_make_foreign_object_1 (element_type, GET(VECT(vcomponent))(vect, i)),
				l);
	}
	return scm_reverse(l);
}