ReactOS 0.4.16-dev-1946-g52006dd
write_sltg.c File Reference
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <ctype.h>
#include <time.h>
#include "widl.h"
#include "windef.h"
#include "winbase.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
 

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_data *name_table, const char *name)
 
static void init_name_table (struct sltg_data *name_table)
 
static void init_library (struct sltg_typelib *sltg)
 
static void add_block_index (struct sltg_typelib *sltg, void *data, int length, 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 length, 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, short kind)
 
static void init_typeinfo (struct sltg_typeinfo_header *ti, const type_t *type, short kind, const struct sltg_hrefmap *hrefmap)
 
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 void init_sltg_tail (struct sltg_tail *tail)
 
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 } }
 

Function Documentation

◆ add_block()

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

Definition at line 391 of file write_sltg.c.

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}
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:79
Definition: name.c:39
struct sltg_data index
Definition: write_sltg.c:92
static void add_block_index(struct sltg_typelib *sltg, void *data, int length, int index)
Definition: write_sltg.c:382
static int add_index(struct sltg_data *index, const char *name)
Definition: write_sltg.c:260
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  length,
int  index 
)
static

Definition at line 382 of file write_sltg.c.

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}
void * xrealloc(void *oldmem, size_t size)
Definition: uimain.c:736
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
struct sltg_block * blocks
Definition: write_sltg.c:95
int block_count
Definition: write_sltg.c:96

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 1522 of file write_sltg.c.

1523{
1524 error("add_coclass_typeinfo: %s not implemented\n", type->name);
1525}
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 1512 of file write_sltg.c.

1513{
1514 error("add_enum_typeinfo: %s not implemented\n", type->name);
1515}

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 1187 of file write_sltg.c.

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}
@ optional
Definition: SystemMenu.c:34
coclass MediaStreamFilter helpstring("Stream Class")
#define NULL
Definition: types.h:112
unsigned int idx
Definition: utils.c:41
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
size_t const old_size
Definition: expand.cpp:65
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
__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:65
short helpcontext
Definition: write_sltg.c:212
short funcflags
Definition: write_sltg.c:221
static type_t * type_function_get_rettype(const type_t *type)
Definition: typetree.h:158
static var_list_t * type_function_get_args(const type_t *type)
Definition: typetree.h:139
unsigned int pointer_size
Definition: widl.c:147
@ ATTR_OPTIONAL
Definition: widltypes.h:150
void * arg
Definition: msvc.h:10
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 int add_name(struct sltg_data *name_table, const char *name)
Definition: write_sltg.c:288
static void append_data(struct sltg_data *block, const void *data, int size)
Definition: write_sltg.c:482
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 int get_func_flags(const var_t *func, int *dispid, int *invokekind, int *helpcontext, const char **helpstring)
Definition: write_sltg.c:1065

Referenced by add_interface_typeinfo().

◆ add_index()

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

Definition at line 260 of file write_sltg.c.

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}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
size_t const new_size
Definition: expand.cpp:66
strcpy
Definition: string.h:131
#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 1370 of file write_sltg.c.

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}
struct outqueuenode * tail
Definition: adnsresfilter.c:66
int is_attr(const attr_list_t *list, enum attr_type attr_type)
Definition: attribute.c:45
var_t * var
Definition: widltypes.h:631
union _statement_t::@5358 u
int typelib_idx
Definition: widltypes.h:529
const char * name
Definition: widltypes.h:500
static type_t * type_iface_get_inherit(const type_t *type)
Definition: typetree.h:208
static statement_list_t * type_iface_get_stmts(const type_t *type)
Definition: typetree.h:201
@ TKIND_INTERFACE
Definition: widltypes.h:237
@ ATTR_DISPINTERFACE
Definition: widltypes.h:103
#define STATEMENTS_FOR_EACH_FUNC(stmt, stmts)
Definition: widltypes.h:684
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 void write_hrefmap(struct sltg_data *data, const struct sltg_hrefmap *hrefmap)
Definition: write_sltg.c:581
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 int local_href(struct sltg_hrefmap *hrefmap, int typelib_href)
Definition: write_sltg.c:701
static void add_block(struct sltg_typelib *sltg, void *data, int size, const char *name)
Definition: write_sltg.c:391
static void add_interface_typeinfo(struct sltg_typelib *typelib, type_t *type)
Definition: write_sltg.c:1370
static void write_impl_href(struct sltg_data *data, short href)
Definition: write_sltg.c:1350
static const char * add_typeinfo_block(struct sltg_typelib *typelib, const type_t *type, short kind)
Definition: write_sltg.c:501

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 496 of file write_sltg.c.

497{
498 error("add_module_typeinfo: %s not implemented\n", type->name);
499}

Referenced by add_statement().

◆ add_name()

static int add_name ( struct sltg_data name_table,
const char name 
)
static

Definition at line 288 of file write_sltg.c.

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}
#define memset(x, y, z)
Definition: compat.h:39
char * data
Definition: write_sltg.c:66
int allocated
Definition: write_sltg.c:65

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 1557 of file write_sltg.c.

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}
statement_type_t type
Definition: parser.h:124
typeref_list_t * type_list
Definition: widltypes.h:633
Definition: send.c:48
@ 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
static void add_module_typeinfo(struct sltg_typelib *typelib, type_t *type)
Definition: write_sltg.c:496
static void add_type_typeinfo(struct sltg_typelib *typelib, type_t *type)
Definition: write_sltg.c:1527

Referenced by create_sltg_typelib().

◆ add_structure_typeinfo()

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

Definition at line 923 of file write_sltg.c.

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}
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:132
@ TKIND_RECORD
Definition: widltypes.h:235

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 1527 of file write_sltg.c.

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}
static enum type_type type_get_type(const type_t *type)
Definition: typetree.h:113
@ 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
static void add_coclass_typeinfo(struct sltg_typelib *typelib, type_t *type)
Definition: write_sltg.c:1522
static void add_structure_typeinfo(struct sltg_typelib *typelib, type_t *type)
Definition: write_sltg.c:923
static void add_union_typeinfo(struct sltg_typelib *typelib, type_t *type)
Definition: write_sltg.c:1517
static void add_enum_typeinfo(struct sltg_typelib *typelib, type_t *type)
Definition: write_sltg.c:1512

Referenced by add_statement().

◆ add_typeinfo_block()

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

Definition at line 501 of file write_sltg.c.

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}
GUID guid
Definition: version.c:147
GLuint GLfloat * val
Definition: glext.h:7180
GLfloat GLfloat p
Definition: glext.h:8902
void * get_attrp(const attr_list_t *list, enum attr_type attr_type)
Definition: attribute.c:87
Definition: query.h:86
@ ATTR_UUID
Definition: widltypes.h:182
@ ATTR_HELPCONTEXT
Definition: widltypes.h:119
static void sltg_add_typeinfo(struct sltg_typelib *sltg, void *data, int length, const char *name)
Definition: write_sltg.c:470
static const char * new_index_name(void)
Definition: write_sltg.c:450

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 1517 of file write_sltg.c.

1518{
1519 error("add_union_typeinfo: %s not implemented\n", type->name);
1520}

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 482 of file write_sltg.c.

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}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by add_func_desc(), add_interface_typeinfo(), add_structure_typeinfo(), add_typeinfo_block(), 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 403 of file write_sltg.c.

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}

Referenced by create_sltg_typelib().

◆ create_sltg_typelib()

int create_sltg_typelib ( typelib_t typelib)

Definition at line 1777 of file write_sltg.c.

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);
1798 init_name_table(&sltg.name_table);
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}
typelib_t * typelib
Definition: write_sltg.c:91
static void init_index(struct sltg_data *index)
Definition: write_sltg.c:279
static void init_name_table(struct sltg_data *name_table)
Definition: write_sltg.c:316
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 save_all_changes(struct sltg_typelib *typelib)
Definition: write_sltg.c:1743
static void add_statement(struct sltg_typelib *typelib, const statement_t *stmt)
Definition: write_sltg.c:1557

Referenced by write_typelib_regscript().

◆ dump_var_desc()

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

Definition at line 619 of file write_sltg.c.

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}
#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:94
#define DEBUGLEVEL_CHAT
Definition: widl.h:31
#define DEBUGLEVEL_TRACE
Definition: widl.h:33

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 1044 of file write_sltg.c.

1045{
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}
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 634 of file write_sltg.c.

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}
@ 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:91
unsigned short get_type_vt(type_t *t)
Definition: typelib.c:124

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 1065 of file write_sltg.c.

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}
GLbitfield flags
Definition: glext.h:7161
#define ATTR_HIDDEN
Definition: mkdosfs.c:367
union expr::@560 u
@ ATTR_PROPPUT
Definition: widltypes.h:159
@ ATTR_DEFAULTBIND
Definition: widltypes.h:97
@ ATTR_PROPPUTREF
Definition: widltypes.h:160
@ ATTR_IMMEDIATEBIND
Definition: widltypes.h:129
@ ATTR_DEFAULTCOLLELEM
Definition: widltypes.h:98
@ ATTR_REQUESTEDIT
Definition: widltypes.h:167
@ ATTR_UIDEFAULT
Definition: widltypes.h:179
@ ATTR_DISPLAYBIND
Definition: widltypes.h:104
@ ATTR_PROPGET
Definition: widltypes.h:158
@ ATTR_BINDABLE
Definition: widltypes.h:81
@ ATTR_RESTRICTED
Definition: widltypes.h:168
@ ATTR_ID
Definition: widltypes.h:125
@ ATTR_HELPSTRING
Definition: widltypes.h:121
@ ATTR_NONBROWSABLE
Definition: widltypes.h:141
@ ATTR_SOURCE
Definition: widltypes.h:171
@ ATTR_USESGETLASTERROR
Definition: widltypes.h:181

Referenced by add_func_desc().

◆ get_param_flags()

static int get_param_flags ( const var_t param)
static

Definition at line 1146 of file write_sltg.c.

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}
GLuint in
Definition: glext.h:9616
GLfloat param
Definition: glext.h:5796
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
@ ATTR_IN
Definition: widltypes.h:131
@ ATTR_RETVAL
Definition: widltypes.h:169
@ ATTR_OUT
Definition: widltypes.h:151
@ ATTR_PARAMLCID
Definition: widltypes.h:153

Referenced by add_func_desc().

◆ init_index()

static void init_index ( struct sltg_data index)
static

Definition at line 279 of file write_sltg.c.

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

Referenced by create_sltg_typelib().

◆ init_library()

static void init_library ( struct sltg_typelib sltg)
static

Definition at line 321 of file write_sltg.c.

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}
const attr_list_t * attrs
Definition: widltypes.h:611
char * name
Definition: widltypes.h:610
struct sltg_library library
Definition: write_sltg.c:94
struct sltg_data name_table
Definition: write_sltg.c:93
@ SYS_WIN32
Definition: widltypes.h:647
@ SYS_WIN64
Definition: widltypes.h:649
@ ATTR_HELPFILE
Definition: widltypes.h:120
@ ATTR_VERSION
Definition: widltypes.h:185
@ ATTR_CONTROL
Definition: widltypes.h:92
@ ATTR_LIBLCID
Definition: widltypes.h:134

Referenced by create_sltg_typelib().

◆ init_name_table()

static void init_name_table ( struct sltg_data name_table)
static

Definition at line 316 of file write_sltg.c.

317{
318 init_sltg_data(name_table);
319}

Referenced by create_sltg_typelib().

◆ init_sltg_data()

static void init_sltg_data ( struct sltg_data data)
static

Definition at line 253 of file write_sltg.c.

254{
255 data->size = 0;
256 data->allocated = 0;
257 data->data = NULL;
258}

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

◆ init_sltg_tail()

static void init_sltg_tail ( struct sltg_tail tail)
static

Definition at line 892 of file write_sltg.c.

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}

Referenced by add_interface_typeinfo(), and add_structure_typeinfo().

◆ init_typeinfo()

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

Definition at line 547 of file write_sltg.c.

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}
unsigned int get_attrv(const attr_list_t *list, enum attr_type attr_type)
Definition: attribute.c:78
struct sltg_typeinfo_header::@5359 misc
#define snprintf
Definition: wintirpc.h:48

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 701 of file write_sltg.c.

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}

Referenced by add_interface_typeinfo(), and write_var_desc().

◆ new_index_name()

static const char * new_index_name ( void  )
static

Definition at line 450 of file write_sltg.c.

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}

Referenced by add_typeinfo_block().

◆ save_all_changes()

static void save_all_changes ( struct sltg_typelib typelib)
static

Definition at line 1743 of file write_sltg.c.

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}
static HRESULT flush_output_buffer(mxwriter *This)
Definition: mxwriter.c:661
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 output_typelib_regscript(const typelib_t *typelib)
Definition: register.c:334
void add_output_to_resources(const char *type, const char *name)
Definition: utils.c:192
char * typelib_name
Definition: widl.c:122
static void sltg_write_nametable(struct sltg_typelib *typelib)
Definition: write_sltg.c:1706
static void sltg_write_remainder(void)
Definition: write_sltg.c:1720
static void sltg_write_header(struct sltg_typelib *sltg, int *library_block_start)
Definition: write_sltg.c:1605
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

Referenced by create_sltg_typelib().

◆ sltg_add_typeinfo()

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

Definition at line 470 of file write_sltg.c.

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}
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

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 1605 of file write_sltg.c.

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}
Definition: msctf.idl:532
static const GUID sltg_library_guid
Definition: write_sltg.c:61

Referenced by save_all_changes().

◆ sltg_write_helpstrings()

static void sltg_write_helpstrings ( struct sltg_typelib typelib)
static

Definition at line 1697 of file write_sltg.c.

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}

Referenced by save_all_changes().

◆ sltg_write_nametable()

static void sltg_write_nametable ( struct sltg_typelib typelib)
static

Definition at line 1706 of file write_sltg.c.

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}

Referenced by save_all_changes().

◆ sltg_write_remainder()

static void sltg_write_remainder ( void  )
static

Definition at line 1720 of file write_sltg.c.

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}

Referenced by save_all_changes().

◆ sltg_write_typeinfo()

static void sltg_write_typeinfo ( struct sltg_typelib typelib)
static

Definition at line 1684 of file write_sltg.c.

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}

Referenced by save_all_changes().

◆ write_hrefmap()

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

Definition at line 581 of file write_sltg.c.

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}
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 1350 of file write_sltg.c.

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}

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 732 of file write_sltg.c.

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}
@ VT_CARRAY
Definition: compat.h:2322
static LONG cLocks
Definition: compobj.c:119
static UINT array_size
Definition: msctf.cpp:39
_In_ LPWSTR _In_ DWORD _In_ LPCVOID pvData
Definition: netsh.h:116
static int is_ptr(const type_t *t)
Definition: header.h:55
static int is_array(const type_t *t)
Definition: header.h:60
static int type_array_is_decl_as_ptr(const type_t *type)
Definition: typetree.h:350
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 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 unsigned int type_array_get_dim(const type_t *type)
Definition: typetree.h:303
static int get_element_size(type_t *type)
Definition: write_sltg.c:634

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 61 of file write_sltg.c.

Referenced by sltg_write_header(), and sltg_write_remainder().