Commit 2b3659f3 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

widl: Implement [range] attribute.

parent c3676245
......@@ -571,6 +571,16 @@ s_get_filename(void)
return (char *)__FILE__;
}
int s_echo_ranged_int(int n)
{
return n;
}
void s_get_ranged_enum(renum_t *re)
{
*re = RE3;
}
void
s_context_handle_test(void)
{
......@@ -762,6 +772,7 @@ basic_tests(void)
wstr_struct_t ws = {wstring};
str_t str;
se_t se;
renum_t re;
ok(int_return() == INT_CODE, "RPC int_return\n");
......@@ -869,6 +880,14 @@ basic_tests(void)
str = get_filename();
ok(!strcmp(str, __FILE__), "get_filename() returned %s instead of %s\n", str, __FILE__);
midl_user_free(str);
x = echo_ranged_int(0);
ok(x == 0, "echo_ranged_int() returned %d instead of 0\n", x);
x = echo_ranged_int(100);
ok(x == 100, "echo_ranged_int() returned %d instead of 100\n", x);
get_ranged_enum(&re);
ok(re == RE3, "get_ranged_enum() returned %d instead of RE3\n", re);
}
static void
......
......@@ -339,6 +339,21 @@ cpp_quote("#endif")
void get_numbers_struct([out] numbers_struct_t **ns);
str_t get_filename(void);
enum renum
{
RE0,
RE1,
RE2,
RE3,
};
const int RE_MIN = RE0;
const int RE_MAX = RE3;
typedef [range(RE_MIN, RE_MAX)] enum renum renum_t;
typedef [range(0, 100)] int rint_t;
rint_t echo_ranged_int([range(0, 100)] int n);
void get_ranged_enum([out] renum_t *re);
void context_handle_test(void);
void stop(void);
}
......@@ -1274,6 +1274,37 @@ static void type_function_add_head_arg(type_t *type, var_t *arg)
list_add_head( type->details.function->args, &arg->entry );
}
static int is_allowed_range_type(const type_t *type)
{
switch (type_get_type(type))
{
case TYPE_ENUM:
return TRUE;
case TYPE_BASIC:
switch (type_basic_get_type(type))
{
case TYPE_BASIC_INT8:
case TYPE_BASIC_INT16:
case TYPE_BASIC_INT32:
case TYPE_BASIC_INT64:
case TYPE_BASIC_INT:
case TYPE_BASIC_BYTE:
case TYPE_BASIC_CHAR:
case TYPE_BASIC_WCHAR:
case TYPE_BASIC_HYPER:
return TRUE;
case TYPE_BASIC_FLOAT:
case TYPE_BASIC_DOUBLE:
case TYPE_BASIC_ERROR_STATUS_T:
case TYPE_BASIC_HANDLE:
return FALSE;
}
return FALSE;
default:
return FALSE;
}
}
static type_t *append_ptrchain_type(type_t *ptrchain, type_t *type)
{
type_t *ptrchain_type;
......@@ -1363,6 +1394,10 @@ static void set_type(var_t *v, decl_spec_t *decl_spec, const declarator_t *decl,
error_loc("'%s': [v1_enum] attribute applied to non-enum type\n", v->name);
}
if (is_attr(v->attrs, ATTR_RANGE) && !is_allowed_range_type(v->type))
error_loc("'%s': [range] attribute applied to non-integer type\n",
v->name);
ptype = &v->type;
sizeless = FALSE;
if (arr) LIST_FOR_EACH_ENTRY_REV(dim, arr, expr_t, entry)
......@@ -2339,6 +2374,7 @@ static void check_field_common(const type_t *container_type,
case TGT_IFACE_POINTER:
case TGT_BASIC:
case TGT_ENUM:
case TGT_RANGE:
/* nothing to do */
break;
}
......@@ -2388,6 +2424,7 @@ static void check_remoting_args(const var_t *func)
{
case TGT_BASIC:
case TGT_ENUM:
case TGT_RANGE:
case TGT_STRUCT:
case TGT_UNION:
case TGT_CTXT_HANDLE:
......
......@@ -56,6 +56,7 @@ enum typegen_type
TGT_ENUM,
TGT_STRUCT,
TGT_UNION,
TGT_RANGE,
};
typedef int (*type_pred_t)(const type_t *);
......
Markdown is supported
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