add new sigc++2 directory
[ardour.git] / libs / gtkmm2 / atk / atkmm / implementor.cc
1 // Generated by gtkmmproc -- DO NOT MODIFY!
2
3
4 #include <atkmm/implementor.h>
5 #include <atkmm/private/implementor_p.h>
6
7 // -*- c++ -*-
8 /* $Id$ */
9
10 /* Copyright 1998-2002 The gtkmm Development Team
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Library General Public
14  * License as published by the Free Software Foundation; either
15  * version 2 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  * Library General Public License for more details.
21  *
22  * You should have received a copy of the GNU Library General Public
23  * License along with this library; if not, write to the Free
24  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25  */
26
27 #include <atkmm/object.h>
28 #include <atk/atkobject.h>
29
30
31 namespace
32 {
33 } // anonymous namespace
34
35
36 namespace Glib
37 {
38
39 Glib::RefPtr<Atk::Implementor> wrap(AtkImplementor* object, bool take_copy)
40 {
41   return Glib::RefPtr<Atk::Implementor>( dynamic_cast<Atk::Implementor*> (Glib::wrap_auto_interface<Atk::Implementor> ((GObject*)(object), take_copy)) );
42   //We use dynamic_cast<> in case of multiple inheritance.
43 }
44
45 } // namespace Glib
46
47
48 namespace Atk
49 {
50
51
52 /* The *_Class implementation: */
53
54 const Glib::Interface_Class& Implementor_Class::init()
55 {
56   if(!gtype_) // create the GType if necessary
57   {
58     // Glib::Interface_Class has to know the interface init function
59     // in order to add interfaces to implementing types.
60     class_init_func_ = &Implementor_Class::iface_init_function;
61
62     // We can not derive from another interface, and it is not necessary anyway.
63     gtype_ = atk_implementor_get_type();
64   }
65
66   return *this;
67 }
68
69 void Implementor_Class::iface_init_function(void* g_iface, void*)
70 {
71   BaseClassType *const klass = static_cast<BaseClassType*>(g_iface);
72
73   //This is just to avoid an "unused variable" warning when there are no vfuncs or signal handlers to connect.
74   //This is a temporary fix until I find out why I can not seem to derive a GtkFileChooser interface. murrayc
75   g_assert(klass != 0); 
76
77 #ifdef GLIBMM_VFUNCS_ENABLED
78   klass->ref_accessible = &ref_accessible_vfunc_callback;
79 #endif //GLIBMM_VFUNCS_ENABLED
80
81 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
82 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
83 }
84
85 #ifdef GLIBMM_VFUNCS_ENABLED
86 AtkObject* Implementor_Class::ref_accessible_vfunc_callback(AtkImplementor* self)
87 {
88   Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
89       Glib::ObjectBase::_get_current_wrapper((GObject*)self));
90
91   // Non-gtkmmproc-generated custom classes implicitly call the default
92   // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
93   // generated classes can use this optimisation, which avoids the unnecessary
94   // parameter conversions if there is no possibility of the virtual function
95   // being overridden:
96   if(obj_base && obj_base->is_derived_())
97   {
98     CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
99     if(obj) // This can be NULL during destruction.
100     {
101       #ifdef GLIBMM_EXCEPTIONS_ENABLED
102       try // Trap C++ exceptions which would normally be lost because this is a C callback.
103       {
104       #endif //GLIBMM_EXCEPTIONS_ENABLED
105         // Call the virtual member method, which derived classes might override.
106         return Glib::unwrap(obj->ref_accessibile_vfunc());
107       #ifdef GLIBMM_EXCEPTIONS_ENABLED
108       }
109       catch(...)
110       {
111         Glib::exception_handlers_invoke();
112       }
113       #endif //GLIBMM_EXCEPTIONS_ENABLED
114     }
115   }
116   
117   BaseClassType *const base = static_cast<BaseClassType*>(
118       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
119 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
120 )  );
121
122   // Call the original underlying C function:
123   if(base && base->ref_accessible)
124     return (*base->ref_accessible)(self);
125
126
127   typedef AtkObject* RType;
128   return RType();
129 }
130 #endif //GLIBMM_VFUNCS_ENABLED
131
132 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
133 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
134
135
136 Glib::ObjectBase* Implementor_Class::wrap_new(GObject* object)
137 {
138   return new Implementor((AtkImplementor*)(object));
139 }
140
141
142 /* The implementation: */
143
144 Implementor::Implementor()
145 :
146   Glib::Interface(implementor_class_.init())
147 {}
148
149 Implementor::Implementor(AtkImplementor* castitem)
150 :
151   Glib::Interface((GObject*)(castitem))
152 {}
153
154 Implementor::~Implementor()
155 {}
156
157 // static
158 void Implementor::add_interface(GType gtype_implementer)
159 {
160   implementor_class_.init().add_interface(gtype_implementer);
161 }
162
163 Implementor::CppClassType Implementor::implementor_class_; // initialize static member
164
165 GType Implementor::get_type()
166 {
167   return implementor_class_.init().get_type();
168 }
169
170 GType Implementor::get_base_type()
171 {
172   return atk_implementor_get_type();
173 }
174
175
176 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
177 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
178
179 #ifdef GLIBMM_VFUNCS_ENABLED
180 Glib::RefPtr<Object> Atk::Implementor::ref_accessibile_vfunc() 
181 {
182   BaseClassType *const base = static_cast<BaseClassType*>(
183       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
184 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
185 )  );
186
187   if(base && base->ref_accessible)
188     return Glib::wrap((*base->ref_accessible)(gobj()), true);
189
190   typedef Glib::RefPtr<Object> RType;
191   return RType();
192 }
193 #endif //GLIBMM_VFUNCS_ENABLED
194
195
196 } // namespace Atk
197
198