diff options
author | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2023-03-31 18:15:23 +0200 |
---|---|---|
committer | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2023-03-31 18:15:23 +0200 |
commit | 7ff8b74a47059edbba7a9f9424fa0022943bc6ec (patch) | |
tree | c1c2ef469fbf0a6caf6b23b9a78b86d8d149255e /gio/giomm | |
parent | 98f3b67b5c1bd71d0e7b41193fb4683fc957e321 (diff) | |
download | glibmm-7ff8b74a47059edbba7a9f9424fa0022943bc6ec.tar.gz |
Add Gio::giomm_SignalProxy_async_callback() with C linkage
and use it instead of SignalProxy_async_callback().
Part of issue #1
Diffstat (limited to 'gio/giomm')
-rw-r--r-- | gio/giomm/slot_async.cc | 17 | ||||
-rw-r--r-- | gio/giomm/slot_async.h | 26 |
2 files changed, 38 insertions, 5 deletions
diff --git a/gio/giomm/slot_async.cc b/gio/giomm/slot_async.cc index db23dbf5..d06bf9a5 100644 --- a/gio/giomm/slot_async.cc +++ b/gio/giomm/slot_async.cc @@ -20,9 +20,14 @@ namespace Gio { - +extern "C" +{ +// A function with external linkage and C linkage does not get a mangled name. +// Even though giomm_SignalProxy_async_callback is declared in a named namespace, +// the linker does not see the namespace name, only 'giomm_SignalProxy_async_callback'. +// Therefore the function name shall have a prefix, hopefully unique. void -SignalProxy_async_callback(GObject*, GAsyncResult* res, void* data) +giomm_SignalProxy_async_callback(GObject*, GAsyncResult* res, void* data) { Gio::SlotAsyncReady* the_slot = static_cast<Gio::SlotAsyncReady*>(data); @@ -38,5 +43,13 @@ SignalProxy_async_callback(GObject*, GAsyncResult* res, void* data) delete the_slot; } +} // extern "C" + +//TODO: Remove SignalProxy_async_callback when we can break ABI and API. +void +SignalProxy_async_callback(GObject* source_object, GAsyncResult* res, void* data) +{ + giomm_SignalProxy_async_callback(source_object, res, data); +} } // namespace Gio diff --git a/gio/giomm/slot_async.h b/gio/giomm/slot_async.h index ed76b5b4..cc38cf84 100644 --- a/gio/giomm/slot_async.h +++ b/gio/giomm/slot_async.h @@ -24,14 +24,34 @@ namespace Gio { +extern "C" +{ +/** Callback function, used in combination with Gio::SlotAsyncReady. + * + * Example: + * @code + * _WRAP_METHOD(void acquire_async(const Gio::SlotAsyncReady& slot{callback}, + * const Glib::RefPtr<Gio::Cancellable>& cancellable{.?}), g_permission_acquire_async, + * slot_name slot, slot_callback Gio::giomm_SignalProxy_async_callback) + * @endcode + * + * @newin{2,78} + */ +GIOMM_API +void giomm_SignalProxy_async_callback(GObject*, GAsyncResult* res, void* data); +} // extern "C" + +//TODO: Remove SignalProxy_async_callback when we can break ABI and API. /** Callback function, used in combination with Gio::SlotAsyncReady. * + * Prefer giomm_SignalProxy_async_callback() as a callback from a C function. + * * Example: * @code - * _WRAP_METHOD(void acquire_async(const SlotAsyncReady& slot{callback}, - * const Glib::RefPtr<Cancellable>& cancellable{.?}), g_permission_acquire_async, - * slot_name slot, slot_callback SignalProxy_async_callback) + * _WRAP_METHOD(void acquire_async(const Gio::SlotAsyncReady& slot{callback}, + * const Glib::RefPtr<Gio::Cancellable>& cancellable{.?}), g_permission_acquire_async, + * slot_name slot, slot_callback Gio::SignalProxy_async_callback) * @endcode */ GIOMM_API |