widl-SLTG_Typelib_Support: Delete upstreamed patches.

This commit is contained in:
Zebediah Figura
2024-04-04 13:21:17 -05:00
parent bcf38efc5b
commit a1057e16a6
14 changed files with 0 additions and 2403 deletions

View File

@ -1,102 +0,0 @@
From 5cbf5f43c6b827a9454b2c326a61ea709e32947b Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 7 Jan 2016 19:12:47 +0800
Subject: widl: Properly align name table entries.
---
tools/widl/write_sltg.c | 39 ++++++++++++++++++++++-----------------
1 file changed, 22 insertions(+), 17 deletions(-)
diff --git a/tools/widl/write_sltg.c b/tools/widl/write_sltg.c
index 11b4d0c..1ba921d 100644
--- a/tools/widl/write_sltg.c
+++ b/tools/widl/write_sltg.c
@@ -192,39 +192,44 @@ static void init_index(struct sltg_data *index)
add_index(index, compobj);
}
-static int add_name(struct sltg_data *name_table, const char *name)
+static int add_name(struct sltg_typelib *sltg, const char *name)
{
- int name_offset = name_table->size;
- int new_size = name_table->size + strlen(name) + 1 + 8;
+ int name_offset = sltg->name_table.size;
+ int new_size = sltg->name_table.size + strlen(name) + 1 + 8;
+ int aligned_size;
chat("add_name: %s\n", name);
- new_size = (new_size + 1) & ~1; /* align */
+ aligned_size = (new_size + 0x1f) & ~0x1f;
+ if (aligned_size - new_size < 4)
+ new_size = aligned_size;
+ else
+ new_size = (new_size + 1) & ~1;
- if (new_size > name_table->allocated)
+ if (aligned_size > sltg->name_table.allocated)
{
- name_table->allocated = max(name_table->allocated * 2, new_size);
- name_table->data = xrealloc(name_table->data, name_table->allocated);
+ sltg->name_table.allocated = max(sltg->name_table.allocated * 2, aligned_size);
+ sltg->name_table.data = xrealloc(sltg->name_table.data, sltg->name_table.allocated);
}
- memset(name_table->data + name_table->size, 0xff, 8);
- strcpy(name_table->data + name_table->size + 8, name);
- name_table->size = new_size;
- name_table->data[name_table->size - 1] = 0; /* clear alignment */
+ memset(sltg->name_table.data + sltg->name_table.size, 0xff, 8);
+ strcpy(sltg->name_table.data + sltg->name_table.size + 8, name);
+ sltg->name_table.size = new_size;
+ sltg->name_table.data[sltg->name_table.size - 1] = 0; /* clear alignment */
return name_offset;
}
-static void init_name_table(struct sltg_data *name_table)
+static void init_name_table(struct sltg_typelib *sltg)
{
- init_sltg_data(name_table);
+ init_sltg_data(&sltg->name_table);
}
static void init_library(struct sltg_typelib *sltg)
{
const attr_t *attr;
- sltg->library.name = add_name(&sltg->name_table, sltg->typelib->name);
+ sltg->library.name = add_name(sltg, sltg->typelib->name);
sltg->library.helpstring = NULL;
sltg->library.helpcontext = 0;
sltg->library.syskind = SYS_WIN32;
@@ -443,7 +448,7 @@ static const char *add_typeinfo_block(struct sltg_typelib *typelib, const type_t
strcpy((char *)p, other_name);
p = (short *)((char *)p + strlen(other_name));
*p++ = -1; /* res1a */
- *p++ = add_name(&typelib->name_table, type->name); /* name offset */
+ *p++ = add_name(typelib, type->name); /* name offset */
*p++ = 0; /* FIXME: helpstring */
*p++ = -1; /* res20 */
*(int *)p = helpcontext;
@@ -710,7 +715,7 @@ static void add_structure_typeinfo(struct sltg_typelib *typelib, const type_t *t
next += sizeof(variable);
variable.magic = 0x2a; /* always write flags to simplify calculations */
- variable.name = add_name(&typelib->name_table, var->name);
+ variable.name = add_name(typelib, var->name);
variable.byte_offs = 0;
if (var_data[i].size > sizeof(short))
{
@@ -1063,7 +1068,7 @@ int create_sltg_typelib(typelib_t *typelib)
sltg.first_block = 1;
init_index(&sltg.index);
- init_name_table(&sltg.name_table);
+ init_name_table(&sltg);
init_library(&sltg);
add_library_block(&sltg);
--
2.6.4

View File

@ -1,77 +0,0 @@
From 58a9418411eb13530349887df93b2c96febbd23f Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Sat, 9 Jan 2016 15:49:46 +0800
Subject: [PATCH] widl: More accurately report variable descriptions data size.
---
tools/widl/write_sltg.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/tools/widl/write_sltg.c b/tools/widl/write_sltg.c
index 216d688e69d..0d27898c7c0 100644
--- a/tools/widl/write_sltg.c
+++ b/tools/widl/write_sltg.c
@@ -678,14 +678,15 @@ static void add_structure_typeinfo(struct sltg_typelib *typelib, const type_t *t
LIST_FOR_EACH_ENTRY(var, type_struct_get_fields(type), var_t, entry)
{
+ short base_offset;
+
chat("add_structure_typeinfo: var %p, name %s, type %p\n",
var, var->name, var->declspec.type);
init_sltg_data(&var_data[i]);
- var_data_size += sizeof(struct sltg_variable);
-
- type_desc_offset[i] = write_var_desc(&var_data[i], var->declspec.type, 0, var_data_size);
+ base_offset = var_data_size + (i + 1) * sizeof(struct sltg_variable);
+ type_desc_offset[i] = write_var_desc(&var_data[i], var->declspec.type, 0, base_offset);
dump_var_desc(var_data[i].data, var_data[i].size);
if (var_data[i].size > sizeof(short))
@@ -699,9 +700,11 @@ static void add_structure_typeinfo(struct sltg_typelib *typelib, const type_t *t
member.res00 = 0x0001;
member.res02 = 0xffff;
member.res04 = 0x01;
- member.extra = var_data_size;
+ member.extra = var_data_size + var_count * sizeof(struct sltg_variable);
append_data(&data, &member, sizeof(member));
+ var_data_size = 0;
+
if (type_struct_get_fields(type))
{
int i = 0;
@@ -720,7 +723,8 @@ static void add_structure_typeinfo(struct sltg_typelib *typelib, const type_t *t
if (var_data[i].size > sizeof(short))
{
variable.flags = 0;
- variable.type = next - member_offset + type_desc_offset[i];
+ var_data_size = next - member_offset + type_desc_offset[i];
+ variable.type = var_data_size;
next += var_data[i].size;
}
else
@@ -760,15 +764,15 @@ static void add_structure_typeinfo(struct sltg_typelib *typelib, const type_t *t
tail.res1e = 0;
tail.cbSizeInstance = 0;
tail.cbAlignment = 4;
- tail.res24 = 0;
- tail.res26 = 0;
+ tail.res24 = -1;
+ tail.res26 = -1;
tail.cbSizeVft = 0;
tail.res2a = -1;
tail.res2c = -1;
tail.res2e = -1;
tail.res30 = -1;
tail.res32 = 0;
- tail.type_bytes = data.size - member_offset;
+ tail.type_bytes = data.size - member_offset - sizeof(member);
append_data(&data, &tail, sizeof(tail));
add_block(typelib, data.data, data.size, index_name);
--
2.17.1

View File

@ -1,112 +0,0 @@
From 91a17391506e9be6612af90aee35d33206037b10 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Sat, 9 Jan 2016 16:22:15 +0800
Subject: [PATCH] widl: Calculate size of instance for structures.
---
tools/widl/write_sltg.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/tools/widl/write_sltg.c b/tools/widl/write_sltg.c
index 0d27898c7c0..bf8fe6d9ac0 100644
--- a/tools/widl/write_sltg.c
+++ b/tools/widl/write_sltg.c
@@ -546,7 +546,7 @@ static int get_element_size(type_t *type)
return 0;
}
-static short write_var_desc(struct sltg_data *data, type_t *type, short flags, short base_offset)
+static short write_var_desc(struct sltg_data *data, type_t *type, short flags, short base_offset, int *size_instance)
{
short vt, desc_offset;
@@ -555,7 +555,7 @@ static short write_var_desc(struct sltg_data *data, type_t *type, short flags, s
if (is_array(type) && !type_array_is_decl_as_ptr(type))
{
- int num_dims, elements, array_start, size;
+ int num_dims, elements, array_start, size, array_size;
type_t *atype;
struct
{
@@ -591,22 +591,28 @@ static short write_var_desc(struct sltg_data *data, type_t *type, short flags, s
array->cDims = num_dims;
array->fFeatures = 0x0004; /* FADF_EMBEDDED */
- array->cbElements = get_element_size(type_array_get_element_type(type));
+ array->cbElements = get_element_size(atype);
array->cLocks = 0;
array->pvData = NULL;
bound = array->bound;
+
+ array_size = array->cbElements;
atype = type;
while (is_array(atype) && !type_array_is_decl_as_ptr(atype))
{
bound[0] = type_array_get_dim(atype);
+ array_size *= bound[0];
bound[1] = 0;
bound += 2;
atype = type_array_get_element_type(atype);
}
+ *size_instance += array_size;
+ size_instance = NULL; /* don't account for element size */
+
append_data(data, array, size);
desc_offset = data->size;
@@ -632,15 +638,18 @@ static short write_var_desc(struct sltg_data *data, type_t *type, short flags, s
chat("write_var_desc: vt VT_PTR | 0x0400\n");
vt = VT_PTR | 0x0400;
append_data(data, &vt, sizeof(vt));
- write_var_desc(data, ref, 0, base_offset);
+ write_var_desc(data, ref, 0, base_offset, size_instance);
}
else
- write_var_desc(data, ref, 0x0e00, base_offset);
+ write_var_desc(data, ref, 0x0e00, base_offset, size_instance);
return desc_offset;
}
chat("write_var_desc: vt %d, flags %04x\n", vt, flags);
+ if (size_instance)
+ *size_instance += get_element_size(type);
+
vt |= flags;
append_data(data, &vt, sizeof(vt));
@@ -654,7 +663,7 @@ static void add_structure_typeinfo(struct sltg_typelib *typelib, const type_t *t
struct sltg_typeinfo_header ti;
struct sltg_member_header member;
struct sltg_tail tail;
- int member_offset, var_count = 0, var_data_size = 0;
+ int member_offset, var_count = 0, var_data_size = 0, size_instance = 0;
short *type_desc_offset = NULL;
chat("add_structure_typeinfo: %s\n", type->name);
@@ -686,7 +695,7 @@ static void add_structure_typeinfo(struct sltg_typelib *typelib, const type_t *t
init_sltg_data(&var_data[i]);
base_offset = var_data_size + (i + 1) * sizeof(struct sltg_variable);
- type_desc_offset[i] = write_var_desc(&var_data[i], var->declspec.type, 0, base_offset);
+ type_desc_offset[i] = write_var_desc(&var_data[i], var->declspec.type, 0, base_offset, &size_instance);
dump_var_desc(var_data[i].data, var_data[i].size);
if (var_data[i].size > sizeof(short))
@@ -762,7 +771,7 @@ static void add_structure_typeinfo(struct sltg_typelib *typelib, const type_t *t
tail.res1a = 0;
tail.simple_alias = 0;
tail.res1e = 0;
- tail.cbSizeInstance = 0;
+ tail.cbSizeInstance = size_instance;
tail.cbAlignment = 4;
tail.res24 = -1;
tail.res26 = -1;
--
2.17.1

View File

@ -1,43 +0,0 @@
From 2f8a1768690fb0bb26411f561fe9d9d513c2de1f Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Sun, 10 Jan 2016 15:58:15 +0800
Subject: widl: Write correct typekind to the SLTG typeinfo block.
---
tools/widl/write_sltg.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/widl/write_sltg.c b/tools/widl/write_sltg.c
index 05cda99..04c6123 100644
--- a/tools/widl/write_sltg.c
+++ b/tools/widl/write_sltg.c
@@ -419,7 +419,7 @@ static void add_interface_typeinfo(struct sltg_typelib *typelib, type_t *type)
error("add_interface_typeinfo: %s not implemented\n", type->name);
}
-static const char *add_typeinfo_block(struct sltg_typelib *typelib, const type_t *type)
+static const char *add_typeinfo_block(struct sltg_typelib *typelib, const type_t *type, int kind)
{
const char *index_name, *other_name;
void *block;
@@ -456,7 +456,7 @@ static const char *add_typeinfo_block(struct sltg_typelib *typelib, const type_t
*p++ = -1; /* res26 */
*(GUID *)p = guid;
p += sizeof(GUID)/2;
- *p = type_get_type(type);
+ *p = kind;
sltg_add_typeinfo(typelib, block, size, index_name);
@@ -670,7 +670,7 @@ static void add_structure_typeinfo(struct sltg_typelib *typelib, const type_t *t
init_sltg_data(&data);
- index_name = add_typeinfo_block(typelib, type);
+ index_name = add_typeinfo_block(typelib, type, TKIND_RECORD);
init_typeinfo(&ti, type, TKIND_RECORD);
append_data(&data, &ti, sizeof(ti));
--
2.6.4

View File

@ -1,64 +0,0 @@
From 8d03a0b285eb282b80d512ac9c28523cb464c209 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Sun, 10 Jan 2016 15:59:19 +0800
Subject: widl: Write SLTG blocks according to the index order.
Now multiple types can be correctly parsed and displayed by oleview.
---
tools/widl/write_sltg.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/tools/widl/write_sltg.c b/tools/widl/write_sltg.c
index 04c6123..4b86bf9 100644
--- a/tools/widl/write_sltg.c
+++ b/tools/widl/write_sltg.c
@@ -291,9 +291,20 @@ static void add_block(struct sltg_typelib *sltg, void *data, int size, const cha
block->length = size;
block->data = data;
block->index_string = add_index(&sltg->index, name);
- block->next = sltg->blocks;
+ block->next = NULL;
+
+ if (sltg->blocks)
+ {
+ struct sltg_block *blocks = sltg->blocks;
+
+ while (blocks->next)
+ blocks = blocks->next;
+
+ blocks->next = block;
+ }
+ else
+ sltg->blocks = block;
- sltg->blocks = block;
sltg->n_file_blocks++;
}
@@ -378,7 +389,7 @@ static void sltg_add_typeinfo(struct sltg_typelib *sltg, void *data, int size, c
{
struct sltg_block *typeinfo = sltg->typeinfo;
- while (typeinfo && typeinfo->next)
+ while (typeinfo->next)
typeinfo = typeinfo->next;
typeinfo->next = block;
@@ -1084,12 +1095,12 @@ int create_sltg_typelib(typelib_t *typelib)
init_name_table(&sltg);
init_library(&sltg);
- add_library_block(&sltg);
-
if (typelib->stmts)
LIST_FOR_EACH_ENTRY(stmt, typelib->stmts, const statement_t, entry)
add_statement(&sltg, stmt);
+ add_library_block(&sltg);
+
save_all_changes(&sltg);
return 1;
--
2.6.4

View File

@ -1,25 +0,0 @@
From 9bdee4f88ef67ad2d6fddaba4712cd786d05a024 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Sun, 10 Jan 2016 16:01:55 +0800
Subject: widl: Write correct syskind by SLTG typelib generator.
---
tools/widl/write_sltg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/widl/write_sltg.c b/tools/widl/write_sltg.c
index d833edfe..df3acc2f 100644
--- a/tools/widl/write_sltg.c
+++ b/tools/widl/write_sltg.c
@@ -232,7 +232,7 @@ static void init_library(struct sltg_typelib *sltg)
sltg->library.name = add_name(sltg, sltg->typelib->name);
sltg->library.helpstring = NULL;
sltg->library.helpcontext = 0;
- sltg->library.syskind = SYS_WIN32;
+ sltg->library.syskind = (pointer_size == 8) ? SYS_WIN64 : SYS_WIN32;
sltg->library.lcid = 0x0409;
sltg->library.libflags = 0;
sltg->library.version = 0;
--
2.19.1

View File

@ -1,30 +0,0 @@
From 5e54bd9690e6b969ea5cccfd58b8f6ffb8800fef Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Sun, 10 Jan 2016 16:03:33 +0800
Subject: widl: Add support for VT_VOID and VT_VARIANT to SLTG typelib
generator.
---
tools/widl/write_sltg.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/widl/write_sltg.c b/tools/widl/write_sltg.c
index 61632ee..08bb25e 100644
--- a/tools/widl/write_sltg.c
+++ b/tools/widl/write_sltg.c
@@ -549,6 +549,12 @@ static int get_element_size(type_t *type)
case VT_LPWSTR:
return pointer_size;
+ case VT_VOID:
+ return 0;
+
+ case VT_VARIANT:
+ return pointer_size == 8 ? 24 : 16;
+
default:
error("get_element_size: unrecognized vt %d\n", vt);
break;
--
2.6.4

View File

@ -1,323 +0,0 @@
From b49b4983e2fb13cd4bf81626e19b6c38277f596d Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Wed, 13 Jan 2016 15:58:50 +0800
Subject: [PATCH] widl: Add support for VT_USERDEFINED to SLTG typelib
generator.
---
tools/widl/write_sltg.c | 211 +++++++++++++++++++++++++++++++++++++---
1 file changed, 196 insertions(+), 15 deletions(-)
diff --git a/tools/widl/write_sltg.c b/tools/widl/write_sltg.c
index 7421899ed56..bffd94569a8 100644
--- a/tools/widl/write_sltg.c
+++ b/tools/widl/write_sltg.c
@@ -83,6 +83,12 @@ struct sltg_typelib
struct sltg_block *typeinfo;
};
+struct sltg_hrefmap
+{
+ int href_count;
+ int *href;
+};
+
#include "pshpack1.h"
struct sltg_typeinfo_header
{
@@ -155,6 +161,46 @@ struct sltg_tail
short res32; /* unknown */
short type_bytes; /* bytes used by type descriptions */
};
+
+struct sltg_hrefinfo
+{
+ char magic; /* 0xdf */
+ char res01; /* 0x00 */
+ int res02; /* 0xffffffff */
+ int res06; /* 0xffffffff */
+ int res0a; /* 0xffffffff */
+ int res0e; /* 0xffffffff */
+ int res12; /* 0xffffffff */
+ int res16; /* 0xffffffff */
+ int res1a; /* 0xffffffff */
+ int res1e; /* 0xffffffff */
+ int res22; /* 0xffffffff */
+ int res26; /* 0xffffffff */
+ int res2a; /* 0xffffffff */
+ int res2e; /* 0xffffffff */
+ int res32; /* 0xffffffff */
+ int res36; /* 0xffffffff */
+ int res3a; /* 0xffffffff */
+ int res3e; /* 0xffffffff */
+ short res42;/* 0xffff */
+ int number; /* this is 8 times the number of refs */
+ /* Now we have number bytes (8 for each ref) of SLTG_UnknownRefInfo */
+
+ short res50;/* 0xffff */
+ char res52; /* 0x01 */
+ int res53; /* 0x00000000 */
+ /* Now we have number/8 SLTG_Names (first WORD is no of bytes in the ascii
+ * string). Strings look like "*\Rxxxx*#n". If xxxx == ffff then the
+ * ref refers to the nth type listed in this library (0 based). Else
+ * the xxxx (which maybe fewer than 4 digits) is the offset into the name
+ * table to a string "*\G{<guid>}#1.0#0#C:\WINNT\System32\stdole32.tlb#"
+ * The guid is the typelib guid; the ref again refers to the nth type of
+ * the imported typelib.
+ */
+
+ char resxx; /* 0xdf */
+};
+
#include "poppack.h"
static void init_sltg_data(struct sltg_data *data)
@@ -474,12 +520,12 @@ static const char *add_typeinfo_block(struct sltg_typelib *typelib, const type_t
return index_name;
}
-static void init_typeinfo(struct sltg_typeinfo_header *ti, const type_t *type, int kind)
+static void init_typeinfo(struct sltg_typeinfo_header *ti, const type_t *type, int kind,
+ const struct sltg_hrefmap *hrefmap)
{
ti->magic = 0x0501;
ti->href_offset = -1;
ti->res06 = -1;
- ti->member_offset = sizeof(*ti);
ti->res0e = -1;
ti->version = get_attrv(type->attrs, ATTR_VERSION);
ti->res16 = 0xfffe0000;
@@ -488,6 +534,79 @@ static void init_typeinfo(struct sltg_typeinfo_header *ti, const type_t *type, i
ti->misc.unknown2 = 0x02;
ti->misc.typekind = kind;
ti->res1e = -1;
+
+ ti->member_offset = sizeof(*ti);
+
+ if (hrefmap->href_count)
+ {
+ char name[64];
+ int i, hrefinfo_size;
+
+ hrefinfo_size = sizeof(struct sltg_hrefinfo);
+
+ for (i = 0; i < hrefmap->href_count; i++)
+ {
+ sprintf(name, "*\\Rffff*#%x", hrefmap->href[i]);
+ hrefinfo_size += 8 + 2 + strlen(name);
+ }
+
+ ti->href_offset = ti->member_offset;
+ ti->member_offset += hrefinfo_size;
+ }
+}
+
+static void write_hrefmap(struct sltg_data *data, const struct sltg_hrefmap *hrefmap)
+{
+ struct sltg_hrefinfo hrefinfo;
+ char name[64];
+ int i;
+
+ if (!hrefmap->href_count) return;
+
+ hrefinfo.magic = 0xdf;
+ hrefinfo.res01 = 0;
+ hrefinfo.res02 = -1;
+ hrefinfo.res06 = -1;
+ hrefinfo.res0a = -1;
+ hrefinfo.res0e = -1;
+ hrefinfo.res12 = -1;
+ hrefinfo.res16 = -1;
+ hrefinfo.res1a = -1;
+ hrefinfo.res1e = -1;
+ hrefinfo.res22 = -1;
+ hrefinfo.res26 = -1;
+ hrefinfo.res2a = -1;
+ hrefinfo.res2e = -1;
+ hrefinfo.res32 = -1;
+ hrefinfo.res36 = -1;
+ hrefinfo.res3a = -1;
+ hrefinfo.res3e = -1;
+ hrefinfo.res42 = -1;
+ hrefinfo.number = hrefmap->href_count * 8;
+ hrefinfo.res50 = -1;
+ hrefinfo.res52 = 1;
+ hrefinfo.res53 = 0;
+ hrefinfo.resxx = 0xdf;
+
+ append_data(data, &hrefinfo, offsetof(struct sltg_hrefinfo, res50));
+
+ for (i = 0; i < hrefmap->href_count; i++)
+ append_data(data, "\xff\xff\xff\xff\xff\xff\xff\xff", 8);
+
+ append_data(data, &hrefinfo.res50, 7);
+
+ for (i = 0; i < hrefmap->href_count; i++)
+ {
+ short len;
+
+ sprintf(name, "*\\Rffff*#%x", hrefmap->href[i]);
+ len = strlen(name);
+
+ append_data(data, &len, sizeof(len));
+ append_data(data, name, len);
+ }
+
+ append_data(data, &hrefinfo.resxx, sizeof(hrefinfo.resxx));
}
static void dump_var_desc(const char *data, int size)
@@ -555,6 +674,9 @@ static int get_element_size(type_t *type)
case VT_VARIANT:
return pointer_size == 8 ? 24 : 16;
+ case VT_USERDEFINED:
+ return 0;
+
default:
error("get_element_size: unrecognized vt %d\n", vt);
break;
@@ -563,9 +685,41 @@ static int get_element_size(type_t *type)
return 0;
}
-static short write_var_desc(struct sltg_data *data, type_t *type, short flags, short base_offset, int *size_instance)
+static int local_href(struct sltg_hrefmap *hrefmap, int typelib_href)
+{
+ int i, href = -1;
+
+ for (i = 0; i < hrefmap->href_count; i++)
+ {
+ if (hrefmap->href[i] == typelib_href)
+ {
+ href = i;
+ break;
+ }
+ }
+
+ if (href == -1)
+ {
+ href = hrefmap->href_count;
+
+ if (hrefmap->href)
+ hrefmap->href = xrealloc(hrefmap->href, sizeof(*hrefmap->href) * (hrefmap->href_count + 1));
+ else
+ hrefmap->href = xmalloc(sizeof(*hrefmap->href));
+
+ hrefmap->href[hrefmap->href_count] = typelib_href;
+ hrefmap->href_count++;
+ }
+
+ chat("typelib href %d mapped to local href %d\n", typelib_href, href);
+
+ return href << 2;
+}
+
+static short write_var_desc(struct sltg_data *data, type_t *type, short flags, short base_offset,
+ int *size_instance, struct sltg_hrefmap *hrefmap)
{
- short vt, desc_offset;
+ short vt, vt_flags, desc_offset;
chat("write_var_desc: type %p, type->name %s\n",
type, type->name ? type->name : "NULL");
@@ -655,27 +809,47 @@ static short write_var_desc(struct sltg_data *data, type_t *type, short flags, s
chat("write_var_desc: vt VT_PTR | 0x0400\n");
vt = VT_PTR | 0x0400;
append_data(data, &vt, sizeof(vt));
- write_var_desc(data, ref, 0, base_offset, size_instance);
+ write_var_desc(data, ref, 0, base_offset, size_instance, hrefmap);
}
else
- write_var_desc(data, ref, 0x0e00, base_offset, size_instance);
+ write_var_desc(data, ref, 0x0e00, base_offset, size_instance, hrefmap);
return desc_offset;
}
chat("write_var_desc: vt %d, flags %04x\n", vt, flags);
+ vt_flags = vt | flags;
+ append_data(data, &vt_flags, sizeof(vt_flags));
+
+ if (vt == VT_USERDEFINED)
+ {
+ short href;
+
+ while (type->typelib_idx < 0 && type_is_alias(type))
+ type = type_alias_get_aliasee_type(type);
+
+ chat("write_var_desc: VT_USERDEFINED, type %p, name %s, real type %d, href %d\n",
+ type, type->name, type_get_type(type), type->typelib_idx);
+
+ if (type->typelib_idx == -1)
+ error("write_var_desc: trying to ref not added type\n");
+
+ href = local_href(hrefmap, type->typelib_idx);
+ chat("write_var_desc: VT_USERDEFINED, local href %d\n", href);
+
+ append_data(data, &href, sizeof(href));
+ }
+
if (size_instance)
*size_instance += get_element_size(type);
- vt |= flags;
- append_data(data, &vt, sizeof(vt));
-
return desc_offset;
}
-static void add_structure_typeinfo(struct sltg_typelib *typelib, const type_t *type)
+static void add_structure_typeinfo(struct sltg_typelib *typelib, type_t *type)
{
struct sltg_data data, *var_data = NULL;
+ struct sltg_hrefmap hrefmap;
const char *index_name;
struct sltg_typeinfo_header ti;
struct sltg_member_header member;
@@ -683,15 +857,17 @@ static void add_structure_typeinfo(struct sltg_typelib *typelib, const type_t *t
int member_offset, var_count = 0, var_data_size = 0, size_instance = 0;
short *type_desc_offset = NULL;
- chat("add_structure_typeinfo: %s\n", type->name);
+ chat("add_structure_typeinfo: type %p, type->name %s\n", type, type->name);
+
+ type->typelib_idx = typelib->n_file_blocks;
+
+ hrefmap.href_count = 0;
+ hrefmap.href = NULL;
init_sltg_data(&data);
index_name = add_typeinfo_block(typelib, type, TKIND_RECORD);
- init_typeinfo(&ti, type, TKIND_RECORD);
- append_data(&data, &ti, sizeof(ti));
-
if (type_struct_get_fields(type))
{
int i = 0;
@@ -712,7 +888,7 @@ static void add_structure_typeinfo(struct sltg_typelib *typelib, const type_t *t
init_sltg_data(&var_data[i]);
base_offset = var_data_size + (i + 1) * sizeof(struct sltg_variable);
- type_desc_offset[i] = write_var_desc(&var_data[i], var->declspec.type, 0, base_offset, &size_instance);
+ type_desc_offset[i] = write_var_desc(&var_data[i], var->declspec.type, 0, base_offset, &size_instance, &hrefmap);
dump_var_desc(var_data[i].data, var_data[i].size);
if (var_data[i].size > sizeof(short))
@@ -721,6 +897,11 @@ static void add_structure_typeinfo(struct sltg_typelib *typelib, const type_t *t
}
}
+ init_typeinfo(&ti, type, TKIND_RECORD, &hrefmap);
+ append_data(&data, &ti, sizeof(ti));
+
+ write_hrefmap(&data, &hrefmap);
+
member_offset = data.size;
member.res00 = 0x0001;
--
2.17.1

View File

@ -1,89 +0,0 @@
From 42f5da70a5224b25d783ee628b18adc856d2eac4 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Wed, 13 Jan 2016 16:25:00 +0800
Subject: widl: Factor out SLTG tail initialization.
---
tools/widl/write_sltg.c | 56 +++++++++++++++++++++++++++++--------------------
1 file changed, 33 insertions(+), 23 deletions(-)
diff --git a/tools/widl/write_sltg.c b/tools/widl/write_sltg.c
index dbe75c6..b417dc2 100644
--- a/tools/widl/write_sltg.c
+++ b/tools/widl/write_sltg.c
@@ -555,6 +555,37 @@ static void init_typeinfo(struct sltg_typeinfo_header *ti, const type_t *type, i
}
}
+static void init_sltg_tail(struct sltg_tail *tail)
+{
+ tail->cFuncs = 0;
+ tail->cVars = 0;
+ tail->cImplTypes = 0;
+ tail->res06 = 0;
+ tail->funcs_off = -1;
+ tail->vars_off = 0;
+ tail->impls_off = -1;
+ tail->funcs_bytes = -1;
+ tail->vars_bytes = 0;
+ tail->impls_bytes = -1;
+ tail->tdescalias_vt = -1;
+ tail->res16 = -1;
+ tail->res18 = 0;
+ tail->res1a = 0;
+ tail->simple_alias = 0;
+ tail->res1e = 0;
+ tail->cbSizeInstance = 0;
+ tail->cbAlignment = 4;
+ tail->res24 = -1;
+ tail->res26 = -1;
+ tail->cbSizeVft = 0;
+ tail->res2a = -1;
+ tail->res2c = -1;
+ tail->res2e = -1;
+ tail->res30 = -1;
+ tail->res32 = 0;
+ tail->type_bytes = 0;
+}
+
static void write_hrefmap(struct sltg_data *data, const struct sltg_hrefmap *hrefmap)
{
struct sltg_hrefinfo hrefinfo;
@@ -953,32 +984,11 @@ static void add_structure_typeinfo(struct sltg_typelib *typelib, type_t *type)
}
}
- tail.cFuncs = 0;
+ init_sltg_tail(&tail);
+
tail.cVars = var_count;
- tail.cImplTypes = 0;
- tail.res06 = 0;
- tail.funcs_off = -1;
- tail.vars_off = 0;
- tail.impls_off = -1;
- tail.funcs_bytes = -1;
tail.vars_bytes = var_data_size;
- tail.impls_bytes = -1;
- tail.tdescalias_vt = -1;
- tail.res16 = -1;
- tail.res18 = 0;
- tail.res1a = 0;
- tail.simple_alias = 0;
- tail.res1e = 0;
tail.cbSizeInstance = size_instance;
- tail.cbAlignment = 4;
- tail.res24 = -1;
- tail.res26 = -1;
- tail.cbSizeVft = 0;
- tail.res2a = -1;
- tail.res2c = -1;
- tail.res2e = -1;
- tail.res30 = -1;
- tail.res32 = 0;
tail.type_bytes = data.size - member_offset - sizeof(member);
append_data(&data, &tail, sizeof(tail));
--
2.6.4

View File

@ -1,74 +0,0 @@
From 1182a02286e99d3521b95c3196beda99173ee393 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Wed, 20 Jan 2016 14:26:48 +0800
Subject: [PATCH] widl: Fix generation of resources containing an old typelib.
---
tools/widl/register.c | 7 ++++++-
tools/widl/widl.c | 5 +++--
tools/widl/widl.h | 1 +
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/tools/widl/register.c b/tools/widl/register.c
index 210fb74..1987ccf 100644
--- a/tools/widl/register.c
+++ b/tools/widl/register.c
@@ -286,7 +286,12 @@ void write_typelib_regscript( const statement_list_t *stmts )
if (count && !strendswith( typelib_name, ".res" ))
error( "Cannot store multiple typelibs into %s\n", typelib_name );
else
- create_msft_typelib( stmt->u.lib );
+ {
+ if (do_old_typelib)
+ create_sltg_typelib( stmt->u.lib );
+ else
+ create_msft_typelib( stmt->u.lib );
+ }
count++;
}
if (count && strendswith( typelib_name, ".res" )) flush_output_resources( typelib_name );
diff --git a/tools/widl/widl.c b/tools/widl/widl.c
index 1180e65..afeea39 100644
--- a/tools/widl/widl.c
+++ b/tools/widl/widl.c
@@ -103,6 +103,7 @@ int do_everything = 1;
static int preprocess_only = 0;
int do_header = 0;
int do_typelib = 0;
+int do_old_typelib = 0;
int do_proxies = 0;
int do_client = 0;
int do_server = 0;
@@ -308,6 +309,7 @@ static void set_everything(int x)
{
do_header = x;
do_typelib = x;
+ do_old_typelib = x;
do_proxies = x;
do_client = x;
do_server = x;
@@ -682,8 +684,7 @@ int main(int argc,char *argv[])
do_typelib = 1;
break;
case OLD_TYPELIB_OPTION:
- do_everything = 0;
- do_typelib = 2;
+ do_old_typelib = 1;
break;
case 'T':
typelib_name = xstrdup(optarg);
diff --git a/tools/widl/widl.h b/tools/widl/widl.h
index 7530f9f..73b9152 100644
--- a/tools/widl/widl.h
+++ b/tools/widl/widl.h
@@ -38,6 +38,7 @@ extern int pedantic;
extern int do_everything;
extern int do_header;
extern int do_typelib;
+extern int do_old_typelib;
extern int do_proxies;
extern int do_client;
extern int do_server;
--
1.9.1

View File

@ -1,24 +0,0 @@
From d2ba2796fbd8f9d107f5f3814ddc405713ca5a70 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Thu, 21 Jan 2016 02:51:56 +0100
Subject: [PATCH] widl: Add --oldtlb switch in usage message.
---
tools/widl/widl.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/widl/widl.c b/tools/widl/widl.c
index cf59d7513cb..611735fcae7 100644
--- a/tools/widl/widl.c
+++ b/tools/widl/widl.c
@@ -63,6 +63,7 @@ static const char usage[] =
" --nostdinc Do not search the standard include path\n"
" --ns_prefix Prefix namespaces with ABI namespace\n"
" --oldnames Use old naming conventions\n"
+" --oldtlb Use old typelib (SLTG) format\n"
" -o, --output=NAME Set the output file name\n"
" -Otype Type of stubs to generate (-Os, -Oi, -Oif)\n"
" -p Generate proxy\n"
--
2.24.0.rc1

View File

@ -1,39 +0,0 @@
From 3ad26c39f490daab83f32e87ec6b1b32a27f1bfa Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 28 Jan 2016 15:36:12 +0800
Subject: widl: Minor/cosmetic clean up.
---
tools/widl/write_sltg.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/tools/widl/write_sltg.c b/tools/widl/write_sltg.c
index 3cb137c..04313e6 100644
--- a/tools/widl/write_sltg.c
+++ b/tools/widl/write_sltg.c
@@ -298,9 +298,9 @@ static int add_name(struct sltg_typelib *sltg, const char *name)
else
new_size = (new_size + 1) & ~1;
- if (aligned_size > sltg->name_table.allocated)
+ if (new_size > sltg->name_table.allocated)
{
- sltg->name_table.allocated = max(sltg->name_table.allocated * 2, aligned_size);
+ sltg->name_table.allocated = max(sltg->name_table.allocated * 2, new_size);
sltg->name_table.data = xrealloc(sltg->name_table.data, sltg->name_table.allocated);
}
@@ -889,9 +889,8 @@ static short write_var_desc(struct sltg_typelib *typelib, struct sltg_data *data
{
chat("write_var_desc: vt VT_PTR | 0x0400 | %04x\n", param_flags);
vt = VT_PTR | 0x0400 | param_flags;
- param_flags = 0;
append_data(data, &vt, sizeof(vt));
- write_var_desc(typelib, data, ref, param_flags, 0, base_offset, size_instance, hrefmap);
+ write_var_desc(typelib, data, ref, 0, 0, base_offset, size_instance, hrefmap);
}
else
write_var_desc(typelib, data, ref, param_flags, 0x0e00, base_offset, size_instance, hrefmap);
--
2.6.4