Type library creation, take 2, part 5 of 5

Nyef nyef at softhome.net
Mon Jan 26 11:16:41 CST 2004


Hello all.

Attached is the fifth of five patches against typelib2.c covering
the just over two weeks of work done since the original patch.

This patch contains:

  Support for recording the SYSKIND of the type library.
  Fixes for ICreateTypeInfo2_fnSetGuid() to record the typeinfo
offset in the GUID structure and to record the position of
IDispatch in the header if it is set as a TypeInfo GUID.
  Preliminary implementation of ICreateTypeInfo2_fnAddImplType().
  Preliminary implementation of ICreateTypeInfo2_fnSetAlignment().
  Preliminary implementation of ICreateTypeInfo2_fnSetTypeDescAlias().

--Alastair Bridgewater
-------------- next part --------------
--- typelib2.c.last	2004-01-26 11:28:31.000000000 -0500
+++ typelib2.c	2004-01-26 11:44:43.000000000 -0500
@@ -181,7 +181,7 @@
     This->typelib_header.posguid = -1;
     This->typelib_header.lcid = 0x0409; /* or do we use the current one? */
     This->typelib_header.lcid2 = 0x0409;
-    This->typelib_header.varflags = 0x41;
+    This->typelib_header.varflags = 0x40;
     This->typelib_header.version = 0;
     This->typelib_header.flags = 0;
     This->typelib_header.nrtypeinfos = 0;
@@ -953,8 +953,8 @@
     TRACE("(%p,%s)\n", iface, debugstr_guid(guid));
 
     guidentry.guid = *guid;
-    guidentry.unk10 = 0;
-    guidentry.unk14 = 0x18;
+    guidentry.unk10 = This->typelib->typelib_typeinfo_offsets[This->typeinfo->typekind >> 16];
+    guidentry.unk14 = -1;
 
     offset = ctl2_alloc_guid(This->typelib, &guidentry);
     
@@ -962,6 +962,10 @@
 
     This->typeinfo->posguid = offset;
 
+    if (IsEqualIID(guid, &IID_IDispatch)) {
+	This->typelib->typelib_header.dispatchpos = This->typelib->typelib_typeinfo_offsets[This->typeinfo->typekind >> 16];
+    }
+
     return S_OK;
 }
 
@@ -1205,8 +1209,18 @@
         UINT index,
         HREFTYPE hRefType)
 {
+    ICOM_THIS(ICreateTypeInfo2Impl, iface);
+
     FIXME("(%p,%d,%ld), stub!\n", iface, index, hRefType);
-    return E_OUTOFMEMORY;
+
+    /* Inherited interface case only for now */
+    This->typeinfo->cImplTypes++;
+    This->typeinfo->cbSizeVft += 0x0c; /* hack */
+    This->typeinfo->datatype1 = hRefType;
+    This->typeinfo->datatype2 = (3 << 16) | 1; /* ? */
+
+/*     return E_OUTOFMEMORY; */
+    return S_OK;
 }
 
 /******************************************************************************
@@ -1232,8 +1246,19 @@
         ICreateTypeInfo2* iface,
         WORD cbAlignment)
 {
-    FIXME("(%p,%d), stub!\n", iface, cbAlignment);
-    return E_OUTOFMEMORY;
+    ICOM_THIS(ICreateTypeInfo2Impl, iface);
+
+    TRACE("(%p,%d)\n", iface, cbAlignment);
+
+    if (cbAlignment == 1) {
+	This->typeinfo->typekind &= ~0xf900;
+	This->typeinfo->typekind |= (cbAlignment << 11) | 0x40;
+    } else {
+	This->typeinfo->typekind &= ~0xf800;
+	This->typeinfo->typekind |= (cbAlignment << 11);
+    }
+
+    return S_OK;
 }
 
 /******************************************************************************
@@ -1424,8 +1449,24 @@
         ICreateTypeInfo2* iface,
         TYPEDESC* pTDescAlias)
 {
-    FIXME("(%p,%p), stub!\n", iface, pTDescAlias);
-    return E_OUTOFMEMORY;
+    ICOM_THIS(ICreateTypeInfo2Impl, iface);
+
+    int encoded_typedesc;
+
+    if ((This->typeinfo->typekind & 15) != TKIND_ALIAS) {
+	return TYPE_E_WRONGTYPEKIND;
+    }
+
+    FIXME("(%p,%p), hack!\n", iface, pTDescAlias);
+
+    /* FIXME: In the one case for this we have, it mis-encodes the typedesc. */
+    if (ctl2_encode_typedesc(This->typelib, pTDescAlias, &encoded_typedesc, NULL, NULL, NULL) == -1) {
+	return E_OUTOFMEMORY;
+    }
+
+    This->typeinfo->datatype1 = encoded_typedesc;
+
+    return S_OK;
 }
 
 /******************************************************************************
@@ -3098,6 +3139,8 @@
     ctl2_init_header(pCreateTypeLib2Impl);
     ctl2_init_segdir(pCreateTypeLib2Impl);
 
+    pCreateTypeLib2Impl->typelib_header.varflags |= syskind;
+
     /*
      * The following two calls return an offset or -1 if out of memory. We
      * specifically need an offset of 0, however, so...


More information about the wine-patches mailing list