widl-SLTG_Typelib_Support: Set the lowest bit in the param name to indicate whether type description follows the name.

This commit is contained in:
Sebastian Lackner 2016-01-25 21:10:04 +01:00
parent 5e7f75370b
commit cd8442e4c4
4 changed files with 112 additions and 64 deletions

View File

@ -6025,7 +6025,8 @@ if test "$enable_widl_SLTG_Typelib_Support" -eq 1; then
patch_apply widl-SLTG_Typelib_Support/0017-widl-Fix-generation-of-resources-containing-an-old-t.patch
patch_apply widl-SLTG_Typelib_Support/0018-widl-Add-oldtlb-switch-in-usage-message.patch
patch_apply widl-SLTG_Typelib_Support/0019-widl-Avoid-relying-on-side-effects-when-marking-func.patch
patch_apply widl-SLTG_Typelib_Support/0020-oleaut32-Fix-logic-for-deciding-whether-type-descrip.patch
patch_apply widl-SLTG_Typelib_Support/0020-widl-Set-the-lowest-bit-in-the-param-name-to-indicat.patch
patch_apply widl-SLTG_Typelib_Support/0021-oleaut32-Fix-logic-for-deciding-whether-type-descrip.patch
(
echo '+ { "Dmitry Timoshkov", "widl: Add initial implementation of SLTG typelib generator.", 1 },';
echo '+ { "Dmitry Timoshkov", "widl: Add support for structures.", 1 },';
@ -6046,7 +6047,8 @@ if test "$enable_widl_SLTG_Typelib_Support" -eq 1; then
echo '+ { "Dmitry Timoshkov", "widl: Fix generation of resources containing an old typelib.", 1 },';
echo '+ { "Sebastian Lackner", "widl: Add --oldtlb switch in usage message.", 1 },';
echo '+ { "Dmitry Timoshkov", "widl: Avoid relying on side effects when marking function index as the last one.", 1 },';
echo '+ { "Dmitry Timoshkov", "oleaut32: Fix logic for deciding whether type description follows the name.", 1 },';
echo '+ { "Dmitry Timoshkov", "widl: Set the lowest bit in the param name to indicate whether type description follows the name.", 1 },';
echo '+ { "Dmitry Timoshkov", "oleaut32: Fix logic for deciding whether type description follows the name.", 2 },';
) >> "$patchlist"
fi

View File

@ -1,62 +0,0 @@
From 80f3b9c3935baba1bbf2ba730a30f9364105ace8 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Wed, 20 Jan 2016 14:04:08 +0800
Subject: oleaut32: Fix logic for deciding whether type description follows the
name.
This makes it possible to load an SLTG typelib generated by widl.
---
dlls/oleaut32/typelib.c | 28 ++++++++--------------------
1 file changed, 8 insertions(+), 20 deletions(-)
diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c
index 0a83b79..e5d8708 100644
--- a/dlls/oleaut32/typelib.c
+++ b/dlls/oleaut32/typelib.c
@@ -4216,35 +4216,23 @@ static void SLTG_DoFuncs(char *pBlk, char *pFirstItem, ITypeInfoImpl *pTI,
for(param = 0; param < pFuncDesc->funcdesc.cParams; param++) {
char *paramName = pNameTable + *pArg;
BOOL HaveOffs;
- /* If arg type follows then paramName points to the 2nd
- letter of the name, else the next WORD is an offset to
- the arg type and paramName points to the first letter.
- So let's take one char off paramName and see if we're
- pointing at an alpha-numeric char. However if *pArg is
- 0xffff or 0xfffe then the param has no name, the former
- meaning that the next WORD is the type, the latter
- meaning that the next WORD is an offset to the type. */
-
- HaveOffs = FALSE;
- if(*pArg == 0xffff)
- paramName = NULL;
- else if(*pArg == 0xfffe) {
- paramName = NULL;
- HaveOffs = TRUE;
- }
- else if(paramName[-1] && !isalnum(paramName[-1]))
- HaveOffs = TRUE;
+
+ TRACE_(typelib)("param %d: paramName %s, pArg %p, *pArg %#x\n",
+ param, debugstr_a(paramName), pArg, *pArg);
pArg++;
+ if (*pArg & 0xff00 || (WORD*)(pBlk + *pArg) < pArg)
+ HaveOffs = FALSE; /* type follows */
+ else
+ HaveOffs = TRUE;
+
if(HaveOffs) { /* the next word is an offset to type */
pType = (WORD*)(pBlk + *pArg);
SLTG_DoElem(pType, pBlk,
&pFuncDesc->funcdesc.lprgelemdescParam[param], ref_lookup);
pArg++;
} else {
- if(paramName)
- paramName--;
pArg = SLTG_DoElem(pArg, pBlk,
&pFuncDesc->funcdesc.lprgelemdescParam[param], ref_lookup);
}
--
2.6.4

View File

@ -0,0 +1,45 @@
From f52df44c1930e62fa9096f24ba8b1b84765c0e34 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Mon, 25 Jan 2016 15:05:03 +0800
Subject: widl: Set the lowest bit in the param name to indicate whether type
description follows the name.
It looks like the lowest bit in the param name offset actually indicates
whether type description follows the name, and since the name offsets are
always aligned that makes sense.
This makes oleview.exe from PSDK running under Windows7 correctly show mix
of different very complex and relatively simple type descriptions generated
by widl's SLTG generator.
---
tools/widl/write_sltg.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/widl/write_sltg.c b/tools/widl/write_sltg.c
index acfc039..2ec1770 100644
--- a/tools/widl/write_sltg.c
+++ b/tools/widl/write_sltg.c
@@ -1307,7 +1307,6 @@ static int add_func_desc(struct sltg_typelib *typelib, struct sltg_data *data, v
short name, type_offset;
name = base_offset != -1 ? add_name(typelib, arg->name) : -1;
- append_data(data, &name, sizeof(name));
if (arg_data[i].size > sizeof(short))
{
@@ -1315,8 +1314,12 @@ static int add_func_desc(struct sltg_typelib *typelib, struct sltg_data *data, v
arg_offset += arg_data[i].size;
}
else
+ {
+ name |= 1;
type_offset = *(short *)arg_data[i].data;
+ }
+ append_data(data, &name, sizeof(name));
append_data(data, &type_offset, sizeof(type_offset));
if (base_offset != -1)
--
2.6.4

View File

@ -0,0 +1,63 @@
From ed5f6c45666a220fd9f2532d0ab55bc9e4e7054c Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Wed, 20 Jan 2016 14:04:08 +0800
Subject: oleaut32: Fix logic for deciding whether type description follows the
name (v2).
This makes it possible to load an SLTG typelib generated by widl.
It looks like the lowest bit actually indicates whether type description
follows the name, and since the name offsets are always aligned that makes
sense.
---
dlls/oleaut32/typelib.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c
index 0a83b79..d8d8ec8 100644
--- a/dlls/oleaut32/typelib.c
+++ b/dlls/oleaut32/typelib.c
@@ -4214,7 +4214,7 @@ static void SLTG_DoFuncs(char *pBlk, char *pFirstItem, ITypeInfoImpl *pTI,
pArg = (WORD*)(pBlk + pFunc->arg_off);
for(param = 0; param < pFuncDesc->funcdesc.cParams; param++) {
- char *paramName = pNameTable + *pArg;
+ char *paramName = pNameTable + (*pArg & ~1);
BOOL HaveOffs;
/* If arg type follows then paramName points to the 2nd
letter of the name, else the next WORD is an offset to
@@ -4225,26 +4225,21 @@ static void SLTG_DoFuncs(char *pBlk, char *pFirstItem, ITypeInfoImpl *pTI,
meaning that the next WORD is the type, the latter
meaning that the next WORD is an offset to the type. */
- HaveOffs = FALSE;
- if(*pArg == 0xffff)
+ if(*pArg == 0xffff || *pArg == 0xfffe)
paramName = NULL;
- else if(*pArg == 0xfffe) {
- paramName = NULL;
- HaveOffs = TRUE;
- }
- else if(paramName[-1] && !isalnum(paramName[-1]))
- HaveOffs = TRUE;
+ HaveOffs = !(*pArg & 1);
pArg++;
+ TRACE_(typelib)("param %d: paramName %s, *pArg %#x\n",
+ param, debugstr_a(paramName), *pArg);
+
if(HaveOffs) { /* the next word is an offset to type */
pType = (WORD*)(pBlk + *pArg);
SLTG_DoElem(pType, pBlk,
&pFuncDesc->funcdesc.lprgelemdescParam[param], ref_lookup);
pArg++;
} else {
- if(paramName)
- paramName--;
pArg = SLTG_DoElem(pArg, pBlk,
&pFuncDesc->funcdesc.lprgelemdescParam[param], ref_lookup);
}
--
2.6.4