From 435e36e3664ca5944965a62c8294bda1db756e38 Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Tue, 13 Dec 2005 11:22:08 +0100 Subject: [PATCH] widl: Start generating type format strings. Based on a patch by Eric Kohl. --- tools/widl/client.c | 2 +- tools/widl/server.c | 2 +- tools/widl/typegen.c | 62 +++++++++++++++++++++++++++++++++++++++++++- tools/widl/typegen.h | 2 +- 4 files changed, 64 insertions(+), 4 deletions(-) diff --git a/tools/widl/client.c b/tools/widl/client.c index 24bcda83749..e0c42959934 100644 --- a/tools/widl/client.c +++ b/tools/widl/client.c @@ -504,7 +504,7 @@ void write_client(ifref_t *ifaces) fprintf(client, "\n"); write_procformatstring(client, iface->iface); - write_typeformatstring(client); + write_typeformatstring(client, iface->iface); fprintf(client, "\n"); diff --git a/tools/widl/server.c b/tools/widl/server.c index d90fc8d5649..cb1099339d2 100644 --- a/tools/widl/server.c +++ b/tools/widl/server.c @@ -514,7 +514,7 @@ void write_server(ifref_t *ifaces) fprintf(server, "\n"); write_procformatstring(server, iface->iface); - write_typeformatstring(server); + write_typeformatstring(server, iface->iface); fprintf(server, "\n"); diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index 6cdff1f05be..32ac8e8393b 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -137,9 +137,52 @@ void write_procformatstring(FILE *file, type_t *iface) } -void write_typeformatstring(FILE *file) +static void write_typeformatstring_var(FILE *file, int indent, var_t *var) +{ + int ptr_level = var->ptr_level; + + /* basic types don't need a type format string */ + if (ptr_level == 0) + return; + + if (ptr_level == 1) + { + switch (var->type->type) + { +#define CASE_BASETYPE(fctype) \ + case RPC_##fctype: \ + print_file(file, indent, "0x11, 0x08, /* FC_RP [simple_pointer] */\n"); \ + print_file(file, indent, "0x%02x, /* " #fctype " */\n", var->type->type); \ + print_file(file, indent, "0x5c, /* FC_PAD */\n"); \ + break + CASE_BASETYPE(FC_BYTE); + CASE_BASETYPE(FC_CHAR); + CASE_BASETYPE(FC_SMALL); + CASE_BASETYPE(FC_USMALL); + CASE_BASETYPE(FC_WCHAR); + CASE_BASETYPE(FC_SHORT); + CASE_BASETYPE(FC_USHORT); + CASE_BASETYPE(FC_LONG); + CASE_BASETYPE(FC_ULONG); + CASE_BASETYPE(FC_FLOAT); + CASE_BASETYPE(FC_HYPER); + CASE_BASETYPE(FC_DOUBLE); + CASE_BASETYPE(FC_ENUM16); + CASE_BASETYPE(FC_ENUM32); + CASE_BASETYPE(FC_IGNORE); + CASE_BASETYPE(FC_ERROR_STATUS_T); + default: + error("write_typeformatstring_var: Unknown/unsupported type: %s (0x%02x)\n", var->name, var->type->type); + } + } +} + +void write_typeformatstring(FILE *file, type_t *iface) { int indent = 0; + func_t *func = iface->funcs; + var_t *var; + print_file(file, indent, "static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString =\n"); print_file(file, indent, "{\n"); indent++; @@ -147,6 +190,23 @@ void write_typeformatstring(FILE *file) print_file(file, indent, "{\n"); indent++; print_file(file, indent, "NdrFcShort(0x0),\n"); + + while (NEXT_LINK(func)) func = NEXT_LINK(func); + while (func) + { + if (func->args) + { + var = func->args; + while (NEXT_LINK(var)) var = NEXT_LINK(var); + while (var) + { + write_typeformatstring_var(file, indent, var); + var = PREV_LINK(var); + } + } + func = PREV_LINK(func); + } + print_file(file, indent, "0x0\n"); indent--; print_file(file, indent, "}\n"); diff --git a/tools/widl/typegen.h b/tools/widl/typegen.h index 5517c62116c..66701970dfb 100644 --- a/tools/widl/typegen.h +++ b/tools/widl/typegen.h @@ -21,7 +21,7 @@ void write_procformatstring(FILE *file, type_t *iface); -void write_typeformatstring(FILE *file); +void write_typeformatstring(FILE *file, type_t *iface); unsigned int get_required_buffer_size(type_t *type); void marshall_arguments(FILE *file, int indent, func_t *func); void unmarshall_arguments(FILE *file, int indent, func_t *func);