Commit 1550938a authored by Eric Kohl's avatar Eric Kohl Committed by Alexandre Julliard

widl: Fix format string size calculation.

- Move proc format string size calculation from client.c and server.c to typegen.c. - Implement type format string size calculation.
parent 9873494c
/*
* IDL Compiler
*
* Copyright 2005 Eric Kohl
* Copyright 2005-2006 Eric Kohl
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -384,35 +384,11 @@ static void write_formatdesc( const char *str )
static void write_formatstringsdecl(type_t *iface)
{
int byte_count = 1;
print_client("#define TYPE_FORMAT_STRING_SIZE %d\n",
get_size_typeformatstring(iface));
print_client("#define TYPE_FORMAT_STRING_SIZE %d\n", 3); /* FIXME */
/* determine the proc format string size */
if (iface->funcs)
{
func_t *func = iface->funcs;
while (NEXT_LINK(func)) func = NEXT_LINK(func);
while (func)
{
/* argument list size */
if (func->args)
{
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);
}
}
print_client("#define PROC_FORMAT_STRING_SIZE %d\n", byte_count);
print_client("#define PROC_FORMAT_STRING_SIZE %d\n",
get_size_procformatstring(iface));
fprintf(client, "\n");
write_formatdesc("TYPE");
......
/*
* IDL Compiler
*
* Copyright 2005 Eric Kohl
* Copyright 2005-2006 Eric Kohl
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -472,35 +472,11 @@ static void write_formatdesc( const char *str )
static void write_formatstringsdecl(type_t *iface)
{
int byte_count = 1;
print_server("#define TYPE_FORMAT_STRING_SIZE %d\n",
get_size_typeformatstring(iface));
print_server("#define TYPE_FORMAT_STRING_SIZE %d\n", 3); /* FIXME */
/* determine the proc format string size */
if (iface->funcs)
{
func_t *func = iface->funcs;
while (NEXT_LINK(func)) func = NEXT_LINK(func);
while (func)
{
/* argument list size */
if (func->args)
{
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);
}
}
print_server("#define PROC_FORMAT_STRING_SIZE %d\n", byte_count);
print_server("#define PROC_FORMAT_STRING_SIZE %d\n",
get_size_procformatstring(iface));
fprintf(server, "\n");
write_formatdesc("TYPE");
......
/*
* Format String Generator for IDL Compiler
*
* Copyright 2005 Eric Kohl
* Copyright 2005-2006 Eric Kohl
* Copyright 2005-2006 Robert Shearman
*
* This library is free software; you can redistribute it and/or
......@@ -1591,6 +1591,68 @@ size_t get_size_typeformatstring_var(const var_t *var)
return type_offset;
}
size_t get_size_procformatstring(const type_t *iface)
{
size_t size = 1;
func_t *func;
var_t *var;
if (iface->funcs)
{
func = iface->funcs;
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)
{
size += get_size_procformatstring_var(var);
var = PREV_LINK(var);
}
}
/* return value size */
size += 2; /* FIXME: determine real size */
func = PREV_LINK(func);
}
}
return size;
}
size_t get_size_typeformatstring(const type_t *iface)
{
size_t size = 3;
func_t *func;
var_t *var;
if (iface->funcs)
{
func = iface->funcs;
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)
{
size += get_size_typeformatstring_var(var);
var = PREV_LINK(var);
}
}
func = PREV_LINK(func);
}
}
return size;
}
static void write_struct_expr(FILE *h, const expr_t *e, int brackets,
const var_t *fields, const char *structvar)
{
......
/*
* Format String Generator for IDL Compiler
*
* Copyright 2005 Eric Kohl
* Copyright 2005-2006 Eric Kohl
* Copyright 2005 Robert Shearman
*
* This library is free software; you can redistribute it and/or
......@@ -41,5 +41,7 @@ unsigned int get_required_buffer_size(const var_t *var, unsigned int *alignment)
void write_remoting_arguments(FILE *file, int indent, const func_t *func, unsigned int *type_offset, enum pass pass, enum remoting_phase phase);
size_t get_size_procformatstring_var(const var_t *var);
size_t get_size_typeformatstring_var(const var_t *var);
size_t get_size_procformatstring(const type_t *iface);
size_t get_size_typeformatstring(const type_t *iface);
int write_expr_eval_routines(FILE *file, const char *iface);
void write_expr_eval_routine_list(FILE *file, const char *iface);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment