Dan Hipschman : widl: Write types in the format string comments.
Alexandre Julliard
julliard at winehq.org
Wed Oct 3 06:08:14 CDT 2007
Module: wine
Branch: master
Commit: 304852f97e8da64954e33ceb6ab5e014fa26049f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=304852f97e8da64954e33ceb6ab5e014fa26049f
Author: Dan Hipschman <dsh at linux.ucla.edu>
Date: Tue Oct 2 21:40:13 2007 -0700
widl: Write types in the format string comments.
---
tools/widl/header.c | 12 +++++++++---
tools/widl/typegen.c | 21 ++++++++++++++-------
2 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/tools/widl/header.c b/tools/widl/header.c
index 07a562b..2643f49 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -195,6 +195,8 @@ int needs_space_after(type_t *t)
void write_type_left(FILE *h, type_t *t, int declonly)
{
+ if (!h) return;
+
if (t->is_const) fprintf(h, "const ");
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);
fprintf(h, "}");
}
- else fprintf(h, "enum %s", t->name);
+ else fprintf(h, "enum %s", t->name ? t->name : "");
break;
case RPC_FC_STRUCT:
case RPC_FC_CVSTRUCT:
@@ -232,7 +234,7 @@ void write_type_left(FILE *h, type_t *t, int declonly)
indent(h, -1);
fprintf(h, "}");
}
- else fprintf(h, "struct %s", t->name);
+ else fprintf(h, "struct %s", t->name ? t->name : "");
break;
case RPC_FC_NON_ENCAPSULATED_UNION:
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);
fprintf(h, "}");
}
- else fprintf(h, "union %s", t->name);
+ else fprintf(h, "union %s", t->name ? t->name : "");
break;
case RPC_FC_RP:
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)
{
+ if (!h) return;
+
if (t->declarray) {
if (is_conformant_array(t)) {
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,
const char *fmt, va_list args)
{
+ if (!h) return;
+
write_type_left(h, t, declonly);
if (fmt) {
if (needs_space_after(t))
diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index e3bdd83..a91fd13 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -868,11 +868,18 @@ static unsigned int write_simple_pointer(FILE *file, const type_t *type)
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)
{
unsigned int offset = *typestring_offset;
- print_file(file, 0, "/* %d */\n", offset);
+ print_start_tfs_comment(file, type, offset);
update_tfsoff(type, offset, file);
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))
{
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, "0x5c,\t/* FC_PAD */\n");
*tfsoff += 2;
@@ -925,7 +932,7 @@ static void write_user_tfs(FILE *file, type_t *type, unsigned int *tfsoff)
start = *tfsoff;
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/* Alignment= %d, Flags= %02x */\n",
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;
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%x,\t/* %d */\n", align - 1, align - 1);
*typestring_offset += 2;
@@ -1672,7 +1679,7 @@ static size_t write_struct_tfs(FILE *file, type_t *type,
start_offset = *tfsoff;
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/* %d */\n", align - 1, align - 1);
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;
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)
{
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);
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, "0x5a,\t/* FC_CONSTANT_IID */\n");
print_file(file, 2, "NdrFcLong(0x%08lx),\n", uuid->Data1);
More information about the wine-cvs
mailing list