4 * Copyright 2004 Alastair Bridgewater
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * --------------------------------------------------------------------------------------
25 * Only works on little-endian systems.
30 #include "wine/port.h"
39 #define NONAMELESSUNION
40 #define NONAMELESSSTRUCT
48 #include "wine/unicode.h"
51 #include "wine/debug.h"
53 WINE_DEFAULT_DEBUG_CHANNEL(typelib2
);
54 /* WINE_DEFAULT_DEBUG_CHANNEL(ole); */
57 /******************************************************************************
58 * ICreateTypeLib2 {OLEAUT32}
61 * The ICreateTypeLib2 interface provides an interface whereby one may create
62 * new type library (.tlb) files.
64 * This interface inherits from ICreateTypeLib, and can be freely cast back
65 * and forth between an ICreateTypeLib and an ICreateTypeLib2 on local clients.
66 * This dispensation applies only to ICreateTypeLib objects obtained on MSFT
67 * format type libraries (those made through CreateTypeLib2).
72 /******************************************************************************
73 * ICreateTypeInfo2 {OLEAUT32}
76 * The ICreateTypeInfo2 interface provides an interface whereby one may add
77 * type information to type library (.tlb) files.
79 * This interface inherits from ICreateTypeInfo, and can be freely cast back
80 * and forth between an ICreateTypeInfo and an ICreateTypeInfo2 on local clients.
81 * This dispensation applies only to ICreateTypeInfo objects obtained on MSFT
82 * format type libraries (those made through CreateTypeLib2).
87 /******************************************************************************
88 * ITypeLib2 {OLEAUT32}
91 * The ITypeLib2 interface provides an interface whereby one may query MSFT
92 * format type library (.tlb) files.
94 * This interface inherits from ITypeLib, and can be freely cast back and
95 * forth between an ITypeLib and an ITypeLib2 on local clients. This
96 * dispensation applies only to ITypeLib objects obtained on MSFT format type
97 * libraries (those made through CreateTypeLib2).
102 /******************************************************************************
103 * ITypeInfo2 {OLEAUT32}
106 * The ITypeInfo2 interface provides an interface whereby one may query type
107 * information stored in MSFT format type library (.tlb) files.
109 * This interface inherits from ITypeInfo, and can be freely cast back and
110 * forth between an ITypeInfo and an ITypeInfo2 on local clients. This
111 * dispensation applies only to ITypeInfo objects obtained on MSFT format type
112 * libraries (those made through CreateTypeLib2).
117 /*================== Implementation Structures ===================================*/
119 enum MSFT_segment_index
{
120 MSFT_SEG_TYPEINFO
= 0, /* type information */
121 MSFT_SEG_IMPORTINFO
, /* import information */
122 MSFT_SEG_IMPORTFILES
, /* import filenames */
123 MSFT_SEG_REFERENCES
, /* references (?) */
124 MSFT_SEG_GUIDHASH
, /* hash table for guids? */
125 MSFT_SEG_GUID
, /* guid storage */
126 MSFT_SEG_NAMEHASH
, /* hash table for names */
127 MSFT_SEG_NAME
, /* name storage */
128 MSFT_SEG_STRING
, /* string storage */
129 MSFT_SEG_TYPEDESC
, /* type descriptions */
130 MSFT_SEG_ARRAYDESC
, /* array descriptions */
131 MSFT_SEG_CUSTDATA
, /* custom data */
132 MSFT_SEG_CUSTDATAGUID
, /* custom data guids */
133 MSFT_SEG_UNKNOWN
, /* ??? */
134 MSFT_SEG_UNKNOWN2
, /* ??? */
135 MSFT_SEG_MAX
/* total number of segments */
138 typedef struct tagMSFT_ImpFile
{
142 char filename
[0]; /* preceded by two bytes of encoded (length << 2) + flags in the low two bits. */
145 typedef struct tagICreateTypeLib2Impl
147 const ICreateTypeLib2Vtbl
*lpVtbl
;
148 const ITypeLib2Vtbl
*lpVtblTypeLib2
;
154 MSFT_Header typelib_header
;
155 MSFT_pSeg typelib_segdir
[MSFT_SEG_MAX
];
156 char *typelib_segment_data
[MSFT_SEG_MAX
];
157 int typelib_segment_block_length
[MSFT_SEG_MAX
];
159 INT typelib_typeinfo_offsets
[0x200]; /* Hope that's enough. */
161 INT
*typelib_namehash_segment
;
162 INT
*typelib_guidhash_segment
;
164 struct tagICreateTypeInfo2Impl
*typeinfos
;
165 struct tagICreateTypeInfo2Impl
*last_typeinfo
;
166 } ICreateTypeLib2Impl
;
168 static inline ICreateTypeLib2Impl
*impl_from_ITypeLib2( ITypeLib2
*iface
)
170 return (ICreateTypeLib2Impl
*)((char*)iface
- FIELD_OFFSET(ICreateTypeLib2Impl
, lpVtblTypeLib2
));
173 typedef struct tagICreateTypeInfo2Impl
175 const ICreateTypeInfo2Vtbl
*lpVtbl
;
176 const ITypeInfo2Vtbl
*lpVtblTypeInfo2
;
180 ICreateTypeLib2Impl
*typelib
;
181 MSFT_TypeInfoBase
*typeinfo
;
184 int typedata_allocated
;
193 struct tagICreateTypeInfo2Impl
*next_typeinfo
;
194 } ICreateTypeInfo2Impl
;
196 static inline ICreateTypeInfo2Impl
*impl_from_ITypeInfo2( ITypeInfo2
*iface
)
198 return (ICreateTypeInfo2Impl
*)((char*)iface
- FIELD_OFFSET(ICreateTypeInfo2Impl
, lpVtblTypeInfo2
));
201 static ULONG WINAPI
ICreateTypeLib2_fnRelease(ICreateTypeLib2
*iface
);
204 /*================== Internal functions ===================================*/
206 /****************************************************************************
209 * Initializes the type library header of a new typelib.
211 static void ctl2_init_header(
212 ICreateTypeLib2Impl
*This
) /* [I] The typelib to initialize. */
214 This
->typelib_header
.magic1
= 0x5446534d;
215 This
->typelib_header
.magic2
= 0x00010002;
216 This
->typelib_header
.posguid
= -1;
217 This
->typelib_header
.lcid
= This
->typelib_header
.lcid2
= GetUserDefaultLCID();
218 This
->typelib_header
.varflags
= 0x40;
219 This
->typelib_header
.version
= 0;
220 This
->typelib_header
.flags
= 0;
221 This
->typelib_header
.nrtypeinfos
= 0;
222 This
->typelib_header
.helpstring
= -1;
223 This
->typelib_header
.helpstringcontext
= 0;
224 This
->typelib_header
.helpcontext
= 0;
225 This
->typelib_header
.nametablecount
= 0;
226 This
->typelib_header
.nametablechars
= 0;
227 This
->typelib_header
.NameOffset
= -1;
228 This
->typelib_header
.helpfile
= -1;
229 This
->typelib_header
.CustomDataOffset
= -1;
230 This
->typelib_header
.res44
= 0x20;
231 This
->typelib_header
.res48
= 0x80;
232 This
->typelib_header
.dispatchpos
= -1;
233 This
->typelib_header
.nimpinfos
= 0;
236 /****************************************************************************
239 * Initializes the segment directory of a new typelib.
241 static void ctl2_init_segdir(
242 ICreateTypeLib2Impl
*This
) /* [I] The typelib to initialize. */
247 segdir
= &This
->typelib_segdir
[MSFT_SEG_TYPEINFO
];
249 for (i
= 0; i
< 15; i
++) {
250 segdir
[i
].offset
= -1;
251 segdir
[i
].length
= 0;
252 segdir
[i
].res08
= -1;
253 segdir
[i
].res0c
= 0x0f;
257 /****************************************************************************
260 * Generates a hash key from a GUID.
264 * The hash key for the GUID.
266 static int ctl2_hash_guid(
267 REFGUID guid
) /* [I] The guid to find. */
273 for (i
= 0; i
< 8; i
++) {
274 hash
^= ((const short *)guid
)[i
];
280 /****************************************************************************
283 * Locates a guid in a type library.
287 * The offset into the GUID segment of the guid, or -1 if not found.
289 static int ctl2_find_guid(
290 ICreateTypeLib2Impl
*This
, /* [I] The typelib to operate against. */
291 int hash_key
, /* [I] The hash key for the guid. */
292 REFGUID guid
) /* [I] The guid to find. */
295 MSFT_GuidEntry
*guidentry
;
297 offset
= This
->typelib_guidhash_segment
[hash_key
];
298 while (offset
!= -1) {
299 guidentry
= (MSFT_GuidEntry
*)&This
->typelib_segment_data
[MSFT_SEG_GUID
][offset
];
301 if (!memcmp(guidentry
, guid
, sizeof(GUID
))) return offset
;
303 offset
= guidentry
->next_hash
;
309 /****************************************************************************
312 * Locates a name in a type library.
316 * The offset into the NAME segment of the name, or -1 if not found.
320 * The name must be encoded as with ctl2_encode_name().
322 static int ctl2_find_name(
323 ICreateTypeLib2Impl
*This
, /* [I] The typelib to operate against. */
324 const char *name
) /* [I] The encoded name to find. */
329 offset
= This
->typelib_namehash_segment
[name
[2] & 0x7f];
330 while (offset
!= -1) {
331 namestruct
= (int *)&This
->typelib_segment_data
[MSFT_SEG_NAME
][offset
];
333 if (!((namestruct
[2] ^ *((const int *)name
)) & 0xffff00ff)) {
334 /* hash codes and lengths match, final test */
335 if (!strncasecmp(name
+4, (void *)(namestruct
+3), name
[0])) break;
338 /* move to next item in hash bucket */
339 offset
= namestruct
[1];
345 /****************************************************************************
348 * Encodes a name string to a form suitable for storing into a type library
349 * or comparing to a name stored in a type library.
353 * The length of the encoded name, including padding and length+hash fields.
357 * Will throw an exception if name or result are NULL. Is not multithread
358 * safe in the slightest.
360 static int ctl2_encode_name(
361 ICreateTypeLib2Impl
*This
, /* [I] The typelib to operate against (used for LCID only). */
362 const WCHAR
*name
, /* [I] The name string to encode. */
363 char **result
) /* [O] A pointer to a pointer to receive the encoded name. */
366 static char converted_name
[0x104];
370 length
= WideCharToMultiByte(CP_ACP
, 0, name
, strlenW(name
), converted_name
+4, 0x100, NULL
, NULL
);
371 converted_name
[0] = length
& 0xff;
373 converted_name
[length
+ 4] = 0;
375 converted_name
[1] = 0x00;
377 value
= LHashValOfNameSysA(This
->typelib_header
.varflags
& 0x0f, This
->typelib_header
.lcid
, converted_name
+ 4);
379 converted_name
[2] = value
;
380 converted_name
[3] = value
>> 8;
382 for (offset
= (4 - length
) & 3; offset
; offset
--) converted_name
[length
+ offset
+ 3] = 0x57;
384 *result
= converted_name
;
386 return (length
+ 7) & ~3;
389 /****************************************************************************
392 * Encodes a string to a form suitable for storing into a type library or
393 * comparing to a string stored in a type library.
397 * The length of the encoded string, including padding and length fields.
401 * Will throw an exception if string or result are NULL. Is not multithread
402 * safe in the slightest.
404 static int ctl2_encode_string(
405 ICreateTypeLib2Impl
*This
, /* [I] The typelib to operate against (not used?). */
406 const WCHAR
*string
, /* [I] The string to encode. */
407 char **result
) /* [O] A pointer to a pointer to receive the encoded string. */
410 static char converted_string
[0x104];
413 length
= WideCharToMultiByte(CP_ACP
, 0, string
, strlenW(string
), converted_string
+2, 0x102, NULL
, NULL
);
414 converted_string
[0] = length
& 0xff;
415 converted_string
[1] = (length
>> 8) & 0xff;
417 for (offset
= (4 - (length
+ 2)) & 3; offset
; offset
--) converted_string
[length
+ offset
+ 1] = 0x57;
419 *result
= converted_string
;
421 return (length
+ 5) & ~3;
424 /****************************************************************************
427 * Allocates memory from a segment in a type library.
431 * Success: The offset within the segment of the new data area.
432 * Failure: -1 (this is invariably an out of memory condition).
436 * Does not (yet) handle the case where the allocated segment memory needs to grow.
438 static int ctl2_alloc_segment(
439 ICreateTypeLib2Impl
*This
, /* [I] The type library in which to allocate. */
440 enum MSFT_segment_index segment
, /* [I] The segment in which to allocate. */
441 int size
, /* [I] The amount to allocate. */
442 int block_size
) /* [I] Initial allocation block size, or 0 for default. */
446 if(!This
->typelib_segment_data
[segment
]) {
447 if (!block_size
) block_size
= 0x2000;
449 This
->typelib_segment_block_length
[segment
] = block_size
;
450 This
->typelib_segment_data
[segment
] = HeapAlloc(GetProcessHeap(), 0, block_size
);
451 if (!This
->typelib_segment_data
[segment
]) return -1;
452 memset(This
->typelib_segment_data
[segment
], 0x57, block_size
);
455 while ((This
->typelib_segdir
[segment
].length
+ size
) > This
->typelib_segment_block_length
[segment
]) {
458 block_size
= This
->typelib_segment_block_length
[segment
];
459 block
= HeapReAlloc(GetProcessHeap(), 0, This
->typelib_segment_data
[segment
], block_size
<< 1);
460 if (!block
) return -1;
462 if (segment
== MSFT_SEG_TYPEINFO
) {
463 /* TypeInfos have a direct pointer to their memory space, so we have to fix them up. */
464 ICreateTypeInfo2Impl
*typeinfo
;
466 for (typeinfo
= This
->typeinfos
; typeinfo
; typeinfo
= typeinfo
->next_typeinfo
) {
467 typeinfo
->typeinfo
= (void *)&block
[((char *)typeinfo
->typeinfo
) - This
->typelib_segment_data
[segment
]];
471 memset(block
+ block_size
, 0x57, block_size
);
472 This
->typelib_segment_block_length
[segment
] = block_size
<< 1;
473 This
->typelib_segment_data
[segment
] = block
;
476 offset
= This
->typelib_segdir
[segment
].length
;
477 This
->typelib_segdir
[segment
].length
+= size
;
482 /****************************************************************************
483 * ctl2_alloc_typeinfo
485 * Allocates and initializes a typeinfo structure in a type library.
489 * Success: The offset of the new typeinfo.
490 * Failure: -1 (this is invariably an out of memory condition).
492 static int ctl2_alloc_typeinfo(
493 ICreateTypeLib2Impl
*This
, /* [I] The type library to allocate in. */
494 int nameoffset
) /* [I] The offset of the name for this typeinfo. */
497 MSFT_TypeInfoBase
*typeinfo
;
499 offset
= ctl2_alloc_segment(This
, MSFT_SEG_TYPEINFO
, sizeof(MSFT_TypeInfoBase
), 0);
500 if (offset
== -1) return -1;
502 This
->typelib_typeinfo_offsets
[This
->typelib_header
.nrtypeinfos
++] = offset
;
504 typeinfo
= (void *)(This
->typelib_segment_data
[MSFT_SEG_TYPEINFO
] + offset
);
506 typeinfo
->typekind
= (This
->typelib_header
.nrtypeinfos
- 1) << 16;
507 typeinfo
->memoffset
= -1; /* should be EOF if no elements */
512 typeinfo
->cElement
= 0;
517 typeinfo
->posguid
= -1;
519 typeinfo
->NameOffset
= nameoffset
;
520 typeinfo
->version
= 0;
521 typeinfo
->docstringoffs
= -1;
522 typeinfo
->helpstringcontext
= 0;
523 typeinfo
->helpcontext
= 0;
524 typeinfo
->oCustData
= -1;
525 typeinfo
->cbSizeVft
= 0;
526 typeinfo
->cImplTypes
= 0;
528 typeinfo
->datatype1
= -1;
529 typeinfo
->datatype2
= 0;
531 typeinfo
->res19
= -1;
536 /****************************************************************************
539 * Allocates and initializes a GUID structure in a type library. Also updates
540 * the GUID hash table as needed.
544 * Success: The offset of the new GUID.
545 * Failure: -1 (this is invariably an out of memory condition).
547 static int ctl2_alloc_guid(
548 ICreateTypeLib2Impl
*This
, /* [I] The type library to allocate in. */
549 MSFT_GuidEntry
*guid
) /* [I] The GUID to store. */
552 MSFT_GuidEntry
*guid_space
;
555 hash_key
= ctl2_hash_guid(&guid
->guid
);
557 offset
= ctl2_find_guid(This
, hash_key
, &guid
->guid
);
558 if (offset
!= -1) return offset
;
560 offset
= ctl2_alloc_segment(This
, MSFT_SEG_GUID
, sizeof(MSFT_GuidEntry
), 0);
561 if (offset
== -1) return -1;
563 guid_space
= (void *)(This
->typelib_segment_data
[MSFT_SEG_GUID
] + offset
);
566 guid_space
->next_hash
= This
->typelib_guidhash_segment
[hash_key
];
567 This
->typelib_guidhash_segment
[hash_key
] = offset
;
572 /****************************************************************************
575 * Allocates and initializes a name within a type library. Also updates the
576 * name hash table as needed.
580 * Success: The offset within the segment of the new name.
581 * Failure: -1 (this is invariably an out of memory condition).
583 static int ctl2_alloc_name(
584 ICreateTypeLib2Impl
*This
, /* [I] The type library to allocate in. */
585 const WCHAR
*name
) /* [I] The name to store. */
589 MSFT_NameIntro
*name_space
;
592 length
= ctl2_encode_name(This
, name
, &encoded_name
);
594 offset
= ctl2_find_name(This
, encoded_name
);
595 if (offset
!= -1) return offset
;
597 offset
= ctl2_alloc_segment(This
, MSFT_SEG_NAME
, length
+ 8, 0);
598 if (offset
== -1) return -1;
600 name_space
= (void *)(This
->typelib_segment_data
[MSFT_SEG_NAME
] + offset
);
601 name_space
->hreftype
= -1;
602 name_space
->next_hash
= -1;
603 memcpy(&name_space
->namelen
, encoded_name
, length
);
605 if (This
->typelib_namehash_segment
[encoded_name
[2] & 0x7f] != -1)
606 name_space
->next_hash
= This
->typelib_namehash_segment
[encoded_name
[2] & 0x7f];
608 This
->typelib_namehash_segment
[encoded_name
[2] & 0x7f] = offset
;
610 This
->typelib_header
.nametablecount
+= 1;
611 This
->typelib_header
.nametablechars
+= *encoded_name
;
616 /****************************************************************************
619 * Allocates and initializes a string in a type library.
623 * Success: The offset within the segment of the new string.
624 * Failure: -1 (this is invariably an out of memory condition).
626 static int ctl2_alloc_string(
627 ICreateTypeLib2Impl
*This
, /* [I] The type library to allocate in. */
628 const WCHAR
*string
) /* [I] The string to store. */
633 char *encoded_string
;
635 length
= ctl2_encode_string(This
, string
, &encoded_string
);
637 for (offset
= 0; offset
< This
->typelib_segdir
[MSFT_SEG_STRING
].length
;
638 offset
+= ((((This
->typelib_segment_data
[MSFT_SEG_STRING
][offset
+ 1] << 8) & 0xff)
639 | (This
->typelib_segment_data
[MSFT_SEG_STRING
][offset
+ 0] & 0xff)) + 5) & ~3) {
640 if (!memcmp(encoded_string
, This
->typelib_segment_data
[MSFT_SEG_STRING
] + offset
, length
)) return offset
;
643 offset
= ctl2_alloc_segment(This
, MSFT_SEG_STRING
, length
, 0);
644 if (offset
== -1) return -1;
646 string_space
= This
->typelib_segment_data
[MSFT_SEG_STRING
] + offset
;
647 memcpy(string_space
, encoded_string
, length
);
652 /****************************************************************************
653 * ctl2_alloc_importinfo
655 * Allocates and initializes an import information structure in a type library.
659 * Success: The offset of the new importinfo.
660 * Failure: -1 (this is invariably an out of memory condition).
662 static int ctl2_alloc_importinfo(
663 ICreateTypeLib2Impl
*This
, /* [I] The type library to allocate in. */
664 MSFT_ImpInfo
*impinfo
) /* [I] The import information to store. */
667 MSFT_ImpInfo
*impinfo_space
;
670 offset
< This
->typelib_segdir
[MSFT_SEG_IMPORTINFO
].length
;
671 offset
+= sizeof(MSFT_ImpInfo
)) {
672 if (!memcmp(&(This
->typelib_segment_data
[MSFT_SEG_IMPORTINFO
][offset
]),
673 impinfo
, sizeof(MSFT_ImpInfo
))) {
678 impinfo
->flags
|= This
->typelib_header
.nimpinfos
++;
680 offset
= ctl2_alloc_segment(This
, MSFT_SEG_IMPORTINFO
, sizeof(MSFT_ImpInfo
), 0);
681 if (offset
== -1) return -1;
683 impinfo_space
= (void *)(This
->typelib_segment_data
[MSFT_SEG_IMPORTINFO
] + offset
);
684 *impinfo_space
= *impinfo
;
689 /****************************************************************************
690 * ctl2_alloc_importfile
692 * Allocates and initializes an import file definition in a type library.
696 * Success: The offset of the new importinfo.
697 * Failure: -1 (this is invariably an out of memory condition).
699 static int ctl2_alloc_importfile(
700 ICreateTypeLib2Impl
*This
, /* [I] The type library to allocate in. */
701 int guidoffset
, /* [I] The offset to the GUID for the imported library. */
702 int major_version
, /* [I] The major version number of the imported library. */
703 int minor_version
, /* [I] The minor version number of the imported library. */
704 const WCHAR
*filename
) /* [I] The filename of the imported library. */
708 MSFT_ImpFile
*importfile
;
709 char *encoded_string
;
711 length
= ctl2_encode_string(This
, filename
, &encoded_string
);
713 encoded_string
[0] <<= 2;
714 encoded_string
[0] |= 1;
716 for (offset
= 0; offset
< This
->typelib_segdir
[MSFT_SEG_IMPORTFILES
].length
;
717 offset
+= ((((This
->typelib_segment_data
[MSFT_SEG_IMPORTFILES
][offset
+ 0xd] << 8) & 0xff)
718 | (This
->typelib_segment_data
[MSFT_SEG_IMPORTFILES
][offset
+ 0xc] & 0xff)) >> 2) + 0xc) {
719 if (!memcmp(encoded_string
, This
->typelib_segment_data
[MSFT_SEG_IMPORTFILES
] + offset
+ 0xc, length
)) return offset
;
722 offset
= ctl2_alloc_segment(This
, MSFT_SEG_IMPORTFILES
, length
+ 0xc, 0);
723 if (offset
== -1) return -1;
725 importfile
= (MSFT_ImpFile
*)&This
->typelib_segment_data
[MSFT_SEG_IMPORTFILES
][offset
];
726 importfile
->guid
= guidoffset
;
727 importfile
->lcid
= This
->typelib_header
.lcid2
;
728 importfile
->version
= major_version
| (minor_version
<< 16);
729 memcpy(&importfile
->filename
, encoded_string
, length
);
734 /****************************************************************************
735 * ctl2_alloc_custdata
737 * Allocates and initializes a "custom data" value in a type library.
741 * Success: The offset of the new custdata.
745 * -2: Unable to encode VARIANT data (typically a bug).
747 static int ctl2_alloc_custdata(
748 ICreateTypeLib2Impl
*This
, /* [I] The type library in which to encode the value. */
749 VARIANT
*pVarVal
) /* [I] The value to encode. */
753 TRACE("(%p,%p(%d))\n",This
,pVarVal
,V_VT(pVarVal
));
755 switch (V_VT(pVarVal
)) {
757 offset
= ctl2_alloc_segment(This
, MSFT_SEG_CUSTDATA
, 8, 0);
758 if (offset
== -1) return offset
;
760 *((unsigned short *)&This
->typelib_segment_data
[MSFT_SEG_CUSTDATA
][offset
]) = VT_UI4
;
761 *((unsigned long *)&This
->typelib_segment_data
[MSFT_SEG_CUSTDATA
][offset
+2]) = V_UI4(pVarVal
);
765 FIXME("Unknown variable encoding vt %d.\n", V_VT(pVarVal
));
772 /****************************************************************************
775 * Adds a custom data element to an object in a type library.
780 * Failure: One of E_INVALIDARG or E_OUTOFMEMORY.
782 static HRESULT
ctl2_set_custdata(
783 ICreateTypeLib2Impl
*This
, /* [I] The type library to store the custom data in. */
784 REFGUID guid
, /* [I] The GUID used as a key to retrieve the custom data. */
785 VARIANT
*pVarVal
, /* [I] The custom data itself. */
786 int *offset
) /* [I/O] The list of custom data to prepend to. */
788 MSFT_GuidEntry guidentry
;
794 guidentry
.guid
= *guid
;
796 guidentry
.hreftype
= -1;
797 guidentry
.next_hash
= -1;
799 guidoffset
= ctl2_alloc_guid(This
, &guidentry
);
800 if (guidoffset
== -1) return E_OUTOFMEMORY
;
801 dataoffset
= ctl2_alloc_custdata(This
, pVarVal
);
802 if (dataoffset
== -1) return E_OUTOFMEMORY
;
803 if (dataoffset
== -2) return E_INVALIDARG
;
805 custoffset
= ctl2_alloc_segment(This
, MSFT_SEG_CUSTDATAGUID
, 12, 0);
806 if (custoffset
== -1) return E_OUTOFMEMORY
;
808 custdata
= (int *)&This
->typelib_segment_data
[MSFT_SEG_CUSTDATAGUID
][custoffset
];
809 custdata
[0] = guidoffset
;
810 custdata
[1] = dataoffset
;
811 custdata
[2] = *offset
;
812 *offset
= custoffset
;
817 /****************************************************************************
818 * ctl2_encode_typedesc
820 * Encodes a type description, storing information in the TYPEDESC and ARRAYDESC
821 * segments as needed.
828 static int ctl2_encode_typedesc(
829 ICreateTypeLib2Impl
*This
, /* [I] The type library in which to encode the TYPEDESC. */
830 const TYPEDESC
*tdesc
, /* [I] The type description to encode. */
831 int *encoded_tdesc
, /* [O] The encoded type description. */
832 int *width
, /* [O] The width of the type, or NULL. */
833 int *alignment
, /* [O] The alignment of the type, or NULL. */
834 int *decoded_size
) /* [O] The total size of the unencoded TYPEDESCs, including nested descs. */
845 default_tdesc
= 0x80000000 | (tdesc
->vt
<< 16) | tdesc
->vt
;
846 if (!width
) width
= &scratch
;
847 if (!alignment
) alignment
= &scratch
;
848 if (!decoded_size
) decoded_size
= &scratch
;
855 *encoded_tdesc
= default_tdesc
;
861 *encoded_tdesc
= 0x80000000 | (VT_I4
<< 16) | VT_INT
;
862 if ((This
->typelib_header
.varflags
& 0x0f) == SYS_WIN16
) {
872 *encoded_tdesc
= 0x80000000 | (VT_UI4
<< 16) | VT_UINT
;
873 if ((This
->typelib_header
.varflags
& 0x0f) == SYS_WIN16
) {
885 *encoded_tdesc
= default_tdesc
;
896 *encoded_tdesc
= default_tdesc
;
902 *encoded_tdesc
= default_tdesc
;
904 *alignment
= 4; /* guess? */
908 *encoded_tdesc
= 0x80000000 | (VT_EMPTY
<< 16) | tdesc
->vt
;
914 /* FIXME: Make with the error checking. */
915 FIXME("PTR vartype, may not work correctly.\n");
917 ctl2_encode_typedesc(This
, tdesc
->u
.lptdesc
, &target_type
, NULL
, NULL
, &child_size
);
919 for (typeoffset
= 0; typeoffset
< This
->typelib_segdir
[MSFT_SEG_TYPEDESC
].length
; typeoffset
+= 8) {
920 typedata
= (void *)&This
->typelib_segment_data
[MSFT_SEG_TYPEDESC
][typeoffset
];
921 if (((typedata
[0] & 0xffff) == VT_PTR
) && (typedata
[1] == target_type
)) break;
924 if (typeoffset
== This
->typelib_segdir
[MSFT_SEG_TYPEDESC
].length
) {
927 if (target_type
& 0x80000000) {
928 mix_field
= ((target_type
>> 16) & 0x3fff) | VT_BYREF
;
930 typedata
= (void *)&This
->typelib_segment_data
[MSFT_SEG_TYPEDESC
][target_type
];
931 mix_field
= ((typedata
[0] >> 16) == 0x7fff)? 0x7fff: 0x7ffe;
934 typeoffset
= ctl2_alloc_segment(This
, MSFT_SEG_TYPEDESC
, 8, 0);
935 typedata
= (void *)&This
->typelib_segment_data
[MSFT_SEG_TYPEDESC
][typeoffset
];
937 typedata
[0] = (mix_field
<< 16) | VT_PTR
;
938 typedata
[1] = target_type
;
941 *encoded_tdesc
= typeoffset
;
945 *decoded_size
= sizeof(TYPEDESC
) + child_size
;
949 /* FIXME: Make with the error checking. */
950 FIXME("SAFEARRAY vartype, may not work correctly.\n");
952 ctl2_encode_typedesc(This
, tdesc
->u
.lptdesc
, &target_type
, NULL
, NULL
, &child_size
);
954 for (typeoffset
= 0; typeoffset
< This
->typelib_segdir
[MSFT_SEG_TYPEDESC
].length
; typeoffset
+= 8) {
955 typedata
= (void *)&This
->typelib_segment_data
[MSFT_SEG_TYPEDESC
][typeoffset
];
956 if (((typedata
[0] & 0xffff) == VT_SAFEARRAY
) && (typedata
[1] == target_type
)) break;
959 if (typeoffset
== This
->typelib_segdir
[MSFT_SEG_TYPEDESC
].length
) {
962 if (target_type
& 0x80000000) {
963 mix_field
= ((target_type
>> 16) & VT_TYPEMASK
) | VT_ARRAY
;
965 typedata
= (void *)&This
->typelib_segment_data
[MSFT_SEG_TYPEDESC
][target_type
];
966 mix_field
= ((typedata
[0] >> 16) == 0x7fff)? 0x7fff: 0x7ffe;
969 typeoffset
= ctl2_alloc_segment(This
, MSFT_SEG_TYPEDESC
, 8, 0);
970 typedata
= (void *)&This
->typelib_segment_data
[MSFT_SEG_TYPEDESC
][typeoffset
];
972 typedata
[0] = (mix_field
<< 16) | VT_SAFEARRAY
;
973 typedata
[1] = target_type
;
976 *encoded_tdesc
= typeoffset
;
980 *decoded_size
= sizeof(TYPEDESC
) + child_size
;
985 /* FIXME: Make with the error checking. */
986 int num_dims
= tdesc
->u
.lpadesc
->cDims
, elements
= 1, dim
;
988 ctl2_encode_typedesc(This
, &tdesc
->u
.lpadesc
->tdescElem
, &target_type
, width
, alignment
, NULL
);
989 arrayoffset
= ctl2_alloc_segment(This
, MSFT_SEG_ARRAYDESC
, (2 + 2 * num_dims
) * sizeof(int), 0);
990 arraydata
= (void *)&This
->typelib_segment_data
[MSFT_SEG_ARRAYDESC
][arrayoffset
];
992 arraydata
[0] = target_type
;
993 arraydata
[1] = num_dims
;
994 arraydata
[1] |= ((num_dims
* 2 * sizeof(int)) << 16);
997 for(dim
= 0; dim
< num_dims
; dim
++) {
998 arraydata
[0] = tdesc
->u
.lpadesc
->rgbounds
[dim
].cElements
;
999 arraydata
[1] = tdesc
->u
.lpadesc
->rgbounds
[dim
].lLbound
;
1000 elements
*= tdesc
->u
.lpadesc
->rgbounds
[dim
].cElements
;
1003 typeoffset
= ctl2_alloc_segment(This
, MSFT_SEG_TYPEDESC
, 8, 0);
1004 typedata
= (void *)&This
->typelib_segment_data
[MSFT_SEG_TYPEDESC
][typeoffset
];
1006 typedata
[0] = (0x7ffe << 16) | VT_CARRAY
;
1007 typedata
[1] = arrayoffset
;
1009 *encoded_tdesc
= typeoffset
;
1010 *width
= *width
* elements
;
1011 *decoded_size
= sizeof(ARRAYDESC
) + (num_dims
- 1) * sizeof(SAFEARRAYBOUND
);
1015 case VT_USERDEFINED
:
1016 TRACE("USERDEFINED.\n");
1017 for (typeoffset
= 0; typeoffset
< This
->typelib_segdir
[MSFT_SEG_TYPEDESC
].length
; typeoffset
+= 8) {
1018 typedata
= (void *)&This
->typelib_segment_data
[MSFT_SEG_TYPEDESC
][typeoffset
];
1019 if ((typedata
[0] == ((0x7fff << 16) | VT_USERDEFINED
)) && (typedata
[1] == tdesc
->u
.hreftype
)) break;
1022 if (typeoffset
== This
->typelib_segdir
[MSFT_SEG_TYPEDESC
].length
) {
1023 typeoffset
= ctl2_alloc_segment(This
, MSFT_SEG_TYPEDESC
, 8, 0);
1024 typedata
= (void *)&This
->typelib_segment_data
[MSFT_SEG_TYPEDESC
][typeoffset
];
1026 typedata
[0] = (0x7fff << 16) | VT_USERDEFINED
;
1027 typedata
[1] = tdesc
->u
.hreftype
;
1030 *encoded_tdesc
= typeoffset
;
1036 FIXME("Unrecognized type %d.\n", tdesc
->vt
);
1037 *encoded_tdesc
= default_tdesc
;
1046 /****************************************************************************
1047 * ctl2_find_nth_reference
1049 * Finds a reference by index into the linked list of reference records.
1053 * Success: Offset of the desired reference record.
1056 static int ctl2_find_nth_reference(
1057 ICreateTypeLib2Impl
*This
, /* [I] The type library in which to search. */
1058 int offset
, /* [I] The starting offset of the reference list. */
1059 int index
) /* [I] The index of the reference to find. */
1061 MSFT_RefRecord
*ref
;
1063 for (; index
&& (offset
!= -1); index
--) {
1064 ref
= (MSFT_RefRecord
*)&This
->typelib_segment_data
[MSFT_SEG_REFERENCES
][offset
];
1065 offset
= ref
->onext
;
1071 /****************************************************************************
1072 * ctl2_find_typeinfo_from_offset
1074 * Finds an ITypeInfo given an offset into the TYPEINFO segment.
1079 * Failure: TYPE_E_ELEMENTNOTFOUND.
1081 static HRESULT
ctl2_find_typeinfo_from_offset(
1082 ICreateTypeLib2Impl
*This
, /* [I] The typelib to find the typeinfo in. */
1083 int offset
, /* [I] The offset of the desired typeinfo. */
1084 ITypeInfo
**ppTinfo
) /* [I] The typeinfo found. */
1087 ICreateTypeInfo2Impl
*typeinfo
;
1089 typeinfodata
= &This
->typelib_segment_data
[MSFT_SEG_TYPEINFO
][offset
];
1091 for (typeinfo
= This
->typeinfos
; typeinfo
; typeinfo
= typeinfo
->next_typeinfo
) {
1092 if (typeinfo
->typeinfo
== typeinfodata
) {
1093 *ppTinfo
= (ITypeInfo
*)&typeinfo
->lpVtblTypeInfo2
;
1094 ITypeInfo2_AddRef(*ppTinfo
);
1099 ERR("Failed to find typeinfo, invariant varied.\n");
1101 return TYPE_E_ELEMENTNOTFOUND
;
1104 /*================== ICreateTypeInfo2 Implementation ===================================*/
1106 /******************************************************************************
1107 * ICreateTypeInfo2_QueryInterface {OLEAUT32}
1109 * See IUnknown_QueryInterface.
1111 static HRESULT WINAPI
ICreateTypeInfo2_fnQueryInterface(
1112 ICreateTypeInfo2
* iface
,
1116 ICreateTypeInfo2Impl
*This
= (ICreateTypeInfo2Impl
*)iface
;
1118 TRACE("(%p)->(IID: %s)\n",This
,debugstr_guid(riid
));
1121 if(IsEqualIID(riid
, &IID_IUnknown
) ||
1122 IsEqualIID(riid
,&IID_ICreateTypeInfo
)||
1123 IsEqualIID(riid
,&IID_ICreateTypeInfo2
))
1126 } else if (IsEqualIID(riid
, &IID_ITypeInfo
) ||
1127 IsEqualIID(riid
, &IID_ITypeInfo2
)) {
1128 *ppvObject
= &This
->lpVtblTypeInfo2
;
1133 ICreateTypeLib2_AddRef(iface
);
1134 TRACE("-- Interface: (%p)->(%p)\n",ppvObject
,*ppvObject
);
1137 TRACE("-- Interface: E_NOINTERFACE\n");
1138 return E_NOINTERFACE
;
1141 /******************************************************************************
1142 * ICreateTypeInfo2_AddRef {OLEAUT32}
1144 * See IUnknown_AddRef.
1146 static ULONG WINAPI
ICreateTypeInfo2_fnAddRef(ICreateTypeInfo2
*iface
)
1148 ICreateTypeInfo2Impl
*This
= (ICreateTypeInfo2Impl
*)iface
;
1149 ULONG ref
= InterlockedIncrement(&This
->ref
);
1151 TRACE("(%p)->ref was %u\n",This
, ref
- 1);
1156 /******************************************************************************
1157 * ICreateTypeInfo2_Release {OLEAUT32}
1159 * See IUnknown_Release.
1161 static ULONG WINAPI
ICreateTypeInfo2_fnRelease(ICreateTypeInfo2
*iface
)
1163 ICreateTypeInfo2Impl
*This
= (ICreateTypeInfo2Impl
*)iface
;
1164 ULONG ref
= InterlockedDecrement(&This
->ref
);
1166 TRACE("(%p)->(%u)\n",This
, ref
);
1169 if (This
->typelib
) {
1170 ICreateTypeLib2_fnRelease((ICreateTypeLib2
*)This
->typelib
);
1171 This
->typelib
= NULL
;
1174 /* ICreateTypeLib2 frees all ICreateTypeInfos when it releases. */
1175 /* HeapFree(GetProcessHeap(),0,This); */
1183 /******************************************************************************
1184 * ICreateTypeInfo2_SetGuid {OLEAUT32}
1186 * See ICreateTypeInfo_SetGuid.
1188 static HRESULT WINAPI
ICreateTypeInfo2_fnSetGuid(ICreateTypeInfo2
*iface
, REFGUID guid
)
1190 ICreateTypeInfo2Impl
*This
= (ICreateTypeInfo2Impl
*)iface
;
1192 MSFT_GuidEntry guidentry
;
1195 TRACE("(%p,%s)\n", iface
, debugstr_guid(guid
));
1197 guidentry
.guid
= *guid
;
1198 guidentry
.hreftype
= This
->typelib
->typelib_typeinfo_offsets
[This
->typeinfo
->typekind
>> 16];
1199 guidentry
.next_hash
= -1;
1201 offset
= ctl2_alloc_guid(This
->typelib
, &guidentry
);
1203 if (offset
== -1) return E_OUTOFMEMORY
;
1205 This
->typeinfo
->posguid
= offset
;
1207 if (IsEqualIID(guid
, &IID_IDispatch
)) {
1208 This
->typelib
->typelib_header
.dispatchpos
= This
->typelib
->typelib_typeinfo_offsets
[This
->typeinfo
->typekind
>> 16];
1214 /******************************************************************************
1215 * ICreateTypeInfo2_SetTypeFlags {OLEAUT32}
1217 * See ICreateTypeInfo_SetTypeFlags.
1219 static HRESULT WINAPI
ICreateTypeInfo2_fnSetTypeFlags(ICreateTypeInfo2
*iface
, UINT uTypeFlags
)
1221 ICreateTypeInfo2Impl
*This
= (ICreateTypeInfo2Impl
*)iface
;
1223 TRACE("(%p,0x%x)\n", iface
, uTypeFlags
);
1225 This
->typeinfo
->flags
= uTypeFlags
;
1227 if (uTypeFlags
& TYPEFLAG_FDISPATCHABLE
) {
1231 MSFT_ImpInfo impinfo
;
1232 static const WCHAR stdole2tlb
[] = { 's','t','d','o','l','e','2','.','t','l','b',0 };
1234 foo
.guid
= IID_StdOle
;
1237 guidoffset
= ctl2_alloc_guid(This
->typelib
, &foo
);
1238 if (guidoffset
== -1) return E_OUTOFMEMORY
;
1240 fileoffset
= ctl2_alloc_importfile(This
->typelib
, guidoffset
, 2, 0, stdole2tlb
);
1241 if (fileoffset
== -1) return E_OUTOFMEMORY
;
1243 foo
.guid
= IID_IDispatch
;
1246 guidoffset
= ctl2_alloc_guid(This
->typelib
, &foo
);
1247 if (guidoffset
== -1) return E_OUTOFMEMORY
;
1249 impinfo
.flags
= TKIND_INTERFACE
<< 24 | MSFT_IMPINFO_OFFSET_IS_GUID
;
1250 impinfo
.oImpFile
= fileoffset
;
1251 impinfo
.oGuid
= guidoffset
;
1252 ctl2_alloc_importinfo(This
->typelib
, &impinfo
);
1254 This
->typelib
->typelib_header
.dispatchpos
= 1;
1256 This
->typeinfo
->typekind
|= 0x10;
1257 This
->typeinfo
->typekind
&= ~0x0f;
1258 This
->typeinfo
->typekind
|= TKIND_DISPATCH
;
1264 /******************************************************************************
1265 * ICreateTypeInfo2_SetDocString {OLEAUT32}
1267 * See ICreateTypeInfo_SetDocString.
1269 static HRESULT WINAPI
ICreateTypeInfo2_fnSetDocString(
1270 ICreateTypeInfo2
* iface
,
1273 ICreateTypeInfo2Impl
*This
= (ICreateTypeInfo2Impl
*)iface
;
1277 TRACE("(%p,%s)\n", iface
, debugstr_w(pStrDoc
));
1279 offset
= ctl2_alloc_string(This
->typelib
, pStrDoc
);
1280 if (offset
== -1) return E_OUTOFMEMORY
;
1281 This
->typeinfo
->docstringoffs
= offset
;
1285 /******************************************************************************
1286 * ICreateTypeInfo2_SetHelpContext {OLEAUT32}
1288 * See ICreateTypeInfo_SetHelpContext.
1290 static HRESULT WINAPI
ICreateTypeInfo2_fnSetHelpContext(
1291 ICreateTypeInfo2
* iface
,
1292 DWORD dwHelpContext
)
1294 ICreateTypeInfo2Impl
*This
= (ICreateTypeInfo2Impl
*)iface
;
1296 TRACE("(%p,%d)\n", iface
, dwHelpContext
);
1298 This
->typeinfo
->helpcontext
= dwHelpContext
;
1303 /******************************************************************************
1304 * ICreateTypeInfo2_SetVersion {OLEAUT32}
1306 * See ICreateTypeInfo_SetVersion.
1308 static HRESULT WINAPI
ICreateTypeInfo2_fnSetVersion(
1309 ICreateTypeInfo2
* iface
,
1313 ICreateTypeInfo2Impl
*This
= (ICreateTypeInfo2Impl
*)iface
;
1315 TRACE("(%p,%d,%d)\n", iface
, wMajorVerNum
, wMinorVerNum
);
1317 This
->typeinfo
->version
= wMajorVerNum
| (wMinorVerNum
<< 16);
1321 /******************************************************************************
1322 * ICreateTypeInfo2_AddRefTypeInfo {OLEAUT32}
1324 * See ICreateTypeInfo_AddRefTypeInfo.
1326 static HRESULT WINAPI
ICreateTypeInfo2_fnAddRefTypeInfo(
1327 ICreateTypeInfo2
* iface
,
1329 HREFTYPE
* phRefType
)
1331 ICreateTypeInfo2Impl
*This
= (ICreateTypeInfo2Impl
*)iface
;
1333 ITypeLib
*container
;
1337 TRACE("(%p,%p,%p)\n", iface
, pTInfo
, phRefType
);
1340 * If this is one of ours, we set *phRefType to the TYPEINFO offset of
1341 * the referred TypeInfo. Otherwise, we presumably have more magic to do.
1343 * Unfortunately, we can't rely on the passed-in TypeInfo even having the
1344 * same internal structure as one of ours. It could be from another
1345 * implementation of ITypeInfo. So we need to do the following...
1347 res
= ITypeInfo_GetContainingTypeLib(pTInfo
, &container
, &index
);
1348 if (!SUCCEEDED(res
)) {
1349 TRACE("failed to find containing typelib.\n");
1353 if (container
== (ITypeLib
*)&This
->typelib
->lpVtblTypeLib2
) {
1354 *phRefType
= This
->typelib
->typelib_typeinfo_offsets
[index
];
1356 FIXME("(%p,%p,%p), pTInfo from different typelib.\n", iface
, pTInfo
, phRefType
);
1359 ITypeLib_Release(container
);
1363 /******************************************************************************
1364 * ICreateTypeInfo2_AddFuncDesc {OLEAUT32}
1366 * See ICreateTypeInfo_AddFuncDesc.
1368 static HRESULT WINAPI
ICreateTypeInfo2_fnAddFuncDesc(
1369 ICreateTypeInfo2
* iface
,
1371 FUNCDESC
* pFuncDesc
)
1373 ICreateTypeInfo2Impl
*This
= (ICreateTypeInfo2Impl
*)iface
;
1380 FIXME("(%p,%d,%p), stub!\n", iface
, index
, pFuncDesc
);
1381 FIXME("{%d,%p,%p,%d,%d,%d,%d,%d,%d,%d,{%d},%d}\n", pFuncDesc
->memid
, pFuncDesc
->lprgscode
, pFuncDesc
->lprgelemdescParam
, pFuncDesc
->funckind
, pFuncDesc
->invkind
, pFuncDesc
->callconv
, pFuncDesc
->cParams
, pFuncDesc
->cParamsOpt
, pFuncDesc
->oVft
, pFuncDesc
->cScodes
, pFuncDesc
->elemdescFunc
.tdesc
.vt
, pFuncDesc
->wFuncFlags
);
1382 /* FIXME("{%d, %d}\n", pFuncDesc->lprgelemdescParam[0].tdesc.vt, pFuncDesc->lprgelemdescParam[1].tdesc.vt); */
1383 /* return E_OUTOFMEMORY; */
1385 if (!This
->typedata
) {
1386 This
->typedata
= HeapAlloc(GetProcessHeap(), 0, 0x2000);
1387 This
->typedata
[0] = 0;
1390 /* allocate type data space for us */
1391 offset
= This
->typedata
[0];
1392 This
->typedata
[0] += 0x18 + (pFuncDesc
->cParams
* 12);
1393 typedata
= This
->typedata
+ (offset
>> 2) + 1;
1395 /* fill out the basic type information */
1396 typedata
[0] = (0x18 + (pFuncDesc
->cParams
* 12)) | (index
<< 16);
1397 ctl2_encode_typedesc(This
->typelib
, &pFuncDesc
->elemdescFunc
.tdesc
, &typedata
[1], NULL
, NULL
, &decoded_size
);
1398 typedata
[2] = pFuncDesc
->wFuncFlags
;
1399 typedata
[3] = ((sizeof(FUNCDESC
) + decoded_size
) << 16) | This
->typeinfo
->cbSizeVft
;
1400 typedata
[4] = (index
<< 16) | (pFuncDesc
->callconv
<< 8) | 9;
1401 typedata
[5] = pFuncDesc
->cParams
;
1403 /* NOTE: High word of typedata[3] is total size of FUNCDESC + size of all ELEMDESCs for params + TYPEDESCs for pointer params and return types. */
1404 /* That is, total memory allocation required to reconstitute the FUNCDESC in its entirety. */
1405 typedata
[3] += (sizeof(ELEMDESC
) * pFuncDesc
->cParams
) << 16;
1407 for (i
= 0; i
< pFuncDesc
->cParams
; i
++) {
1408 ctl2_encode_typedesc(This
->typelib
, &pFuncDesc
->lprgelemdescParam
[i
].tdesc
, &typedata
[6+(i
*3)], NULL
, NULL
, &decoded_size
);
1409 typedata
[7+(i
*3)] = -1;
1410 typedata
[8+(i
*3)] = pFuncDesc
->lprgelemdescParam
[i
].u
.paramdesc
.wParamFlags
;
1411 typedata
[3] += decoded_size
<< 16;
1414 /* FIXME: Doesn't work. Doesn't even come up with usable VTs for varDefaultValue. */
1415 if (pFuncDesc
->lprgelemdescParam
[i
].u
.paramdesc
.wParamFlags
& PARAMFLAG_FHASDEFAULT
) {
1416 ctl2_alloc_custdata(This
->typelib
, &pFuncDesc
->lprgelemdescParam
[i
].u
.paramdesc
.pparamdescex
->varDefaultValue
);
1421 /* update the index data */
1422 This
->indices
[index
] = ((0x6000 | This
->typeinfo
->cImplTypes
) << 16) | index
;
1423 This
->names
[index
] = -1;
1424 This
->offsets
[index
] = offset
;
1427 if (!This
->typeinfo
->res2
) This
->typeinfo
->res2
= 0x20;
1428 This
->typeinfo
->res2
<<= 1;
1431 if (This
->typeinfo
->res3
== -1) This
->typeinfo
->res3
= 0;
1432 This
->typeinfo
->res3
+= 0x38;
1435 if (index
< 2) This
->typeinfo
->res2
+= pFuncDesc
->cParams
<< 4;
1436 This
->typeinfo
->res3
+= pFuncDesc
->cParams
<< 4;
1438 /* adjust size of VTBL */
1439 This
->typeinfo
->cbSizeVft
+= 4;
1441 /* Increment the number of function elements */
1442 This
->typeinfo
->cElement
+= 1;
1447 /******************************************************************************
1448 * ICreateTypeInfo2_AddImplType {OLEAUT32}
1450 * See ICreateTypeInfo_AddImplType.
1452 static HRESULT WINAPI
ICreateTypeInfo2_fnAddImplType(
1453 ICreateTypeInfo2
* iface
,
1457 ICreateTypeInfo2Impl
*This
= (ICreateTypeInfo2Impl
*)iface
;
1459 TRACE("(%p,%d,%d)\n", iface
, index
, hRefType
);
1461 if ((This
->typeinfo
->typekind
& 15) == TKIND_COCLASS
) {
1463 MSFT_RefRecord
*ref
;
1466 if (This
->typeinfo
->datatype1
!= -1) return TYPE_E_ELEMENTNOTFOUND
;
1468 offset
= ctl2_alloc_segment(This
->typelib
, MSFT_SEG_REFERENCES
, sizeof(MSFT_RefRecord
), 0);
1469 if (offset
== -1) return E_OUTOFMEMORY
;
1471 This
->typeinfo
->datatype1
= offset
;
1475 lastoffset
= ctl2_find_nth_reference(This
->typelib
, This
->typeinfo
->datatype1
, index
- 1);
1476 if (lastoffset
== -1) return TYPE_E_ELEMENTNOTFOUND
;
1478 ref
= (MSFT_RefRecord
*)&This
->typelib
->typelib_segment_data
[MSFT_SEG_REFERENCES
][lastoffset
];
1479 if (ref
->onext
!= -1) return TYPE_E_ELEMENTNOTFOUND
;
1481 offset
= ctl2_alloc_segment(This
->typelib
, MSFT_SEG_REFERENCES
, sizeof(MSFT_RefRecord
), 0);
1482 if (offset
== -1) return E_OUTOFMEMORY
;
1484 ref
->onext
= offset
;
1487 ref
= (MSFT_RefRecord
*)&This
->typelib
->typelib_segment_data
[MSFT_SEG_REFERENCES
][offset
];
1489 ref
->reftype
= hRefType
;
1491 ref
->oCustData
= -1;
1493 } else if ((This
->typeinfo
->typekind
& 15) == TKIND_DISPATCH
) {
1494 FIXME("dispatch case unhandled.\n");
1495 } else if ((This
->typeinfo
->typekind
& 15) == TKIND_INTERFACE
) {
1496 if (This
->typeinfo
->cImplTypes
) {
1497 return (index
== 1)? TYPE_E_BADMODULEKIND
: TYPE_E_ELEMENTNOTFOUND
;
1500 if (index
!= 0) return TYPE_E_ELEMENTNOTFOUND
;
1502 This
->typeinfo
->cImplTypes
++;
1504 /* hacked values for IDispatch only, and maybe only for stdole. */
1505 This
->typeinfo
->cbSizeVft
+= 0x0c; /* hack */
1506 This
->typeinfo
->datatype1
= hRefType
;
1507 This
->typeinfo
->datatype2
= (3 << 16) | 1; /* ? */
1509 FIXME("AddImplType unsupported on typekind %d\n", This
->typeinfo
->typekind
& 15);
1510 return E_OUTOFMEMORY
;
1516 /******************************************************************************
1517 * ICreateTypeInfo2_SetImplTypeFlags {OLEAUT32}
1519 * See ICreateTypeInfo_SetImplTypeFlags.
1521 static HRESULT WINAPI
ICreateTypeInfo2_fnSetImplTypeFlags(
1522 ICreateTypeInfo2
* iface
,
1526 ICreateTypeInfo2Impl
*This
= (ICreateTypeInfo2Impl
*)iface
;
1528 MSFT_RefRecord
*ref
;
1530 TRACE("(%p,%d,0x%x)\n", iface
, index
, implTypeFlags
);
1532 if ((This
->typeinfo
->typekind
& 15) != TKIND_COCLASS
) {
1533 return TYPE_E_BADMODULEKIND
;
1536 offset
= ctl2_find_nth_reference(This
->typelib
, This
->typeinfo
->datatype1
, index
);
1537 if (offset
== -1) return TYPE_E_ELEMENTNOTFOUND
;
1539 ref
= (MSFT_RefRecord
*)&This
->typelib
->typelib_segment_data
[MSFT_SEG_REFERENCES
][offset
];
1540 ref
->flags
= implTypeFlags
;
1545 /******************************************************************************
1546 * ICreateTypeInfo2_SetAlignment {OLEAUT32}
1548 * See ICreateTypeInfo_SetAlignment.
1550 static HRESULT WINAPI
ICreateTypeInfo2_fnSetAlignment(
1551 ICreateTypeInfo2
* iface
,
1554 ICreateTypeInfo2Impl
*This
= (ICreateTypeInfo2Impl
*)iface
;
1556 TRACE("(%p,%d)\n", iface
, cbAlignment
);
1558 if (!cbAlignment
) return E_INVALIDARG
;
1559 if (cbAlignment
> 16) return E_INVALIDARG
;
1561 This
->typeinfo
->typekind
&= ~0xffc0;
1562 This
->typeinfo
->typekind
|= cbAlignment
<< 6;
1564 /* FIXME: There's probably some way to simplify this. */
1565 switch (This
->typeinfo
->typekind
& 15) {
1571 case TKIND_INTERFACE
:
1572 case TKIND_DISPATCH
:
1574 if (cbAlignment
> 4) cbAlignment
= 4;
1584 This
->typeinfo
->typekind
|= cbAlignment
<< 11;
1589 /******************************************************************************
1590 * ICreateTypeInfo2_SetSchema {OLEAUT32}
1592 * See ICreateTypeInfo_SetSchema.
1594 static HRESULT WINAPI
ICreateTypeInfo2_fnSetSchema(
1595 ICreateTypeInfo2
* iface
,
1596 LPOLESTR pStrSchema
)
1598 FIXME("(%p,%s), stub!\n", iface
, debugstr_w(pStrSchema
));
1599 return E_OUTOFMEMORY
;
1602 /******************************************************************************
1603 * ICreateTypeInfo2_AddVarDesc {OLEAUT32}
1605 * See ICreateTypeInfo_AddVarDesc.
1607 static HRESULT WINAPI
ICreateTypeInfo2_fnAddVarDesc(
1608 ICreateTypeInfo2
* iface
,
1612 ICreateTypeInfo2Impl
*This
= (ICreateTypeInfo2Impl
*)iface
;
1620 TRACE("(%p,%d,%p), stub!\n", iface
, index
, pVarDesc
);
1621 TRACE("%d, %p, %d, {{%x, %d}, {%p, %x}}, 0x%x, %d\n", pVarDesc
->memid
, pVarDesc
->lpstrSchema
, pVarDesc
->u
.oInst
,
1622 pVarDesc
->elemdescVar
.tdesc
.u
.hreftype
, pVarDesc
->elemdescVar
.tdesc
.vt
,
1623 pVarDesc
->elemdescVar
.u
.paramdesc
.pparamdescex
, pVarDesc
->elemdescVar
.u
.paramdesc
.wParamFlags
,
1624 pVarDesc
->wVarFlags
, pVarDesc
->varkind
);
1626 if ((This
->typeinfo
->cElement
>> 16) != index
) {
1627 TRACE("Out-of-order element.\n");
1628 return TYPE_E_ELEMENTNOTFOUND
;
1631 if (!This
->typedata
) {
1632 This
->typedata
= HeapAlloc(GetProcessHeap(), 0, 0x2000);
1633 This
->typedata
[0] = 0;
1636 /* allocate type data space for us */
1637 offset
= This
->typedata
[0];
1638 This
->typedata
[0] += 0x14;
1639 typedata
= This
->typedata
+ (offset
>> 2) + 1;
1641 /* fill out the basic type information */
1642 typedata
[0] = 0x14 | (index
<< 16);
1643 typedata
[2] = pVarDesc
->wVarFlags
;
1644 typedata
[3] = (sizeof(VARDESC
) << 16) | 0;
1646 /* update the index data */
1647 This
->indices
[index
] = 0x40000000 + index
;
1648 This
->names
[index
] = -1;
1649 This
->offsets
[index
] = offset
;
1651 /* figure out type widths and whatnot */
1652 ctl2_encode_typedesc(This
->typelib
, &pVarDesc
->elemdescVar
.tdesc
,
1653 &typedata
[1], &var_datawidth
, &var_alignment
,
1656 /* pad out starting position to data width */
1657 This
->datawidth
+= var_alignment
- 1;
1658 This
->datawidth
&= ~(var_alignment
- 1);
1659 typedata
[4] = This
->datawidth
;
1661 /* add the new variable to the total data width */
1662 This
->datawidth
+= var_datawidth
;
1664 /* add type description size to total required allocation */
1665 typedata
[3] += var_type_size
<< 16;
1667 /* fix type alignment */
1668 alignment
= (This
->typeinfo
->typekind
>> 11) & 0x1f;
1669 if (alignment
< var_alignment
) {
1670 alignment
= var_alignment
;
1671 This
->typeinfo
->typekind
&= ~0xf800;
1672 This
->typeinfo
->typekind
|= alignment
<< 11;
1676 if (!This
->typeinfo
->res2
) This
->typeinfo
->res2
= 0x1a;
1677 if ((index
== 0) || (index
== 1) || (index
== 2) || (index
== 4) || (index
== 9)) {
1678 This
->typeinfo
->res2
<<= 1;
1682 if (This
->typeinfo
->res3
== -1) This
->typeinfo
->res3
= 0;
1683 This
->typeinfo
->res3
+= 0x2c;
1685 /* increment the number of variable elements */
1686 This
->typeinfo
->cElement
+= 0x10000;
1688 /* pad data width to alignment */
1689 This
->typeinfo
->size
= (This
->datawidth
+ (alignment
- 1)) & ~(alignment
- 1);
1694 /******************************************************************************
1695 * ICreateTypeInfo2_SetFuncAndParamNames {OLEAUT32}
1697 * See ICreateTypeInfo_SetFuncAndParamNames.
1699 static HRESULT WINAPI
ICreateTypeInfo2_fnSetFuncAndParamNames(
1700 ICreateTypeInfo2
* iface
,
1702 LPOLESTR
* rgszNames
,
1705 ICreateTypeInfo2Impl
*This
= (ICreateTypeInfo2Impl
*)iface
;
1711 FIXME("(%p,%d,%s,%d), stub!\n", iface
, index
, debugstr_w(*rgszNames
), cNames
);
1713 offset
= ctl2_alloc_name(This
->typelib
, rgszNames
[0]);
1714 This
->names
[index
] = offset
;
1716 namedata
= This
->typelib
->typelib_segment_data
[MSFT_SEG_NAME
] + offset
;
1717 namedata
[9] &= ~0x10;
1718 if (*((INT
*)namedata
) == -1) {
1719 *((INT
*)namedata
) = This
->typelib
->typelib_typeinfo_offsets
[This
->typeinfo
->typekind
>> 16];
1722 for (i
= 1; i
< cNames
; i
++) {
1723 /* FIXME: Almost certainly easy to break */
1724 int *paramdata
= &This
->typedata
[This
->offsets
[index
] >> 2];
1726 offset
= ctl2_alloc_name(This
->typelib
, rgszNames
[i
]);
1727 paramdata
[(i
* 3) + 5] = offset
;
1733 /******************************************************************************
1734 * ICreateTypeInfo2_SetVarName {OLEAUT32}
1736 * See ICreateTypeInfo_SetVarName.
1738 static HRESULT WINAPI
ICreateTypeInfo2_fnSetVarName(
1739 ICreateTypeInfo2
* iface
,
1743 ICreateTypeInfo2Impl
*This
= (ICreateTypeInfo2Impl
*)iface
;
1747 TRACE("(%p,%d,%s), stub!\n", iface
, index
, debugstr_w(szName
));
1749 if ((This
->typeinfo
->cElement
>> 16) <= index
) {
1750 TRACE("Out-of-order element.\n");
1751 return TYPE_E_ELEMENTNOTFOUND
;
1754 offset
= ctl2_alloc_name(This
->typelib
, szName
);
1755 if (offset
== -1) return E_OUTOFMEMORY
;
1757 namedata
= This
->typelib
->typelib_segment_data
[MSFT_SEG_NAME
] + offset
;
1758 if (*((INT
*)namedata
) == -1) {
1759 *((INT
*)namedata
) = This
->typelib
->typelib_typeinfo_offsets
[This
->typeinfo
->typekind
>> 16];
1760 namedata
[9] |= 0x10;
1762 if ((This
->typeinfo
->typekind
& 15) == TKIND_ENUM
) {
1763 namedata
[9] |= 0x20;
1765 This
->names
[index
] = offset
;
1770 /******************************************************************************
1771 * ICreateTypeInfo2_SetTypeDescAlias {OLEAUT32}
1773 * See ICreateTypeInfo_SetTypeDescAlias.
1775 static HRESULT WINAPI
ICreateTypeInfo2_fnSetTypeDescAlias(
1776 ICreateTypeInfo2
* iface
,
1777 TYPEDESC
* pTDescAlias
)
1779 ICreateTypeInfo2Impl
*This
= (ICreateTypeInfo2Impl
*)iface
;
1781 int encoded_typedesc
;
1784 if ((This
->typeinfo
->typekind
& 15) != TKIND_ALIAS
) {
1785 return TYPE_E_WRONGTYPEKIND
;
1788 FIXME("(%p,%p), hack!\n", iface
, pTDescAlias
);
1790 if (ctl2_encode_typedesc(This
->typelib
, pTDescAlias
, &encoded_typedesc
, &width
, NULL
, NULL
) == -1) {
1791 return E_OUTOFMEMORY
;
1794 This
->typeinfo
->size
= width
;
1795 This
->typeinfo
->datatype1
= encoded_typedesc
;
1800 /******************************************************************************
1801 * ICreateTypeInfo2_DefineFuncAsDllEntry {OLEAUT32}
1803 * See ICreateTypeInfo_DefineFuncAsDllEntry.
1805 static HRESULT WINAPI
ICreateTypeInfo2_fnDefineFuncAsDllEntry(
1806 ICreateTypeInfo2
* iface
,
1809 LPOLESTR szProcName
)
1811 FIXME("(%p,%d,%s,%s), stub!\n", iface
, index
, debugstr_w(szDllName
), debugstr_w(szProcName
));
1812 return E_OUTOFMEMORY
;
1815 /******************************************************************************
1816 * ICreateTypeInfo2_SetFuncDocString {OLEAUT32}
1818 * See ICreateTypeInfo_SetFuncDocString.
1820 static HRESULT WINAPI
ICreateTypeInfo2_fnSetFuncDocString(
1821 ICreateTypeInfo2
* iface
,
1823 LPOLESTR szDocString
)
1825 FIXME("(%p,%d,%s), stub!\n", iface
, index
, debugstr_w(szDocString
));
1826 return E_OUTOFMEMORY
;
1829 /******************************************************************************
1830 * ICreateTypeInfo2_SetVarDocString {OLEAUT32}
1832 * See ICreateTypeInfo_SetVarDocString.
1834 static HRESULT WINAPI
ICreateTypeInfo2_fnSetVarDocString(
1835 ICreateTypeInfo2
* iface
,
1837 LPOLESTR szDocString
)
1839 ICreateTypeInfo2Impl
*This
= (ICreateTypeInfo2Impl
*)iface
;
1841 FIXME("(%p,%d,%s), stub!\n", iface
, index
, debugstr_w(szDocString
));
1843 ctl2_alloc_string(This
->typelib
, szDocString
);
1845 return E_OUTOFMEMORY
;
1848 /******************************************************************************
1849 * ICreateTypeInfo2_SetFuncHelpContext {OLEAUT32}
1851 * See ICreateTypeInfo_SetFuncHelpContext.
1853 static HRESULT WINAPI
ICreateTypeInfo2_fnSetFuncHelpContext(
1854 ICreateTypeInfo2
* iface
,
1856 DWORD dwHelpContext
)
1858 FIXME("(%p,%d,%d), stub!\n", iface
, index
, dwHelpContext
);
1859 return E_OUTOFMEMORY
;
1862 /******************************************************************************
1863 * ICreateTypeInfo2_SetVarHelpContext {OLEAUT32}
1865 * See ICreateTypeInfo_SetVarHelpContext.
1867 static HRESULT WINAPI
ICreateTypeInfo2_fnSetVarHelpContext(
1868 ICreateTypeInfo2
* iface
,
1870 DWORD dwHelpContext
)
1872 FIXME("(%p,%d,%d), stub!\n", iface
, index
, dwHelpContext
);
1873 return E_OUTOFMEMORY
;
1876 /******************************************************************************
1877 * ICreateTypeInfo2_SetMops {OLEAUT32}
1879 * See ICreateTypeInfo_SetMops.
1881 static HRESULT WINAPI
ICreateTypeInfo2_fnSetMops(
1882 ICreateTypeInfo2
* iface
,
1886 FIXME("(%p,%d,%p), stub!\n", iface
, index
, bstrMops
);
1887 return E_OUTOFMEMORY
;
1890 /******************************************************************************
1891 * ICreateTypeInfo2_SetTypeIdldesc {OLEAUT32}
1893 * See ICreateTypeInfo_SetTypeIdldesc.
1895 static HRESULT WINAPI
ICreateTypeInfo2_fnSetTypeIdldesc(
1896 ICreateTypeInfo2
* iface
,
1899 FIXME("(%p,%p), stub!\n", iface
, pIdlDesc
);
1900 return E_OUTOFMEMORY
;
1903 /******************************************************************************
1904 * ICreateTypeInfo2_LayOut {OLEAUT32}
1906 * See ICreateTypeInfo_LayOut.
1908 static HRESULT WINAPI
ICreateTypeInfo2_fnLayOut(
1909 ICreateTypeInfo2
* iface
)
1911 TRACE("(%p), stub!\n", iface
);
1912 /* return E_OUTOFMEMORY; */
1916 /******************************************************************************
1917 * ICreateTypeInfo2_DeleteFuncDesc {OLEAUT32}
1919 * Delete a function description from a type.
1924 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
1926 static HRESULT WINAPI
ICreateTypeInfo2_fnDeleteFuncDesc(
1927 ICreateTypeInfo2
* iface
, /* [I] The typeinfo from which to delete a function. */
1928 UINT index
) /* [I] The index of the function to delete. */
1930 FIXME("(%p,%d), stub!\n", iface
, index
);
1931 return E_OUTOFMEMORY
;
1934 /******************************************************************************
1935 * ICreateTypeInfo2_DeleteFuncDescByMemId {OLEAUT32}
1937 * Delete a function description from a type.
1942 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
1944 static HRESULT WINAPI
ICreateTypeInfo2_fnDeleteFuncDescByMemId(
1945 ICreateTypeInfo2
* iface
, /* [I] The typeinfo from which to delete a function. */
1946 MEMBERID memid
, /* [I] The member id of the function to delete. */
1947 INVOKEKIND invKind
) /* [I] The invocation type of the function to delete. (?) */
1949 FIXME("(%p,%d,%d), stub!\n", iface
, memid
, invKind
);
1950 return E_OUTOFMEMORY
;
1953 /******************************************************************************
1954 * ICreateTypeInfo2_DeleteVarDesc {OLEAUT32}
1956 * Delete a variable description from a type.
1961 * Failure: One of E_OUTOFMEMORY, E_INVALIDARG, TYPE_E_IOERROR,
1962 * TYPE_E_INVDATAREAD, TYPE_E_UNSUPFORMAT or TYPE_E_INVALIDSTATE.
1964 static HRESULT WINAPI
ICreateTypeInfo2_fnDeleteVarDesc(
1965 ICreateTypeInfo2
* iface
, /* [I] The typeinfo from which to delete the variable description. */
1966 UINT index
) /* [I] The index of the variable description to delete. */
1968 FIXME("(%p,%d), stub!\n", iface
, index
);
1969 return E_OUTOFMEMORY
;
1972 /******************************************************************************
1973 * ICreateTypeInfo2_DeleteVarDescByMemId {OLEAUT32}
1975 * Delete a variable description from a type.
1980 * Failure: One of E_OUTOFMEMORY, E_INVALIDARG, TYPE_E_IOERROR,
1981 * TYPE_E_INVDATAREAD, TYPE_E_UNSUPFORMAT or TYPE_E_INVALIDSTATE.
1983 static HRESULT WINAPI
ICreateTypeInfo2_fnDeleteVarDescByMemId(
1984 ICreateTypeInfo2
* iface
, /* [I] The typeinfo from which to delete the variable description. */
1985 MEMBERID memid
) /* [I] The member id of the variable description to delete. */
1987 FIXME("(%p,%d), stub!\n", iface
, memid
);
1988 return E_OUTOFMEMORY
;
1991 /******************************************************************************
1992 * ICreateTypeInfo2_DeleteImplType {OLEAUT32}
1994 * Delete an interface implementation from a type. (?)
1999 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2001 static HRESULT WINAPI
ICreateTypeInfo2_fnDeleteImplType(
2002 ICreateTypeInfo2
* iface
, /* [I] The typeinfo from which to delete. */
2003 UINT index
) /* [I] The index of the interface to delete. */
2005 FIXME("(%p,%d), stub!\n", iface
, index
);
2006 return E_OUTOFMEMORY
;
2009 /******************************************************************************
2010 * ICreateTypeInfo2_SetCustData {OLEAUT32}
2012 * Set the custom data for a type.
2017 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2019 static HRESULT WINAPI
ICreateTypeInfo2_fnSetCustData(
2020 ICreateTypeInfo2
* iface
, /* [I] The typeinfo in which to set the custom data. */
2021 REFGUID guid
, /* [I] The GUID used as a key to retrieve the custom data. */
2022 VARIANT
* pVarVal
) /* [I] The custom data. */
2024 FIXME("(%p,%s,%p), stub!\n", iface
, debugstr_guid(guid
), pVarVal
);
2025 return E_OUTOFMEMORY
;
2028 /******************************************************************************
2029 * ICreateTypeInfo2_SetFuncCustData {OLEAUT32}
2031 * Set the custom data for a function.
2036 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2038 static HRESULT WINAPI
ICreateTypeInfo2_fnSetFuncCustData(
2039 ICreateTypeInfo2
* iface
, /* [I] The typeinfo in which to set the custom data. */
2040 UINT index
, /* [I] The index of the function for which to set the custom data. */
2041 REFGUID guid
, /* [I] The GUID used as a key to retrieve the custom data. */
2042 VARIANT
* pVarVal
) /* [I] The custom data. */
2044 FIXME("(%p,%d,%s,%p), stub!\n", iface
, index
, debugstr_guid(guid
), pVarVal
);
2045 return E_OUTOFMEMORY
;
2048 /******************************************************************************
2049 * ICreateTypeInfo2_SetParamCustData {OLEAUT32}
2051 * Set the custom data for a function parameter.
2056 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2058 static HRESULT WINAPI
ICreateTypeInfo2_fnSetParamCustData(
2059 ICreateTypeInfo2
* iface
, /* [I] The typeinfo in which to set the custom data. */
2060 UINT indexFunc
, /* [I] The index of the function on which the parameter resides. */
2061 UINT indexParam
, /* [I] The index of the parameter on which to set the custom data. */
2062 REFGUID guid
, /* [I] The GUID used as a key to retrieve the custom data. */
2063 VARIANT
* pVarVal
) /* [I] The custom data. */
2065 FIXME("(%p,%d,%d,%s,%p), stub!\n", iface
, indexFunc
, indexParam
, debugstr_guid(guid
), pVarVal
);
2066 return E_OUTOFMEMORY
;
2069 /******************************************************************************
2070 * ICreateTypeInfo2_SetVarCustData {OLEAUT32}
2072 * Set the custom data for a variable.
2077 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2079 static HRESULT WINAPI
ICreateTypeInfo2_fnSetVarCustData(
2080 ICreateTypeInfo2
* iface
, /* [I] The typeinfo in which to set the custom data. */
2081 UINT index
, /* [I] The index of the variable on which to set the custom data. */
2082 REFGUID guid
, /* [I] The GUID used as a key to retrieve the custom data. */
2083 VARIANT
* pVarVal
) /* [I] The custom data. */
2085 FIXME("(%p,%d,%s,%p), stub!\n", iface
, index
, debugstr_guid(guid
), pVarVal
);
2086 return E_OUTOFMEMORY
;
2089 /******************************************************************************
2090 * ICreateTypeInfo2_SetImplTypeCustData {OLEAUT32}
2092 * Set the custom data for an implemented interface.
2097 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2099 static HRESULT WINAPI
ICreateTypeInfo2_fnSetImplTypeCustData(
2100 ICreateTypeInfo2
* iface
, /* [I] The typeinfo on which to set the custom data. */
2101 UINT index
, /* [I] The index of the implemented interface on which to set the custom data. */
2102 REFGUID guid
, /* [I] The GUID used as a key to retrieve the custom data. */
2103 VARIANT
* pVarVal
) /* [I] The custom data. */
2105 FIXME("(%p,%d,%s,%p), stub!\n", iface
, index
, debugstr_guid(guid
), pVarVal
);
2106 return E_OUTOFMEMORY
;
2109 /******************************************************************************
2110 * ICreateTypeInfo2_SetHelpStringContext {OLEAUT32}
2112 * Set the help string context for the typeinfo.
2117 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2119 static HRESULT WINAPI
ICreateTypeInfo2_fnSetHelpStringContext(
2120 ICreateTypeInfo2
* iface
, /* [I] The typeinfo on which to set the help string context. */
2121 ULONG dwHelpStringContext
) /* [I] The help string context. */
2123 FIXME("(%p,%d), stub!\n", iface
, dwHelpStringContext
);
2124 return E_OUTOFMEMORY
;
2127 /******************************************************************************
2128 * ICreateTypeInfo2_SetFuncHelpStringContext {OLEAUT32}
2130 * Set the help string context for a function.
2135 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2137 static HRESULT WINAPI
ICreateTypeInfo2_fnSetFuncHelpStringContext(
2138 ICreateTypeInfo2
* iface
, /* [I] The typeinfo on which to set the help string context. */
2139 UINT index
, /* [I] The index for the function on which to set the help string context. */
2140 ULONG dwHelpStringContext
) /* [I] The help string context. */
2142 FIXME("(%p,%d,%d), stub!\n", iface
, index
, dwHelpStringContext
);
2143 return E_OUTOFMEMORY
;
2146 /******************************************************************************
2147 * ICreateTypeInfo2_SetVarHelpStringContext {OLEAUT32}
2149 * Set the help string context for a variable.
2154 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2156 static HRESULT WINAPI
ICreateTypeInfo2_fnSetVarHelpStringContext(
2157 ICreateTypeInfo2
* iface
, /* [I] The typeinfo on which to set the help string context. */
2158 UINT index
, /* [I] The index of the variable on which to set the help string context. */
2159 ULONG dwHelpStringContext
) /* [I] The help string context */
2161 FIXME("(%p,%d,%d), stub!\n", iface
, index
, dwHelpStringContext
);
2162 return E_OUTOFMEMORY
;
2165 /******************************************************************************
2166 * ICreateTypeInfo2_Invalidate {OLEAUT32}
2168 * Undocumented function. (!)
2170 static HRESULT WINAPI
ICreateTypeInfo2_fnInvalidate(
2171 ICreateTypeInfo2
* iface
)
2173 FIXME("(%p), stub!\n", iface
);
2174 return E_OUTOFMEMORY
;
2177 /******************************************************************************
2178 * ICreateTypeInfo2_SetName {OLEAUT32}
2180 * Set the name for a typeinfo.
2185 * Failure: One of STG_E_INSUFFICIENTMEMORY, E_OUTOFMEMORY, E_INVALIDARG or TYPE_E_INVALIDSTATE.
2187 static HRESULT WINAPI
ICreateTypeInfo2_fnSetName(
2188 ICreateTypeInfo2
* iface
,
2191 FIXME("(%p,%s), stub!\n", iface
, debugstr_w(szName
));
2192 return E_OUTOFMEMORY
;
2195 /*================== ITypeInfo2 Implementation ===================================*/
2197 /******************************************************************************
2198 * ITypeInfo2_QueryInterface {OLEAUT32}
2200 * See IUnknown_QueryInterface.
2202 static HRESULT WINAPI
ITypeInfo2_fnQueryInterface(ITypeInfo2
* iface
, REFIID riid
, LPVOID
* ppv
)
2204 ICreateTypeInfo2Impl
*This
= impl_from_ITypeInfo2(iface
);
2206 return ICreateTypeInfo2_QueryInterface((ICreateTypeInfo2
*)This
, riid
, ppv
);
2209 /******************************************************************************
2210 * ITypeInfo2_AddRef {OLEAUT32}
2212 * See IUnknown_AddRef.
2214 static ULONG WINAPI
ITypeInfo2_fnAddRef(ITypeInfo2
* iface
)
2216 ICreateTypeInfo2Impl
*This
= impl_from_ITypeInfo2(iface
);
2218 return ICreateTypeInfo2_AddRef((ICreateTypeInfo2
*)This
);
2221 /******************************************************************************
2222 * ITypeInfo2_Release {OLEAUT32}
2224 * See IUnknown_Release.
2226 static ULONG WINAPI
ITypeInfo2_fnRelease(ITypeInfo2
* iface
)
2228 ICreateTypeInfo2Impl
*This
= impl_from_ITypeInfo2(iface
);
2230 return ICreateTypeInfo2_Release((ICreateTypeInfo2
*)This
);
2233 /******************************************************************************
2234 * ITypeInfo2_GetTypeAttr {OLEAUT32}
2236 * See ITypeInfo_GetTypeAttr.
2238 static HRESULT WINAPI
ITypeInfo2_fnGetTypeAttr(
2240 TYPEATTR
** ppTypeAttr
)
2242 FIXME("(%p,%p), stub!\n", iface
, ppTypeAttr
);
2243 return E_OUTOFMEMORY
;
2246 /******************************************************************************
2247 * ITypeInfo2_GetTypeComp {OLEAUT32}
2249 * See ITypeInfo_GetTypeComp.
2251 static HRESULT WINAPI
ITypeInfo2_fnGetTypeComp(
2253 ITypeComp
** ppTComp
)
2255 FIXME("(%p,%p), stub!\n", iface
, ppTComp
);
2256 return E_OUTOFMEMORY
;
2259 /******************************************************************************
2260 * ITypeInfo2_GetFuncDesc {OLEAUT32}
2262 * See ITypeInfo_GetFuncDesc.
2264 static HRESULT WINAPI
ITypeInfo2_fnGetFuncDesc(
2267 FUNCDESC
** ppFuncDesc
)
2269 FIXME("(%p,%d,%p), stub!\n", iface
, index
, ppFuncDesc
);
2270 return E_OUTOFMEMORY
;
2273 /******************************************************************************
2274 * ITypeInfo2_GetVarDesc {OLEAUT32}
2276 * See ITypeInfo_GetVarDesc.
2278 static HRESULT WINAPI
ITypeInfo2_fnGetVarDesc(
2281 VARDESC
** ppVarDesc
)
2283 FIXME("(%p,%d,%p), stub!\n", iface
, index
, ppVarDesc
);
2284 return E_OUTOFMEMORY
;
2287 /******************************************************************************
2288 * ITypeInfo2_GetNames {OLEAUT32}
2290 * See ITypeInfo_GetNames.
2292 static HRESULT WINAPI
ITypeInfo2_fnGetNames(
2299 FIXME("(%p,%d,%p,%d,%p), stub!\n", iface
, memid
, rgBstrNames
, cMaxNames
, pcNames
);
2300 return E_OUTOFMEMORY
;
2303 /******************************************************************************
2304 * ITypeInfo2_GetRefTypeOfImplType {OLEAUT32}
2306 * See ITypeInfo_GetRefTypeOfImplType.
2308 static HRESULT WINAPI
ITypeInfo2_fnGetRefTypeOfImplType(
2313 FIXME("(%p,%d,%p), stub!\n", iface
, index
, pRefType
);
2314 return E_OUTOFMEMORY
;
2317 /******************************************************************************
2318 * ITypeInfo2_GetImplTypeFlags {OLEAUT32}
2320 * See ITypeInfo_GetImplTypeFlags.
2322 static HRESULT WINAPI
ITypeInfo2_fnGetImplTypeFlags(
2325 INT
* pImplTypeFlags
)
2327 FIXME("(%p,%d,%p), stub!\n", iface
, index
, pImplTypeFlags
);
2328 return E_OUTOFMEMORY
;
2331 /******************************************************************************
2332 * ITypeInfo2_GetIDsOfNames {OLEAUT32}
2334 * See ITypeInfo_GetIDsOfNames.
2336 static HRESULT WINAPI
ITypeInfo2_fnGetIDsOfNames(
2338 LPOLESTR
* rgszNames
,
2342 FIXME("(%p,%p,%d,%p), stub!\n", iface
, rgszNames
, cNames
, pMemId
);
2343 return E_OUTOFMEMORY
;
2346 /******************************************************************************
2347 * ITypeInfo2_Invoke {OLEAUT32}
2349 * See ITypeInfo_Invoke.
2351 static HRESULT WINAPI
ITypeInfo2_fnInvoke(
2356 DISPPARAMS
* pDispParams
,
2357 VARIANT
* pVarResult
,
2358 EXCEPINFO
* pExcepInfo
,
2361 FIXME("(%p,%p,%d,%x,%p,%p,%p,%p), stub!\n", iface
, pvInstance
, memid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2362 return E_OUTOFMEMORY
;
2365 /******************************************************************************
2366 * ITypeInfo2_GetDocumentation {OLEAUT32}
2368 * See ITypeInfo_GetDocumentation.
2370 static HRESULT WINAPI
ITypeInfo2_fnGetDocumentation(
2374 BSTR
* pBstrDocString
,
2375 DWORD
* pdwHelpContext
,
2376 BSTR
* pBstrHelpFile
)
2378 FIXME("(%p,%d,%p,%p,%p,%p), stub!\n", iface
, memid
, pBstrName
, pBstrDocString
, pdwHelpContext
, pBstrHelpFile
);
2379 return E_OUTOFMEMORY
;
2382 /******************************************************************************
2383 * ITypeInfo2_GetDllEntry {OLEAUT32}
2385 * See ITypeInfo_GetDllEntry.
2387 static HRESULT WINAPI
ITypeInfo2_fnGetDllEntry(
2395 FIXME("(%p,%d,%d,%p,%p,%p), stub!\n", iface
, memid
, invKind
, pBstrDllName
, pBstrName
, pwOrdinal
);
2396 return E_OUTOFMEMORY
;
2399 /******************************************************************************
2400 * ITypeInfo2_GetRefTypeInfo {OLEAUT32}
2402 * See ITypeInfo_GetRefTypeInfo.
2404 static HRESULT WINAPI
ITypeInfo2_fnGetRefTypeInfo(
2407 ITypeInfo
** ppTInfo
)
2409 FIXME("(%p,%d,%p), stub!\n", iface
, hRefType
, ppTInfo
);
2410 return E_OUTOFMEMORY
;
2413 /******************************************************************************
2414 * ITypeInfo2_AddressOfMember {OLEAUT32}
2416 * See ITypeInfo_AddressOfMember.
2418 static HRESULT WINAPI
ITypeInfo2_fnAddressOfMember(
2424 FIXME("(%p,%d,%d,%p), stub!\n", iface
, memid
, invKind
, ppv
);
2425 return E_OUTOFMEMORY
;
2428 /******************************************************************************
2429 * ITypeInfo2_CreateInstance {OLEAUT32}
2431 * See ITypeInfo_CreateInstance.
2433 static HRESULT WINAPI
ITypeInfo2_fnCreateInstance(
2435 IUnknown
* pUnkOuter
,
2439 FIXME("(%p,%p,%s,%p), stub!\n", iface
, pUnkOuter
, debugstr_guid(riid
), ppvObj
);
2440 return E_OUTOFMEMORY
;
2443 /******************************************************************************
2444 * ITypeInfo2_GetMops {OLEAUT32}
2446 * See ITypeInfo_GetMops.
2448 static HRESULT WINAPI
ITypeInfo2_fnGetMops(
2453 FIXME("(%p,%d,%p), stub!\n", iface
, memid
, pBstrMops
);
2454 return E_OUTOFMEMORY
;
2457 /******************************************************************************
2458 * ITypeInfo2_GetContainingTypeLib {OLEAUT32}
2460 * See ITypeInfo_GetContainingTypeLib.
2462 static HRESULT WINAPI
ITypeInfo2_fnGetContainingTypeLib(
2467 ICreateTypeInfo2Impl
*This
= impl_from_ITypeInfo2(iface
);
2469 TRACE("(%p,%p,%p)\n", iface
, ppTLib
, pIndex
);
2471 *ppTLib
= (ITypeLib
*)&This
->typelib
->lpVtblTypeLib2
;
2472 This
->typelib
->ref
++;
2473 *pIndex
= This
->typeinfo
->typekind
>> 16;
2478 /******************************************************************************
2479 * ITypeInfo2_ReleaseTypeAttr {OLEAUT32}
2481 * See ITypeInfo_ReleaseTypeAttr.
2483 static void WINAPI
ITypeInfo2_fnReleaseTypeAttr(
2485 TYPEATTR
* pTypeAttr
)
2487 FIXME("(%p,%p), stub!\n", iface
, pTypeAttr
);
2490 /******************************************************************************
2491 * ITypeInfo2_ReleaseFuncDesc {OLEAUT32}
2493 * See ITypeInfo_ReleaseFuncDesc.
2495 static void WINAPI
ITypeInfo2_fnReleaseFuncDesc(
2497 FUNCDESC
* pFuncDesc
)
2499 FIXME("(%p,%p), stub!\n", iface
, pFuncDesc
);
2502 /******************************************************************************
2503 * ITypeInfo2_ReleaseVarDesc {OLEAUT32}
2505 * See ITypeInfo_ReleaseVarDesc.
2507 static void WINAPI
ITypeInfo2_fnReleaseVarDesc(
2511 FIXME("(%p,%p), stub!\n", iface
, pVarDesc
);
2514 /******************************************************************************
2515 * ITypeInfo2_GetTypeKind {OLEAUT32}
2517 * Get the TYPEKIND value for a TypeInfo.
2522 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2524 static HRESULT WINAPI
ITypeInfo2_fnGetTypeKind(
2525 ITypeInfo2
* iface
, /* [I] The TypeInfo to obtain the typekind for. */
2526 TYPEKIND
* pTypeKind
) /* [O] The typekind for this TypeInfo. */
2528 FIXME("(%p,%p), stub!\n", iface
, pTypeKind
);
2529 return E_OUTOFMEMORY
;
2532 /******************************************************************************
2533 * ITypeInfo2_GetTypeFlags {OLEAUT32}
2535 * Get the Type Flags for a TypeInfo.
2540 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2542 static HRESULT WINAPI
ITypeInfo2_fnGetTypeFlags(
2543 ITypeInfo2
* iface
, /* [I] The TypeInfo to obtain the typeflags for. */
2544 ULONG
* pTypeFlags
) /* [O] The type flags for this TypeInfo. */
2546 FIXME("(%p,%p), stub!\n", iface
, pTypeFlags
);
2547 return E_OUTOFMEMORY
;
2550 /******************************************************************************
2551 * ITypeInfo2_GetFuncIndexOfMemId {OLEAUT32}
2553 * Gets the index of a function given its member id.
2558 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2560 static HRESULT WINAPI
ITypeInfo2_fnGetFuncIndexOfMemId(
2561 ITypeInfo2
* iface
, /* [I] The TypeInfo in which to find the function. */
2562 MEMBERID memid
, /* [I] The member id for the function. */
2563 INVOKEKIND invKind
, /* [I] The invocation kind for the function. */
2564 UINT
* pFuncIndex
) /* [O] The index of the function. */
2566 FIXME("(%p,%d,%d,%p), stub!\n", iface
, memid
, invKind
, pFuncIndex
);
2567 return E_OUTOFMEMORY
;
2570 /******************************************************************************
2571 * ITypeInfo2_GetVarIndexOfMemId {OLEAUT32}
2573 * Gets the index of a variable given its member id.
2578 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2580 static HRESULT WINAPI
ITypeInfo2_fnGetVarIndexOfMemId(
2581 ITypeInfo2
* iface
, /* [I] The TypeInfo in which to find the variable. */
2582 MEMBERID memid
, /* [I] The member id for the variable. */
2583 UINT
* pVarIndex
) /* [O] The index of the variable. */
2585 FIXME("(%p,%d,%p), stub!\n", iface
, memid
, pVarIndex
);
2586 return E_OUTOFMEMORY
;
2589 /******************************************************************************
2590 * ITypeInfo2_GetCustData {OLEAUT32}
2592 * Gets a custom data element from a TypeInfo.
2597 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2599 static HRESULT WINAPI
ITypeInfo2_fnGetCustData(
2600 ITypeInfo2
* iface
, /* [I] The TypeInfo in which to find the custom data. */
2601 REFGUID guid
, /* [I] The GUID under which the custom data is stored. */
2602 VARIANT
* pVarVal
) /* [O] The custom data. */
2604 FIXME("(%p,%s,%p), stub!\n", iface
, debugstr_guid(guid
), pVarVal
);
2605 return E_OUTOFMEMORY
;
2608 /******************************************************************************
2609 * ITypeInfo2_GetFuncCustData {OLEAUT32}
2611 * Gets a custom data element from a function.
2616 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2618 static HRESULT WINAPI
ITypeInfo2_fnGetFuncCustData(
2619 ITypeInfo2
* iface
, /* [I] The TypeInfo in which to find the custom data. */
2620 UINT index
, /* [I] The index of the function for which to retrieve the custom data. */
2621 REFGUID guid
, /* [I] The GUID under which the custom data is stored. */
2622 VARIANT
* pVarVal
) /* [O] The custom data. */
2624 FIXME("(%p,%d,%s,%p), stub!\n", iface
, index
, debugstr_guid(guid
), pVarVal
);
2625 return E_OUTOFMEMORY
;
2628 /******************************************************************************
2629 * ITypeInfo2_GetParamCustData {OLEAUT32}
2631 * Gets a custom data element from a parameter.
2636 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2638 static HRESULT WINAPI
ITypeInfo2_fnGetParamCustData(
2639 ITypeInfo2
* iface
, /* [I] The TypeInfo in which to find the custom data. */
2640 UINT indexFunc
, /* [I] The index of the function for which to retrieve the custom data. */
2641 UINT indexParam
, /* [I] The index of the parameter for which to retrieve the custom data. */
2642 REFGUID guid
, /* [I] The GUID under which the custom data is stored. */
2643 VARIANT
* pVarVal
) /* [O] The custom data. */
2645 FIXME("(%p,%d,%d,%s,%p), stub!\n", iface
, indexFunc
, indexParam
, debugstr_guid(guid
), pVarVal
);
2646 return E_OUTOFMEMORY
;
2649 /******************************************************************************
2650 * ITypeInfo2_GetVarCustData {OLEAUT32}
2652 * Gets a custom data element from a variable.
2657 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2659 static HRESULT WINAPI
ITypeInfo2_fnGetVarCustData(
2660 ITypeInfo2
* iface
, /* [I] The TypeInfo in which to find the custom data. */
2661 UINT index
, /* [I] The index of the variable for which to retrieve the custom data. */
2662 REFGUID guid
, /* [I] The GUID under which the custom data is stored. */
2663 VARIANT
* pVarVal
) /* [O] The custom data. */
2665 FIXME("(%p,%d,%s,%p), stub!\n", iface
, index
, debugstr_guid(guid
), pVarVal
);
2666 return E_OUTOFMEMORY
;
2669 /******************************************************************************
2670 * ITypeInfo2_GetImplTypeCustData {OLEAUT32}
2672 * Gets a custom data element from an implemented type of a TypeInfo.
2677 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2679 static HRESULT WINAPI
ITypeInfo2_fnGetImplTypeCustData(
2680 ITypeInfo2
* iface
, /* [I] The TypeInfo in which to find the custom data. */
2681 UINT index
, /* [I] The index of the implemented type for which to retrieve the custom data. */
2682 REFGUID guid
, /* [I] The GUID under which the custom data is stored. */
2683 VARIANT
* pVarVal
) /* [O] The custom data. */
2685 FIXME("(%p,%d,%s,%p), stub!\n", iface
, index
, debugstr_guid(guid
), pVarVal
);
2686 return E_OUTOFMEMORY
;
2689 /******************************************************************************
2690 * ITypeInfo2_GetDocumentation2 {OLEAUT32}
2692 * Gets some documentation from a TypeInfo in a locale-aware fashion.
2697 * Failure: One of STG_E_INSUFFICIENTMEMORY or E_INVALIDARG.
2699 static HRESULT WINAPI
ITypeInfo2_fnGetDocumentation2(
2700 ITypeInfo2
* iface
, /* [I] The TypeInfo to retrieve the documentation from. */
2701 MEMBERID memid
, /* [I] The member id (why?). */
2702 LCID lcid
, /* [I] The locale (why?). */
2703 BSTR
* pbstrHelpString
, /* [O] The help string. */
2704 DWORD
* pdwHelpStringContext
, /* [O] The help string context. */
2705 BSTR
* pbstrHelpStringDll
) /* [O] The help file name. */
2707 FIXME("(%p,%d,%d,%p,%p,%p), stub!\n", iface
, memid
, lcid
, pbstrHelpString
, pdwHelpStringContext
, pbstrHelpStringDll
);
2708 return E_OUTOFMEMORY
;
2711 /******************************************************************************
2712 * ITypeInfo2_GetAllCustData {OLEAUT32}
2714 * Gets all of the custom data associated with a TypeInfo.
2719 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2721 static HRESULT WINAPI
ITypeInfo2_fnGetAllCustData(
2722 ITypeInfo2
* iface
, /* [I] The TypeInfo in which to find the custom data. */
2723 CUSTDATA
* pCustData
) /* [O] A pointer to the custom data. */
2725 FIXME("(%p,%p), stub!\n", iface
, pCustData
);
2726 return E_OUTOFMEMORY
;
2729 /******************************************************************************
2730 * ITypeInfo2_GetAllFuncCustData {OLEAUT32}
2732 * Gets all of the custom data associated with a function.
2737 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2739 static HRESULT WINAPI
ITypeInfo2_fnGetAllFuncCustData(
2740 ITypeInfo2
* iface
, /* [I] The TypeInfo in which to find the custom data. */
2741 UINT index
, /* [I] The index of the function for which to retrieve the custom data. */
2742 CUSTDATA
* pCustData
) /* [O] A pointer to the custom data. */
2744 FIXME("(%p,%d,%p), stub!\n", iface
, index
, pCustData
);
2745 return E_OUTOFMEMORY
;
2748 /******************************************************************************
2749 * ITypeInfo2_GetAllParamCustData {OLEAUT32}
2751 * Gets all of the custom data associated with a parameter.
2756 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2758 static HRESULT WINAPI
ITypeInfo2_fnGetAllParamCustData(
2759 ITypeInfo2
* iface
, /* [I] The TypeInfo in which to find the custom data. */
2760 UINT indexFunc
, /* [I] The index of the function for which to retrieve the custom data. */
2761 UINT indexParam
, /* [I] The index of the parameter for which to retrieve the custom data. */
2762 CUSTDATA
* pCustData
) /* [O] A pointer to the custom data. */
2764 FIXME("(%p,%d,%d,%p), stub!\n", iface
, indexFunc
, indexParam
, pCustData
);
2765 return E_OUTOFMEMORY
;
2768 /******************************************************************************
2769 * ITypeInfo2_GetAllVarCustData {OLEAUT32}
2771 * Gets all of the custom data associated with a variable.
2776 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2778 static HRESULT WINAPI
ITypeInfo2_fnGetAllVarCustData(
2779 ITypeInfo2
* iface
, /* [I] The TypeInfo in which to find the custom data. */
2780 UINT index
, /* [I] The index of the variable for which to retrieve the custom data. */
2781 CUSTDATA
* pCustData
) /* [O] A pointer to the custom data. */
2783 FIXME("(%p,%d,%p), stub!\n", iface
, index
, pCustData
);
2784 return E_OUTOFMEMORY
;
2787 /******************************************************************************
2788 * ITypeInfo2_GetAllImplTypeCustData {OLEAUT32}
2790 * Gets all of the custom data associated with an implemented type.
2795 * Failure: One of E_OUTOFMEMORY or E_INVALIDARG.
2797 static HRESULT WINAPI
ITypeInfo2_fnGetAllImplTypeCustData(
2798 ITypeInfo2
* iface
, /* [I] The TypeInfo in which to find the custom data. */
2799 UINT index
, /* [I] The index of the implemented type for which to retrieve the custom data. */
2800 CUSTDATA
* pCustData
) /* [O] A pointer to the custom data. */
2802 FIXME("(%p,%d,%p), stub!\n", iface
, index
, pCustData
);
2803 return E_OUTOFMEMORY
;
2807 /*================== ICreateTypeInfo2 & ITypeInfo2 VTABLEs And Creation ===================================*/
2809 static const ICreateTypeInfo2Vtbl ctypeinfo2vt
=
2812 ICreateTypeInfo2_fnQueryInterface
,
2813 ICreateTypeInfo2_fnAddRef
,
2814 ICreateTypeInfo2_fnRelease
,
2816 ICreateTypeInfo2_fnSetGuid
,
2817 ICreateTypeInfo2_fnSetTypeFlags
,
2818 ICreateTypeInfo2_fnSetDocString
,
2819 ICreateTypeInfo2_fnSetHelpContext
,
2820 ICreateTypeInfo2_fnSetVersion
,
2821 ICreateTypeInfo2_fnAddRefTypeInfo
,
2822 ICreateTypeInfo2_fnAddFuncDesc
,
2823 ICreateTypeInfo2_fnAddImplType
,
2824 ICreateTypeInfo2_fnSetImplTypeFlags
,
2825 ICreateTypeInfo2_fnSetAlignment
,
2826 ICreateTypeInfo2_fnSetSchema
,
2827 ICreateTypeInfo2_fnAddVarDesc
,
2828 ICreateTypeInfo2_fnSetFuncAndParamNames
,
2829 ICreateTypeInfo2_fnSetVarName
,
2830 ICreateTypeInfo2_fnSetTypeDescAlias
,
2831 ICreateTypeInfo2_fnDefineFuncAsDllEntry
,
2832 ICreateTypeInfo2_fnSetFuncDocString
,
2833 ICreateTypeInfo2_fnSetVarDocString
,
2834 ICreateTypeInfo2_fnSetFuncHelpContext
,
2835 ICreateTypeInfo2_fnSetVarHelpContext
,
2836 ICreateTypeInfo2_fnSetMops
,
2837 ICreateTypeInfo2_fnSetTypeIdldesc
,
2838 ICreateTypeInfo2_fnLayOut
,
2840 ICreateTypeInfo2_fnDeleteFuncDesc
,
2841 ICreateTypeInfo2_fnDeleteFuncDescByMemId
,
2842 ICreateTypeInfo2_fnDeleteVarDesc
,
2843 ICreateTypeInfo2_fnDeleteVarDescByMemId
,
2844 ICreateTypeInfo2_fnDeleteImplType
,
2845 ICreateTypeInfo2_fnSetCustData
,
2846 ICreateTypeInfo2_fnSetFuncCustData
,
2847 ICreateTypeInfo2_fnSetParamCustData
,
2848 ICreateTypeInfo2_fnSetVarCustData
,
2849 ICreateTypeInfo2_fnSetImplTypeCustData
,
2850 ICreateTypeInfo2_fnSetHelpStringContext
,
2851 ICreateTypeInfo2_fnSetFuncHelpStringContext
,
2852 ICreateTypeInfo2_fnSetVarHelpStringContext
,
2853 ICreateTypeInfo2_fnInvalidate
,
2854 ICreateTypeInfo2_fnSetName
2857 static const ITypeInfo2Vtbl typeinfo2vt
=
2860 ITypeInfo2_fnQueryInterface
,
2861 ITypeInfo2_fnAddRef
,
2862 ITypeInfo2_fnRelease
,
2864 ITypeInfo2_fnGetTypeAttr
,
2865 ITypeInfo2_fnGetTypeComp
,
2866 ITypeInfo2_fnGetFuncDesc
,
2867 ITypeInfo2_fnGetVarDesc
,
2868 ITypeInfo2_fnGetNames
,
2869 ITypeInfo2_fnGetRefTypeOfImplType
,
2870 ITypeInfo2_fnGetImplTypeFlags
,
2871 ITypeInfo2_fnGetIDsOfNames
,
2872 ITypeInfo2_fnInvoke
,
2873 ITypeInfo2_fnGetDocumentation
,
2874 ITypeInfo2_fnGetDllEntry
,
2875 ITypeInfo2_fnGetRefTypeInfo
,
2876 ITypeInfo2_fnAddressOfMember
,
2877 ITypeInfo2_fnCreateInstance
,
2878 ITypeInfo2_fnGetMops
,
2879 ITypeInfo2_fnGetContainingTypeLib
,
2880 ITypeInfo2_fnReleaseTypeAttr
,
2881 ITypeInfo2_fnReleaseFuncDesc
,
2882 ITypeInfo2_fnReleaseVarDesc
,
2884 ITypeInfo2_fnGetTypeKind
,
2885 ITypeInfo2_fnGetTypeFlags
,
2886 ITypeInfo2_fnGetFuncIndexOfMemId
,
2887 ITypeInfo2_fnGetVarIndexOfMemId
,
2888 ITypeInfo2_fnGetCustData
,
2889 ITypeInfo2_fnGetFuncCustData
,
2890 ITypeInfo2_fnGetParamCustData
,
2891 ITypeInfo2_fnGetVarCustData
,
2892 ITypeInfo2_fnGetImplTypeCustData
,
2893 ITypeInfo2_fnGetDocumentation2
,
2894 ITypeInfo2_fnGetAllCustData
,
2895 ITypeInfo2_fnGetAllFuncCustData
,
2896 ITypeInfo2_fnGetAllParamCustData
,
2897 ITypeInfo2_fnGetAllVarCustData
,
2898 ITypeInfo2_fnGetAllImplTypeCustData
,
2901 static ICreateTypeInfo2
*ICreateTypeInfo2_Constructor(ICreateTypeLib2Impl
*typelib
, WCHAR
*szName
, TYPEKIND tkind
)
2903 ICreateTypeInfo2Impl
*pCreateTypeInfo2Impl
;
2906 int typeinfo_offset
;
2907 MSFT_TypeInfoBase
*typeinfo
;
2909 TRACE("Constructing ICreateTypeInfo2 for %s with tkind %d\n", debugstr_w(szName
), tkind
);
2911 pCreateTypeInfo2Impl
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(ICreateTypeInfo2Impl
));
2912 if (!pCreateTypeInfo2Impl
) return NULL
;
2914 pCreateTypeInfo2Impl
->lpVtbl
= &ctypeinfo2vt
;
2915 pCreateTypeInfo2Impl
->lpVtblTypeInfo2
= &typeinfo2vt
;
2916 pCreateTypeInfo2Impl
->ref
= 1;
2918 pCreateTypeInfo2Impl
->typelib
= typelib
;
2921 nameoffset
= ctl2_alloc_name(typelib
, szName
);
2922 typeinfo_offset
= ctl2_alloc_typeinfo(typelib
, nameoffset
);
2923 typeinfo
= (MSFT_TypeInfoBase
*)&typelib
->typelib_segment_data
[MSFT_SEG_TYPEINFO
][typeinfo_offset
];
2925 typelib
->typelib_segment_data
[MSFT_SEG_NAME
][nameoffset
+ 9] = 0x38;
2926 *((int *)&typelib
->typelib_segment_data
[MSFT_SEG_NAME
][nameoffset
]) = typeinfo_offset
;
2928 pCreateTypeInfo2Impl
->typeinfo
= typeinfo
;
2930 typeinfo
->typekind
|= tkind
| 0x20;
2931 ICreateTypeInfo2_SetAlignment((ICreateTypeInfo2
*)pCreateTypeInfo2Impl
, 4);
2935 case TKIND_INTERFACE
:
2936 case TKIND_DISPATCH
:
2951 typeinfo
->size
= -0x75;
2955 FIXME("(%s,%d), unrecognized typekind %d\n", debugstr_w(szName
), tkind
, tkind
);
2956 typeinfo
->size
= 0xdeadbeef;
2960 if (typelib
->last_typeinfo
) typelib
->last_typeinfo
->next_typeinfo
= pCreateTypeInfo2Impl
;
2961 typelib
->last_typeinfo
= pCreateTypeInfo2Impl
;
2962 if (!typelib
->typeinfos
) typelib
->typeinfos
= pCreateTypeInfo2Impl
;
2964 TRACE(" -- %p\n", pCreateTypeInfo2Impl
);
2966 return (ICreateTypeInfo2
*)pCreateTypeInfo2Impl
;
2970 /*================== ICreateTypeLib2 Implementation ===================================*/
2972 /******************************************************************************
2973 * ICreateTypeLib2_QueryInterface {OLEAUT32}
2975 * See IUnknown_QueryInterface.
2977 static HRESULT WINAPI
ICreateTypeLib2_fnQueryInterface(
2978 ICreateTypeLib2
* iface
,
2982 ICreateTypeLib2Impl
*This
= (ICreateTypeLib2Impl
*)iface
;
2984 TRACE("(%p)->(IID: %s)\n",This
,debugstr_guid(riid
));
2987 if(IsEqualIID(riid
, &IID_IUnknown
) ||
2988 IsEqualIID(riid
,&IID_ICreateTypeLib
)||
2989 IsEqualIID(riid
,&IID_ICreateTypeLib2
))
2992 } else if (IsEqualIID(riid
, &IID_ITypeLib
) ||
2993 IsEqualIID(riid
, &IID_ITypeLib2
)) {
2994 *ppvObject
= &This
->lpVtblTypeLib2
;
2999 ICreateTypeLib2_AddRef(iface
);
3000 TRACE("-- Interface: (%p)->(%p)\n",ppvObject
,*ppvObject
);
3003 TRACE("-- Interface: E_NOINTERFACE\n");
3004 return E_NOINTERFACE
;
3007 /******************************************************************************
3008 * ICreateTypeLib2_AddRef {OLEAUT32}
3010 * See IUnknown_AddRef.
3012 static ULONG WINAPI
ICreateTypeLib2_fnAddRef(ICreateTypeLib2
*iface
)
3014 ICreateTypeLib2Impl
*This
= (ICreateTypeLib2Impl
*)iface
;
3015 ULONG ref
= InterlockedIncrement(&This
->ref
);
3017 TRACE("(%p)->ref was %u\n",This
, ref
- 1);
3022 /******************************************************************************
3023 * ICreateTypeLib2_Release {OLEAUT32}
3025 * See IUnknown_Release.
3027 static ULONG WINAPI
ICreateTypeLib2_fnRelease(ICreateTypeLib2
*iface
)
3029 ICreateTypeLib2Impl
*This
= (ICreateTypeLib2Impl
*)iface
;
3030 ULONG ref
= InterlockedDecrement(&This
->ref
);
3032 TRACE("(%p)->(%u)\n",This
, ref
);
3037 for (i
= 0; i
< MSFT_SEG_MAX
; i
++) {
3038 HeapFree(GetProcessHeap(), 0, This
->typelib_segment_data
[i
]);
3039 This
->typelib_segment_data
[i
] = NULL
;
3042 HeapFree(GetProcessHeap(), 0, This
->filename
);
3043 This
->filename
= NULL
;
3045 while (This
->typeinfos
) {
3046 ICreateTypeInfo2Impl
*typeinfo
= This
->typeinfos
;
3047 This
->typeinfos
= typeinfo
->next_typeinfo
;
3048 HeapFree(GetProcessHeap(), 0, typeinfo
->typedata
);
3049 HeapFree(GetProcessHeap(), 0, typeinfo
);
3052 HeapFree(GetProcessHeap(),0,This
);
3060 /******************************************************************************
3061 * ICreateTypeLib2_CreateTypeInfo {OLEAUT32}
3063 * See ICreateTypeLib_CreateTypeInfo.
3065 static HRESULT WINAPI
ICreateTypeLib2_fnCreateTypeInfo(
3066 ICreateTypeLib2
* iface
,
3069 ICreateTypeInfo
**ppCTInfo
)
3071 ICreateTypeLib2Impl
*This
= (ICreateTypeLib2Impl
*)iface
;
3073 TRACE("(%p,%s,%d,%p)\n", iface
, debugstr_w(szName
), tkind
, ppCTInfo
);
3075 *ppCTInfo
= (ICreateTypeInfo
*)ICreateTypeInfo2_Constructor(This
, szName
, tkind
);
3077 if (!*ppCTInfo
) return E_OUTOFMEMORY
;
3082 /******************************************************************************
3083 * ICreateTypeLib2_SetName {OLEAUT32}
3085 * See ICreateTypeLib_SetName.
3087 static HRESULT WINAPI
ICreateTypeLib2_fnSetName(
3088 ICreateTypeLib2
* iface
,
3091 ICreateTypeLib2Impl
*This
= (ICreateTypeLib2Impl
*)iface
;
3095 TRACE("(%p,%s)\n", iface
, debugstr_w(szName
));
3097 offset
= ctl2_alloc_name(This
, szName
);
3098 if (offset
== -1) return E_OUTOFMEMORY
;
3099 This
->typelib_header
.NameOffset
= offset
;
3103 /******************************************************************************
3104 * ICreateTypeLib2_SetVersion {OLEAUT32}
3106 * See ICreateTypeLib_SetVersion.
3108 static HRESULT WINAPI
ICreateTypeLib2_fnSetVersion(ICreateTypeLib2
* iface
, WORD wMajorVerNum
, WORD wMinorVerNum
)
3110 ICreateTypeLib2Impl
*This
= (ICreateTypeLib2Impl
*)iface
;
3112 TRACE("(%p,%d,%d)\n", iface
, wMajorVerNum
, wMinorVerNum
);
3114 This
->typelib_header
.version
= wMajorVerNum
| (wMinorVerNum
<< 16);
3118 /******************************************************************************
3119 * ICreateTypeLib2_SetGuid {OLEAUT32}
3121 * See ICreateTypeLib_SetGuid.
3123 static HRESULT WINAPI
ICreateTypeLib2_fnSetGuid(ICreateTypeLib2
* iface
, REFGUID guid
)
3125 ICreateTypeLib2Impl
*This
= (ICreateTypeLib2Impl
*)iface
;
3127 MSFT_GuidEntry guidentry
;
3130 TRACE("(%p,%s)\n", iface
, debugstr_guid(guid
));
3132 guidentry
.guid
= *guid
;
3133 guidentry
.hreftype
= -2;
3134 guidentry
.next_hash
= -1;
3136 offset
= ctl2_alloc_guid(This
, &guidentry
);
3138 if (offset
== -1) return E_OUTOFMEMORY
;
3140 This
->typelib_header
.posguid
= offset
;
3145 /******************************************************************************
3146 * ICreateTypeLib2_SetDocString {OLEAUT32}
3148 * See ICreateTypeLib_SetDocString.
3150 static HRESULT WINAPI
ICreateTypeLib2_fnSetDocString(ICreateTypeLib2
* iface
, LPOLESTR szDoc
)
3152 ICreateTypeLib2Impl
*This
= (ICreateTypeLib2Impl
*)iface
;
3156 TRACE("(%p,%s)\n", iface
, debugstr_w(szDoc
));
3158 offset
= ctl2_alloc_string(This
, szDoc
);
3159 if (offset
== -1) return E_OUTOFMEMORY
;
3160 This
->typelib_header
.helpstring
= offset
;
3164 /******************************************************************************
3165 * ICreateTypeLib2_SetHelpFileName {OLEAUT32}
3167 * See ICreateTypeLib_SetHelpFileName.
3169 static HRESULT WINAPI
ICreateTypeLib2_fnSetHelpFileName(ICreateTypeLib2
* iface
, LPOLESTR szHelpFileName
)
3171 ICreateTypeLib2Impl
*This
= (ICreateTypeLib2Impl
*)iface
;
3175 TRACE("(%p,%s)\n", iface
, debugstr_w(szHelpFileName
));
3177 offset
= ctl2_alloc_string(This
, szHelpFileName
);
3178 if (offset
== -1) return E_OUTOFMEMORY
;
3179 This
->typelib_header
.helpfile
= offset
;
3180 This
->typelib_header
.varflags
|= 0x10;
3184 /******************************************************************************
3185 * ICreateTypeLib2_SetHelpContext {OLEAUT32}
3187 * See ICreateTypeLib_SetHelpContext.
3189 static HRESULT WINAPI
ICreateTypeLib2_fnSetHelpContext(ICreateTypeLib2
* iface
, DWORD dwHelpContext
)
3191 FIXME("(%p,%d), stub!\n", iface
, dwHelpContext
);
3192 return E_OUTOFMEMORY
;
3195 /******************************************************************************
3196 * ICreateTypeLib2_SetLcid {OLEAUT32}
3198 * See ICreateTypeLib_SetLcid.
3200 static HRESULT WINAPI
ICreateTypeLib2_fnSetLcid(ICreateTypeLib2
* iface
, LCID lcid
)
3202 ICreateTypeLib2Impl
*This
= (ICreateTypeLib2Impl
*)iface
;
3204 TRACE("(%p,%d)\n", iface
, lcid
);
3206 This
->typelib_header
.lcid
= This
->typelib_header
.lcid2
= lcid
;
3211 /******************************************************************************
3212 * ICreateTypeLib2_SetLibFlags {OLEAUT32}
3214 * See ICreateTypeLib_SetLibFlags.
3216 static HRESULT WINAPI
ICreateTypeLib2_fnSetLibFlags(ICreateTypeLib2
* iface
, UINT uLibFlags
)
3218 ICreateTypeLib2Impl
*This
= (ICreateTypeLib2Impl
*)iface
;
3220 TRACE("(%p,0x%x)\n", iface
, uLibFlags
);
3222 This
->typelib_header
.flags
= uLibFlags
;
3227 static int ctl2_write_chunk(HANDLE hFile
, const void *segment
, int length
)
3230 if (!WriteFile(hFile
, segment
, length
, &dwWritten
, 0)) {
3237 static int ctl2_write_segment(ICreateTypeLib2Impl
*This
, HANDLE hFile
, int segment
)
3240 if (!WriteFile(hFile
, This
->typelib_segment_data
[segment
],
3241 This
->typelib_segdir
[segment
].length
, &dwWritten
, 0)) {
3249 static void ctl2_finalize_typeinfos(ICreateTypeLib2Impl
*This
, int filesize
)
3251 ICreateTypeInfo2Impl
*typeinfo
;
3253 for (typeinfo
= This
->typeinfos
; typeinfo
; typeinfo
= typeinfo
->next_typeinfo
) {
3254 typeinfo
->typeinfo
->memoffset
= filesize
;
3255 if (typeinfo
->typedata
) {
3256 ICreateTypeInfo2_fnLayOut((ICreateTypeInfo2
*)typeinfo
);
3257 filesize
+= typeinfo
->typedata
[0] + ((typeinfo
->typeinfo
->cElement
>> 16) * 12) + ((typeinfo
->typeinfo
->cElement
& 0xffff) * 12) + 4;
3262 static int ctl2_finalize_segment(ICreateTypeLib2Impl
*This
, int filepos
, int segment
)
3264 if (This
->typelib_segdir
[segment
].length
) {
3265 This
->typelib_segdir
[segment
].offset
= filepos
;
3267 This
->typelib_segdir
[segment
].offset
= -1;
3270 return This
->typelib_segdir
[segment
].length
;
3273 static void ctl2_write_typeinfos(ICreateTypeLib2Impl
*This
, HANDLE hFile
)
3275 ICreateTypeInfo2Impl
*typeinfo
;
3277 for (typeinfo
= This
->typeinfos
; typeinfo
; typeinfo
= typeinfo
->next_typeinfo
) {
3278 if (!typeinfo
->typedata
) continue;
3280 ctl2_write_chunk(hFile
, typeinfo
->typedata
, typeinfo
->typedata
[0] + 4);
3281 ctl2_write_chunk(hFile
, typeinfo
->indices
, ((typeinfo
->typeinfo
->cElement
& 0xffff) + (typeinfo
->typeinfo
->cElement
>> 16)) * 4);
3282 ctl2_write_chunk(hFile
, typeinfo
->names
, ((typeinfo
->typeinfo
->cElement
& 0xffff) + (typeinfo
->typeinfo
->cElement
>> 16)) * 4);
3283 ctl2_write_chunk(hFile
, typeinfo
->offsets
, ((typeinfo
->typeinfo
->cElement
& 0xffff) + (typeinfo
->typeinfo
->cElement
>> 16)) * 4);
3287 /******************************************************************************
3288 * ICreateTypeLib2_SaveAllChanges {OLEAUT32}
3290 * See ICreateTypeLib_SaveAllChanges.
3292 static HRESULT WINAPI
ICreateTypeLib2_fnSaveAllChanges(ICreateTypeLib2
* iface
)
3294 ICreateTypeLib2Impl
*This
= (ICreateTypeLib2Impl
*)iface
;
3300 TRACE("(%p)\n", iface
);
3302 retval
= TYPE_E_IOERROR
;
3304 hFile
= CreateFileW(This
->filename
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, 0);
3305 if (hFile
== INVALID_HANDLE_VALUE
) return retval
;
3307 filepos
= sizeof(MSFT_Header
) + sizeof(MSFT_SegDir
);
3308 filepos
+= This
->typelib_header
.nrtypeinfos
* 4;
3310 filepos
+= ctl2_finalize_segment(This
, filepos
, MSFT_SEG_TYPEINFO
);
3311 filepos
+= ctl2_finalize_segment(This
, filepos
, MSFT_SEG_GUIDHASH
);
3312 filepos
+= ctl2_finalize_segment(This
, filepos
, MSFT_SEG_GUID
);
3313 filepos
+= ctl2_finalize_segment(This
, filepos
, MSFT_SEG_IMPORTINFO
);
3314 filepos
+= ctl2_finalize_segment(This
, filepos
, MSFT_SEG_IMPORTFILES
);
3315 filepos
+= ctl2_finalize_segment(This
, filepos
, MSFT_SEG_REFERENCES
);
3316 filepos
+= ctl2_finalize_segment(This
, filepos
, MSFT_SEG_NAMEHASH
);
3317 filepos
+= ctl2_finalize_segment(This
, filepos
, MSFT_SEG_NAME
);
3318 filepos
+= ctl2_finalize_segment(This
, filepos
, MSFT_SEG_STRING
);
3319 filepos
+= ctl2_finalize_segment(This
, filepos
, MSFT_SEG_TYPEDESC
);
3320 filepos
+= ctl2_finalize_segment(This
, filepos
, MSFT_SEG_ARRAYDESC
);
3321 filepos
+= ctl2_finalize_segment(This
, filepos
, MSFT_SEG_CUSTDATA
);
3322 filepos
+= ctl2_finalize_segment(This
, filepos
, MSFT_SEG_CUSTDATAGUID
);
3324 ctl2_finalize_typeinfos(This
, filepos
);
3326 if (!ctl2_write_chunk(hFile
, &This
->typelib_header
, sizeof(This
->typelib_header
))) return retval
;
3327 if (!ctl2_write_chunk(hFile
, This
->typelib_typeinfo_offsets
, This
->typelib_header
.nrtypeinfos
* 4)) return retval
;
3328 if (!ctl2_write_chunk(hFile
, &This
->typelib_segdir
, sizeof(This
->typelib_segdir
))) return retval
;
3329 if (!ctl2_write_segment(This
, hFile
, MSFT_SEG_TYPEINFO
)) return retval
;
3330 if (!ctl2_write_segment(This
, hFile
, MSFT_SEG_GUIDHASH
)) return retval
;
3331 if (!ctl2_write_segment(This
, hFile
, MSFT_SEG_GUID
)) return retval
;
3332 if (!ctl2_write_segment(This
, hFile
, MSFT_SEG_IMPORTINFO
)) return retval
;
3333 if (!ctl2_write_segment(This
, hFile
, MSFT_SEG_IMPORTFILES
)) return retval
;
3334 if (!ctl2_write_segment(This
, hFile
, MSFT_SEG_REFERENCES
)) return retval
;
3335 if (!ctl2_write_segment(This
, hFile
, MSFT_SEG_NAMEHASH
)) return retval
;
3336 if (!ctl2_write_segment(This
, hFile
, MSFT_SEG_NAME
)) return retval
;
3337 if (!ctl2_write_segment(This
, hFile
, MSFT_SEG_STRING
)) return retval
;
3338 if (!ctl2_write_segment(This
, hFile
, MSFT_SEG_TYPEDESC
)) return retval
;
3339 if (!ctl2_write_segment(This
, hFile
, MSFT_SEG_ARRAYDESC
)) return retval
;
3340 if (!ctl2_write_segment(This
, hFile
, MSFT_SEG_CUSTDATA
)) return retval
;
3341 if (!ctl2_write_segment(This
, hFile
, MSFT_SEG_CUSTDATAGUID
)) return retval
;
3343 ctl2_write_typeinfos(This
, hFile
);
3345 if (!CloseHandle(hFile
)) return retval
;
3352 /******************************************************************************
3353 * ICreateTypeLib2_DeleteTypeInfo {OLEAUT32}
3355 * Deletes a named TypeInfo from a type library.
3360 * Failure: E_OUTOFMEMORY or E_INVALIDARG.
3362 static HRESULT WINAPI
ICreateTypeLib2_fnDeleteTypeInfo(
3363 ICreateTypeLib2
* iface
, /* [I] The type library to delete from. */
3364 LPOLESTR szName
) /* [I] The name of the typeinfo to delete. */
3366 FIXME("(%p,%s), stub!\n", iface
, debugstr_w(szName
));
3367 return E_OUTOFMEMORY
;
3370 /******************************************************************************
3371 * ICreateTypeLib2_SetCustData {OLEAUT32}
3373 * Sets custom data for a type library.
3378 * Failure: E_OUTOFMEMORY or E_INVALIDARG.
3380 static HRESULT WINAPI
ICreateTypeLib2_fnSetCustData(
3381 ICreateTypeLib2
* iface
, /* [I] The type library to store the custom data in. */
3382 REFGUID guid
, /* [I] The GUID used as a key to retrieve the custom data. */
3383 VARIANT
*pVarVal
) /* [I] The custom data itself. */
3385 ICreateTypeLib2Impl
*This
= (ICreateTypeLib2Impl
*)iface
;
3387 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(guid
), pVarVal
);
3389 return ctl2_set_custdata(This
, guid
, pVarVal
, &This
->typelib_header
.CustomDataOffset
);
3392 /******************************************************************************
3393 * ICreateTypeLib2_SetHelpStringContext {OLEAUT32}
3395 * Sets a context number for the library help string.
3400 * Failure: E_OUTOFMEMORY or E_INVALIDARG.
3402 static HRESULT WINAPI
ICreateTypeLib2_fnSetHelpStringContext(
3403 ICreateTypeLib2
* iface
, /* [I] The type library to set the help string context for. */
3404 ULONG dwHelpStringContext
) /* [I] The help string context. */
3406 FIXME("(%p,%d), stub!\n", iface
, dwHelpStringContext
);
3407 return E_OUTOFMEMORY
;
3410 /******************************************************************************
3411 * ICreateTypeLib2_SetHelpStringDll {OLEAUT32}
3413 * Sets the DLL used to look up localized help strings.
3418 * Failure: E_OUTOFMEMORY or E_INVALIDARG.
3420 static HRESULT WINAPI
ICreateTypeLib2_fnSetHelpStringDll(
3421 ICreateTypeLib2
* iface
, /* [I] The type library to set the help DLL for. */
3422 LPOLESTR szFileName
) /* [I] The name of the help DLL. */
3424 FIXME("(%p,%s), stub!\n", iface
, debugstr_w(szFileName
));
3425 return E_OUTOFMEMORY
;
3428 /*================== ITypeLib2 Implementation ===================================*/
3430 /******************************************************************************
3431 * ITypeLib2_QueryInterface {OLEAUT32}
3433 * See IUnknown_QueryInterface.
3435 static HRESULT WINAPI
ITypeLib2_fnQueryInterface(ITypeLib2
* iface
, REFIID riid
, LPVOID
* ppv
)
3437 ICreateTypeLib2Impl
*This
= impl_from_ITypeLib2(iface
);
3439 return ICreateTypeLib2_QueryInterface((ICreateTypeLib2
*)This
, riid
, ppv
);
3442 /******************************************************************************
3443 * ITypeLib2_AddRef {OLEAUT32}
3445 * See IUnknown_AddRef.
3447 static ULONG WINAPI
ITypeLib2_fnAddRef(ITypeLib2
* iface
)
3449 ICreateTypeLib2Impl
*This
= impl_from_ITypeLib2(iface
);
3451 return ICreateTypeLib2_AddRef((ICreateTypeLib2
*)This
);
3454 /******************************************************************************
3455 * ITypeLib2_Release {OLEAUT32}
3457 * See IUnknown_Release.
3459 static ULONG WINAPI
ITypeLib2_fnRelease(ITypeLib2
* iface
)
3461 ICreateTypeLib2Impl
*This
= impl_from_ITypeLib2(iface
);
3463 return ICreateTypeLib2_Release((ICreateTypeLib2
*)This
);
3466 /******************************************************************************
3467 * ITypeLib2_GetTypeInfoCount {OLEAUT32}
3469 * See ITypeLib_GetTypeInfoCount.
3471 static UINT WINAPI
ITypeLib2_fnGetTypeInfoCount(
3474 ICreateTypeLib2Impl
*This
= impl_from_ITypeLib2(iface
);
3476 TRACE("(%p)\n", iface
);
3478 return This
->typelib_header
.nrtypeinfos
;
3481 /******************************************************************************
3482 * ITypeLib2_GetTypeInfo {OLEAUT32}
3484 * See ITypeLib_GetTypeInfo.
3486 static HRESULT WINAPI
ITypeLib2_fnGetTypeInfo(
3489 ITypeInfo
** ppTInfo
)
3491 ICreateTypeLib2Impl
*This
= impl_from_ITypeLib2(iface
);
3493 TRACE("(%p,%d,%p)\n", iface
, index
, ppTInfo
);
3495 if (index
>= This
->typelib_header
.nrtypeinfos
) {
3496 return TYPE_E_ELEMENTNOTFOUND
;
3499 return ctl2_find_typeinfo_from_offset(This
, This
->typelib_typeinfo_offsets
[index
], ppTInfo
);
3502 /******************************************************************************
3503 * ITypeLib2_GetTypeInfoType {OLEAUT32}
3505 * See ITypeLib_GetTypeInfoType.
3507 static HRESULT WINAPI
ITypeLib2_fnGetTypeInfoType(
3512 ICreateTypeLib2Impl
*This
= impl_from_ITypeLib2(iface
);
3514 TRACE("(%p,%d,%p)\n", iface
, index
, pTKind
);
3516 if (index
>= This
->typelib_header
.nrtypeinfos
) {
3517 return TYPE_E_ELEMENTNOTFOUND
;
3520 *pTKind
= (This
->typelib_segment_data
[MSFT_SEG_TYPEINFO
][This
->typelib_typeinfo_offsets
[index
]]) & 15;
3525 /******************************************************************************
3526 * ITypeLib2_GetTypeInfoOfGuid {OLEAUT32}
3528 * See ITypeLib_GetTypeInfoOfGuid.
3530 static HRESULT WINAPI
ITypeLib2_fnGetTypeInfoOfGuid(
3533 ITypeInfo
** ppTinfo
)
3535 ICreateTypeLib2Impl
*This
= impl_from_ITypeLib2(iface
);
3540 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(guid
), ppTinfo
);
3542 guidoffset
= ctl2_find_guid(This
, ctl2_hash_guid(guid
), guid
);
3543 if (guidoffset
== -1) return TYPE_E_ELEMENTNOTFOUND
;
3545 typeinfo
= ((MSFT_GuidEntry
*)&This
->typelib_segment_data
[MSFT_SEG_GUID
][guidoffset
])->hreftype
;
3546 if (typeinfo
< 0) return TYPE_E_ELEMENTNOTFOUND
;
3548 return ctl2_find_typeinfo_from_offset(This
, typeinfo
, ppTinfo
);
3551 /******************************************************************************
3552 * ITypeLib2_GetLibAttr {OLEAUT32}
3554 * See ITypeLib_GetLibAttr.
3556 static HRESULT WINAPI
ITypeLib2_fnGetLibAttr(
3558 TLIBATTR
** ppTLibAttr
)
3560 ICreateTypeLib2Impl
*This
= impl_from_ITypeLib2(iface
);
3562 FIXME("(%p,%p), stub!\n", This
, ppTLibAttr
);
3564 return E_OUTOFMEMORY
;
3567 /******************************************************************************
3568 * ITypeLib2_GetTypeComp {OLEAUT32}
3570 * See ITypeLib_GetTypeComp.
3572 static HRESULT WINAPI
ITypeLib2_fnGetTypeComp(
3574 ITypeComp
** ppTComp
)
3576 ICreateTypeLib2Impl
*This
= impl_from_ITypeLib2(iface
);
3578 FIXME("(%p,%p), stub!\n", This
, ppTComp
);
3580 return E_OUTOFMEMORY
;
3583 /******************************************************************************
3584 * ITypeLib2_GetDocumentation {OLEAUT32}
3586 * See ITypeLib_GetDocumentation.
3588 static HRESULT WINAPI
ITypeLib2_fnGetDocumentation(
3592 BSTR
* pBstrDocString
,
3593 DWORD
* pdwHelpContext
,
3594 BSTR
* pBstrHelpFile
)
3596 ICreateTypeLib2Impl
*This
= impl_from_ITypeLib2(iface
);
3598 FIXME("(%p,%d,%p,%p,%p,%p), stub!\n", This
, index
, pBstrName
, pBstrDocString
, pdwHelpContext
, pBstrHelpFile
);
3600 return E_OUTOFMEMORY
;
3603 /******************************************************************************
3604 * ITypeLib2_IsName {OLEAUT32}
3606 * See ITypeLib_IsName.
3608 static HRESULT WINAPI
ITypeLib2_fnIsName(
3614 ICreateTypeLib2Impl
*This
= impl_from_ITypeLib2(iface
);
3618 MSFT_NameIntro
*nameintro
;
3620 TRACE("(%p,%s,%x,%p)\n", iface
, debugstr_w(szNameBuf
), lHashVal
, pfName
);
3622 ctl2_encode_name(This
, szNameBuf
, &encoded_name
);
3623 nameoffset
= ctl2_find_name(This
, encoded_name
);
3627 if (nameoffset
== -1) return S_OK
;
3629 nameintro
= (MSFT_NameIntro
*)(&This
->typelib_segment_data
[MSFT_SEG_NAME
][nameoffset
]);
3630 if (nameintro
->hreftype
== -1) return S_OK
;
3634 FIXME("Should be decoding our copy of the name over szNameBuf.\n");
3639 /******************************************************************************
3640 * ITypeLib2_FindName {OLEAUT32}
3642 * See ITypeLib_FindName.
3644 static HRESULT WINAPI
ITypeLib2_fnFindName(
3648 ITypeInfo
** ppTInfo
,
3652 ICreateTypeLib2Impl
*This
= impl_from_ITypeLib2(iface
);
3654 FIXME("(%p,%s,%x,%p,%p,%p), stub!\n", This
, debugstr_w(szNameBuf
), lHashVal
, ppTInfo
, rgMemId
, pcFound
);
3656 return E_OUTOFMEMORY
;
3659 /******************************************************************************
3660 * ITypeLib2_ReleaseTLibAttr {OLEAUT32}
3662 * See ITypeLib_ReleaseTLibAttr.
3664 static void WINAPI
ITypeLib2_fnReleaseTLibAttr(
3666 TLIBATTR
* pTLibAttr
)
3668 ICreateTypeLib2Impl
*This
= impl_from_ITypeLib2(iface
);
3670 FIXME("(%p,%p), stub!\n", This
, pTLibAttr
);
3673 /******************************************************************************
3674 * ICreateTypeLib2_GetCustData {OLEAUT32}
3676 * Retrieves a custom data value stored on a type library.
3681 * Failure: E_OUTOFMEMORY or E_INVALIDARG.
3683 static HRESULT WINAPI
ITypeLib2_fnGetCustData(
3684 ITypeLib2
* iface
, /* [I] The type library in which to find the custom data. */
3685 REFGUID guid
, /* [I] The GUID under which the custom data is stored. */
3686 VARIANT
* pVarVal
) /* [O] The custom data. */
3688 ICreateTypeLib2Impl
*This
= impl_from_ITypeLib2(iface
);
3690 FIXME("(%p,%s,%p), stub!\n", This
, debugstr_guid(guid
), pVarVal
);
3692 return E_OUTOFMEMORY
;
3695 /******************************************************************************
3696 * ICreateTypeLib2_GetLibStatistics {OLEAUT32}
3698 * Retrieves some statistics about names in a type library, supposedly for
3699 * hash table optimization purposes.
3704 * Failure: E_OUTOFMEMORY or E_INVALIDARG.
3706 static HRESULT WINAPI
ITypeLib2_fnGetLibStatistics(
3707 ITypeLib2
* iface
, /* [I] The type library to get statistics about. */
3708 ULONG
* pcUniqueNames
, /* [O] The number of unique names in the type library. */
3709 ULONG
* pcchUniqueNames
) /* [O] The number of changed (?) characters in names in the type library. */
3711 ICreateTypeLib2Impl
*This
= impl_from_ITypeLib2(iface
);
3713 FIXME("(%p,%p,%p), stub!\n", This
, pcUniqueNames
, pcchUniqueNames
);
3715 return E_OUTOFMEMORY
;
3718 /******************************************************************************
3719 * ICreateTypeLib2_GetDocumentation2 {OLEAUT32}
3721 * Obtain locale-aware help string information.
3726 * Failure: STG_E_INSUFFICIENTMEMORY or E_INVALIDARG.
3728 static HRESULT WINAPI
ITypeLib2_fnGetDocumentation2(
3732 BSTR
* pbstrHelpString
,
3733 DWORD
* pdwHelpStringContext
,
3734 BSTR
* pbstrHelpStringDll
)
3736 ICreateTypeLib2Impl
*This
= impl_from_ITypeLib2(iface
);
3738 FIXME("(%p,%d,%d,%p,%p,%p), stub!\n", This
, index
, lcid
, pbstrHelpString
, pdwHelpStringContext
, pbstrHelpStringDll
);
3740 return E_OUTOFMEMORY
;
3743 /******************************************************************************
3744 * ICreateTypeLib2_GetAllCustData {OLEAUT32}
3746 * Retrieve all of the custom data for a type library.
3751 * Failure: E_OUTOFMEMORY or E_INVALIDARG.
3753 static HRESULT WINAPI
ITypeLib2_fnGetAllCustData(
3754 ITypeLib2
* iface
, /* [I] The type library in which to find the custom data. */
3755 CUSTDATA
* pCustData
) /* [O] The structure in which to place the custom data. */
3757 ICreateTypeLib2Impl
*This
= impl_from_ITypeLib2(iface
);
3759 FIXME("(%p,%p), stub!\n", This
, pCustData
);
3761 return E_OUTOFMEMORY
;
3765 /*================== ICreateTypeLib2 & ITypeLib2 VTABLEs And Creation ===================================*/
3767 static const ICreateTypeLib2Vtbl ctypelib2vt
=
3770 ICreateTypeLib2_fnQueryInterface
,
3771 ICreateTypeLib2_fnAddRef
,
3772 ICreateTypeLib2_fnRelease
,
3774 ICreateTypeLib2_fnCreateTypeInfo
,
3775 ICreateTypeLib2_fnSetName
,
3776 ICreateTypeLib2_fnSetVersion
,
3777 ICreateTypeLib2_fnSetGuid
,
3778 ICreateTypeLib2_fnSetDocString
,
3779 ICreateTypeLib2_fnSetHelpFileName
,
3780 ICreateTypeLib2_fnSetHelpContext
,
3781 ICreateTypeLib2_fnSetLcid
,
3782 ICreateTypeLib2_fnSetLibFlags
,
3783 ICreateTypeLib2_fnSaveAllChanges
,
3785 ICreateTypeLib2_fnDeleteTypeInfo
,
3786 ICreateTypeLib2_fnSetCustData
,
3787 ICreateTypeLib2_fnSetHelpStringContext
,
3788 ICreateTypeLib2_fnSetHelpStringDll
3791 static const ITypeLib2Vtbl typelib2vt
=
3794 ITypeLib2_fnQueryInterface
,
3796 ITypeLib2_fnRelease
,
3798 ITypeLib2_fnGetTypeInfoCount
,
3799 ITypeLib2_fnGetTypeInfo
,
3800 ITypeLib2_fnGetTypeInfoType
,
3801 ITypeLib2_fnGetTypeInfoOfGuid
,
3802 ITypeLib2_fnGetLibAttr
,
3803 ITypeLib2_fnGetTypeComp
,
3804 ITypeLib2_fnGetDocumentation
,
3806 ITypeLib2_fnFindName
,
3807 ITypeLib2_fnReleaseTLibAttr
,
3809 ITypeLib2_fnGetCustData
,
3810 ITypeLib2_fnGetLibStatistics
,
3811 ITypeLib2_fnGetDocumentation2
,
3812 ITypeLib2_fnGetAllCustData
,
3815 static ICreateTypeLib2
*ICreateTypeLib2_Constructor(SYSKIND syskind
, LPCOLESTR szFile
)
3817 ICreateTypeLib2Impl
*pCreateTypeLib2Impl
;
3820 TRACE("Constructing ICreateTypeLib2 (%d, %s)\n", syskind
, debugstr_w(szFile
));
3822 pCreateTypeLib2Impl
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(ICreateTypeLib2Impl
));
3823 if (!pCreateTypeLib2Impl
) return NULL
;
3825 pCreateTypeLib2Impl
->filename
= HeapAlloc(GetProcessHeap(), 0, (strlenW(szFile
) + 1) * sizeof(WCHAR
));
3826 if (!pCreateTypeLib2Impl
->filename
) {
3827 HeapFree(GetProcessHeap(), 0, pCreateTypeLib2Impl
);
3830 strcpyW(pCreateTypeLib2Impl
->filename
, szFile
);
3832 ctl2_init_header(pCreateTypeLib2Impl
);
3833 ctl2_init_segdir(pCreateTypeLib2Impl
);
3835 pCreateTypeLib2Impl
->typelib_header
.varflags
|= syskind
;
3838 * The following two calls return an offset or -1 if out of memory. We
3839 * specifically need an offset of 0, however, so...
3841 if (ctl2_alloc_segment(pCreateTypeLib2Impl
, MSFT_SEG_GUIDHASH
, 0x80, 0x80)) { failed
= 1; }
3842 if (ctl2_alloc_segment(pCreateTypeLib2Impl
, MSFT_SEG_NAMEHASH
, 0x200, 0x200)) { failed
= 1; }
3844 pCreateTypeLib2Impl
->typelib_guidhash_segment
= (int *)pCreateTypeLib2Impl
->typelib_segment_data
[MSFT_SEG_GUIDHASH
];
3845 pCreateTypeLib2Impl
->typelib_namehash_segment
= (int *)pCreateTypeLib2Impl
->typelib_segment_data
[MSFT_SEG_NAMEHASH
];
3847 memset(pCreateTypeLib2Impl
->typelib_guidhash_segment
, 0xff, 0x80);
3848 memset(pCreateTypeLib2Impl
->typelib_namehash_segment
, 0xff, 0x200);
3850 pCreateTypeLib2Impl
->lpVtbl
= &ctypelib2vt
;
3851 pCreateTypeLib2Impl
->lpVtblTypeLib2
= &typelib2vt
;
3852 pCreateTypeLib2Impl
->ref
= 1;
3855 ICreateTypeLib2_fnRelease((ICreateTypeLib2
*)pCreateTypeLib2Impl
);
3859 return (ICreateTypeLib2
*)pCreateTypeLib2Impl
;
3862 /******************************************************************************
3863 * CreateTypeLib2 [OLEAUT32.180]
3865 * Obtains an ICreateTypeLib2 object for creating a new-style (MSFT) type
3870 * See also CreateTypeLib.
3876 HRESULT WINAPI
CreateTypeLib2(
3877 SYSKIND syskind
, /* [I] System type library is for */
3878 LPCOLESTR szFile
, /* [I] Type library file name */
3879 ICreateTypeLib2
** ppctlib
) /* [O] Storage for object returned */
3881 TRACE("(%d,%s,%p)\n", syskind
, debugstr_w(szFile
), ppctlib
);
3883 if (!szFile
) return E_INVALIDARG
;
3884 *ppctlib
= ICreateTypeLib2_Constructor(syskind
, szFile
);
3885 return (*ppctlib
)? S_OK
: E_OUTOFMEMORY
;
3888 /******************************************************************************
3889 * ClearCustData (OLEAUT32.171)
3891 * Clear a custom data types' data.
3894 * lpCust [I] The custom data type instance
3899 void WINAPI
ClearCustData(LPCUSTDATA lpCust
)
3901 if (lpCust
&& lpCust
->cCustData
)
3903 if (lpCust
->prgCustData
)
3907 for (i
= 0; i
< lpCust
->cCustData
; i
++)
3908 VariantClear(&lpCust
->prgCustData
[i
].varValue
);
3910 /* FIXME - Should be using a per-thread IMalloc */
3911 HeapFree(GetProcessHeap(), 0, lpCust
->prgCustData
);
3912 lpCust
->prgCustData
= NULL
;
3914 lpCust
->cCustData
= 0;