mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice-gtk
synced 2026-01-02 13:17:12 +00:00
build-sys: move codegen & proto to spice-common
With this iteration, all the spice_codegen.py/proto/marshaller generation has been moved to spice-common. The spice-common directory will ship spice-protocol, since it's needed there too to build libspice-common. Again, make distcheck passes. Build with mingw & fedora linux.
This commit is contained in:
parent
6db275a422
commit
05a203af12
7
.gitmodules
vendored
7
.gitmodules
vendored
@ -1,6 +1,3 @@
|
||||
[submodule "spice-protocol"]
|
||||
path = spice-protocol
|
||||
url = ../spice-protocol
|
||||
[submodule "common"]
|
||||
path = common
|
||||
[submodule "spice-common"]
|
||||
path = spice-common
|
||||
url = ../spice-common
|
||||
|
||||
47
Makefile.am
47
Makefile.am
@ -1,7 +1,8 @@
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
NULL =
|
||||
|
||||
SUBDIRS = spice-protocol common gtk po python_modules doc data
|
||||
SUBDIRS = spice-common gtk po doc data
|
||||
|
||||
if HAVE_INTROSPECTION
|
||||
if WITH_VALA
|
||||
SUBDIRS += vapi
|
||||
@ -12,30 +13,31 @@ pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = \
|
||||
spice-client-glib-2.0.pc \
|
||||
spice-client-gtk-$(SPICE_GTK_API_VERSION).pc \
|
||||
spice-controller.pc
|
||||
spice-controller.pc \
|
||||
$(NULL)
|
||||
|
||||
INTLTOOL_FILES = intltool-extract.in \
|
||||
intltool-merge.in \
|
||||
intltool-update.in \
|
||||
$(NULL)
|
||||
INTLTOOL_FILES = \
|
||||
intltool-extract.in \
|
||||
intltool-merge.in \
|
||||
intltool-update.in \
|
||||
$(NULL)
|
||||
|
||||
DISTCLEANFILES = $(pkgconfig_DATA) \
|
||||
intltool-extract \
|
||||
intltool-merge \
|
||||
intltool-update \
|
||||
gnome-doc-utils.make \
|
||||
po/.intltool-merge-cache \
|
||||
$(NULL)
|
||||
DISTCLEANFILES = \
|
||||
$(pkgconfig_DATA) \
|
||||
intltool-extract \
|
||||
intltool-merge \
|
||||
intltool-update \
|
||||
gnome-doc-utils.make \
|
||||
po/.intltool-merge-cache \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DIST = spice.proto \
|
||||
spice1.proto \
|
||||
spice_codegen.py \
|
||||
build-aux/git-version-gen \
|
||||
gtk-doc.make \
|
||||
.version \
|
||||
THANKS \
|
||||
$(INTLTOOL_FILES) \
|
||||
$(NULL)
|
||||
EXTRA_DIST = \
|
||||
build-aux/git-version-gen \
|
||||
gtk-doc.make \
|
||||
.version \
|
||||
THANKS \
|
||||
$(INTLTOOL_FILES) \
|
||||
$(NULL)
|
||||
|
||||
MAINTAINERCLEANFILES = \
|
||||
ABOUT-NLS \
|
||||
@ -104,4 +106,3 @@ spicy-for-windows.exe:
|
||||
/usr/i686-pc-mingw32/sys-root/mingw/lib/gstreamer-0.10/libgstcoreelements.dll
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
||||
|
||||
|
||||
@ -5,8 +5,7 @@ set -e # exit on errors
|
||||
srcdir=`dirname $0`
|
||||
test -z "$srcdir" && srcdir=.
|
||||
|
||||
git submodule init
|
||||
git submodule update
|
||||
git submodule update --init --recursive
|
||||
|
||||
gtkdocize
|
||||
autoreconf -v --force --install
|
||||
|
||||
1
common
1
common
@ -1 +0,0 @@
|
||||
Subproject commit c71904e26748d7932df581939f64383a18acaf0e
|
||||
11
configure.ac
11
configure.ac
@ -23,8 +23,6 @@ AC_SUBST(SPICE_GTK_LOCALEDIR)
|
||||
|
||||
GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
|
||||
|
||||
# Define default SPICE_COMMON_SRCDIR
|
||||
SPICE_COMMON_SRCDIR='$(top_srcdir)'/common
|
||||
# no opengl support yet
|
||||
AM_CONDITIONAL(SUPPORT_GL, false)
|
||||
|
||||
@ -71,9 +69,9 @@ AC_CHECK_HEADERS([sys/socket.h netinet/in.h arpa/inet.h])
|
||||
AC_CHECK_LIBM
|
||||
AC_SUBST(LIBM)
|
||||
|
||||
AC_CONFIG_SUBDIRS([spice-protocol])
|
||||
PROTOCOL_CFLAGS='-I ${top_srcdir}/spice-protocol'
|
||||
AC_SUBST(PROTOCOL_CFLAGS)
|
||||
AC_CONFIG_SUBDIRS([spice-common])
|
||||
COMMON_CFLAGS='-I ${top_srcdir}/spice-common/ -I ${top_srcdir}/spice-common/spice-protocol/'
|
||||
AC_SUBST(COMMON_CFLAGS)
|
||||
|
||||
dnl =========================================================================
|
||||
dnl Chek optional features
|
||||
@ -593,7 +591,6 @@ SPICE_GTK_CFLAGS="$SPICE_GLIB_CFLAGS $GTK_CFLAGS "
|
||||
AC_SUBST(SPICE_GLIB_CFLAGS)
|
||||
AC_SUBST(SPICE_GTK_CFLAGS)
|
||||
|
||||
AC_SUBST(SPICE_COMMON_SRCDIR)
|
||||
AC_SUBST(SPICE_GLIB_REQUIRES)
|
||||
AC_SUBST(SPICE_GTK_REQUIRES)
|
||||
|
||||
@ -605,12 +602,10 @@ spice-client-glib-2.0.pc
|
||||
spice-client-gtk-2.0.pc
|
||||
spice-client-gtk-3.0.pc
|
||||
spice-controller.pc
|
||||
common/Makefile
|
||||
data/Makefile
|
||||
data/spicy.desktop.in
|
||||
data/spicy.nsis
|
||||
po/Makefile.in
|
||||
python_modules/Makefile
|
||||
gtk/Makefile
|
||||
gtk/controller/Makefile
|
||||
doc/Makefile
|
||||
|
||||
@ -53,7 +53,7 @@ IGNORE_HFILES= \
|
||||
$(NULL)
|
||||
|
||||
# CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library.
|
||||
GTKDOC_CFLAGS = -I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/gtk -I$(top_builddir)/gtk $(SPICE_GLIB_CFLAGS) $(SPICE_GTK_CFLAGS)
|
||||
GTKDOC_CFLAGS = -I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/gtk -I$(top_builddir)/gtk $(SPICE_GLIB_CFLAGS) $(SPICE_GTK_CFLAGS) $(COMMON_CFLAGS)
|
||||
GTKDOC_LIBS = $(top_builddir)/gtk/libspice-client-glib-2.0.la $(top_builddir)/gtk/libspice-client-gtk-$(SPICE_GTK_API_VERSION).la
|
||||
|
||||
include $(top_srcdir)/gtk-doc.make
|
||||
|
||||
326
gtk/Makefile.am
326
gtk/Makefile.am
@ -2,16 +2,6 @@ NULL =
|
||||
|
||||
SUBDIRS = controller
|
||||
|
||||
COMMON_DIR = $(SPICE_COMMON_SRCDIR)
|
||||
|
||||
# Avoid need for python(pyparsing) by end users
|
||||
MARSHALLERS = \
|
||||
generated_demarshallers.c \
|
||||
generated_demarshallers1.c \
|
||||
generated_marshallers.c \
|
||||
generated_marshallers1.c \
|
||||
$(NULL)
|
||||
|
||||
# Avoid need for perl(Text::CSV) by end users
|
||||
KEYMAPS = \
|
||||
vncdisplaykeymap_xorgevdev2xtkbd.c \
|
||||
@ -33,10 +23,9 @@ GLIBGENS = \
|
||||
$(NULL)
|
||||
|
||||
CLEANFILES = $(GLIBGENS)
|
||||
BUILT_SOURCES = $(GLIBGENS) $(KEYMAPS) $(MARSHALLERS)
|
||||
BUILT_SOURCES = $(GLIBGENS) $(KEYMAPS)
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(MARSHALLERS) \
|
||||
$(KEYMAPS) \
|
||||
decode-glz-tmpl.c \
|
||||
keymap-gen.pl \
|
||||
@ -69,37 +58,36 @@ endif
|
||||
|
||||
KEYMAP_GEN = $(srcdir)/keymap-gen.pl
|
||||
|
||||
SPICE_COMMON_CPPFLAGS = \
|
||||
-DG_LOG_DOMAIN=\"GSpice\" \
|
||||
-DSPICE_NO_DEPRECATED \
|
||||
-DGTK_DISABLE_DEPRECATED \
|
||||
-DSW_CANVAS_CACHE \
|
||||
-DSPICE_GTK_LOCALEDIR=\"${SPICE_GTK_LOCALEDIR}\" \
|
||||
-DPNP_IDS=\""$(PNP_IDS)"\" \
|
||||
-DUSB_IDS=\""$(USB_IDS)"\" \
|
||||
-DSPICE_DISABLE_ABORT \
|
||||
\
|
||||
-I$(COMMON_DIR) \
|
||||
\
|
||||
$(PROTOCOL_CFLAGS) \
|
||||
$(PIXMAN_CFLAGS) \
|
||||
$(CELT051_CFLAGS) \
|
||||
$(PULSE_CFLAGS) \
|
||||
$(GTK_CFLAGS) \
|
||||
$(CAIRO_CFLAGS) \
|
||||
$(GLIB2_CFLAGS) \
|
||||
$(GIO_CFLAGS) \
|
||||
$(GOBJECT2_CFLAGS) \
|
||||
$(SSL_CFLAGS) \
|
||||
$(SASL_CFLAGS) \
|
||||
$(GST_CFLAGS) \
|
||||
$(SMARTCARD_CFLAGS) \
|
||||
$(USBREDIR_CFLAGS) \
|
||||
SPICE_COMMON_CPPFLAGS = \
|
||||
-DG_LOG_DOMAIN=\"GSpice\" \
|
||||
-DSPICE_NO_DEPRECATED \
|
||||
-DGTK_DISABLE_DEPRECATED \
|
||||
-DSW_CANVAS_CACHE \
|
||||
-DSPICE_GTK_LOCALEDIR=\"${SPICE_GTK_LOCALEDIR}\" \
|
||||
-DPNP_IDS=\""$(PNP_IDS)"\" \
|
||||
-DUSB_IDS=\""$(USB_IDS)"\" \
|
||||
-DSPICE_DISABLE_ABORT \
|
||||
-I$(top_srcdir) \
|
||||
$(COMMON_CFLAGS) \
|
||||
$(PIXMAN_CFLAGS) \
|
||||
$(CELT051_CFLAGS) \
|
||||
$(PULSE_CFLAGS) \
|
||||
$(GTK_CFLAGS) \
|
||||
$(CAIRO_CFLAGS) \
|
||||
$(GLIB2_CFLAGS) \
|
||||
$(GIO_CFLAGS) \
|
||||
$(GOBJECT2_CFLAGS) \
|
||||
$(SSL_CFLAGS) \
|
||||
$(SASL_CFLAGS) \
|
||||
$(GST_CFLAGS) \
|
||||
$(SMARTCARD_CFLAGS) \
|
||||
$(USBREDIR_CFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
$(SPICE_COMMON_CPPFLAGS) \
|
||||
$(SPICE_CFLAGS)
|
||||
AM_CPPFLAGS = \
|
||||
$(SPICE_COMMON_CPPFLAGS) \
|
||||
$(SPICE_CFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
|
||||
SPICE_GTK_LDFLAGS_COMMON = \
|
||||
@ -166,7 +154,7 @@ libspice_client_gtkinclude_HEADERS = \
|
||||
$(NULL)
|
||||
|
||||
nodist_libspice_client_gtkinclude_HEADERS = \
|
||||
spice-widget-enums.h \
|
||||
spice-widget-enums.h \
|
||||
$(NULL)
|
||||
|
||||
libspice_client_glib_2_0_la_LDFLAGS = \
|
||||
@ -175,112 +163,90 @@ libspice_client_glib_2_0_la_LDFLAGS = \
|
||||
$(VERSION_LDFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
libspice_client_glib_2_0_la_LIBADD = \
|
||||
$(GLIB2_LIBS) \
|
||||
$(GIO_LIBS) \
|
||||
$(GOBJECT2_LIBS) \
|
||||
$(CELT051_LIBS) \
|
||||
$(JPEG_LIBS) \
|
||||
$(Z_LIBS) \
|
||||
$(PIXMAN_LIBS) \
|
||||
$(SSL_LIBS) \
|
||||
$(PULSE_LIBS) \
|
||||
$(GST_LIBS) \
|
||||
$(SASL_LIBS) \
|
||||
$(SMARTCARD_LIBS) \
|
||||
$(USBREDIR_LIBS) \
|
||||
libspice_client_glib_2_0_la_LIBADD = \
|
||||
$(top_builddir)/spice-common/common/libspice-common.la \
|
||||
$(top_builddir)/spice-common/common/libspice-common-client.la \
|
||||
$(GLIB2_LIBS) \
|
||||
$(GIO_LIBS) \
|
||||
$(GOBJECT2_LIBS) \
|
||||
$(CELT051_LIBS) \
|
||||
$(JPEG_LIBS) \
|
||||
$(Z_LIBS) \
|
||||
$(PIXMAN_LIBS) \
|
||||
$(SSL_LIBS) \
|
||||
$(PULSE_LIBS) \
|
||||
$(GST_LIBS) \
|
||||
$(SASL_LIBS) \
|
||||
$(SMARTCARD_LIBS) \
|
||||
$(USBREDIR_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
if WITH_POLKIT
|
||||
USB_ACL_HELPER_SRCS = \
|
||||
usb-acl-helper.c \
|
||||
usb-acl-helper.h
|
||||
USB_ACL_HELPER_SRCS = \
|
||||
usb-acl-helper.c \
|
||||
usb-acl-helper.h \
|
||||
$(NULL)
|
||||
AM_CPPFLAGS += -DACL_HELPER_PATH="\"$(ACL_HELPER_DIR)\""
|
||||
else
|
||||
USB_ACL_HELPER_SRCS =
|
||||
endif
|
||||
|
||||
libspice_client_glib_2_0_la_SOURCES = \
|
||||
bio-gsocket.c \
|
||||
bio-gsocket.h \
|
||||
glib-compat.c \
|
||||
glib-compat.h \
|
||||
spice-audio.c \
|
||||
spice-audio-priv.h \
|
||||
spice-common.h \
|
||||
spice-util.c \
|
||||
spice-util-priv.h \
|
||||
spice-option.h \
|
||||
spice-option.c \
|
||||
\
|
||||
spice-client.c \
|
||||
spice-session.c \
|
||||
spice-session-priv.h \
|
||||
spice-channel.c \
|
||||
spice-channel-cache.h \
|
||||
spice-channel-priv.h \
|
||||
coroutine.h \
|
||||
gio-coroutine.c \
|
||||
gio-coroutine.h \
|
||||
\
|
||||
channel-base.c \
|
||||
channel-cursor.c \
|
||||
channel-display.c \
|
||||
channel-display-priv.h \
|
||||
channel-display-mjpeg.c \
|
||||
channel-inputs.c \
|
||||
channel-main.c \
|
||||
channel-playback.c \
|
||||
channel-record.c \
|
||||
channel-smartcard.c \
|
||||
channel-usbredir.c \
|
||||
channel-usbredir-priv.h \
|
||||
smartcard-manager.c \
|
||||
smartcard-manager-priv.h \
|
||||
usb-device-manager.c \
|
||||
usb-device-manager-priv.h \
|
||||
usbutil.c \
|
||||
usbutil.h \
|
||||
$(USB_ACL_HELPER_SRCS) \
|
||||
\
|
||||
decode.h \
|
||||
decode-glz.c \
|
||||
decode-jpeg.c \
|
||||
decode-zlib.c \
|
||||
\
|
||||
$(COMMON_DIR)/backtrace.c \
|
||||
$(COMMON_DIR)/backtrace.h \
|
||||
$(COMMON_DIR)/mem.c \
|
||||
$(COMMON_DIR)/mem.h \
|
||||
$(COMMON_DIR)/marshaller.c \
|
||||
$(COMMON_DIR)/marshaller.h \
|
||||
$(COMMON_DIR)/canvas_utils.c \
|
||||
$(COMMON_DIR)/canvas_utils.h \
|
||||
$(COMMON_DIR)/sw_canvas.c \
|
||||
$(COMMON_DIR)/sw_canvas.h \
|
||||
$(COMMON_DIR)/pixman_utils.c \
|
||||
$(COMMON_DIR)/pixman_utils.h \
|
||||
$(COMMON_DIR)/lines.c \
|
||||
$(COMMON_DIR)/lines.h \
|
||||
$(COMMON_DIR)/rop3.c \
|
||||
$(COMMON_DIR)/rop3.h \
|
||||
$(COMMON_DIR)/quic.c \
|
||||
$(COMMON_DIR)/quic.h \
|
||||
$(COMMON_DIR)/log.c \
|
||||
$(COMMON_DIR)/log.h \
|
||||
$(COMMON_DIR)/lz.c \
|
||||
$(COMMON_DIR)/lz.h \
|
||||
$(COMMON_DIR)/region.c \
|
||||
$(COMMON_DIR)/region.h \
|
||||
$(COMMON_DIR)/ssl_verify.c \
|
||||
$(COMMON_DIR)/ssl_verify.h \
|
||||
libspice_client_glib_2_0_la_SOURCES = \
|
||||
bio-gsocket.c \
|
||||
bio-gsocket.h \
|
||||
glib-compat.c \
|
||||
glib-compat.h \
|
||||
spice-audio.c \
|
||||
spice-audio-priv.h \
|
||||
spice-common.h \
|
||||
spice-util.c \
|
||||
spice-util-priv.h \
|
||||
spice-option.h \
|
||||
spice-option.c \
|
||||
\
|
||||
spice-client.c \
|
||||
spice-session.c \
|
||||
spice-session-priv.h \
|
||||
spice-channel.c \
|
||||
spice-channel-cache.h \
|
||||
spice-channel-priv.h \
|
||||
coroutine.h \
|
||||
gio-coroutine.c \
|
||||
gio-coroutine.h \
|
||||
\
|
||||
channel-base.c \
|
||||
channel-cursor.c \
|
||||
channel-display.c \
|
||||
channel-display-priv.h \
|
||||
channel-display-mjpeg.c \
|
||||
channel-inputs.c \
|
||||
channel-main.c \
|
||||
channel-playback.c \
|
||||
channel-record.c \
|
||||
channel-smartcard.c \
|
||||
channel-usbredir.c \
|
||||
channel-usbredir-priv.h \
|
||||
smartcard-manager.c \
|
||||
smartcard-manager-priv.h \
|
||||
usb-device-manager.c \
|
||||
usb-device-manager-priv.h \
|
||||
usbutil.c \
|
||||
usbutil.h \
|
||||
$(USB_ACL_HELPER_SRCS) \
|
||||
\
|
||||
decode.h \
|
||||
decode-glz.c \
|
||||
decode-jpeg.c \
|
||||
decode-zlib.c \
|
||||
\
|
||||
$(top_srcdir)/spice-common/common/sw_canvas.c \
|
||||
$(top_srcdir)/spice-common/common/sw_canvas.h \
|
||||
$(NULL)
|
||||
|
||||
nodist_libspice_client_glib_2_0_la_SOURCES = \
|
||||
$(MARSHALLERS) \
|
||||
spice-glib-enums.c \
|
||||
spice-marshal.c \
|
||||
spice-marshal.h \
|
||||
spice-glib-enums.c \
|
||||
spice-marshal.c \
|
||||
spice-marshal.h \
|
||||
$(NULL)
|
||||
|
||||
libspice_client_glibincludedir = $(includedir)/spice-client-glib-2.0
|
||||
@ -305,7 +271,7 @@ libspice_client_glibinclude_HEADERS = \
|
||||
$(NULL)
|
||||
|
||||
nodist_libspice_client_glibinclude_HEADERS = \
|
||||
spice-glib-enums.h \
|
||||
spice-glib-enums.h \
|
||||
$(NULL)
|
||||
|
||||
# file for API compatibility, but we don't want warning during our compilation
|
||||
@ -340,7 +306,7 @@ libspice_client_glib_2_0_la_SOURCES += coroutine_gthread.c
|
||||
libspice_client_glib_2_0_la_LIBADD += $(GTHREAD_LIBS)
|
||||
endif
|
||||
|
||||
displaysrc = \
|
||||
displaysrc = \
|
||||
glib-compat.h \
|
||||
display/edid.h \
|
||||
display/edid-parse.c \
|
||||
@ -370,13 +336,13 @@ spicy_SOURCES = \
|
||||
$(displaysrc) \
|
||||
$(NULL)
|
||||
|
||||
spicy_LDADD = \
|
||||
libspice-client-gtk-$(SPICE_GTK_API_VERSION).la \
|
||||
libspice-client-glib-2.0.la \
|
||||
$(XRANDR_LIBS) \
|
||||
$(GTHREAD_LIBS) \
|
||||
$(GTK_LIBS) \
|
||||
$(LIBM) \
|
||||
spicy_LDADD = \
|
||||
libspice-client-gtk-$(SPICE_GTK_API_VERSION).la \
|
||||
libspice-client-glib-2.0.la \
|
||||
$(XRANDR_LIBS) \
|
||||
$(GTHREAD_LIBS) \
|
||||
$(GTK_LIBS) \
|
||||
$(LIBM) \
|
||||
$(NULL)
|
||||
|
||||
spicy_CPPFLAGS = \
|
||||
@ -423,9 +389,9 @@ snappy_SOURCES = \
|
||||
spice-cmdline.c \
|
||||
$(NULL)
|
||||
|
||||
snappy_LDADD = \
|
||||
snappy_LDADD = \
|
||||
libspice-client-glib-2.0.la \
|
||||
$(GOBJECT2_LIBS) \
|
||||
$(GOBJECT2_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
spicy_stats_SOURCES = \
|
||||
@ -436,7 +402,7 @@ spicy_stats_SOURCES = \
|
||||
|
||||
spicy_stats_LDADD = \
|
||||
libspice-client-glib-2.0.la \
|
||||
$(GOBJECT2_LIBS) \
|
||||
$(GOBJECT2_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
|
||||
@ -511,20 +477,6 @@ spice-widget-enums.h: spice-widget.h
|
||||
$< > $@
|
||||
|
||||
|
||||
# Note despite being autogenerated these are not part of CLEANFILES, they are
|
||||
# actually a part of EXTRA_DIST, to avoid the need for pyparser by end users
|
||||
generated_demarshallers.c: $(top_srcdir)/spice.proto
|
||||
$(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-demarshallers --client --include messages.h $< $@ >/dev/null
|
||||
|
||||
generated_demarshallers1.c: $(top_srcdir)/spice1.proto
|
||||
$(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-demarshallers --client --include messages.h --prefix 1 --ptrsize 8 $< $@ >/dev/null
|
||||
|
||||
generated_marshallers.c: $(top_srcdir)/spice.proto
|
||||
$(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers -P --include messages.h --include client_marshallers.h --client $< $@ >/dev/null
|
||||
|
||||
generated_marshallers1.c: $(top_srcdir)/spice1.proto
|
||||
$(AM_V_GEN)$(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers -P --include messages.h --include client_marshallers.h --client --prefix 1 --ptrsize 8 $< $@ >/dev/null
|
||||
|
||||
vncdisplaykeymap.c: $(KEYMAPS)
|
||||
|
||||
$(KEYMAPS): $(KEYMAP_GEN) keymaps.csv
|
||||
@ -592,34 +544,34 @@ INTROSPECTION_SCANNER_ARGS = --warn-all --accept-unprefixed --add-include-path=$
|
||||
INTROSPECTION_COMPILER_ARGS = --includedir=$(builddir)
|
||||
|
||||
if HAVE_INTROSPECTION
|
||||
glib_introspection_files = \
|
||||
$(libspice_client_glibinclude_HEADERS) \
|
||||
glib_introspection_files = \
|
||||
$(libspice_client_glibinclude_HEADERS) \
|
||||
$(nodist_libspice_client_glibinclude_HEADERS) \
|
||||
spice-audio.c \
|
||||
spice-client.c \
|
||||
spice-session.c \
|
||||
spice-channel.c \
|
||||
spice-glib-enums.c \
|
||||
spice-option.c \
|
||||
spice-util.c \
|
||||
channel-cursor.c \
|
||||
channel-display.c \
|
||||
channel-inputs.c \
|
||||
channel-main.c \
|
||||
channel-playback.c \
|
||||
channel-record.c \
|
||||
channel-smartcard.c \
|
||||
channel-usbredir.c \
|
||||
smartcard-manager.c \
|
||||
usb-device-manager.c \
|
||||
spice-audio.c \
|
||||
spice-client.c \
|
||||
spice-session.c \
|
||||
spice-channel.c \
|
||||
spice-glib-enums.c \
|
||||
spice-option.c \
|
||||
spice-util.c \
|
||||
channel-cursor.c \
|
||||
channel-display.c \
|
||||
channel-inputs.c \
|
||||
channel-main.c \
|
||||
channel-playback.c \
|
||||
channel-record.c \
|
||||
channel-smartcard.c \
|
||||
channel-usbredir.c \
|
||||
smartcard-manager.c \
|
||||
usb-device-manager.c \
|
||||
$(NULL)
|
||||
|
||||
gtk_introspection_files = \
|
||||
$(libspice_client_gtkinclude_HEADERS) \
|
||||
gtk_introspection_files = \
|
||||
$(libspice_client_gtkinclude_HEADERS) \
|
||||
$(nodist_libspice_client_gtkinclude_HEADERS) \
|
||||
spice-gtk-session.c \
|
||||
spice-widget.c \
|
||||
spice-grabsequence.c \
|
||||
spice-gtk-session.c \
|
||||
spice-widget.c \
|
||||
spice-grabsequence.c \
|
||||
$(NULL)
|
||||
|
||||
SpiceClientGLib-2.0.gir: libspice-client-glib-2.0.la
|
||||
|
||||
@ -26,13 +26,12 @@
|
||||
#endif
|
||||
#include <jpeglib.h>
|
||||
|
||||
/* spice/common */
|
||||
#include "canvas_base.h"
|
||||
#include "canvas_utils.h"
|
||||
#include "sw_canvas.h"
|
||||
#include "ring.h"
|
||||
#include "quic.h"
|
||||
#include "rop3.h"
|
||||
#include "common/canvas_base.h"
|
||||
#include "common/canvas_utils.h"
|
||||
#include "common/sw_canvas.h"
|
||||
#include "common/ring.h"
|
||||
#include "common/quic.h"
|
||||
#include "common/rop3.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ NULL =
|
||||
AM_CPPFLAGS = \
|
||||
-DG_LOG_DOMAIN=\"GSpiceController\" \
|
||||
$(GIO_CFLAGS) \
|
||||
$(PROTOCOL_CFLAGS) \
|
||||
$(COMMON_CFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
|
||||
|
||||
@ -25,8 +25,7 @@
|
||||
#include "spice-util.h"
|
||||
#include "decode.h"
|
||||
|
||||
/* spice/common */
|
||||
#include "canvas_utils.h"
|
||||
#include "common/canvas_utils.h"
|
||||
|
||||
struct glz_image_hdr {
|
||||
uint64_t id;
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "canvas_base.h"
|
||||
#include "common/canvas_base.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
@ -18,10 +18,9 @@
|
||||
#ifndef SPICE_CHANNEL_CACHE_H_
|
||||
# define SPICE_CHANNEL_CACHE_H_
|
||||
|
||||
/* spice/common */
|
||||
#include <inttypes.h> /* For PRIx64 */
|
||||
#include "mem.h"
|
||||
#include "ring.h"
|
||||
#include "common/mem.h"
|
||||
#include "common/ring.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
@ -33,10 +33,9 @@
|
||||
#include "coroutine.h"
|
||||
#include "gio-coroutine.h"
|
||||
|
||||
#include "client_marshallers.h"
|
||||
#include "client_demarshallers.h"
|
||||
|
||||
#include "ssl_verify.h"
|
||||
#include "common/client_marshallers.h"
|
||||
#include "common/client_demarshallers.h"
|
||||
#include "common/ssl_verify.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
@ -27,10 +27,9 @@
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
/* spice/common */
|
||||
#include "mem.h"
|
||||
#include "messages.h"
|
||||
#include "marshaller.h"
|
||||
#include "common/mem.h"
|
||||
#include "common/messages.h"
|
||||
#include "common/marshaller.h"
|
||||
|
||||
#include "spice-util.h"
|
||||
|
||||
|
||||
@ -17,16 +17,14 @@
|
||||
*/
|
||||
#include <gio/gio.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "common/ring.h"
|
||||
|
||||
#include "spice-client.h"
|
||||
#include "spice-common.h"
|
||||
#include "spice-channel-priv.h"
|
||||
#include "spice-util-priv.h"
|
||||
|
||||
#include "spice-session-priv.h"
|
||||
|
||||
/* spice/common */
|
||||
#include "ring.h"
|
||||
|
||||
#include "gio-coroutine.h"
|
||||
#include "glib-compat.h"
|
||||
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
NULL =
|
||||
|
||||
PYTHON_MODULES = __init__.py codegen.py demarshal.py marshal.py ptypes.py spice_parser.py
|
||||
|
||||
EXTRA_DIST = $(PYTHON_MODULES)
|
||||
|
||||
DISTCLEANFILES = *.pyc
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
||||
|
||||
@ -1,374 +0,0 @@
|
||||
from __future__ import with_statement
|
||||
from cStringIO import StringIO
|
||||
|
||||
def camel_to_underscores(s, upper = False):
|
||||
res = ""
|
||||
for i in range(len(s)):
|
||||
c = s[i]
|
||||
if i > 0 and c.isupper():
|
||||
res = res + "_"
|
||||
if upper:
|
||||
res = res + c.upper()
|
||||
else:
|
||||
res = res + c.lower()
|
||||
return res
|
||||
|
||||
def underscores_to_camel(s):
|
||||
res = ""
|
||||
do_upper = True
|
||||
for i in range(len(s)):
|
||||
c = s[i]
|
||||
if c == "_":
|
||||
do_upper = True
|
||||
else:
|
||||
if do_upper:
|
||||
res = res + c.upper()
|
||||
else:
|
||||
res = res + c
|
||||
do_upper = False
|
||||
return res
|
||||
|
||||
proto_prefix = "Temp"
|
||||
|
||||
def set_prefix(prefix):
|
||||
global proto_prefix
|
||||
global proto_prefix_upper
|
||||
global proto_prefix_lower
|
||||
proto_prefix = prefix
|
||||
proto_prefix_upper = prefix.upper()
|
||||
proto_prefix_lower = prefix.lower()
|
||||
|
||||
def prefix_underscore_upper(*args):
|
||||
s = proto_prefix_upper
|
||||
for arg in args:
|
||||
s = s + "_" + arg
|
||||
return s
|
||||
|
||||
def prefix_underscore_lower(*args):
|
||||
s = proto_prefix_lower
|
||||
for arg in args:
|
||||
s = s + "_" + arg
|
||||
return s
|
||||
|
||||
def prefix_camel(*args):
|
||||
s = proto_prefix
|
||||
for arg in args:
|
||||
s = s + underscores_to_camel(arg)
|
||||
return s
|
||||
|
||||
def increment_identifier(idf):
|
||||
v = idf[-1:]
|
||||
if v.isdigit():
|
||||
return idf[:-1] + str(int(v) + 1)
|
||||
return idf + "2"
|
||||
|
||||
def sum_array(array):
|
||||
if len(array) == 0:
|
||||
return 0
|
||||
return " + ".join(array)
|
||||
|
||||
class CodeWriter:
|
||||
def __init__(self):
|
||||
self.out = StringIO()
|
||||
self.contents = [self.out]
|
||||
self.indentation = 0
|
||||
self.at_line_start = True
|
||||
self.indexes = ["i", "j", "k", "ii", "jj", "kk"]
|
||||
self.current_index = 0
|
||||
self.generated = {}
|
||||
self.vars = []
|
||||
self.has_error_check = False
|
||||
self.options = {}
|
||||
self.function_helper_writer = None
|
||||
|
||||
def set_option(self, opt, value = True):
|
||||
self.options[opt] = value
|
||||
|
||||
def has_option(self, opt):
|
||||
return self.options.has_key(opt)
|
||||
|
||||
def set_is_generated(self, kind, name):
|
||||
if not self.generated.has_key(kind):
|
||||
v = {}
|
||||
self.generated[kind] = v
|
||||
else:
|
||||
v = self.generated[kind]
|
||||
v[name] = 1
|
||||
|
||||
def is_generated(self, kind, name):
|
||||
if not self.generated.has_key(kind):
|
||||
return False
|
||||
v = self.generated[kind]
|
||||
return v.has_key(name)
|
||||
|
||||
def getvalue(self):
|
||||
strs = map(lambda writer: writer.getvalue(), self.contents)
|
||||
return "".join(strs)
|
||||
|
||||
def get_subwriter(self):
|
||||
writer = CodeWriter()
|
||||
self.contents.append(writer)
|
||||
self.out = StringIO()
|
||||
self.contents.append(self.out)
|
||||
writer.indentation = self.indentation
|
||||
writer.at_line_start = self.at_line_start
|
||||
writer.generated = self.generated
|
||||
writer.options = self.options
|
||||
writer.public_prefix = self.public_prefix
|
||||
|
||||
return writer;
|
||||
|
||||
def write(self, s):
|
||||
# Ensure its a string
|
||||
s = str(s)
|
||||
|
||||
if len(s) == 0:
|
||||
return
|
||||
|
||||
if self.at_line_start:
|
||||
for i in range(self.indentation):
|
||||
self.out.write(" ")
|
||||
self.at_line_start = False
|
||||
self.out.write(s)
|
||||
return self
|
||||
|
||||
def newline(self):
|
||||
self.out.write("\n")
|
||||
self.at_line_start = True
|
||||
return self
|
||||
|
||||
def writeln(self, s):
|
||||
self.write(s)
|
||||
self.newline()
|
||||
return self
|
||||
|
||||
def label(self, s):
|
||||
self.indentation = self.indentation - 1
|
||||
self.write(s + ":")
|
||||
self.indentation = self.indentation + 1
|
||||
self.newline()
|
||||
|
||||
def statement(self, s):
|
||||
self.write(s)
|
||||
self.write(";")
|
||||
self.newline()
|
||||
return self
|
||||
|
||||
def assign(self, var, val):
|
||||
self.write("%s = %s" % (var, val))
|
||||
self.write(";")
|
||||
self.newline()
|
||||
return self
|
||||
|
||||
def increment(self, var, val):
|
||||
self.write("%s += %s" % (var, val))
|
||||
self.write(";")
|
||||
self.newline()
|
||||
return self
|
||||
|
||||
def comment(self, str):
|
||||
self.write("/* " + str + " */")
|
||||
return self
|
||||
|
||||
def todo(self, str):
|
||||
self.comment("TODO: *** %s ***" % str).newline()
|
||||
return self
|
||||
|
||||
def error_check(self, check, label = "error"):
|
||||
self.has_error_check = True
|
||||
with self.block("if (SPICE_UNLIKELY(%s))" % check):
|
||||
if self.has_option("print_error"):
|
||||
self.statement('printf("%%s: Caught error - %s", __PRETTY_FUNCTION__)' % check)
|
||||
if self.has_option("assert_on_error"):
|
||||
self.statement("assert(0)")
|
||||
self.statement("goto %s" % label)
|
||||
|
||||
def indent(self):
|
||||
self.indentation += 4;
|
||||
|
||||
def unindent(self):
|
||||
self.indentation -= 4;
|
||||
if self.indentation < 0:
|
||||
self.indenttation = 0
|
||||
|
||||
def begin_block(self, prefix= "", comment = ""):
|
||||
if len(prefix) > 0:
|
||||
self.write(prefix)
|
||||
if self.at_line_start:
|
||||
self.write("{")
|
||||
else:
|
||||
self.write(" {")
|
||||
if len(comment) > 0:
|
||||
self.write(" ")
|
||||
self.comment(comment)
|
||||
self.newline()
|
||||
self.indent()
|
||||
|
||||
def end_block(self, semicolon=False, newline=True):
|
||||
self.unindent()
|
||||
if self.at_line_start:
|
||||
self.write("}")
|
||||
else:
|
||||
self.write(" }")
|
||||
if semicolon:
|
||||
self.write(";")
|
||||
if newline:
|
||||
self.newline()
|
||||
|
||||
class Block:
|
||||
def __init__(self, writer, semicolon, newline):
|
||||
self.writer = writer
|
||||
self.semicolon = semicolon
|
||||
self.newline = newline
|
||||
|
||||
def __enter__(self):
|
||||
return self.writer.get_subwriter()
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
self.writer.end_block(self.semicolon, self.newline)
|
||||
|
||||
class PartialBlock:
|
||||
def __init__(self, writer, scope, semicolon, newline):
|
||||
self.writer = writer
|
||||
self.scope = scope
|
||||
self.semicolon = semicolon
|
||||
self.newline = newline
|
||||
|
||||
def __enter__(self):
|
||||
return self.scope
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
self.writer.end_block(self.semicolon, self.newline)
|
||||
|
||||
class NoBlock:
|
||||
def __init__(self, scope):
|
||||
self.scope = scope
|
||||
|
||||
def __enter__(self):
|
||||
return self.scope
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
pass
|
||||
|
||||
def block(self, prefix= "", comment = "", semicolon=False, newline=True):
|
||||
self.begin_block(prefix, comment)
|
||||
return self.Block(self, semicolon, newline)
|
||||
|
||||
def partial_block(self, scope, semicolon=False, newline=True):
|
||||
return self.PartialBlock(self, scope, semicolon, newline)
|
||||
|
||||
def no_block(self, scope):
|
||||
return self.NoBlock(scope)
|
||||
|
||||
def optional_block(self, scope):
|
||||
if scope != None:
|
||||
return self.NoBlock(scope)
|
||||
return self.block()
|
||||
|
||||
def for_loop(self, index, limit):
|
||||
return self.block("for (%s = 0; %s < %s; %s++)" % (index, index, limit, index))
|
||||
|
||||
def while_loop(self, expr):
|
||||
return self.block("while (%s)" % (expr))
|
||||
|
||||
def if_block(self, check, elseif=False, newline=True):
|
||||
s = "if (%s)" % (check)
|
||||
if elseif:
|
||||
s = " else " + s
|
||||
self.begin_block(s, "")
|
||||
return self.Block(self, False, newline)
|
||||
|
||||
def variable_defined(self, name):
|
||||
for n in self.vars:
|
||||
if n == name:
|
||||
return True
|
||||
return False
|
||||
|
||||
def variable_def(self, ctype, *names):
|
||||
for n in names:
|
||||
# Strip away initialization
|
||||
i = n.find("=")
|
||||
if i != -1:
|
||||
n = n[0:i]
|
||||
self.vars.append(n.strip())
|
||||
# only add space for non-pointer types
|
||||
if ctype[-1] == "*":
|
||||
ctype = ctype[:-1].rstrip()
|
||||
self.writeln("%s *%s;"%(ctype, ", *".join(names)))
|
||||
else:
|
||||
self.writeln("%s %s;"%(ctype, ", ".join(names)))
|
||||
return self
|
||||
|
||||
def function_helper(self):
|
||||
if self.function_helper_writer != None:
|
||||
writer = self.function_helper_writer.get_subwriter()
|
||||
self.function_helper_writer.newline()
|
||||
else:
|
||||
writer = self.get_subwriter()
|
||||
return writer
|
||||
|
||||
def function(self, name, return_type, args, static = False):
|
||||
self.has_error_check = False
|
||||
self.function_helper_writer = self.get_subwriter()
|
||||
if static:
|
||||
self.write("static ")
|
||||
self.write(return_type)
|
||||
self.write(" %s(%s)"% (name, args)).newline()
|
||||
self.begin_block()
|
||||
self.function_variables_writer = self.get_subwriter()
|
||||
self.function_variables = {}
|
||||
return self.function_variables_writer
|
||||
|
||||
def macro(self, name, args, define):
|
||||
self.write("#define %s(%s) %s" % (name, args, define)).newline()
|
||||
|
||||
def ifdef(self, name):
|
||||
indentation = self.indentation
|
||||
self.indentation = 0;
|
||||
self.write("#ifdef %s" % (name)).newline()
|
||||
self.indentation = indentation
|
||||
|
||||
def ifdef_else(self, name):
|
||||
indentation = self.indentation
|
||||
self.indentation = 0;
|
||||
self.write("#else /* %s */" % (name)).newline()
|
||||
self.indentation = indentation
|
||||
|
||||
def endif(self, name):
|
||||
indentation = self.indentation
|
||||
self.indentation = 0;
|
||||
self.write("#endif /* %s */" % (name)).newline()
|
||||
self.indentation = indentation
|
||||
|
||||
def add_function_variable(self, ctype, name):
|
||||
if self.function_variables.has_key(name):
|
||||
assert(self.function_variables[name] == ctype)
|
||||
else:
|
||||
self.function_variables[name] = ctype
|
||||
self.function_variables_writer.variable_def(ctype, name)
|
||||
|
||||
def pop_index(self):
|
||||
index = self.indexes[self.current_index]
|
||||
self.current_index = self.current_index + 1
|
||||
self.add_function_variable("uint32_t", index)
|
||||
return index
|
||||
|
||||
def push_index(self):
|
||||
self.current_index = self.current_index - 1
|
||||
|
||||
class Index:
|
||||
def __init__(self, writer, val):
|
||||
self.writer = writer
|
||||
self.val = val
|
||||
|
||||
def __enter__(self):
|
||||
return self.val
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
self.writer.push_index()
|
||||
|
||||
def index(self, no_block = False):
|
||||
if no_block:
|
||||
return self.no_block(None)
|
||||
val = self.pop_index()
|
||||
return self.Index(self, val)
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,424 +0,0 @@
|
||||
from __future__ import with_statement
|
||||
import ptypes
|
||||
import codegen
|
||||
|
||||
def write_includes(writer):
|
||||
writer.header.writeln("#include <spice/protocol.h>")
|
||||
writer.header.writeln("#include <marshaller.h>")
|
||||
writer.header.newline()
|
||||
writer.header.writeln("#ifndef _GENERATED_HEADERS_H")
|
||||
writer.header.writeln("#define _GENERATED_HEADERS_H")
|
||||
|
||||
writer.writeln("#include <string.h>")
|
||||
writer.writeln("#include <assert.h>")
|
||||
writer.writeln("#include <stdlib.h>")
|
||||
writer.writeln("#include <stdio.h>")
|
||||
writer.writeln("#include <spice/protocol.h>")
|
||||
writer.writeln("#include <spice/macros.h>")
|
||||
writer.writeln("#include <marshaller.h>")
|
||||
writer.newline()
|
||||
writer.writeln("#ifdef _MSC_VER")
|
||||
writer.writeln("#pragma warning(disable:4101)")
|
||||
writer.writeln("#pragma warning(disable:4018)")
|
||||
writer.writeln("#endif")
|
||||
writer.newline()
|
||||
|
||||
class MarshallingSource:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def child_at_end(self, t):
|
||||
return RootMarshallingSource(self, t.c_type(), t.sizeof())
|
||||
|
||||
def child_sub(self, containee):
|
||||
return SubMarshallingSource(self, containee)
|
||||
|
||||
def declare(self, writer):
|
||||
return writer.optional_block(self.reuse_scope)
|
||||
|
||||
def is_toplevel(self):
|
||||
return self.parent_src == None and not self.is_helper
|
||||
|
||||
class RootMarshallingSource(MarshallingSource):
|
||||
def __init__(self, parent_src, c_type, sizeof, pointer = None):
|
||||
self.is_helper = False
|
||||
self.reuse_scope = None
|
||||
self.parent_src = parent_src
|
||||
if parent_src:
|
||||
self.base_var = codegen.increment_identifier(parent_src.base_var)
|
||||
else:
|
||||
self.base_var = "src"
|
||||
self.c_type = c_type
|
||||
self.sizeof = sizeof
|
||||
self.pointer = pointer
|
||||
assert pointer != None
|
||||
|
||||
def get_self_ref(self):
|
||||
return self.base_var
|
||||
|
||||
def get_ref(self, member):
|
||||
return self.base_var + "->" + member
|
||||
|
||||
def declare(self, writer):
|
||||
if self.reuse_scope:
|
||||
scope = self.reuse_scope
|
||||
else:
|
||||
writer.begin_block()
|
||||
scope = writer.get_subwriter()
|
||||
|
||||
scope.variable_def(self.c_type + " *", self.base_var)
|
||||
if not self.reuse_scope:
|
||||
scope.newline()
|
||||
|
||||
writer.assign(self.base_var, "(%s *)%s" % (self.c_type, self.pointer))
|
||||
writer.newline()
|
||||
|
||||
if self.reuse_scope:
|
||||
return writer.no_block(self.reuse_scope)
|
||||
else:
|
||||
return writer.partial_block(scope)
|
||||
|
||||
class SubMarshallingSource(MarshallingSource):
|
||||
def __init__(self, parent_src, containee):
|
||||
self.reuse_scope = None
|
||||
self.parent_src = parent_src
|
||||
self.base_var = parent_src.base_var
|
||||
self.containee = containee
|
||||
self.name = containee.name
|
||||
self.is_helper = False
|
||||
|
||||
def get_self_ref(self):
|
||||
if self.containee.has_attr("to_ptr"):
|
||||
return "%s" % self.parent_src.get_ref(self.name)
|
||||
else:
|
||||
return "&%s" % self.parent_src.get_ref(self.name)
|
||||
|
||||
def get_ref(self, member):
|
||||
if self.containee.has_attr("to_ptr"):
|
||||
return self.parent_src.get_ref(self.name) + "->" + member
|
||||
else:
|
||||
return self.parent_src.get_ref(self.name) + "." + member
|
||||
|
||||
def write_marshal_ptr_function(writer, target_type):
|
||||
if target_type.is_array():
|
||||
marshal_function = "spice_marshall_array_%s" % target_type.element_type.primitive_type()
|
||||
else:
|
||||
marshal_function = "spice_marshall_%s" % target_type.name
|
||||
if writer.is_generated("marshaller", marshal_function):
|
||||
return marshal_function
|
||||
|
||||
writer.set_is_generated("marshaller", marshal_function)
|
||||
|
||||
names = target_type.get_pointer_names(False)
|
||||
names_args = ""
|
||||
if len(names) > 0:
|
||||
n = map(lambda name: ", SpiceMarshaller **%s_out" % name, names)
|
||||
names_args = "".join(n)
|
||||
|
||||
header = writer.header
|
||||
writer = writer.function_helper()
|
||||
writer.header = header
|
||||
writer.out_prefix = ""
|
||||
if target_type.is_array():
|
||||
scope = writer.function(marshal_function, "SPICE_GNUC_UNUSED static void", "SpiceMarshaller *m, %s_t *ptr, unsigned count" % target_type.element_type.primitive_type() + names_args)
|
||||
else:
|
||||
scope = writer.function(marshal_function, "void", "SpiceMarshaller *m, %s *ptr" % target_type.c_type() + names_args)
|
||||
header.writeln("void " + marshal_function + "(SpiceMarshaller *m, %s *msg" % target_type.c_type() + names_args + ");")
|
||||
scope.variable_def("SPICE_GNUC_UNUSED SpiceMarshaller *", "m2")
|
||||
|
||||
for n in names:
|
||||
writer.assign("*%s_out" % n, "NULL")
|
||||
|
||||
writer.newline()
|
||||
|
||||
if target_type.is_struct():
|
||||
src = RootMarshallingSource(None, target_type.c_type(), target_type.sizeof(), "ptr")
|
||||
src.reuse_scope = scope
|
||||
write_container_marshaller(writer, target_type, src)
|
||||
elif target_type.is_array() and target_type.element_type.is_primitive():
|
||||
with writer.index() as index:
|
||||
with writer.for_loop(index, "count") as array_scope:
|
||||
writer.statement("spice_marshaller_add_%s(m, *ptr++)" % (target_type.element_type.primitive_type()))
|
||||
else:
|
||||
writer.todo("Unsuppored pointer marshaller type")
|
||||
|
||||
writer.end_block()
|
||||
|
||||
return marshal_function
|
||||
|
||||
def get_array_size(array, container_src):
|
||||
if array.is_constant_length():
|
||||
return array.size
|
||||
elif array.is_identifier_length():
|
||||
return container_src.get_ref(array.size)
|
||||
elif array.is_remaining_length():
|
||||
raise NotImplementedError("remaining size array sizes marshalling not supported")
|
||||
elif array.is_image_size_length():
|
||||
bpp = array.size[1]
|
||||
width = array.size[2]
|
||||
rows = array.size[3]
|
||||
width_v = container_src.get_ref(width)
|
||||
rows_v = container_src.get_ref(rows)
|
||||
# TODO: Handle multiplication overflow
|
||||
if bpp == 8:
|
||||
return "(%s * %s)" % (width_v, rows_v)
|
||||
elif bpp == 1:
|
||||
return "(((%s + 7) / 8 ) * %s)" % (width_v, rows_v)
|
||||
else:
|
||||
return "(((%s * %s + 7) / 8 ) * %s)" % (bpp, width_v, rows_v)
|
||||
elif array.is_bytes_length():
|
||||
return container_src.get_ref(array.size[2])
|
||||
else:
|
||||
raise NotImplementedError("TODO array size type not handled yet: %s" % array)
|
||||
|
||||
def write_array_marshaller(writer, member, array, container_src, scope):
|
||||
element_type = array.element_type
|
||||
|
||||
if array.is_remaining_length():
|
||||
writer.comment("Remaining data must be appended manually").newline()
|
||||
return
|
||||
|
||||
nelements = get_array_size(array, container_src)
|
||||
is_byte_size = array.is_bytes_length()
|
||||
|
||||
element = "%s__element" % member.name
|
||||
|
||||
if not scope.variable_defined(element):
|
||||
if array.has_attr("ptr_array"):
|
||||
stars = " **"
|
||||
else:
|
||||
stars = " *"
|
||||
scope.variable_def(element_type.c_type() + stars, element)
|
||||
element_array = element
|
||||
if array.has_attr("ptr_array"):
|
||||
element = "*" + element
|
||||
|
||||
writer.assign(element_array, container_src.get_ref(member.name))
|
||||
|
||||
if is_byte_size:
|
||||
size_start_var = "%s__size_start" % member.name
|
||||
scope.variable_def("size_t", size_start_var)
|
||||
writer.assign(size_start_var, "spice_marshaller_get_size(m)")
|
||||
|
||||
with writer.index() as index:
|
||||
with writer.for_loop(index, nelements) as array_scope:
|
||||
if element_type.is_primitive():
|
||||
writer.statement("spice_marshaller_add_%s(m, *%s)" % (element_type.primitive_type(), element))
|
||||
elif element_type.is_struct():
|
||||
src2 = RootMarshallingSource(container_src, element_type.c_type(), element_type.sizeof(), element)
|
||||
src2.reuse_scope = array_scope
|
||||
write_container_marshaller(writer, element_type, src2)
|
||||
else:
|
||||
writer.todo("array element unhandled type").newline()
|
||||
|
||||
writer.statement("%s++" % element_array)
|
||||
|
||||
if is_byte_size:
|
||||
size_var = member.container.lookup_member(array.size[1])
|
||||
size_var_type = size_var.member_type
|
||||
var = "%s__ref" % array.size[1]
|
||||
writer.statement("spice_marshaller_set_%s(m, %s, spice_marshaller_get_size(m) - %s)" % (size_var_type.primitive_type(), var, size_start_var))
|
||||
|
||||
def write_pointer_marshaller(writer, member, src):
|
||||
t = member.member_type
|
||||
ptr_func = write_marshal_ptr_function(writer, t.target_type)
|
||||
submarshaller = "spice_marshaller_get_ptr_submarshaller(m, %d)" % (1 if member.get_fixed_nw_size() == 8 else 0)
|
||||
if member.has_attr("marshall"):
|
||||
rest_args = ""
|
||||
if t.target_type.is_array():
|
||||
rest_args = ", %s" % get_array_size(t.target_type, src)
|
||||
writer.assign("m2", submarshaller)
|
||||
if t.has_attr("nonnull"):
|
||||
writer.statement("%s(m2, %s%s)" % (ptr_func, src.get_ref(member.name), rest_args))
|
||||
else:
|
||||
with writer.if_block("%s != NULL" % src.get_ref(member.name)) as block:
|
||||
writer.statement("%s(m2, %s%s)" % (ptr_func, src.get_ref(member.name), rest_args))
|
||||
else:
|
||||
writer.assign("*%s_out" % (writer.out_prefix + member.name), submarshaller)
|
||||
|
||||
def write_switch_marshaller(writer, container, switch, src, scope):
|
||||
var = container.lookup_member(switch.variable)
|
||||
var_type = var.member_type
|
||||
|
||||
saved_out_prefix = writer.out_prefix
|
||||
first = True
|
||||
for c in switch.cases:
|
||||
check = c.get_check(src.get_ref(switch.variable), var_type)
|
||||
m = c.member
|
||||
writer.out_prefix = saved_out_prefix
|
||||
if m.has_attr("outvar"):
|
||||
writer.out_prefix = "%s_%s" % (m.attributes["outvar"][0], writer.out_prefix)
|
||||
with writer.if_block(check, not first, False) as block:
|
||||
t = m.member_type
|
||||
if switch.has_attr("anon"):
|
||||
if t.is_struct():
|
||||
src2 = src.child_sub(m)
|
||||
else:
|
||||
src2 = src
|
||||
else:
|
||||
if t.is_struct():
|
||||
src2 = src.child_sub(switch).child_sub(m)
|
||||
else:
|
||||
src2 = src.child_sub(switch)
|
||||
src2.reuse_scope = block
|
||||
|
||||
if t.is_struct():
|
||||
write_container_marshaller(writer, t, src2)
|
||||
elif t.is_pointer():
|
||||
write_pointer_marshaller(writer, m, src2)
|
||||
elif t.is_primitive():
|
||||
if m.has_attr("zero"):
|
||||
writer.statement("spice_marshaller_add_%s(m, 0)" % (t.primitive_type()))
|
||||
else:
|
||||
writer.statement("spice_marshaller_add_%s(m, %s)" % (t.primitive_type(), src2.get_ref(m.name)))
|
||||
#TODO validate e.g. flags and enums
|
||||
elif t.is_array():
|
||||
write_array_marshaller(writer, m, t, src2, scope)
|
||||
else:
|
||||
writer.todo("Can't handle type %s" % m.member_type)
|
||||
|
||||
if switch.has_attr("fixedsize"):
|
||||
remaining = switch.get_fixed_nw_size() - t.get_fixed_nw_size()
|
||||
if remaining != 0:
|
||||
writer.statement("spice_marshaller_reserve_space(m, %s)" % remaining)
|
||||
|
||||
first = False
|
||||
if switch.has_attr("fixedsize"):
|
||||
with writer.block(" else"):
|
||||
writer.statement("spice_marshaller_reserve_space(m, %s)" % switch.get_fixed_nw_size())
|
||||
|
||||
writer.newline()
|
||||
|
||||
def write_member_marshaller(writer, container, member, src, scope):
|
||||
if member.has_attr("outvar"):
|
||||
writer.out_prefix = "%s_%s" % (member.attributes["outvar"][0], writer.out_prefix)
|
||||
if member.has_attr("virtual"):
|
||||
writer.comment("Don't marshall @virtual %s" % member.name).newline()
|
||||
return
|
||||
if member.has_attr("nomarshal"):
|
||||
writer.comment("Don't marshall @nomarshal %s" % member.name).newline()
|
||||
return
|
||||
if member.is_switch():
|
||||
write_switch_marshaller(writer, container, member, src, scope)
|
||||
return
|
||||
|
||||
t = member.member_type
|
||||
|
||||
if t.is_pointer():
|
||||
write_pointer_marshaller(writer, member, src)
|
||||
elif t.is_primitive():
|
||||
if member.has_attr("zero"):
|
||||
writer.statement("spice_marshaller_add_%s(m, 0)" % (t.primitive_type()))
|
||||
if member.has_attr("bytes_count"):
|
||||
var = "%s__ref" % member.name
|
||||
scope.variable_def("void *", var)
|
||||
writer.statement("%s = spice_marshaller_add_%s(m, %s)" % (var, t.primitive_type(), 0))
|
||||
|
||||
else:
|
||||
writer.statement("spice_marshaller_add_%s(m, %s)" % (t.primitive_type(), src.get_ref(member.name)))
|
||||
elif t.is_array():
|
||||
write_array_marshaller(writer, member, t, src, scope)
|
||||
elif t.is_struct():
|
||||
src2 = src.child_sub(member)
|
||||
writer.comment(member.name)
|
||||
write_container_marshaller(writer, t, src2)
|
||||
else:
|
||||
raise NotImplementedError("TODO can't handle parsing of %s" % t)
|
||||
|
||||
def write_container_marshaller(writer, container, src):
|
||||
saved_out_prefix = writer.out_prefix
|
||||
with src.declare(writer) as scope:
|
||||
for m in container.members:
|
||||
writer.out_prefix = saved_out_prefix
|
||||
write_member_marshaller(writer, container, m, src, scope)
|
||||
|
||||
def write_message_marshaller(writer, message, is_server, private):
|
||||
if message.has_attr("ifdef"):
|
||||
writer.ifdef(message.attributes["ifdef"][0])
|
||||
writer.out_prefix = ""
|
||||
function_name = "spice_marshall_" + message.c_name()
|
||||
if writer.is_generated("marshaller", function_name):
|
||||
return function_name
|
||||
writer.set_is_generated("marshaller", function_name)
|
||||
|
||||
names = message.get_pointer_names(False)
|
||||
names_args = ""
|
||||
if len(names) > 0:
|
||||
n = map(lambda name: ", SpiceMarshaller **%s_out" % name, names)
|
||||
names_args = "".join(n)
|
||||
|
||||
if not private:
|
||||
writer.header.writeln("void " + function_name + "(SpiceMarshaller *m, %s *msg" % message.c_type() + names_args + ");")
|
||||
|
||||
scope = writer.function(function_name,
|
||||
"static void" if private else "void",
|
||||
"SpiceMarshaller *m, %s *msg" % message.c_type() + names_args)
|
||||
scope.variable_def("SPICE_GNUC_UNUSED SpiceMarshaller *", "m2")
|
||||
|
||||
for n in names:
|
||||
writer.assign("*%s_out" % n, "NULL")
|
||||
|
||||
# fix warnings about unused variables by not creating body if no members to parse
|
||||
if any(x.is_fixed_nw_size() for x in message.members):
|
||||
src = RootMarshallingSource(None, message.c_type(), message.sizeof(), "msg")
|
||||
src.reuse_scope = scope
|
||||
|
||||
write_container_marshaller(writer, message, src)
|
||||
|
||||
writer.end_block()
|
||||
if message.has_attr("ifdef"):
|
||||
writer.endif(message.attributes["ifdef"][0])
|
||||
writer.newline()
|
||||
return function_name
|
||||
|
||||
def write_protocol_marshaller(writer, proto, is_server, private_marshallers):
|
||||
functions = {}
|
||||
for c in proto.channels:
|
||||
channel = c.channel_type
|
||||
if channel.has_attr("ifdef"):
|
||||
writer.ifdef(channel.attributes["ifdef"][0])
|
||||
if is_server:
|
||||
for m in channel.client_messages:
|
||||
message = m.message_type
|
||||
f = write_message_marshaller(writer, message, is_server, private_marshallers)
|
||||
if channel.has_attr("ifdef") and not functions.has_key(f):
|
||||
functions[f] = channel.attributes["ifdef"][0]
|
||||
elif message.has_attr("ifdef") and not functions.has_key(f):
|
||||
functions[f] = message.attributes["ifdef"][0]
|
||||
else:
|
||||
functions[f] = True
|
||||
else:
|
||||
for m in channel.server_messages:
|
||||
message = m.message_type
|
||||
f = write_message_marshaller(writer, message, is_server, private_marshallers)
|
||||
if channel.has_attr("ifdef") and not functions.has_key(f):
|
||||
functions[f] = channel.attributes["ifdef"][0]
|
||||
elif message.has_attr("ifdef") and not functions.has_key(f):
|
||||
functions[f] = message.attributes["ifdef"][0]
|
||||
else:
|
||||
functions[f] = True
|
||||
if channel.has_attr("ifdef"):
|
||||
writer.endif(channel.attributes["ifdef"][0])
|
||||
|
||||
if private_marshallers:
|
||||
scope = writer.function("spice_message_marshallers_get" + writer.public_prefix,
|
||||
"SpiceMessageMarshallers *",
|
||||
"void")
|
||||
writer.writeln("static SpiceMessageMarshallers marshallers = {NULL};").newline()
|
||||
for f in sorted(functions.keys()):
|
||||
member = f[len("spice_marshall_"):]
|
||||
if not member.startswith("msg"):
|
||||
member = "msg_" + member
|
||||
if functions[f] != True:
|
||||
writer.ifdef(functions[f])
|
||||
writer.assign("marshallers.%s" % member, f)
|
||||
if functions[f] != True:
|
||||
writer.endif(functions[f])
|
||||
|
||||
writer.newline()
|
||||
writer.statement("return &marshallers")
|
||||
writer.end_block()
|
||||
writer.newline()
|
||||
|
||||
def write_trailer(writer):
|
||||
writer.header.writeln("#endif")
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,161 +0,0 @@
|
||||
try:
|
||||
from pyparsing import Literal, CaselessLiteral, Word, OneOrMore, ZeroOrMore, \
|
||||
Forward, delimitedList, Group, Optional, Combine, alphas, nums, restOfLine, cStyleComment, \
|
||||
alphanums, ParseException, ParseResults, Keyword, StringEnd, replaceWith
|
||||
except ImportError:
|
||||
print "Module pyparsing not found."
|
||||
exit(1)
|
||||
|
||||
import ptypes
|
||||
import sys
|
||||
|
||||
cvtInt = lambda toks: int(toks[0])
|
||||
|
||||
def parseVariableDef(toks):
|
||||
t = toks[0][0]
|
||||
pointer = toks[0][1]
|
||||
name = toks[0][2]
|
||||
array_size = toks[0][3]
|
||||
attributes = toks[0][4]
|
||||
|
||||
if array_size != None:
|
||||
t = ptypes.ArrayType(t, array_size)
|
||||
|
||||
if pointer != None:
|
||||
t = ptypes.PointerType(t);
|
||||
|
||||
return ptypes.Member(name, t, attributes)
|
||||
|
||||
bnf = None
|
||||
def SPICE_BNF():
|
||||
global bnf
|
||||
|
||||
if not bnf:
|
||||
|
||||
# punctuation
|
||||
colon = Literal(":").suppress()
|
||||
lbrace = Literal("{").suppress()
|
||||
rbrace = Literal("}").suppress()
|
||||
lbrack = Literal("[").suppress()
|
||||
rbrack = Literal("]").suppress()
|
||||
lparen = Literal("(").suppress()
|
||||
rparen = Literal(")").suppress()
|
||||
equals = Literal("=").suppress()
|
||||
comma = Literal(",").suppress()
|
||||
semi = Literal(";").suppress()
|
||||
|
||||
# primitive types
|
||||
int8_ = Keyword("int8").setParseAction(replaceWith(ptypes.int8))
|
||||
uint8_ = Keyword("uint8").setParseAction(replaceWith(ptypes.uint8))
|
||||
int16_ = Keyword("int16").setParseAction(replaceWith(ptypes.int16))
|
||||
uint16_ = Keyword("uint16").setParseAction(replaceWith(ptypes.uint16))
|
||||
int32_ = Keyword("int32").setParseAction(replaceWith(ptypes.int32))
|
||||
uint32_ = Keyword("uint32").setParseAction(replaceWith(ptypes.uint32))
|
||||
int64_ = Keyword("int64").setParseAction(replaceWith(ptypes.int64))
|
||||
uint64_ = Keyword("uint64").setParseAction(replaceWith(ptypes.uint64))
|
||||
|
||||
# keywords
|
||||
channel_ = Keyword("channel")
|
||||
enum32_ = Keyword("enum32").setParseAction(replaceWith(32))
|
||||
enum16_ = Keyword("enum16").setParseAction(replaceWith(16))
|
||||
enum8_ = Keyword("enum8").setParseAction(replaceWith(8))
|
||||
flags32_ = Keyword("flags32").setParseAction(replaceWith(32))
|
||||
flags16_ = Keyword("flags16").setParseAction(replaceWith(16))
|
||||
flags8_ = Keyword("flags8").setParseAction(replaceWith(8))
|
||||
channel_ = Keyword("channel")
|
||||
server_ = Keyword("server")
|
||||
client_ = Keyword("client")
|
||||
protocol_ = Keyword("protocol")
|
||||
typedef_ = Keyword("typedef")
|
||||
struct_ = Keyword("struct")
|
||||
message_ = Keyword("message")
|
||||
image_size_ = Keyword("image_size")
|
||||
bytes_ = Keyword("bytes")
|
||||
cstring_ = Keyword("cstring")
|
||||
switch_ = Keyword("switch")
|
||||
default_ = Keyword("default")
|
||||
case_ = Keyword("case")
|
||||
|
||||
identifier = Word( alphas, alphanums + "_" )
|
||||
enumname = Word( alphanums + "_" )
|
||||
|
||||
integer = ( Combine( CaselessLiteral("0x") + Word( nums+"abcdefABCDEF" ) ) |
|
||||
Word( nums+"+-", nums ) ).setName("int").setParseAction(cvtInt)
|
||||
|
||||
typename = identifier.copy().setParseAction(lambda toks : ptypes.TypeRef(str(toks[0])))
|
||||
|
||||
# This is just normal "types", i.e. not channels or messages
|
||||
typeSpec = Forward()
|
||||
|
||||
attributeValue = integer ^ identifier
|
||||
attribute = Group(Combine ("@" + identifier) + Optional(lparen + delimitedList(attributeValue) + rparen))
|
||||
attributes = Group(ZeroOrMore(attribute))
|
||||
arraySizeSpecImage = Group(image_size_ + lparen + integer + comma + identifier + comma + identifier + rparen)
|
||||
arraySizeSpecBytes = Group(bytes_ + lparen + identifier + comma + identifier + rparen)
|
||||
arraySizeSpecCString = Group(cstring_ + lparen + rparen)
|
||||
arraySizeSpec = lbrack + Optional(identifier ^ integer ^ arraySizeSpecImage ^ arraySizeSpecBytes ^arraySizeSpecCString, default="") + rbrack
|
||||
variableDef = Group(typeSpec + Optional("*", default=None) + identifier + Optional(arraySizeSpec, default=None) + attributes - semi) \
|
||||
.setParseAction(parseVariableDef)
|
||||
|
||||
switchCase = Group(Group(OneOrMore(default_.setParseAction(replaceWith(None)) + colon | Group(case_.suppress() + Optional("!", default="") + identifier) + colon)) + variableDef) \
|
||||
.setParseAction(lambda toks: ptypes.SwitchCase(toks[0][0], toks[0][1]))
|
||||
switchBody = Group(switch_ + lparen + delimitedList(identifier,delim='.', combine=True) + rparen + lbrace + Group(OneOrMore(switchCase)) + rbrace + identifier + attributes - semi) \
|
||||
.setParseAction(lambda toks: ptypes.Switch(toks[0][1], toks[0][2], toks[0][3], toks[0][4]))
|
||||
messageBody = structBody = Group(lbrace + ZeroOrMore(variableDef | switchBody) + rbrace)
|
||||
structSpec = Group(struct_ + identifier + structBody + attributes).setParseAction(lambda toks: ptypes.StructType(toks[0][1], toks[0][2], toks[0][3]))
|
||||
|
||||
# have to use longest match for type, in case a user-defined type name starts with a keyword type, like "channel_type"
|
||||
typeSpec << ( structSpec ^ int8_ ^ uint8_ ^ int16_ ^ uint16_ ^
|
||||
int32_ ^ uint32_ ^ int64_ ^ uint64_ ^
|
||||
typename).setName("type")
|
||||
|
||||
flagsBody = enumBody = Group(lbrace + delimitedList(Group (enumname + Optional(equals + integer))) + Optional(comma) + rbrace)
|
||||
|
||||
messageSpec = Group(message_ + messageBody + attributes).setParseAction(lambda toks: ptypes.MessageType(None, toks[0][1], toks[0][2])) | typename
|
||||
|
||||
channelParent = Optional(colon + typename, default=None)
|
||||
channelMessage = Group(messageSpec + identifier + Optional(equals + integer, default=None) + semi) \
|
||||
.setParseAction(lambda toks: ptypes.ChannelMember(toks[0][1], toks[0][0], toks[0][2]))
|
||||
channelBody = channelParent + Group(lbrace + ZeroOrMore( server_ + colon | client_ + colon | channelMessage) + rbrace)
|
||||
|
||||
enum_ = (enum32_ | enum16_ | enum8_)
|
||||
flags_ = (flags32_ | flags16_ | flags8_)
|
||||
enumDef = Group(enum_ + identifier + enumBody + attributes - semi).setParseAction(lambda toks: ptypes.EnumType(toks[0][0], toks[0][1], toks[0][2], toks[0][3]))
|
||||
flagsDef = Group(flags_ + identifier + flagsBody + attributes - semi).setParseAction(lambda toks: ptypes.FlagsType(toks[0][0], toks[0][1], toks[0][2], toks[0][3]))
|
||||
messageDef = Group(message_ + identifier + messageBody + attributes - semi).setParseAction(lambda toks: ptypes.MessageType(toks[0][1], toks[0][2], toks[0][3]))
|
||||
channelDef = Group(channel_ + identifier + channelBody + attributes - semi).setParseAction(lambda toks: ptypes.ChannelType(toks[0][1], toks[0][2], toks[0][3], toks[0][4]))
|
||||
structDef = Group(struct_ + identifier + structBody + attributes - semi).setParseAction(lambda toks: ptypes.StructType(toks[0][1], toks[0][2], toks[0][3]))
|
||||
typedefDef = Group(typedef_ + identifier + typeSpec + attributes - semi).setParseAction(lambda toks: ptypes.TypeAlias(toks[0][1], toks[0][2], toks[0][3]))
|
||||
|
||||
definitions = typedefDef | structDef | enumDef | flagsDef | messageDef | channelDef
|
||||
|
||||
protocolChannel = Group(typename + identifier + Optional(equals + integer, default=None) + semi) \
|
||||
.setParseAction(lambda toks: ptypes.ProtocolMember(toks[0][1], toks[0][0], toks[0][2]))
|
||||
protocolDef = Group(protocol_ + identifier + Group(lbrace + ZeroOrMore(protocolChannel) + rbrace) + semi) \
|
||||
.setParseAction(lambda toks: ptypes.ProtocolType(toks[0][1], toks[0][2]))
|
||||
|
||||
bnf = ZeroOrMore (definitions) + protocolDef + StringEnd()
|
||||
|
||||
singleLineComment = "//" + restOfLine
|
||||
bnf.ignore( singleLineComment )
|
||||
bnf.ignore( cStyleComment )
|
||||
|
||||
return bnf
|
||||
|
||||
|
||||
def parse(filename):
|
||||
try:
|
||||
bnf = SPICE_BNF()
|
||||
types = bnf.parseFile(filename)
|
||||
except ParseException, err:
|
||||
print >> sys.stderr, err.line
|
||||
print >> sys.stderr, " "*(err.column-1) + "^"
|
||||
print >> sys.stderr, err
|
||||
return None
|
||||
|
||||
for t in types:
|
||||
t.resolve()
|
||||
t.register()
|
||||
protocol = types[-1]
|
||||
return protocol
|
||||
|
||||
1
spice-common
Submodule
1
spice-common
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit fb24e4e28bad0b0e2bb670deb9fb56223be49ada
|
||||
@ -1 +0,0 @@
|
||||
Subproject commit 32da251a6572e3463cff040d106bb47a04e5a905
|
||||
1205
spice.proto
1205
spice.proto
File diff suppressed because it is too large
Load Diff
934
spice1.proto
934
spice1.proto
@ -1,934 +0,0 @@
|
||||
/* built in types:
|
||||
int8, uint8, 16, 32, 64
|
||||
*/
|
||||
|
||||
typedef fixed28_4 int32 @ctype(SPICE_FIXED28_4);
|
||||
|
||||
struct Point {
|
||||
int32 x;
|
||||
int32 y;
|
||||
};
|
||||
|
||||
struct Point16 {
|
||||
int16 x;
|
||||
int16 y;
|
||||
};
|
||||
|
||||
struct PointFix {
|
||||
fixed28_4 x;
|
||||
fixed28_4 y;
|
||||
};
|
||||
|
||||
struct Rect {
|
||||
int32 top;
|
||||
int32 left;
|
||||
int32 bottom;
|
||||
int32 right;
|
||||
};
|
||||
|
||||
enum32 link_err {
|
||||
OK,
|
||||
ERROR,
|
||||
INVALID_MAGIC,
|
||||
INVALID_DATA,
|
||||
VERSION_MISMATCH,
|
||||
NEED_SECURED,
|
||||
NEED_UNSECURED,
|
||||
PERMISSION_DENIED,
|
||||
BAD_CONNECTION_ID,
|
||||
CHANNEL_NOT_AVAILABLE
|
||||
};
|
||||
|
||||
enum32 warn_code {
|
||||
WARN_GENERAL
|
||||
} @prefix(SPICE_);
|
||||
|
||||
enum32 info_code {
|
||||
INFO_GENERAL
|
||||
} @prefix(SPICE_);
|
||||
|
||||
flags32 migrate_flags {
|
||||
NEED_FLUSH,
|
||||
NEED_DATA_TRANSFER
|
||||
} @prefix(SPICE_MIGRATE_);
|
||||
|
||||
enum32 notify_severity {
|
||||
INFO,
|
||||
WARN,
|
||||
ERROR,
|
||||
};
|
||||
|
||||
enum32 notify_visibility {
|
||||
LOW,
|
||||
MEDIUM,
|
||||
HIGH,
|
||||
};
|
||||
|
||||
flags32 mouse_mode {
|
||||
SERVER,
|
||||
CLIENT,
|
||||
};
|
||||
|
||||
enum16 pubkey_type {
|
||||
INVALID,
|
||||
RSA,
|
||||
RSA2,
|
||||
DSA,
|
||||
DSA1,
|
||||
DSA2,
|
||||
DSA3,
|
||||
DSA4,
|
||||
DH,
|
||||
EC,
|
||||
};
|
||||
|
||||
message Empty {
|
||||
};
|
||||
|
||||
message Data {
|
||||
uint8 data[] @end @ctype(uint8_t);
|
||||
} @nocopy;
|
||||
|
||||
struct ChannelWait {
|
||||
uint8 channel_type;
|
||||
uint8 channel_id;
|
||||
uint64 message_serial;
|
||||
} @ctype(SpiceWaitForChannel);
|
||||
|
||||
channel BaseChannel {
|
||||
server:
|
||||
message {
|
||||
migrate_flags flags;
|
||||
} migrate;
|
||||
|
||||
Data migrate_data;
|
||||
|
||||
message {
|
||||
uint32 generation;
|
||||
uint32 window;
|
||||
} set_ack;
|
||||
|
||||
message {
|
||||
uint32 id;
|
||||
uint64 timestamp;
|
||||
uint8 data[] @ctype(uint8_t) @as_ptr(data_len);
|
||||
} ping;
|
||||
|
||||
message {
|
||||
uint8 wait_count;
|
||||
ChannelWait wait_list[wait_count] @end;
|
||||
} wait_for_channels;
|
||||
|
||||
message {
|
||||
uint64 time_stamp;
|
||||
link_err reason;
|
||||
} @ctype(SpiceMsgDisconnect) disconnecting;
|
||||
|
||||
message {
|
||||
uint64 time_stamp;
|
||||
notify_severity severity;
|
||||
notify_visibility visibilty;
|
||||
uint32 what; /* error_code/warn_code/info_code */
|
||||
uint32 message_len;
|
||||
uint8 message[message_len] @end @nomarshal;
|
||||
uint8 zero @end @ctype(uint8_t) @nomarshal;
|
||||
} notify;
|
||||
|
||||
client:
|
||||
message {
|
||||
uint32 generation;
|
||||
} ack_sync;
|
||||
|
||||
Empty ack;
|
||||
|
||||
message {
|
||||
uint32 id;
|
||||
uint64 timestamp;
|
||||
} @ctype(SpiceMsgPing) pong;
|
||||
|
||||
Empty migrate_flush_mark;
|
||||
|
||||
Data migrate_data;
|
||||
|
||||
message {
|
||||
uint64 time_stamp;
|
||||
link_err reason;
|
||||
} @ctype(SpiceMsgDisconnect) disconnecting;
|
||||
};
|
||||
|
||||
struct ChannelId {
|
||||
uint8 type;
|
||||
uint8 id;
|
||||
};
|
||||
|
||||
channel MainChannel : BaseChannel {
|
||||
server:
|
||||
message {
|
||||
uint16 port;
|
||||
uint16 sport;
|
||||
uint32 host_offset @zero;
|
||||
uint32 host_size;
|
||||
pubkey_type pub_key_type @minor(1);
|
||||
uint32 pub_key_offset @minor(1) @zero;
|
||||
uint32 pub_key_size @minor(1);
|
||||
uint8 host_data[host_size] @as_ptr @zero_terminated;
|
||||
uint8 pub_key_data[pub_key_size] @minor(1) @as_ptr @zero_terminated;
|
||||
} @ctype(SpiceMsgMainMigrationBegin) migrate_begin = 101;
|
||||
|
||||
Empty migrate_cancel;
|
||||
|
||||
message {
|
||||
uint32 session_id;
|
||||
uint32 display_channels_hint;
|
||||
uint32 supported_mouse_modes;
|
||||
uint32 current_mouse_mode;
|
||||
uint32 agent_connected;
|
||||
uint32 agent_tokens;
|
||||
uint32 multi_media_time;
|
||||
uint32 ram_hint;
|
||||
} init;
|
||||
|
||||
message {
|
||||
uint32 num_of_channels;
|
||||
ChannelId channels[num_of_channels] @end;
|
||||
} @ctype(SpiceMsgChannels) channels_list;
|
||||
|
||||
message {
|
||||
mouse_mode supported_modes;
|
||||
mouse_mode current_mode @unique_flag;
|
||||
} mouse_mode;
|
||||
|
||||
message {
|
||||
uint32 time;
|
||||
} @ctype(SpiceMsgMainMultiMediaTime) multi_media_time;
|
||||
|
||||
Empty agent_connected;
|
||||
|
||||
message {
|
||||
link_err error_code;
|
||||
} @ctype(SpiceMsgMainAgentDisconnect) agent_disconnected;
|
||||
|
||||
Data agent_data;
|
||||
|
||||
message {
|
||||
uint32 num_tokens;
|
||||
} @ctype(SpiceMsgMainAgentTokens) agent_token;
|
||||
|
||||
message {
|
||||
uint16 port;
|
||||
uint16 sport;
|
||||
uint32 host_offset @zero;
|
||||
uint32 host_size;
|
||||
uint32 cert_subject_offset @zero;
|
||||
uint32 cert_subject_size;
|
||||
uint8 host_data[host_size] @as_ptr @zero_terminated;
|
||||
uint8 cert_subject_data[cert_subject_size] @as_ptr @zero_terminated;
|
||||
} @ctype(SpiceMsgMainMigrationSwitchHost) migrate_switch_host;
|
||||
|
||||
client:
|
||||
message {
|
||||
uint64 cache_size;
|
||||
} @ctype(SpiceMsgcClientInfo) client_info = 101;
|
||||
|
||||
Empty migrate_connected;
|
||||
|
||||
Empty migrate_connect_error;
|
||||
|
||||
Empty attach_channels;
|
||||
|
||||
message {
|
||||
mouse_mode mode;
|
||||
} mouse_mode_request;
|
||||
|
||||
message {
|
||||
uint32 num_tokens;
|
||||
} agent_start;
|
||||
|
||||
Data agent_data;
|
||||
|
||||
message {
|
||||
uint32 num_tokens;
|
||||
} @ctype(SpiceMsgcMainAgentTokens) agent_token;
|
||||
};
|
||||
|
||||
enum32 clip_type {
|
||||
NONE,
|
||||
RECTS
|
||||
};
|
||||
|
||||
flags32 path_flags { /* TODO: C enum names changes */
|
||||
BEGIN = 0,
|
||||
END = 1,
|
||||
CLOSE = 3,
|
||||
BEZIER = 4,
|
||||
} @prefix(SPICE_PATH_);
|
||||
|
||||
enum32 video_codec_type {
|
||||
MJPEG = 1,
|
||||
};
|
||||
|
||||
flags32 stream_flags {
|
||||
TOP_DOWN = 0,
|
||||
};
|
||||
|
||||
enum32 brush_type {
|
||||
NONE,
|
||||
SOLID,
|
||||
PATTERN,
|
||||
};
|
||||
|
||||
flags8 mask_flags {
|
||||
INVERS,
|
||||
};
|
||||
|
||||
enum8 image_type {
|
||||
BITMAP,
|
||||
QUIC,
|
||||
RESERVED,
|
||||
LZ_PLT = 100,
|
||||
LZ_RGB,
|
||||
GLZ_RGB,
|
||||
FROM_CACHE,
|
||||
};
|
||||
|
||||
flags8 image_flags {
|
||||
CACHE_ME,
|
||||
};
|
||||
|
||||
enum8 bitmap_fmt {
|
||||
INVALID,
|
||||
1BIT_LE,
|
||||
1BIT_BE,
|
||||
4BIT_LE,
|
||||
4BIT_BE,
|
||||
8BIT /* 8bit indexed mode */,
|
||||
16BIT, /* 0555 mode */
|
||||
24BIT /* 3 byte, brg */,
|
||||
32BIT /* 4 byte, xrgb in little endian format */,
|
||||
RGBA /* 4 byte, argb in little endian format */
|
||||
};
|
||||
|
||||
flags8 bitmap_flags {
|
||||
PAL_CACHE_ME,
|
||||
PAL_FROM_CACHE,
|
||||
TOP_DOWN,
|
||||
};
|
||||
|
||||
enum8 image_scale_mode {
|
||||
INTERPOLATE,
|
||||
NEAREST,
|
||||
};
|
||||
|
||||
flags16 ropd {
|
||||
INVERS_SRC,
|
||||
INVERS_BRUSH,
|
||||
INVERS_DEST,
|
||||
OP_PUT,
|
||||
OP_OR,
|
||||
OP_AND,
|
||||
OP_XOR,
|
||||
OP_BLACKNESS,
|
||||
OP_WHITENESS,
|
||||
OP_INVERS,
|
||||
INVERS_RES,
|
||||
};
|
||||
|
||||
flags8 line_flags {
|
||||
STYLED = 3,
|
||||
START_WITH_GAP = 2,
|
||||
};
|
||||
|
||||
enum8 line_cap {
|
||||
ROUND,
|
||||
SQUARE,
|
||||
BUTT,
|
||||
};
|
||||
|
||||
enum8 line_join {
|
||||
ROUND,
|
||||
BEVEL,
|
||||
MITER,
|
||||
};
|
||||
|
||||
flags16 string_flags {
|
||||
RASTER_A1,
|
||||
RASTER_A4,
|
||||
RASTER_A8,
|
||||
RASTER_TOP_DOWN,
|
||||
};
|
||||
|
||||
enum8 resource_type {
|
||||
INVALID,
|
||||
PIXMAP
|
||||
} @prefix(SPICE_RES_TYPE_);
|
||||
|
||||
struct ClipRects {
|
||||
uint32 num_rects;
|
||||
Rect rects[num_rects] @end;
|
||||
};
|
||||
|
||||
struct PathSegment {
|
||||
path_flags flags;
|
||||
uint32 count;
|
||||
PointFix points[count] @end;
|
||||
} @ctype(SpicePathSeg);
|
||||
|
||||
struct Path {
|
||||
uint32 segments_size @bytes_count(num_segments);
|
||||
PathSegment segments[bytes(segments_size, num_segments)] @ptr_array;
|
||||
};
|
||||
|
||||
struct Clip {
|
||||
clip_type type;
|
||||
switch (type) {
|
||||
case RECTS:
|
||||
ClipRects *rects @outvar(cliprects);
|
||||
default:
|
||||
uint64 data @zero;
|
||||
} u @anon;
|
||||
};
|
||||
|
||||
struct DisplayBase {
|
||||
uint32 surface_id @virtual(0);
|
||||
Rect box;
|
||||
Clip clip;
|
||||
} @ctype(SpiceMsgDisplayBase);
|
||||
|
||||
struct ResourceID {
|
||||
uint8 type;
|
||||
uint64 id;
|
||||
};
|
||||
|
||||
struct WaitForChannel {
|
||||
uint8 channel_type;
|
||||
uint8 channel_id;
|
||||
uint64 message_serial;
|
||||
};
|
||||
|
||||
struct Palette {
|
||||
uint64 unique;
|
||||
uint16 num_ents;
|
||||
uint32 ents[num_ents] @end;
|
||||
};
|
||||
|
||||
struct BitmapData {
|
||||
bitmap_fmt format;
|
||||
bitmap_flags flags;
|
||||
uint32 x;
|
||||
uint32 y;
|
||||
uint32 stride;
|
||||
switch (flags) {
|
||||
case PAL_FROM_CACHE:
|
||||
uint64 palette_id;
|
||||
default:
|
||||
Palette *palette @outvar(bitmap);
|
||||
} pal @anon;
|
||||
uint8 *data[image_size(8, stride, y)] @chunk; /* pointer to array, not array of pointers as in C */
|
||||
} @ctype(SpiceBitmap);
|
||||
|
||||
struct BinaryData {
|
||||
uint32 data_size;
|
||||
uint8 data[data_size] @nomarshal @chunk;
|
||||
} @ctype(SpiceQUICData);
|
||||
|
||||
struct LZPLTData {
|
||||
bitmap_flags flags;
|
||||
uint32 data_size;
|
||||
switch (flags) {
|
||||
case PAL_FROM_CACHE:
|
||||
uint64 palette_id;
|
||||
default:
|
||||
Palette *palette @nonnull @outvar(lzplt);
|
||||
} pal @anon;
|
||||
uint8 data[data_size] @nomarshal @chunk;
|
||||
};
|
||||
|
||||
struct Image {
|
||||
struct ImageDescriptor {
|
||||
uint64 id;
|
||||
image_type type;
|
||||
image_flags flags;
|
||||
uint32 width;
|
||||
uint32 height;
|
||||
} descriptor;
|
||||
|
||||
switch (descriptor.type) {
|
||||
case BITMAP:
|
||||
BitmapData bitmap;
|
||||
case QUIC:
|
||||
BinaryData quic;
|
||||
case LZ_RGB:
|
||||
case GLZ_RGB:
|
||||
BinaryData lz_rgb;
|
||||
case LZ_PLT:
|
||||
LZPLTData lz_plt;
|
||||
} u;
|
||||
};
|
||||
|
||||
struct Pattern {
|
||||
Image *pat @nonnull;
|
||||
Point pos;
|
||||
};
|
||||
|
||||
struct Brush {
|
||||
brush_type type;
|
||||
switch (type) {
|
||||
case SOLID:
|
||||
uint32 color;
|
||||
case PATTERN:
|
||||
Pattern pattern;
|
||||
} u @fixedsize;
|
||||
};
|
||||
|
||||
struct QMask {
|
||||
mask_flags flags;
|
||||
Point pos;
|
||||
Image *bitmap;
|
||||
};
|
||||
|
||||
struct LineAttr {
|
||||
line_flags flags;
|
||||
line_join join_style @zero;
|
||||
line_cap end_style @zero;
|
||||
uint8 style_nseg;
|
||||
fixed28_4 width @zero;
|
||||
fixed28_4 miter_limit @zero;
|
||||
fixed28_4 *style[style_nseg];
|
||||
};
|
||||
|
||||
struct RasterGlyphA1 {
|
||||
Point render_pos;
|
||||
Point glyph_origin;
|
||||
uint16 width;
|
||||
uint16 height;
|
||||
uint8 data[image_size(1, width, height)] @end;
|
||||
} @ctype(SpiceRasterGlyph);
|
||||
|
||||
struct RasterGlyphA4 {
|
||||
Point render_pos;
|
||||
Point glyph_origin;
|
||||
uint16 width;
|
||||
uint16 height;
|
||||
uint8 data[image_size(4, width, height)] @end;
|
||||
} @ctype(SpiceRasterGlyph);
|
||||
|
||||
struct RasterGlyphA8 {
|
||||
Point render_pos;
|
||||
Point glyph_origin;
|
||||
uint16 width;
|
||||
uint16 height;
|
||||
uint8 data[image_size(8, width, height)] @end;
|
||||
} @ctype(SpiceRasterGlyph);
|
||||
|
||||
struct String {
|
||||
uint16 length;
|
||||
string_flags flags; /* Special: Only one of a1/a4/a8 set */
|
||||
switch (flags) {
|
||||
case RASTER_A1:
|
||||
RasterGlyphA1 glyphs[length] @ctype(SpiceRasterGlyph) @ptr_array;
|
||||
case RASTER_A4:
|
||||
RasterGlyphA4 glyphs[length] @ctype(SpiceRasterGlyph) @ptr_array;
|
||||
case RASTER_A8:
|
||||
RasterGlyphA8 glyphs[length] @ctype(SpiceRasterGlyph) @ptr_array;
|
||||
} u @anon;
|
||||
};
|
||||
|
||||
channel DisplayChannel : BaseChannel {
|
||||
server:
|
||||
message {
|
||||
uint32 x_res;
|
||||
uint32 y_res;
|
||||
uint32 bits;
|
||||
} mode = 101;
|
||||
|
||||
Empty mark;
|
||||
Empty reset;
|
||||
|
||||
message {
|
||||
DisplayBase base;
|
||||
Point src_pos;
|
||||
} copy_bits;
|
||||
|
||||
message {
|
||||
uint16 count;
|
||||
ResourceID resources[count] @end;
|
||||
} @ctype(SpiceResourceList) inval_list;
|
||||
|
||||
message {
|
||||
uint8 wait_count;
|
||||
WaitForChannel wait_list[wait_count] @end;
|
||||
} @ctype(SpiceMsgWaitForChannels) inval_all_pixmaps;
|
||||
|
||||
message {
|
||||
uint64 id;
|
||||
} @ctype(SpiceMsgDisplayInvalOne) inval_palette;
|
||||
|
||||
Empty inval_all_palettes;
|
||||
|
||||
message {
|
||||
uint32 surface_id @virtual(0);
|
||||
uint32 id;
|
||||
stream_flags flags;
|
||||
video_codec_type codec_type;
|
||||
uint64 stamp;
|
||||
uint32 stream_width;
|
||||
uint32 stream_height;
|
||||
uint32 src_width;
|
||||
uint32 src_height;
|
||||
Rect dest;
|
||||
Clip clip;
|
||||
} stream_create = 122;
|
||||
|
||||
message {
|
||||
uint32 id;
|
||||
uint32 multi_media_time;
|
||||
uint32 data_size;
|
||||
uint32 pad_size @zero;
|
||||
uint8 data[data_size] @end @nomarshal;
|
||||
/* Ignore: uint8 padding[pad_size] */
|
||||
} stream_data;
|
||||
|
||||
message {
|
||||
uint32 id;
|
||||
Clip clip;
|
||||
} stream_clip;
|
||||
|
||||
message {
|
||||
uint32 id;
|
||||
} stream_destroy;
|
||||
|
||||
Empty stream_destroy_all;
|
||||
|
||||
message {
|
||||
DisplayBase base;
|
||||
struct Fill {
|
||||
Brush brush @outvar(brush);
|
||||
uint16 rop_descriptor;
|
||||
QMask mask @outvar(mask);
|
||||
} data;
|
||||
} draw_fill = 302;
|
||||
|
||||
message {
|
||||
DisplayBase base;
|
||||
struct Opaque {
|
||||
Image *src_bitmap;
|
||||
Rect src_area;
|
||||
Brush brush;
|
||||
ropd rop_descriptor;
|
||||
image_scale_mode scale_mode;
|
||||
QMask mask @outvar(mask);
|
||||
} data;
|
||||
} draw_opaque;
|
||||
|
||||
message {
|
||||
DisplayBase base;
|
||||
struct Copy {
|
||||
Image *src_bitmap;
|
||||
Rect src_area;
|
||||
ropd rop_descriptor;
|
||||
image_scale_mode scale_mode;
|
||||
QMask mask @outvar(mask);
|
||||
} data;
|
||||
} draw_copy;
|
||||
|
||||
message {
|
||||
DisplayBase base;
|
||||
struct Blend {
|
||||
Image *src_bitmap;
|
||||
Rect src_area;
|
||||
ropd rop_descriptor;
|
||||
image_scale_mode scale_mode;
|
||||
QMask mask @outvar(mask);
|
||||
} @ctype(SpiceCopy) data;
|
||||
} draw_blend;
|
||||
|
||||
message {
|
||||
DisplayBase base;
|
||||
struct Blackness {
|
||||
QMask mask @outvar(mask);
|
||||
} data;
|
||||
} draw_blackness;
|
||||
|
||||
message {
|
||||
DisplayBase base;
|
||||
struct Whiteness {
|
||||
QMask mask @outvar(mask);
|
||||
} data;
|
||||
} draw_whiteness;
|
||||
|
||||
message {
|
||||
DisplayBase base;
|
||||
struct Invers {
|
||||
QMask mask @outvar(mask);
|
||||
} data;
|
||||
} draw_invers;
|
||||
|
||||
message {
|
||||
DisplayBase base;
|
||||
struct Rop3 {
|
||||
Image *src_bitmap;
|
||||
Rect src_area;
|
||||
Brush brush;
|
||||
uint8 rop3;
|
||||
image_scale_mode scale_mode;
|
||||
QMask mask @outvar(mask);
|
||||
} data;
|
||||
} draw_rop3;
|
||||
|
||||
message {
|
||||
DisplayBase base;
|
||||
struct Stroke {
|
||||
Path *path;
|
||||
LineAttr attr;
|
||||
Brush brush;
|
||||
uint16 fore_mode;
|
||||
uint16 back_mode;
|
||||
} data;
|
||||
} draw_stroke;
|
||||
|
||||
message {
|
||||
DisplayBase base;
|
||||
struct Text {
|
||||
String *str;
|
||||
Rect back_area;
|
||||
Brush fore_brush @outvar(fore_brush);
|
||||
Brush back_brush @outvar(back_brush);
|
||||
uint16 fore_mode;
|
||||
uint16 back_mode;
|
||||
} data;
|
||||
} draw_text;
|
||||
|
||||
message {
|
||||
DisplayBase base;
|
||||
struct Transparent {
|
||||
Image *src_bitmap;
|
||||
Rect src_area;
|
||||
uint32 src_color;
|
||||
uint32 true_color;
|
||||
} data;
|
||||
} draw_transparent;
|
||||
|
||||
message {
|
||||
DisplayBase base;
|
||||
struct AlphaBlend {
|
||||
int8 alpha_flags @virtual(0);
|
||||
uint8 alpha;
|
||||
Image *src_bitmap;
|
||||
Rect src_area;
|
||||
} data;
|
||||
} draw_alpha_blend;
|
||||
|
||||
client:
|
||||
message {
|
||||
uint8 pixmap_cache_id;
|
||||
int64 pixmap_cache_size; //in pixels
|
||||
uint8 glz_dictionary_id;
|
||||
int32 glz_dictionary_window_size; // in pixels
|
||||
} init = 101;
|
||||
};
|
||||
|
||||
flags32 keyboard_modifier_flags {
|
||||
SCROLL_LOCK,
|
||||
NUM_LOCK,
|
||||
CAPS_LOCK
|
||||
};
|
||||
|
||||
enum32 mouse_button {
|
||||
INVALID,
|
||||
LEFT,
|
||||
MIDDLE,
|
||||
RIGHT,
|
||||
UP,
|
||||
DOWN,
|
||||
};
|
||||
|
||||
flags32 mouse_button_mask {
|
||||
LEFT,
|
||||
MIDDLE,
|
||||
RIGHT
|
||||
};
|
||||
|
||||
channel InputsChannel : BaseChannel {
|
||||
client:
|
||||
message {
|
||||
uint32 code;
|
||||
} @ctype(SpiceMsgcKeyDown) key_down = 101;
|
||||
|
||||
message {
|
||||
uint32 code;
|
||||
} @ctype(SpiceMsgcKeyUp) key_up;
|
||||
|
||||
message {
|
||||
keyboard_modifier_flags modifiers;
|
||||
} @ctype(SpiceMsgcKeyModifiers) key_modifiers;
|
||||
|
||||
message {
|
||||
int32 dx;
|
||||
int32 dy;
|
||||
mouse_button_mask buttons_state;
|
||||
} @ctype(SpiceMsgcMouseMotion) mouse_motion = 111;
|
||||
|
||||
message {
|
||||
uint32 x;
|
||||
uint32 y;
|
||||
mouse_button_mask buttons_state;
|
||||
uint8 display_id;
|
||||
} @ctype(SpiceMsgcMousePosition) mouse_position;
|
||||
|
||||
message {
|
||||
mouse_button button;
|
||||
mouse_button_mask buttons_state;
|
||||
} @ctype(SpiceMsgcMousePress) mouse_press;
|
||||
|
||||
message {
|
||||
mouse_button button;
|
||||
mouse_button_mask buttons_state;
|
||||
} @ctype(SpiceMsgcMouseRelease) mouse_release;
|
||||
|
||||
server:
|
||||
message {
|
||||
keyboard_modifier_flags keyboard_modifiers;
|
||||
} init = 101;
|
||||
|
||||
message {
|
||||
keyboard_modifier_flags modifiers;
|
||||
} key_modifiers;
|
||||
|
||||
Empty mouse_motion_ack = 111;
|
||||
};
|
||||
|
||||
enum16 cursor_type {
|
||||
ALPHA,
|
||||
MONO,
|
||||
COLOR4,
|
||||
COLOR8,
|
||||
COLOR16,
|
||||
COLOR24,
|
||||
COLOR32,
|
||||
};
|
||||
|
||||
flags32 cursor_flags {
|
||||
NONE, /* Means no cursor */
|
||||
CACHE_ME,
|
||||
FROM_CACHE,
|
||||
};
|
||||
|
||||
struct CursorHeader {
|
||||
uint64 unique;
|
||||
cursor_type type;
|
||||
uint16 width;
|
||||
uint16 height;
|
||||
uint16 hot_spot_x;
|
||||
uint16 hot_spot_y;
|
||||
};
|
||||
|
||||
struct Cursor {
|
||||
cursor_flags flags;
|
||||
CursorHeader header;
|
||||
uint8 data[] @as_ptr(data_size);
|
||||
};
|
||||
|
||||
channel CursorChannel : BaseChannel {
|
||||
server:
|
||||
message {
|
||||
Point16 position;
|
||||
uint16 trail_length;
|
||||
uint16 trail_frequency;
|
||||
uint8 visible;
|
||||
Cursor cursor;
|
||||
} init = 101;
|
||||
|
||||
Empty reset;
|
||||
|
||||
message {
|
||||
Point16 position;
|
||||
uint8 visible;
|
||||
Cursor cursor;
|
||||
} set;
|
||||
|
||||
message {
|
||||
Point16 position;
|
||||
} move;
|
||||
|
||||
Empty hide;
|
||||
|
||||
message {
|
||||
uint16 length;
|
||||
uint16 frequency;
|
||||
} trail;
|
||||
|
||||
message {
|
||||
uint64 id;
|
||||
} @ctype(SpiceMsgDisplayInvalOne) inval_one;
|
||||
|
||||
Empty inval_all;
|
||||
};
|
||||
|
||||
enum32 audio_data_mode {
|
||||
INVALID,
|
||||
RAW,
|
||||
CELT_0_5_1,
|
||||
};
|
||||
|
||||
enum32 audio_fmt {
|
||||
INVALID,
|
||||
S16,
|
||||
};
|
||||
|
||||
channel PlaybackChannel : BaseChannel {
|
||||
server:
|
||||
message {
|
||||
uint32 time;
|
||||
uint8 data[] @as_ptr(data_size);
|
||||
} @ctype(SpiceMsgPlaybackPacket) data = 101;
|
||||
|
||||
message {
|
||||
uint32 time;
|
||||
audio_data_mode mode;
|
||||
uint8 data[] @as_ptr(data_size);
|
||||
} mode;
|
||||
|
||||
message {
|
||||
uint32 channels;
|
||||
audio_fmt format;
|
||||
uint32 frequency;
|
||||
uint32 time;
|
||||
} start;
|
||||
|
||||
Empty stop;
|
||||
};
|
||||
|
||||
channel RecordChannel : BaseChannel {
|
||||
server:
|
||||
message {
|
||||
uint32 channels;
|
||||
audio_fmt format;
|
||||
uint32 frequency;
|
||||
} start = 101;
|
||||
|
||||
Empty stop;
|
||||
client:
|
||||
message {
|
||||
uint32 time;
|
||||
uint8 data[] @nomarshal @as_ptr(data_size);
|
||||
} @ctype(SpiceMsgcRecordPacket) data = 101;
|
||||
|
||||
message {
|
||||
uint32 time;
|
||||
audio_data_mode mode;
|
||||
uint8 data[] @as_ptr(data_size);
|
||||
} mode;
|
||||
|
||||
message {
|
||||
uint32 time;
|
||||
} start_mark;
|
||||
};
|
||||
|
||||
protocol Spice {
|
||||
MainChannel main = 1;
|
||||
DisplayChannel display;
|
||||
InputsChannel inputs;
|
||||
CursorChannel cursor;
|
||||
PlaybackChannel playback;
|
||||
RecordChannel record;
|
||||
};
|
||||
211
spice_codegen.py
211
spice_codegen.py
@ -1,211 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from optparse import OptionParser
|
||||
import traceback
|
||||
from python_modules import spice_parser
|
||||
from python_modules import ptypes
|
||||
from python_modules import codegen
|
||||
from python_modules import demarshal
|
||||
from python_modules import marshal
|
||||
|
||||
def write_channel_enums(writer, channel, client):
|
||||
messages = filter(lambda m : m.channel == channel, \
|
||||
channel.client_messages if client else channel.server_messages)
|
||||
if len(messages) == 0:
|
||||
return
|
||||
writer.begin_block("enum")
|
||||
i = 0;
|
||||
if client:
|
||||
prefix = [ "MSGC" ]
|
||||
else:
|
||||
prefix = [ "MSG" ]
|
||||
if channel.member_name:
|
||||
prefix.append(channel.member_name.upper())
|
||||
prefix.append(None) # To be replaced with name
|
||||
for m in messages:
|
||||
prefix[-1] = m.name.upper()
|
||||
enum = codegen.prefix_underscore_upper(*prefix)
|
||||
if m.value == i:
|
||||
writer.writeln("%s," % enum)
|
||||
i = i + 1
|
||||
else:
|
||||
writer.writeln("%s = %s," % (enum, m.value))
|
||||
i = m.value + 1
|
||||
if channel.member_name:
|
||||
prefix[-1] = prefix[-2]
|
||||
prefix[-2] = "END"
|
||||
writer.newline()
|
||||
writer.writeln("%s" % (codegen.prefix_underscore_upper(*prefix)))
|
||||
writer.end_block(semicolon=True)
|
||||
writer.newline()
|
||||
|
||||
def write_enums(writer):
|
||||
writer.writeln("#ifndef _H_SPICE_ENUMS")
|
||||
writer.writeln("#define _H_SPICE_ENUMS")
|
||||
writer.newline()
|
||||
writer.comment("Generated from %s, don't edit" % writer.options["source"]).newline()
|
||||
writer.newline()
|
||||
|
||||
# Define enums
|
||||
for t in ptypes.get_named_types():
|
||||
if isinstance(t, ptypes.EnumBaseType):
|
||||
t.c_define(writer)
|
||||
|
||||
i = 0;
|
||||
writer.begin_block("enum")
|
||||
for c in proto.channels:
|
||||
enum = codegen.prefix_underscore_upper("CHANNEL", c.name.upper())
|
||||
if c.value == i:
|
||||
writer.writeln("%s," % enum)
|
||||
i = i + 1
|
||||
else:
|
||||
writer.writeln("%s = %s," % (enum, c.value))
|
||||
i = c.value + 1
|
||||
writer.newline()
|
||||
writer.writeln("SPICE_END_CHANNEL")
|
||||
writer.end_block(semicolon=True)
|
||||
writer.newline()
|
||||
|
||||
for c in ptypes.get_named_types():
|
||||
if not isinstance(c, ptypes.ChannelType):
|
||||
continue
|
||||
write_channel_enums(writer, c, False)
|
||||
write_channel_enums(writer, c, True)
|
||||
|
||||
writer.writeln("#endif /* _H_SPICE_ENUMS */")
|
||||
|
||||
parser = OptionParser(usage="usage: %prog [options] <protocol_file> <destination file>")
|
||||
parser.add_option("-e", "--generate-enums",
|
||||
action="store_true", dest="generate_enums", default=False,
|
||||
help="Generate enums")
|
||||
parser.add_option("-d", "--generate-demarshallers",
|
||||
action="store_true", dest="generate_demarshallers", default=False,
|
||||
help="Generate demarshallers")
|
||||
parser.add_option("-m", "--generate-marshallers",
|
||||
action="store_true", dest="generate_marshallers", default=False,
|
||||
help="Generate message marshallers")
|
||||
parser.add_option("-P", "--private-marshallers",
|
||||
action="store_true", dest="private_marshallers", default=False,
|
||||
help="Generate private message marshallers")
|
||||
parser.add_option("-M", "--generate-struct-marshaller",
|
||||
action="append", dest="struct_marshallers",
|
||||
help="Generate struct marshallers")
|
||||
parser.add_option("-a", "--assert-on-error",
|
||||
action="store_true", dest="assert_on_error", default=False,
|
||||
help="Assert on error")
|
||||
parser.add_option("-H", "--header",
|
||||
action="store_true", dest="header", default=False,
|
||||
help="Generate header")
|
||||
parser.add_option("-p", "--print-error",
|
||||
action="store_true", dest="print_error", default=False,
|
||||
help="Print errors")
|
||||
parser.add_option("-s", "--server",
|
||||
action="store_true", dest="server", default=False,
|
||||
help="Print errors")
|
||||
parser.add_option("-c", "--client",
|
||||
action="store_true", dest="client", default=False,
|
||||
help="Print errors")
|
||||
parser.add_option("-k", "--keep-identical-file",
|
||||
action="store_true", dest="keep_identical_file", default=False,
|
||||
help="Print errors")
|
||||
parser.add_option("-i", "--include",
|
||||
action="append", dest="includes", metavar="FILE",
|
||||
help="Include FILE in generated code")
|
||||
parser.add_option("--prefix", dest="prefix",
|
||||
help="set public symbol prefix", default="")
|
||||
parser.add_option("--ptrsize", dest="ptrsize",
|
||||
help="set default pointer size", default="4")
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if len(args) == 0:
|
||||
parser.error("No protocol file specified")
|
||||
|
||||
if len(args) == 1:
|
||||
parser.error("No destination file specified")
|
||||
|
||||
ptypes.default_pointer_size = int(options.ptrsize)
|
||||
|
||||
proto_file = args[0]
|
||||
dest_file = args[1]
|
||||
proto = spice_parser.parse(proto_file)
|
||||
|
||||
if proto == None:
|
||||
exit(1)
|
||||
|
||||
codegen.set_prefix(proto.name)
|
||||
writer = codegen.CodeWriter()
|
||||
writer.header = codegen.CodeWriter()
|
||||
writer.set_option("source", os.path.basename(proto_file))
|
||||
|
||||
writer.public_prefix = options.prefix
|
||||
|
||||
if options.assert_on_error:
|
||||
writer.set_option("assert_on_error")
|
||||
|
||||
if options.print_error:
|
||||
writer.set_option("print_error")
|
||||
|
||||
if options.includes:
|
||||
for i in options.includes:
|
||||
writer.writeln('#include "%s"' % i)
|
||||
|
||||
if options.generate_enums:
|
||||
write_enums(writer)
|
||||
|
||||
if options.generate_demarshallers:
|
||||
if not options.server and not options.client:
|
||||
print >> sys.stderr, "Must specify client and/or server"
|
||||
sys.exit(1)
|
||||
demarshal.write_includes(writer)
|
||||
|
||||
if options.server:
|
||||
demarshal.write_protocol_parser(writer, proto, False)
|
||||
if options.client:
|
||||
demarshal.write_protocol_parser(writer, proto, True)
|
||||
|
||||
if options.generate_marshallers or (options.struct_marshallers and len(options.struct_marshallers) > 0):
|
||||
marshal.write_includes(writer)
|
||||
|
||||
if options.generate_marshallers:
|
||||
if not options.server and not options.client:
|
||||
print >> sys.stderr, "Must specify client and/or server"
|
||||
sys.exit(1)
|
||||
if options.server:
|
||||
marshal.write_protocol_marshaller(writer, proto, False, options.private_marshallers)
|
||||
if options.client:
|
||||
marshal.write_protocol_marshaller(writer, proto, True, options.private_marshallers)
|
||||
|
||||
if options.struct_marshallers:
|
||||
for structname in options.struct_marshallers:
|
||||
t = ptypes.lookup_type(structname)
|
||||
marshal.write_marshal_ptr_function(writer, t)
|
||||
|
||||
if options.generate_marshallers or (options.struct_marshallers and len(options.struct_marshallers) > 0):
|
||||
marshal.write_trailer(writer)
|
||||
|
||||
if options.header:
|
||||
content = writer.header.getvalue()
|
||||
else:
|
||||
content = writer.getvalue()
|
||||
if options.keep_identical_file:
|
||||
try:
|
||||
f = open(dest_file, 'rb')
|
||||
old_content = f.read()
|
||||
f.close()
|
||||
|
||||
if content == old_content:
|
||||
print "No changes to %s" % dest_file
|
||||
sys.exit(0)
|
||||
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
f = open(dest_file, 'wb')
|
||||
f.write(content)
|
||||
f.close()
|
||||
|
||||
print "Wrote %s" % dest_file
|
||||
sys.exit(0)
|
||||
Loading…
Reference in New Issue
Block a user