From 55a00aae2900cec493b06d6a434809f053d76fe5 Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Sun, 30 Jun 2013 19:42:32 +0200 Subject: widl: Require interfaces to inherit from another interface unless explicitly exempted. --- tools/widl/typetree.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c index a9e71be..de373a2 100644 --- a/tools/widl/typetree.c +++ b/tools/widl/typetree.c @@ -352,6 +352,14 @@ type_t *type_new_bitfield(type_t *field, const expr_t *bits) return t; } +static int is_root_interface(type_t *iface) +{ + if (!strcmp(iface->name, "IUnknown")) return TRUE; + if (!strcmp(iface->name, "ID3DInclude")) return TRUE; + if (!strcmp(iface->name, "nsISupports")) return TRUE; + return FALSE; +} + static int compute_method_indexes(type_t *iface) { int idx; @@ -377,11 +385,15 @@ static int compute_method_indexes(type_t *iface) void type_interface_define(type_t *iface, type_t *inherit, statement_list_t *stmts) { + const attr_t *attr; iface->details.iface = xmalloc(sizeof(*iface->details.iface)); iface->details.iface->disp_props = NULL; iface->details.iface->disp_methods = NULL; iface->details.iface->stmts = stmts; iface->details.iface->inherit = inherit; + if (iface->attrs) LIST_FOR_EACH_ENTRY( attr, iface->attrs, const attr_t, entry ) + if (attr->type == ATTR_OBJECT && !inherit && !is_root_interface(iface)) + error_loc("object interface must inherit from another object interface\n"); iface->defined = TRUE; compute_method_indexes(iface); } -- 1.8.1.5