Rob Shearman : widl: Remove some confusion in how version numbers are packed into an attribute by defining some macros for this purpose .

Alexandre Julliard julliard at winehq.org
Wed Dec 12 09:29:24 CST 2007


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

Author: Rob Shearman <rob at codeweavers.com>
Date:   Wed Dec 12 14:49:34 2007 +0000

widl: Remove some confusion in how version numbers are packed into an attribute by defining some macros for this purpose.

Remove unneeded includes.

---

 tools/widl/client.c  |    8 ++------
 tools/widl/header.c  |    9 ++++-----
 tools/widl/parser.y  |    6 ++----
 tools/widl/server.c  |   13 +++++--------
 tools/widl/typegen.c |    1 -
 tools/widl/utils.h   |    4 ++++
 6 files changed, 17 insertions(+), 24 deletions(-)

diff --git a/tools/widl/client.c b/tools/widl/client.c
index 9d09671..5cd2a81 100644
--- a/tools/widl/client.c
+++ b/tools/widl/client.c
@@ -29,16 +29,12 @@
 #include <ctype.h>
 #include <signal.h>
 
-#include "windef.h"
-
 #include "widl.h"
 #include "utils.h"
 #include "parser.h"
 #include "header.h"
 
 #include "widltypes.h"
-#include "typelib.h"
-#include "typelib_struct.h"
 #include "typegen.h"
 
 static FILE* client;
@@ -337,7 +333,7 @@ static void write_clientinterfacedecl(type_t *iface)
     print_client("{{0x%08lx,0x%04x,0x%04x,{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x}},{%d,%d}},\n",
                  uuid->Data1, uuid->Data2, uuid->Data3, uuid->Data4[0], uuid->Data4[1],
                  uuid->Data4[2], uuid->Data4[3], uuid->Data4[4], uuid->Data4[5], uuid->Data4[6],
-                 uuid->Data4[7], LOWORD(ver), HIWORD(ver));
+                 uuid->Data4[7], MAJORVERSION(ver), MINORVERSION(ver));
     print_client("{{0x8a885d04,0x1ceb,0x11c9,{0x9f,0xe8,0x08,0x00,0x2b,0x10,0x48,0x60}},{2,0}},\n"); /* FIXME */
     print_client("0,\n");
     if (endpoints)
@@ -360,7 +356,7 @@ static void write_clientinterfacedecl(type_t *iface)
                      iface->name, iface->name);
     else
         print_client("RPC_IF_HANDLE %s%s_v%d_%d_c_ifspec = (RPC_IF_HANDLE)& %s___RpcClientInterface;\n",
-                     prefix_client, iface->name, LOWORD(ver), HIWORD(ver), iface->name);
+                     prefix_client, iface->name, MAJORVERSION(ver), MINORVERSION(ver), iface->name);
     fprintf(client, "\n");
 }
 
diff --git a/tools/widl/header.c b/tools/widl/header.c
index 16bf82b..fd89534 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -31,7 +31,6 @@
 #include <ctype.h>
 #include <signal.h>
 
-#include "windef.h"
 #include "widl.h"
 #include "utils.h"
 #include "parser.h"
@@ -942,7 +941,7 @@ static void write_com_interface(type_t *iface)
 
 static void write_rpc_interface(const type_t *iface)
 {
-  unsigned long ver = get_attrv(iface->attrs, ATTR_VERSION);
+  unsigned int ver = get_attrv(iface->attrs, ATTR_VERSION);
   const char *var = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
   static int allocate_written = 0;
 
@@ -954,7 +953,7 @@ static void write_rpc_interface(const type_t *iface)
   }
 
   fprintf(header, "/*****************************************************************************\n");
-  fprintf(header, " * %s interface (v%d.%d)\n", iface->name, LOWORD(ver), HIWORD(ver));
+  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);
@@ -970,9 +969,9 @@ static void write_rpc_interface(const type_t *iface)
     else
     {
         fprintf(header, "extern RPC_IF_HANDLE %s%s_v%d_%d_c_ifspec;\n",
-                prefix_client, iface->name, LOWORD(ver), HIWORD(ver));
+                prefix_client, iface->name, MAJORVERSION(ver), MINORVERSION(ver));
         fprintf(header, "extern RPC_IF_HANDLE %s%s_v%d_%d_s_ifspec;\n",
-                prefix_server, iface->name, LOWORD(ver), HIWORD(ver));
+                prefix_server, iface->name, MAJORVERSION(ver), MINORVERSION(ver));
     }
     write_function_protos(iface);
   }
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index 0a8af54..6c8337e 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -31,8 +31,6 @@
 #include <alloca.h>
 #endif
 
-#include "windef.h"
-
 #include "widl.h"
 #include "utils.h"
 #include "parser.h"
@@ -929,8 +927,8 @@ uniondef: tUNION t_ident '{' fields '}'		{ $$ = get_typev(RPC_FC_NON_ENCAPSULATE
 	;
 
 version:
-	  aNUM					{ $$ = MAKELONG($1, 0); }
-	| aNUM '.' aNUM				{ $$ = MAKELONG($1, $3); }
+	  aNUM					{ $$ = MAKEVERSION($1, 0); }
+	| aNUM '.' aNUM				{ $$ = MAKEVERSION($1, $3); }
 	;
 
 %%
diff --git a/tools/widl/server.c b/tools/widl/server.c
index f020613..e2c3ac9 100644
--- a/tools/widl/server.c
+++ b/tools/widl/server.c
@@ -35,10 +35,7 @@
 #include "utils.h"
 #include "parser.h"
 #include "header.h"
-#include "windef.h"
 
-#include "typelib.h"
-#include "typelib_struct.h"
 #include "typegen.h"
 
 static FILE* server;
@@ -285,7 +282,7 @@ static void write_dispatchtable(type_t *iface)
     print_server("0\n");
     indent--;
     print_server("};\n");
-    print_server("RPC_DISPATCH_TABLE %s_v%d_%d_DispatchTable =\n", iface->name, LOWORD(ver), HIWORD(ver));
+    print_server("RPC_DISPATCH_TABLE %s_v%d_%d_DispatchTable =\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver));
     print_server("{\n");
     indent++;
     print_server("%u,\n", method_count);
@@ -349,7 +346,7 @@ static void write_serverinterfacedecl(type_t *iface)
 
     if (endpoints) write_endpoints( server, iface->name, endpoints );
 
-    print_server("extern RPC_DISPATCH_TABLE %s_v%d_%d_DispatchTable;\n", iface->name, LOWORD(ver), HIWORD(ver));
+    print_server("extern RPC_DISPATCH_TABLE %s_v%d_%d_DispatchTable;\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver));
     fprintf(server, "\n");
     print_server("static const RPC_SERVER_INTERFACE %s___RpcServerInterface =\n", iface->name );
     print_server("{\n");
@@ -358,9 +355,9 @@ static void write_serverinterfacedecl(type_t *iface)
     print_server("{{0x%08lx,0x%04x,0x%04x,{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x}},{%d,%d}},\n",
                  uuid->Data1, uuid->Data2, uuid->Data3, uuid->Data4[0], uuid->Data4[1],
                  uuid->Data4[2], uuid->Data4[3], uuid->Data4[4], uuid->Data4[5], uuid->Data4[6],
-                 uuid->Data4[7], LOWORD(ver), HIWORD(ver));
+                 uuid->Data4[7], MAJORVERSION(ver), MINORVERSION(ver));
     print_server("{{0x8a885d04,0x1ceb,0x11c9,{0x9f,0xe8,0x08,0x00,0x2b,0x10,0x48,0x60}},{2,0}},\n"); /* FIXME */
-    print_server("&%s_v%d_%d_DispatchTable,\n", iface->name, LOWORD(ver), HIWORD(ver));
+    print_server("&%s_v%d_%d_DispatchTable,\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver));
     if (endpoints)
     {
         print_server("%u,\n", list_count(endpoints));
@@ -381,7 +378,7 @@ static void write_serverinterfacedecl(type_t *iface)
                      iface->name, iface->name);
     else
         print_server("RPC_IF_HANDLE %s%s_v%d_%d_s_ifspec = (RPC_IF_HANDLE)& %s___RpcServerInterface;\n",
-                     prefix_server, iface->name, LOWORD(ver), HIWORD(ver), iface->name);
+                     prefix_server, iface->name, MAJORVERSION(ver), MINORVERSION(ver), iface->name);
     fprintf(server, "\n");
 }
 
diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index b293b1a..3bb88da 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -37,7 +37,6 @@
 #include "utils.h"
 #include "parser.h"
 #include "header.h"
-#include "windef.h"
 #include "wine/list.h"
 
 #include "typegen.h"
diff --git a/tools/widl/utils.h b/tools/widl/utils.h
index c9cc2ba..1cd3dd3 100644
--- a/tools/widl/utils.h
+++ b/tools/widl/utils.h
@@ -46,4 +46,8 @@ size_t widl_getline(char **linep, size_t *lenp, FILE *fp);
 UUID *parse_uuid(const char *u);
 int is_valid_uuid(const char *s);
 
+#define MAKEVERSION(major, minor) ((((major) & 0xffff) << 16) | ((minor) & 0xffff))
+#define MAJORVERSION(version) (((version) >> 16) & 0xffff)
+#define MINORVERSION(version) ((version) & 0xffff)
+
 #endif




More information about the wine-cvs mailing list