[vala/wip/transform: 200/200] Merge branch 'master' into wip/transform
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/transform: 200/200] Merge branch 'master' into wip/transform
- Date: Sat, 24 Sep 2016 17:44:15 +0000 (UTC)
commit 65f6633bddf5486b52752b46bee3cc530072cce5
Merge: 1b717f1 472b282
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Sep 24 19:43:38 2016 +0200
Merge branch 'master' into wip/transform
Makefile.am | 3 +-
NEWS | 22 +
README | 2 +-
codegen/valaccodeattribute.vala | 15 +-
codegen/valaccodebasemodule.vala | 61 +-
codegen/valaccodedelegatemodule.vala | 2 +-
codegen/valaccodemethodmodule.vala | 5 +-
codegen/valaccodestructmodule.vala | 4 +-
codegen/valagdbusclientmodule.vala | 2 +-
codegen/valagdbusclienttransformer.vala | 9 +-
codegen/valagdbusmodule.vala | 4 +
codegen/valagirwriter.vala | 11 +-
codegen/valagsignalmodule.vala | 2 +-
codegen/valagtypemodule.vala | 6 +-
compiler/valacompiler.vala | 9 +-
configure.ac | 12 +-
doc/valac.1 | 3 +
tests/Makefile.am | 7 +
tests/asynchronous/bug659886.vala | 14 +
tests/basic-types/arrays.vala | 74 +
tests/basic-types/bug648364.vala | 2 +-
tests/basic-types/bug761307.vala | 12 +
tests/basic-types/bug771626.test | 7 +
tests/basic-types/escape-chars.vala | 10 +
tests/control-flow/nested-conditional.vala | 8 +
tests/enums/bug763831.vala | 13 +
tests/objects/bug767092.test | 8 +
tests/objects/bug768823.test | 11 +
tests/testrunner.sh | 12 +-
vala/Makefile.am | 1 +
vala/valaarraycreationexpression.vala | 2 -
vala/valaassignment.vala | 8 +
vala/valaattribute.vala | 8 +
vala/valaclass.vala | 7 +-
vala/valacodecontext.vala | 13 +-
vala/valacodewriter.vala | 20 +
vala/valadelegatetype.vala | 2 +-
vala/valagenieparser.vala | 5 +
vala/valagirparser.vala | 58 +-
vala/valainterface.vala | 1 +
vala/valalambdaexpression.vala | 3 +-
vala/valamemberaccess.vala | 3 +-
vala/valaobjectcreationexpression.vala | 2 +-
vala/valaobjecttype.vala | 6 +
vala/valaparser.vala | 4 +
vala/valascanner.vala | 3 +
vala/valasourcefile.vala | 64 +
vala/valasymbol.vala | 109 +--
vala/valatokentype.vala | 2 +
vala/valatypeparameter.vala | 12 +-
vala/valausedattr.vala | 5 +-
vala/valaversionattribute.vala | 231 +++
vapi/Makefile.am | 26 +
vapi/atk.vapi | 234 ++--
vapi/atspi-2.vapi | 41 +-
vapi/cairo-xcb.vapi | 2 +-
vapi/cairo.vapi | 1427 ++++++++----------
vapi/clutter-1.0.vapi | 1564 +++++++++++++++-----
vapi/clutter-gdk-1.0.vapi | 7 +
vapi/clutter-gst-1.0.vapi | 10 +-
vapi/clutter-gst-2.0.vapi | 13 +-
vapi/clutter-gst-3.0.vapi | 59 +-
vapi/clutter-gtk-1.0.vapi | 7 +-
vapi/clutter-x11-1.0.vapi | 33 +-
vapi/cogl-pango-1.0.vapi | 13 +-
vapi/gconf-2.0.vapi | 2 +-
vapi/gdk-2.0.vapi | 112 +-
vapi/gdk-3.0.vapi | 762 +++++++++-
vapi/gdk-pixbuf-2.0.vapi | 72 +-
vapi/gdk-x11-2.0.vapi | 2 +-
vapi/gdk-x11-3.0.vapi | 104 +-
vapi/gdl-3.0.vapi | 59 +-
vapi/gedit-2.20.vapi | 2 +-
vapi/gedit.vapi | 30 +-
vapi/geocode-glib-1.0.vapi | 3 +-
vapi/gio-2.0.vapi | 1357 ++++++++++++++----
vapi/gio-unix-2.0.vapi | 3 +-
vapi/gio-windows-2.0.deps | 1 +
vapi/gio-windows-2.0.vapi | 23 +
vapi/glib-2.0.vapi | 750 ++++++++--
vapi/gnet-2.0.vapi | 10 +-
vapi/gnome-keyring-1.vapi | 2 +-
vapi/gobject-2.0.vapi | 1127 +++++++-------
vapi/gobject-introspection-1.0.vapi | 13 +-
vapi/goocanvas.vapi | 2 +-
vapi/graphene-1.0.deps | 1 +
vapi/graphene-1.0.vapi | 581 ++++++++
vapi/gstreamer-0.10.vapi | 49 +-
vapi/gstreamer-1.0.vapi | 450 ++++++-
vapi/gstreamer-allocators-1.0.vapi | 11 +-
vapi/gstreamer-app-0.10.vapi | 1 +
vapi/gstreamer-app-1.0.vapi | 16 +
vapi/gstreamer-audio-0.10.vapi | 3 +-
vapi/gstreamer-audio-1.0.vapi | 208 +++-
vapi/gstreamer-base-0.10.vapi | 9 +-
vapi/gstreamer-base-1.0.vapi | 60 +-
vapi/gstreamer-cdda-0.10.vapi | 1 +
vapi/gstreamer-check-0.10.vapi | 1 +
vapi/gstreamer-check-1.0.vapi | 22 +-
vapi/gstreamer-controller-0.10.vapi | 7 +-
vapi/gstreamer-controller-1.0.vapi | 19 +-
vapi/gstreamer-dataprotocol-0.10.vapi | 1 +
vapi/gstreamer-fft-0.10.vapi | 1 +
vapi/gstreamer-interfaces-0.10.vapi | 1 +
vapi/gstreamer-net-0.10.vapi | 1 +
vapi/gstreamer-net-1.0.vapi | 22 +-
vapi/gstreamer-netbuffer-0.10.vapi | 1 +
vapi/gstreamer-pbutils-0.10.vapi | 1 +
vapi/gstreamer-pbutils-1.0.vapi | 67 +-
vapi/gstreamer-player-1.0.deps | 2 +
vapi/gstreamer-player-1.0.vapi | 209 +++
vapi/gstreamer-riff-0.10.vapi | 1 +
vapi/gstreamer-rtp-0.10.vapi | 1 +
vapi/gstreamer-rtp-1.0.vapi | 61 +-
vapi/gstreamer-rtsp-0.10.vapi | 1 +
vapi/gstreamer-rtsp-1.0.vapi | 22 +-
vapi/gstreamer-sdp-0.10.vapi | 1 +
vapi/gstreamer-sdp-1.0.vapi | 114 ++-
vapi/gstreamer-tag-0.10.vapi | 1 +
vapi/gstreamer-tag-1.0.vapi | 4 +
vapi/gstreamer-video-0.10.vapi | 1 +
vapi/gstreamer-video-1.0.vapi | 233 +++-
vapi/gtk+-2.0.vapi | 230 ++--
vapi/gtk+-3.0.vapi | 992 +++++++------
vapi/gtksourceview-3.0.vapi | 283 ++++-
vapi/gudev-1.0.vapi | 4 +
vapi/json-glib-1.0.vapi | 150 ++-
vapi/libarchive.vapi | 28 +-
vapi/libbonoboui-2.0.vapi | 2 +-
vapi/libesmtp.vapi | 98 +-
vapi/libgda-4.0.vapi | 2 +-
vapi/libgda-report-4.0.vapi | 2 +-
vapi/libgdata.vapi | 947 +++++++++++-
vapi/libglade-2.0.vapi | 2 +-
vapi/libnl-3.0.vapi | 39 +
vapi/libnotify.vapi | 16 +-
vapi/libpanelapplet-2.0.vapi | 2 +-
vapi/libpeas-1.0.vapi | 9 +
vapi/libpeas-gtk-1.0.vapi | 6 +-
vapi/librsvg-2.0.vapi | 70 +-
vapi/libsoup-2.2.vapi | 2 +-
vapi/libsoup-2.4.vapi | 483 +++++--
vapi/libwnck-1.0.vapi | 2 +-
vapi/libwnck-3.0.vapi | 83 +-
vapi/libxml-2.0.vapi | 4 +-
vapi/linux.vapi | 16 +-
vapi/lua.vapi | 2 +-
vapi/metadata/Atk-1.0-custom.vala | 69 +-
vapi/metadata/Clutter-1.0-custom.vala | 4 +-
vapi/metadata/ClutterGst-2.0.metadata | 5 +-
vapi/metadata/ClutterGst-3.0.metadata | 5 +-
vapi/metadata/Gdk-3.0-custom.vala | 19 +-
vapi/metadata/Gdk-3.0.metadata | 5 +
vapi/metadata/GdkPixbuf-2.0-custom.vala | 4 +-
vapi/metadata/GdkX11-3.0-custom.vala | 56 +-
vapi/metadata/Gio-2.0-custom.vala | 350 ++---
vapi/metadata/Gio-2.0.metadata | 48 +-
vapi/metadata/Graphene-1.0.metadata | 29 +
vapi/metadata/Gst-1.0.metadata | 7 +-
vapi/metadata/GstBase-1.0.metadata | 4 +
vapi/metadata/GstController-1.0.metadata | 7 +-
vapi/metadata/GstPlayer-1.0.metadata | 6 +
vapi/metadata/GtkClutter-1.0-custom.vala | 4 +-
vapi/metadata/Json-1.0.metadata | 11 +-
vapi/metadata/Mx-1.0-custom.vala | 64 +-
vapi/metadata/Pango-1.0-custom.vala | 20 +-
vapi/metadata/Polkit-1.0.metadata | 1 +
vapi/metadata/PolkitAgent-1.0.metadata | 1 +
vapi/metadata/Rsvg-2.0-custom.vala | 26 +-
vapi/metadata/Soup-2.4-custom.vala | 54 +-
vapi/metadata/WebKit2WebExtension-4.0.metadata | 2 +
vapi/mx-1.0.vapi | 230 +++-
vapi/packagekit-glib2.vapi | 576 +++++++-
vapi/packages/gdk-2.0/gdk-2.0-custom.vala | 16 +-
vapi/packages/gio-unix-2.0/gio-unix-2.0.metadata | 2 +-
.../gstreamer-0.10/gstreamer-0.10-custom.vala | 2 +-
.../gstreamer-0.10/gstreamer-0.10.metadata | 2 +-
.../gstreamer-app-0.10/gstreamer-app-0.10.metadata | 2 +-
.../gstreamer-audio-0.10.metadata | 2 +-
.../gstreamer-base-0.10.metadata | 2 +-
.../gstreamer-cdda-0.10.metadata | 2 +-
.../gstreamer-check-0.10.metadata | 4 +-
.../gstreamer-controller-0.10.metadata | 2 +-
.../gstreamer-dataprotocol-0.10.metadata | 2 +-
.../gstreamer-fft-0.10/gstreamer-fft-0.10.metadata | 2 +-
.../gstreamer-interfaces-0.10.metadata | 2 +-
.../gstreamer-net-0.10/gstreamer-net-0.10.metadata | 2 +-
.../gstreamer-netbuffer-0.10.metadata | 2 +-
.../gstreamer-pbutils-0.10.metadata | 2 +-
.../gstreamer-riff-0.10.metadata | 2 +-
.../gstreamer-rtp-0.10/gstreamer-rtp-0.10.metadata | 2 +-
.../gstreamer-rtsp-0.10.metadata | 2 +-
.../gstreamer-sdp-0.10/gstreamer-sdp-0.10.metadata | 4 +-
.../gstreamer-tag-0.10/gstreamer-tag-0.10.metadata | 2 +-
.../gstreamer-video-0.10.metadata | 2 +-
vapi/packages/gtk+-2.0/gtk+-2.0-custom.vala | 218 ++--
vapi/packages/gtk+-2.0/gtk+-2.0.metadata | 4 +
vapi/packages/gtk+-3.0/gtk+-3.0-custom.vala | 294 +++--
vapi/packages/gtk+-3.0/gtk+-3.0.gi | 431 +++++-
vapi/packages/gtk+-3.0/gtk+-3.0.metadata | 256 +++-
vapi/pango.vapi | 226 +++-
vapi/pangocairo.vapi | 29 +-
vapi/polkit-agent-1.deps | 2 +
vapi/polkit-agent-1.vapi | 43 +
vapi/polkit-gobject-1.deps | 1 +
vapi/polkit-gobject-1.vapi | 222 +++
vapi/poppler-glib.vapi | 195 +++-
vapi/posix.vapi | 13 +-
vapi/rest-0.6.vapi | 4 +-
vapi/rest-0.7.vapi | 10 +-
vapi/rest-extras-0.7.vapi | 2 +-
vapi/sqlite3.vapi | 12 +-
vapi/udisks2.vapi | 49 +-
vapi/vte-2.90.vapi | 70 +
vapi/vte.vapi | 2 +-
vapi/webkit2gtk-4.0.vapi | 205 +++-
vapi/webkit2gtk-web-extension-4.0.vapi | 245 +++-
vapi/xcb-icccm.vapi | 2 +-
vapi/xcb.vapi | 14 +-
vapigen/Makefile.am | 2 +-
vapigen/valagidlparser.vala | 135 +-
vapigen/valavapigen.vala | 1 +
222 files changed, 14342 insertions(+), 4464 deletions(-)
---
diff --cc codegen/valaccodebasemodule.vala
index 04cca4c,0e3a606..0cf7c79
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@@ -459,18 -470,15 +468,14 @@@ public abstract class Vala.CCodeBaseMod
gquark_type = new IntegerType ((Struct) glib_ns.scope.lookup ("Quark"));
gvalue_type = (Struct) glib_ns.scope.lookup ("Value");
- gvariant_type = (Class) glib_ns.scope.lookup ("Variant");
gsource_type = (Class) glib_ns.scope.lookup ("Source");
- if (context.require_glib_version (2, 32)) {
- gmutex_type = (Struct) glib_ns.scope.lookup ("Mutex");
- grecmutex_type = (Struct) glib_ns.scope.lookup ("RecMutex");
- grwlock_type = (Struct) glib_ns.scope.lookup ("RWLock");
- gcond_type = (Struct) glib_ns.scope.lookup ("Cond");
+ gmutex_type = (Struct) glib_ns.scope.lookup ("Mutex");
+ grecmutex_type = (Struct) glib_ns.scope.lookup ("RecMutex");
+ grwlock_type = (Struct) glib_ns.scope.lookup ("RWLock");
+ gcond_type = (Struct) glib_ns.scope.lookup ("Cond");
- mutex_type = grecmutex_type;
- } else {
- mutex_type = (Struct) glib_ns.scope.lookup ("StaticRecMutex");
- }
+ mutex_type = grecmutex_type;
type_module_type = (TypeSymbol) glib_ns.scope.lookup ("TypeModule");
diff --cc codegen/valagdbusclientmodule.vala
index cef9b35,7ec2387..04d8041
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@@ -35,7 -55,7 +35,7 @@@ public class Vala.GDBusClientModule : G
push_function (func);
if (dynamic_method.dynamic_type.data_type == dbus_proxy_type) {
- //generate_marshalling (method, CallType.SYNC, null, method.name);
- generate_marshalling (method, CallType.SYNC, null, method.name, -1);
++ //generate_marshalling (method, CallType.SYNC, null, method.name, -1);
} else {
Report.error (method.source_reference, "dynamic methods are not supported for
`%s'".printf (dynamic_method.dynamic_type.to_string ()));
}
diff --cc codegen/valagdbusclienttransformer.vala
index fb584a3,0000000..bb2a205
mode 100644,000000..100644
--- a/codegen/valagdbusclienttransformer.vala
+++ b/codegen/valagdbusclienttransformer.vala
@@@ -1,395 -1,0 +1,396 @@@
+/* valagdbusclienttransformer.vala
+ *
+ * Copyright (C) 2011 Luca Bruno
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Luca Bruno <lucabru src gnome org>
+ */
+
+/**
+ * Code visitor for transforming the code tree related to DBus clients.
+ */
+public class Vala.GDBusClientTransformer : GVariantTransformer {
+ public static bool is_dbus_no_reply (Method m) {
+ return m.get_attribute_bool ("DBus", "no_reply");
+ }
+
+ public static string? get_dbus_name (TypeSymbol symbol) {
+ return symbol.get_attribute_string ("DBus", "name");
+ }
+
+ public static string get_dbus_name_for_member (Symbol symbol) {
+ var dbus_name = symbol.get_attribute_string ("DBus", "name");
+ if (dbus_name != null) {
+ return dbus_name;
+ }
+
+ return Symbol.lower_case_to_camel_case (symbol.name);
+ }
+
+ public Expression read_dbus_value (DataType type, string iter, string message, ref string? fd_list,
ref string? fd_index) {
+ string? type_name = null;
+ if (type.data_type != null) {
+ type_name = type.data_type.get_full_name ();
+ }
+ if (type_name == "GLib.UnixInputStream" || type_name == "GLib.UnixOutputStream" || type_name
== "GLib.Socket") {
+ if (fd_list == null) {
+ fd_list = b.add_temp_declaration (data_type ("GLib.UnixFDList"), null);
+ fd_index = b.add_temp_declaration (null, expression ("0"));
+ statements (@"$fd_list = $message.get_unix_fd_list ();");
+ }
+ statements (@"$iter.next (\"h\", out $fd_index);");
+ if (type_name == "GLib.UnixInputStream") {
+ return expression (@"new GLib.UnixInputStream ($fd_list.get ($fd_index),
true)");
+ } else if (type_name == "GLib.UnixInputStream") {
+ return expression (@"new GLib.UnixOutputStream ($fd_list.get ($fd_index),
true)");
+ } else {
+ // socket
+ return expression (@"new GLib.Socket.from_fd ($fd_list.get ($fd_index))");
+ }
+ } else if (type_name == "GLib.Variant") {
+ return expression (@"$iter.next_value ().get_variant ()");
+ } else {
+ return expression (@"($type) ($iter.next_value ())");
+ }
+ }
+
+ public void write_dbus_value (DataType type, string builder, string value, ref string? fd_list) {
+ string? type_name = null;
+ if (type is ObjectType) {
+ type_name = type.data_type.get_full_name ();
+ }
+ if (type_name == "GLib.Cancellable" || type_name == "GLib.BusName") {
+ return;
+ }
+ if (type_name == "GLib.UnixInputStream" || type_name == "GLib.UnixOutputStream" || type_name
== "GLib.Socket") {
+ if (fd_list == null) {
+ fd_list = b.add_temp_declaration (null, expression ("new GLib.UnixFDList
()"));
+ }
+ statements (@"$builder.add (\"h\", $fd_list.append ($value.get_fd ()));");
+ } else if (type_name == "GLib.Variant") {
+ statements (@"$builder.add (\"v\", $value);");
+ } else {
+ statements (@"$builder.add_value ($value);");
+ }
+ }
+
- void generate_marshalling (Method m, string? iface_name, string? method_name) {
++ void generate_marshalling (Method m, string? iface_name, string? method_name, int method_timeout) {
+ var interface_name = iface_name != null ? @"\"$iface_name\"" : "this.get_interface_name ()";
+
+ // create the message
+ var reply = b.add_temp_declaration (data_type ("GLib.DBusMessage"));
+ var message = b.add_temp_declaration (null, expression (@"new GLib.DBusMessage.method_call
(this.get_name (), this.get_object_path (), $interface_name, \"$method_name\")"));
+ var builder = b.add_temp_declaration (null, expression (@"new GLib.VariantBuilder
(GLib.VariantType.TUPLE)"));
+
+ // fill the message
+ bool has_result = m.has_result;
+ string cancellable = "null";
+ string fd_list = null;
+ foreach (var param in m.get_parameters ()) {
+ if (param.direction == ParameterDirection.IN) {
+ if (param.variable_type is ObjectType &&
param.variable_type.data_type.get_full_name () == "GLib.Cancellable") {
+ cancellable = param.name;
+ }
+ write_dbus_value (param.variable_type, builder, param.name, ref fd_list);
+ } else if (param.direction == ParameterDirection.OUT) {
+ has_result = true;
+ }
+ }
+ statements (@"$message.set_body ($builder.end ());");
+ if (fd_list != null) {
+ statements (@"$message.set_unix_fd_list ($fd_list);");
+ }
+
+ // send the message
+ if (is_dbus_no_reply (m)) {
+ statements (@"this.get_connection ().send_message ($message,
GLib.DBusSendMessageFlags.NO_REPLY_EXPECTED, null);");
+ } else {
+ var yield_str = m.coroutine ? "yield " : "";
+ var method_str = m.coroutine ? "send_message_with_reply" :
"send_message_with_reply_sync";
- statements (@"$reply = $yield_str this.get_connection ().$method_str ($message,
GLib.DBusSendMessageFlags.NONE, this.get_default_timeout (), null, $cancellable);");
++ var timeout_str = method_timeout > 0 ? @"$method_timeout" : "this.get_default_timeout
()";
++ statements (@"$reply = $yield_str this.get_connection ().$method_str ($message,
GLib.DBusSendMessageFlags.NONE, $timeout_str, null, $cancellable);");
+
+ statements (@"$reply.to_gerror ();");
+ }
+
+ // deserialize the result
+ fd_list = null;
+ string fd_index = null;
+ if (has_result) {
+ var iter = b.add_temp_declaration (data_type ("GLib.VariantIter"));
+ statements (@"$iter = $reply.get_body ().iterator ();");
+ foreach (var param in m.get_parameters ()) {
+ if (param.direction == ParameterDirection.OUT) {
+ b.add_assignment (expression (param.name), read_dbus_value
(param.variable_type, iter, reply, ref fd_list, ref fd_index));
+ }
+ }
+ if (m.has_result) {
+ b.add_return (read_dbus_value (m.return_type, iter, reply, ref fd_list, ref
fd_index));
+ }
+ }
+ }
+
+ void generate_dbus_proxy_method (Class proxy_class, Interface iface, Method m) {
+ var proxy = new Method (m.name, m.return_type.copy(), m.source_reference);
+ foreach (var param in m.get_parameters ()) {
+ proxy.add_parameter (param.copy ());
+ }
+ proxy.access = m.access;
+ proxy.binding = m.binding;
+ proxy.coroutine = m.coroutine;
+ var error_types = new ArrayList<DataType> ();
+ m.get_error_types (error_types);
+ foreach (var error_type in error_types) {
+ proxy.add_error_type (error_type);
+ }
+ proxy_class.add_method (proxy);
+
+ push_builder (new CodeBuilder.for_subroutine (proxy));
+ string dbus_iface_name = get_dbus_name (iface);
- generate_marshalling (m, dbus_iface_name, get_dbus_name_for_member (m));
++ generate_marshalling (m, dbus_iface_name, get_dbus_name_for_member (m),
GDBusModule.get_dbus_timeout_for_member (m));
+ pop_builder ();
+ }
+
+ void generate_dbus_proxy_methods (Class proxy_class, Interface iface) {
+ // also generate proxy for prerequisites
+ foreach (var prereq in iface.get_prerequisites ()) {
+ if (prereq.data_type is Interface) {
+ generate_dbus_proxy_methods (proxy_class, (Interface) prereq.data_type);
+ }
+ }
+
+ foreach (var m in iface.get_methods ()) {
+ if (!m.is_abstract) {
+ continue;
+ }
+
+ generate_dbus_proxy_method (proxy_class, iface, m);
+ }
+ }
+
+ string generate_dbus_proxy_signal (Class proxy_class, Signal sig, ObjectTypeSymbol sym) {
+ var m = new Method (temp_func_cname (), new VoidType (), sig.source_reference);
+ m.access = SymbolAccessibility.PRIVATE;
+ m.add_parameter (new Parameter ("parameters", data_type ("GLib.Variant", false),
sig.source_reference));
+ proxy_class.add_method (m);
+ push_builder (new CodeBuilder.for_subroutine (m));
+
+ var iter = b.add_temp_declaration (null, expression ("parameters.iterator ()"));
+ var call = new MethodCall (expression (sig.name), sig.source_reference);
+ foreach (var param in sig.get_parameters ()) {
+ var temp = b.add_temp_declaration (copy_type (param.variable_type, true));
+ if (is_gvariant_type (param.variable_type)) {
+ statements (@"$temp = $iter.next_value ().get_variant ();");
+ } else {
+ statements (@"$temp = ($(param.variable_type)) ($iter.next_value ());");
+ }
+ call.add_argument (expression (temp));
+ }
+ b.add_expression (call);
+
+ pop_builder ();
+ return m.name;
+ }
+
+ void generate_dbus_proxy_signals (Class proxy_class, ObjectTypeSymbol sym) {
+ var g_signal = (Signal) symbol_from_string ("GLib.DBusProxy.g_signal");
+ var m = new Method ("g_signal", g_signal.return_type.copy(), sym.source_reference);
+ m.overrides = true;
+ m.access = SymbolAccessibility.PUBLIC;
+ foreach (var param in g_signal.get_parameters ()) {
+ m.add_parameter (param.copy ());
+ }
+ proxy_class.add_method (m);
+
+ push_builder (new CodeBuilder.for_subroutine (m));
+
+ b.open_switch (expression ("signal_name"), null);
+ statements ("GLib.assert_not_reached ();");
+ b.add_break ();
+ foreach (var sig in sym.get_signals ()) {
+ if (sig.access != SymbolAccessibility.PUBLIC) {
+ continue;
+ }
+
+ b.add_section (expression (@"\"$(get_dbus_name_for_member (sig))\""));
+ var handler_name = generate_dbus_proxy_signal (proxy_class, sig, sym);
+ statements (@"$handler_name (parameters);");
+ b.add_break ();
+ }
+ b.close ();
+ pop_builder ();
+ }
+
+ public int get_dbus_timeout (Symbol symbol) {
+ int timeout = -1;
+
+ var dbus = symbol.get_attribute ("DBus");
+ if (dbus != null && dbus.has_argument ("timeout")) {
+ timeout = dbus.get_integer ("timeout");
+ } else if (symbol.parent_symbol != null) {
+ return get_dbus_timeout (symbol.parent_symbol);
+ }
+
+ return timeout;
+ }
+
+ void generate_dbus_proxy_property (Class proxy_class, Interface iface, Property prop) {
+ int timeout = get_dbus_timeout (prop);
+ var dbus_name = get_dbus_name_for_member (prop);
+ var dbus_iface_name = get_dbus_name (iface);
+
+ PropertyAccessor proxy_get = null;
+ if (prop.get_accessor != null) {
+ var owned_type = copy_type (prop.get_accessor.value_type, true);
+ if (owned_type.is_disposable () && !prop.get_accessor.value_type.value_owned) {
+ Report.error (prop.get_accessor.value_type.source_reference, "Properties used
in D-Bus clients require owned get accessor");
+ return;
+ }
+
+ proxy_get = new PropertyAccessor (true, false, false, owned_type, null,
prop.get_accessor.source_reference);
+
+ push_builder (new CodeBuilder.for_subroutine (proxy_get));
+ // first try cached value
+ var result = b.add_temp_declaration (null, expression (@"get_cached_property
(\"$dbus_name\")"));
+ b.open_if (expression (@"$result == null"));
+
+ b.open_try ();
+ statements (@"$result = call_sync (\"org.freedesktop.DBus.Properties.Get\", new
Variant (\"(ss)\", \"$dbus_iface_name\", \"$dbus_name\"), GLib.DBusCallFlags.NONE, $timeout, null);");
+ b.add_catch_uncaught_error ();
+ b.close ();
+
+ statements (@"$result.get (\"(v)\", out $result);");
+ b.close ();
+
+ statements (@"return ($(prop.property_type)) ($result);");
+ pop_builder ();
+ }
+
+ PropertyAccessor proxy_set = null;
+ if (prop.set_accessor != null) {
+ proxy_set = new PropertyAccessor (false, true, false, prop.set_accessor.value_type,
null, prop.set_accessor.source_reference);
+ push_builder (new CodeBuilder.for_subroutine (proxy_set));
+ var variant = b.add_temp_declaration (data_type ("GLib.Variant"), expression
("value"));
+ statements (@"call_sync (\"org.freedesktop.DBus.Properties.Set\", new Variant
(\"(ssv)\", \"$dbus_iface_name\", \"$dbus_name\", $variant), GLib.DBusCallFlags.NONE, $timeout, null);");
+ pop_builder ();
+ }
+
+ Property proxy = new Property (prop.name, prop.property_type, proxy_get, proxy_set,
prop.source_reference);
+ proxy_class.add_property (proxy);
+ }
+
+ void generate_dbus_proxy_properties (Class proxy_class, Interface iface) {
+ // also generate proxy for prerequisites
+ foreach (var prereq in iface.get_prerequisites ()) {
+ if (prereq.data_type is Interface) {
+ generate_dbus_proxy_properties (proxy_class, (Interface) prereq.data_type);
+ }
+ }
+
+ foreach (var prop in iface.get_properties ()) {
+ if (!prop.is_abstract) {
+ continue;
+ }
+
+ generate_dbus_proxy_property (proxy_class, iface, prop);
+ }
+ }
+
+ public override void visit_interface (Interface iface) {
+ if (is_visited (iface)) {
+ base.visit_interface (iface);
+ }
+
+ string dbus_iface_name = get_dbus_name (iface);
+ if (dbus_iface_name == null) {
+ return;
+ }
+
+ if (iface.parent_symbol.scope.lookup (iface.name+"Proxy") != null) {
+ return;
+ }
+
+ if (!context.has_package ("gio-2.0")) {
+ if (!iface.error) {
+ Report.error (iface.source_reference, "gio-2.0 package required for dbus type
symbols");
+ iface.error = true;
+ }
+ return;
+ }
+
+ // create proxy class
+ var proxy = new Class (iface.name + "Proxy", iface.source_reference, null);
+ proxy.add_base_type (data_type ("GLib.DBusProxy"));
+ proxy.add_base_type (SemanticAnalyzer.get_data_type_for_symbol (iface));
+ proxy.access = SymbolAccessibility.PRIVATE;
+ iface.parent_symbol.add_class (proxy);
+
+ generate_dbus_proxy_methods (proxy, iface);
+ generate_dbus_proxy_signals (proxy, iface);
+ generate_dbus_proxy_properties (proxy, iface);
+
+ check (proxy);
+ }
+
+ public override void visit_method_call (MethodCall expr) {
+ var m = expr.call.symbol_reference as Method;
+ if (m is DynamicMethod && ((DynamicMethod) m).dynamic_type.data_type == symbol_from_string
("GLib.DBusProxy")) {
+ generate_dynamic_dbus_call (expr);
+ } else if (m != null && m == symbol_from_string ("GLib.Bus.get_proxy")) {
+ generate_get_proxy_call (expr);
+ } else {
+ base.visit_method_call (expr);
+ }
+ }
+
+ private void generate_get_proxy_call (MethodCall expr) {
+ var ma = (MemberAccess) expr.call;
+ var type_arg = ma.get_type_arguments ().get (0);
+ var object_type = type_arg as ObjectType;
+ if (object_type != null && object_type.type_symbol is Interface) {
+ var iface = (Interface) object_type.type_symbol;
+ if (get_dbus_name (iface) != null) {
+ current_namespace = context.analyzer.get_current_namespace (expr);
+ accept_external (iface);
+ }
+ }
+ base.visit_method_call (expr);
+ }
+
+ private void generate_dynamic_dbus_call (MethodCall expr) {
+ var m = (DynamicMethod) expr.call.symbol_reference;
+ push_builder (new CodeBuilder (context, expr.parent_statement, expr.source_reference));
+
+ Method wrapper;
+ var cache_key = "gdbus_client_dynamic_method_call " + m.return_type.to_string ();
+ foreach (var param in m.get_parameters ()) {
+ cache_key = "%s %s".printf (cache_key, param.variable_type.to_string ());
+ }
+ if (!wrapper_method (m.return_type.copy(), cache_key, out wrapper, symbol_from_string
("GLib.DBusProxy"))) {
+ foreach (var param in m.get_parameters ()) {
+ wrapper.add_parameter (param.copy ());
+ }
+ b = new CodeBuilder.for_subroutine (wrapper);
- generate_marshalling (m, null, m.name);
++ generate_marshalling (m, null, m.name, GDBusModule.get_dbus_timeout_for_member (m));
+ check (wrapper);
+ }
+
+ pop_builder ();
+ expr.call.symbol_reference = wrapper;
+ base.visit_method_call (expr);
+ }
+}
diff --cc tests/Makefile.am
index b8c2c6e,e5c2301..d4f0fc3
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@@ -75,9 -77,9 +77,10 @@@ TESTS =
control-flow/expressions-conditional.vala \
control-flow/for.vala \
control-flow/foreach.vala \
+ control-flow/nested-conditional.vala \
control-flow/switch.vala \
control-flow/sideeffects.vala \
+ control-flow/bug628336.vala \
control-flow/bug639482.vala \
control-flow/bug652549.vala \
control-flow/bug661985.vala \
diff --cc vala/valaassignment.vala
index 6086948,fc27acf..ee37225
--- a/vala/valaassignment.vala
+++ b/vala/valaassignment.vala
@@@ -173,8 -145,14 +173,14 @@@ public class Vala.Assignment : Expressi
if (left is MemberAccess) {
var ma = (MemberAccess) left;
+ if (ma.symbol_reference is Constant) {
+ error = true;
+ Report.error (source_reference, "Assignment to constant after
initialization");
+ return false;
+ }
+
if ((!(ma.symbol_reference is Signal || ma.symbol_reference is DynamicProperty) &&
ma.value_type == null) ||
- (ma.inner == null && ma.member_name == "this" &&
context.analyzer.is_in_instance_method ())) {
+ (ma.inner == null && ma.member_name == "this" &&
context.analyzer.is_in_instance_method (this))) {
error = true;
Report.error (source_reference, "unsupported lvalue in assignment");
return false;
diff --cc vala/valacodecontext.vala
index 628f71e,ddb9fdf..0ca1961
--- a/vala/valacodecontext.vala
+++ b/vala/valacodecontext.vala
@@@ -493,81 -488,14 +498,87 @@@ public class Vala.CodeContext
}
flow_analyzer.analyze (this);
+
+ if (report.get_errors () > 0) {
+ return;
+ }
+
+ used_attr.check_unused (this);
}
+ public void load_plugins () {
+ if (!Module.supported ()) {
+ return;
+ }
+
+ if (plugin_directories != null) {
+ if (!experimental) {
+ Report.warning (null, "plugins are experimental and their API is unstable");
+ }
+
+ foreach (string dir in plugin_directories) {
+ load_plugins_in_directory (dir);
+ }
+ }
+ }
+
+ public void load_plugins_in_directory (string dirname) {
+ Dir dir;
+ try {
+ dir = Dir.open (dirname, 0);
+ } catch (Error e) {
+ return;
+ }
+
+ string? name = null;
+
+ while ((name = dir.read_name ()) != null) {
+ string path = Path.build_filename (dirname, name);
+ if (FileUtils.test (path, FileTest.IS_DIR)) {
+ continue;
+ }
+ if (!name.has_prefix ("valaplugin")) {
+ continue;
+ }
+
+ var mod = Module.open (path, ModuleFlags.BIND_LOCAL);
+
+ if (mod == null) {
+ if (verbose_mode) {
+ stdout.printf ("Could not load module: %s\n", path);
+ }
+ continue;
+ } else {
+ if (verbose_mode) {
+ stdout.printf ("Loaded module: %s\n", path);
+ }
+ }
+
+ void* function;
+ if (!mod.symbol ("vala_plugin_register", out function) || function == null) {
+ if (verbose_mode) {
+ stdout.printf ("Could not load entry point for module %s\n", path);
+ }
+ continue;
+ }
+
+ unowned RegisterPluginFunction register_plugin = (RegisterPluginFunction) function;
+ register_plugin (this);
+
+ mod.make_resident ();
+ }
+ }
+
+ /**
+ * Set the given transformer as the head transformer
+ */
+ public void register_transformer (CodeTransformer transformer) {
+ transformer.next = this.transformer;
+ // Setting .head, will recursively set the head for the next transformers
+ transformer.head = transformer;
+ this.transformer = transformer;
+ }
+
public void add_define (string define) {
defines.add (define);
}
diff --cc vala/valalambdaexpression.vala
index 98e86e1,1d6f957..1723388
--- a/vala/valalambdaexpression.vala
+++ b/vala/valalambdaexpression.vala
@@@ -137,13 -137,12 +137,12 @@@ public class Vala.LambdaExpression : Ex
method = new Method (get_lambda_name (context), return_type, source_reference);
// track usage for flow analyzer
method.used = true;
- method.check_deprecated (source_reference);
- method.check_experimental (source_reference);
+ method.version.check (source_reference);
- if (!cb.has_target || !context.analyzer.is_in_instance_method ()) {
+ if (!cb.has_target || !context.analyzer.is_in_instance_method (this)) {
method.binding = MemberBinding.STATIC;
} else {
- var sym = context.analyzer.current_symbol;
+ var sym = context.analyzer.get_current_symbol (this);
while (method.this_parameter == null) {
if (sym is Property) {
var prop = (Property) sym;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]