aboutsummaryrefslogtreecommitdiff
path: root/guile_type_helpers.c
blob: 74223bae57ccfe2b8196dc9e9c50c5a613b2a941 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#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);
		scm_gc_protect_object(s->scm);
	}

	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);
}