Store interfaces, structs, coclasses and modules that are to be

written into a typelib in a list.
This commit is contained in:
Huw Davies 2005-01-05 17:12:25 +00:00 committed by Alexandre Julliard
parent 5e4ac6bc1b
commit 86fead3c25
4 changed files with 97 additions and 29 deletions

View File

@ -713,7 +713,9 @@ structdef: tSTRUCT t_ident '{' fields '}' { $$ = get_typev(RPC_FC_STRUCT, $2, ts
$$->type = get_struct_type( $4 );
$$->fields = $4;
$$->defined = TRUE;
}
if(in_typelib)
add_struct($$);
}
;
type: tVOID { $$ = make_tref(NULL, make_type(0, NULL)); }

View File

@ -35,7 +35,6 @@
#include "typelib.h"
int in_typelib = 0;
static FILE* typelib;
/* Copied from wtypes.h. Not included directly because that would create a
* circular dependency (after all, wtypes.h is generated by widl...) */
@ -91,6 +90,7 @@ enum VARENUM {
VT_ILLEGALMASKED = 0xfff,
VT_TYPEMASK = 0xfff
};
static typelib_t *typelib;
/* List of oleauto types that should be recognized by name.
* (most of) these seem to be intrinsic types in mktyplib. */
@ -217,52 +217,84 @@ unsigned short get_var_vt(var_t *v)
void start_typelib(char *name, attr_t *attrs)
{
in_typelib++;
if (!do_everything && !typelib_only) return;
if(!(typelib = fopen(typelib_name, "wb")))
error("Could not open %s for output\n", typelib_name);
in_typelib++;
if (!do_everything && !typelib_only) return;
typelib = xmalloc(sizeof(*typelib));
typelib->name = xstrdup(name);
typelib->filename = xstrdup(typelib_name);
typelib->attrs = attrs;
}
void end_typelib(void)
{
if (typelib) fclose(typelib);
in_typelib--;
in_typelib--;
if (!typelib) return;
/* create_msft_typelib(typelib);*/
return;
}
void add_interface(type_t *iface)
{
if (!typelib) return;
typelib_entry_t *entry;
if (!typelib) return;
/* FIXME: add interface and dependent types to typelib */
printf("add interface: %s\n", iface->name);
chat("add interface: %s\n", iface->name);
entry = xmalloc(sizeof(*entry));
entry->kind = TKIND_INTERFACE;
entry->u.interface = iface;
LINK(entry, typelib->entry);
typelib->entry = entry;
}
void add_coclass(class_t *cls)
{
ifref_t *lcur = cls->ifaces;
ifref_t *cur;
ifref_t *lcur = cls->ifaces;
ifref_t *cur;
typelib_entry_t *entry;
if (lcur) {
while (NEXT_LINK(lcur)) lcur = NEXT_LINK(lcur);
}
if (lcur) {
while (NEXT_LINK(lcur)) lcur = NEXT_LINK(lcur);
}
if (!typelib) return;
if (!typelib) return;
/* install interfaces the coclass depends on */
cur = lcur;
while (cur) {
add_interface(cur->iface);
cur = PREV_LINK(cur);
}
/* FIXME: add coclass to typelib */
printf("add coclass: %s\n", cls->name);
/* install interfaces the coclass depends on */
cur = lcur;
while (cur) {
add_interface(cur->iface);
cur = PREV_LINK(cur);
}
entry = xmalloc(sizeof(*entry));
entry->kind = TKIND_COCLASS;
entry->u.class = cls;
LINK(entry, typelib->entry);
typelib->entry = entry;
}
void add_module(type_t *module)
{
if (!typelib) return;
typelib_entry_t *entry;
if (!typelib) return;
/* FIXME: add module to typelib */
printf("add module: %s\n", module->name);
chat("add module: %s\n", module->name);
entry = xmalloc(sizeof(*entry));
entry->kind = TKIND_MODULE;
entry->u.module = module;
LINK(entry, typelib->entry);
typelib->entry = entry;
}
void add_struct(type_t *structure)
{
typelib_entry_t *entry;
if (!typelib) return;
chat("add struct: %s\n", structure->name);
entry = xmalloc(sizeof(*entry));
entry->kind = TKIND_RECORD;
entry->u.structure = structure;
LINK(entry, typelib->entry);
typelib->entry = entry;
}

View File

@ -27,5 +27,6 @@ extern void end_typelib(void);
extern void add_interface(type_t *iface);
extern void add_coclass(class_t *cls);
extern void add_module(type_t *module);
extern void add_struct(type_t *structure);
#endif

View File

@ -45,6 +45,8 @@ typedef struct _var_t var_t;
typedef struct _func_t func_t;
typedef struct _ifref_t ifref_t;
typedef struct _class_t class_t;
typedef struct _typelib_entry_t typelib_entry_t;
typedef struct _typelib_t typelib_t;
#define DECL_LINK(type) \
type *l_next; \
@ -126,6 +128,19 @@ enum expr_type
EXPR_COND,
};
enum type_kind
{
TKIND_ENUM = 0,
TKIND_RECORD,
TKIND_MODULE,
TKIND_INTERFACE,
TKIND_DISPATCH,
TKIND_COCLASS,
TKIND_ALIAS,
TKIND_UNION,
TKIND_MAX
};
struct _attr_t {
enum attr_type type;
union {
@ -214,4 +229,22 @@ struct _class_t {
DECL_LINK(class_t)
};
struct _typelib_entry_t {
enum type_kind kind;
union {
class_t *class;
type_t *interface;
type_t *module;
type_t *structure;
} u;
DECL_LINK(typelib_entry_t)
};
struct _typelib_t {
char *name;
char *filename;
attr_t *attrs;
typelib_entry_t *entry;
};
#endif