Commit 942ec30a authored by Alexandre Julliard's avatar Alexandre Julliard

widl: Use write_pointer_description_offsets() to output no_repeat descriptors for consistency.

parent 916461d9
......@@ -1614,7 +1614,7 @@ static void write_descriptors(FILE *file, type_t *type, unsigned int *tfsoff)
}
}
static int write_no_repeat_pointer_descriptions(
static int write_pointer_description_offsets(
FILE *file, const attr_list_t *attrs, type_t *type,
unsigned int *offset_in_memory, unsigned int *offset_in_buffer,
unsigned int *typestring_offset)
......@@ -1622,25 +1622,39 @@ static int write_no_repeat_pointer_descriptions(
int written = 0;
unsigned int align;
if (is_ptr(type) ||
(is_conformant_array(type) && type_array_is_decl_as_ptr(type)))
if ((is_ptr(type) && type_get_type(type_pointer_get_ref(type)) != TYPE_INTERFACE) ||
(is_array(type) && type_array_is_decl_as_ptr(type)))
{
if (offset_in_memory && offset_in_buffer)
{
unsigned int memsize;
print_file(file, 2, "0x%02x, /* FC_NO_REPEAT */\n", RPC_FC_NO_REPEAT);
print_file(file, 2, "0x%02x, /* FC_PAD */\n", RPC_FC_PAD);
/* pointer instance */
/* FIXME: sometimes from end of structure, sometimes from beginning */
print_file(file, 2, "NdrFcShort(0x%hx),\t/* Memory offset = %d */\n", *offset_in_memory, *offset_in_memory);
print_file(file, 2, "NdrFcShort(0x%hx),\t/* Buffer offset = %d */\n", *offset_in_buffer, *offset_in_buffer);
*typestring_offset += 6;
align = 0;
memsize = type_memsize(type, &align);
*offset_in_memory += memsize;
/* increment these separately as in the case of conformant (varying)
* structures these start at different values */
*offset_in_buffer += memsize;
}
*typestring_offset += 4;
if (is_ptr(type))
{
type_t *ref = type_pointer_get_ref(type);
if (is_string_type(attrs, type))
write_string_tfs(file, attrs, type, FALSE, NULL, typestring_offset);
else if (processed(ref))
write_nonsimple_pointer(file, attrs, type, FALSE, ref->typestring_offset, typestring_offset);
else if (type_get_type(ref) == TYPE_BASIC || type_get_type(ref) == TYPE_ENUM)
*typestring_offset += write_simple_pointer(file, attrs, type, FALSE);
else
write_pointer_tfs(file, attrs, type, FALSE, typestring_offset);
error("write_pointer_description_offsets: type format string unknown\n");
}
else
{
......@@ -1652,18 +1666,18 @@ static int write_no_repeat_pointer_descriptions(
write_nonsimple_pointer(file, attrs, type, FALSE, offset, typestring_offset);
}
align = 0;
memsize = type_memsize(type, &align);
*offset_in_memory += memsize;
/* increment these separately as in the case of conformant (varying)
* structures these start at different values */
*offset_in_buffer += memsize;
return 1;
}
if (is_non_complex_struct(type))
if (is_array(type))
{
return write_pointer_description_offsets(
file, attrs, type_array_get_element(type), offset_in_memory,
offset_in_buffer, typestring_offset);
}
else if (is_non_complex_struct(type))
{
/* otherwise search for interesting fields to parse */
const var_t *v;
LIST_FOR_EACH_ENTRY( v, type_struct_get_fields(type), const var_t, entry )
{
......@@ -1676,13 +1690,15 @@ static int write_no_repeat_pointer_descriptions(
*offset_in_memory += padding;
*offset_in_buffer += padding;
}
written += write_no_repeat_pointer_descriptions(
file, v->attrs, v->type,
offset_in_memory, offset_in_buffer, typestring_offset);
written += write_pointer_description_offsets(
file, v->attrs, v->type, offset_in_memory, offset_in_buffer,
typestring_offset);
}
}
else
{
if (offset_in_memory && offset_in_buffer)
{
unsigned int memsize;
align = 0;
memsize = type_memsize(type, &align);
......@@ -1691,11 +1707,12 @@ static int write_no_repeat_pointer_descriptions(
* structures these start at different values */
*offset_in_buffer += memsize;
}
}
return written;
}
static int write_pointer_description_offsets(
static int write_no_repeat_pointer_descriptions(
FILE *file, const attr_list_t *attrs, type_t *type,
unsigned int *offset_in_memory, unsigned int *offset_in_buffer,
unsigned int *typestring_offset)
......@@ -1703,62 +1720,19 @@ static int write_pointer_description_offsets(
int written = 0;
unsigned int align;
if ((is_ptr(type) && type_get_type(type_pointer_get_ref(type)) != TYPE_INTERFACE) ||
(is_array(type) && type_array_is_decl_as_ptr(type)))
{
if (offset_in_memory && offset_in_buffer)
{
unsigned int memsize;
/* pointer instance */
/* FIXME: sometimes from end of structure, sometimes from beginning */
print_file(file, 2, "NdrFcShort(0x%hx),\t/* Memory offset = %d */\n", *offset_in_memory, *offset_in_memory);
print_file(file, 2, "NdrFcShort(0x%hx),\t/* Buffer offset = %d */\n", *offset_in_buffer, *offset_in_buffer);
align = 0;
memsize = type_memsize(type, &align);
*offset_in_memory += memsize;
/* increment these separately as in the case of conformant (varying)
* structures these start at different values */
*offset_in_buffer += memsize;
}
*typestring_offset += 4;
if (is_ptr(type))
{
type_t *ref = type_pointer_get_ref(type);
if (is_string_type(attrs, type))
write_string_tfs(file, attrs, type, FALSE, NULL, typestring_offset);
else if (processed(ref))
write_nonsimple_pointer(file, attrs, type, FALSE, ref->typestring_offset, typestring_offset);
else if (type_get_type(ref) == TYPE_BASIC || type_get_type(ref) == TYPE_ENUM)
*typestring_offset += write_simple_pointer(file, attrs, type, FALSE);
else
error("write_pointer_description_offsets: type format string unknown\n");
}
else
if (is_ptr(type) ||
(is_conformant_array(type) && type_array_is_decl_as_ptr(type)))
{
unsigned int offset = type->typestring_offset;
/* skip over the pointer that is written for strings, since a
* pointer has to be written in-place here */
if (is_string_type(attrs, type))
offset += 4;
write_nonsimple_pointer(file, attrs, type, FALSE, offset, typestring_offset);
}
print_file(file, 2, "0x%02x, /* FC_NO_REPEAT */\n", RPC_FC_NO_REPEAT);
print_file(file, 2, "0x%02x, /* FC_PAD */\n", RPC_FC_PAD);
*typestring_offset += 2;
return 1;
return write_pointer_description_offsets(file, attrs, type,
offset_in_memory, offset_in_buffer, typestring_offset);
}
if (is_array(type))
{
return write_pointer_description_offsets(
file, attrs, type_array_get_element(type), offset_in_memory,
offset_in_buffer, typestring_offset);
}
else if (is_non_complex_struct(type))
if (is_non_complex_struct(type))
{
/* otherwise search for interesting fields to parse */
const var_t *v;
LIST_FOR_EACH_ENTRY( v, type_struct_get_fields(type), const var_t, entry )
{
......@@ -1771,15 +1745,13 @@ static int write_pointer_description_offsets(
*offset_in_memory += padding;
*offset_in_buffer += padding;
}
written += write_pointer_description_offsets(
file, v->attrs, v->type, offset_in_memory, offset_in_buffer,
typestring_offset);
written += write_no_repeat_pointer_descriptions(
file, v->attrs, v->type,
offset_in_memory, offset_in_buffer, typestring_offset);
}
}
else
{
if (offset_in_memory && offset_in_buffer)
{
unsigned int memsize;
align = 0;
memsize = type_memsize(type, &align);
......@@ -1788,7 +1760,6 @@ static int write_pointer_description_offsets(
* structures these start at different values */
*offset_in_buffer += memsize;
}
}
return written;
}
......
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