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