示例#1
0
文件: testa.c 项目: stevedonovan/llib
PValue test(PValue *args) {
    printf("gotcha! %d %d\n",value_as_int(args[1]),a);
    printf("the include paths\n");
    FOR_ARR (str_t,P,incdirs)
        printf("'%s'\n",*P);
    return NULL;
}
示例#2
0
/**
	Get a value as int to a corresponding key if available, else set to default

	\param key key
	\param defvalue default value
	\returns value
*/
int value_as_int_default(const char *key, int defvalue)
{
	if (key_exists(key)) {
		return value_as_int(key);
	} else {
		return defvalue;
	}
}
示例#3
0
ex_value_t *
convert_value (ex_value_t *value, type_t *type)
{
	if (!is_scalar (type) || !is_scalar (ev_types[value->type])) {
		error (0, "unable to convert non-scalar value");
		return value;
	}
	if (is_float (type)) {
		float       val = value_as_float (value);
		return new_float_val (val);
	} else if (type->type == ev_short) {
		int         val = value_as_int (value);
		return new_short_val (val);
	} else if (type->type == ev_uinteger) {
		unsigned    val = value_as_uint (value);
		return new_uinteger_val (val);
	} else {
		//FIXME handle enums separately?
		int         val = value_as_int (value);
		return new_integer_val (val);
	}
}