Commit 4194daf1 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

widl: Support using context handles as the binding handle in client functions.

parent 35d7f706
......@@ -70,6 +70,20 @@ static void check_pointers(const func_t *func)
}
}
const var_t* get_context_handle_var(const func_t* func)
{
const var_t* var;
if (!func->args)
return NULL;
LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry )
if (is_attr(var->attrs, ATTR_IN) && is_context_handle(var->type))
return var;
return NULL;
}
static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
{
const func_t *func;
......@@ -85,13 +99,16 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
{
const var_t *def = func->def;
const var_t* explicit_handle_var;
const var_t* context_handle_var = NULL;
int has_full_pointer = is_full_pointer_function(func);
/* check for a defined binding handle */
explicit_handle_var = get_explicit_handle_var(func);
if (!explicit_handle_var)
context_handle_var = get_context_handle_var(func);
if (explicit_handle)
{
if (!explicit_handle_var)
if (!explicit_handle_var || !context_handle_var)
{
error("%s() does not define an explicit binding handle!\n", def->name);
return;
......@@ -131,7 +148,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
fprintf(client, " _RetVal;\n");
}
if (implicit_handle || explicit_handle_var)
if (implicit_handle || explicit_handle_var || context_handle_var)
print_client("RPC_BINDING_HANDLE _Handle = 0;\n");
print_client("RPC_MESSAGE _RpcMessage;\n");
......@@ -172,6 +189,13 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
print_client("_Handle = %s;\n", explicit_handle_var->name);
fprintf(client, "\n");
}
else if (context_handle_var)
{
print_client("if (%s%s != 0)\n", is_ptr(context_handle_var->type) ? "*" : "", context_handle_var->name);
indent++;
print_client("_Handle = NDRCContextBinding(%s%s);\n", is_ptr(context_handle_var->type) ? "*" : "", context_handle_var->name);
indent--;
}
write_remoting_arguments(client, indent, func, PASS_IN, PHASE_BUFFERSIZE);
......@@ -179,7 +203,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
indent++;
print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");
print_client("_StubMsg.BufferLength,\n");
if (implicit_handle || explicit_handle_var)
if (implicit_handle || explicit_handle_var || context_handle_var)
print_client("_Handle);\n");
else
print_client("%s__MIDL_AutoBindHandle);\n", iface->name);
......
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