From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbP4F-0004fc-Iu for qemu-devel@nongnu.org; Fri, 27 Mar 2015 03:52:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YbP4C-00085t-RK for qemu-devel@nongnu.org; Fri, 27 Mar 2015 03:52:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51699) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbP4C-00085p-Ir for qemu-devel@nongnu.org; Fri, 27 Mar 2015 03:52:32 -0400 From: Markus Armbruster References: <1427227433-5030-1-git-send-email-eblake@redhat.com> <1427227433-5030-17-git-send-email-eblake@redhat.com> Date: Fri, 27 Mar 2015 08:52:27 +0100 In-Reply-To: <1427227433-5030-17-git-send-email-eblake@redhat.com> (Eric Blake's message of "Tue, 24 Mar 2015 14:03:41 -0600") Message-ID: <87wq22ubb8.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v5 16/28] qapi: Better error messages for duplicated expressions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: kwolf@redhat.com, lcapitulino@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, wenchaoqemu@gmail.com One more... Eric Blake writes: [...] > diff --git a/scripts/qapi.py b/scripts/qapi.py > index 90eb3bc..5d0dc91 100644 > --- a/scripts/qapi.py > +++ b/scripts/qapi.py [...] > @@ -560,12 +585,22 @@ def type_name(name): > return c_list_type(name[0]) > return name > > -enum_types = [] > -struct_types = [] > -union_types = [] > +def add_name(name, info, meta, implicit = False): > + global all_names > + if name in all_names: > + raise QAPIExprError(info, > + "%s '%s' is already defined" > + %(all_names[name], name)) We say "struct 'Foo'", and expect the user to know that 'struct' means 'complex type'. It'll do, it's just a development tool. I'm not really happy with 'complex type', though. Isn't a union type complex, too? Anyway, we can clean up our confused terminology later; this series is long enough. > + if not implicit and name[-4:] == 'Kind': > + raise QAPIExprError(info, > + "%s '%s' should not end in 'Kind'" > + %(meta, name)) > + all_names[name] = meta > > -def add_struct(definition): > +def add_struct(definition, info): > global struct_types > + name = definition['type'] > + add_name(name, info, 'struct') > struct_types.append(definition) > > def find_struct(name): [...]