Eric Kohl : widl: Write out argument lists in the server.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Dec 8 07:06:19 CST 2005
Module: wine
Branch: refs/heads/master
Commit: ba39a874d4c36d6a2e3b569164f00fe39f8438b0
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=ba39a874d4c36d6a2e3b569164f00fe39f8438b0
Author: Eric Kohl <eric.kohl at t-online.de>
Date: Thu Dec 8 12:48:44 2005 +0100
widl: Write out argument lists in the server.
- Add framework for updating proc offsets.
- Write out argument lists in the server.
---
tools/widl/client.c | 54 ++++++++++++++++++++++--------
tools/widl/server.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 130 insertions(+), 17 deletions(-)
diff --git a/tools/widl/client.c b/tools/widl/client.c
index c7d5d48..2523125 100644
--- a/tools/widl/client.c
+++ b/tools/widl/client.c
@@ -126,6 +126,7 @@ static void write_function_stubs(type_t
{
func_t *func = iface->funcs;
char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
+ var_t *var;
int method_count = 0;
unsigned int proc_offset = 0;
@@ -178,11 +179,16 @@ static void write_function_stubs(type_t
fprintf(client, "\n");
if (implicit_handle)
+ {
print_client("_Handle = %s;\n", implicit_handle);
+ fprintf(client, "\n");
+ }
+
+ /* emit the message buffer size */
+ print_client("_StubMsg.BufferLength =");
+ print_client("0"); /* FIXME */
+ fprintf(client, ";\n");
- /* FIXME: marshal arguments */
- print_client("_StubMsg.BufferLength = 0UL;\n");
- /* print_client("NdrNsGetBuffer(\n"); */
print_client("NdrGetBuffer(\n");
indent++;
print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");
@@ -206,11 +212,7 @@ static void write_function_stubs(type_t
indent--;
/* unmarshal return value */
- if (is_void(def->type, NULL))
- {
- proc_offset += 2;
- }
- else
+ if (!is_void(def->type, NULL))
{
fprintf(client, "\n");
@@ -219,17 +221,27 @@ static void write_function_stubs(type_t
print_client("NdrConvert(\n");
indent++;
print_client("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");
- print_client("(PFORMAT_STRING)&__MIDL_ProcFormatString[%u]);\n", proc_offset);
+ print_client("(PFORMAT_STRING)&__MIDL_ProcFormatString.Format[%u]);\n", proc_offset);
indent -= 2;
fprintf(client, "\n");
print_client("_RetVal = *((");
write_type(client, def->type, def, def->tname);
fprintf(client, " __RPC_FAR *)_StubMsg.Buffer)++;\n");
+ }
- /* FIXME: update proc_offset */
- proc_offset += 2;
+ /* update proc_offset */
+ if (func->args)
+ {
+ var = func->args;
+ while (NEXT_LINK(var)) var = NEXT_LINK(var);
+ while (var)
+ {
+ proc_offset += 2; /* FIXME */
+ var = PREV_LINK(var);
+ }
}
+ proc_offset += 2; /* FIXME */
indent--;
print_client("}\n");
@@ -358,6 +370,7 @@ static void write_formatdesc( const char
static void write_formatstringsdecl(type_t *iface)
{
func_t *func;
+ var_t *var;
int byte_count = 1;
print_client("#define TYPE_FORMAT_STRING_SIZE %d\n", 3); /* FIXME */
@@ -367,6 +380,19 @@ static void write_formatstringsdecl(type
while (NEXT_LINK(func)) func = NEXT_LINK(func);
while (func)
{
+ /* argument list size */
+ if (func->args)
+ {
+ var = func->args;
+ while (NEXT_LINK(var)) var = NEXT_LINK(var);
+ while (var)
+ {
+ byte_count += 2; /* FIXME: determine real size */
+ var = PREV_LINK(var);
+ }
+ }
+
+ /* return value size */
byte_count += 2; /* FIXME: determine real size */
func = PREV_LINK(func);
}
@@ -384,11 +410,11 @@ static void write_formatstringsdecl(type
static void write_implicithandledecl(type_t *iface)
{
- char *var = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
+ char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
- if (var)
+ if (implicit_handle)
{
- fprintf(client, "handle_t %s;\n", var);
+ fprintf(client, "handle_t %s;\n", implicit_handle);
fprintf(client, "\n");
}
}
diff --git a/tools/widl/server.c b/tools/widl/server.c
index 8629ef9..ee2a1c2 100644
--- a/tools/widl/server.c
+++ b/tools/widl/server.c
@@ -150,6 +150,9 @@ static unsigned int get_required_stack_s
static void write_function_stubs(type_t *iface)
{
func_t *func = iface->funcs;
+ var_t *var;
+ unsigned int proc_offset = 0;
+
while (NEXT_LINK(func)) func = NEXT_LINK(func);
while (func)
{
@@ -176,9 +179,28 @@ static void write_function_stubs(type_t
fprintf(server, " _RetVal;\n");
}
+ /* declare arguments */
+ if (func->args)
+ {
+ var = func->args;
+ while (NEXT_LINK(var)) var = NEXT_LINK(var);
+ while (var)
+ {
+ print_server("");
+ write_type(server, var->type, var, var->tname);
+ fprintf(server, " ");
+ write_name(server, var);
+ fprintf(server, ";\n");
+
+ var = PREV_LINK(var);
+ }
+ }
+
print_server("MIDL_STUB_MESSAGE _StubMsg;\n");
print_server("RPC_STATUS _Status;\n");
fprintf(server, "\n");
+
+
print_server("((void)(_Status));\n");
print_server("NdrServerInitializeNew(\n");
indent++;
@@ -194,6 +216,21 @@ static void write_function_stubs(type_t
print_server("RpcTryExcept\n");
print_server("{\n");
indent++;
+
+ if (func->args)
+ {
+ print_server("if ((_pRpcMessage->DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)\n");
+ indent++;
+ print_server("NdrConvert(\n");
+ indent++;
+ print_server("(PMIDL_STUB_MESSAGE)&_StubMsg,\n");
+ print_server("(PFORMAT_STRING)&__MIDL_ProcFormatString.Format[%u]);\n", proc_offset);
+ indent -= 2;
+ fprintf(server, "\n");
+
+ /* FIXME: unmarshall arguments */
+ }
+
print_server("if (_StubMsg.Buffer > _StubMsg.BufferEnd)\n");
print_server("{\n");
indent++;
@@ -219,10 +256,33 @@ static void write_function_stubs(type_t
print_server("");
write_name(server, def);
- /* FIXME: handle argument list */
- fprintf(server, "();\n");
+ if (func->args)
+ {
+ int first_arg = 1;
+
+ fprintf(server, "(\n");
+ indent++;
+ var = func->args;
+ while (NEXT_LINK(var)) var = NEXT_LINK(var);
+ while (var)
+ {
+ if (first_arg)
+ first_arg = 0;
+ else
+ fprintf(server, ",\n");
+ print_server("");
+ write_name(server, var);
+ var = PREV_LINK(var);
+ }
+ fprintf(server, ");\n");
+ indent--;
+ }
+ else
+ {
+ fprintf(server, "();\n");
+ }
- /* FIXME: Marshall the return value */
+ /* marshall the return value */
if (!is_void(def->type, NULL))
{
fprintf(server, "\n");
@@ -260,6 +320,19 @@ static void write_function_stubs(type_t
fprintf(server, "}\n");
fprintf(server, "\n");
+ /* update proc_offset */
+ if (func->args)
+ {
+ var = func->args;
+ while (NEXT_LINK(var)) var = NEXT_LINK(var);
+ while (var)
+ {
+ proc_offset += 2; /* FIXME */
+ var = PREV_LINK(var);
+ }
+ }
+ proc_offset += 2; /* FIXME */
+
func = PREV_LINK(func);
}
}
@@ -383,6 +456,7 @@ static void write_formatdesc( const char
static void write_formatstringsdecl(type_t *iface)
{
func_t *func;
+ var_t *var;
int byte_count = 1;
print_server("#define TYPE_FORMAT_STRING_SIZE %d\n", 3); /* FIXME */
@@ -392,6 +466,19 @@ static void write_formatstringsdecl(type
while (NEXT_LINK(func)) func = NEXT_LINK(func);
while (func)
{
+ /* argument list size */
+ if (func->args)
+ {
+ var = func->args;
+ while (NEXT_LINK(var)) var = NEXT_LINK(var);
+ while (var)
+ {
+ byte_count += 2; /* FIXME: determine real size */
+ var = PREV_LINK(var);
+ }
+ }
+
+ /* return value size */
byte_count += 2; /* FIXME: determine real size */
func = PREV_LINK(func);
}
More information about the wine-cvs
mailing list