Add more C-side accum helpers

This commit is contained in:
Lassi Kortela 2019-10-14 00:43:00 +03:00
parent 874ffe9007
commit b655859822
2 changed files with 10 additions and 1 deletions

View File

@ -1053,9 +1053,11 @@ struct accum {
.list = FL_NIL, .tail = FL_NIL \ .list = FL_NIL, .tail = FL_NIL \
} }
void accum_init(struct accum *accum);
void accum_elt(struct accum *accum, value_t elt); void accum_elt(struct accum *accum, value_t elt);
void accum_pair(struct accum *accum, value_t a, value_t d); void accum_pair(struct accum *accum, value_t a, value_t d);
void accum_name_value(struct accum *accum, const char *name, value_t value); void accum_name_value(struct accum *accum, const char *name, value_t value);
void accum_name_value1(struct accum *accum, const char *name, value_t value);
struct sv_accum { struct sv_accum {
char **vec; char **vec;

View File

@ -21,6 +21,8 @@ void *reallocarray(void *ptr, size_t nmemb, size_t size)
// //
void accum_init(struct accum *accum) { accum->list = accum->tail = FL_NIL; }
void accum_elt(struct accum *accum, value_t elt) void accum_elt(struct accum *accum, value_t elt)
{ {
value_t newtail; value_t newtail;
@ -41,7 +43,12 @@ void accum_pair(struct accum *accum, value_t a, value_t d)
void accum_name_value(struct accum *accum, const char *name, value_t value) void accum_name_value(struct accum *accum, const char *name, value_t value)
{ {
accum_pair(accum, string_from_cstr(name), value); accum_pair(accum, symbol(name), value);
}
void accum_name_value1(struct accum *accum, const char *name, value_t value)
{
accum_pair(accum, symbol(name), fl_cons(value, FL_NIL));
} }
// //