Commit d33a553d authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

Add support for typedefs.

parent 69bdc10a
......@@ -732,12 +732,14 @@ type: tVOID { $$ = make_tref(NULL, make_type(0, NULL)); }
| tUNION aIDENTIFIER { $$ = make_tref(NULL, find_type2($2, tsUNION)); }
;
typedef: tTYPEDEF m_attributes type pident_list { typeref_t *tref = uniq_tref($3);
typedef: tTYPEDEF m_attributes type pident_list { typeref_t *tref = uniq_tref($3);
$4->tname = tref->name;
tref->name = NULL;
$$ = type_ref(tref);
$$->attrs = $2;
if (!parse_only && do_header) write_typedef($$, $4);
if (in_typelib && $$->attrs)
add_typedef($$, $4);
reg_types($$, $4, 0);
}
;
......
......@@ -148,6 +148,8 @@ unsigned short get_type_vt(type_t *t)
case RPC_FC_PSTRUCT:
return VT_USERDEFINED;
case 0:
if(t->attrs)
return VT_USERDEFINED;
return 0;
default:
error("get_type_vt: unknown-type: %d\n", t->type);
......@@ -264,3 +266,18 @@ void add_enum(type_t *enumeration)
LINK(entry, typelib->entry);
typelib->entry = entry;
}
void add_typedef(type_t *tdef, var_t *name)
{
typelib_entry_t *entry;
if (!typelib) return;
entry = xmalloc(sizeof(*entry));
entry->kind = TKIND_ALIAS;
entry->u.tdef = xmalloc(sizeof(*entry->u.tdef));
memcpy(entry->u.tdef, name, sizeof(*name));
entry->u.tdef->type = tdef;
entry->u.tdef->name = xstrdup(name->name);
LINK(entry, typelib->entry);
typelib->entry = entry;
}
......@@ -29,6 +29,7 @@ extern void add_coclass(class_t *cls);
extern void add_module(type_t *module);
extern void add_struct(type_t *structure);
extern void add_enum(type_t *enumeration);
extern void add_typedef(type_t *tdef, var_t *name);
/* Copied from wtypes.h. Not included directly because that would create a
* circular dependency (after all, wtypes.h is generated by widl...) */
......
......@@ -242,6 +242,7 @@ struct _typelib_entry_t {
type_t *module;
type_t *structure;
type_t *enumeration;
var_t *tdef;
} u;
DECL_LINK(typelib_entry_t)
};
......
......@@ -884,6 +884,8 @@ static int encode_type(
case RPC_FC_IP:
add_interface_typeinfo(typelib, type);
break;
case 0:
error("encode_type: VT_USERDEFINED - can't yet add typedef's on the fly\n");
default:
error("encode_type: VT_USERDEFINED - unhandled type %d\n", type->type);
}
......@@ -934,7 +936,7 @@ static int encode_type(
static void dump_type(type_t *t)
{
chat("dump_type: %p name %s type %d ref %p rname %s\n", t, t->name, t->type, t->ref, t->rname);
chat("dump_type: %p name %s type %d ref %p rname %s attrs %p\n", t, t->name, t->type, t->ref, t->rname, t->attrs);
if(t->ref) dump_type(t->ref);
}
......@@ -1616,6 +1618,9 @@ static msft_typeinfo_t *create_msft_typeinfo(msft_typelib_t *typelib, enum type_
case ATTR_ODL:
break;
case ATTR_PUBLIC:
break;
case ATTR_RESTRICTED:
typeinfo->flags |= 0x200; /* TYPEFLAG_FRESTRICTED */
break;
......@@ -1685,6 +1690,7 @@ static void add_dispinterface_typeinfo(msft_typelib_t *typelib, type_t *dispinte
var_t *var;
msft_typeinfo_t *msft_typeinfo;
dispinterface->typelib_idx = typelib->typelib_header.nrtypeinfos;
msft_typeinfo = create_msft_typeinfo(typelib, TKIND_DISPATCH, dispinterface->name,
dispinterface->attrs, typelib->typelib_header.nrtypeinfos);
......@@ -1813,6 +1819,24 @@ static void add_enum_typeinfo(msft_typelib_t *typelib, type_t *enumeration)
}
}
static void add_typedef_typeinfo(msft_typelib_t *typelib, var_t *tdef)
{
msft_typeinfo_t *msft_typeinfo;
int alignment;
attr_t *attrs;
tdef->type->typelib_idx = typelib->typelib_header.nrtypeinfos;
msft_typeinfo = create_msft_typeinfo(typelib, TKIND_ALIAS, tdef->name, tdef->type->attrs,
typelib->typelib_header.nrtypeinfos);
attrs = tdef->type->attrs;
tdef->type->attrs = NULL;
encode_var(typelib, tdef, &msft_typeinfo->typeinfo->datatype1, &msft_typeinfo->typeinfo->size,
&alignment, &msft_typeinfo->typeinfo->datatype2);
tdef->type->attrs = attrs;
msft_typeinfo->typeinfo->typekind |= (alignment << 11 | alignment << 6);
}
static void add_entry(msft_typelib_t *typelib, typelib_entry_t *entry)
{
switch(entry->kind) {
......@@ -1828,6 +1852,10 @@ static void add_entry(msft_typelib_t *typelib, typelib_entry_t *entry)
add_enum_typeinfo(typelib, entry->u.enumeration);
break;
case TKIND_ALIAS:
add_typedef_typeinfo(typelib, entry->u.tdef);
break;
default:
error("add_entry: unhandled type %d\n", entry->kind);
break;
......
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