widl #36: property function fixes
Huw D M Davies
h.davies1 at physics.ox.ac.uk
Fri Feb 4 06:59:07 CST 2005
Huw Davies <huw at codeweavers.com>
Add VARIANT_BOOL
Fix CURRENCY alignment
A function with a [retval] param has a bit set in the FKCCIC
bitfield
Two functions with the same name share the same id
The param names of propput and propputref functions don't go
into the typelib.
--
Huw Davies
huw at codeweavers.com
Index: tools/widl/typelib.c
===================================================================
RCS file: /home/wine/wine/tools/widl/typelib.c,v
retrieving revision 1.12
diff -u -p -r1.12 typelib.c
--- tools/widl/typelib.c 3 Feb 2005 13:34:28 -0000 1.12
+++ tools/widl/typelib.c 4 Feb 2005 12:53:05 -0000
@@ -45,15 +45,16 @@ static struct oatype {
const char *kw;
unsigned short vt;
} oatypes[] = {
- {"BSTR", VT_BSTR},
- {"CURRENCY", VT_CY},
- {"DATE", VT_DATE},
- {"DECIMAL", VT_DECIMAL},
- {"HRESULT", VT_HRESULT},
- {"LPSTR", VT_LPSTR},
- {"LPWSTR", VT_LPWSTR},
- {"SCODE", VT_ERROR},
- {"VARIANT", VT_VARIANT}
+ {"BSTR", VT_BSTR},
+ {"CURRENCY", VT_CY},
+ {"DATE", VT_DATE},
+ {"DECIMAL", VT_DECIMAL},
+ {"HRESULT", VT_HRESULT},
+ {"LPSTR", VT_LPSTR},
+ {"LPWSTR", VT_LPWSTR},
+ {"SCODE", VT_ERROR},
+ {"VARIANT", VT_VARIANT},
+ {"VARIANT_BOOL", VT_BOOL}
};
#define NTYPES (sizeof(oatypes)/sizeof(oatypes[0]))
#define KWP(p) ((const struct oatype *)(p))
Index: tools/widl/typelib_struct.h
===================================================================
RCS file: /home/wine/wine/tools/widl/typelib_struct.h,v
retrieving revision 1.5
diff -u -p -r1.5 typelib_struct.h
--- tools/widl/typelib_struct.h 1 Feb 2005 18:48:25 -0000 1.5
+++ tools/widl/typelib_struct.h 4 Feb 2005 12:53:05 -0000
@@ -182,6 +182,7 @@ typedef struct {
/* bits 8 - 11: CALLCONV */
/* bit 12: parameters have default values */
/* bit 13: oEntry is numeric */
+ /* bit 14: has retval param */
/* bits 16 - 31: index of next function with same id */
#ifdef WORDS_BIGENDIAN
INT16 nroargs; /* nr of optional arguments */
Index: tools/widl/write_msft.c
===================================================================
RCS file: /home/wine/wine/tools/widl/write_msft.c,v
retrieving revision 1.29
diff -u -p -r1.29 write_msft.c
--- tools/widl/write_msft.c 3 Feb 2005 13:34:28 -0000 1.29
+++ tools/widl/write_msft.c 4 Feb 2005 12:53:05 -0000
@@ -758,7 +758,7 @@ static int encode_type(
case VT_CY:
*encoded_type = default_type;
*width = 8;
- *alignment = 4; /* guess? */
+ *alignment = 8;
break;
case VT_VOID:
@@ -1151,7 +1151,7 @@ static HRESULT set_custdata(msft_typelib
static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, func_t *func, int index)
{
- int offset;
+ int offset, name_offset;
int *typedata, typedata_size;
int i, id, next_idx;
int decoded_size, extra_attr = 0;
@@ -1190,6 +1190,8 @@ static HRESULT add_func_desc(msft_typein
chat("add_func_desc: num of params %d\n", num_params);
+ name_offset = ctl2_alloc_name(typeinfo->typelib, func->def->name);
+
for(attr = func->def->attrs; attr; attr = NEXT_LINK(attr)) {
expr_t *expr = attr->u.pval;
switch(attr->type) {
@@ -1233,7 +1235,8 @@ static HRESULT add_func_desc(msft_typein
switch(invokekind) {
case 0x2: /* INVOKE_PROPERTYGET */
- if(num_params != 0) {
+ if((num_params != 0 && (typeinfo->typeinfo->typekind & 15) == TKIND_DISPATCH)
+ || (num_params != 1 && (typeinfo->typeinfo->typekind & 15) == TKIND_INTERFACE)) {
error("expecting no args on a propget func\n");
return S_FALSE;
}
@@ -1268,6 +1271,15 @@ static HRESULT add_func_desc(msft_typein
typeinfo->func_data[0] += typedata_size;
typedata = typeinfo->func_data + (offset >> 2) + 1;
+
+ /* find func with the same name - if it exists use its id */
+ for(i = 0; i < (typeinfo->typeinfo->cElement & 0xffff); i++) {
+ if(name_offset == typeinfo->func_names[i]) {
+ id = typeinfo->func_indices[i];
+ break;
+ }
+ }
+
/* find the first func with the same id and link via the hiword of typedata[4] */
next_idx = index;
for(i = 0; i < (typeinfo->typeinfo->cElement & 0xffff); i++) {
@@ -1344,6 +1356,7 @@ static HRESULT add_func_desc(msft_typein
break;
case ATTR_RETVAL:
paramflags |= 0x08; /* PARAMFLAG_FRETVAL */
+ typedata[4] |= 0x4000;
break;
default:
chat("unhandled param attr %d\n", attr->type);
@@ -1371,9 +1384,7 @@ static HRESULT add_func_desc(msft_typein
/* update the index data */
typeinfo->func_indices[typeinfo->typeinfo->cElement & 0xffff] = id;
typeinfo->func_offsets[typeinfo->typeinfo->cElement & 0xffff] = offset;
-
- offset = ctl2_alloc_name(typeinfo->typelib, func->def->name);
- typeinfo->func_names[typeinfo->typeinfo->cElement & 0xffff] = offset;
+ typeinfo->func_names[typeinfo->typeinfo->cElement & 0xffff] = name_offset;
/* ??? */
if (!typeinfo->typeinfo->res2) typeinfo->typeinfo->res2 = 0x20;
@@ -1391,13 +1402,14 @@ static HRESULT add_func_desc(msft_typein
/* Increment the number of function elements */
typeinfo->typeinfo->cElement += 1;
- namedata = typeinfo->typelib->typelib_segment_data[MSFT_SEG_NAME] + offset;
+ namedata = typeinfo->typelib->typelib_segment_data[MSFT_SEG_NAME] + name_offset;
if (*((INT *)namedata) == -1) {
*((INT *)namedata) = typeinfo->typelib->typelib_typeinfo_offsets[typeinfo->typeinfo->typekind >> 16];
namedata[9] &= ~0x10;
}
- if(invokekind == 0x1 /* INVOKE_FUNC */) { /* don't give the arg of a [prop*] func a name */
+ if(invokekind != 0x4 /* INVOKE_PROPERTYPUT */ && invokekind != 0x8 /* INVOKE_PROPERTYPUTREF */) {
+ /* don't give the arg of a [propput*] func a name */
for (arg = last_arg, i = 0; arg; arg = PREV_LINK(arg), i++) {
int *paramdata = typedata + 6 + extra_attr + (num_defaults ? num_params : 0) + i * 3;
offset = ctl2_alloc_name(typeinfo->typelib, arg->name);
More information about the wine-patches
mailing list