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.
This commit is contained in:
Eric Kohl 2006-03-23 10:33:08 +01:00 committed by Alexandre Julliard
parent 9873494ced
commit 1550938a50
4 changed files with 76 additions and 60 deletions

View File

@ -1,7 +1,7 @@
/*
* 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");

View File

@ -1,7 +1,7 @@
/*
* 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");

View File

@ -1,7 +1,7 @@
/*
* 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)
{

View File

@ -1,7 +1,7 @@
/*
* 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);