-
Notifications
You must be signed in to change notification settings - Fork 18
/
glibmm.patch
189 lines (171 loc) · 8.37 KB
/
glibmm.patch
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
diff --git a/meson.build b/meson.build
index 2eefa135..0109a99d 100644
--- a/meson.build
+++ b/meson.build
@@ -109,12 +109,13 @@ sigcxx_req = '>= 3.0.0'
glib_req = '>= 2.77.0'
# There are pkg-config files for sigc++ and glib on MSVC, so just use that.
+dl_dep = cpp_compiler.find_library('dl', required : false)
sigcxx_dep = dependency('sigc++-3.0', version: sigcxx_req)
glib_dep = dependency('glib-2.0', version: glib_req)
gobject_dep = dependency('gobject-2.0', version: glib_req)
gmodule_dep = dependency('gmodule-2.0', version: glib_req)
-glibmm_build_dep = [sigcxx_dep, glib_dep, gobject_dep, gmodule_dep]
+glibmm_build_dep = [dl_dep, sigcxx_dep, glib_dep, gobject_dep, gmodule_dep]
glibmm_requires = [
'sigc++-3.0', sigcxx_req,
'glib-2.0', glib_req,
diff --git a/tools/generate_wrap_init.pl.in b/tools/generate_wrap_init.pl.in
index 21b7b907..d03eec5e 100644
--- a/tools/generate_wrap_init.pl.in
+++ b/tools/generate_wrap_init.pl.in
@@ -206,6 +206,7 @@ print << "EOF";
// Generated by generate_wrap_init.pl -- DO NOT MODIFY!
#define GLIBMM_INCLUDED_FROM_WRAP_INIT_CC
+#include <dlfcn.h>
#include <glibmm.h>
#include <${parent_dir}/wrap_init.h>
#include <glibmm/error.h>
@@ -361,8 +362,8 @@ foreach my $sub_namespace (sort keys %extra_namespaces)
my ($cppname, $basename, @extra_namespace) = @{$i};
if (@extra_namespace > 0 && $sub_namespace eq join("::", @extra_namespace))
{
- $message .= " Glib::Error::register_domain(${basename}_quark(), &" .
- "${sub_namespace}::${cppname}::throw_func);\n";
+ $message .= " if (const auto func = (decltype(&${basename}_quark)) dlsym(RTLD_DEFAULT, \"${basename}_quark\"))\n" .
+ " Glib::Error::register_domain(func(), &${sub_namespace}::${cppname}::throw_func);\n";
}
}
print_with_guards($filename_header, $message) if $message;
@@ -387,8 +388,8 @@ foreach my $filename_header (sort keys %exceptions)
my ($cppname, $basename, @extra_namespace) = @{$i};
if (@extra_namespace == 0)
{
- $message .= " Glib::Error::register_domain(${basename}_quark(), &" .
- "${cppname}::throw_func);\n";
+ $message .= " if (const auto func = (decltype(&${basename}_quark)) dlsym(RTLD_DEFAULT, \"${basename}_quark\"))\n" .
+ " Glib::Error::register_domain(func(), &${cppname}::throw_func);\n";
}
}
print_with_guards($filename_header, $message) if $message;
@@ -419,8 +420,8 @@ foreach my $filename_header (sort keys %objects)
{
my ($cppname, $basename, @extra_namespace) = @{$i};
my $qualified_cppname = join("::", (@extra_namespace, $cppname));
- $message .= " Glib::wrap_register(${basename}_get_type(), &" .
- "${qualified_cppname}_Class::wrap_new);\n";
+ $message .= " if (const auto func = (decltype(&${basename}_get_type)) dlsym(RTLD_DEFAULT, \"${basename}_get_type\"))\n" .
+ " Glib::wrap_register(func(), &${qualified_cppname}_Class::wrap_new);\n";
}
print_with_guards($filename_header, $message);
}
diff --git a/tools/m4/base.m4 b/tools/m4/base.m4
index 45354752..a3dae03f 100644
--- a/tools/m4/base.m4
+++ b/tools/m4/base.m4
@@ -134,8 +134,17 @@ dnl also pre-pending an '_' to the pairs. Finally, it converts all characters
dnl to lowercase (with the translit), removing the first '_' (with substr) and
dnl appending _get_type(). This works with regular types like GtkWidget, but
dnl also multi-cap types like GdkGCFooBar or GdkFOOBar.
+
+define(`_GET_TYPE_FUNC_NAME',`dnl
+m4_translit(m4_substr(m4_patsubst(m4_patsubst(`$1',`[A-Z][A-Z]+',`_\&'),`[A-Z][a-z]',`_\&'),1),`[A-Z]',`[a-z]')_get_type`'dnl
+')
+
define(`_GET_TYPE_FUNC',`dnl
-m4_translit(m4_substr(m4_patsubst(m4_patsubst(`$1',`[A-Z][A-Z]+',`_\&'),`[A-Z][a-z]',`_\&'),1),`[A-Z]',`[a-z]')_get_type()`'dnl
+[] {
+ if (const auto func = (decltype(&_GET_TYPE_FUNC_NAME($1))) dlsym(RTLD_DEFAULT, "_GET_TYPE_FUNC_NAME($1)"))
+ return func();
+ return GType();
+}()
')
dnl Define a new diversion
@@ -337,6 +346,7 @@ _IMPORT(SECTION_CC_PRE_INCLUDES)
_DEPRECATE_IFDEF_CLASS_CONFIG_START
+#include <dlfcn.h>
#include <glibmm.h>
#include <__MODULE__/__FILE__.h>
diff --git a/tools/m4/class_interface.m4 b/tools/m4/class_interface.m4
index 5243b265..7da9a316 100644
--- a/tools/m4/class_interface.m4
+++ b/tools/m4/class_interface.m4
@@ -86,7 +86,8 @@ const Glib::Interface_Class& __CPPNAME__`'_Class::init()
class_init_func_ = &__CPPNAME__`'_Class::iface_init_function;
// We can not derive from another interface, and it is not necessary anyway.
- gtype_ = _LOWER(__CCAST__)_get_type();
+ if (const auto func = (decltype(&_LOWER(__CCAST__)_get_type)) dlsym(RTLD_DEFAULT, "_LOWER(__CCAST__)_get_type"))
+ gtype_ = func();
}
return *this;
diff --git a/tools/m4/class_opaque_refcounted.m4 b/tools/m4/class_opaque_refcounted.m4
index 544f772e..607ac795 100644
--- a/tools/m4/class_opaque_refcounted.m4
+++ b/tools/m4/class_opaque_refcounted.m4
@@ -115,7 +115,9 @@ GType __CPPNAME__::get_type()
ifelse(__OPAQUE_FUNC_GTYPE__,,`dnl
return _GET_TYPE_FUNC(__CNAME__);
',`dnl
- return __OPAQUE_FUNC_GTYPE__`'();
+ if (const auto func = (decltype(&__OPAQUE_FUNC_GTYPE__)) dlsym(RTLD_DEFAULT, "__OPAQUE_FUNC_GTYPE__"))
+ return func();
+ return GType();
')dnl
}
diff --git a/tools/m4/class_shared.m4 b/tools/m4/class_shared.m4
index 3ba0f32f..983f6924 100644
--- a/tools/m4/class_shared.m4
+++ b/tools/m4/class_shared.m4
@@ -175,10 +175,12 @@ ifdef(`__BOOL_ABI_AS_WITH_DERIVED_GTYPE__',`dnl
class_init_func_ = &__CPPNAME__`'_Class::class_init_function;
// Do not derive a GType, or use a derived class:
- gtype_ = _LOWER(__CCAST__)_get_type();
+ if (const auto func = (decltype(&_LOWER(__CCAST__)_get_type)) dlsym(RTLD_DEFAULT, "_LOWER(__CCAST__)_get_type"))
+ gtype_ = func();
',`dnl
// Do not derive a GType, or use a derived class:
- gtype_ = _LOWER(__CCAST__)_get_type();
+ if (const auto func = (decltype(&_LOWER(__CCAST__)_get_type)) dlsym(RTLD_DEFAULT, "_LOWER(__CCAST__)_get_type"))
+ gtype_ = func();
')',`dnl not __BOOL_DO_NOT_DERIVE_GTYPE__
// Glib::Class has to know the class init function to clone custom types.
class_init_func_ = &__CPPNAME__`'_Class::class_init_function;
@@ -188,7 +190,8 @@ ifdef(`__BOOL_ABI_AS_WITH_DERIVED_GTYPE__',`dnl
//CppClassParent::CppObjectType::get_type();
// Create the wrapper type, with the same class/instance size as the base type.
- register_derived_type(_LOWER(__CCAST__)_get_type());
+ if (const auto func = (decltype(&_LOWER(__CCAST__)_get_type)) dlsym(RTLD_DEFAULT, "_LOWER(__CCAST__)_get_type"))
+ register_derived_type(func());
// Add derived versions of interfaces, if the C type implements any interfaces:
_IMPORT(SECTION_CC_IMPLEMENTS_INTERFACES)
@@ -209,10 +212,12 @@ ifdef(`__BOOL_ABI_AS_WITH_DERIVED_GTYPE__',`dnl
class_init_func_ = &__CPPNAME__`'_Class::class_init_function;
// Do not derive a GType, or use a derived class:
- gtype_ = _LOWER(__CCAST__)_get_type();
+ if (const auto func = (decltype(&_LOWER(__CCAST__)_get_type)) dlsym(RTLD_DEFAULT, "_LOWER(__CCAST__)_get_type"))
+ gtype_ = func();
',`dnl
// Do not derive a GType, or use a derived class:
- gtype_ = _LOWER(__CCAST__)_get_type();
+ if (const auto func = (decltype(&_LOWER(__CCAST__)_get_type)) dlsym(RTLD_DEFAULT, "_LOWER(__CCAST__)_get_type"))
+ gtype_ = func();
')',`dnl
// Glib::Class has to know the class init function to clone custom types.
class_init_func_ = &__CPPNAME__`'_Class::class_init_function;
@@ -222,7 +227,8 @@ ifdef(`__BOOL_ABI_AS_WITH_DERIVED_GTYPE__',`dnl
//CppClassParent::CppObjectType::get_type();
// Create the wrapper type, with the same class/instance size as the base type.
- register_derived_type(_LOWER(__CCAST__)_get_type(), module);
+ if (const auto func = (decltype(&_LOWER(__CCAST__)_get_type)) dlsym(RTLD_DEFAULT, "_LOWER(__CCAST__)_get_type"))
+ register_derived_type(func(), module);
// Add derived versions of interfaces, if the C type implements any interfaces:
_IMPORT(SECTION_CC_IMPLEMENTS_INTERFACES)
@@ -287,7 +293,9 @@ GType __CPPNAME__::get_type(GTypeModule* module)
GType __CPPNAME__::get_base_type()
{
- return _LOWER(__CCAST__)_get_type();
+ if (const auto func = (decltype(&_LOWER(__CCAST__)_get_type)) dlsym(RTLD_DEFAULT, "_LOWER(__CCAST__)_get_type"))
+ return func();
+ return GType();
}
_IMPORT(SECTION_CC)