summaryrefslogtreecommitdiff
path: root/python_modules/ptypes.py
AgeCommit message (Collapse)AuthorFilesLines
2018-10-15codegen: Remove minor attributeFrediano Ziglio1-52/+0
The idea in version 1 of the protocol was to extend it using the minor version. However this was replaced by the usage of capabilities and the minor attribute (which was not much used in version 1) was abandoned in version 2. This patch create a big difference in the code generated but only because the minor version was passed between all possible functions as argument. Note that exported functions retain the minor argument for compatibility reasons. The demarshaller code export directly spice_get_client_channel_parser or spice_get_server_channel_parser functions which returns internal module functions which parse message of specific channels. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-10-15codegen: Remove fixedsize attributeFrediano Ziglio1-6/+0
This attribute was used only in SPICE version 1. The intention was use fixed size for switch type in the protocol. However this does not bring any improvement, just increase network bytes used. Generated code does not change. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-10-15codegen: Remove bytes_count attributeFrediano Ziglio1-4/+0
This attribute was used only in SPICE version 1. Its usage was confusing, and was replaced by the simple usage of array size. Generated code does not change. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-06-27ptypes: Improve some attribute documentationFrediano Ziglio1-2/+7
Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-05-23Check for messages with duplicate values inside a channelFrediano Ziglio1-0/+8
Make sure there are not 2 messages with the same value in the same channel. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-05-23Check for messages with duplicate names inside a channelFrediano Ziglio1-0/+2
Make sure there are not 2 messages with the same name in the same channel. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2018-05-23codegen: Remove duplicate client and server code from ChannelType::resolveFrediano Ziglio1-39/+29
Code that handled client and server messages check was the same, just changed some variable names. Instead use a class to store same information and reuse the code. This allows easier extension of the 2 path of code. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Lukáš Hrázký <lhrazky@redhat.com>
2018-05-09codegen: Removed unused get_type methodsFrediano Ziglio1-9/+0
Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Lukáš Hrázký <lhrazky@redhat.com>
2018-05-09codegen: Add some commentsFrediano Ziglio1-1/+5
Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Lukáš Hrázký <lhrazky@redhat.com>
2018-04-17Remove extra self parameter from member functionJonathon Jongsma1-1/+1
When testing out some experimental protocol changes, I managed to trigger the following error: GEN generated_client_demarshallers.c Traceback (most recent call last): File "../../../spice-common/spice_codegen.py", line 267, in <module> demarshal.write_protocol_parser(writer, proto, True) File "/home/jjongsma/work/spice/spice-common/python_modules/demarshal.py", line 1270, in write_protocol_parser parsers[channel.value] = (channel.channel_type, write_channel_parser(writer, channel.channel_type, is_server)) File "/home/jjongsma/work/spice/spice-common/python_modules/demarshal.py", line 1163, in write_channel_parser func = write_msg_parser(helpers, ids[i].message_type) File "/home/jjongsma/work/spice/spice-common/python_modules/demarshal.py", line 1061, in write_msg_parser num_pointers = message.get_num_pointers() File "/home/jjongsma/work/spice/spice-common/python_modules/ptypes.py", line 855, in get_num_pointers count = count + m.get_num_pointers() File "/home/jjongsma/work/spice/spice-common/python_modules/ptypes.py", line 662, in get_num_pointers return self.member_type.get_num_pointers() File "/home/jjongsma/work/spice/spice-common/python_modules/ptypes.py", line 507, in get_num_pointers if self.is_constant_length(self): TypeError: is_constant_length() takes exactly 1 argument (2 given) Calling a member function will implicitly pass 'self' as the first argument, but we were also explicitly passing it as an argument (self.is_constant_length(self)). This resulted in the above error. Acked-by: Lukáš Hrázký <lhrazky@redhat.com>
2016-06-24codegen: Fix 'registred' typoChristophe Fergeau1-3/+3
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-06-21extend a comment for type attributesFrediano Ziglio1-1/+1
Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-06-21add a check for negate cases on enumerationsFrediano Ziglio1-0/+1
Not supported by code so trigger an error to avoid invalid usages Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-06-02fix wrong assert checkFrediano Ziglio1-1/+1
The assert were never triggered as always True Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-03-10codegen: simplify FdTypeMarc-André Lureau1-4/+4
This patch is a left-over from the fd passing commit 267391c8fd as suggested by Frediano Ziglio during review. Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com> Acked-by: Frediano Ziglio <fziglio@redhat.com> (cherry picked from spice-protocol commit 47076559628d71c128e14e11147ce36b92677885) Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2016-03-10protocol: learn to describe fd passing in messagesMarc-Andre Lureau1-0/+9
Add a new type, "unix_fd", used to describe file descriptor sharing via socket ancillary data (these messages are local only). The marshaller/demarshaller can't serialize this in memory (consume_fd implementation is empty), so it is the responsability of the marshaller user to handle sending and receiving the handles, which are appended at the end of the message with an extra stream byte (because some Unix requires sending at least a byte with ancillary data). Even if there is no fd to send (or if the fd is invalid etc), the receiver side expects an extra byte anyway. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com> (cherry-picked from spice-protocol commit 267391c8fd7c90c067b3e4845ff0227a2580e2e2) Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2016-03-10Revert "Remove files moved to spice-protocol"Marc-André Lureau1-0/+1129
This reverts commit 7665dcf1bb2fa0b16b3d0015b28d7f5912664c3f. Also revert the related build-sys changes to fix the build. codegen generated code depends on spice-common code (marshaller, messages etc), it makes more sense to keep the generator along this. Otherwise a newer protocol release will fail to build older projects. *.proto files are required as well, since it generates code that parent modules depend on unconditionnaly. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2015-08-11Remove files moved to spice-protocolFrediano Ziglio1-1129/+0
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2015-08-04codegen: ptypes.py: keep attribute names in setsUri Lublin1-4/+4
This patch changes the type of 'valid_attributes' and 'attributes_with_arguments'. Both of them are list of different strings and are kept in sets. This was the intention of the original code, but this patch use a specific set([ strings ]) format, instead of { strings }. This fixes the build for me on RHEL-6 (python-2.6.6). Build error is: File "/home/ulublin/git/spice/spice-common/python_modules/ptypes.py", line 67 'end', ^ SyntaxError: invalid syntax
2015-07-23codegen: Remove old ptr32 attributeFrediano Ziglio1-4/+0
This attribute is not used in code. Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2015-07-23codegen: Do some checks on attributesFrediano Ziglio1-0/+72
Verify that the attribute is known. This could help for instance to avoid some future typo mistakes. We also now have a list of attributes that we can comment for documentation purpose. Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2015-07-23codegen: Reuse code to fix attribute from prototype fileFrediano Ziglio1-16/+16
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2015-04-01Make spice_codegen.py work on both Python 2 and 3Alexander Wauck1-33/+33
This is a new version of my previous patch that does not include six.py. It's still kind of big, but at least it's all spice-common changes now. There are also a few other fixes that Christophe brought to my attention. Note that six now needs to be installed on the system (python-six on Fedora and Debian, six on PyPI). This *should* be enough to make spice_codegen.py work on both Python 2 and Python 3. The major changes are as follows: * cStringIO.StringIO -> io.StringIO * str vs. unicode updates (io.StringIO doesn't like str) * integer division * foo.has_key(bar) -> bar in foo * import internal_thing -> from . import internal_thing * removed from __future__ import with_statement (might break Python 2.5?) * changed some lambdas to list comprehensions (done by 2to3) * cast some_dict.keys() to list where needed (e.g. for sorting) * use normal type names with isinstance instead of types.WhateverType Signed-off-by: Alexander Wauck <awauck@codeweavers.com>
2013-10-23codegen: Add a --generate-wireshark-dissector optionJonathon Jongsma1-0/+17
The wireshark protocol dissector is a bit out-of-date. Several new channel types and enums have been added. It would be nice if these values (and the translation between the value and the name) could be automatically generated so that updating the dissector was a slightly less manual process. This patch adds a commandline switch which generates both the enums and value-name lists in the format that wireshark expects.
2012-06-14python_modules/ptypes.py/EnumBaseType.c_enumname: add missing return to fix ↵Alon Levy1-1/+1
broken enums generation Fixes the resulting enums.h from the invocation of: ./spice_codegen.py --generate-enums spice.proto spice-protocol/spice/enums.h Right now any enum will contain None as the enum members, with this fix it will contain the real enum members, i.e. SPICE_FOO.
2012-03-20allow attributes on channel elements in .proto filesChristophe Fergeau1-1/+3
We want to be able to add an @ifdef annotation to optional messages For example, we want to compile in the smartcard messages only if libcacard is available
2012-03-20fix copy & paste error in ptypes.pyChristophe Fergeau1-3/+1
2012-03-20codegen: Fix enums.h generationHans de Goede1-1/+3
With the new usbredir code we have the new concept of the abstract / generic spicevmc channel type (which just tunnels data from a qemu chardev), and we've the usbredir channel, which is the only current user of this. This was reflected in the protocols enum in spice-protocol.h by a manual edit done by me, my bad. This patch teaches spice.proto about the relation between the abstract spicevmc channel and the usbredir channel and modifies codegen to deal with this. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2012-03-20python: remove c-ism trailing ;Marc-André Lureau1-3/+3
2012-03-20codegen: typedef the protocol enumsMarc-André Lureau1-4/+12
Commit 9d5ef9beeca722b2ceff7d15aaa3aaaaf07ecfbf in spice-protocol introduced a typedef manually in the generated enums.h header. This patch adds them automatically to all enums during enums.h generation.
2012-03-20spice codegen: fix copy-o, no such variable valueAlon Levy1-1/+1
2012-03-20Don't send CursorHeader if cursor_flags is NONEAlexander Larsson1-2/+2
2012-03-20codegen: Allow @to_ptr to make inline structs demarshal as pointersAlexander Larsson1-1/+3
2012-03-20codegen: Remove unused methos has_pointer()Alexander Larsson1-27/+0
2012-03-20codegen: No SPICE_ADDRESS types left, drop @c_ptrAlexander Larsson1-2/+5
2012-03-20Properly parse QXLImage to the new-world SpiceImageGerd Hoffmann1-7/+24
SpiceImage now replaces RedImage and has all image types in it. All image data are now chunked (and as such not copied when demarshalling).
2012-03-20codegen: support @chunk on non-pointer arraysAlexander Larsson1-2/+2
This is similar to @as_ptr, but generates a single chunk of data.
2012-03-20marshaller: Make get_nw_offset() handle deep member referencesAlexander Larsson1-7/+32
2012-03-20marshaller: Make @nonnull a propagated attributeAlexander Larsson1-1/+1
This cleans up some stuff
2012-03-20marshaller: Make @c_ptr a propagated attributeAlexander Larsson1-1/+1
This simplifies some code
2012-03-20marshaller: Add generic way to handle propagating attributesAlexander Larsson1-4/+11
Also switches @ptr_array to use this
2012-03-20Properly parse and marshall SpiceStringGerd Hoffmann1-1/+7
2012-03-20Simplify SpiceLineAttr by removing unsed stuffAlexander Larsson1-1/+14
Also in new protocol don't send style data if not needed.
2012-03-20Support @marshall to automatically marshall pointersAlexander Larsson1-13/+16
2012-03-20Make pointers 32bit in new protocol formatAlexander Larsson1-1/+3
2012-03-20marshaller: Correctly determine if switches are fixed sizeAlexander Larsson1-1/+9
Switches are fixed size only if all cases have the same size *and* it has a default case or all the valid cases are listed.
2012-03-20Fix handling of @ptr32 network sizeAlexander Larsson1-4/+10
2012-03-20Add support for @virtual markup in spice protocolAlexander Larsson1-0/+4
This means the member is not sent on the network at all. Instead its initialized to the attribute argument when demarshalled. This is useful for backwards compatibility support.
2012-03-20Initial import of spice protocol description and demarshall generatorAlexander Larsson1-0/+965
The "spice.proto" file describes in detail the networking prototcol that spice uses and spice_codegen.py can parse this and generate demarshallers for such network messages.