Commit 6655071a authored by Alexandre Julliard's avatar Alexandre Julliard

widl: Move initialization of the stub buffer size into write_remoting_arguments().

parent 85ed9ca3
......@@ -59,24 +59,6 @@ static int print_client( const char *format, ... )
}
static void print_message_buffer_size(const func_t *func)
{
unsigned int total_size = 0;
if (func->args)
{
const var_t *var;
LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry )
{
unsigned int alignment;
total_size += get_required_buffer_size(var, &alignment, PASS_IN);
total_size += alignment;
}
}
fprintf(client, " %u", total_size);
}
static void check_pointers(const func_t *func)
{
const var_t *var;
......@@ -189,11 +171,6 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset, unsig
fprintf(client, "\n");
}
/* emit the message buffer size */
print_client("_StubMsg.BufferLength =");
print_message_buffer_size(func);
fprintf(client, ";\n");
type_offset_func = *type_offset;
write_remoting_arguments(client, indent, func, &type_offset_func, PASS_IN, PHASE_BUFFERSIZE);
......
......@@ -88,7 +88,6 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset, unsig
LIST_FOR_EACH_ENTRY( func, iface->funcs, const func_t, entry )
{
const var_t *def = func->def;
unsigned long buffer_size = 0;
unsigned int type_offset_func;
/* check for a defined binding handle */
......@@ -222,31 +221,8 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset, unsig
fprintf(server, "();\n");
}
if (func->args)
{
LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry )
{
if (is_attr(var->attrs, ATTR_OUT))
{
unsigned int alignment;
buffer_size += get_required_buffer_size(var, &alignment, PASS_OUT);
buffer_size += alignment;
}
}
}
if (!is_void(def->type, NULL))
{
unsigned int alignment;
buffer_size += get_required_buffer_size(def, &alignment, PASS_RETURN);
buffer_size += alignment;
}
if (has_out_arg_or_return(func))
{
fprintf(server, "\n");
print_server("_StubMsg.BufferLength = %u;\n", buffer_size);
type_offset_func = *type_offset;
write_remoting_arguments(server, indent, func, &type_offset_func, PASS_OUT, PHASE_BUFFERSIZE);
......
......@@ -1551,7 +1551,7 @@ static unsigned int get_required_buffer_size_type(
return 0;
}
unsigned int get_required_buffer_size(const var_t *var, unsigned int *alignment, enum pass pass)
static unsigned int get_required_buffer_size(const var_t *var, unsigned int *alignment, enum pass pass)
{
expr_t *size_is = get_attrp(var->attrs, ATTR_SIZEIS);
int has_size = (size_is && (size_is->type != EXPR_VOID));
......@@ -1621,6 +1621,28 @@ unsigned int get_required_buffer_size(const var_t *var, unsigned int *alignment,
}
}
static unsigned int get_function_buffer_size( const func_t *func, enum pass pass )
{
const var_t *var;
unsigned int total_size = 0, alignment;
if (func->args)
{
LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry )
{
total_size += get_required_buffer_size(var, &alignment, pass);
total_size += alignment;
}
}
if (pass == PASS_OUT && !is_void(func->def->type, NULL))
{
total_size += get_required_buffer_size(func->def, &alignment, PASS_RETURN);
total_size += alignment;
}
return total_size;
}
static void print_phase_function(FILE *file, int indent, const char *type,
enum remoting_phase phase,
const char *varname, unsigned int type_offset)
......@@ -1767,6 +1789,12 @@ void write_remoting_arguments(FILE *file, int indent, const func_t *func,
if (!func->args)
return;
if (phase == PHASE_BUFFERSIZE)
{
unsigned int size = get_function_buffer_size( func, pass );
print_file(file, indent, "_StubMsg.BufferLength = %u;\n", size);
}
LIST_FOR_EACH_ENTRY( var, func->args, const var_t, entry )
{
const type_t *type = var->type;
......
......@@ -39,7 +39,6 @@ void write_formatstringsdecl(FILE *f, int indent, ifref_list_t *ifaces, int for_
void write_procformatstring(FILE *file, const ifref_list_t *ifaces, int for_objects);
void write_typeformatstring(FILE *file, const ifref_list_t *ifaces, int for_objects);
size_t get_type_memsize(const type_t *type);
unsigned int get_required_buffer_size(const var_t *var, unsigned int *alignment, enum pass pass);
void print_phase_basetype(FILE *file, int indent, enum remoting_phase phase, enum pass pass, const var_t *var, const char *varname);
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);
......
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