ReactOS 0.4.16-dev-1946-g52006dd
write_sltg.c
Go to the documentation of this file.
1/*
2 * Typelib (SLTG) generation
3 *
4 * Copyright 2015,2016 Dmitry Timoshkov
5 *
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.
10 *
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.
15 *
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
19 */
20
21#include "config.h"
22
23#include <stdlib.h>
24#include <string.h>
25#include <stdarg.h>
26#include <stdio.h>
27#include <ctype.h>
28#include <time.h>
29
30#include "widl.h"
31#ifdef __REACTOS__
32#include <typedefs.h>
33#include <nls.h>
34#include <stddef.h>
35#else
36#include "windef.h"
37#include "winbase.h"
38#endif
39
40#include "typelib.h"
41#include "typelib_struct.h"
42#include "utils.h"
43#include "header.h"
44#include "typetree.h"
45
46#ifdef __REACTOS__
47
48typedef struct _GUID
49{
50#ifdef _MSC_VER
51 unsigned long Data1;
52#else
53 unsigned int Data1;
54#endif
55 unsigned short Data2;
56 unsigned short Data3;
57 unsigned char Data4[ 8 ];
58} GUID;
59#endif
60
61static const GUID sltg_library_guid = { 0x204ff,0,0,{ 0xc0,0,0,0,0,0,0,0x46 } };
62
64{
66 char *data;
67};
68
70{
71 short name;
73 char *helpfile;
80};
81
83{
84 int length;
86 void *data;
87};
88
90{
101};
102
104{
106 int *href;
107};
108
109#include "pshpack1.h"
111{
112 short magic;
114 int res06;
116 int res0e;
118 int res16;
119 struct
120 {
121 unsigned unknown1 : 3;
122 unsigned flags : 13;
123 unsigned unknown2 : 8;
124 unsigned typekind : 8;
126 int res1e;
127};
128
130{
131 short res00;
132 short res02;
133 char res04;
134 int extra;
135};
136
138{
139 char magic; /* 0x0a */
140 char flags;
141 short next;
142 short name;
143 short byte_offs; /* pos in struct, or offset to const type or const data (if flags & 0x08) */
144 short type; /* if flags & 0x02 this is the type, else offset to type */
145 int memid;
148 short varflags; /* only present if magic & 0x20 */
149};
150
152{
153 short cFuncs;
154 short cVars;
156 short res06; /* always 0000 */
157 short funcs_off; /* offset to functions (starting from the member header) */
158 short vars_off; /* offset to vars (starting from the member header) */
159 short impls_off; /* offset to implemented types (starting from the member header) */
160 short funcs_bytes; /* bytes used by function data */
161 short vars_bytes; /* bytes used by var data */
162 short impls_bytes; /* bytes used by implemented type data */
163 short tdescalias_vt; /* for TKIND_ALIAS */
164 short res16; /* always ffff */
165 short res18; /* always 0000 */
166 short res1a; /* always 0000 */
167 short simple_alias; /* tdescalias_vt is a vt rather than an offset? */
168 short res1e; /* always 0000 */
171 short res24;
172 short res26;
174 short res2a; /* always ffff */
175 short res2c; /* always ffff */
176 short res2e; /* always ffff */
177 short res30; /* always ffff */
178 short res32; /* unknown */
179 short type_bytes; /* bytes used by type descriptions */
180};
181
183{
184 char magic; /* 0xdf */
185 char res01; /* 0x00 */
186 char res02[0x42]; /* 0xff... */
187 int number; /* this is 8 times the number of refs */
188 /* Now we have number bytes (8 for each ref) of SLTG_UnknownRefInfo */
189
190 short res50;/* 0xffff */
191 char res52; /* 0x01 */
192 int res53; /* 0x00000000 */
193 /* Now we have number/8 SLTG_Names (first WORD is no of bytes in the ascii
194 * string). Strings look like "*\Rxxxx*#n". If xxxx == ffff then the
195 * ref refers to the nth type listed in this library (0 based). Else
196 * the xxxx (which maybe fewer than 4 digits) is the offset into the name
197 * table to a string "*\G{<guid>}#1.0#0#C:\WINNT\System32\stdole32.tlb#"
198 * The guid is the typelib guid; the ref again refers to the nth type of
199 * the imported typelib.
200 */
201
202 char resxx; /* 0xdf */
203};
204
206{
207 char magic; /* 0x4c, 0xcb or 0x8b with optional SLTG_FUNCTION_FLAGS_PRESENT flag */
208 char flags; /* high nibble is INVOKE_KIND, low nibble = 2 */
209 short next; /* byte offset from beginning of group to next fn */
210 short name; /* Offset within name table to name */
211 int dispid; /* dispid */
212 short helpcontext; /* helpcontext (again 1 is special) */
213 short helpstring; /* helpstring offset to offset */
214 short arg_off; /* offset to args from start of block */
215 char nacc; /* lowest 3bits are CALLCONV, rest are no of args */
216 char retnextopt; /* if 0x80 bit set ret type follows else next WORD
217 is offset to ret type. No of optional args is
218 middle 6 bits */
219 short rettype; /* return type VT_?? or offset to ret type */
220 short vtblpos; /* position in vtbl? */
221 short funcflags; /* present if magic & 0x20 */
222/* Param list starts, repeat next two as required */
223#if 0
224 WORD name; /* offset to 2nd letter of name */
225 WORD+ type; /* VT_ of param */
226#endif
227};
228
230{
231 short res00;
232 short next;
233 short res04;
235 char res07;
236 short res08;
237 short ref;
238 short res0c;
239 short res0e;
240 short res10;
241 short res12;
242 short pos;
243};
244
245#include "poppack.h"
246
249static void add_enum_typeinfo(struct sltg_typelib *typelib, type_t *type);
250static void add_union_typeinfo(struct sltg_typelib *typelib, type_t *type);
252
253static void init_sltg_data(struct sltg_data *data)
254{
255 data->size = 0;
256 data->allocated = 0;
257 data->data = NULL;
258}
259
260static int add_index(struct sltg_data *index, const char *name)
261{
262 int name_offset = index->size;
263 int new_size = index->size + strlen(name) + 1;
264
265 chat("add_index: name_offset %d, \"%s\"\n", name_offset, name);
266
267 if (new_size > index->allocated)
268 {
269 index->allocated = index->allocated ? max(index->allocated * 2, new_size) : new_size;
270 index->data = xrealloc(index->data, index->allocated);
271 }
272
273 strcpy(index->data + index->size, name);
274 index->size = new_size;
275
276 return name_offset;
277}
278
279static void init_index(struct sltg_data *index)
280{
281 static const char compobj[] = { 1,'C','o','m','p','O','b','j',0 };
282
284
285 add_index(index, compobj);
286}
287
288static int add_name(struct sltg_data *name_table, const char *name)
289{
290 int name_offset = name_table->size;
291 int new_size = name_table->size + strlen(name) + 1 + 8;
292 int aligned_size;
293
294 chat("add_name: %s\n", name);
295
296 aligned_size = (new_size + 0x1f) & ~0x1f;
297 if (aligned_size - new_size < 4)
298 new_size = aligned_size;
299 else
300 new_size = (new_size + 1) & ~1;
301
302 if (new_size > name_table->allocated)
303 {
304 name_table->allocated = name_table->allocated ? max(name_table->allocated * 2, new_size) : new_size;
305 name_table->data = xrealloc(name_table->data, name_table->allocated);
306 }
307
308 memset(name_table->data + name_table->size, 0xff, 8);
309 strcpy(name_table->data + name_table->size + 8, name);
310 name_table->size = new_size;
311 name_table->data[name_table->size - 1] = 0; /* clear alignment */
312
313 return name_offset;
314}
315
316static void init_name_table(struct sltg_data *name_table)
317{
318 init_sltg_data(name_table);
319}
320
321static void init_library(struct sltg_typelib *sltg)
322{
323 const attr_t *attr;
324
325 sltg->library.name = add_name(&sltg->name_table, sltg->typelib->name);
326 sltg->library.helpstring = NULL;
327 sltg->library.helpcontext = 0;
328#ifdef __REACTOS__
329 sltg->library.syskind = (pointer_size == 8) ? SYS_WIN64 : SYS_WIN32;
330#else
331 sltg->library.syskind = SYS_WIN32;
332#endif
333 sltg->library.lcid = 0x0409;
334 sltg->library.libflags = 0;
335 sltg->library.version = 0;
336 sltg->library.helpfile = NULL;
337 memset(&sltg->library.uuid, 0, sizeof(sltg->library.uuid));
338
339 if (!sltg->typelib->attrs) return;
340
342 {
343 const expr_t *expr;
344
345 switch (attr->type)
346 {
347 case ATTR_VERSION:
348 sltg->library.version = attr->u.ival;
349 break;
350 case ATTR_HELPSTRING:
351 sltg->library.helpstring = attr->u.pval;
352 break;
353 case ATTR_HELPFILE:
354 sltg->library.helpfile = attr->u.pval;
355 break;
356 case ATTR_UUID:
357 sltg->library.uuid = *(GUID *)attr->u.pval;
358 break;
359 case ATTR_HELPCONTEXT:
360 expr = attr->u.pval;
361 sltg->library.helpcontext = expr->cval;
362 break;
363 case ATTR_LIBLCID:
364 expr = attr->u.pval;
365 sltg->library.lcid = expr->cval;
366 break;
367 case ATTR_CONTROL:
368 sltg->library.libflags |= 0x02; /* LIBFLAG_FCONTROL */
369 break;
370 case ATTR_HIDDEN:
371 sltg->library.libflags |= 0x04; /* LIBFLAG_FHIDDEN */
372 break;
373 case ATTR_RESTRICTED:
374 sltg->library.libflags |= 0x01; /* LIBFLAG_FRESTRICTED */
375 break;
376 default:
377 break;
378 }
379 }
380}
381
382static void add_block_index(struct sltg_typelib *sltg, void *data, int length, int index)
383{
384 sltg->blocks = xrealloc(sltg->blocks, sizeof(sltg->blocks[0]) * (sltg->block_count + 1));
385 sltg->blocks[sltg->block_count].length = length;
386 sltg->blocks[sltg->block_count].data = data;
387 sltg->blocks[sltg->block_count].index_string = index;
388 sltg->block_count++;
389}
390
391static void add_block(struct sltg_typelib *sltg, void *data, int size, const char *name)
392{
393 struct sltg_block *block = xmalloc(sizeof(*block));
394 int index;
395
396 chat("add_block: %p,%d,\"%s\"\n", data, size, name);
397
398 index = add_index(&sltg->index, name);
399
401}
402
403static void *create_library_block(struct sltg_typelib *typelib, int *size, int *index)
404{
405 void *block;
406 short *p;
407
408 *size = sizeof(short) * 9 + sizeof(int) * 3 + sizeof(GUID);
409 if (typelib->library.helpstring) *size += strlen(typelib->library.helpstring);
410 if (typelib->library.helpfile) *size += strlen(typelib->library.helpfile);
411
412 block = xmalloc(*size);
413 p = block;
414 *p++ = 0x51cc; /* magic */
415 *p++ = 3; /* res02 */
416 *p++ = typelib->library.name;
417 *p++ = 0xffff; /* res06 */
418 if (typelib->library.helpstring)
419 {
420 *p++ = strlen(typelib->library.helpstring);
421 strcpy((char *)p, typelib->library.helpstring);
422 p = (short *)((char *)p + strlen(typelib->library.helpstring));
423 }
424 else
425 *p++ = 0xffff;
426 if (typelib->library.helpfile)
427 {
428 *p++ = strlen(typelib->library.helpfile);
429 strcpy((char *)p, typelib->library.helpfile);
430 p = (short *)((char *)p + strlen(typelib->library.helpfile));
431 }
432 else
433 *p++ = 0xffff;
434 *(int *)p = typelib->library.helpcontext;
435 p += 2;
436 *p++ = typelib->library.syskind;
437 *p++ = typelib->library.lcid;
438 *(int *)p = 0; /* res12 */
439 p += 2;
440 *p++ = typelib->library.libflags;
441 *(int *)p = typelib->library.version;
442 p += 2;
443 *(GUID *)p = typelib->library.uuid;
444
445 *index = add_index(&typelib->index, "dir");
446
447 return block;
448}
449
450static const char *new_index_name(void)
451{
452 static char name[11] = "AAAAAAAAAA";
453 static int pos = 0;
454 char *new_name;
455
456 if (name[pos] == 'Z')
457 {
458 pos++;
459 if (pos > 9)
460 error("too many index names\n");
461 }
462
463 name[pos]++;
464
465 new_name = xmalloc(sizeof(name));
466 strcpy(new_name, name);
467 return new_name;
468}
469
470static void sltg_add_typeinfo(struct sltg_typelib *sltg, void *data, int length, const char *name)
471{
472 chat("sltg_add_typeinfo: %p,%d,%s\n", data, length, name);
473
474 sltg->typeinfo = xrealloc(sltg->typeinfo, sizeof(sltg->typeinfo[0]) * (sltg->typeinfo_count + 1));
475 sltg->typeinfo[sltg->typeinfo_count].length = length;
476 sltg->typeinfo[sltg->typeinfo_count].data = data;
477 sltg->typeinfo[sltg->typeinfo_count].index_string = 0;
478 sltg->typeinfo_count++;
479 sltg->typeinfo_size += length;
480}
481
482static void append_data(struct sltg_data *block, const void *data, int size)
483{
484 int new_size = block->size + size;
485
486 if (new_size > block->allocated)
487 {
488 block->allocated = max(block->allocated * 2, new_size);
489 block->data = xrealloc(block->data, block->allocated);
490 }
491
492 memcpy(block->data + block->size, data, size);
493 block->size = new_size;
494}
495
497{
498 error("add_module_typeinfo: %s not implemented\n", type->name);
499}
500
501static const char *add_typeinfo_block(struct sltg_typelib *typelib, const type_t *type, short kind)
502{
503 struct sltg_data block;
504 const char *index_name, *other_name;
505 short val;
506 void *p;
507 int helpcontext = 0;
508 GUID guid = { 0 };
509 const expr_t *expr;
510
511 index_name = new_index_name();
512 other_name = new_index_name();
513
515 if (expr) helpcontext = expr->cval;
516
517 p = get_attrp(type->attrs, ATTR_UUID);
518 if (p) guid = *(GUID *)p;
519
521
522 val = strlen(index_name);
523 append_data(&block, &val, sizeof(val));
524 append_data(&block, index_name, val);
525 val = strlen(other_name);
526 append_data(&block, &val, sizeof(val));
527 append_data(&block, other_name, val);
528 val = -1; /* res1a */
529 append_data(&block, &val, sizeof(val));
530 val = add_name(&typelib->name_table, type->name); /* name offset */
531 append_data(&block, &val, sizeof(val));
532 val = 0; /* FIXME: helpstring */
533 append_data(&block, &val, sizeof(val));
534 val = -1; /* res20 */
535 append_data(&block, &val, sizeof(val));
536 append_data(&block, &helpcontext, sizeof(helpcontext));
537 val = -1; /* res26 */
538 append_data(&block, &val, sizeof(val));
539 append_data(&block, &guid, sizeof(guid));
540 append_data(&block, &kind, sizeof(kind));
541
542 sltg_add_typeinfo(typelib, block.data, block.size, index_name);
543
544 return index_name;
545}
546
547static void init_typeinfo(struct sltg_typeinfo_header *ti, const type_t *type, short kind,
548 const struct sltg_hrefmap *hrefmap)
549{
550 ti->magic = 0x0501;
551 ti->href_offset = -1;
552 ti->res06 = -1;
553 ti->member_offset = sizeof(*ti);
554 ti->res0e = -1;
555 ti->version = get_attrv(type->attrs, ATTR_VERSION);
556 ti->res16 = 0xfffe0000;
557 ti->misc.unknown1 = 0x02;
558 ti->misc.flags = 0; /* FIXME */
559 ti->misc.unknown2 = 0x02;
560 ti->misc.typekind = kind;
561 ti->res1e = 0;
562
563 if (hrefmap->href_count)
564 {
565 char name[64];
566 int i, hrefinfo_size;
567
568 hrefinfo_size = sizeof(struct sltg_hrefinfo);
569
570 for (i = 0; i < hrefmap->href_count; i++)
571 {
572 snprintf(name, sizeof(name), "*\\Rffff*#%x", hrefmap->href[i]);
573 hrefinfo_size += 8 + 2 + strlen(name);
574 }
575
576 ti->href_offset = ti->member_offset;
577 ti->member_offset += hrefinfo_size;
578 }
579}
580
581static void write_hrefmap(struct sltg_data *data, const struct sltg_hrefmap *hrefmap)
582{
583 struct sltg_hrefinfo hrefinfo;
584 char name[64];
585 int i;
586
587 if (!hrefmap->href_count) return;
588
589 hrefinfo.magic = 0xdf;
590 hrefinfo.res01 = 0;
591 memset(hrefinfo.res02, 0xff, sizeof(hrefinfo.res02));
592 hrefinfo.number = hrefmap->href_count * 8;
593 hrefinfo.res50 = -1;
594 hrefinfo.res52 = 1;
595 hrefinfo.res53 = 0;
596 hrefinfo.resxx = 0xdf;
597
598 append_data(data, &hrefinfo, offsetof(struct sltg_hrefinfo, res50));
599
600 for (i = 0; i < hrefmap->href_count; i++)
601 append_data(data, "\xff\xff\xff\xff\xff\xff\xff\xff", 8);
602
603 append_data(data, &hrefinfo.res50, 7);
604
605 for (i = 0; i < hrefmap->href_count; i++)
606 {
607 short len;
608
609 snprintf(name, sizeof(name), "*\\Rffff*#%x", hrefmap->href[i]);
610 len = strlen(name);
611
612 append_data(data, &len, sizeof(len));
614 }
615
616 append_data(data, &hrefinfo.resxx, sizeof(hrefinfo.resxx));
617}
618
619static void dump_var_desc(const char *data, int size)
620{
621 const unsigned char *p = (const unsigned char *)data;
622 int i;
623
624 if (!(debuglevel & (DEBUGLEVEL_TRACE | DEBUGLEVEL_CHAT))) return;
625
626 chat("dump_var_desc: size %d bytes\n", size);
627
628 for (i = 0; i < size; i++)
629 fprintf(stderr, " %02x", *p++);
630
631 fprintf(stderr, "\n");
632}
633
635{
636 int vt = get_type_vt(type);
637
638 switch (vt)
639 {
640 case VT_I1:
641 case VT_UI1:
642 return 1;
643
644 case VT_UI2:
645 case VT_I2:
646 case VT_BOOL:
647 return 2;
648
649 case VT_INT:
650 case VT_UINT:
651 case VT_I4:
652 case VT_UI4:
653 case VT_R4:
654 case VT_ERROR:
655 case VT_HRESULT:
656 return 4;
657
658 case VT_R8:
659 case VT_I8:
660 case VT_UI8:
661 case VT_CY:
662 case VT_DATE:
663 return 8;
664
665 case VT_DECIMAL:
666 return 16;
667
668 case VT_PTR:
669 case VT_UNKNOWN:
670 case VT_DISPATCH:
671 case VT_BSTR:
672 case VT_LPSTR:
673 case VT_LPWSTR:
674#ifdef __REACTOS__
675 return pointer_size;
676#else
677 return 4;
678#endif
679
680 case VT_VOID:
681 return 0;
682
683 case VT_VARIANT:
684#ifdef __REACTOS__
685 return pointer_size == 8 ? 24 : 16;
686#else
687 return 16;
688#endif
689
690 case VT_USERDEFINED:
691 return 0;
692
693 default:
694 error("get_element_size: unrecognized vt %d\n", vt);
695 break;
696 }
697
698 return 0;
699}
700
701static int local_href(struct sltg_hrefmap *hrefmap, int typelib_href)
702{
703 int i, href = -1;
704
705 for (i = 0; i < hrefmap->href_count; i++)
706 {
707 if (hrefmap->href[i] == typelib_href)
708 {
709 href = i;
710 break;
711 }
712 }
713
714 if (href == -1)
715 {
716 href = hrefmap->href_count;
717
718 if (hrefmap->href)
719 hrefmap->href = xrealloc(hrefmap->href, sizeof(*hrefmap->href) * (hrefmap->href_count + 1));
720 else
721 hrefmap->href = xmalloc(sizeof(*hrefmap->href));
722
723 hrefmap->href[hrefmap->href_count] = typelib_href;
724 hrefmap->href_count++;
725 }
726
727 chat("typelib href %d mapped to local href %d\n", typelib_href, href);
728
729 return href << 2;
730}
731
732static short write_var_desc(struct sltg_typelib *typelib, struct sltg_data *data, type_t *type, short param_flags,
733 short flags, short base_offset, int *size_instance, struct sltg_hrefmap *hrefmap)
734{
735 short vt, vt_flags, desc_offset;
736
737 chat("write_var_desc: type %p, type->name %s\n",
738 type, type->name ? type->name : "NULL");
739
741 {
742 int num_dims, elements, array_start, size, array_size;
743 type_t *atype;
744 struct
745 {
746 short cDims;
747 short fFeatures;
748 int cbElements;
749 int cLocks;
750 int pvData;
751 int bound[2];
752 } *array;
753 int *bound;
754 short vt_off[2];
755
756 elements = 1;
757 num_dims = 0;
758
759 atype = type;
760
761 while (is_array(atype) && !type_array_is_decl_as_ptr(atype))
762 {
763 num_dims++;
764 elements *= type_array_get_dim(atype);
765
766 atype = type_array_get_element_type(atype);
767 }
768
769 chat("write_var_desc: VT_CARRAY: %d dimensions, %d elements\n", num_dims, elements);
770
771 array_start = data->size;
772
773 size = sizeof(*array) + (num_dims - 1) * 8 /* sizeof(SAFEARRAYBOUND) */;
774 array = xmalloc(size);
775
776 array->cDims = num_dims;
777 array->fFeatures = 0x0004; /* FADF_EMBEDDED */
778 array->cbElements = get_element_size(atype);
779 array->cLocks = 0;
780 array->pvData = 0;
781
782 bound = array->bound;
783
784 array_size = array->cbElements;
785 atype = type;
786
787 while (is_array(atype) && !type_array_is_decl_as_ptr(atype))
788 {
789 bound[0] = type_array_get_dim(atype);
790 array_size *= bound[0];
791 bound[1] = 0;
792 bound += 2;
793
794 atype = type_array_get_element_type(atype);
795 }
796
797 if (size_instance)
798 {
799 *size_instance += array_size;
800 size_instance = NULL; /* don't account for element size */
801 }
802
804
805 desc_offset = data->size;
806
807 vt_off[0] = VT_CARRAY;
808 vt_off[1] = array_start + base_offset;
809 append_data(data, vt_off, sizeof(vt_off));
810
811 /* fall through to write array element description */
812 type = atype;
813 }
814 else
815 desc_offset = data->size;
816
818
819 if (vt == VT_PTR)
820 {
822
823 if (is_ptr(ref))
824 {
825 chat("write_var_desc: vt VT_PTR | 0x0400 | %04x\n", param_flags);
826 vt = VT_PTR | 0x0400 | param_flags;
827 append_data(data, &vt, sizeof(vt));
828 write_var_desc(typelib, data, ref, 0, 0, base_offset, size_instance, hrefmap);
829 }
830 else
831 write_var_desc(typelib, data, ref, param_flags, 0x0e00, base_offset, size_instance, hrefmap);
832 return desc_offset;
833 }
834
835 chat("write_var_desc: vt %d, flags %04x\n", vt, flags);
836
837 vt_flags = vt | flags | param_flags;
838 append_data(data, &vt_flags, sizeof(vt_flags));
839
840 if (vt == VT_USERDEFINED)
841 {
842 short href;
843
844 while (type->typelib_idx < 0 && type_is_alias(type))
846
847 chat("write_var_desc: VT_USERDEFINED, type %p, name %s, real type %d, href %d\n",
848 type, type->name, type_get_type(type), type->typelib_idx);
849
850 if (type->typelib_idx == -1)
851 {
852 chat("write_var_desc: trying to ref not added type\n");
853
854 switch (type_get_type(type))
855 {
856 case TYPE_STRUCT:
858 break;
859 case TYPE_INTERFACE:
861 break;
862 case TYPE_ENUM:
864 break;
865 case TYPE_UNION:
867 break;
868 case TYPE_COCLASS:
870 break;
871 default:
872 error("write_var_desc: VT_USERDEFINED - unhandled type %d\n",
874 }
875 }
876
877 if (type->typelib_idx == -1)
878 error("write_var_desc: trying to ref not added type\n");
879
880 href = local_href(hrefmap, type->typelib_idx);
881 chat("write_var_desc: VT_USERDEFINED, local href %d\n", href);
882
883 append_data(data, &href, sizeof(href));
884 }
885
886 if (size_instance)
887 *size_instance += get_element_size(type);
888
889 return desc_offset;
890}
891
892static void init_sltg_tail(struct sltg_tail *tail)
893{
894 tail->cFuncs = 0;
895 tail->cVars = 0;
896 tail->cImplTypes = 0;
897 tail->res06 = 0;
898 tail->funcs_off = -1;
899 tail->vars_off = -1;
900 tail->impls_off = -1;
901 tail->funcs_bytes = -1;
902 tail->vars_bytes = -1;
903 tail->impls_bytes = -1;
904 tail->tdescalias_vt = -1;
905 tail->res16 = -1;
906 tail->res18 = 0;
907 tail->res1a = 0;
908 tail->simple_alias = 0;
909 tail->res1e = 0;
910 tail->cbSizeInstance = 0;
911 tail->cbAlignment = 4;
912 tail->res24 = -1;
913 tail->res26 = -1;
914 tail->cbSizeVft = 0;
915 tail->res2a = -1;
916 tail->res2c = -1;
917 tail->res2e = -1;
918 tail->res30 = -1;
919 tail->res32 = 0;
920 tail->type_bytes = 0;
921}
922
924{
925 struct sltg_data data, *var_data = NULL;
926 struct sltg_hrefmap hrefmap;
927 const char *index_name;
928 struct sltg_typeinfo_header ti;
930 struct sltg_tail tail;
931 int member_offset, var_count = 0, var_data_size = 0, size_instance = 0;
932 short *type_desc_offset = NULL;
933
934 if (type->typelib_idx != -1) return;
935
936 chat("add_structure_typeinfo: type %p, type->name %s\n", type, type->name);
937
938 type->typelib_idx = typelib->block_count;
939
940 hrefmap.href_count = 0;
941 hrefmap.href = NULL;
942
944 {
945 int i = 0;
946 var_t *var;
947
949
950 var_data = xmalloc(var_count * sizeof(*var_data));
951 type_desc_offset = xmalloc(var_count * sizeof(*type_desc_offset));
952
954 {
955 short base_offset;
956
957 chat("add_structure_typeinfo: var %p (%s), type %p (%s)\n",
958 var, var->name, var->declspec.type, var->declspec.type->name);
959
960 init_sltg_data(&var_data[i]);
961
962 base_offset = var_data_size + (i + 1) * sizeof(struct sltg_variable);
963 type_desc_offset[i] = write_var_desc(typelib, &var_data[i], var->declspec.type, 0, 0,
964 base_offset, &size_instance, &hrefmap);
965 dump_var_desc(var_data[i].data, var_data[i].size);
966
967 if (var_data[i].size > sizeof(short))
968 var_data_size += var_data[i].size;
969 i++;
970 }
971 }
972
974
976
977 init_typeinfo(&ti, type, TKIND_RECORD, &hrefmap);
978 append_data(&data, &ti, sizeof(ti));
979
980 write_hrefmap(&data, &hrefmap);
981
982 member_offset = data.size;
983
984 member.res00 = 0x0001;
985 member.res02 = 0xffff;
986 member.res04 = 0x01;
987 member.extra = var_data_size + var_count * sizeof(struct sltg_variable);
988 append_data(&data, &member, sizeof(member));
989
990 var_data_size = 0;
991
993 {
994 int i = 0;
995 short next = member_offset;
996 var_t *var;
997
999 {
1000 struct sltg_variable variable;
1001
1002 next += sizeof(variable);
1003
1004 variable.magic = 0x2a; /* always write flags to simplify calculations */
1005 variable.name = add_name(&typelib->name_table, var->name);
1006 variable.byte_offs = 0;
1007 if (var_data[i].size > sizeof(short))
1008 {
1009 variable.flags = 0;
1010 var_data_size = next - member_offset + type_desc_offset[i];
1011 variable.type = var_data_size;
1012 next += var_data[i].size;
1013 }
1014 else
1015 {
1016 variable.flags = 0x02;
1017 variable.type = *(short *)var_data[i].data;
1018 }
1019 variable.next = i < var_count - 1 ? next - member_offset : -1;
1020 variable.memid = 0x40000000 + i;
1021 variable.helpcontext = -2; /* 0xfffe */
1022 variable.helpstring = -1;
1023 variable.varflags = 0;
1024
1025 append_data(&data, &variable, sizeof(variable));
1026 if (var_data[i].size > sizeof(short))
1027 append_data(&data, var_data[i].data, var_data[i].size);
1028
1029 i++;
1030 }
1031 }
1032
1034 tail.cVars = var_count;
1035 tail.vars_off = 0;
1036 tail.vars_bytes = var_data_size;
1037 tail.cbSizeInstance = size_instance;
1038 tail.type_bytes = data.size - member_offset - sizeof(member);
1039 append_data(&data, &tail, sizeof(tail));
1040
1041 add_block(typelib, data.data, data.size, index_name);
1042}
1043
1045{
1046 importlib_t *importlib;
1047
1048 LIST_FOR_EACH_ENTRY(importlib, &typelib->importlibs, importlib_t, entry)
1049 {
1050 int i;
1051
1052 for (i = 0; i < importlib->ntypeinfos; i++)
1053 {
1054 if (!strcmp(name, importlib->importinfos[i].name))
1055 {
1056 chat("Found %s in importlib list\n", name);
1057 return &importlib->importinfos[i];
1058 }
1059 }
1060 }
1061
1062 return NULL;
1063}
1064
1065static int get_func_flags(const var_t *func, int *dispid, int *invokekind, int *helpcontext, const char **helpstring)
1066{
1067 const attr_t *attr;
1068 int flags;
1069
1070 *invokekind = 1 /* INVOKE_FUNC */;
1071 *helpcontext = -2;
1072 *helpstring = NULL;
1073
1074 if (!func->attrs) return 0;
1075
1076 flags = 0;
1077
1078 LIST_FOR_EACH_ENTRY(attr, func->attrs, const attr_t, entry)
1079 {
1080 expr_t *expr = attr->u.pval;
1081 switch(attr->type)
1082 {
1083 case ATTR_BINDABLE:
1084 flags |= 0x4; /* FUNCFLAG_FBINDABLE */
1085 break;
1086 case ATTR_DEFAULTBIND:
1087 flags |= 0x20; /* FUNCFLAG_FDEFAULTBIND */
1088 break;
1090 flags |= 0x100; /* FUNCFLAG_FDEFAULTCOLLELEM */
1091 break;
1092 case ATTR_DISPLAYBIND:
1093 flags |= 0x10; /* FUNCFLAG_FDISPLAYBIND */
1094 break;
1095 case ATTR_HELPCONTEXT:
1096 *helpcontext = expr->u.integer.value;
1097 break;
1098 case ATTR_HELPSTRING:
1099 *helpstring = attr->u.pval;
1100 break;
1101 case ATTR_HIDDEN:
1102 flags |= 0x40; /* FUNCFLAG_FHIDDEN */
1103 break;
1104 case ATTR_ID:
1105 *dispid = expr->cval;
1106 break;
1107 case ATTR_IMMEDIATEBIND:
1108 flags |= 0x1000; /* FUNCFLAG_FIMMEDIATEBIND */
1109 break;
1110 case ATTR_NONBROWSABLE:
1111 flags |= 0x400; /* FUNCFLAG_FNONBROWSABLE */
1112 break;
1113 case ATTR_PROPGET:
1114 *invokekind = 0x2; /* INVOKE_PROPERTYGET */
1115 break;
1116 case ATTR_PROPPUT:
1117 *invokekind = 0x4; /* INVOKE_PROPERTYPUT */
1118 break;
1119 case ATTR_PROPPUTREF:
1120 *invokekind = 0x8; /* INVOKE_PROPERTYPUTREF */
1121 break;
1122 /* FIXME: FUNCFLAG_FREPLACEABLE */
1123 case ATTR_REQUESTEDIT:
1124 flags |= 0x8; /* FUNCFLAG_FREQUESTEDIT */
1125 break;
1126 case ATTR_RESTRICTED:
1127 flags |= 0x1; /* FUNCFLAG_FRESTRICTED */
1128 break;
1129 case ATTR_SOURCE:
1130 flags |= 0x2; /* FUNCFLAG_FSOURCE */
1131 break;
1132 case ATTR_UIDEFAULT:
1133 flags |= 0x200; /* FUNCFLAG_FUIDEFAULT */
1134 break;
1136 flags |= 0x80; /* FUNCFLAG_FUSESGETLASTERROR */
1137 break;
1138 default:
1139 break;
1140 }
1141 }
1142
1143 return flags;
1144}
1145
1146static int get_param_flags(const var_t *param)
1147{
1148 const attr_t *attr;
1149 int flags, in, out;
1150
1151 if (!param->attrs) return 0;
1152
1153 flags = 0;
1154 in = out = 0;
1155
1156 LIST_FOR_EACH_ENTRY(attr, param->attrs, const attr_t, entry)
1157 {
1158 switch(attr->type)
1159 {
1160 case ATTR_IN:
1161 in++;
1162 break;
1163 case ATTR_OUT:
1164 out++;
1165 break;
1166 case ATTR_PARAMLCID:
1167 flags |= 0x2000;
1168 break;
1169 case ATTR_RETVAL:
1170 flags |= 0x80;
1171 break;
1172 default:
1173 chat("unhandled param attr %d\n", attr->type);
1174 break;
1175 }
1176 }
1177
1178 if (out)
1179 flags |= in ? 0x8000 : 0x4000;
1180 else if (!in)
1181 flags |= 0xc000;
1182
1183 return flags;
1184}
1185
1186
1188 int idx, int dispid, short base_offset, struct sltg_hrefmap *hrefmap)
1189{
1190 struct sltg_data ret_data, *arg_data;
1191 int arg_count = 0, arg_data_size, optional = 0, old_size;
1192 int funcflags = 0, invokekind = 1 /* INVOKE_FUNC */, helpcontext;
1193 const char *helpstring;
1194 const var_t *arg;
1195 short ret_desc_offset, *arg_desc_offset, arg_offset;
1196 struct sltg_function func_desc;
1197
1198 chat("add_func_desc: %s, idx %#x, dispid %#x\n", func->name, idx, dispid);
1199
1200 old_size = data->size;
1201
1202 init_sltg_data(&ret_data);
1203 ret_desc_offset = write_var_desc(typelib, &ret_data, type_function_get_rettype(func->declspec.type),
1204 0, 0, base_offset, NULL, hrefmap);
1205 dump_var_desc(ret_data.data, ret_data.size);
1206
1207 arg_data_size = 0;
1208 arg_offset = base_offset + sizeof(struct sltg_function);
1209
1210 if (ret_data.size > sizeof(short))
1211 {
1212 arg_data_size += ret_data.size;
1213 arg_offset += ret_data.size;
1214 }
1215
1216 if (type_function_get_args(func->declspec.type))
1217 {
1218 int i = 0;
1219
1220 arg_count = list_count(type_function_get_args(func->declspec.type));
1221
1222 arg_data = xmalloc(arg_count * sizeof(*arg_data));
1223 arg_desc_offset = xmalloc(arg_count * sizeof(*arg_desc_offset));
1224
1225 arg_offset += arg_count * 2 * sizeof(short);
1226
1228 {
1229 const attr_t *attr;
1230 short param_flags = get_param_flags(arg);
1231
1232 chat("add_func_desc: arg[%d] %p (%s), type %p (%s)\n",
1233 i, arg, arg->name, arg->declspec.type, arg->declspec.type->name);
1234
1235 init_sltg_data(&arg_data[i]);
1236
1237
1238 arg_desc_offset[i] = write_var_desc(typelib, &arg_data[i], arg->declspec.type, param_flags, 0,
1239 arg_offset, NULL, hrefmap);
1240 dump_var_desc(arg_data[i].data, arg_data[i].size);
1241
1242 if (arg_data[i].size > sizeof(short))
1243 {
1244 arg_data_size += arg_data[i].size;
1245 arg_offset += arg_data[i].size;
1246 }
1247
1248 i++;
1249
1250 if (!arg->attrs) continue;
1251
1252 LIST_FOR_EACH_ENTRY(attr, arg->attrs, const attr_t, entry)
1253 {
1254 if (attr->type == ATTR_OPTIONAL)
1255 optional++;
1256 }
1257 }
1258 }
1259
1261
1262 if (base_offset != -1)
1263 chat("add_func_desc: flags %#x, dispid %#x, invokekind %d, helpcontext %#x, helpstring %s\n",
1264 funcflags, dispid, invokekind, helpcontext, helpstring);
1265
1266 func_desc.magic = 0x6c; /* always write flags to simplify calculations */
1267 func_desc.flags = (invokekind << 4) | 0x02;
1268 if (idx & 0x80000000)
1269 {
1270 func_desc.next = -1;
1271 idx &= ~0x80000000;
1272 }
1273 else
1274 func_desc.next = base_offset + sizeof(func_desc) + arg_data_size + arg_count * 2 * sizeof(short);
1275 func_desc.name = base_offset != -1 ? add_name(&typelib->name_table, func->name) : -1;
1276 func_desc.dispid = dispid;
1277 func_desc.helpcontext = helpcontext;
1278 func_desc.helpstring = (helpstring && base_offset != -1) ? add_name(&typelib->name_table, helpstring) : -1;
1279 func_desc.arg_off = arg_count ? base_offset + sizeof(func_desc) : -1;
1280 func_desc.nacc = (arg_count << 3) | 4 /* CC_STDCALL */;
1281 func_desc.retnextopt = (optional << 1);
1282 if (ret_data.size > sizeof(short))
1283 {
1284 func_desc.rettype = base_offset + sizeof(func_desc) + ret_desc_offset;
1285 if (arg_count)
1286 func_desc.arg_off += ret_data.size;
1287 }
1288 else
1289 {
1290 func_desc.retnextopt |= 0x80;
1291 func_desc.rettype = *(short *)ret_data.data;
1292 }
1293 func_desc.vtblpos = idx * pointer_size;
1294 func_desc.funcflags = funcflags;
1295
1296 append_data(data, &func_desc, sizeof(func_desc));
1297
1298 arg_offset = base_offset + sizeof(struct sltg_function);
1299
1300 if (ret_data.size > sizeof(short))
1301 {
1302 append_data(data, ret_data.data, ret_data.size);
1303 func_desc.arg_off += ret_data.size;
1304 arg_offset += ret_data.size;
1305 }
1306
1307 if (arg_count)
1308 {
1309 int i = 0;
1310
1311 arg_offset += arg_count * 2 * sizeof(short);
1312
1314 {
1315 short name, type_offset;
1316
1317 name = base_offset != -1 ? add_name(&typelib->name_table, arg->name) : -1;
1318
1319 if (arg_data[i].size > sizeof(short))
1320 {
1321 type_offset = (arg_offset + arg_desc_offset[i]);
1322 arg_offset += arg_data[i].size;
1323 }
1324 else
1325 {
1326 name |= 1;
1327 type_offset = *(short *)arg_data[i].data;
1328 }
1329
1330 append_data(data, &name, sizeof(name));
1331 append_data(data, &type_offset, sizeof(type_offset));
1332
1333 if (base_offset != -1)
1334 chat("add_func_desc: arg[%d] - name %s (%#x), type_offset %#x\n",
1335 i, arg->name, name, type_offset);
1336
1337 i++;
1338 }
1339
1340 for (i = 0; i < arg_count; i++)
1341 {
1342 if (arg_data[i].size > sizeof(short))
1343 append_data(data, arg_data[i].data, arg_data[i].size);
1344 }
1345 }
1346
1347 return data->size - old_size;
1348}
1349
1350static void write_impl_href(struct sltg_data *data, short href)
1351{
1352 struct sltg_impl_info impl_info;
1353
1354 impl_info.res00 = 0x004a;
1355 impl_info.next = -1;
1356 impl_info.res04 = -1;
1357 impl_info.impltypeflags = 0;
1358 impl_info.res07 = 0x80;
1359 impl_info.res08 = 0x0012;
1360 impl_info.ref = href;
1361 impl_info.res0c = 0x4001;
1362 impl_info.res0e = -2; /* 0xfffe */
1363 impl_info.res10 = -1;
1364 impl_info.res12 = 0x001d;
1365 impl_info.pos = 0;
1366
1367 append_data(data, &impl_info, sizeof(impl_info));
1368}
1369
1371{
1372 const statement_t *stmt_func;
1373 importinfo_t *ref_importinfo = NULL;
1374 short inherit_href = -1;
1375 struct sltg_data data;
1376 struct sltg_hrefmap hrefmap;
1377 const char *index_name;
1378 struct sltg_typeinfo_header ti;
1380 struct sltg_tail tail;
1381 int member_offset, base_offset, func_data_size, i;
1382 int func_count, inherited_func_count = 0;
1383 int dispid, inherit_level = 0;
1384
1385 if (iface->typelib_idx != -1) return;
1386
1387 chat("add_interface_typeinfo: type %p, type->name %s\n", iface, iface->name);
1388
1389 if (!iface->details.iface)
1390 {
1391 error("interface %s is referenced but not defined\n", iface->name);
1392 return;
1393 }
1394
1395 if (is_attr(iface->attrs, ATTR_DISPINTERFACE))
1396 {
1397 error("support for dispinterface %s is not implemented\n", iface->name);
1398 return;
1399 }
1400
1401 hrefmap.href_count = 0;
1402 hrefmap.href = NULL;
1403
1404 if (type_iface_get_inherit(iface))
1405 {
1406 type_t *inherit;
1407
1408 inherit = type_iface_get_inherit(iface);
1409
1410 chat("add_interface_typeinfo: inheriting from base interface %s\n", inherit->name);
1411
1412 ref_importinfo = find_importinfo(typelib->typelib, inherit->name);
1413
1414 if (!ref_importinfo && type_iface_get_inherit(inherit))
1416
1417 if (ref_importinfo)
1418 error("support for imported interfaces is not implemented\n");
1419
1420 inherit_href = local_href(&hrefmap, inherit->typelib_idx);
1421
1422 while (inherit)
1423 {
1424 inherit_level++;
1425 inherited_func_count += list_count(type_iface_get_stmts(inherit));
1426 inherit = type_iface_get_inherit(inherit);
1427 }
1428 }
1429
1430 /* check typelib_idx again, it could have been added while resolving the parent interface */
1431 if (iface->typelib_idx != -1) return;
1432
1433 iface->typelib_idx = typelib->block_count;
1434
1435 /* pass 1: calculate function descriptions data size */
1437
1439 {
1440 add_func_desc(typelib, &data, stmt_func->u.var, -1, -1, -1, &hrefmap);
1441 }
1442
1443 func_data_size = data.size;
1444
1445 /* pass 2: write function descriptions */
1447
1448 func_count = list_count(type_iface_get_stmts(iface));
1449
1450 index_name = add_typeinfo_block(typelib, iface, TKIND_INTERFACE);
1451
1452 init_typeinfo(&ti, iface, TKIND_INTERFACE, &hrefmap);
1453 append_data(&data, &ti, sizeof(ti));
1454
1455 write_hrefmap(&data, &hrefmap);
1456
1457 member_offset = data.size;
1458 base_offset = 0;
1459
1460 member.res00 = 0x0001;
1461 member.res02 = 0xffff;
1462 member.res04 = 0x01;
1463 member.extra = func_data_size;
1464 if (inherit_href != -1)
1465 {
1466 member.extra += sizeof(struct sltg_impl_info);
1467 base_offset += sizeof(struct sltg_impl_info);
1468 }
1469 append_data(&data, &member, sizeof(member));
1470
1471 if (inherit_href != -1)
1472 write_impl_href(&data, inherit_href);
1473
1474 i = 0;
1475 dispid = 0x60000000 | (inherit_level << 16);
1476
1478 {
1479 int idx = inherited_func_count + i;
1480
1481 if (i == func_count - 1) idx |= 0x80000000;
1482
1483 base_offset += add_func_desc(typelib, &data, stmt_func->u.var,
1484 idx, dispid + i, base_offset, &hrefmap);
1485 i++;
1486 }
1487
1489
1490 tail.cFuncs = func_count;
1491 tail.funcs_off = 0;
1492 tail.funcs_bytes = func_data_size;
1493 tail.cbSizeInstance = pointer_size;
1494 tail.cbAlignment = pointer_size;
1495 tail.cbSizeVft = (inherited_func_count + func_count) * pointer_size;
1496 tail.type_bytes = data.size - member_offset - sizeof(member);
1497 tail.res24 = 0;
1498 tail.res26 = 0;
1499 if (inherit_href != -1)
1500 {
1501 tail.cImplTypes++;
1502 tail.impls_off = 0;
1503 tail.impls_bytes = 0;
1504
1505 tail.funcs_off += sizeof(struct sltg_impl_info);
1506 }
1507 append_data(&data, &tail, sizeof(tail));
1508
1509 add_block(typelib, data.data, data.size, index_name);
1510}
1511
1513{
1514 error("add_enum_typeinfo: %s not implemented\n", type->name);
1515}
1516
1518{
1519 error("add_union_typeinfo: %s not implemented\n", type->name);
1520}
1521
1523{
1524 error("add_coclass_typeinfo: %s not implemented\n", type->name);
1525}
1526
1528{
1529 chat("add_type_typeinfo: adding %s, type %d\n", type->name, type_get_type(type));
1530
1531 switch (type_get_type(type))
1532 {
1533 case TYPE_INTERFACE:
1535 break;
1536 case TYPE_STRUCT:
1538 break;
1539 case TYPE_ENUM:
1541 break;
1542 case TYPE_UNION:
1544 break;
1545 case TYPE_COCLASS:
1547 break;
1548 case TYPE_BASIC:
1549 case TYPE_POINTER:
1550 break;
1551 default:
1552 error("add_type_typeinfo: unhandled type %d for %s\n", type_get_type(type), type->name);
1553 break;
1554 }
1555}
1556
1557static void add_statement(struct sltg_typelib *typelib, const statement_t *stmt)
1558{
1559 switch(stmt->type)
1560 {
1561 case STMT_LIBRARY:
1562 case STMT_IMPORT:
1563 case STMT_PRAGMA:
1564 case STMT_CPPQUOTE:
1565 case STMT_DECLARATION:
1566 /* not included in typelib */
1567 break;
1568 case STMT_IMPORTLIB:
1569 /* not processed here */
1570 break;
1571
1572 case STMT_TYPEDEF:
1573 {
1574 typeref_t *ref;
1575
1576 if (!stmt->u.type_list)
1577 break;
1578
1580 {
1581 /* in old style typelibs all types are public */
1583 }
1584 break;
1585 }
1586
1587 case STMT_MODULE:
1589 break;
1590
1591 case STMT_TYPE:
1592 case STMT_TYPEREF:
1593 {
1594 type_t *type = stmt->u.type;
1596 break;
1597 }
1598
1599 default:
1600 error("add_statement: unhandled statement type %d\n", stmt->type);
1601 break;
1602 }
1603}
1604
1605static void sltg_write_header(struct sltg_typelib *sltg, int *library_block_start)
1606{
1607 char pad[0x40];
1608 struct sltg_header
1609 {
1610 int magic;
1611 short block_count;
1612 short res06;
1613 short size_of_index;
1614 short first_blk;
1615 GUID uuid;
1616 int res1c;
1617 int res20;
1618 } header;
1619 struct sltg_block_entry
1620 {
1621 int length;
1622 short index_string;
1623 short next;
1624 } entry;
1625 int i;
1626
1627 header.magic = 0x47544c53;
1628 header.block_count = sltg->block_count + 1; /* 1-based */
1629 header.res06 = 9;
1630 header.size_of_index = sltg->index.size;
1631 header.first_blk = 1; /* 1-based */
1633 header.res1c = 0x00000044;
1634 header.res20 = 0xffff0000;
1635
1636 put_data(&header, sizeof(header));
1637
1638 /* library block is written separately */
1639 for (i = 0; i < sltg->block_count - 1; i++)
1640 {
1641 entry.length = sltg->blocks[i].length;
1642 entry.index_string = sltg->blocks[i].index_string;
1643 entry.next = header.first_blk + i + 1; /* point to next block */
1644 chat("sltg_write_header: writing block entry %d: length %#x, index_string %#x, next %#x\n",
1645 i, entry.length, entry.index_string, entry.next);
1646 put_data(&entry, sizeof(entry));
1647 }
1648
1649 /* library block length includes helpstrings and name table */
1650 entry.length = sltg->blocks[sltg->block_count - 1].length + 0x40 /* pad after library block */ +
1651 sizeof(sltg->typeinfo_count) + sltg->typeinfo_size + 4 /* library block size */ + 6 /* dummy help strings */ +
1652 12 /* name table header */ + 0x200 /* name table hash */ +
1653 sizeof(sltg->name_table.size) + sltg->name_table.size +
1654 4 /* 0x01ffff01 */ + 4 /* 0 */;
1655 entry.index_string = sltg->blocks[sltg->block_count - 1].index_string;
1656 entry.next = 0;
1657 chat("sltg_write_header: writing library block entry %d: length %#x, index_string %#x, next %#x\n",
1658 i, entry.length, entry.index_string, entry.next);
1659 put_data(&entry, sizeof(entry));
1660
1661 chat("sltg_write_header: writing index: %d bytes\n", sltg->index.size);
1662 put_data(sltg->index.data, sltg->index.size);
1663 memset(pad, 0, 9);
1664 put_data(pad, 9);
1665
1666 /* library block is written separately */
1667 for (i = 0; i < sltg->block_count - 1; i++)
1668 {
1669 chat("sltg_write_header: writing block %d: %d bytes\n", i, sltg->blocks[i].length);
1670 put_data(sltg->blocks[i].data, sltg->blocks[i].length);
1671 }
1672
1673 /* library block */
1674 chat("library_block_start = %#x\n", (int)output_buffer_pos);
1675 *library_block_start = output_buffer_pos;
1676 chat("sltg_write_header: writing library block %d: %d bytes\n", i, sltg->blocks[i].length);
1677 put_data(sltg->blocks[sltg->block_count - 1].data, sltg->blocks[sltg->block_count - 1].length);
1678
1679 chat("sltg_write_header: writing pad 0x40 bytes\n");
1680 memset(pad, 0xff, 0x40);
1681 put_data(pad, 0x40);
1682}
1683
1685{
1686 short i;
1687
1688 put_data(&typelib->typeinfo_count, sizeof(typelib->typeinfo_count));
1689
1690 for (i = 0; i < typelib->typeinfo_count; i++)
1691 {
1692 chat("sltg_write_typeinfo: writing block %d: %d bytes\n", i, typelib->typeinfo[i].length);
1693 put_data(typelib->typeinfo[i].data, typelib->typeinfo[i].length);
1694 }
1695}
1696
1698{
1699 static const char dummy[6];
1700
1701 chat("sltg_write_helpstrings: writing dummy 6 bytes\n");
1702
1703 put_data(dummy, sizeof(dummy));
1704}
1705
1707{
1708 static const short dummy[6] = { 0xffff,1,2,0xff00,0xffff,0xffff };
1709 char pad[0x200];
1710
1711 chat("sltg_write_nametable: writing 12+0x200+%d bytes\n", typelib->name_table.size);
1712
1713 put_data(dummy, sizeof(dummy));
1714 memset(pad, 0xff, 0x200);
1715 put_data(pad, 0x200);
1716 put_data(&typelib->name_table.size, sizeof(typelib->name_table.size));
1717 put_data(typelib->name_table.data, typelib->name_table.size);
1718}
1719
1720static void sltg_write_remainder(void)
1721{
1722 static const short dummy1[] = { 1,0xfffe,0x0a03,0,0xffff,0xffff };
1723 static const short dummy2[] = { 0xffff,0xffff,0x0200,0,0,0 };
1724 static const char dummy3[] = { 0xf4,0x39,0xb2,0x71,0,0,0,0,0,0,0,0,0,0,0,0 };
1725 static const char TYPELIB[] = { 8,0,0,0,'T','Y','P','E','L','I','B',0 };
1726 int pad;
1727
1728 pad = 0x01ffff01;
1729 put_data(&pad, sizeof(pad));
1730 pad = 0;
1731 put_data(&pad, sizeof(pad));
1732
1733 put_data(dummy1, sizeof(dummy1));
1734
1736
1737 put_data(TYPELIB, sizeof(TYPELIB));
1738
1739 put_data(dummy2, sizeof(dummy2));
1740 put_data(dummy3, sizeof(dummy3));
1741}
1742
1744{
1745 int library_block_start;
1746 int *name_table_offset;
1747
1748 sltg_write_header(typelib, &library_block_start);
1750
1751 name_table_offset = (int *)(output_buffer + output_buffer_pos);
1752 chat("name_table_offset = %#x\n", (int)output_buffer_pos);
1753 put_data(&library_block_start, sizeof(library_block_start));
1754
1756
1757 *name_table_offset = output_buffer_pos - library_block_start;
1758 chat("*name_table_offset = %#x\n", *name_table_offset);
1759
1762
1763 if (strendswith(typelib_name, ".res")) /* create a binary resource file */
1764 {
1765 char typelib_id[13] = "#1";
1766
1767 expr_t *expr = get_attrp(typelib->typelib->attrs, ATTR_ID);
1768 if (expr)
1769 snprintf(typelib_id, sizeof(typelib_id), "#%d", expr->cval);
1770 add_output_to_resources("TYPELIB", typelib_id);
1771 if (strendswith(typelib_name, "_t.res")) /* add typelib registration */
1773 }
1775}
1776
1778{
1779 struct sltg_typelib sltg;
1780 const statement_t *stmt;
1781 void *library_block;
1782 int library_block_size, library_block_index;
1783
1784#ifndef __REACTOS__
1785 if (pointer_size != 4)
1786 error("Only 32-bit platform is supported\n");
1787#endif
1788
1789 sltg.typelib = typelib;
1790 sltg.typeinfo_count = 0;
1791 sltg.typeinfo_size = 0;
1792 sltg.typeinfo = NULL;
1793 sltg.blocks = NULL;
1794 sltg.block_count = 0;
1795 sltg.first_block = 1;
1796
1797 init_index(&sltg.index);
1799 init_library(&sltg);
1800
1801 library_block = create_library_block(&sltg, &library_block_size, &library_block_index);
1802
1803 if (typelib->stmts)
1804 LIST_FOR_EACH_ENTRY(stmt, typelib->stmts, const statement_t, entry)
1805 add_statement(&sltg, stmt);
1806
1807 add_block_index(&sltg, library_block, library_block_size, library_block_index);
1808
1809 save_all_changes(&sltg);
1810
1811 return 1;
1812}
@ optional
Definition: SystemMenu.c:34
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
struct outqueuenode * tail
Definition: adnsresfilter.c:66
coclass MediaStreamFilter helpstring("Stream Class")
void * xmalloc(int size)
Definition: uimain.c:747
void * xrealloc(void *oldmem, size_t size)
Definition: uimain.c:736
#define index(s, c)
Definition: various.h:29
#define NULL
Definition: types.h:112
unsigned int idx
Definition: utils.c:41
@ VT_UI8
Definition: compat.h:2315
@ VT_BSTR
Definition: compat.h:2303
@ VT_VOID
Definition: compat.h:2318
@ VT_INT
Definition: compat.h:2316
@ VT_LPSTR
Definition: compat.h:2324
@ VT_R4
Definition: compat.h:2299
@ VT_UNKNOWN
Definition: compat.h:2308
@ VT_PTR
Definition: compat.h:2320
@ VT_UI2
Definition: compat.h:2312
@ VT_DECIMAL
Definition: compat.h:2309
@ VT_ERROR
Definition: compat.h:2305
@ VT_LPWSTR
Definition: compat.h:2325
@ VT_R8
Definition: compat.h:2300
@ VT_CY
Definition: compat.h:2301
@ VT_VARIANT
Definition: compat.h:2307
@ VT_I8
Definition: compat.h:2314
@ VT_I1
Definition: compat.h:2310
@ VT_I4
Definition: compat.h:2298
@ VT_USERDEFINED
Definition: compat.h:2323
@ VT_HRESULT
Definition: compat.h:2319
@ VT_DATE
Definition: compat.h:2302
@ VT_BOOL
Definition: compat.h:2306
@ VT_I2
Definition: compat.h:2297
@ VT_UI4
Definition: compat.h:2313
@ VT_UINT
Definition: compat.h:2317
@ VT_CARRAY
Definition: compat.h:2322
@ VT_DISPATCH
Definition: compat.h:2304
@ VT_UI1
Definition: compat.h:2311
GUID guid
Definition: version.c:147
static REFPROPVARIANT PROPVAR_CHANGE_FLAGS VARTYPE vt
Definition: suminfo.c:91
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
size_t const old_size
Definition: expand.cpp:65
size_t const new_size
Definition: expand.cpp:66
unsigned short WORD
Definition: ntddk_ex.h:93
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum func
Definition: glext.h:6028
GLsizeiptr size
Definition: glext.h:5919
GLuint index
Definition: glext.h:6031
GLuint in
Definition: glext.h:9616
GLbitfield flags
Definition: glext.h:7161
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLuint GLfloat * val
Definition: glext.h:7180
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLenum variable
Definition: glext.h:9031
GLfloat param
Definition: glext.h:5796
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
Definition: msctf.idl:532
uint32_t entry
Definition: isohybrid.c:63
#define ATTR_HIDDEN
Definition: mkdosfs.c:367
#define error(str)
Definition: mkdosfs.c:1605
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
const char * var
Definition: shader.c:5666
static LONG cLocks
Definition: compobj.c:119
static UINT array_size
Definition: msctf.cpp:39
static HRESULT flush_output_buffer(mxwriter *This)
Definition: mxwriter.c:661
_In_ LPWSTR _In_ DWORD _In_ LPCVOID pvData
Definition: netsh.h:116
static unsigned __int64 next
Definition: rand_nt.c:6
#define offsetof(TYPE, MEMBER)
DWORD LCID
Definition: nls.h:13
strcpy
Definition: string.h:131
__WINE_SERVER_LIST_INLINE unsigned int list_count(const struct list *list)
Definition: list.h:155
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define memset(x, y, z)
Definition: compat.h:39
size_t output_buffer_pos
Definition: utils.c:164
static int strendswith(const char *str, const char *end)
Definition: tools.h:145
static void put_data(const void *data, size_t size)
Definition: tools.h:798
void * get_attrp(const attr_list_t *list, enum attr_type attr_type)
Definition: attribute.c:87
unsigned int get_attrv(const attr_list_t *list, enum attr_type attr_type)
Definition: attribute.c:78
int is_attr(const attr_list_t *list, enum attr_type attr_type)
Definition: attribute.c:45
static int is_ptr(const type_t *t)
Definition: header.h:55
static int is_array(const type_t *t)
Definition: header.h:60
void output_typelib_regscript(const typelib_t *typelib)
Definition: register.c:334
unsigned short get_type_vt(type_t *t)
Definition: typelib.c:124
void add_output_to_resources(const char *type, const char *name)
Definition: utils.c:192
void chat(const char *s,...)
Definition: utils.c:79
Definition: scsiwmi.h:51
unsigned char Data4[8]
Definition: scsiwmi.h:55
unsigned long Data1
Definition: scsiwmi.h:52
unsigned short Data2
Definition: scsiwmi.h:53
unsigned short Data3
Definition: scsiwmi.h:54
statement_type_t type
Definition: parser.h:124
var_t * var
Definition: widltypes.h:631
typeref_list_t * type_list
Definition: widltypes.h:633
union _statement_t::@5358 u
attr_list_t * attrs
Definition: widltypes.h:503
union _type_t::@5357 details
int typelib_idx
Definition: widltypes.h:529
struct iface_details * iface
Definition: widltypes.h:509
const char * name
Definition: widltypes.h:500
const attr_list_t * attrs
Definition: widltypes.h:611
char * name
Definition: widltypes.h:610
Definition: cookie.c:202
Definition: query.h:86
union expr::@560 u
Definition: name.c:39
Definition: send.c:48
int index_string
Definition: write_sltg.c:85
int length
Definition: write_sltg.c:84
void * data
Definition: write_sltg.c:86
char * data
Definition: write_sltg.c:66
int size
Definition: write_sltg.c:65
int allocated
Definition: write_sltg.c:65
short helpcontext
Definition: write_sltg.c:212
short helpstring
Definition: write_sltg.c:213
short funcflags
Definition: write_sltg.c:221
char res02[0x42]
Definition: write_sltg.c:186
char impltypeflags
Definition: write_sltg.c:234
int helpcontext
Definition: write_sltg.c:74
char * helpfile
Definition: write_sltg.c:73
short name
Definition: write_sltg.c:71
char * helpstring
Definition: write_sltg.c:72
short funcs_off
Definition: write_sltg.c:157
short cVars
Definition: write_sltg.c:154
short simple_alias
Definition: write_sltg.c:167
short impls_off
Definition: write_sltg.c:159
short res32
Definition: write_sltg.c:178
short impls_bytes
Definition: write_sltg.c:162
short res18
Definition: write_sltg.c:165
short cbSizeVft
Definition: write_sltg.c:173
short res2c
Definition: write_sltg.c:175
short res2e
Definition: write_sltg.c:176
short cbAlignment
Definition: write_sltg.c:170
short res24
Definition: write_sltg.c:171
short cbSizeInstance
Definition: write_sltg.c:169
short res30
Definition: write_sltg.c:177
short res1e
Definition: write_sltg.c:168
short res26
Definition: write_sltg.c:172
short funcs_bytes
Definition: write_sltg.c:160
short vars_off
Definition: write_sltg.c:158
short cImplTypes
Definition: write_sltg.c:155
short res06
Definition: write_sltg.c:156
short cFuncs
Definition: write_sltg.c:153
short res2a
Definition: write_sltg.c:174
short tdescalias_vt
Definition: write_sltg.c:163
short type_bytes
Definition: write_sltg.c:179
short res16
Definition: write_sltg.c:164
short vars_bytes
Definition: write_sltg.c:161
short res1a
Definition: write_sltg.c:166
struct sltg_typeinfo_header::@5359 misc
typelib_t * typelib
Definition: write_sltg.c:91
struct sltg_data index
Definition: write_sltg.c:92
struct sltg_block * typeinfo
Definition: write_sltg.c:100
int typeinfo_size
Definition: write_sltg.c:99
short typeinfo_count
Definition: write_sltg.c:98
struct sltg_library library
Definition: write_sltg.c:94
struct sltg_block * blocks
Definition: write_sltg.c:95
int first_block
Definition: write_sltg.c:97
struct sltg_data name_table
Definition: write_sltg.c:93
int block_count
Definition: write_sltg.c:96
short byte_offs
Definition: write_sltg.c:143
short varflags
Definition: write_sltg.c:148
short helpstring
Definition: write_sltg.c:147
short helpcontext
Definition: write_sltg.c:146
#define max(a, b)
Definition: svc.c:63
static int type_array_is_decl_as_ptr(const type_t *type)
Definition: typetree.h:350
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:113
static type_t * type_function_get_rettype(const type_t *type)
Definition: typetree.h:158
static type_t * type_array_get_element_type(const type_t *type)
Definition: typetree.h:345
static type_t * type_alias_get_aliasee_type(const type_t *type)
Definition: typetree.h:373
static var_list_t * type_struct_get_fields(const type_t *type)
Definition: typetree.h:132
static type_t * type_pointer_get_ref_type(const type_t *type)
Definition: typetree.h:424
static int type_is_alias(const type_t *type)
Definition: typetree.h:357
static type_t * type_iface_get_inherit(const type_t *type)
Definition: typetree.h:208
static var_list_t * type_function_get_args(const type_t *type)
Definition: typetree.h:139
static unsigned int type_array_get_dim(const type_t *type)
Definition: typetree.h:303
static statement_list_t * type_iface_get_stmts(const type_t *type)
Definition: typetree.h:201
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
char * typelib_name
Definition: widl.c:122
unsigned int pointer_size
Definition: widl.c:147
int debuglevel
Definition: widl.c:94
#define DEBUGLEVEL_CHAT
Definition: widl.h:31
#define DEBUGLEVEL_TRACE
Definition: widl.h:33
@ TYPE_ENUM
Definition: widltypes.h:480
@ TYPE_BASIC
Definition: widltypes.h:479
@ TYPE_UNION
Definition: widltypes.h:483
@ TYPE_POINTER
Definition: widltypes.h:489
@ TYPE_COCLASS
Definition: widltypes.h:486
@ TYPE_STRUCT
Definition: widltypes.h:481
@ TYPE_INTERFACE
Definition: widltypes.h:488
@ TKIND_RECORD
Definition: widltypes.h:235
@ TKIND_INTERFACE
Definition: widltypes.h:237
@ SYS_WIN32
Definition: widltypes.h:647
@ SYS_WIN64
Definition: widltypes.h:649
@ ATTR_IN
Definition: widltypes.h:131
@ ATTR_RETVAL
Definition: widltypes.h:169
@ ATTR_PROPPUT
Definition: widltypes.h:159
@ ATTR_DEFAULTBIND
Definition: widltypes.h:97
@ ATTR_UUID
Definition: widltypes.h:182
@ ATTR_HELPFILE
Definition: widltypes.h:120
@ ATTR_PROPPUTREF
Definition: widltypes.h:160
@ ATTR_IMMEDIATEBIND
Definition: widltypes.h:129
@ ATTR_DEFAULTCOLLELEM
Definition: widltypes.h:98
@ ATTR_VERSION
Definition: widltypes.h:185
@ ATTR_REQUESTEDIT
Definition: widltypes.h:167
@ ATTR_CONTROL
Definition: widltypes.h:92
@ ATTR_LIBLCID
Definition: widltypes.h:134
@ ATTR_UIDEFAULT
Definition: widltypes.h:179
@ ATTR_DISPLAYBIND
Definition: widltypes.h:104
@ ATTR_OUT
Definition: widltypes.h:151
@ ATTR_PROPGET
Definition: widltypes.h:158
@ ATTR_BINDABLE
Definition: widltypes.h:81
@ ATTR_OPTIONAL
Definition: widltypes.h:150
@ ATTR_RESTRICTED
Definition: widltypes.h:168
@ ATTR_ID
Definition: widltypes.h:125
@ ATTR_DISPINTERFACE
Definition: widltypes.h:103
@ ATTR_HELPCONTEXT
Definition: widltypes.h:119
@ ATTR_HELPSTRING
Definition: widltypes.h:121
@ ATTR_PARAMLCID
Definition: widltypes.h:153
@ ATTR_NONBROWSABLE
Definition: widltypes.h:141
@ ATTR_SOURCE
Definition: widltypes.h:171
@ ATTR_USESGETLASTERROR
Definition: widltypes.h:181
@ STMT_MODULE
Definition: widltypes.h:269
@ STMT_IMPORT
Definition: widltypes.h:271
@ STMT_IMPORTLIB
Definition: widltypes.h:272
@ STMT_TYPE
Definition: widltypes.h:267
@ STMT_DECLARATION
Definition: widltypes.h:266
@ STMT_LIBRARY
Definition: widltypes.h:265
@ STMT_TYPEDEF
Definition: widltypes.h:270
@ STMT_CPPQUOTE
Definition: widltypes.h:274
@ STMT_TYPEREF
Definition: widltypes.h:268
@ STMT_PRAGMA
Definition: widltypes.h:273
#define STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
Definition: widltypes.h:684
void * arg
Definition: msvc.h:10
#define snprintf
Definition: wintirpc.h:48
static int add_func_desc(struct sltg_typelib *typelib, struct sltg_data *data, var_t *func, int idx, int dispid, short base_offset, struct sltg_hrefmap *hrefmap)
Definition: write_sltg.c:1187
static const GUID sltg_library_guid
Definition: write_sltg.c:61
static void write_hrefmap(struct sltg_data *data, const struct sltg_hrefmap *hrefmap)
Definition: write_sltg.c:581
static void dump_var_desc(const char *data, int size)
Definition: write_sltg.c:619
static int get_param_flags(const var_t *param)
Definition: write_sltg.c:1146
static void init_sltg_data(struct sltg_data *data)
Definition: write_sltg.c:253
static void sltg_add_typeinfo(struct sltg_typelib *sltg, void *data, int length, const char *name)
Definition: write_sltg.c:470
static int add_name(struct sltg_data *name_table, const char *name)
Definition: write_sltg.c:288
int create_sltg_typelib(typelib_t *typelib)
Definition: write_sltg.c:1777
static importinfo_t * find_importinfo(typelib_t *typelib, const char *name)
Definition: write_sltg.c:1044
static void init_sltg_tail(struct sltg_tail *tail)
Definition: write_sltg.c:892
static void init_typeinfo(struct sltg_typeinfo_header *ti, const type_t *type, short kind, const struct sltg_hrefmap *hrefmap)
Definition: write_sltg.c:547
static void add_coclass_typeinfo(struct sltg_typelib *typelib, type_t *type)
Definition: write_sltg.c:1522
static void init_index(struct sltg_data *index)
Definition: write_sltg.c:279
static void append_data(struct sltg_data *block, const void *data, int size)
Definition: write_sltg.c:482
static void init_name_table(struct sltg_data *name_table)
Definition: write_sltg.c:316
static int local_href(struct sltg_hrefmap *hrefmap, int typelib_href)
Definition: write_sltg.c:701
static void * create_library_block(struct sltg_typelib *typelib, int *size, int *index)
Definition: write_sltg.c:403
static void init_library(struct sltg_typelib *sltg)
Definition: write_sltg.c:321
static void add_block(struct sltg_typelib *sltg, void *data, int size, const char *name)
Definition: write_sltg.c:391
static short write_var_desc(struct sltg_typelib *typelib, struct sltg_data *data, type_t *type, short param_flags, short flags, short base_offset, int *size_instance, struct sltg_hrefmap *hrefmap)
Definition: write_sltg.c:732
static const char * new_index_name(void)
Definition: write_sltg.c:450
static void add_interface_typeinfo(struct sltg_typelib *typelib, type_t *type)
Definition: write_sltg.c:1370
static void add_module_typeinfo(struct sltg_typelib *typelib, type_t *type)
Definition: write_sltg.c:496
static void sltg_write_nametable(struct sltg_typelib *typelib)
Definition: write_sltg.c:1706
static void add_block_index(struct sltg_typelib *sltg, void *data, int length, int index)
Definition: write_sltg.c:382
static void add_structure_typeinfo(struct sltg_typelib *typelib, type_t *type)
Definition: write_sltg.c:923
static void sltg_write_remainder(void)
Definition: write_sltg.c:1720
static void write_impl_href(struct sltg_data *data, short href)
Definition: write_sltg.c:1350
static void sltg_write_header(struct sltg_typelib *sltg, int *library_block_start)
Definition: write_sltg.c:1605
static void save_all_changes(struct sltg_typelib *typelib)
Definition: write_sltg.c:1743
static void add_union_typeinfo(struct sltg_typelib *typelib, type_t *type)
Definition: write_sltg.c:1517
static const char * add_typeinfo_block(struct sltg_typelib *typelib, const type_t *type, short kind)
Definition: write_sltg.c:501
static void add_statement(struct sltg_typelib *typelib, const statement_t *stmt)
Definition: write_sltg.c:1557
static int get_element_size(type_t *type)
Definition: write_sltg.c:634
static void add_enum_typeinfo(struct sltg_typelib *typelib, type_t *type)
Definition: write_sltg.c:1512
static int get_func_flags(const var_t *func, int *dispid, int *invokekind, int *helpcontext, const char **helpstring)
Definition: write_sltg.c:1065
static void add_type_typeinfo(struct sltg_typelib *typelib, type_t *type)
Definition: write_sltg.c:1527
static void sltg_write_helpstrings(struct sltg_typelib *typelib)
Definition: write_sltg.c:1697
static void sltg_write_typeinfo(struct sltg_typelib *typelib)
Definition: write_sltg.c:1684
static int add_index(struct sltg_data *index, const char *name)
Definition: write_sltg.c:260
static unsigned int block
Definition: xmlmemory.c:101