Module: wine Branch: master Commit: b7e7243a1e5a4eb17c868246d075751fb1c1ac45 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=b7e7243a1e5a4eb17c868246...
Author: Dan Hipschman dsh@linux.ucla.edu Date: Wed Aug 16 18:01:56 2006 -0700
widl: Move format-string declaration output to typegen.c.
---
tools/widl/client.c | 33 +-------------------------------- tools/widl/server.c | 32 +------------------------------- tools/widl/typegen.c | 27 +++++++++++++++++++++++++++ tools/widl/typegen.h | 1 + 4 files changed, 30 insertions(+), 63 deletions(-)
diff --git a/tools/widl/client.c b/tools/widl/client.c index 267bbfe..3bc47b2 100644 --- a/tools/widl/client.c +++ b/tools/widl/client.c @@ -395,37 +395,6 @@ static void write_clientinterfacedecl(ty }
-static void write_formatdesc( const char *str ) -{ - print_client("typedef struct _MIDL_%s_FORMAT_STRING\n", str ); - print_client("{\n"); - indent++; - print_client("short Pad;\n"); - print_client("unsigned char Format[%s_FORMAT_STRING_SIZE];\n", str); - indent--; - print_client("} MIDL_%s_FORMAT_STRING;\n", str); - print_client("\n"); -} - - -static void write_formatstringsdecl(ifref_t *ifaces) -{ - print_client("#define TYPE_FORMAT_STRING_SIZE %d\n", - get_size_typeformatstring(ifaces)); - - print_client("#define PROC_FORMAT_STRING_SIZE %d\n", - get_size_procformatstring(ifaces)); - - fprintf(client, "\n"); - write_formatdesc("TYPE"); - write_formatdesc("PROC"); - fprintf(client, "\n"); - print_client("static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;\n"); - print_client("static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;\n"); - print_client("\n"); -} - - static void write_implicithandledecl(type_t *iface) { const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE); @@ -471,7 +440,7 @@ void write_client(ifref_t *ifaces) if (!client) return;
- write_formatstringsdecl(ifaces); + write_formatstringsdecl(client, indent, ifaces);
for (; iface; iface = PREV_LINK(iface)) { diff --git a/tools/widl/server.c b/tools/widl/server.c index 7a4aed9..69eddb8 100644 --- a/tools/widl/server.c +++ b/tools/widl/server.c @@ -550,36 +550,6 @@ static void write_serverinterfacedecl(ty fprintf(server, "\n"); }
-static void write_formatdesc( const char *str ) -{ - print_server("typedef struct _MIDL_%s_FORMAT_STRING\n", str ); - print_server("{\n"); - indent++; - print_server("short Pad;\n"); - print_server("unsigned char Format[%s_FORMAT_STRING_SIZE];\n", str); - indent--; - print_server("} MIDL_%s_FORMAT_STRING;\n", str); - print_server("\n"); -} - - -static void write_formatstringsdecl(ifref_t *ifaces) -{ - print_server("#define TYPE_FORMAT_STRING_SIZE %d\n", - get_size_typeformatstring(ifaces)); - - print_server("#define PROC_FORMAT_STRING_SIZE %d\n", - get_size_procformatstring(ifaces)); - - fprintf(server, "\n"); - write_formatdesc("TYPE"); - write_formatdesc("PROC"); - fprintf(server, "\n"); - print_server("static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;\n"); - print_server("static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;\n"); - print_server("\n"); -} -
static void init_server(void) { @@ -612,7 +582,7 @@ void write_server(ifref_t *ifaces) if (!server) return;
- write_formatstringsdecl(ifaces); + write_formatstringsdecl(server, indent, ifaces);
for (; iface; iface = PREV_LINK(iface)) { diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index 83af2eb..632bc8a 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -132,6 +132,33 @@ static int print_file(FILE *file, int in return r; }
+static void write_formatdesc(FILE *f, int indent, const char *str) +{ + print_file(f, indent, "typedef struct _MIDL_%s_FORMAT_STRING\n", str); + print_file(f, indent, "{\n"); + print_file(f, indent + 1, "short Pad;\n"); + print_file(f, indent + 1, "unsigned char Format[%s_FORMAT_STRING_SIZE];\n", str); + print_file(f, indent, "} MIDL_%s_FORMAT_STRING;\n", str); + print_file(f, indent, "\n"); +} + +void write_formatstringsdecl(FILE *f, int indent, ifref_t *ifaces) +{ + print_file(f, indent, "#define TYPE_FORMAT_STRING_SIZE %d\n", + get_size_typeformatstring(ifaces)); + + print_file(f, indent, "#define PROC_FORMAT_STRING_SIZE %d\n", + get_size_procformatstring(ifaces)); + + fprintf(f, "\n"); + write_formatdesc(f, indent, "TYPE"); + write_formatdesc(f, indent, "PROC"); + fprintf(f, "\n"); + print_file(f, indent, "static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;\n"); + print_file(f, indent, "static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;\n"); + print_file(f, indent, "\n"); +} + static inline int type_has_ref(const type_t *type) { return (type->type == 0 && type->ref); diff --git a/tools/widl/typegen.h b/tools/widl/typegen.h index eb4c4c7..4509032 100644 --- a/tools/widl/typegen.h +++ b/tools/widl/typegen.h @@ -35,6 +35,7 @@ enum remoting_phase PHASE_FREE };
+void write_formatstringsdecl(FILE *f, int indent, ifref_t *ifaces); void write_procformatstring(FILE *file, const ifref_t *ifaces); void write_typeformatstring(FILE *file, const ifref_t *ifaces); size_t get_type_memsize(const type_t *type);