[Spice-devel] [PATCH v6 01/42] Supports ifdef attribute on enumerations

Christophe Fergeau cfergeau at redhat.com
Fri Aug 14 04:02:04 PDT 2015


Hey,

Ah, this adds some #ifdef to the enums.h file. I was hoping we could
totally omit them from the output of the generator ;) Should do, but
then the @ifdef should be SPICE_DISSECTOR, not a non-namespaced
DISSECTOR.

Christophe

On Thu, Aug 13, 2015 at 02:11:40PM +0100, Frediano Ziglio wrote:
> This allows to exclude some enumaration for different
> purposes.
> For instance one could use some enumerations only on
> marshaller to avoid clash with some other demarshaller
> defines.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  python_modules/ptypes.py | 2 --
>  spice_codegen.py         | 6 ++++++
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
> index 7ab2771..c1eb756 100644
> --- a/python_modules/ptypes.py
> +++ b/python_modules/ptypes.py
> @@ -390,7 +390,6 @@ class EnumType(EnumBaseType):
>          writer.write(self.c_name())
>          writer.write(";")
>          writer.newline()
> -        writer.newline()
>  
>  class FlagsType(EnumBaseType):
>      def __init__(self, bits, name, flags, attribute_list):
> @@ -444,7 +443,6 @@ class FlagsType(EnumBaseType):
>          writer.write(self.c_name())
>          writer.write(";")
>          writer.newline()
> -        writer.newline()
>  
>  class ArrayType(Type):
>      def __init__(self, element_type, size):
> diff --git a/spice_codegen.py b/spice_codegen.py
> index 569cccc..2f3dbff 100755
> --- a/spice_codegen.py
> +++ b/spice_codegen.py
> @@ -85,9 +85,15 @@ def write_enums(writer, describe=False):
>      # Define enums
>      for t in ptypes.get_named_types():
>          if isinstance(t, ptypes.EnumBaseType):
> +            if t.has_attr("ifdef"):
> +                writer.ifdef(t.attributes["ifdef"][0])
>              t.c_define(writer)
>              if describe:
> +                writer.newline()
>                  t.c_describe(writer)
> +            if t.has_attr("ifdef"):
> +                writer.endif(t.attributes["ifdef"][0])
> +            writer.newline()
>  
>      write_channel_type_enum(writer)
>      if (describe):
> -- 
> 2.4.3
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20150814/2270c49f/attachment.sig>


More information about the Spice-devel mailing list