Rob Shearman : widl: Automatically add "handle_t IDL_handle" parameter to functions with no explicit handle specified whose containing interface has the explicit_handle attribute .
Alexandre Julliard
julliard at winehq.org
Mon Apr 21 07:46:17 CDT 2008
Module: wine
Branch: master
Commit: c46fcfb356b31431cc34de1f9c6a7599db317abd
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c46fcfb356b31431cc34de1f9c6a7599db317abd
Author: Rob Shearman <rob at codeweavers.com>
Date: Sun Apr 20 22:15:29 2008 +0100
widl: Automatically add "handle_t IDL_handle" parameter to functions with no explicit handle specified whose containing interface has the explicit_handle attribute.
---
tools/widl/client.c | 20 --------------------
tools/widl/header.c | 14 ++++++++++++++
tools/widl/header.h | 1 +
tools/widl/parser.y | 41 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 56 insertions(+), 20 deletions(-)
diff --git a/tools/widl/client.c b/tools/widl/client.c
index b3f89a7..d15dfdc 100644
--- a/tools/widl/client.c
+++ b/tools/widl/client.c
@@ -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));
diff --git a/tools/widl/header.c b/tools/widl/header.c
index 8668ce9..3c89d61 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -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;
diff --git a/tools/widl/header.h b/tools/widl/header.h
index 3f4fee2..e8fdbc9 100644
--- a/tools/widl/header.h
+++ b/tools/widl/header.h
@@ -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);
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index 4d04546..6f5dbdd 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -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;
More information about the wine-cvs
mailing list