Commit ca041574 authored by Daan Vreeken's avatar Daan Vreeken
Browse files

Add optional initial value to argument list of the 'value' block.

Before, a value of '1.0' had to be created like this :

	blocks(..) {
		{ "value", "one" }
	}
	params {
		{ "one", "value", 1.0 }
	}

Now you can simply instantiate the same block with :

	blocks(..) {
		{ "value", "one", 1.0 }
	}

I've finally found a good use for fully specified multiple choice argument
lists :)

	modified:   block/block_value.c
parent a9a42203
......@@ -57,14 +57,18 @@ static struct controller_block_outterm_list outterms[] = {
{ NULL }
};
static struct controller_block * block_value_float_create(char *name, int argc, va_list ap)
static struct controller_block * block_value_float_create(char *name,
int argc, va_list ap)
{
struct controller_block *value;
if (!(value = controller_block_alloc("value_float", name, sizeof(struct controller_block_private))))
return NULL;
value->private->value = 0.0;
if (argc == 0)
value->private->value = 0.0;
else
value->private->value = va_arg(ap, double);
if (controller_block_outterm_list_init(value, outterms))
goto err_block;
......@@ -86,10 +90,10 @@ err_block:
BLOCK_CREATE(value_float) = {
.create = block_value_float_create,
.args = { NULL },
.args = { "", "double", NULL },
};
BLOCK_CREATE(value) = {
.create = block_value_float_create,
.args = { NULL },
.args = { "", "double", NULL },
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment