From f4a96193645ac2af81ab4ee7d6033e1426a37897 Mon Sep 17 00:00:00 2001 From: Rob Shearman Date: Thu, 27 Mar 2008 14:03:23 +0000 Subject: [PATCH] widl: Fix detection of non-pointer context handles. is_ptr cannot be used because it follows the chain of types into the type which has the context_handle attribute, which is typically "void *" and so causes these context handles to be incorrectly detected as context handles. Instead, we can use is_aliaschain_ptr to follow the chain of aliases without following pointers and the absence of the context_handle attribute indicates that it must be present on a type after following a pointer. --- tools/widl/client.c | 8 ++++++-- tools/widl/server.c | 6 +++++- tools/widl/typegen.c | 6 +++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tools/widl/client.c b/tools/widl/client.c index 47fb25d3583..7f2a8064648 100644 --- a/tools/widl/client.c +++ b/tools/widl/client.c @@ -203,9 +203,13 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) } else if (context_handle_var) { - print_client("if (%s%s != 0)\n", is_ptr(context_handle_var->type) ? "*" : "", context_handle_var->name); + /* if the context_handle attribute appears in the chain of types + * without pointers being followed, then the context handle must + * be direct, otherwise it is a pointer */ + int is_ch_ptr = is_aliaschain_attr(context_handle_var->type, ATTR_CONTEXTHANDLE) ? FALSE : TRUE; + print_client("if (%s%s != 0)\n", is_ch_ptr ? "*" : "", context_handle_var->name); indent++; - print_client("_Handle = NDRCContextBinding(%s%s);\n", is_ptr(context_handle_var->type) ? "*" : "", context_handle_var->name); + print_client("_Handle = NDRCContextBinding(%s%s);\n", is_ch_ptr ? "*" : "", context_handle_var->name); indent--; fprintf(client, "\n"); } diff --git a/tools/widl/server.c b/tools/widl/server.c index 820339639fd..a81c602baeb 100644 --- a/tools/widl/server.c +++ b/tools/widl/server.c @@ -184,9 +184,13 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) fprintf(server, ",\n"); if (is_context_handle(var->type)) { + /* if the context_handle attribute appears in the chain of types + * without pointers being followed, then the context handle must + * be direct, otherwise it is a pointer */ + int is_ch_ptr = is_aliaschain_attr(var->type, ATTR_CONTEXTHANDLE) ? FALSE : TRUE; print_server("("); write_type_decl_left(server, var->type); - fprintf(server, ")%sNDRSContextValue(%s)", is_ptr(var->type) ? "" : "*", var->name); + fprintf(server, ")%sNDRSContextValue(%s)", is_ch_ptr ? "" : "*", var->name); } else { diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index 4e5782b7922..0c53153a93d 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -2778,9 +2778,13 @@ static void write_remoting_arg(FILE *file, int indent, const func_t *func, { if (pass == PASS_IN) { + /* if the context_handle attribute appears in the chain of types + * without pointers being followed, then the context handle must + * be direct, otherwise it is a pointer */ + int is_ch_ptr = is_aliaschain_attr(type, ATTR_CONTEXTHANDLE) ? FALSE : TRUE; print_file(file, indent, "NdrClientContextMarshall(\n"); print_file(file, indent + 1, "&_StubMsg,\n"); - print_file(file, indent + 1, "(NDR_CCONTEXT)%s%s,\n", is_ptr(type) ? "*" : "", var->name); + print_file(file, indent + 1, "(NDR_CCONTEXT)%s%s,\n", is_ch_ptr ? "*" : "", var->name); print_file(file, indent + 1, "%s);\n", in_attr && out_attr ? "1" : "0"); } else