Commit c46fcfb3 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

widl: Automatically add "handle_t IDL_handle" parameter to functions with no…

widl: Automatically add "handle_t IDL_handle" parameter to functions with no explicit handle specified whose containing interface has the explicit_handle attribute.
parent c4ca32bb
......@@ -70,25 +70,10 @@ 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;
const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
int explicit_handle = is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE);
const var_t *var;
int method_count = 0;
......@@ -110,12 +95,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
{
explicit_generic_handle_var = get_explicit_generic_handle_var(func);
if (!explicit_generic_handle_var)
{
context_handle_var = get_context_handle_var(func);
if (!context_handle_var && explicit_handle)
/* FIXME: should use automatically added IDL_handle parameter */
error("explicit_handle attribute specified and %s() does not define an explicit binding handle - not implemented yet\n", def->name);
}
}
write_type_decl_left(client, get_func_return_type(func));
......
......@@ -618,6 +618,20 @@ const var_t* get_explicit_generic_handle_var(const func_t* func)
return NULL;
}
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;
}
int has_out_arg_or_return(const func_t *func)
{
const var_t *var;
......
......@@ -66,6 +66,7 @@ extern void write_generic_handle_routines(void);
extern const var_t* get_explicit_handle_var(const func_t* func);
extern const type_t* get_explicit_generic_handle_type(const var_t* var);
extern const var_t* get_explicit_generic_handle_var(const func_t* func);
extern const var_t* get_context_handle_var(const func_t* func);
extern int has_out_arg_or_return(const func_t *func);
extern void write_guid(FILE *f, const char *guid_prefix, const char *name,
const UUID *uuid);
......
......@@ -142,6 +142,7 @@ static attr_list_t *check_dispiface_attrs(const char *name, attr_list_t *attrs);
static const attr_list_t *check_module_attrs(const char *name, const attr_list_t *attrs);
static const attr_list_t *check_coclass_attrs(const char *name, const attr_list_t *attrs);
const char *get_attr_display_name(enum attr_type type);
static void add_explicit_handle_if_necessary(func_t *func);
#define tsENUM 1
#define tsSTRUCT 2
......@@ -2482,8 +2483,48 @@ static void check_remoting_args(const func_t *func)
}
}
static void add_explicit_handle_if_necessary(func_t *func)
{
const var_t* explicit_handle_var;
const var_t* explicit_generic_handle_var = NULL;
const var_t* context_handle_var = NULL;
/* check for a defined binding handle */
explicit_handle_var = get_explicit_handle_var(func);
if (!explicit_handle_var)
{
explicit_generic_handle_var = get_explicit_generic_handle_var(func);
if (!explicit_generic_handle_var)
{
context_handle_var = get_context_handle_var(func);
if (!context_handle_var)
{
/* no explicit handle specified so add
* "[in] handle_t IDL_handle" as the first parameter to the
* function */
var_t *idl_handle = make_var(xstrdup("IDL_handle"));
idl_handle->attrs = append_attr(NULL, make_attr(ATTR_IN));
idl_handle->type = find_type("handle_t", 0);
if (!func->def->type->fields_or_args)
{
func->def->type->fields_or_args = xmalloc( sizeof(*func->def->type->fields_or_args) );
list_init( func->def->type->fields_or_args );
}
list_add_head( func->def->type->fields_or_args, &idl_handle->entry );
func->args = func->def->type->fields_or_args;
}
}
}
}
static void check_functions(const type_t *iface)
{
if (is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE) && iface->funcs)
{
func_t *func;
LIST_FOR_EACH_ENTRY( func, iface->funcs, func_t, entry )
add_explicit_handle_if_necessary(func);
}
if (!is_inside_library && !is_attr(iface->attrs, ATTR_LOCAL))
{
const func_t *func;
......
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