widl: Fix SEGVs with client and server code generation when an

interface has no methods.
This commit is contained in:
Robert Shearman 2005-12-26 13:08:51 +01:00 committed by Alexandre Julliard
parent 73a25d316d
commit 86c3a2e76a
3 changed files with 92 additions and 81 deletions

View File

@ -403,32 +403,33 @@ 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 */
/* determine the proc format string size */
func = iface->funcs;
while (NEXT_LINK(func)) func = NEXT_LINK(func);
while (func)
if (iface->funcs)
{
/* argument list size */
if (func->args)
func_t *func = iface->funcs;
while (NEXT_LINK(func)) func = NEXT_LINK(func);
while (func)
{
var = func->args;
while (NEXT_LINK(var)) var = NEXT_LINK(var);
while (var)
/* argument list size */
if (func->args)
{
byte_count += 2; /* FIXME: determine real size */
var = PREV_LINK(var);
var_t *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);
}
/* return value size */
byte_count += 2; /* FIXME: determine real size */
func = PREV_LINK(func);
}
print_client("#define PROC_FORMAT_STRING_SIZE %d\n", byte_count);
@ -492,15 +493,18 @@ void write_client(ifref_t *ifaces)
fprintf(client, " */\n");
fprintf(client, "\n");
write_formatstringsdecl(iface->iface);
write_implicithandledecl(iface->iface);
write_clientinterfacedecl(iface->iface);
write_stubdescdecl(iface->iface);
write_bindinghandledecl(iface->iface);
write_function_stubs(iface->iface);
write_stubdescriptor(iface->iface);
if (iface->iface->funcs)
{
write_formatstringsdecl(iface->iface);
write_implicithandledecl(iface->iface);
write_clientinterfacedecl(iface->iface);
write_stubdescdecl(iface->iface);
write_bindinghandledecl(iface->iface);
write_function_stubs(iface->iface);
write_stubdescriptor(iface->iface);
}
print_client("#if !defined(__RPC_WIN32__)\n");
print_client("#error Invalid build platform for this stub.\n");

View File

@ -428,32 +428,33 @@ 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 */
/* determine the proc format string size */
func = iface->funcs;
while (NEXT_LINK(func)) func = NEXT_LINK(func);
while (func)
if (iface->funcs)
{
/* argument list size */
if (func->args)
func_t *func = iface->funcs;
while (NEXT_LINK(func)) func = NEXT_LINK(func);
while (func)
{
var = func->args;
while (NEXT_LINK(var)) var = NEXT_LINK(var);
while (var)
/* argument list size */
if (func->args)
{
byte_count += 2; /* FIXME: determine real size */
var = PREV_LINK(var);
var_t *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);
}
/* return value size */
byte_count += 2; /* FIXME: determine real size */
func = PREV_LINK(func);
}
print_server("#define PROC_FORMAT_STRING_SIZE %d\n", byte_count);
@ -503,14 +504,17 @@ void write_server(ifref_t *ifaces)
fprintf(server, " */\n");
fprintf(server, "\n");
write_formatstringsdecl(iface->iface);
write_serverinterfacedecl(iface->iface);
write_stubdescdecl(iface->iface);
write_function_stubs(iface->iface);
write_stubdescriptor(iface->iface);
write_dispatchtable(iface->iface);
if (iface->iface->funcs)
{
write_formatstringsdecl(iface->iface);
write_serverinterfacedecl(iface->iface);
write_stubdescdecl(iface->iface);
write_function_stubs(iface->iface);
write_stubdescriptor(iface->iface);
write_dispatchtable(iface->iface);
}
print_server("#if !defined(__RPC_WIN32__)\n");
print_server("#error Invalid build platform for this stub.\n");

View File

@ -119,7 +119,6 @@ static size_t write_procformatstring_var(FILE *file, int indent, var_t *var, int
void write_procformatstring(FILE *file, type_t *iface)
{
int indent = 0;
func_t *func = iface->funcs;
var_t *var;
unsigned int type_offset = 2;
@ -130,32 +129,34 @@ void write_procformatstring(FILE *file, type_t *iface)
print_file(file, indent, "{\n");
indent++;
while (NEXT_LINK(func)) func = NEXT_LINK(func);
while (func)
if (iface->funcs)
{
/* emit argument data */
if (func->args)
func_t *func = iface->funcs;
while (NEXT_LINK(func)) func = NEXT_LINK(func);
for (; func; func = PREV_LINK(func))
{
var = func->args;
while (NEXT_LINK(var)) var = NEXT_LINK(var);
while (var)
/* emit argument data */
if (func->args)
{
write_procformatstring_var(file, indent, var, FALSE, &type_offset);
var = PREV_LINK(var);
var = func->args;
while (NEXT_LINK(var)) var = NEXT_LINK(var);
while (var)
{
write_procformatstring_var(file, indent, var, FALSE, &type_offset);
var = PREV_LINK(var);
}
}
/* emit return value data */
var = func->def;
if (is_void(var->type, NULL))
{
print_file(file, indent, "0x5b, /* FC_END */\n");
print_file(file, indent, "0x5c, /* FC_PAD */\n");
}
else
write_procformatstring_var(file, indent, var, TRUE, &type_offset);
}
/* emit return value data */
var = func->def;
if (is_void(var->type, NULL))
{
print_file(file, indent, "0x5b, /* FC_END */\n");
print_file(file, indent, "0x5c, /* FC_PAD */\n");
}
else
write_procformatstring_var(file, indent, var, TRUE, &type_offset);
func = PREV_LINK(func);
}
print_file(file, indent, "0x0\n");
@ -214,7 +215,6 @@ static size_t write_typeformatstring_var(FILE *file, int indent, var_t *var)
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");
@ -225,20 +225,23 @@ void write_typeformatstring(FILE *file, type_t *iface)
indent++;
print_file(file, indent, "NdrFcShort(0x0),\n");
while (NEXT_LINK(func)) func = NEXT_LINK(func);
while (func)
if (iface->funcs)
{
if (func->args)
func_t *func = iface->funcs;
while (NEXT_LINK(func)) func = NEXT_LINK(func);
for (; func; func = PREV_LINK(func))
{
var = func->args;
while (NEXT_LINK(var)) var = NEXT_LINK(var);
while (var)
if (func->args)
{
write_typeformatstring_var(file, indent, var);
var = PREV_LINK(var);
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");