Module: wine Branch: master Commit: 1c56d293f0087789d975ffe5c666fc442e015618 URL: http://source.winehq.org/git/wine.git/?a=commit;h=1c56d293f0087789d975ffe5c6...
Author: Michael Karcher wine@mkarcher.dialup.fu-berlin.de Date: Sun Jan 11 15:00:18 2009 +0100
widl: Dereference operator in expr works on any declared pointer.
---
dlls/rpcrt4/tests/server.c | 23 +++++++++++++++++++++++ dlls/rpcrt4/tests/server.idl | 1 + tools/widl/expr.c | 3 +++ 3 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/dlls/rpcrt4/tests/server.c b/dlls/rpcrt4/tests/server.c index df0cdfd..fe4a1e8 100644 --- a/dlls/rpcrt4/tests/server.c +++ b/dlls/rpcrt4/tests/server.c @@ -227,6 +227,23 @@ s_sum_conf_array(int x[], int n) }
int +s_sum_conf_ptr_by_conf_ptr(int n1, int *n2_then_x1, int *x2) +{ + int i; + int sum = 0; + if(n1 == 0) + return 0; + + for(i = 1; i < n1; ++i) + sum += n2_then_x1[i]; + + for(i = 0; i < *n2_then_x1; ++i) + sum += x2[i]; + + return sum; +} + +int s_sum_unique_conf_array(int x[], int n) { return s_sum_conf_array(x, n); @@ -1127,6 +1144,7 @@ array_tests(void) {{1, -2, 3, -4}, {2, 3, 5, 7}, {-4, -1, -14, 4114}} }; int c[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + int c2[] = {10, 100, 200}; vector_t vs[2] = {{1, -2, 3}, {4, -5, -6}}; cps_t cps; cpsc_t cpsc; @@ -1147,6 +1165,11 @@ array_tests(void) ok(sum_conf_array(&c[7], 1) == 7, "RPC sum_conf_array\n"); ok(sum_conf_array(&c[2], 0) == 0, "RPC sum_conf_array\n");
+ ok(sum_conf_ptr_by_conf_ptr(1, c2, c) == 45, "RPC sum_conf_ptr_by_conf_ptr"); + ok(sum_conf_ptr_by_conf_ptr(3, c2, c) == 345, "RPC sum_conf_ptr_by_conf_ptr"); + c2[0] = 0; + ok(sum_conf_ptr_by_conf_ptr(3, c2, c) == 300, "RPC sum_conf_ptr_by_conf_ptr"); + ok(sum_unique_conf_array(ca, 4) == -2, "RPC sum_unique_conf_array\n"); ok(sum_unique_conf_ptr(ca, 5) == 3, "RPC sum_unique_conf_array\n"); ok(sum_unique_conf_ptr(NULL, 10) == 0, "RPC sum_unique_conf_array\n"); diff --git a/dlls/rpcrt4/tests/server.idl b/dlls/rpcrt4/tests/server.idl index 53ec016..254551e 100644 --- a/dlls/rpcrt4/tests/server.idl +++ b/dlls/rpcrt4/tests/server.idl @@ -121,6 +121,7 @@ cpp_quote("#endif") int test_list_length(test_list_t *ls); int sum_fixed_int_3d(int m[2][3][4]); int sum_conf_array([size_is(n)] int x[], int n); + int sum_conf_ptr_by_conf_ptr(int n1, [size_is(n1)] int *n2_then_x1, [size_is(*n2_then_x1)] int *x2); int sum_unique_conf_array([size_is(n), unique] int x[], int n); int sum_unique_conf_ptr([size_is(n), unique] int *x, int n); int sum_var_array([length_is(n)] int x[20], int n); diff --git a/tools/widl/expr.c b/tools/widl/expr.c index 7f0e26d..7717da3 100644 --- a/tools/widl/expr.c +++ b/tools/widl/expr.c @@ -470,6 +470,9 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc result = resolve_expression(expr_loc, cont_type, e->ref); if (result.type && is_ptr(result.type)) result.type = type_pointer_get_ref(result.type); + else if(result.type && is_array(result.type) + && !result.type->declarray) + result.type = type_array_get_element(result.type); else error_loc_info(&expr_loc->v->loc_info, "dereference operator applied to non-pointer type in expression%s%s\n", expr_loc->attr ? " for attribute " : "",