From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEhOW-0001ps-FH for qemu-devel@nongnu.org; Thu, 20 Sep 2012 10:06:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TEhOQ-0000wK-Tx for qemu-devel@nongnu.org; Thu, 20 Sep 2012 10:06:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45091) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEhOQ-0000ul-K5 for qemu-devel@nongnu.org; Thu, 20 Sep 2012 10:06:14 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8KE6DRS001014 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 20 Sep 2012 10:06:14 -0400 Date: Thu, 20 Sep 2012 11:07:04 -0300 From: Luiz Capitulino Message-ID: <20120920110704.7cceb260@doriath.home> In-Reply-To: <1348065078-5139-4-git-send-email-pbonzini@redhat.com> References: <1348065078-5139-1-git-send-email-pbonzini@redhat.com> <1348065078-5139-4-git-send-email-pbonzini@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 03/12] qapi: do not protect enum values from namespace pollution List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org On Wed, 19 Sep 2012 16:31:06 +0200 Paolo Bonzini wrote: > Enum values are always preceded by the uppercase name of the enum, so > they do not conflict with reserved words. > > Signed-off-by: Paolo Bonzini Cherry-picked into qmp branch, thanks. > --- > scripts/qapi-types.py | 4 ++-- > scripts/qapi-visit.py | 2 +- > scripts/qapi.py | 8 ++++---- > 3 file modificati, 7 inserzioni(+), 7 rimozioni(-) > > diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py > index 49ef569..1b84834 100644 > --- a/scripts/qapi-types.py > +++ b/scripts/qapi-types.py > @@ -91,9 +91,9 @@ const char *%(name)s_lookup[] = { > > def generate_enum_name(name): > if name.isupper(): > - return c_fun(name) > + return c_fun(name, False) > new_name = '' > - for c in c_fun(name): > + for c in c_fun(name, False): > if c.isupper(): > new_name += '_' > new_name += c > diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py > index e2093e8..a360de7 100644 > --- a/scripts/qapi-visit.py > +++ b/scripts/qapi-visit.py > @@ -173,7 +173,7 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error ** > break; > ''', > abbrev = de_camel_case(name).upper(), > - enum = c_fun(de_camel_case(key)).upper(), > + enum = c_fun(de_camel_case(key),False).upper(), > c_type=members[key], > c_name=c_fun(key)) > > diff --git a/scripts/qapi.py b/scripts/qapi.py > index 122b4cb..057332e 100644 > --- a/scripts/qapi.py > +++ b/scripts/qapi.py > @@ -141,7 +141,7 @@ def camel_case(name): > new_name += ch.lower() > return new_name > > -def c_var(name): > +def c_var(name, protect=True): > # ANSI X3J11/88-090, 3.1.1 > c89_words = set(['auto', 'break', 'case', 'char', 'const', 'continue', > 'default', 'do', 'double', 'else', 'enum', 'extern', 'float', > @@ -156,12 +156,12 @@ def c_var(name): > # GCC http://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/C-Extensions.html > # excluding _.* > gcc_words = set(['asm', 'typeof']) > - if name in c89_words | c99_words | c11_words | gcc_words: > + if protect and (name in c89_words | c99_words | c11_words | gcc_words): > return "q_" + name > return name.replace('-', '_').lstrip("*") > > -def c_fun(name): > - return c_var(name).replace('.', '_') > +def c_fun(name, protect=True): > + return c_var(name, protect).replace('.', '_') > > def c_list_type(name): > return '%sList' % name