7. Runt Functionality
These are core words and functions designed to integrate ftlists into runt and graforge.
7.1. loader
The loader for all the runt words is done with
load_ftlist
. Like all runt graforge loaders, this expects
the graforge runt pointer pw
.
int load_ftlist(runt_vm *vm, runt_ptr pw);
<<wordfuncs>>
int load_ftlist(runt_vm *vm, runt_ptr pw)
{
runt_cell *c;
<<words>>
return RUNT_OK;
}
7.2. ftlist_new
The runt word ftlist_new
allocates a new ftlist using
graforge, then pushes it onto the stack.
runt_keyword_define(vm,
"ftlist_new",
10,
rproc_ftlist_new,
&c);
runt_cell_data(vm, c, pw);
static runt_int rproc_ftlist_new(runt_vm *vm, runt_ptr p)
{
gf_patch *patch;
sp_ftlist *ftlst;
int rc;
runt_stacklet *s;
patch = rgf_get_patch(p);
rc = runt_ppush(vm, &s);
RUNT_ERROR_CHECK(rc);
ftlst = malloc(sp_ftlist_sizeof());
sp_ftlist_init(ftlst);
rgf_append_ftlist(patch, ftlst);
rgf_stacklet_ftlist(vm, s, ftlst);
return RUNT_OK;
}
7.3. rgf_get_ftlist
Pops an ftlist from the runt stack, and does some light type checking.
runt_int rgf_get_ftlist(runt_vm *vm, sp_ftlist **ftl);
runt_int rgf_get_ftlist(runt_vm *vm, sp_ftlist **ftl)
{
runt_int rc;
runt_stacklet *s;
rc = runt_ppop(vm, &s);
RUNT_ERROR_CHECK(rc);
if(s->t != FTLIST_TYPE) {
runt_print(vm, "Parameter does not seem to be an ftlist\n");
*ftl = NULL;
return RUNT_NOT_OK;
}
*ftl = runt_to_cptr(s->p);
return RUNT_OK;
}
7.4. rgf_append_ftlist
Allocates and appends an ftlist to the current graforge pointer list.
void rgf_append_ftlist(gf_patch *patch, sp_ftlist *ftl);
static void free_ftlist(gf_pointer *p)
{
sp_ftlist *ftlst;
ftlst = gf_pointer_data(p);
sp_ftlist_clean(ftlst);
free(ftlst);
}
void rgf_append_ftlist(gf_patch *patch, sp_ftlist *ftl)
{
gf_patch_append_userdata(patch, free_ftlist, ftl);
}
7.5. type id
The type id is used inside the stacklet as a means for soft
type checking. It it send to be END + 111
, where END
is the the last id of the default ugens (retrived via
rgf_get_end
).
This type ID represented as a macro FTLIST_TYPE
.
#define FTLIST_TYPE (rgf_get_end() + 111)
7.6. rgf_stacklet_ftlist
Configures a runt stacklet (presumably being pushed) to
encapsulate an ftlist. The most important thing here is
the type id, which is set to be FTLIST_TYPE
.
void rgf_stacklet_ftlist(runt_vm *vm,
runt_stacklet *s,
sp_ftlist *ftl);
void rgf_stacklet_ftlist(runt_vm *vm,
runt_stacklet *s,
sp_ftlist *ftl)
{
runt_stacklet_init(vm, s);
s->p = runt_mk_cptr(vm, ftl);
s->t = FTLIST_TYPE;
}
prev | home | next