1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
// -*- c++ -*-
/* $Id$ */
/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <glibmm/interface.h>
#include <glibmm/private/interface_p.h>
namespace Glib
{
/**** Glib::Interface_Class ************************************************/
void Interface_Class::add_interface(GType instance_type) const
{
//This check is distabled, because it checks whether any of the types's bases implement the interface, not just the specific type.
//if( !g_type_is_a(instance_type, gtype_) ) //For convenience, don't complain about calling this twice.
//{
const GInterfaceInfo interface_info =
{
class_init_func_,
0, // interface_finalize
0, // interface_data
};
g_type_add_interface_static(instance_type, gtype_, &interface_info);
//}
}
/**** Interface Glib::Interface ********************************************/
Interface::Interface(const Interface_Class& interface_class)
{
//gobject_ will be set in the Object constructor.
//Any instantiable class that derives from Interface should also inherit from Object.
// If I understand it correctly, gobject_ shouldn't be 0 now. daniel.
// TODO: Make this a g_assert() if the assumption above is correct.
g_return_if_fail(gobject_ != 0);
if(custom_type_name_ && !is_anonymous_custom_())
{
void *const instance_class = G_OBJECT_GET_CLASS(gobject_);
if(!g_type_interface_peek(instance_class, interface_class.get_type()))
{
interface_class.add_interface(G_OBJECT_CLASS_TYPE(instance_class));
}
}
}
Interface::Interface(GObject* castitem)
{
// Connect GObject and wrapper instances.
ObjectBase::initialize(castitem);
}
Interface::~Interface()
{}
GType Interface::get_type()
{
return G_TYPE_INTERFACE;
}
GType Interface::get_base_type()
{
return G_TYPE_INTERFACE;
}
RefPtr<ObjectBase> wrap_interface(GObject* object, bool take_copy)
{
return Glib::RefPtr<ObjectBase>( wrap_auto(object, take_copy) );
}
} // namespace Glib
|