ReactOS 0.4.15-dev-8241-g63935f8
write_sltg.c File Reference
#include "config.h"
#include "wine/port.h"
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <ctype.h>
#include <time.h>
#include "windef.h"
#include "winbase.h"
#include "widl.h"
#include "typelib.h"
#include "typelib_struct.h"
#include "utils.h"
#include "header.h"
#include "typetree.h"
#include "pshpack1.h"
#include "poppack.h"
Include dependency graph for write_sltg.c:

Go to the source code of this file.

Classes

struct  sltg_data
 
struct  sltg_library
 
struct  sltg_block
 
struct  sltg_typelib
 
struct  sltg_hrefmap
 
struct  sltg_typeinfo_header
 
struct  sltg_member_header
 
struct  sltg_variable
 
struct  sltg_tail
 
struct  sltg_hrefinfo
 
struct  sltg_function
 
struct  sltg_impl_info
 

Macros

#define NONAMELESSUNION
 

Functions

static void add_structure_typeinfo (struct sltg_typelib *typelib, type_t *type)
 
static void add_interface_typeinfo (struct sltg_typelib *typelib, type_t *type)
 
static void add_enum_typeinfo (struct sltg_typelib *typelib, type_t *type)
 
static void add_union_typeinfo (struct sltg_typelib *typelib, type_t *type)
 
static void add_coclass_typeinfo (struct sltg_typelib *typelib, type_t *type)
 
static void init_sltg_data (struct sltg_data *data)
 
static int add_index (struct sltg_data *index, const char *name)
 
static void init_index (struct sltg_data *index)
 
static int add_name (struct sltg_typelib *sltg, const char *name)
 
static void init_name_table (struct sltg_typelib *sltg)
 
static void init_library (struct sltg_typelib *sltg)
 
static void add_block_index (struct sltg_typelib *sltg, void *data, int size, int index)
 
static void add_block (struct sltg_typelib *sltg, void *data, int size, const char *name)
 
static voidcreate_library_block (struct sltg_typelib *typelib, int *size, int *index)
 
static const charnew_index_name (void)
 
static void sltg_add_typeinfo (struct sltg_typelib *sltg, void *data, int size, const char *name)
 
static void append_data (struct sltg_data *block, const void *data, int size)
 
static void add_module_typeinfo (struct sltg_typelib *typelib, type_t *type)
 
static const charadd_typeinfo_block (struct sltg_typelib *typelib, const type_t *type, int kind)
 
static void init_typeinfo (struct sltg_typeinfo_header *ti, const type_t *type, int kind, const struct sltg_hrefmap *hrefmap)
 
static void init_sltg_tail (struct sltg_tail *tail)
 
static void write_hrefmap (struct sltg_data *data, const struct sltg_hrefmap *hrefmap)
 
static void dump_var_desc (const char *data, int size)
 
static int get_element_size (type_t *type)
 
static int local_href (struct sltg_hrefmap *hrefmap, int typelib_href)
 
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)
 
static importinfo_tfind_importinfo (typelib_t *typelib, const char *name)
 
static int get_func_flags (const var_t *func, int *dispid, int *invokekind, int *helpcontext, const char **helpstring)
 
static int get_param_flags (const var_t *param)
 
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)
 
static void write_impl_href (struct sltg_data *data, short href)
 
static void add_type_typeinfo (struct sltg_typelib *typelib, type_t *type)
 
static void add_statement (struct sltg_typelib *typelib, const statement_t *stmt)
 
static void sltg_write_header (struct sltg_typelib *sltg, int *library_block_start)
 
static void sltg_write_typeinfo (struct sltg_typelib *typelib)
 
static void sltg_write_helpstrings (struct sltg_typelib *typelib)
 
static void sltg_write_nametable (struct sltg_typelib *typelib)
 
static void sltg_write_remainder (void)
 
static void save_all_changes (struct sltg_typelib *typelib)
 
int create_sltg_typelib (typelib_t *typelib)
 

Variables

static const GUID sltg_library_guid = { 0x204ff,0,0,{ 0xc0,0,0,0,0,0,0,0x46 } }
 

Macro Definition Documentation

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 31 of file write_sltg.c.

Function Documentation

◆ add_block()

static void add_block ( struct sltg_typelib sltg,
void data,
int  size,
const char name 
)
static

Definition at line 406 of file write_sltg.c.

407{
408 struct sltg_block *block = xmalloc(sizeof(*block));
409 int index;
410
411 chat("add_block: %p,%d,\"%s\"\n", data, size, name);
412
413 index = add_index(&sltg->index, name);
414
416}
void * xmalloc(int size)
Definition: uimain.c:747
#define index(s, c)
Definition: various.h:29
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
GLuint index
Definition: glext.h:6031
void chat(const char *s,...)
Definition: utils.c:131
Definition: name.c:39
struct sltg_data index
Definition: write_sltg.c:80
static void add_block_index(struct sltg_typelib *sltg, void *data, int size, int index)
Definition: write_sltg.c:382
static int add_index(struct sltg_data *index, const char *name)
Definition: write_sltg.c:264
static unsigned int block
Definition: xmlmemory.c:101

Referenced by add_interface_typeinfo(), and add_structure_typeinfo().

◆ add_block_index()

static void add_block_index ( struct sltg_typelib sltg,
void data,
int  size,
int  index 
)
static

Definition at line 382 of file write_sltg.c.

383{
384 struct sltg_block *block = xmalloc(sizeof(*block));
385
386 block->length = size;
387 block->data = data;
388 block->index_string = index;
389 block->next = NULL;
390
391 if (sltg->blocks)
392 {
393 struct sltg_block *blocks = sltg->blocks;
394
395 while (blocks->next)
396 blocks = blocks->next;
397
398 blocks->next = block;
399 }
400 else
401 sltg->blocks = block;
402
403 sltg->n_file_blocks++;
404}
#define NULL
Definition: types.h:112
static int blocks
Definition: mkdosfs.c:527
int n_file_blocks
Definition: write_sltg.c:84
struct sltg_block * blocks
Definition: write_sltg.c:83

Referenced by add_block(), and create_sltg_typelib().

◆ add_coclass_typeinfo()

static void add_coclass_typeinfo ( struct sltg_typelib typelib,
type_t type 
)
static

Definition at line 1568 of file write_sltg.c.

1569{
1570 error("add_coclass_typeinfo: %s not implemented\n", type->name);
1571}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define error(str)
Definition: mkdosfs.c:1605

Referenced by add_type_typeinfo(), and write_var_desc().

◆ add_enum_typeinfo()

static void add_enum_typeinfo ( struct sltg_typelib typelib,
type_t type 
)
static

Definition at line 1558 of file write_sltg.c.

1559{
1560 error("add_enum_typeinfo: %s not implemented\n", type->name);
1561}

Referenced by add_type_typeinfo(), and write_var_desc().

◆ add_func_desc()

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 
)
static

Definition at line 1232 of file write_sltg.c.

1234{
1235 struct sltg_data ret_data, *arg_data;
1236 int arg_count = 0, arg_data_size, optional = 0, defaults = 0, old_size;
1237 int funcflags = 0, invokekind = 1 /* INVOKE_FUNC */, helpcontext;
1238 const char *helpstring;
1239 const var_t *arg;
1240 short ret_desc_offset, *arg_desc_offset, arg_offset;
1241 struct sltg_function func_desc;
1242
1243 chat("add_func_desc: %s, idx %#x, dispid %#x\n", func->name, idx, dispid);
1244
1245 old_size = data->size;
1246
1247 init_sltg_data(&ret_data);
1248 ret_desc_offset = write_var_desc(typelib, &ret_data, type_function_get_rettype(func->type),
1249 0, 0, base_offset, NULL, hrefmap);
1250 dump_var_desc(ret_data.data, ret_data.size);
1251
1252 arg_data_size = 0;
1253 arg_offset = base_offset + sizeof(struct sltg_function);
1254
1255 if (ret_data.size > sizeof(short))
1256 {
1257 arg_data_size += ret_data.size;
1258 arg_offset += ret_data.size;
1259 }
1260
1261 if (type_get_function_args(func->type))
1262 {
1263 int i = 0;
1264
1265 arg_count = list_count(type_get_function_args(func->type));
1266
1267 arg_data = xmalloc(arg_count * sizeof(*arg_data));
1268 arg_desc_offset = xmalloc(arg_count * sizeof(*arg_desc_offset));
1269
1270 arg_offset += arg_count * 2 * sizeof(short);
1271
1273 {
1274 const attr_t *attr;
1275 short param_flags = get_param_flags(arg);
1276
1277 chat("add_func_desc: arg[%d] %p (%s), type %p (%s)\n",
1278 i, arg, arg->name, arg->type, arg->type->name);
1279
1280 init_sltg_data(&arg_data[i]);
1281
1282 arg_desc_offset[i] = write_var_desc(typelib, &arg_data[i], arg->type, param_flags, 0,
1283 arg_offset, NULL, hrefmap);
1284 dump_var_desc(arg_data[i].data, arg_data[i].size);
1285
1286 if (arg_data[i].size > sizeof(short))
1287 {
1288 arg_data_size += arg_data[i].size;
1289 arg_offset += arg_data[i].size;;
1290 }
1291
1292 i++;
1293
1294 if (!arg->attrs) continue;
1295
1296 LIST_FOR_EACH_ENTRY(attr, arg->attrs, const attr_t, entry)
1297 {
1298 if (attr->type == ATTR_DEFAULTVALUE)
1299 defaults++;
1300 else if(attr->type == ATTR_OPTIONAL)
1301 optional++;
1302 }
1303 }
1304 }
1305
1307
1308 if (base_offset != -1)
1309 chat("add_func_desc: flags %#x, dispid %#x, invokekind %d, helpcontext %#x, helpstring %s\n",
1310 funcflags, dispid, invokekind, helpcontext, helpstring);
1311
1312 func_desc.magic = 0x6c; /* always write flags to simplify calculations */
1313 func_desc.flags = (invokekind << 4) | 0x02;
1314 if (idx & 0x80000000)
1315 {
1316 func_desc.next = -1;
1317 idx &= ~0x80000000;
1318 }
1319 else
1320 func_desc.next = base_offset + sizeof(func_desc) + arg_data_size + arg_count * 2 * sizeof(short);
1321 func_desc.name = base_offset != -1 ? add_name(typelib, func->name) : -1;
1322 func_desc.dispid = dispid;
1323 func_desc.helpcontext = helpcontext;
1324 func_desc.helpstring = (helpstring && base_offset != -1) ? add_name(typelib, helpstring) : -1;
1325 func_desc.arg_off = arg_count ? base_offset + sizeof(func_desc) : -1;
1326 func_desc.nacc = (arg_count << 3) | 4 /* CC_STDCALL */;
1327 func_desc.retnextopt = (optional << 1);
1328 if (ret_data.size > sizeof(short))
1329 {
1330 func_desc.rettype = base_offset + sizeof(func_desc) + ret_desc_offset;
1331 if (arg_count)
1332 func_desc.arg_off += ret_data.size;
1333 }
1334 else
1335 {
1336 func_desc.retnextopt |= 0x80;
1337 func_desc.rettype = *(short *)ret_data.data;
1338 }
1339 func_desc.vtblpos = idx * pointer_size;
1340 func_desc.funcflags = funcflags;
1341
1342 append_data(data, &func_desc, sizeof(func_desc));
1343
1344 arg_offset = base_offset + sizeof(struct sltg_function);
1345
1346 if (ret_data.size > sizeof(short))
1347 {
1348 append_data(data, ret_data.data, ret_data.size);
1349 func_desc.arg_off += ret_data.size;
1350 arg_offset += ret_data.size;
1351 }
1352
1353 if (arg_count)
1354 {
1355 int i = 0;
1356
1357 arg_offset += arg_count * 2 * sizeof(short);
1358
1360 {
1361 short name, type_offset;
1362
1363 name = base_offset != -1 ? add_name(typelib, arg->name) : -1;
1364
1365 if (arg_data[i].size > sizeof(short))
1366 {
1367 type_offset = (arg_offset + arg_desc_offset[i]);
1368 arg_offset += arg_data[i].size;
1369 }
1370 else
1371 {
1372 name |= 1;
1373 type_offset = *(short *)arg_data[i].data;
1374 }
1375
1376 append_data(data, &name, sizeof(name));
1377 append_data(data, &type_offset, sizeof(type_offset));
1378
1379 if (base_offset != -1)
1380 chat("add_func_desc: arg[%d] - name %s (%#x), type_offset %#x\n",
1381 i, arg->name, name, type_offset);
1382
1383 i++;
1384 }
1385
1386 for (i = 0; i < arg_count; i++)
1387 {
1388 if (arg_data[i].size > sizeof(short))
1389 append_data(data, arg_data[i].data, arg_data[i].size);
1390 }
1391 }
1392
1393 return data->size - old_size;
1394}
@ optional
Definition: SystemMenu.c:34
coclass MediaStreamFilter helpstring("Stream Class")
static ITypeLib * typelib
Definition: apps.c:108
unsigned int idx
Definition: utils.c:41
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
GLenum func
Definition: glext.h:6028
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
uint32_t entry
Definition: isohybrid.c:63
static const ASMPROP_RES defaults[ASM_NAME_MAX_PARAMS]
Definition: asmname.c:82
__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
Definition: cookie.c:202
int size
Definition: write_sltg.c:52
short helpcontext
Definition: write_sltg.c:216
short funcflags
Definition: write_sltg.c:225
static type_t * type_function_get_rettype(const type_t *type)
Definition: typetree.h:108
unsigned int pointer_size
Definition: widl.c:158
@ ATTR_OPTIONAL
Definition: widltypes.h:137
@ ATTR_DEFAULTVALUE
Definition: widltypes.h:91
static var_list_t * type_get_function_args(const type_t *func_type)
Definition: widltypes.h:585
void * arg
Definition: msvc.h:10
static void dump_var_desc(const char *data, int size)
Definition: write_sltg.c:695
static int get_param_flags(const var_t *param)
Definition: write_sltg.c:1186
static void init_sltg_data(struct sltg_data *data)
Definition: write_sltg.c:257
static void append_data(struct sltg_data *block, const void *data, int size)
Definition: write_sltg.c:512
static int add_name(struct sltg_typelib *sltg, const char *name)
Definition: write_sltg.c:292
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:802
static int get_func_flags(const var_t *func, int *dispid, int *invokekind, int *helpcontext, const char **helpstring)
Definition: write_sltg.c:1105

Referenced by add_interface_typeinfo().

◆ add_index()

static int add_index ( struct sltg_data index,
const char name 
)
static

Definition at line 264 of file write_sltg.c.

265{
266 int name_offset = index->size;
267 int new_size = index->size + strlen(name) + 1;
268
269 chat("add_index: name_offset %d, \"%s\"\n", name_offset, name);
270
271 if (new_size > index->allocated)
272 {
273 index->allocated = max(index->allocated * 2, new_size);
274 index->data = xrealloc(index->data, index->allocated);
275 }
276
277 strcpy(index->data + index->size, name);
278 index->size = new_size;
279
280 return name_offset;
281}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
void * xrealloc(void *oldmem, size_t size)
Definition: uimain.c:736
#define max(a, b)
Definition: svc.c:63

Referenced by add_block(), create_library_block(), and init_index().

◆ add_interface_typeinfo()

static void add_interface_typeinfo ( struct sltg_typelib typelib,
type_t type 
)
static

Definition at line 1416 of file write_sltg.c.

1417{
1418 const statement_t *stmt_func;
1419 importinfo_t *ref_importinfo = NULL;
1420 short inherit_href = -1;
1421 struct sltg_data data;
1422 struct sltg_hrefmap hrefmap;
1423 const char *index_name;
1424 struct sltg_typeinfo_header ti;
1426 struct sltg_tail tail;
1427 int member_offset, base_offset, func_data_size, i;
1428 int func_count, inherited_func_count = 0;
1429 int dispid, inherit_level = 0;
1430
1431 if (iface->typelib_idx != -1) return;
1432
1433 chat("add_interface_typeinfo: type %p, type->name %s\n", iface, iface->name);
1434
1435 if (!iface->details.iface)
1436 {
1437 error("interface %s is referenced but not defined\n", iface->name);
1438 return;
1439 }
1440
1441 if (is_attr(iface->attrs, ATTR_DISPINTERFACE))
1442 {
1443 error("support for dispinterface %s is not implemented\n", iface->name);
1444 return;
1445 }
1446
1447 hrefmap.href_count = 0;
1448 hrefmap.href = NULL;
1449
1450 if (type_iface_get_inherit(iface))
1451 {
1452 type_t *inherit;
1453
1454 inherit = type_iface_get_inherit(iface);
1455
1456 chat("add_interface_typeinfo: inheriting from base interface %s\n", inherit->name);
1457
1458 ref_importinfo = find_importinfo(typelib->typelib, inherit->name);
1459
1460 if (!ref_importinfo && type_iface_get_inherit(inherit))
1462
1463 if (ref_importinfo)
1464 error("support for imported interfaces is not implemented\n");
1465
1466 inherit_href = local_href(&hrefmap, inherit->typelib_idx);
1467
1468 while (inherit)
1469 {
1470 inherit_level++;
1471 inherited_func_count += list_count(type_iface_get_stmts(inherit));
1472 inherit = type_iface_get_inherit(inherit);
1473 }
1474 }
1475
1476 /* check typelib_idx again, it could have been added while resolving the parent interface */
1477 if (iface->typelib_idx != -1) return;
1478
1479 iface->typelib_idx = typelib->n_file_blocks;
1480
1481 /* pass 1: calculate function descriptions data size */
1483
1485 {
1486 add_func_desc(typelib, &data, stmt_func->u.var, -1, -1, -1, &hrefmap);
1487 }
1488
1489 func_data_size = data.size;
1490
1491 /* pass 2: write function descriptions */
1493
1494 func_count = list_count(type_iface_get_stmts(iface));
1495
1496 index_name = add_typeinfo_block(typelib, iface, TKIND_INTERFACE);
1497
1498 init_typeinfo(&ti, iface, TKIND_INTERFACE, &hrefmap);
1499 append_data(&data, &ti, sizeof(ti));
1500
1501 write_hrefmap(&data, &hrefmap);
1502
1503 member_offset = data.size;
1504 base_offset = 0;
1505
1506 member.res00 = 0x0001;
1507 member.res02 = 0xffff;
1508 member.res04 = 0x01;
1509 member.extra = func_data_size;
1510 if (inherit_href != -1)
1511 {
1512 member.extra += sizeof(struct sltg_impl_info);
1513 base_offset += sizeof(struct sltg_impl_info);
1514 }
1515 append_data(&data, &member, sizeof(member));
1516
1517 if (inherit_href != -1)
1518 write_impl_href(&data, inherit_href);
1519
1520 i = 0;
1521 dispid = 0x60000000 | (inherit_level << 16);
1522
1524 {
1525 int idx = inherited_func_count + i;
1526
1527 if (i == func_count - 1) idx |= 0x80000000;
1528
1529 base_offset += add_func_desc(typelib, &data, stmt_func->u.var,
1530 idx, dispid + i, base_offset, &hrefmap);
1531 i++;
1532 }
1533
1535
1536 tail.cFuncs = func_count;
1537 tail.funcs_off = 0;
1538 tail.funcs_bytes = func_data_size;
1539 tail.cbSizeInstance = pointer_size;
1540 tail.cbAlignment = pointer_size;
1541 tail.cbSizeVft = (inherited_func_count + func_count) * pointer_size;
1542 tail.type_bytes = data.size - member_offset - sizeof(member);
1543 tail.res24 = 0;
1544 tail.res26 = 0;
1545 if (inherit_href != -1)
1546 {
1547 tail.cImplTypes++;
1548 tail.impls_off = 0;
1549 tail.impls_bytes = 0;
1550
1551 tail.funcs_off += sizeof(struct sltg_impl_info);
1552 }
1553 append_data(&data, &tail, sizeof(tail));
1554
1555 add_block(typelib, data.data, data.size, index_name);
1556}
struct outqueuenode * tail
Definition: adnsresfilter.c:66
int is_attr(const attr_list_t *list, enum attr_type t)
Definition: header.c:99
union _statement_t::@5043 u
var_t * var
Definition: widltypes.h:539
int typelib_idx
Definition: widltypes.h:440
const char * name
Definition: widltypes.h:419
static type_t * type_iface_get_inherit(const type_t *type)
Definition: typetree.h:158
static statement_list_t * type_iface_get_stmts(const type_t *type)
Definition: typetree.h:151
@ TKIND_INTERFACE
Definition: widltypes.h:222
@ ATTR_DISPINTERFACE
Definition: widltypes.h:94
#define STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
Definition: widltypes.h:597
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:1232
static void write_hrefmap(struct sltg_data *data, const struct sltg_hrefmap *hrefmap)
Definition: write_sltg.c:641
static importinfo_t * find_importinfo(typelib_t *typelib, const char *name)
Definition: write_sltg.c:1084
static void init_sltg_tail(struct sltg_tail *tail)
Definition: write_sltg.c:610
static int local_href(struct sltg_hrefmap *hrefmap, int typelib_href)
Definition: write_sltg.c:771
static void add_block(struct sltg_typelib *sltg, void *data, int size, const char *name)
Definition: write_sltg.c:406
static void add_interface_typeinfo(struct sltg_typelib *typelib, type_t *type)
Definition: write_sltg.c:1416
static void write_impl_href(struct sltg_data *data, short href)
Definition: write_sltg.c:1396
static const char * add_typeinfo_block(struct sltg_typelib *typelib, const type_t *type, int kind)
Definition: write_sltg.c:531
static void init_typeinfo(struct sltg_typeinfo_header *ti, const type_t *type, int kind, const struct sltg_hrefmap *hrefmap)
Definition: write_sltg.c:575

Referenced by add_interface_typeinfo(), add_type_typeinfo(), and write_var_desc().

◆ add_module_typeinfo()

static void add_module_typeinfo ( struct sltg_typelib typelib,
type_t type 
)
static

Definition at line 526 of file write_sltg.c.

527{
528 error("add_module_typeinfo: %s not implemented\n", type->name);
529}

Referenced by add_statement().

◆ add_name()

static int add_name ( struct sltg_typelib sltg,
const char name 
)
static

Definition at line 292 of file write_sltg.c.

293{
294 int name_offset = sltg->name_table.size;
295 int new_size = sltg->name_table.size + strlen(name) + 1 + 8;
296 int aligned_size;
297
298 chat("add_name: %s\n", name);
299
300 aligned_size = (new_size + 0x1f) & ~0x1f;
301 if (aligned_size - new_size < 4)
302 new_size = aligned_size;
303 else
304 new_size = (new_size + 1) & ~1;
305
306 if (new_size > sltg->name_table.allocated)
307 {
308 sltg->name_table.allocated = max(sltg->name_table.allocated * 2, new_size);
309 sltg->name_table.data = xrealloc(sltg->name_table.data, sltg->name_table.allocated);
310 }
311
312 memset(sltg->name_table.data + sltg->name_table.size, 0xff, 8);
313 strcpy(sltg->name_table.data + sltg->name_table.size + 8, name);
314 sltg->name_table.size = new_size;
315 sltg->name_table.data[sltg->name_table.size - 1] = 0; /* clear alignment */
316
317 return name_offset;
318}
#define memset(x, y, z)
Definition: compat.h:39
struct sltg_data name_table
Definition: write_sltg.c:81

Referenced by add_func_desc(), add_structure_typeinfo(), add_typeinfo_block(), and init_library().

◆ add_statement()

static void add_statement ( struct sltg_typelib typelib,
const statement_t stmt 
)
static

Definition at line 1603 of file write_sltg.c.

1604{
1605 switch(stmt->type)
1606 {
1607 case STMT_LIBRARY:
1608 case STMT_IMPORT:
1609 case STMT_PRAGMA:
1610 case STMT_CPPQUOTE:
1611 case STMT_DECLARATION:
1612 /* not included in typelib */
1613 break;
1614 case STMT_IMPORTLIB:
1615 /* not processed here */
1616 break;
1617
1618 case STMT_TYPEDEF:
1619 {
1620 const type_list_t *type_entry = stmt->u.type_list;
1621 for (; type_entry; type_entry = type_entry->next)
1622 {
1623 /* in old style typelibs all types are public */
1624 add_type_typeinfo(typelib, type_entry->type);
1625 }
1626 break;
1627 }
1628
1629 case STMT_MODULE:
1631 break;
1632
1633 case STMT_TYPE:
1634 case STMT_TYPEREF:
1635 {
1636 type_t *type = stmt->u.type;
1638 break;
1639 }
1640
1641 default:
1642 error("add_statement: unhandled statement type %d\n", stmt->type);
1643 break;
1644 }
1645}
statement_type_t type
Definition: parser.h:124
type_list_t * type_list
Definition: widltypes.h:541
struct _type_list_t * next
Definition: widltypes.h:528
type_t * type
Definition: widltypes.h:527
@ STMT_MODULE
Definition: widltypes.h:244
@ STMT_IMPORT
Definition: widltypes.h:246
@ STMT_IMPORTLIB
Definition: widltypes.h:247
@ STMT_TYPE
Definition: widltypes.h:242
@ STMT_DECLARATION
Definition: widltypes.h:241
@ STMT_LIBRARY
Definition: widltypes.h:240
@ STMT_TYPEDEF
Definition: widltypes.h:245
@ STMT_CPPQUOTE
Definition: widltypes.h:249
@ STMT_TYPEREF
Definition: widltypes.h:243
@ STMT_PRAGMA
Definition: widltypes.h:248
static void add_module_typeinfo(struct sltg_typelib *typelib, type_t *type)
Definition: write_sltg.c:526
static void add_type_typeinfo(struct sltg_typelib *typelib, type_t *type)
Definition: write_sltg.c:1573

Referenced by create_sltg_typelib().

◆ add_structure_typeinfo()

static void add_structure_typeinfo ( struct sltg_typelib typelib,
type_t type 
)
static

Definition at line 962 of file write_sltg.c.

963{
964 struct sltg_data data, *var_data = NULL;
965 struct sltg_hrefmap hrefmap;
966 const char *index_name;
967 struct sltg_typeinfo_header ti;
969 struct sltg_tail tail;
970 int member_offset, var_count = 0, var_data_size = 0, size_instance = 0;
971 short *type_desc_offset = NULL;
972
973 if (type->typelib_idx != -1) return;
974
975 chat("add_structure_typeinfo: type %p, type->name %s\n", type, type->name);
976
977 type->typelib_idx = typelib->n_file_blocks;
978
979 hrefmap.href_count = 0;
980 hrefmap.href = NULL;
981
983 {
984 int i = 0;
985 var_t *var;
986
988
989 var_data = xmalloc(var_count * sizeof(*var_data));
990 type_desc_offset = xmalloc(var_count * sizeof(*type_desc_offset));
991
993 {
994 short base_offset;
995
996 chat("add_structure_typeinfo: var %p (%s), type %p (%s)\n",
997 var, var->name, var->type, var->type->name);
998
999 init_sltg_data(&var_data[i]);
1000
1001 base_offset = var_data_size + (i + 1) * sizeof(struct sltg_variable);
1002 type_desc_offset[i] = write_var_desc(typelib, &var_data[i], var->type, 0, 0,
1003 base_offset, &size_instance, &hrefmap);
1004 dump_var_desc(var_data[i].data, var_data[i].size);
1005
1006 if (var_data[i].size > sizeof(short))
1007 var_data_size += var_data[i].size;
1008 i++;
1009 }
1010 }
1011
1013
1015
1016 init_typeinfo(&ti, type, TKIND_RECORD, &hrefmap);
1017 append_data(&data, &ti, sizeof(ti));
1018
1019 write_hrefmap(&data, &hrefmap);
1020
1021 member_offset = data.size;
1022
1023 member.res00 = 0x0001;
1024 member.res02 = 0xffff;
1025 member.res04 = 0x01;
1026 member.extra = var_data_size + var_count * sizeof(struct sltg_variable);
1027 append_data(&data, &member, sizeof(member));
1028
1029 var_data_size = 0;
1030
1032 {
1033 int i = 0;
1034 short next = member_offset;
1035 var_t *var;
1036
1038 {
1039 struct sltg_variable variable;
1040
1041 next += sizeof(variable);
1042
1043 variable.magic = 0x2a; /* always write flags to simplify calculations */
1044 variable.name = add_name(typelib, var->name);
1045 variable.byte_offs = 0;
1046 if (var_data[i].size > sizeof(short))
1047 {
1048 variable.flags = 0;
1049 var_data_size = next - member_offset + type_desc_offset[i];
1050 variable.type = var_data_size;
1051 next += var_data[i].size;
1052 }
1053 else
1054 {
1055 variable.flags = 0x02;
1056 variable.type = *(short *)var_data[i].data;
1057 }
1058 variable.next = i < var_count - 1 ? next - member_offset : -1;
1059 variable.memid = 0x40000000 + i;
1060 variable.helpcontext = -2; /* 0xfffe */
1061 variable.helpstring = -1;
1062 variable.varflags = 0;
1063
1064 append_data(&data, &variable, sizeof(variable));
1065 if (var_data[i].size > sizeof(short))
1066 append_data(&data, var_data[i].data, var_data[i].size);
1067
1068 i++;
1069 }
1070 }
1071
1073
1074 tail.cVars = var_count;
1075 tail.vars_off = 0;
1076 tail.vars_bytes = var_data_size;
1077 tail.cbSizeInstance = size_instance;
1078 tail.type_bytes = data.size - member_offset - sizeof(member);
1079 append_data(&data, &tail, sizeof(tail));
1080
1081 add_block(typelib, data.data, data.size, index_name);
1082}
GLenum GLenum variable
Definition: glext.h:9031
const char * var
Definition: shader.c:5666
static unsigned __int64 next
Definition: rand_nt.c:6
static var_list_t * type_struct_get_fields(const type_t *type)
Definition: typetree.h:87
@ TKIND_RECORD
Definition: widltypes.h:220

Referenced by add_type_typeinfo(), and write_var_desc().

◆ add_type_typeinfo()

static void add_type_typeinfo ( struct sltg_typelib typelib,
type_t type 
)
static

Definition at line 1573 of file write_sltg.c.

1574{
1575 chat("add_type_typeinfo: adding %s, type %d\n", type->name, type_get_type(type));
1576
1577 switch (type_get_type(type))
1578 {
1579 case TYPE_INTERFACE:
1581 break;
1582 case TYPE_STRUCT:
1584 break;
1585 case TYPE_ENUM:
1587 break;
1588 case TYPE_UNION:
1590 break;
1591 case TYPE_COCLASS:
1593 break;
1594 case TYPE_BASIC:
1595 case TYPE_POINTER:
1596 break;
1597 default:
1598 error("add_type_typeinfo: unhandled type %d for %s\n", type_get_type(type), type->name);
1599 break;
1600 }
1601}
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:68
@ TYPE_ENUM
Definition: widltypes.h:404
@ TYPE_BASIC
Definition: widltypes.h:403
@ TYPE_UNION
Definition: widltypes.h:407
@ TYPE_POINTER
Definition: widltypes.h:413
@ TYPE_COCLASS
Definition: widltypes.h:410
@ TYPE_STRUCT
Definition: widltypes.h:405
@ TYPE_INTERFACE
Definition: widltypes.h:412
static void add_coclass_typeinfo(struct sltg_typelib *typelib, type_t *type)
Definition: write_sltg.c:1568
static void add_structure_typeinfo(struct sltg_typelib *typelib, type_t *type)
Definition: write_sltg.c:962
static void add_union_typeinfo(struct sltg_typelib *typelib, type_t *type)
Definition: write_sltg.c:1563
static void add_enum_typeinfo(struct sltg_typelib *typelib, type_t *type)
Definition: write_sltg.c:1558

Referenced by add_statement().

◆ add_typeinfo_block()

static const char * add_typeinfo_block ( struct sltg_typelib typelib,
const type_t type,
int  kind 
)
static

Definition at line 531 of file write_sltg.c.

532{
533 const char *index_name, *other_name;
534 void *block;
535 short *p;
536 int size, helpcontext = 0;
537 GUID guid = { 0 };
538 const expr_t *expr;
539
540 index_name = new_index_name();
541 other_name = new_index_name();
542
544 if (expr) helpcontext = expr->cval;
545
546 p = get_attrp(type->attrs, ATTR_UUID);
547 if (p) guid = *(GUID *)p;
548
549 size = sizeof(short) * 8 + 10 /* index_name */ * 2 + sizeof(int) + sizeof(GUID);
550
551 block = xmalloc(size);
552 p = block;
553 *p++ = strlen(index_name);
554 strcpy((char *)p, index_name);
555 p = (short *)((char *)p + strlen(index_name));
556 *p++ = strlen(other_name);
557 strcpy((char *)p, other_name);
558 p = (short *)((char *)p + strlen(other_name));
559 *p++ = -1; /* res1a */
560 *p++ = add_name(typelib, type->name); /* name offset */
561 *p++ = 0; /* FIXME: helpstring */
562 *p++ = -1; /* res20 */
563 *(int *)p = helpcontext;
564 p += 2;
565 *p++ = -1; /* res26 */
566 *(GUID *)p = guid;
567 p += sizeof(GUID)/2;
568 *p = kind;
569
570 sltg_add_typeinfo(typelib, block, size, index_name);
571
572 return index_name;
573}
GLfloat GLfloat p
Definition: glext.h:8902
const GUID * guid
void * get_attrp(const attr_list_t *list, enum attr_type t)
Definition: header.c:107
Definition: query.h:87
@ ATTR_UUID
Definition: widltypes.h:166
@ ATTR_HELPCONTEXT
Definition: widltypes.h:106
static const char * new_index_name(void)
Definition: write_sltg.c:465
static void sltg_add_typeinfo(struct sltg_typelib *sltg, void *data, int size, const char *name)
Definition: write_sltg.c:485

Referenced by add_interface_typeinfo(), and add_structure_typeinfo().

◆ add_union_typeinfo()

static void add_union_typeinfo ( struct sltg_typelib typelib,
type_t type 
)
static

Definition at line 1563 of file write_sltg.c.

1564{
1565 error("add_union_typeinfo: %s not implemented\n", type->name);
1566}

Referenced by add_type_typeinfo(), and write_var_desc().

◆ append_data()

static void append_data ( struct sltg_data block,
const void data,
int  size 
)
static

Definition at line 512 of file write_sltg.c.

513{
514 int new_size = block->size + size;
515
516 if (new_size > block->allocated)
517 {
518 block->allocated = max(block->allocated * 2, new_size);
519 block->data = xrealloc(block->data, block->allocated);
520 }
521
522 memcpy(block->data + block->size, data, size);
523 block->size = new_size;
524}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by add_func_desc(), add_interface_typeinfo(), add_structure_typeinfo(), write_hrefmap(), write_impl_href(), and write_var_desc().

◆ create_library_block()

static void * create_library_block ( struct sltg_typelib typelib,
int size,
int index 
)
static

Definition at line 418 of file write_sltg.c.

419{
420 void *block;
421 short *p;
422
423 *size = sizeof(short) * 9 + sizeof(int) * 3 + sizeof(GUID);
424 if (typelib->library.helpstring) *size += strlen(typelib->library.helpstring);
425 if (typelib->library.helpfile) *size += strlen(typelib->library.helpfile);
426
427 block = xmalloc(*size);
428 p = block;
429 *p++ = 0x51cc; /* magic */
430 *p++ = 3; /* res02 */
431 *p++ = typelib->library.name;
432 *p++ = 0xffff; /* res06 */
433 if (typelib->library.helpstring)
434 {
435 *p++ = strlen(typelib->library.helpstring);
436 strcpy((char *)p, typelib->library.helpstring);
437 p = (short *)((char *)p + strlen(typelib->library.helpstring));
438 }
439 else
440 *p++ = 0xffff;
441 if (typelib->library.helpfile)
442 {
443 *p++ = strlen(typelib->library.helpfile);
444 strcpy((char *)p, typelib->library.helpfile);
445 p = (short *)((char *)p + strlen(typelib->library.helpfile));
446 }
447 else
448 *p++ = 0xffff;
449 *(int *)p = typelib->library.helpcontext;
450 p += 2;
451 *p++ = typelib->library.syskind;
452 *p++ = typelib->library.lcid;
453 *(int *)p = 0; /* res12 */
454 p += 2;
455 *p++ = typelib->library.libflags;
456 *(int *)p = typelib->library.version;
457 p += 2;
458 *(GUID *)p = typelib->library.uuid;
459
460 *index = add_index(&typelib->index, "dir");
461
462 return block;
463}

Referenced by create_sltg_typelib().

◆ create_sltg_typelib()

int create_sltg_typelib ( typelib_t typelib)

Definition at line 1831 of file write_sltg.c.

1832{
1833 struct sltg_typelib sltg;
1834 const statement_t *stmt;
1835 void *library_block;
1836 int library_block_size, library_block_index;
1837
1838 sltg.typelib = typelib;
1839 sltg.typeinfo_count = 0;
1840 sltg.typeinfo_size = 0;
1841 sltg.typeinfo = NULL;
1842 sltg.blocks = NULL;
1843 sltg.n_file_blocks = 0;
1844 sltg.first_block = 1;
1845
1846 init_index(&sltg.index);
1847 init_name_table(&sltg);
1848 init_library(&sltg);
1849
1850 library_block = create_library_block(&sltg, &library_block_size, &library_block_index);
1851
1852 if (typelib->stmts)
1853 LIST_FOR_EACH_ENTRY(stmt, typelib->stmts, const statement_t, entry)
1854 add_statement(&sltg, stmt);
1855
1856 add_block_index(&sltg, library_block, library_block_size, library_block_index);
1857
1858 save_all_changes(&sltg);
1859
1860 return 1;
1861}
static void init_name_table(struct sltg_typelib *sltg)
Definition: write_sltg.c:320
static void init_index(struct sltg_data *index)
Definition: write_sltg.c:283
static void * create_library_block(struct sltg_typelib *typelib, int *size, int *index)
Definition: write_sltg.c:418
static void init_library(struct sltg_typelib *sltg)
Definition: write_sltg.c:325
static void save_all_changes(struct sltg_typelib *typelib)
Definition: write_sltg.c:1798
static void add_statement(struct sltg_typelib *typelib, const statement_t *stmt)
Definition: write_sltg.c:1603

Referenced by write_typelib_regscript().

◆ dump_var_desc()

static void dump_var_desc ( const char data,
int  size 
)
static

Definition at line 695 of file write_sltg.c.

696{
697 const unsigned char *p = (const unsigned char *)data;
698 int i;
699
700 if (!(debuglevel & (DEBUGLEVEL_TRACE | DEBUGLEVEL_CHAT))) return;
701
702 chat("dump_var_desc: size %d bytes\n", size);
703
704 for (i = 0; i < size; i++)
705 fprintf(stderr, " %02x", *p++);
706
707 fprintf(stderr, "\n");
708}
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
int debuglevel
Definition: widl.c:110
#define DEBUGLEVEL_CHAT
Definition: widl.h:30
#define DEBUGLEVEL_TRACE
Definition: widl.h:32

Referenced by add_func_desc(), and add_structure_typeinfo().

◆ find_importinfo()

static importinfo_t * find_importinfo ( typelib_t typelib,
const char name 
)
static

Definition at line 1084 of file write_sltg.c.

1085{
1087
1088 LIST_FOR_EACH_ENTRY(importlib, &typelib->importlibs, importlib_t, entry)
1089 {
1090 int i;
1091
1092 for (i = 0; i < importlib->ntypeinfos; i++)
1093 {
1094 if (!strcmp(name, importlib->importinfos[i].name))
1095 {
1096 chat("Found %s in importlib list\n", name);
1097 return &importlib->importinfos[i];
1098 }
1099 }
1100 }
1101
1102 return NULL;
1103}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
importlib("stdole2.tlb")

Referenced by add_interface_typeinfo().

◆ get_element_size()

static int get_element_size ( type_t type)
static

Definition at line 710 of file write_sltg.c.

711{
712 int vt = get_type_vt(type);
713
714 switch (vt)
715 {
716 case VT_I1:
717 case VT_UI1:
718 return 1;
719
720 case VT_INT:
721 case VT_UINT:
722 return /* typelib_kind == SYS_WIN16 ? 2 : */ 4;
723
724 case VT_UI2:
725 case VT_I2:
726 case VT_BOOL:
727 return 2;
728
729 case VT_I4:
730 case VT_UI4:
731 case VT_R4:
732 case VT_ERROR:
733 case VT_HRESULT:
734 return 4;
735
736 case VT_R8:
737 case VT_I8:
738 case VT_UI8:
739 case VT_CY:
740 case VT_DATE:
741 return 8;
742
743 case VT_DECIMAL:
744 return 16;
745
746 case VT_PTR:
747 case VT_UNKNOWN:
748 case VT_DISPATCH:
749 case VT_BSTR:
750 case VT_LPSTR:
751 case VT_LPWSTR:
752 return pointer_size;
753
754 case VT_VOID:
755 return 0;
756
757 case VT_VARIANT:
758 return pointer_size == 8 ? 24 : 16;
759
760 case VT_USERDEFINED:
761 return 0;
762
763 default:
764 error("get_element_size: unrecognized vt %d\n", vt);
765 break;
766 }
767
768 return 0;
769}
@ 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_DISPATCH
Definition: compat.h:2304
@ VT_UI1
Definition: compat.h:2311
static REFPROPVARIANT PROPVAR_CHANGE_FLAGS VARTYPE vt
Definition: suminfo.c:86
unsigned short get_type_vt(type_t *t)
Definition: typelib.c:129

Referenced by write_var_desc().

◆ get_func_flags()

static int get_func_flags ( const var_t func,
int dispid,
int invokekind,
int helpcontext,
const char **  helpstring 
)
static

Definition at line 1105 of file write_sltg.c.

1106{
1107 const attr_t *attr;
1108 int flags;
1109
1110 *invokekind = 1 /* INVOKE_FUNC */;
1111 *helpcontext = -2;
1112 *helpstring = NULL;
1113
1114 if (!func->attrs) return 0;
1115
1116 flags = 0;
1117
1118 LIST_FOR_EACH_ENTRY(attr, func->attrs, const attr_t, entry)
1119 {
1120 expr_t *expr = attr->u.pval;
1121 switch(attr->type)
1122 {
1123 case ATTR_BINDABLE:
1124 flags |= 0x4; /* FUNCFLAG_FBINDABLE */
1125 break;
1126 case ATTR_DEFAULTBIND:
1127 flags |= 0x20; /* FUNCFLAG_FDEFAULTBIND */
1128 break;
1130 flags |= 0x100; /* FUNCFLAG_FDEFAULTCOLLELEM */
1131 break;
1132 case ATTR_DISPLAYBIND:
1133 flags |= 0x10; /* FUNCFLAG_FDISPLAYBIND */
1134 break;
1135 case ATTR_HELPCONTEXT:
1136 *helpcontext = expr->u.lval;
1137 break;
1138 case ATTR_HELPSTRING:
1139 *helpstring = attr->u.pval;
1140 break;
1141 case ATTR_HIDDEN:
1142 flags |= 0x40; /* FUNCFLAG_FHIDDEN */
1143 break;
1144 case ATTR_ID:
1145 *dispid = expr->cval;
1146 break;
1147 case ATTR_IMMEDIATEBIND:
1148 flags |= 0x1000; /* FUNCFLAG_FIMMEDIATEBIND */
1149 break;
1150 case ATTR_NONBROWSABLE:
1151 flags |= 0x400; /* FUNCFLAG_FNONBROWSABLE */
1152 break;
1153 case ATTR_PROPGET:
1154 *invokekind = 0x2; /* INVOKE_PROPERTYGET */
1155 break;
1156 case ATTR_PROPPUT:
1157 *invokekind = 0x4; /* INVOKE_PROPERTYPUT */
1158 break;
1159 case ATTR_PROPPUTREF:
1160 *invokekind = 0x8; /* INVOKE_PROPERTYPUTREF */
1161 break;
1162 /* FIXME: FUNCFLAG_FREPLACEABLE */
1163 case ATTR_REQUESTEDIT:
1164 flags |= 0x8; /* FUNCFLAG_FREQUESTEDIT */
1165 break;
1166 case ATTR_RESTRICTED:
1167 flags |= 0x1; /* FUNCFLAG_FRESTRICTED */
1168 break;
1169 case ATTR_SOURCE:
1170 flags |= 0x2; /* FUNCFLAG_FSOURCE */
1171 break;
1172 case ATTR_UIDEFAULT:
1173 flags |= 0x200; /* FUNCFLAG_FUIDEFAULT */
1174 break;
1176 flags |= 0x80; /* FUNCFLAG_FUSESGETLASTERROR */
1177 break;
1178 default:
1179 break;
1180 }
1181 }
1182
1183 return flags;
1184}
#define ATTR_HIDDEN
Definition: fat.h:160
GLbitfield flags
Definition: glext.h:7161
union expr::@513 u
@ ATTR_PROPPUT
Definition: widltypes.h:145
@ ATTR_DEFAULTBIND
Definition: widltypes.h:89
@ ATTR_PROPPUTREF
Definition: widltypes.h:146
@ ATTR_IMMEDIATEBIND
Definition: widltypes.h:116
@ ATTR_DEFAULTCOLLELEM
Definition: widltypes.h:90
@ ATTR_REQUESTEDIT
Definition: widltypes.h:152
@ ATTR_UIDEFAULT
Definition: widltypes.h:163
@ ATTR_DISPLAYBIND
Definition: widltypes.h:95
@ ATTR_PROPGET
Definition: widltypes.h:144
@ ATTR_BINDABLE
Definition: widltypes.h:77
@ ATTR_RESTRICTED
Definition: widltypes.h:153
@ ATTR_ID
Definition: widltypes.h:112
@ ATTR_HELPSTRING
Definition: widltypes.h:108
@ ATTR_NONBROWSABLE
Definition: widltypes.h:128
@ ATTR_SOURCE
Definition: widltypes.h:156
@ ATTR_USESGETLASTERROR
Definition: widltypes.h:165

Referenced by add_func_desc().

◆ get_param_flags()

static int get_param_flags ( const var_t param)
static

Definition at line 1186 of file write_sltg.c.

1187{
1188 const attr_t *attr;
1189 int flags, in, out;
1190
1191 if (!param->attrs) return 0;
1192
1193 flags = 0;
1194 in = out = 0;
1195
1196 LIST_FOR_EACH_ENTRY(attr, param->attrs, const attr_t, entry)
1197 {
1198 switch(attr->type)
1199 {
1200 case ATTR_IN:
1201 in++;
1202 break;
1203 case ATTR_OUT:
1204 out++;
1205 break;
1206 case ATTR_PARAMLCID:
1207 flags |= 0x2000;
1208 break;
1209 case ATTR_RETVAL:
1210 flags |= 0x80;
1211 break;
1212 default:
1213 chat("unhandled param attr %d\n", attr->type);
1214 break;
1215 }
1216 }
1217
1218 if (out)
1219 {
1220 if (in)
1221 flags |= 0x8000;
1222 else
1223 flags |= 0x4000;
1224 }
1225 else if (!in)
1226 flags |= 0xc000;
1227
1228 return flags;
1229}
GLuint in
Definition: glext.h:9616
GLfloat param
Definition: glext.h:5796
static FILE * out
Definition: regtests2xml.c:44
@ ATTR_IN
Definition: widltypes.h:118
@ ATTR_RETVAL
Definition: widltypes.h:154
@ ATTR_OUT
Definition: widltypes.h:138
@ ATTR_PARAMLCID
Definition: widltypes.h:139

Referenced by add_func_desc().

◆ init_index()

static void init_index ( struct sltg_data index)
static

Definition at line 283 of file write_sltg.c.

284{
285 static const char compobj[] = { 1,'C','o','m','p','O','b','j',0 };
286
288
289 add_index(index, compobj);
290}

Referenced by create_sltg_typelib().

◆ init_library()

static void init_library ( struct sltg_typelib sltg)
static

Definition at line 325 of file write_sltg.c.

326{
327 const attr_t *attr;
328
329 sltg->library.name = add_name(sltg, sltg->typelib->name);
330 sltg->library.helpstring = NULL;
331 sltg->library.helpcontext = 0;
332 sltg->library.syskind = (pointer_size == 8) ? SYS_WIN64 : SYS_WIN32;
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}
const attr_list_t * attrs
Definition: widltypes.h:516
char * name
Definition: widltypes.h:515
typelib_t * typelib
Definition: write_sltg.c:79
struct sltg_library library
Definition: write_sltg.c:82
@ SYS_WIN32
Definition: widltypes.h:552
@ SYS_WIN64
Definition: widltypes.h:554
@ ATTR_HELPFILE
Definition: widltypes.h:107
@ ATTR_VERSION
Definition: widltypes.h:169
@ ATTR_CONTROL
Definition: widltypes.h:86
@ ATTR_LIBLCID
Definition: widltypes.h:122

Referenced by create_sltg_typelib().

◆ init_name_table()

static void init_name_table ( struct sltg_typelib sltg)
static

Definition at line 320 of file write_sltg.c.

321{
323}

Referenced by create_sltg_typelib().

◆ init_sltg_data()

static void init_sltg_data ( struct sltg_data data)
static

Definition at line 257 of file write_sltg.c.

258{
259 data->size = 0;
260 data->allocated = 0x10;
261 data->data = xmalloc(0x10);
262}

Referenced by add_func_desc(), add_interface_typeinfo(), add_structure_typeinfo(), init_index(), and init_name_table().

◆ init_sltg_tail()

static void init_sltg_tail ( struct sltg_tail tail)
static

Definition at line 610 of file write_sltg.c.

611{
612 tail->cFuncs = 0;
613 tail->cVars = 0;
614 tail->cImplTypes = 0;
615 tail->res06 = 0;
616 tail->funcs_off = -1;
617 tail->vars_off = -1;
618 tail->impls_off = -1;
619 tail->funcs_bytes = -1;
620 tail->vars_bytes = -1;
621 tail->impls_bytes = -1;
622 tail->tdescalias_vt = -1;
623 tail->res16 = -1;
624 tail->res18 = 0;
625 tail->res1a = 0;
626 tail->simple_alias = 0;
627 tail->res1e = 0;
628 tail->cbSizeInstance = 0;
629 tail->cbAlignment = 4;
630 tail->res24 = -1;
631 tail->res26 = -1;
632 tail->cbSizeVft = 0;
633 tail->res2a = -1;
634 tail->res2c = -1;
635 tail->res2e = -1;
636 tail->res30 = -1;
637 tail->res32 = 0;
638 tail->type_bytes = 0;
639}

Referenced by add_interface_typeinfo(), and add_structure_typeinfo().

◆ init_typeinfo()

static void init_typeinfo ( struct sltg_typeinfo_header ti,
const type_t type,
int  kind,
const struct sltg_hrefmap hrefmap 
)
static

Definition at line 575 of file write_sltg.c.

577{
578 ti->magic = 0x0501;
579 ti->href_offset = -1;
580 ti->res06 = -1;
581 ti->res0e = -1;
582 ti->version = get_attrv(type->attrs, ATTR_VERSION);
583 ti->res16 = 0xfffe0000;
584 ti->misc.unknown1 = 0x02;
585 ti->misc.flags = 0; /* FIXME */
586 ti->misc.unknown2 = 0x02;
587 ti->misc.typekind = kind;
588 ti->res1e = 0;
589
590 ti->member_offset = sizeof(*ti);
591
592 if (hrefmap->href_count)
593 {
594 char name[64];
595 int i, hrefinfo_size;
596
597 hrefinfo_size = sizeof(struct sltg_hrefinfo);
598
599 for (i = 0; i < hrefmap->href_count; i++)
600 {
601 sprintf(name, "*\\Rffff*#%x", hrefmap->href[i]);
602 hrefinfo_size += 8 + 2 + strlen(name);
603 }
604
605 ti->href_offset = ti->member_offset;
606 ti->member_offset += hrefinfo_size;
607 }
608}
#define sprintf(buf, format,...)
Definition: sprintf.c:55
unsigned int get_attrv(const attr_list_t *list, enum attr_type t)
Definition: header.c:115
int href_count
Definition: write_sltg.c:93
int * href
Definition: write_sltg.c:94
struct sltg_typeinfo_header::@5044 misc

Referenced by add_interface_typeinfo(), and add_structure_typeinfo().

◆ local_href()

static int local_href ( struct sltg_hrefmap hrefmap,
int  typelib_href 
)
static

Definition at line 771 of file write_sltg.c.

772{
773 int i, href = -1;
774
775 for (i = 0; i < hrefmap->href_count; i++)
776 {
777 if (hrefmap->href[i] == typelib_href)
778 {
779 href = i;
780 break;
781 }
782 }
783
784 if (href == -1)
785 {
786 href = hrefmap->href_count;
787
788 if (hrefmap->href)
789 hrefmap->href = xrealloc(hrefmap->href, sizeof(*hrefmap->href) * (hrefmap->href_count + 1));
790 else
791 hrefmap->href = xmalloc(sizeof(*hrefmap->href));
792
793 hrefmap->href[hrefmap->href_count] = typelib_href;
794 hrefmap->href_count++;
795 }
796
797 chat("typelib href %d mapped to local href %d\n", typelib_href, href);
798
799 return href << 2;
800}

Referenced by add_interface_typeinfo(), and write_var_desc().

◆ new_index_name()

static const char * new_index_name ( void  )
static

Definition at line 465 of file write_sltg.c.

466{
467 static char name[11] = "0000000000";
468 static int pos = 0;
469 char *new_name;
470
471 if (name[pos] == 'Z')
472 {
473 pos++;
474 if (pos > 9)
475 error("too many index names\n");
476 }
477
478 name[pos]++;
479
480 new_name = xmalloc(sizeof(name));
481 strcpy(new_name, name);
482 return new_name;
483}

Referenced by add_typeinfo_block().

◆ save_all_changes()

static void save_all_changes ( struct sltg_typelib typelib)
static

Definition at line 1798 of file write_sltg.c.

1799{
1800 int library_block_start;
1801 int *name_table_offset;
1802
1803 sltg_write_header(typelib, &library_block_start);
1805
1806 name_table_offset = (int *)(output_buffer + output_buffer_pos);
1807 chat("name_table_offset = %#lx\n", (SIZE_T)output_buffer_pos);
1808 put_data(&library_block_start, sizeof(library_block_start));
1809
1811
1812 *name_table_offset = output_buffer_pos - library_block_start;
1813 chat("*name_table_offset = %#x\n", *name_table_offset);
1814
1817
1818 if (strendswith(typelib_name, ".res")) /* create a binary resource file */
1819 {
1820 char typelib_id[13] = "#1";
1821
1822 expr_t *expr = get_attrp(typelib->typelib->attrs, ATTR_ID);
1823 if (expr)
1824 sprintf(typelib_id, "#%d", expr->cval);
1825 add_output_to_resources("TYPELIB", typelib_id);
1827 }
1829}
static HRESULT flush_output_buffer(mxwriter *This)
Definition: mxwriter.c:661
void output_typelib_regscript(const typelib_t *typelib)
Definition: register.c:304
size_t output_buffer_pos
Definition: utils.c:253
void add_output_to_resources(const char *type, const char *name)
Definition: utils.c:307
void put_data(const void *data, size_t size)
Definition: utils.c:376
int strendswith(const char *str, const char *end)
Definition: utils.c:238
ULONG_PTR SIZE_T
Definition: typedefs.h:80
char * typelib_name
Definition: widl.c:139
static void sltg_write_nametable(struct sltg_typelib *typelib)
Definition: write_sltg.c:1761
static void sltg_write_remainder(void)
Definition: write_sltg.c:1775
static void sltg_write_header(struct sltg_typelib *sltg, int *library_block_start)
Definition: write_sltg.c:1647
static void sltg_write_helpstrings(struct sltg_typelib *typelib)
Definition: write_sltg.c:1752
static void sltg_write_typeinfo(struct sltg_typelib *typelib)
Definition: write_sltg.c:1733

Referenced by create_sltg_typelib().

◆ sltg_add_typeinfo()

static void sltg_add_typeinfo ( struct sltg_typelib sltg,
void data,
int  size,
const char name 
)
static

Definition at line 485 of file write_sltg.c.

486{
487 struct sltg_block *block = xmalloc(sizeof(*block));
488
489 chat("sltg_add_typeinfo: %p,%d,%s\n", data, size, name);
490
491 block->length = size;
492 block->data = data;
493 block->index_string = 0;
494 block->next = NULL;
495
496 if (sltg->typeinfo)
497 {
498 struct sltg_block *typeinfo = sltg->typeinfo;
499
500 while (typeinfo->next)
501 typeinfo = typeinfo->next;
502
503 typeinfo->next = block;
504 }
505 else
506 sltg->typeinfo = block;
507
508 sltg->typeinfo_count++;
509 sltg->typeinfo_size += size;
510}
struct sltg_block * typeinfo
Definition: write_sltg.c:88
int typeinfo_size
Definition: write_sltg.c:87
int typeinfo_count
Definition: write_sltg.c:86

Referenced by add_typeinfo_block().

◆ sltg_write_header()

static void sltg_write_header ( struct sltg_typelib sltg,
int library_block_start 
)
static

Definition at line 1647 of file write_sltg.c.

1648{
1649 char pad[0x40];
1650 struct sltg_header
1651 {
1652 int magic;
1653 short n_file_blocks;
1654 short res06;
1655 short size_of_index;
1656 short first_blk;
1657 GUID uuid;
1658 int res1c;
1659 int res20;
1660 } header;
1661 struct sltg_block_entry
1662 {
1663 int length;
1664 short index_string;
1665 short next;
1666 } entry;
1667 struct sltg_block *block;
1668 int i;
1669
1670 header.magic = 0x47544c53;
1671 header.n_file_blocks = sltg->n_file_blocks + 1;
1672 header.res06 = 9;
1673 header.size_of_index = sltg->index.size;
1674 header.first_blk = 1;
1676 header.res1c = 0x00000044;
1677 header.res20 = 0xffff0000;
1678
1679 put_data(&header, sizeof(header));
1680
1681 block = sltg->blocks;
1682 for (i = 0; i < sltg->n_file_blocks - 1; i++)
1683 {
1684 assert(block->next != NULL);
1685
1686 entry.length = block->length;
1687 entry.index_string = block->index_string;
1688 entry.next = header.first_blk + i + 1;
1689 chat("sltg_write_header: writing block entry %d: length %#x, index_string %#x, next %#x\n",
1690 i, entry.length, entry.index_string, entry.next);
1691 put_data(&entry, sizeof(entry));
1692
1693 block = block->next;
1694 }
1695
1696 assert(block->next == NULL);
1697
1698 /* library block length includes helpstrings and name table */
1699 entry.length = block->length + 0x40 + 2 + sltg->typeinfo_size + 4 + 6 + 12 + 0x200 + sltg->name_table.size + 12;
1700 entry.index_string = block->index_string;
1701 entry.next = 0;
1702 chat("sltg_write_header: writing library block entry %d: length %#x, index_string %#x, next %#x\n",
1703 i, entry.length, entry.index_string, entry.next);
1704 put_data(&entry, sizeof(entry));
1705
1706 chat("sltg_write_header: writing index: %d bytes\n", sltg->index.size);
1707 put_data(sltg->index.data, sltg->index.size);
1708 memset(pad, 0, 9);
1709 put_data(pad, 9);
1710
1711 block = sltg->blocks;
1712 for (i = 0; i < sltg->n_file_blocks - 1; i++)
1713 {
1714 chat("sltg_write_header: writing block %d: %d bytes\n", i, block->length);
1715
1716 put_data(block->data, block->length);
1717 block = block->next;
1718 }
1719
1720 assert(block->next == NULL);
1721
1722 /* library block */
1723 chat("library_block_start = %#lx\n", (SIZE_T)output_buffer_pos);
1724 *library_block_start = output_buffer_pos;
1725 chat("sltg_write_header: writing library block %d: %d bytes\n", i, block->length);
1726 put_data(block->data, block->length);
1727
1728 chat("sltg_write_header: writing pad 0x40 bytes\n");
1729 memset(pad, 0xff, 0x40);
1730 put_data(pad, 0x40);
1731}
#define assert(x)
Definition: debug.h:53
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
Definition: msctf.idl:550
u32_t magic(void)
static const GUID sltg_library_guid
Definition: write_sltg.c:48

Referenced by save_all_changes().

◆ sltg_write_helpstrings()

static void sltg_write_helpstrings ( struct sltg_typelib typelib)
static

Definition at line 1752 of file write_sltg.c.

1753{
1754 static const char dummy[6];
1755
1756 chat("sltg_write_helpstrings: writing dummy 6 bytes\n");
1757
1758 put_data(dummy, sizeof(dummy));
1759}

Referenced by save_all_changes().

◆ sltg_write_nametable()

static void sltg_write_nametable ( struct sltg_typelib typelib)
static

Definition at line 1761 of file write_sltg.c.

1762{
1763 static const short dummy[6] = { 0xffff,1,2,0xff00,0xffff,0xffff };
1764 char pad[0x200];
1765
1766 chat("sltg_write_nametable: writing 12+0x200+%d bytes\n", typelib->name_table.size);
1767
1768 put_data(dummy, sizeof(dummy));
1769 memset(pad, 0xff, 0x200);
1770 put_data(pad, 0x200);
1771 put_data(&typelib->name_table.size, sizeof(typelib->name_table.size));
1772 put_data(typelib->name_table.data, typelib->name_table.size);
1773}

Referenced by save_all_changes().

◆ sltg_write_remainder()

static void sltg_write_remainder ( void  )
static

Definition at line 1775 of file write_sltg.c.

1776{
1777 static const short dummy1[] = { 1,0xfffe,0x0a03,0,0xffff,0xffff };
1778 static const short dummy2[] = { 0xffff,0xffff,0x0200,0,0,0 };
1779 static const char dummy3[] = { 0xf4,0x39,0xb2,0x71,0,0,0,0,0,0,0,0,0,0,0,0 };
1780 static const char TYPELIB[] = { 8,0,0,0,'T','Y','P','E','L','I','B',0 };
1781 int pad;
1782
1783 pad = 0x01ffff01;
1784 put_data(&pad, sizeof(pad));
1785 pad = 0;
1786 put_data(&pad, sizeof(pad));
1787
1788 put_data(dummy1, sizeof(dummy1));
1789
1791
1792 put_data(TYPELIB, sizeof(TYPELIB));
1793
1794 put_data(dummy2, sizeof(dummy2));
1795 put_data(dummy3, sizeof(dummy3));
1796}

Referenced by save_all_changes().

◆ sltg_write_typeinfo()

static void sltg_write_typeinfo ( struct sltg_typelib typelib)
static

Definition at line 1733 of file write_sltg.c.

1734{
1735 int i;
1736 struct sltg_block *block;
1737 short count = typelib->typeinfo_count;
1738
1739 put_data(&count, sizeof(count));
1740
1741 block = typelib->typeinfo;
1742 for (i = 0; i < typelib->typeinfo_count; i++)
1743 {
1744 chat("sltg_write_typeinfo: writing block %d: %d bytes\n", i, block->length);
1745
1746 put_data(block->data, block->length);
1747 block = block->next;
1748 }
1749 assert(block == NULL);
1750}
GLuint GLuint GLsizei count
Definition: gl.h:1545

Referenced by save_all_changes().

◆ write_hrefmap()

static void write_hrefmap ( struct sltg_data data,
const struct sltg_hrefmap hrefmap 
)
static

Definition at line 641 of file write_sltg.c.

642{
643 struct sltg_hrefinfo hrefinfo;
644 char name[64];
645 int i;
646
647 if (!hrefmap->href_count) return;
648
649 hrefinfo.magic = 0xdf;
650 hrefinfo.res01 = 0;
651 hrefinfo.res02 = -1;
652 hrefinfo.res06 = -1;
653 hrefinfo.res0a = -1;
654 hrefinfo.res0e = -1;
655 hrefinfo.res12 = -1;
656 hrefinfo.res16 = -1;
657 hrefinfo.res1a = -1;
658 hrefinfo.res1e = -1;
659 hrefinfo.res22 = -1;
660 hrefinfo.res26 = -1;
661 hrefinfo.res2a = -1;
662 hrefinfo.res2e = -1;
663 hrefinfo.res32 = -1;
664 hrefinfo.res36 = -1;
665 hrefinfo.res3a = -1;
666 hrefinfo.res3e = -1;
667 hrefinfo.res42 = -1;
668 hrefinfo.number = hrefmap->href_count * 8;
669 hrefinfo.res50 = -1;
670 hrefinfo.res52 = 1;
671 hrefinfo.res53 = 0;
672 hrefinfo.resxx = 0xdf;
673
674 append_data(data, &hrefinfo, offsetof(struct sltg_hrefinfo, res50));
675
676 for (i = 0; i < hrefmap->href_count; i++)
677 append_data(data, "\xff\xff\xff\xff\xff\xff\xff\xff", 8);
678
679 append_data(data, &hrefinfo.res50, 7);
680
681 for (i = 0; i < hrefmap->href_count; i++)
682 {
683 short len;
684
685 sprintf(name, "*\\Rffff*#%x", hrefmap->href[i]);
686 len = strlen(name);
687
688 append_data(data, &len, sizeof(len));
690 }
691
692 append_data(data, &hrefinfo.resxx, sizeof(hrefinfo.resxx));
693}
GLenum GLsizei len
Definition: glext.h:6722
#define offsetof(TYPE, MEMBER)

Referenced by add_interface_typeinfo(), and add_structure_typeinfo().

◆ write_impl_href()

static void write_impl_href ( struct sltg_data data,
short  href 
)
static

Definition at line 1396 of file write_sltg.c.

1397{
1398 struct sltg_impl_info impl_info;
1399
1400 impl_info.res00 = 0x004a;
1401 impl_info.next = -1;
1402 impl_info.res04 = -1;
1403 impl_info.impltypeflags = 0;
1404 impl_info.res07 = 0x80;
1405 impl_info.res08 = 0x0012;
1406 impl_info.ref = href;
1407 impl_info.res0c = 0x4001;
1408 impl_info.res0e = -2; /* 0xfffe */
1409 impl_info.res10 = -1;
1410 impl_info.res12 = 0x001d;
1411 impl_info.pos = 0;
1412
1413 append_data(data, &impl_info, sizeof(impl_info));
1414}

Referenced by add_interface_typeinfo().

◆ write_var_desc()

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 
)
static

Definition at line 802 of file write_sltg.c.

804{
805 short vt, vt_flags, desc_offset;
806
807 chat("write_var_desc: type %p, type->name %s\n",
808 type, type->name ? type->name : "NULL");
809
811 {
812 int num_dims, elements, array_start, size, array_size;
813 type_t *atype;
814 struct
815 {
816 short cDims;
817 short fFeatures;
818 int cbElements;
819 int cLocks;
820 void *pvData;
821 int bound[2];
822 } *array;
823 int *bound;
824 short vt_off[2];
825
826 elements = 1;
827 num_dims = 0;
828
829 atype = type;
830
831 while (is_array(atype) && !type_array_is_decl_as_ptr(atype))
832 {
833 num_dims++;
834 elements *= type_array_get_dim(atype);
835
836 atype = type_array_get_element(atype);
837 }
838
839 chat("write_var_desc: VT_CARRAY: %d dimensions, %d elements\n", num_dims, elements);
840
841 array_start = data->size;
842
843 size = sizeof(*array) + (num_dims - 1) * 8 /* sizeof(SAFEARRAYBOUND) */;
844 array = xmalloc(size);
845
846 array->cDims = num_dims;
847 array->fFeatures = 0x0004; /* FADF_EMBEDDED */
848 array->cbElements = get_element_size(atype);
849 array->cLocks = 0;
850 array->pvData = NULL;
851
852 bound = array->bound;
853
854 array_size = array->cbElements;
855 atype = type;
856
857 while (is_array(atype) && !type_array_is_decl_as_ptr(atype))
858 {
859 bound[0] = type_array_get_dim(atype);
860 array_size *= bound[0];
861 bound[1] = 0;
862 bound += 2;
863
864 atype = type_array_get_element(atype);
865 }
866
867 if (size_instance)
868 {
869 *size_instance += array_size;
870 size_instance = NULL; /* don't account for element size */
871 }
872
874
875 desc_offset = data->size;
876
877 vt_off[0] = VT_CARRAY;
878 vt_off[1] = array_start + base_offset;
879 append_data(data, vt_off, sizeof(vt_off));
880
881 /* fall through to write array element description */
882 type = atype;
883 }
884 else
885 desc_offset = data->size;
886
888
889 if (vt == VT_PTR)
890 {
892
893 if (is_ptr(ref))
894 {
895 chat("write_var_desc: vt VT_PTR | 0x0400 | %04x\n", param_flags);
896 vt = VT_PTR | 0x0400 | param_flags;
897 append_data(data, &vt, sizeof(vt));
898 write_var_desc(typelib, data, ref, 0, 0, base_offset, size_instance, hrefmap);
899 }
900 else
901 write_var_desc(typelib, data, ref, param_flags, 0x0e00, base_offset, size_instance, hrefmap);
902 return desc_offset;
903 }
904
905 chat("write_var_desc: vt %d, flags %04x\n", vt, flags);
906
907 vt_flags = vt | flags | param_flags;
908 append_data(data, &vt_flags, sizeof(vt_flags));
909
910 if (vt == VT_USERDEFINED)
911 {
912 short href;
913
914 while (type->typelib_idx < 0 && type_is_alias(type))
916
917 chat("write_var_desc: VT_USERDEFINED, type %p, name %s, real type %d, href %d\n",
918 type, type->name, type_get_type(type), type->typelib_idx);
919
920 if (type->typelib_idx == -1)
921 {
922 chat("write_var_desc: trying to ref not added type\n");
923
924 switch (type_get_type(type))
925 {
926 case TYPE_STRUCT:
928 break;
929 case TYPE_INTERFACE:
931 break;
932 case TYPE_ENUM:
934 break;
935 case TYPE_UNION:
937 break;
938 case TYPE_COCLASS:
940 break;
941 default:
942 error("write_var_desc: VT_USERDEFINED - unhandled type %d\n",
944 }
945 }
946
947 if (type->typelib_idx == -1)
948 error("write_var_desc: trying to ref not added type\n");
949
950 href = local_href(hrefmap, type->typelib_idx);
951 chat("write_var_desc: VT_USERDEFINED, local href %d\n", href);
952
953 append_data(data, &href, sizeof(href));
954 }
955
956 if (size_instance)
957 *size_instance += get_element_size(type);
958
959 return desc_offset;
960}
@ VT_CARRAY
Definition: compat.h:2322
static int is_ptr(const type_t *t)
Definition: header.h:59
static int is_array(const type_t *t)
Definition: header.h:64
static LONG cLocks
Definition: compobj.c:119
static UINT array_size
Definition: msctf.c:67
Definition: send.c:48
static int type_array_is_decl_as_ptr(const type_t *type)
Definition: typetree.h:260
static type_t * type_alias_get_aliasee(const type_t *type)
Definition: typetree.h:279
static int type_is_alias(const type_t *type)
Definition: typetree.h:274
static type_t * type_array_get_element(const type_t *type)
Definition: typetree.h:253
static unsigned int type_array_get_dim(const type_t *type)
Definition: typetree.h:232
static type_t * type_pointer_get_ref(const type_t *type)
Definition: typetree.h:292
_In_ ULONG _In_opt_ PVOID pvData
Definition: winddi.h:3749
static int get_element_size(type_t *type)
Definition: write_sltg.c:710

Referenced by add_func_desc(), add_structure_typeinfo(), and write_var_desc().

Variable Documentation

◆ sltg_library_guid

const GUID sltg_library_guid = { 0x204ff,0,0,{ 0xc0,0,0,0,0,0,0,0x46 } }
static

Definition at line 48 of file write_sltg.c.

Referenced by sltg_write_header(), and sltg_write_remainder().