widl: prelude to typelib generation
Huw D M Davies
h.davies1 at physics.ox.ac.uk
Wed Jan 5 05:52:56 CST 2005
Huw Davies <huw at codeweavers.com>
Store interfaces, structs, coclasses and modules that are to
be written into a typelib in a list.
--
Huw Davies
huw at codeweavers.com
Index: tools/widl/parser.y
===================================================================
RCS file: /home/wine/wine/tools/widl/parser.y,v
retrieving revision 1.28
diff -u -p -r1.28 parser.y
--- tools/widl/parser.y 4 Jan 2005 20:34:05 -0000 1.28
+++ tools/widl/parser.y 5 Jan 2005 11:49:55 -0000
@@ -713,7 +713,9 @@ structdef: tSTRUCT t_ident '{' fields '}
$$->type = get_struct_type( $4 );
$$->fields = $4;
$$->defined = TRUE;
- }
+ if(in_typelib)
+ add_struct($$);
+ }
;
type: tVOID { $$ = make_tref(NULL, make_type(0, NULL)); }
Index: tools/widl/typelib.c
===================================================================
RCS file: /home/wine/wine/tools/widl/typelib.c,v
retrieving revision 1.3
diff -u -p -r1.3 typelib.c
--- tools/widl/typelib.c 6 Dec 2004 20:43:55 -0000 1.3
+++ tools/widl/typelib.c 5 Jan 2005 11:49:55 -0000
@@ -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;
-
- if (lcur) {
- while (NEXT_LINK(lcur)) lcur = NEXT_LINK(lcur);
- }
+ ifref_t *lcur = cls->ifaces;
+ ifref_t *cur;
+ typelib_entry_t *entry;
- if (!typelib) return;
+ if (lcur) {
+ while (NEXT_LINK(lcur)) lcur = NEXT_LINK(lcur);
+ }
- /* install interfaces the coclass depends on */
- cur = lcur;
- while (cur) {
- add_interface(cur->iface);
- cur = PREV_LINK(cur);
- }
+ if (!typelib) return;
- /* 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;
+
+ 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;
- /* FIXME: add module to typelib */
- printf("add module: %s\n", module->name);
+ 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;
}
Index: tools/widl/typelib.h
===================================================================
RCS file: /home/wine/wine/tools/widl/typelib.h,v
retrieving revision 1.1
diff -u -p -r1.1 typelib.h
--- tools/widl/typelib.h 7 Jan 2004 04:21:27 -0000 1.1
+++ tools/widl/typelib.h 5 Jan 2005 11:49:55 -0000
@@ -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
Index: tools/widl/widltypes.h
===================================================================
RCS file: /home/wine/wine/tools/widl/widltypes.h,v
retrieving revision 1.18
diff -u -p -r1.18 widltypes.h
--- tools/widl/widltypes.h 3 Jan 2005 14:26:17 -0000 1.18
+++ tools/widl/widltypes.h 5 Jan 2005 11:49:55 -0000
@@ -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 {
@@ -212,6 +227,24 @@ struct _class_t {
/* parser-internal */
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
More information about the wine-patches
mailing list