summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2011-02-24 11:33:21 +0100
committerMurray Cumming <murrayc@murrayc.com>2011-02-24 11:33:21 +0100
commit055b060e47d262bc52cc64a7a9cb539b6243859a (patch)
tree5e43966844000dbbd2d57d499268ec48311f2e40
parent9670cf533be1ad717df6974e800cc3b3a419b780 (diff)
downloadglibmm-055b060e47d262bc52cc64a7a9cb539b6243859a.tar.gz
Move Gio::DBusError to Gio::Dbus::DBusError.
* tools/m4/base.m4: Added a SECTION_H_GERROR_PRIVATE section. * tools/m4/gerror.m4: Import the SECTION_H_GERROR_PRIVATE section. * gio/src/dbuserror.hg: Put this back into the DBus namespace. Push a custom friend declaration into the SECTION_H_GERROR_PRIVATE section, because the standard generated friend declaration would not specify the correct one. This still does not rename DBusError to DBus::Error, but this is a step on the way. * examples/dbus/busserver.cc: Adapated.
-rw-r--r--ChangeLog14
-rw-r--r--examples/dbus/busserver.cc6
-rw-r--r--gio/src/dbuserror.hg23
-rw-r--r--tools/m4/base.m43
-rw-r--r--tools/m4/gerror.m42
5 files changed, 36 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 2de970e1..13ed8183 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2011-02-24 Murray Cumming <murrayc@murrayc.com>
+
+ Move Gio::DBusError to Gio::Dbus::DBusError.
+
+ * tools/m4/base.m4: Added a SECTION_H_GERROR_PRIVATE section.
+ * tools/m4/gerror.m4: Import the SECTION_H_GERROR_PRIVATE section.
+ * gio/src/dbuserror.hg: Put this back into the DBus namespace.
+ Push a custom friend declaration into the SECTION_H_GERROR_PRIVATE section,
+ because the standard generated friend declaration would not specify the
+ correct one.
+ This still does not rename DBusError to DBus::Error, but this is a step on
+ the way.
+ * examples/dbus/busserver.cc: Adapated.
+
2011-02-23 Murray Cumming <murrayc@murrayc.com>
Bring back Gio::Error registration.
diff --git a/examples/dbus/busserver.cc b/examples/dbus/busserver.cc
index 534a70b8..8d87e4f0 100644
--- a/examples/dbus/busserver.cc
+++ b/examples/dbus/busserver.cc
@@ -100,7 +100,7 @@ static void on_method_call(const Glib::RefPtr<Gio::DBus::Connection>& connection
if(!curr_alarm.assign_from_iso8601(time_str))
{
// If setting alarm was not successful, return an error.
- Gio::DBusError error(Gio::DBusError::INVALID_ARGS,
+ Gio::DBus::DBusError error(Gio::DBus::DBusError::INVALID_ARGS,
"Alarm string is not in ISO8601 format.");
invocation->return_gerror(error);
}
@@ -144,7 +144,7 @@ static void on_method_call(const Glib::RefPtr<Gio::DBus::Connection>& connection
else
{
// Non-existent method on the interface.
- Gio::DBusError error(Gio::DBusError::UNKNOWN_METHOD,
+ Gio::DBus::DBusError error(Gio::DBus::DBusError::UNKNOWN_METHOD,
"Method does not exist.");
invocation->return_gerror(error);
}
@@ -174,7 +174,7 @@ void on_get_property(Glib::VariantBase& property,
}
else
{
- throw Gio::DBusError(Gio::DBusError::FAILED, "Unknown property name.");
+ throw Gio::DBus::DBusError(Gio::DBus::DBusError::FAILED, "Unknown property name.");
}
}
diff --git a/gio/src/dbuserror.hg b/gio/src/dbuserror.hg
index 95f1aa68..15fb8eff 100644
--- a/gio/src/dbuserror.hg
+++ b/gio/src/dbuserror.hg
@@ -24,21 +24,26 @@ namespace Gio
{
#ifndef DOXYGEN_SHOULD_SKIP_THIS
-//Let the generated friend declaration know what wrap_init() it should refer to.
-//TODO: But the generated friend declaration needs to specify the full namespace too.
+//Our custom friend declaration (see below) needs this pre-declaration.
void wrap_init();
#endif // DOXYGEN_SHOULD_SKIP_THIS
-//TODO: Put this in the DBus namespace and remove the DBus prefix,
-//when we can get the generate friend declaration to be generated correctly.
-//namespace DBus
-//{
+namespace DBus
+{
+
+//The GMMPROC_EXTRA_NAMESPACE() macro is a hint to generate_wrap_init.pl to put it in the DBus sub-namespace
+_GMMPROC_EXTRA_NAMESPACE(DBus)
+
+
+#m4 _PUSH(SECTION_H_GERROR_PRIVATE)
+ //This extra line is only necessary because this class is in a sub-namespace, but we want
+ //it to be used in the wrap_init() of the main namespace. It's an awkward hack.
+ friend void Gio::wrap_init(); // uses throw_func()
+#m4 _POP()
-//This will be necessary when putting it in the DBus namespace:
-//Add the underscore so this is recognized: GMMPROC_EXTRA_NAMESPACE(DBus)
_WRAP_GERROR(DBusError, GDBusError, G_DBUS_ERROR, NO_GTYPE)
-//} //namespace DBus
+} //namespace DBus
} // namespace Gio
diff --git a/tools/m4/base.m4 b/tools/m4/base.m4
index b09e39f6..b230dee7 100644
--- a/tools/m4/base.m4
+++ b/tools/m4/base.m4
@@ -201,6 +201,9 @@ dnl Property Proxies:
dnl _NEW_SECTION(SECTION_H_PROPERTYPROXIES)
_NEW_SECTION(SECTION_CC_PROPERTYPROXIES)
+dnl Just a hack for some GError wrappers:
+_NEW_SECTION(SECTION_H_GERROR_PRIVATE) dnl In the private part of the declaration.
+
_NEW_SECTION(SECTION_CC_INITIALIZE_CLASS_EXTRA) dnl For instance, to initialize special member data from all constructors. Not commonly used.
dnl _NEW_SECTION(PROXY)
diff --git a/tools/m4/gerror.m4 b/tools/m4/gerror.m4
index 630f03bd..f18109f8 100644
--- a/tools/m4/gerror.m4
+++ b/tools/m4/gerror.m4
@@ -31,6 +31,8 @@ private:
static void throw_func(GError* gobject);
friend void wrap_init(); // uses throw_func()
+
+ _IMPORT(SECTION_H_GERROR_PRIVATE)
#endif //DOXYGEN_SHOULD_SKIP_THIS
};