widl: Write out argument lists in the server.

- Add framework for updating proc offsets.
- Write out argument lists in the server.
This commit is contained in:
Eric Kohl 2005-12-08 12:48:44 +01:00 committed by Alexandre Julliard
parent 80e262202f
commit ba39a874d4
2 changed files with 131 additions and 18 deletions

View File

@ -126,6 +126,7 @@ static void write_function_stubs(type_t *iface)
{
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 *iface)
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 *iface)
indent--;
/* unmarshal return value */
if (is_void(def->type, NULL))
{
proc_offset += 2;
}
else
if (!is_void(def->type, NULL))
{
fprintf(client, "\n");
@ -219,18 +221,28 @@ static void write_function_stubs(type_t *iface)
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");
print_client("RpcFinally\n");
@ -358,6 +370,7 @@ static void write_formatdesc( const char *str )
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_t *iface)
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_t *iface)
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");
}
}

View File

@ -150,6 +150,9 @@ static unsigned int get_required_stack_size(type_t *type)
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 *iface)
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 *iface)
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 *iface)
print_server("");
write_name(server, def);
/* FIXME: handle argument list */
fprintf(server, "();\n");
if (func->args)
{
int first_arg = 1;
/* FIXME: Marshall the return value */
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");
}
/* marshall the return value */
if (!is_void(def->type, NULL))
{
fprintf(server, "\n");
@ -260,6 +320,19 @@ static void write_function_stubs(type_t *iface)
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 *str )
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_t *iface)
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);
}