widl: Write types in the format string comments.

This commit is contained in:
Dan Hipschman 2007-10-02 21:40:13 -07:00 committed by Alexandre Julliard
parent 32a2477ef5
commit 304852f97e
2 changed files with 23 additions and 10 deletions

View File

@ -195,6 +195,8 @@ int needs_space_after(type_t *t)
void write_type_left(FILE *h, type_t *t, int declonly) void write_type_left(FILE *h, type_t *t, int declonly)
{ {
if (!h) return;
if (t->is_const) fprintf(h, "const "); if (t->is_const) fprintf(h, "const ");
if (t->kind == TKIND_ALIAS) fprintf(h, "%s", t->name); if (t->kind == TKIND_ALIAS) fprintf(h, "%s", t->name);
@ -214,7 +216,7 @@ void write_type_left(FILE *h, type_t *t, int declonly)
indent(h, -1); indent(h, -1);
fprintf(h, "}"); fprintf(h, "}");
} }
else fprintf(h, "enum %s", t->name); else fprintf(h, "enum %s", t->name ? t->name : "");
break; break;
case RPC_FC_STRUCT: case RPC_FC_STRUCT:
case RPC_FC_CVSTRUCT: case RPC_FC_CVSTRUCT:
@ -232,7 +234,7 @@ void write_type_left(FILE *h, type_t *t, int declonly)
indent(h, -1); indent(h, -1);
fprintf(h, "}"); fprintf(h, "}");
} }
else fprintf(h, "struct %s", t->name); else fprintf(h, "struct %s", t->name ? t->name : "");
break; break;
case RPC_FC_NON_ENCAPSULATED_UNION: case RPC_FC_NON_ENCAPSULATED_UNION:
if (!declonly && t->defined && !t->written && !t->ignore) { if (!declonly && t->defined && !t->written && !t->ignore) {
@ -244,7 +246,7 @@ void write_type_left(FILE *h, type_t *t, int declonly)
indent(h, -1); indent(h, -1);
fprintf(h, "}"); fprintf(h, "}");
} }
else fprintf(h, "union %s", t->name); else fprintf(h, "union %s", t->name ? t->name : "");
break; break;
case RPC_FC_RP: case RPC_FC_RP:
case RPC_FC_UP: case RPC_FC_UP:
@ -264,6 +266,8 @@ void write_type_left(FILE *h, type_t *t, int declonly)
void write_type_right(FILE *h, type_t *t, int is_field) void write_type_right(FILE *h, type_t *t, int is_field)
{ {
if (!h) return;
if (t->declarray) { if (t->declarray) {
if (is_conformant_array(t)) { if (is_conformant_array(t)) {
fprintf(h, "[%s]", is_field ? "1" : ""); fprintf(h, "[%s]", is_field ? "1" : "");
@ -277,6 +281,8 @@ void write_type_right(FILE *h, type_t *t, int is_field)
void write_type_v(FILE *h, type_t *t, int is_field, int declonly, void write_type_v(FILE *h, type_t *t, int is_field, int declonly,
const char *fmt, va_list args) const char *fmt, va_list args)
{ {
if (!h) return;
write_type_left(h, t, declonly); write_type_left(h, t, declonly);
if (fmt) { if (fmt) {
if (needs_space_after(t)) if (needs_space_after(t))

View File

@ -868,11 +868,18 @@ static unsigned int write_simple_pointer(FILE *file, const type_t *type)
return 4; return 4;
} }
static void print_start_tfs_comment(FILE *file, type_t *t, unsigned int tfsoff)
{
print_file(file, 0, "/* %u (", tfsoff);
write_type_decl(file, t, NULL);
print_file(file, 0, ") */\n");
}
static size_t write_pointer_tfs(FILE *file, type_t *type, unsigned int *typestring_offset) static size_t write_pointer_tfs(FILE *file, type_t *type, unsigned int *typestring_offset)
{ {
unsigned int offset = *typestring_offset; unsigned int offset = *typestring_offset;
print_file(file, 0, "/* %d */\n", offset); print_start_tfs_comment(file, type, offset);
update_tfsoff(type, offset, file); update_tfsoff(type, offset, file);
if (type->ref->typestring_offset) if (type->ref->typestring_offset)
@ -904,7 +911,7 @@ static void write_user_tfs(FILE *file, type_t *type, unsigned int *tfsoff)
if (is_base_type(utype->type)) if (is_base_type(utype->type))
{ {
absoff = *tfsoff; absoff = *tfsoff;
print_file(file, 0, "/* %d */\n", absoff); print_start_tfs_comment(file, utype, absoff);
print_file(file, 2, "0x%x,\t/* %s */\n", utype->type, string_of_type(utype->type)); print_file(file, 2, "0x%x,\t/* %s */\n", utype->type, string_of_type(utype->type));
print_file(file, 2, "0x5c,\t/* FC_PAD */\n"); print_file(file, 2, "0x5c,\t/* FC_PAD */\n");
*tfsoff += 2; *tfsoff += 2;
@ -925,7 +932,7 @@ static void write_user_tfs(FILE *file, type_t *type, unsigned int *tfsoff)
start = *tfsoff; start = *tfsoff;
update_tfsoff(type, start, file); update_tfsoff(type, start, file);
print_file(file, 0, "/* %d */\n", start); print_start_tfs_comment(file, type, start);
print_file(file, 2, "0x%x,\t/* FC_USER_MARSHAL */\n", RPC_FC_USER_MARSHAL); print_file(file, 2, "0x%x,\t/* FC_USER_MARSHAL */\n", RPC_FC_USER_MARSHAL);
print_file(file, 2, "0x%x,\t/* Alignment= %d, Flags= %02x */\n", print_file(file, 2, "0x%x,\t/* Alignment= %d, Flags= %02x */\n",
flags | (align - 1), align - 1, flags); flags | (align - 1), align - 1, flags);
@ -1486,7 +1493,7 @@ static size_t write_array_tfs(FILE *file, const attr_list_t *attrs, type_t *type
start_offset = *typestring_offset; start_offset = *typestring_offset;
update_tfsoff(type, start_offset, file); update_tfsoff(type, start_offset, file);
print_file(file, 0, "/* %lu */\n", start_offset); print_start_tfs_comment(file, type, start_offset);
print_file(file, 2, "0x%02x,\t/* %s */\n", type->type, string_of_type(type->type)); print_file(file, 2, "0x%02x,\t/* %s */\n", type->type, string_of_type(type->type));
print_file(file, 2, "0x%x,\t/* %d */\n", align - 1, align - 1); print_file(file, 2, "0x%x,\t/* %d */\n", align - 1, align - 1);
*typestring_offset += 2; *typestring_offset += 2;
@ -1672,7 +1679,7 @@ static size_t write_struct_tfs(FILE *file, type_t *type,
start_offset = *tfsoff; start_offset = *tfsoff;
update_tfsoff(type, start_offset, file); update_tfsoff(type, start_offset, file);
print_file(file, 0, "/* %d */\n", start_offset); print_start_tfs_comment(file, type, start_offset);
print_file(file, 2, "0x%x,\t/* %s */\n", type->type, string_of_type(type->type)); print_file(file, 2, "0x%x,\t/* %s */\n", type->type, string_of_type(type->type));
print_file(file, 2, "0x%x,\t/* %d */\n", align - 1, align - 1); print_file(file, 2, "0x%x,\t/* %d */\n", align - 1, align - 1);
print_file(file, 2, "NdrFcShort(0x%x),\t/* %d */\n", total_size, total_size); print_file(file, 2, "NdrFcShort(0x%x),\t/* %d */\n", total_size, total_size);
@ -1825,7 +1832,7 @@ static size_t write_union_tfs(FILE *file, type_t *type, unsigned int *tfsoff)
start_offset = *tfsoff; start_offset = *tfsoff;
update_tfsoff(type, start_offset, file); update_tfsoff(type, start_offset, file);
print_file(file, 0, "/* %d */\n", start_offset); print_start_tfs_comment(file, type, start_offset);
if (type->type == RPC_FC_ENCAPSULATED_UNION) if (type->type == RPC_FC_ENCAPSULATED_UNION)
{ {
const var_t *sv = LIST_ENTRY(list_head(type->fields), const var_t, entry); const var_t *sv = LIST_ENTRY(list_head(type->fields), const var_t, entry);
@ -1926,7 +1933,7 @@ static size_t write_ip_tfs(FILE *file, const attr_list_t *attrs, type_t *type,
error("%s: interface %s missing UUID\n", __FUNCTION__, base->name); error("%s: interface %s missing UUID\n", __FUNCTION__, base->name);
update_tfsoff(type, start_offset, file); update_tfsoff(type, start_offset, file);
print_file(file, 0, "/* %d */\n", start_offset); print_start_tfs_comment(file, type, start_offset);
print_file(file, 2, "0x2f,\t/* FC_IP */\n"); print_file(file, 2, "0x2f,\t/* FC_IP */\n");
print_file(file, 2, "0x5a,\t/* FC_CONSTANT_IID */\n"); print_file(file, 2, "0x5a,\t/* FC_CONSTANT_IID */\n");
print_file(file, 2, "NdrFcLong(0x%08lx),\n", uuid->Data1); print_file(file, 2, "NdrFcLong(0x%08lx),\n", uuid->Data1);