Commit 28a2c06c authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

widl: Use type_get_type to determine the types of types during typelib generation.

parent 0f7f7922
......@@ -109,17 +109,20 @@ static unsigned short builtin_vt(const type_t *t)
}
if (is_string_type (t->attrs, t))
{
unsigned char fc;
const type_t *elem_type;
if (is_array(t))
fc = type_array_get_element(t)->type;
elem_type = type_array_get_element(t);
else
fc = type_pointer_get_ref(t)->type;
switch (fc)
elem_type = type_pointer_get_ref(t);
if (type_get_type(elem_type) == TYPE_BASIC)
{
switch (type_basic_get_fc(elem_type))
{
case RPC_FC_CHAR: return VT_LPSTR;
case RPC_FC_WCHAR: return VT_LPWSTR;
default: break;
}
}
}
return 0;
}
......@@ -143,74 +146,76 @@ unsigned short get_type_vt(type_t *t)
if (type_is_alias(t) && is_attr(t->attrs, ATTR_PUBLIC))
return VT_USERDEFINED;
switch (t->type) {
case RPC_FC_BYTE:
case RPC_FC_USMALL:
return VT_UI1;
case RPC_FC_CHAR:
case RPC_FC_SMALL:
return VT_I1;
case RPC_FC_WCHAR:
return VT_I2; /* mktyplib seems to parse wchar_t as short */
case RPC_FC_SHORT:
return VT_I2;
case RPC_FC_USHORT:
return VT_UI2;
case RPC_FC_LONG:
if (match(t->name, "int")) return VT_INT;
return VT_I4;
case RPC_FC_ULONG:
if (match(t->name, "int")) return VT_UINT;
return VT_UI4;
case RPC_FC_HYPER:
if (t->sign < 0) return VT_UI8;
if (match(t->name, "MIDL_uhyper")) return VT_UI8;
return VT_I8;
case RPC_FC_FLOAT:
return VT_R4;
case RPC_FC_DOUBLE:
return VT_R8;
case RPC_FC_RP:
case RPC_FC_UP:
case RPC_FC_OP:
case RPC_FC_FP:
case RPC_FC_SMFARRAY:
case RPC_FC_LGFARRAY:
case RPC_FC_SMVARRAY:
case RPC_FC_LGVARRAY:
case RPC_FC_CARRAY:
case RPC_FC_CVARRAY:
case RPC_FC_BOGUS_ARRAY:
if(t->ref)
{
if (match(t->ref->name, "SAFEARRAY"))
return VT_SAFEARRAY;
return VT_PTR;
switch (type_get_type(t)) {
case TYPE_BASIC:
switch (type_basic_get_fc(t)) {
case RPC_FC_BYTE:
case RPC_FC_USMALL:
return VT_UI1;
case RPC_FC_CHAR:
case RPC_FC_SMALL:
return VT_I1;
case RPC_FC_WCHAR:
return VT_I2; /* mktyplib seems to parse wchar_t as short */
case RPC_FC_SHORT:
return VT_I2;
case RPC_FC_USHORT:
return VT_UI2;
case RPC_FC_LONG:
if (match(t->name, "int")) return VT_INT;
return VT_I4;
case RPC_FC_ULONG:
if (match(t->name, "int")) return VT_UINT;
return VT_UI4;
case RPC_FC_HYPER:
if (t->sign < 0) return VT_UI8;
if (match(t->name, "MIDL_uhyper")) return VT_UI8;
return VT_I8;
case RPC_FC_FLOAT:
return VT_R4;
case RPC_FC_DOUBLE:
return VT_R8;
default:
error("get_type_vt: unknown basic type: 0x%02x\n", type_basic_get_fc(t));
}
error("get_type_vt: unknown-deref-type: %d\n", t->ref->type);
break;
case RPC_FC_IP:
case TYPE_POINTER:
if (match(type_pointer_get_ref(t)->name, "SAFEARRAY"))
return VT_SAFEARRAY;
return VT_PTR;
case TYPE_ARRAY:
if (t->declarray)
error("get_type_vt: array types not supported\n");
return VT_PTR;
case TYPE_INTERFACE:
if(match(t->name, "IUnknown"))
return VT_UNKNOWN;
if(match(t->name, "IDispatch"))
return VT_DISPATCH;
return VT_USERDEFINED;
case RPC_FC_ENUM16:
case RPC_FC_STRUCT:
case RPC_FC_PSTRUCT:
case RPC_FC_CSTRUCT:
case RPC_FC_CPSTRUCT:
case RPC_FC_CVSTRUCT:
case RPC_FC_BOGUS_STRUCT:
case RPC_FC_COCLASS:
case RPC_FC_MODULE:
case TYPE_ENUM:
case TYPE_STRUCT:
case TYPE_COCLASS:
case TYPE_MODULE:
case TYPE_UNION:
case TYPE_ENCAPSULATED_UNION:
return VT_USERDEFINED;
case 0:
case TYPE_VOID:
return VT_VOID;
default:
error("get_type_vt: unknown type: 0x%02x\n", t->type);
case TYPE_ALIAS:
/* aliases should be filtered out by the type_get_type call above */
assert(0);
break;
case TYPE_FUNCTION:
error("get_type_vt: functions not supported\n");
break;
}
return 0;
}
......
......@@ -983,34 +983,27 @@ static int encode_type(
while (type->typelib_idx < 0 && type_is_alias(type) && !is_attr(type->attrs, ATTR_PUBLIC))
type = type_alias_get_aliasee(type);
chat("encode_type: VT_USERDEFINED - type %p name = %s type->type %d idx %d\n", type,
type->name, type->type, type->typelib_idx);
chat("encode_type: VT_USERDEFINED - type %p name = %s real type %d idx %d\n", type,
type->name, type_get_type(type), type->typelib_idx);
if(type->typelib_idx == -1) {
chat("encode_type: trying to ref not added type\n");
switch(type->type) {
case RPC_FC_STRUCT:
case RPC_FC_PSTRUCT:
case RPC_FC_CSTRUCT:
case RPC_FC_CPSTRUCT:
case RPC_FC_CVSTRUCT:
case RPC_FC_BOGUS_STRUCT:
switch (type_get_type(type)) {
case TYPE_STRUCT:
add_structure_typeinfo(typelib, type);
break;
case RPC_FC_IP:
case TYPE_INTERFACE:
add_interface_typeinfo(typelib, type);
break;
case RPC_FC_ENUM16:
case TYPE_ENUM:
add_enum_typeinfo(typelib, type);
break;
case RPC_FC_COCLASS:
case TYPE_COCLASS:
add_coclass_typeinfo(typelib, type);
break;
case 0:
error("encode_type: VT_USERDEFINED - can't yet add typedef's on the fly\n");
break;
default:
error("encode_type: VT_USERDEFINED - unhandled type %d\n", type->type);
error("encode_type: VT_USERDEFINED - unhandled type %d\n",
type_get_type(type));
}
}
......@@ -1047,7 +1040,7 @@ static int encode_type(
static void dump_type(type_t *t)
{
chat("dump_type: %p name %s type %d ref %p attrs %p\n", t, t->name, t->type, t->ref, t->attrs);
chat("dump_type: %p name %s type %d ref %p attrs %p\n", t, t->name, type_get_type(t), t->ref, t->attrs);
if(t->ref) dump_type(t->ref);
}
......@@ -1482,7 +1475,7 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, var_t *func, int index)
{
int vt;
expr_t *expr = (expr_t *)attr->u.pval;
if (arg->type->type == RPC_FC_ENUM16)
if (type_get_type(arg->type) == TYPE_ENUM)
vt = VT_INT;
else
vt = get_type_vt(arg->type);
......@@ -2211,42 +2204,25 @@ static void add_module_typeinfo(msft_typelib_t *typelib, type_t *module)
static void add_type_typeinfo(msft_typelib_t *typelib, type_t *type)
{
switch (type->type) {
case RPC_FC_IP:
switch (type_get_type(type)) {
case TYPE_INTERFACE:
add_interface_typeinfo(typelib, type);
break;
case RPC_FC_STRUCT:
case TYPE_STRUCT:
add_structure_typeinfo(typelib, type);
break;
case RPC_FC_ENUM16:
case RPC_FC_ENUM32:
case TYPE_ENUM:
add_enum_typeinfo(typelib, type);
break;
case RPC_FC_COCLASS:
case TYPE_COCLASS:
add_coclass_typeinfo(typelib, type);
break;
case RPC_FC_BYTE:
case RPC_FC_CHAR:
case RPC_FC_USMALL:
case RPC_FC_SMALL:
case RPC_FC_WCHAR:
case RPC_FC_USHORT:
case RPC_FC_SHORT:
case RPC_FC_ULONG:
case RPC_FC_LONG:
case RPC_FC_HYPER:
case RPC_FC_IGNORE:
case RPC_FC_FLOAT:
case RPC_FC_DOUBLE:
case RPC_FC_ERROR_STATUS_T:
case RPC_FC_BIND_PRIMITIVE:
case RPC_FC_RP:
case RPC_FC_UP:
case RPC_FC_OP:
case RPC_FC_FP:
case TYPE_BASIC:
case TYPE_POINTER:
break;
default:
error("add_entry: unhandled type 0x%x for %s\n", type->type, type->name);
error("add_entry: unhandled type 0x%x for %s\n",
type_get_type(type), type->name);
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