summaryrefslogtreecommitdiffstats
path: root/python_modules
Commit message (Collapse)AuthorAgeFilesLines
* Remove codegenMarc-André Lureau2016-03-107-3390/+0
| | | | | | | | Codegen generates code specific to spice-common submodule. It's not meant as a generic protocol header or specification. See discussion and commits about spice-common codegen re-import. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* codegen: simplify FdTypeMarc-André Lureau2016-01-191-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>
* protocol: learn to describe fd passing in messagesMarc-Andre Lureau2016-01-143-1/+15
| | | | | | | | | | | | | | | | | 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>
* build-sys: Use $datadir for .proto files/codegen scriptsChristophe Fergeau2015-10-021-1/+1
| | | | They are not arch-specific, so installing them in $libdir is not needed.
* build-sys: Install code generation data/scriptsChristophe Fergeau2015-08-071-9/+8
| | | | | | | spice-common generate code from these python scripts and the installed SPICE .proto. This commit installs them during make install, and adds a codegendir variable to the pkgconfig file so that spice-common can locate the scripts.
* codegen: ptypes.py: keep attribute names in setsUri Lublin2015-08-041-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
* codegen: Allow to specify C type for index variableFrediano Ziglio2015-07-231-1/+3
| | | | | | | | This is to prepare to generate the wireshark dissector which uses glib types instead of the newer C ones (for compatibility with some compilers). Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
* codegen: Check we don't pop too many indexesFrediano Ziglio2015-07-231-0/+1
|
* codegen: Remove old ptr32 attributeFrediano Ziglio2015-07-231-4/+0
| | | | | | This attribute is not used in code. Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
* codegen: Do some checks on attributesFrediano Ziglio2015-07-231-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>
* codegen: Reuse code to fix attribute from prototype fileFrediano Ziglio2015-07-231-16/+16
| | | | Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
* codegen: Remove duplicate variable initializationFrediano Ziglio2015-07-231-1/+0
| | | | Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
* codegen: Optimize code indentation and avoid a loopFrediano Ziglio2015-07-231-2/+1
| | | | Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
* codegen: Fix typo in variable nameFrediano Ziglio2015-07-231-1/+1
| | | | Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
* codegen: Simplify if/else blocksFrediano Ziglio2015-07-231-18/+11
| | | | | | Blocks were mainly the same, this reduces the amount of code. Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
* codegen: Import six module before first useFrediano Ziglio2015-07-231-1/+2
| | | | | | | The module is used in the initial try/except so make sure it is already imported. Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
* codegen: Use six.PY3 rather than six.PY2Christophe Fergeau2015-04-141-3/+3
| | | | | | Older versions of python-six (at least 1.3.0) defined six.PY3 but not six.PY2. six.PY2 is only used twice in straightforward tests so it's easy to use six.PY3 instead.
* Make spice_codegen.py work on both Python 2 and 3Alexander Wauck2015-04-015-66/+71
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* python: Fix -Wsign-compareFabiano Fidêncio2014-09-181-3/+3
| | | | | | | The return of the get_array_size() is used as a limit in a loop, being compared with an unsigned index (indexes are always unsigned). To avoid the -Wsign-compare warning, let's cast the return of the get_array_size() to unsigned and make GCC happier.
* python: Fix -Wunused-parameterFabiano Fidêncio2014-09-182-7/+7
| | | | | | | | Although the most part of the parameters marked as unused are actually being used for a few functions, a bunch of warnings can be seen when the code is compiled with "-Wall -Wextra". As adding the unused attribute means that the variable/parameter is meant to be *possibly* unused, we're safe adding it in the generated code, even for used variables/parameters.
* demarshal: prefix variable name with parent namesMarc-André Lureau2014-05-151-17/+30
| | | | | | Avoid naming clash if parent structures have the same name https://bugzilla.redhat.com/show_bug.cgi?id=1021995
* marshaller: Use #include <> for headers in $srcdir/commonChristophe Fergeau2014-04-161-1/+1
| | | | | | | Since the (de)marshallers are now generated in $builddir and not in $srcdir, when these generated files include a file located in $srcdir/common, the compiler will find them thanks to a -I directive, so it makes more sense to use <> rather than "" when including them.
* Use #include "common/..." in (de)marshallersChristophe Fergeau2014-04-162-3/+3
| | | | | | | | Now that they are created in $builddir, their includes will need to refer to files in $srcdir, which can be different. It's cleaner to add -I $(top_srcdir)/spice-common/ to modules using spice-common rather than having -I $(top_srcdir)/spice-common/common which would could create header collisions.
* codegen: Add a --generate-wireshark-dissector optionJonathon Jongsma2013-10-231-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.
* python_modules/ptypes.py/EnumBaseType.c_enumname: add missing return to fix ↵Alon Levy2012-06-141-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.
* demarshall: add missing parens in BE read_xxx functionsChristophe Fergeau2012-04-061-1/+1
| | | | The missing parens causes build to fail on big-endian machines
* build-sys: make it a seperately buildable spice-common libraryMarc-André Lureau2012-03-221-1/+12
| | | | | | | - autotoolize - fix headers inclusion - generate gitignores - workaround serverSMARTCARD support with dirty hack...
* codegen: ifdef/endif function declaration tooMarc-André Lureau2012-03-211-0/+2
| | | | | | Compile out part that we are not supporting. In the future, we might want to declare a fake type and an empty function to keep API compatibility
* codegen: include headers locallyMarc-André Lureau2012-03-211-2/+2
|
* codegen: struct marshallers are not current function helperMarc-André Lureau2012-03-211-2/+3
| | | | | This solves the issue of struct_marshallers being included within the current ifdef/endif body, although they are independant functions.
* spice_codegen: Always write a channels entry for an ifdef-ed channelHans de Goede2012-03-202-0/+11
| | | | | | | | | | | | | | | | | Before this patch, if a channel is defined conditionally in spice.proto (because it depends on external headers like the smartcard channel), spice_codegen would write an entry to the channels array in spice_get_*_channel_parser which would only take up a place in the array if the ifdef condition is true, thus moving up all other intializers one place when it is not true. This was causing issues (crashes) when building spice-gtk with the combination of usbredir support enabled and smartcard support disabled. This patch fixes this by adding #else { NULL, 0 }, to the generated code. Thanks to coolper chen <lixin.chen@saicocch.com> for reporting this! Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* handle @ifdef on messages and channelsChristophe Fergeau2012-03-202-7/+43
|
* allow attributes on channel elements in .proto filesChristophe Fergeau2012-03-202-2/+4
| | | | | | 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
* add ifdef/endif methods to spice code generatorChristophe Fergeau2012-03-201-0/+12
| | | | | These methods will be needed to be able to make some fields optional in spice.proto
* fix copy & paste error in ptypes.pyChristophe Fergeau2012-03-201-3/+1
|
* demarshal: fixed-size array are missing __nelementsMarc-André Lureau2012-03-201-1/+1
| | | | | | A message with a fixed-size array, such as uint8 uuid[16] will generate an invalid code, missing the __nelements variable. Make sure that variable is defined.
* Remove trailing blank linesDaniel P. Berrange2012-03-202-2/+0
| | | | Remove any blank lines at the end of all source files
* codegen: Fix enums.h generationHans de Goede2012-03-201-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>
* add check for pyparsingChristophe Fergeau2012-03-201-3/+8
| | | | | | Check both in configure.ac (after checking if we need to rebuild the marshalling files) and in the python script using pyparsing (for people modifying .proto files in tarballs)
* python: remove c-ism trailing ;Marc-André Lureau2012-03-204-23/+23
|
* codegen: typedef the protocol enumsMarc-André Lureau2012-03-201-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.
* python_modules/codegen.py: fix indent error in an unused functionAlon Levy2012-03-201-1/+1
|
* demarshaller/marshaller fix gcc 4.6.0Alon Levy2012-03-202-9/+21
| | | | | | | | | | python_modules/demarshal.py and marshal.py fixes for gcc 4.6.0 warning about set but unused variables. The fixes disable creating of variables mem_size when they are not used (demarshall) and declaring a src variable when the message doesn't use it (marshal). You need to touch *.proto after applying this (should add a Makefile dependency).
* codegen: avoid creating out if not used (fix gcc 4.6.0 warning)Alon Levy2012-03-201-3/+5
|
* mingw32 build: python_modules/marshal: use unsigned for for_loop index variableAlon Levy2012-03-201-1/+1
|
* spice codegen: fix copy-o, no such variable valueAlon Levy2012-03-201-1/+1
|
* support python 2.5.4+ for marshaller/demarshallersAlon Levy2012-03-203-0/+3
| | | | | Patch adds a "from __future__" import that doesn't affect newer python's but allows python 2.5.4 to run the code (tested under scratchbox, n900 build environment)
* demarshaller: Fix palette marshallingAlexander Larsson2012-03-201-14/+32
| | | | | | | It turns out that using base + sizeof(struct) is not a good way to access an array at the end of a struct. For SpicePalette sizeof is 16, but offset of ents is 12. Using this calculation in the demarshaller breaks things badly, so now we use the actual array member.
* Fix uninitialized variable warningsAlexander Larsson2012-03-201-1/+1
|
* Don't send CursorHeader if cursor_flags is NONEAlexander Larsson2012-03-203-4/+7
|