Commit 1ea7eac3 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Vitaly Lipatov

widl: Create library block index right after the CompObj one.

Otherwise Wine's oleaut32 refuses to load a typelib.
parent 39e339b2
......@@ -374,15 +374,13 @@ static void init_library(struct sltg_typelib *sltg)
}
}
static void add_block(struct sltg_typelib *sltg, void *data, int size, const char *name)
static void add_block_index(struct sltg_typelib *sltg, void *data, int size, int index)
{
struct sltg_block *block = xmalloc(sizeof(*block));
chat("add_block: %p,%d,\"%s\"\n", data, size, name);
block->length = size;
block->data = data;
block->index_string = add_index(&sltg->index, name);
block->index_string = index;
block->next = NULL;
if (sltg->blocks)
......@@ -400,17 +398,28 @@ static void add_block(struct sltg_typelib *sltg, void *data, int size, const cha
sltg->n_file_blocks++;
}
static void add_library_block(struct sltg_typelib *typelib)
static void add_block(struct sltg_typelib *sltg, void *data, int size, const char *name)
{
struct sltg_block *block = xmalloc(sizeof(*block));
int index;
chat("add_block: %p,%d,\"%s\"\n", data, size, name);
index = add_index(&sltg->index, name);
add_block_index(sltg, data, size, index);
}
static void *create_library_block(struct sltg_typelib *typelib, int *size, int *index)
{
void *block;
short *p;
int size;
size = sizeof(short) * 9 + sizeof(int) * 3 + sizeof(GUID);
if (typelib->library.helpstring) size += strlen(typelib->library.helpstring);
if (typelib->library.helpfile) size += strlen(typelib->library.helpfile);
*size = sizeof(short) * 9 + sizeof(int) * 3 + sizeof(GUID);
if (typelib->library.helpstring) *size += strlen(typelib->library.helpstring);
if (typelib->library.helpfile) *size += strlen(typelib->library.helpfile);
block = xmalloc(size);
block = xmalloc(*size);
p = block;
*p++ = 0x51cc; /* magic */
*p++ = 3; /* res02 */
......@@ -443,7 +452,9 @@ static void add_library_block(struct sltg_typelib *typelib)
p += 2;
*(GUID *)p = typelib->library.uuid;
add_block(typelib, block, size, "dir");
*index = add_index(&typelib->index, "dir");
return block;
}
static const char *new_index_name(void)
......@@ -1767,6 +1778,8 @@ int create_sltg_typelib(typelib_t *typelib)
{
struct sltg_typelib sltg;
const statement_t *stmt;
void *library_block;
int library_block_size, library_block_index;
sltg.typelib = typelib;
sltg.typeinfo_count = 0;
......@@ -1780,11 +1793,13 @@ int create_sltg_typelib(typelib_t *typelib)
init_name_table(&sltg);
init_library(&sltg);
library_block = create_library_block(&sltg, &library_block_size, &library_block_index);
if (typelib->stmts)
LIST_FOR_EACH_ENTRY(stmt, typelib->stmts, const statement_t, entry)
add_statement(&sltg, stmt);
add_library_block(&sltg);
add_block_index(&sltg, library_block, library_block_size, library_block_index);
save_all_changes(&sltg);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment