moved 2.1-staging to trunk @ rev 1765
[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 ((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   CppObjectType *const obj = dynamic_cast<CppObjectType*>(
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 && obj->is_derived_())
97   {
98     #ifdef GLIBMM_EXCEPTIONS_ENABLED
99     try // Trap C++ exceptions which would normally be lost because this is a C callback.
100     {
101     #endif //GLIBMM_EXCEPTIONS_ENABLED
102       // Call the virtual member method, which derived classes might override.
103       return Glib::unwrap(obj->ref_accessibile_vfunc());
104     #ifdef GLIBMM_EXCEPTIONS_ENABLED
105     }
106     catch(...)
107     {
108       Glib::exception_handlers_invoke();
109     }
110     #endif //GLIBMM_EXCEPTIONS_ENABLED
111   }
112   else
113   {
114     BaseClassType *const base = static_cast<BaseClassType*>(
115         g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
116 g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
117 )    );
118
119     // Call the original underlying C function:
120     if(base && base->ref_accessible)
121       return (*base->ref_accessible)(self);
122   }
123
124   typedef AtkObject* RType;
125   return RType();
126 }
127 #endif //GLIBMM_VFUNCS_ENABLED
128
129 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
130 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
131
132
133 Glib::ObjectBase* Implementor_Class::wrap_new(GObject* object)
134 {
135   return new Implementor((AtkImplementor*)(object));
136 }
137
138
139 /* The implementation: */
140
141 Implementor::Implementor()
142 :
143   Glib::Interface(implementor_class_.init())
144 {}
145
146 Implementor::Implementor(AtkImplementor* castitem)
147 :
148   Glib::Interface((GObject*)(castitem))
149 {}
150
151 Implementor::~Implementor()
152 {}
153
154 // static
155 void Implementor::add_interface(GType gtype_implementer)
156 {
157   implementor_class_.init().add_interface(gtype_implementer);
158 }
159
160 Implementor::CppClassType Implementor::implementor_class_; // initialize static member
161
162 GType Implementor::get_type()
163 {
164   return implementor_class_.init().get_type();
165 }
166
167 GType Implementor::get_base_type()
168 {
169   return atk_implementor_get_type();
170 }
171
172
173 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
174 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
175
176 #ifdef GLIBMM_VFUNCS_ENABLED
177 Glib::RefPtr<Object> Atk::Implementor::ref_accessibile_vfunc() 
178 {
179   BaseClassType *const base = static_cast<BaseClassType*>(
180       g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
181 g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
182 )  );
183
184   if(base && base->ref_accessible)
185     return Glib::wrap((*base->ref_accessible)(gobj()), true);
186
187   typedef Glib::RefPtr<Object> RType;
188   return RType();
189 }
190 #endif //GLIBMM_VFUNCS_ENABLED
191
192
193 } // namespace Atk
194
195