Re: [Spice-devel] [PATCH spice-common 2/7] codegen: Add a test for attribute combination
On Wed, Feb 20, 2019 at 12:53:12PM -0500, Frediano Ziglio wrote: > > On Mon, Feb 18, 2019 at 04:01:24PM +, Frediano Ziglio wrote: > > > Does not make sense to specify the same field to have 2 > > > different C implementation at the same time. > > > > > > Signed-off-by: Frediano Ziglio > > > --- > > > python_modules/ptypes.py | 7 +++ > > > 1 file changed, 7 insertions(+) > > > > > > diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py > > > index 3875970..e5fb1e9 100644 > > > --- a/python_modules/ptypes.py > > > +++ b/python_modules/ptypes.py > > > @@ -96,6 +96,13 @@ def fix_attributes(attribute_list): > > > elif len(lst) > 1: > > > raise Exception("Attribute %s has more than 1 argument" % > > > name) > > > attrs[name] = lst > > > + > > > +# these attributes specify output format, only one can be set > > > +output_attrs = set(['end', 'to_ptr', 'as_ptr', 'ptr_array', 'zero']) > > > +output_attrs = [a for a in attrs.keys() if a in output_attrs] > > > > > > output_attrs = set(['end', 'to_ptr', 'as_ptr', 'ptr_array', 'zero']) > > if len(output_attrs.intersection(attrs.keys())) > 1: > > > > seems to work equally well, and is in my opinion easier to read. > > > > Christophe > > > > Yes. Ack with that change? Sure. Acked-by: Christophe Fergeau Christophe > > > > > > +if len(output_attrs) > 1: > > > +raise Exception("Multiple output type attributes specified %s" % > > > output_attrs) > > > + > > > return attrs > > > > > > class Type: > > Frediano signature.asc Description: PGP signature ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [PATCH spice-common 2/7] codegen: Add a test for attribute combination
> On Mon, Feb 18, 2019 at 04:01:24PM +, Frediano Ziglio wrote: > > Does not make sense to specify the same field to have 2 > > different C implementation at the same time. > > > > Signed-off-by: Frediano Ziglio > > --- > > python_modules/ptypes.py | 7 +++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py > > index 3875970..e5fb1e9 100644 > > --- a/python_modules/ptypes.py > > +++ b/python_modules/ptypes.py > > @@ -96,6 +96,13 @@ def fix_attributes(attribute_list): > > elif len(lst) > 1: > > raise Exception("Attribute %s has more than 1 argument" % > > name) > > attrs[name] = lst > > + > > +# these attributes specify output format, only one can be set > > +output_attrs = set(['end', 'to_ptr', 'as_ptr', 'ptr_array', 'zero']) > > +output_attrs = [a for a in attrs.keys() if a in output_attrs] > > > output_attrs = set(['end', 'to_ptr', 'as_ptr', 'ptr_array', 'zero']) > if len(output_attrs.intersection(attrs.keys())) > 1: > > seems to work equally well, and is in my opinion easier to read. > > Christophe > Yes. Ack with that change? > > > +if len(output_attrs) > 1: > > +raise Exception("Multiple output type attributes specified %s" % > > output_attrs) > > + > > return attrs > > > > class Type: Frediano ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/spice-devel
Re: [Spice-devel] [PATCH spice-common 2/7] codegen: Add a test for attribute combination
On Mon, Feb 18, 2019 at 04:01:24PM +, Frediano Ziglio wrote: > Does not make sense to specify the same field to have 2 > different C implementation at the same time. > > Signed-off-by: Frediano Ziglio > --- > python_modules/ptypes.py | 7 +++ > 1 file changed, 7 insertions(+) > > diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py > index 3875970..e5fb1e9 100644 > --- a/python_modules/ptypes.py > +++ b/python_modules/ptypes.py > @@ -96,6 +96,13 @@ def fix_attributes(attribute_list): > elif len(lst) > 1: > raise Exception("Attribute %s has more than 1 argument" % name) > attrs[name] = lst > + > +# these attributes specify output format, only one can be set > +output_attrs = set(['end', 'to_ptr', 'as_ptr', 'ptr_array', 'zero']) > +output_attrs = [a for a in attrs.keys() if a in output_attrs] output_attrs = set(['end', 'to_ptr', 'as_ptr', 'ptr_array', 'zero']) if len(output_attrs.intersection(attrs.keys())) > 1: seems to work equally well, and is in my opinion easier to read. Christophe > +if len(output_attrs) > 1: > +raise Exception("Multiple output type attributes specified %s" % > output_attrs) > + > return attrs > > class Type: > -- > 2.20.1 > > ___ > Spice-devel mailing list > Spice-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/spice-devel signature.asc Description: PGP signature ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/spice-devel
[Spice-devel] [PATCH spice-common 2/7] codegen: Add a test for attribute combination
Does not make sense to specify the same field to have 2 different C implementation at the same time. Signed-off-by: Frediano Ziglio --- python_modules/ptypes.py | 7 +++ 1 file changed, 7 insertions(+) diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py index 3875970..e5fb1e9 100644 --- a/python_modules/ptypes.py +++ b/python_modules/ptypes.py @@ -96,6 +96,13 @@ def fix_attributes(attribute_list): elif len(lst) > 1: raise Exception("Attribute %s has more than 1 argument" % name) attrs[name] = lst + +# these attributes specify output format, only one can be set +output_attrs = set(['end', 'to_ptr', 'as_ptr', 'ptr_array', 'zero']) +output_attrs = [a for a in attrs.keys() if a in output_attrs] +if len(output_attrs) > 1: +raise Exception("Multiple output type attributes specified %s" % output_attrs) + return attrs class Type: -- 2.20.1 ___ Spice-devel mailing list Spice-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/spice-devel