"Fossies" - the Fresh Open Source Software Archive

Member "glibmm-2.74.0/untracked/gio/giomm/asyncresult.cc" (19 Sep 2022, 8681 Bytes) of package /linux/misc/glibmm-2.74.0.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "asyncresult.cc" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes reports: 2.73.2_vs_2.74.0 or 2.72.1_vs_2.74.0.

    1 // Generated by gmmproc 2.74.0 -- DO NOT MODIFY!
    2 
    3 
    4 #include <glibmm.h>
    5 
    6 #include <giomm/asyncresult.h>
    7 #include <giomm/private/asyncresult_p.h>
    8 
    9 
   10 /* Copyright (C) 2007 The giomm Development Team
   11  *
   12  * This library is free software; you can redistribute it and/or
   13  * modify it under the terms of the GNU Lesser General Public
   14  * License as published by the Free Software Foundation; either
   15  * version 2.1 of the License, or (at your option) any later version.
   16  *
   17  * This library is distributed in the hope that it will be useful,
   18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   20  * Lesser General Public License for more details.
   21  *
   22  * You should have received a copy of the GNU Lesser General Public
   23  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
   24  */
   25 
   26 //#include <gio/gasyncresult.h> //We are not allowed to include individual headers.
   27 #include <gio/gio.h>
   28 #include <glibmm/exceptionhandler.h>
   29 
   30 namespace Gio
   31 {
   32 
   33 static GObject*
   34 unwrap_objectbase_custom(const Glib::RefPtr<Glib::ObjectBase>& cpp_instance)
   35 {
   36   return (cpp_instance ? cpp_instance->gobj() : nullptr);
   37 }
   38 
   39 Glib::RefPtr<Glib::ObjectBase>
   40 AsyncResult::get_source_object_base()
   41 {
   42   // Glib::wrap(cobj) can't be used here. See tests/giomm_asyncresult_sourceobject
   43   // for a case where it would fail, and an explanation of why.
   44   // In short, the source object is not necessarily a Glib::Object. It may be
   45   // a Glib::Interface.
   46 
   47   auto cobj = g_async_result_get_source_object(gobj());
   48   auto cppobj = Glib::wrap_auto(cobj); // ObjectBase::_get_current_wrapper(cobj);
   49   return Glib::make_refptr_for_instance<Glib::ObjectBase>(
   50     cppobj); // g_async_result_get_source_object() gives us a ref, unusually.
   51 }
   52 
   53 Glib::RefPtr<const Glib::ObjectBase>
   54 AsyncResult::get_source_object_base() const
   55 {
   56   return const_cast<AsyncResult*>(this)->get_source_object_base();
   57 }
   58 
   59 } // namespace Gio
   60 
   61 namespace
   62 {
   63 } // anonymous namespace
   64 
   65 
   66 namespace Glib
   67 {
   68 
   69 Glib::RefPtr<Gio::AsyncResult> wrap(GAsyncResult* object, bool take_copy)
   70 {
   71   return Glib::make_refptr_for_instance<Gio::AsyncResult>( dynamic_cast<Gio::AsyncResult*> (Glib::wrap_auto_interface<Gio::AsyncResult> ((GObject*)(object), take_copy)) );
   72   //We use dynamic_cast<> in case of multiple inheritance.
   73 }
   74 
   75 } // namespace Glib
   76 
   77 
   78 namespace Gio
   79 {
   80 
   81 
   82 /* The *_Class implementation: */
   83 
   84 const Glib::Interface_Class& AsyncResult_Class::init()
   85 {
   86   if(!gtype_) // create the GType if necessary
   87   {
   88     // Glib::Interface_Class has to know the interface init function
   89     // in order to add interfaces to implementing types.
   90     class_init_func_ = &AsyncResult_Class::iface_init_function;
   91 
   92     // We can not derive from another interface, and it is not necessary anyway.
   93     gtype_ = g_async_result_get_type();
   94   }
   95 
   96   return *this;
   97 }
   98 
   99 void AsyncResult_Class::iface_init_function(void* g_iface, void*)
  100 {
  101   const auto klass = static_cast<BaseClassType*>(g_iface);
  102 
  103   //This is just to avoid an "unused variable" warning when there are no vfuncs or signal handlers to connect.
  104   //This is a temporary fix until I find out why I can not seem to derive a GtkFileChooser interface. murrayc
  105   g_assert(klass != nullptr);
  106 
  107   klass->get_source_object = &get_source_object_vfunc_callback;
  108   klass->is_tagged = &is_tagged_vfunc_callback;
  109 
  110 }
  111 
  112 GObject* AsyncResult_Class::get_source_object_vfunc_callback(GAsyncResult* self)
  113 {
  114   const auto obj_base = static_cast<Glib::ObjectBase*>(
  115       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
  116 
  117   // Non-gtkmmproc-generated custom classes implicitly call the default
  118   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  119   // generated classes can use this optimisation, which avoids the unnecessary
  120   // parameter conversions if there is no possibility of the virtual function
  121   // being overridden:
  122   if(obj_base && obj_base->is_derived_())
  123   {
  124     const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
  125     if(obj) // This can be NULL during destruction.
  126     {
  127       try // Trap C++ exceptions which would normally be lost because this is a C callback.
  128       {
  129         // Call the virtual member method, which derived classes might override.
  130         return unwrap_objectbase_custom(obj->get_source_object_vfunc());
  131       }
  132       catch(...)
  133       {
  134         Glib::exception_handlers_invoke();
  135       }
  136     }
  137   }
  138 
  139   BaseClassType *const base = static_cast<BaseClassType*>(
  140       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
  141 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
  142 )  );
  143 
  144   // Call the original underlying C function:
  145   if(base && base->get_source_object)
  146     return (*base->get_source_object)(self);
  147 
  148   using RType = GObject*;
  149   return RType();
  150 }
  151 gboolean AsyncResult_Class::is_tagged_vfunc_callback(GAsyncResult* self, gpointer source_tag)
  152 {
  153   const auto obj_base = static_cast<Glib::ObjectBase*>(
  154       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
  155 
  156   // Non-gtkmmproc-generated custom classes implicitly call the default
  157   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  158   // generated classes can use this optimisation, which avoids the unnecessary
  159   // parameter conversions if there is no possibility of the virtual function
  160   // being overridden:
  161   if(obj_base && obj_base->is_derived_())
  162   {
  163     const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
  164     if(obj) // This can be NULL during destruction.
  165     {
  166       try // Trap C++ exceptions which would normally be lost because this is a C callback.
  167       {
  168         // Call the virtual member method, which derived classes might override.
  169         return static_cast<int>(obj->is_tagged_vfunc(source_tag));
  170       }
  171       catch(...)
  172       {
  173         Glib::exception_handlers_invoke();
  174       }
  175     }
  176   }
  177 
  178   BaseClassType *const base = static_cast<BaseClassType*>(
  179       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
  180 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
  181 )  );
  182 
  183   // Call the original underlying C function:
  184   if(base && base->is_tagged)
  185     return (*base->is_tagged)(self, source_tag);
  186 
  187   using RType = gboolean;
  188   return RType();
  189 }
  190 
  191 
  192 Glib::ObjectBase* AsyncResult_Class::wrap_new(GObject* object)
  193 {
  194   return new AsyncResult((GAsyncResult*)(object));
  195 }
  196 
  197 
  198 /* The implementation: */
  199 
  200 AsyncResult::AsyncResult()
  201 :
  202   Glib::Interface(asyncresult_class_.init())
  203 {}
  204 
  205 AsyncResult::AsyncResult(GAsyncResult* castitem)
  206 :
  207   Glib::Interface((GObject*)(castitem))
  208 {}
  209 
  210 AsyncResult::AsyncResult(const Glib::Interface_Class& interface_class)
  211 : Glib::Interface(interface_class)
  212 {
  213 }
  214 
  215 AsyncResult::AsyncResult(AsyncResult&& src) noexcept
  216 : Glib::Interface(std::move(src))
  217 {}
  218 
  219 AsyncResult& AsyncResult::operator=(AsyncResult&& src) noexcept
  220 {
  221   Glib::Interface::operator=(std::move(src));
  222   return *this;
  223 }
  224 
  225 AsyncResult::~AsyncResult() noexcept
  226 {}
  227 
  228 // static
  229 void AsyncResult::add_interface(GType gtype_implementer)
  230 {
  231   asyncresult_class_.init().add_interface(gtype_implementer);
  232 }
  233 
  234 AsyncResult::CppClassType AsyncResult::asyncresult_class_; // initialize static member
  235 
  236 GType AsyncResult::get_type()
  237 {
  238   return asyncresult_class_.init().get_type();
  239 }
  240 
  241 
  242 GType AsyncResult::get_base_type()
  243 {
  244   return g_async_result_get_type();
  245 }
  246 
  247 
  248 bool AsyncResult::is_tagged(gpointer source_tag) const
  249 {
  250   return g_async_result_is_tagged(const_cast<GAsyncResult*>(gobj()), source_tag);
  251 }
  252 
  253 
  254 Glib::RefPtr<Glib::ObjectBase> Gio::AsyncResult::get_source_object_vfunc() 
  255 {
  256   const auto base = static_cast<BaseClassType*>(
  257       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
  258 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
  259 )  );
  260 
  261   if(base && base->get_source_object)
  262   {
  263     Glib::RefPtr<Glib::ObjectBase> retval(Glib::wrap((*base->get_source_object)(gobj())));
  264     return retval;
  265   }
  266 
  267   using RType = Glib::RefPtr<Glib::ObjectBase>;
  268   return RType();
  269 }
  270 bool Gio::AsyncResult::is_tagged_vfunc(gpointer source_tag) 
  271 {
  272   const auto base = static_cast<BaseClassType*>(
  273       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
  274 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
  275 )  );
  276 
  277   if(base && base->is_tagged)
  278   {
  279     bool retval((*base->is_tagged)(gobj(),source_tag));
  280     return retval;
  281   }
  282 
  283   using RType = bool;
  284   return RType();
  285 }
  286 
  287 
  288 } // namespace Gio
  289 
  290