[Spice-devel] [spice-common 3/3] codegen: Autogenerate client_marshallers.h
Christophe Fergeau
cfergeau at redhat.com
Tue Jun 21 11:36:15 UTC 2016
On Tue, Jun 21, 2016 at 07:22:34AM -0400, Frediano Ziglio wrote:
> > On Tue, Jun 21, 2016 at 05:15:54AM -0400, Frediano Ziglio wrote:
> > > About the macro, what about
> > >
> > >
> > > diff --git a/python_modules/marshal.py b/python_modules/marshal.py
> > > index cd4b4fa..c2235e2 100644
> > > --- a/python_modules/marshal.py
> > > +++ b/python_modules/marshal.py
> > > @@ -1,13 +1,20 @@
> > >
> > > from . import ptypes
> > > from . import codegen
> > > +import re
> > >
> > > def write_includes(writer):
> > > writer.header.writeln("#include <spice/protocol.h>")
> > > writer.header.writeln('#include "common/marshaller.h"')
> > > writer.header.newline()
> > > - writer.header.writeln("#ifndef _GENERATED_HEADERS_H")
> > > - writer.header.writeln("#define _GENERATED_HEADERS_H")
> > > + if writer.header.has_option("dest_file"):
> > > + src = writer.header.options["dest_file"]
> > > + else:
> > > + src = "generated_headers.h"
> > > + src = re.sub(r'[^a-z0-9]+', '_', 'file_' + src, flags=re.IGNORECASE)
> > > + src = src.upper()
> > > + writer.header.writeln("#ifndef %s" % src)
> > > + writer.header.writeln("#define %s" % src)
> >
> > Looks good to me, I'd probably squash this in:
> >
> > --- a/python_modules/marshal.py
> > +++ b/python_modules/marshal.py
> > @@ -11,8 +11,10 @@ def write_includes(writer):
> > src = writer.header.options["dest_file"]
> > else:
> > src = "generated_headers.h"
> > - src = re.sub(r'[^a-z0-9]+', '_', 'file_' + src, flags=re.IGNORECASE)
> > + src = re.sub(r'[^a-z0-9]+', '_', src, flags=re.IGNORECASE)
> > src = src.upper()
> > + if src.endswith("_H"):
> > + src = "_H_"+src[:-2]
>
> This is not C99 compatible
I knew you would answer that, but this is the form which is used in most
spice-common headers (and in gnulib too apparently), so I'd just assume
this is not going to be an issue.
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20160621/e8a41347/attachment-0001.sig>
More information about the Spice-devel
mailing list