Alexandre Julliard : widl: Support using custom handle types with the implicit_handle attribute.

Alexandre Julliard julliard at winehq.org
Tue May 31 13:08:18 CDT 2011


Module: wine
Branch: master
Commit: 21cbdaa1eb9cbd122037dcb3ad62d257dc2077c5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=21cbdaa1eb9cbd122037dcb3ad62d257dc2077c5

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue May 31 13:01:32 2011 +0200

widl: Support using custom handle types with the implicit_handle attribute.

---

 tools/widl/client.c |   14 +++++++-------
 tools/widl/header.c |    9 +++++++--
 tools/widl/parser.y |   13 ++++++++++++-
 3 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/tools/widl/client.c b/tools/widl/client.c
index aec379c..cf14c9c 100644
--- a/tools/widl/client.c
+++ b/tools/widl/client.c
@@ -75,7 +75,7 @@ static void check_pointers(const var_t *func)
 static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
 {
     const statement_t *stmt;
-    const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
+    const var_t *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
     int method_count = 0;
 
     if (!implicit_handle)
@@ -245,7 +245,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
         }
         else if (implicit_handle)
         {
-            print_client("__frame->_Handle = %s;\n", implicit_handle);
+            print_client("__frame->_Handle = %s;\n", implicit_handle->name);
             fprintf(client, "\n");
         }
 
@@ -334,7 +334,7 @@ static void write_stubdescdecl(type_t *iface)
 
 static void write_stubdescriptor(type_t *iface, int expr_eval_routines)
 {
-    const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
+    const var_t *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
 
     print_client("static const MIDL_STUB_DESC %s_StubDesc =\n", iface->name);
     print_client("{\n");
@@ -345,7 +345,7 @@ static void write_stubdescriptor(type_t *iface, int expr_eval_routines)
     print_client("{\n");
     indent++;
     if (implicit_handle)
-        print_client("&%s,\n", implicit_handle);
+        print_client("&%s,\n", implicit_handle->name);
     else
         print_client("&%s__MIDL_AutoBindHandle,\n", iface->name);
     indent--;
@@ -423,12 +423,12 @@ static void write_clientinterfacedecl(type_t *iface)
 
 static void write_implicithandledecl(type_t *iface)
 {
-    const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
+    const var_t *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
 
     if (implicit_handle)
     {
-        fprintf(client, "handle_t %s;\n", implicit_handle);
-        fprintf(client, "\n");
+        write_type_decl( client, implicit_handle->type, implicit_handle->name );
+        fprintf(client, ";\n\n");
     }
 }
 
diff --git a/tools/widl/header.c b/tools/widl/header.c
index 9df03cc..0ba9022 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -1078,14 +1078,19 @@ static void write_com_interface_end(FILE *header, type_t *iface)
 static void write_rpc_interface_start(FILE *header, const type_t *iface)
 {
   unsigned int ver = get_attrv(iface->attrs, ATTR_VERSION);
-  const char *var = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
+  const var_t *var = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
 
   fprintf(header, "/*****************************************************************************\n");
   fprintf(header, " * %s interface (v%d.%d)\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver));
   fprintf(header, " */\n");
   fprintf(header,"#ifndef __%s_INTERFACE_DEFINED__\n", iface->name);
   fprintf(header,"#define __%s_INTERFACE_DEFINED__\n\n", iface->name);
-  if (var) fprintf(header, "extern handle_t %s;\n", var);
+  if (var)
+  {
+      fprintf(header, "extern ");
+      write_type_decl( header, var->type, var->name );
+      fprintf(header, ";\n");
+  }
   if (old_names)
   {
       fprintf(header, "extern RPC_IF_HANDLE %s%s_ClientIfHandle;\n", prefix_client, iface->name);
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index 6f0cf8c..56d5a8b 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -522,7 +522,7 @@ attribute:					{ $$ = NULL; }
 	| tIGNORE				{ $$ = make_attr(ATTR_IGNORE); }
 	| tIIDIS '(' expr ')'			{ $$ = make_attrp(ATTR_IIDIS, $3); }
 	| tIMMEDIATEBIND			{ $$ = make_attr(ATTR_IMMEDIATEBIND); }
-	| tIMPLICITHANDLE '(' tHANDLET aIDENTIFIER ')'	{ $$ = make_attrp(ATTR_IMPLICIT_HANDLE, $4); }
+	| tIMPLICITHANDLE '(' arg ')'		{ $$ = make_attrp(ATTR_IMPLICIT_HANDLE, $3); }
 	| tIN					{ $$ = make_attr(ATTR_IN); }
 	| tINPUTSYNC				{ $$ = make_attr(ATTR_INPUTSYNC); }
 	| tLENGTHIS '(' m_exprs ')'		{ $$ = make_attrp(ATTR_LENGTHIS, $3); }
@@ -2124,6 +2124,17 @@ static attr_list_t *check_iface_attrs(const char *name, attr_list_t *attrs)
     if (!allowed_attr[attr->type].on_interface)
       error_loc("inapplicable attribute %s for interface %s\n",
                 allowed_attr[attr->type].display_name, name);
+    if (attr->type == ATTR_IMPLICIT_HANDLE)
+    {
+        const var_t *var = attr->u.pval;
+        if (type_get_type( var->type) == TYPE_BASIC &&
+            type_basic_get_type( var->type ) == TYPE_BASIC_HANDLE)
+            continue;
+        if (is_aliaschain_attr( var->type, ATTR_HANDLE ))
+            continue;
+      error_loc("attribute %s requires a handle type in interface %s\n",
+                allowed_attr[attr->type].display_name, name);
+    }
   }
   return attrs;
 }




More information about the wine-cvs mailing list