File: | _build/../libbean/bean-object-module.c |
Warning: | line 465, column 11 Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* |
2 | * bean-object-module.c |
3 | * This file is part of libbean |
4 | * |
5 | * Copyright (C) 2003 Marco Pesenti Gritti |
6 | * Copyright (C) 2003-2004 Christian Persch |
7 | * Copyright (C) 2005-2007 Paolo Maggi |
8 | * Copyright (C) 2008 Jesse van den Kieboom |
9 | * Copyright (C) 2010 Steve Frécinaux |
10 | * |
11 | * libbean is free software; you can redistribute it and/or |
12 | * modify it under the terms of the GNU Lesser General Public |
13 | * License as published by the Free Software Foundation; either |
14 | * version 2.1 of the License, or (at your option) any later version. |
15 | * |
16 | * libbean 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 | * Lesser General Public License for more details. |
20 | * |
21 | * You should have received a copy of the GNU Lesser General Public |
22 | * License along with this library; if not, write to the Free Software |
23 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
24 | */ |
25 | |
26 | #include "config.h" |
27 | |
28 | #include <string.h> |
29 | |
30 | #include "bean-object-module.h" |
31 | #include "bean-plugin-loader.h" |
32 | |
33 | /** |
34 | * SECTION:bean-object-module |
35 | * @short_description: Type module which allows extension registration. |
36 | * |
37 | * #BeanObjectModule is a subclass of #GTypeModule which allows registration |
38 | * of extensions. It will be used by C extensions implementors to register |
39 | * extension implementations from within the bean_register_types module |
40 | * function. |
41 | * |
42 | * Since libbean 1.22, @extension_type can be an Abstract #GType |
43 | * and not just an Interface #GType. |
44 | **/ |
45 | |
46 | typedef void (*BeanObjectModuleRegisterFunc) (BeanObjectModule *module); |
47 | |
48 | enum { |
49 | PROP_0, |
50 | PROP_MODULE_NAME, |
51 | PROP_PATH, |
52 | PROP_SYMBOL, |
53 | PROP_RESIDENT, |
54 | PROP_LOCAL_LINKAGE, |
55 | N_PROPERTIES |
56 | }; |
57 | |
58 | static GParamSpec *properties[N_PROPERTIES] = { NULL((void*)0) }; |
59 | |
60 | typedef struct { |
61 | GType exten_type; |
62 | BeanFactoryFunc func; |
63 | gpointer user_data; |
64 | GDestroyNotify destroy_func; |
65 | } ExtensionImplementation; |
66 | |
67 | struct _BeanObjectModulePrivate { |
68 | GModule *library; |
69 | |
70 | BeanObjectModuleRegisterFunc register_func; |
71 | GArray *implementations; |
72 | |
73 | gchar *path; |
74 | gchar *module_name; |
75 | gchar *symbol; |
76 | |
77 | guint resident : 1; |
78 | guint local_linkage : 1; |
79 | }; |
80 | |
81 | G_DEFINE_TYPE_WITH_PRIVATE (BeanObjectModule,static void bean_object_module_init (BeanObjectModule *self); static void bean_object_module_class_init (BeanObjectModuleClass *klass); static GType bean_object_module_get_type_once (void ); static gpointer bean_object_module_parent_class = ((void*) 0); static gint BeanObjectModule_private_offset; static void bean_object_module_class_intern_init (gpointer klass) { bean_object_module_parent_class = g_type_class_peek_parent (klass); if (BeanObjectModule_private_offset != 0) g_type_class_adjust_private_offset (klass, &BeanObjectModule_private_offset); bean_object_module_class_init ((BeanObjectModuleClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer bean_object_module_get_instance_private (BeanObjectModule *self) { return (((gpointer) ((guint8*) (self ) + (glong) (BeanObjectModule_private_offset)))); } GType bean_object_module_get_type (void) { static gsize static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id )); }))) { GType g_define_type_id = bean_object_module_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id) = (g_define_type_id) ) : (void) 0; g_once_init_leave ((&static_g_define_type_id ), (gsize) (g_define_type_id)); })); } return static_g_define_type_id ; } __attribute__ ((__noinline__)) static GType bean_object_module_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((g_type_module_get_type ()), g_intern_static_string ("BeanObjectModule" ), sizeof (BeanObjectModuleClass), (GClassInitFunc)(void (*)( void)) bean_object_module_class_intern_init, sizeof (BeanObjectModule ), (GInstanceInitFunc)(void (*)(void)) bean_object_module_init , (GTypeFlags) 0); { {{ BeanObjectModule_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (BeanObjectModulePrivate)); };} } return g_define_type_id; } |
82 | bean_object_module,static void bean_object_module_init (BeanObjectModule *self); static void bean_object_module_class_init (BeanObjectModuleClass *klass); static GType bean_object_module_get_type_once (void ); static gpointer bean_object_module_parent_class = ((void*) 0); static gint BeanObjectModule_private_offset; static void bean_object_module_class_intern_init (gpointer klass) { bean_object_module_parent_class = g_type_class_peek_parent (klass); if (BeanObjectModule_private_offset != 0) g_type_class_adjust_private_offset (klass, &BeanObjectModule_private_offset); bean_object_module_class_init ((BeanObjectModuleClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer bean_object_module_get_instance_private (BeanObjectModule *self) { return (((gpointer) ((guint8*) (self ) + (glong) (BeanObjectModule_private_offset)))); } GType bean_object_module_get_type (void) { static gsize static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id )); }))) { GType g_define_type_id = bean_object_module_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id) = (g_define_type_id) ) : (void) 0; g_once_init_leave ((&static_g_define_type_id ), (gsize) (g_define_type_id)); })); } return static_g_define_type_id ; } __attribute__ ((__noinline__)) static GType bean_object_module_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((g_type_module_get_type ()), g_intern_static_string ("BeanObjectModule" ), sizeof (BeanObjectModuleClass), (GClassInitFunc)(void (*)( void)) bean_object_module_class_intern_init, sizeof (BeanObjectModule ), (GInstanceInitFunc)(void (*)(void)) bean_object_module_init , (GTypeFlags) 0); { {{ BeanObjectModule_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (BeanObjectModulePrivate)); };} } return g_define_type_id; } |
83 | G_TYPE_TYPE_MODULE)static void bean_object_module_init (BeanObjectModule *self); static void bean_object_module_class_init (BeanObjectModuleClass *klass); static GType bean_object_module_get_type_once (void ); static gpointer bean_object_module_parent_class = ((void*) 0); static gint BeanObjectModule_private_offset; static void bean_object_module_class_intern_init (gpointer klass) { bean_object_module_parent_class = g_type_class_peek_parent (klass); if (BeanObjectModule_private_offset != 0) g_type_class_adjust_private_offset (klass, &BeanObjectModule_private_offset); bean_object_module_class_init ((BeanObjectModuleClass*) klass); } __attribute__ ((__unused__ )) static inline gpointer bean_object_module_get_instance_private (BeanObjectModule *self) { return (((gpointer) ((guint8*) (self ) + (glong) (BeanObjectModule_private_offset)))); } GType bean_object_module_get_type (void) { static gsize static_g_define_type_id = 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id) == sizeof (gpointer), "Expression evaluates to false"); (void) ( 0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ (*(&static_g_define_type_id)) gapg_temp_newval; __typeof__ ((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id ); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5) ; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id )); }))) { GType g_define_type_id = bean_object_module_get_type_once (); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id ) == sizeof (gpointer), "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id) = (g_define_type_id) ) : (void) 0; g_once_init_leave ((&static_g_define_type_id ), (gsize) (g_define_type_id)); })); } return static_g_define_type_id ; } __attribute__ ((__noinline__)) static GType bean_object_module_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((g_type_module_get_type ()), g_intern_static_string ("BeanObjectModule" ), sizeof (BeanObjectModuleClass), (GClassInitFunc)(void (*)( void)) bean_object_module_class_intern_init, sizeof (BeanObjectModule ), (GInstanceInitFunc)(void (*)(void)) bean_object_module_init , (GTypeFlags) 0); { {{ BeanObjectModule_private_offset = g_type_add_instance_private (g_define_type_id, sizeof (BeanObjectModulePrivate)); };} } return g_define_type_id; } |
84 | |
85 | #define GET_PRIV(o)(bean_object_module_get_instance_private (o)) \ |
86 | (bean_object_module_get_instance_private (o)) |
87 | |
88 | #define TYPE_MISSING_PLUGIN_INFO_PROPERTY(((GType) (1 << 0))) (G_TYPE_FLAG_RESERVED_ID_BIT((GType) (1 << 0))) |
89 | |
90 | static const gchar *intern_plugin_info = NULL((void*)0); |
91 | |
92 | static gboolean |
93 | bean_object_module_load (GTypeModule *gmodule) |
94 | { |
95 | BeanObjectModule *module = BEAN_OBJECT_MODULE (gmodule)((((BeanObjectModule*) (void *) ((gmodule))))); |
96 | BeanObjectModulePrivate *priv = GET_PRIV (module)(bean_object_module_get_instance_private (module)); |
97 | |
98 | g_return_val_if_fail (priv->module_name != NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_36 = 0; if (priv->module_name != ((void*)0)) _g_boolean_var_36 = 1; _g_boolean_var_36; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__)), "priv->module_name != NULL" ); return ((0)); } } while (0); |
99 | |
100 | if (priv->path == NULL((void*)0)) |
101 | { |
102 | g_return_val_if_fail (priv->resident, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_37 = 0; if (priv->resident) _g_boolean_var_37 = 1; _g_boolean_var_37 ; }), 1))) { } else { g_return_if_fail_warning ("libbean", (( const char*) (__func__)), "priv->resident"); return ((0)); } } while (0); |
103 | g_return_val_if_fail (!priv->local_linkage, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_38 = 0; if (!priv->local_linkage) _g_boolean_var_38 = 1; _g_boolean_var_38 ; }), 1))) { } else { g_return_if_fail_warning ("libbean", (( const char*) (__func__)), "!priv->local_linkage"); return ( (0)); } } while (0); |
104 | |
105 | priv->library = g_module_open (NULL((void*)0), 0); |
106 | } |
107 | else |
108 | { |
109 | gchar *path; |
110 | GModuleFlags flags = 0; |
111 | |
112 | path = g_module_build_path (priv->path, priv->module_name); |
113 | |
114 | /* g_module_build_path() will add G_MODULE_SUFFIX to the path, |
115 | * however g_module_open() will only try to load the libtool archive |
116 | * if there is no suffix specified. So we remove G_MODULE_SUFFIX here |
117 | * which allows uninstalled builds to load plugins as well, as there |
118 | * is only the .la file in the build directory. |
119 | */ |
120 | if (G_MODULE_SUFFIX"so"[0] != '\0' && g_str_has_suffix (path, "." G_MODULE_SUFFIX)(__builtin_constant_p ("." "so")? __extension__ ({ const char * const __str = (path); const char * const __suffix = ("." "so" ); gboolean __result = (0); if (__builtin_expect (__extension__ ({ int _g_boolean_var_39 = 0; if (__str == ((void*)0) || __suffix == ((void*)0)) _g_boolean_var_39 = 1; _g_boolean_var_39; }), 0)) __result = (g_str_has_suffix) (__str, __suffix); else { const size_t __str_len = strlen (((__str) + !(__str))); const size_t __suffix_len = strlen (((__suffix) + !(__suffix))); if (__str_len >= __suffix_len) __result = memcmp (__str + __str_len - __suffix_len , ((__suffix) + !(__suffix)), __suffix_len) == 0; } __result; }) : (g_str_has_suffix) (path, "." "so") )) |
121 | path[strlen (path) - strlen (G_MODULE_SUFFIX"so") - 1] = '\0'; |
122 | |
123 | if (priv->local_linkage) |
124 | flags = G_MODULE_BIND_LOCAL; |
125 | |
126 | /* Bind symbols immediately to avoid errors long after loading */ |
127 | priv->library = g_module_open (path, flags); |
128 | g_free (path); |
129 | } |
130 | |
131 | if (priv->library == NULL((void*)0)) |
132 | { |
133 | g_warning ("Failed to load module '%s': %s", |
134 | priv->module_name, g_module_error ()); |
135 | |
136 | return FALSE(0); |
137 | } |
138 | |
139 | /* Extract the required symbol from the library */ |
140 | if (!g_module_symbol (priv->library, priv->symbol, |
141 | (gpointer) &priv->register_func)) |
142 | { |
143 | g_warning ("Failed to get '%s' for module '%s': %s", |
144 | priv->symbol, priv->module_name, g_module_error ()); |
145 | g_module_close (priv->library); |
146 | |
147 | return FALSE(0); |
148 | } |
149 | |
150 | /* The symbol can still be NULL even |
151 | * though g_module_symbol() returned TRUE |
152 | */ |
153 | if (priv->register_func == NULL((void*)0)) |
154 | { |
155 | g_warning ("Invalid '%s' in module '%s'", |
156 | priv->symbol, priv->module_name); |
157 | g_module_close (priv->library); |
158 | |
159 | return FALSE(0); |
160 | } |
161 | |
162 | if (priv->resident) |
163 | g_module_make_resident (priv->library); |
164 | |
165 | priv->register_func (module); |
166 | |
167 | return TRUE(!(0)); |
168 | } |
169 | |
170 | static void |
171 | bean_object_module_unload (GTypeModule *gmodule) |
172 | { |
173 | BeanObjectModule *module = BEAN_OBJECT_MODULE (gmodule)((((BeanObjectModule*) (void *) ((gmodule))))); |
174 | BeanObjectModulePrivate *priv = GET_PRIV (module)(bean_object_module_get_instance_private (module)); |
175 | ExtensionImplementation *impls; |
176 | guint i; |
177 | |
178 | g_module_close (priv->library); |
179 | |
180 | priv->library = NULL((void*)0); |
181 | priv->register_func = NULL((void*)0); |
182 | |
183 | impls = (ExtensionImplementation *) priv->implementations->data; |
184 | for (i = 0; i < priv->implementations->len; ++i) |
185 | { |
186 | if (impls[i].destroy_func != NULL((void*)0)) |
187 | impls[i].destroy_func (impls[i].user_data); |
188 | } |
189 | |
190 | g_array_remove_range (priv->implementations, 0, |
191 | priv->implementations->len); |
192 | } |
193 | |
194 | static void |
195 | bean_object_module_init (BeanObjectModule *module) |
196 | { |
197 | BeanObjectModulePrivate *priv = GET_PRIV (module)(bean_object_module_get_instance_private (module)); |
198 | |
199 | priv->implementations = g_array_new (FALSE(0), FALSE(0), |
200 | sizeof (ExtensionImplementation)); |
201 | } |
202 | |
203 | static void |
204 | bean_object_module_finalize (GObject *object) |
205 | { |
206 | BeanObjectModule *module = BEAN_OBJECT_MODULE (object)((((BeanObjectModule*) (void *) ((object))))); |
207 | BeanObjectModulePrivate *priv = GET_PRIV (module)(bean_object_module_get_instance_private (module)); |
208 | |
209 | g_free (priv->path); |
210 | g_free (priv->module_name); |
211 | g_free (priv->symbol); |
212 | g_array_unref (priv->implementations); |
213 | |
214 | G_OBJECT_CLASS (bean_object_module_parent_class)((((GObjectClass*) (void *) ((bean_object_module_parent_class )))))->finalize (object); |
215 | } |
216 | |
217 | static void |
218 | bean_object_module_get_property (GObject *object, |
219 | guint prop_id, |
220 | GValue *value, |
221 | GParamSpec *pspec) |
222 | { |
223 | BeanObjectModule *module = BEAN_OBJECT_MODULE (object)((((BeanObjectModule*) (void *) ((object))))); |
224 | BeanObjectModulePrivate *priv = GET_PRIV (module)(bean_object_module_get_instance_private (module)); |
225 | |
226 | switch (prop_id) |
227 | { |
228 | case PROP_MODULE_NAME: |
229 | g_value_set_string (value, priv->module_name); |
230 | break; |
231 | case PROP_PATH: |
232 | g_value_set_string (value, priv->path); |
233 | break; |
234 | case PROP_SYMBOL: |
235 | g_value_set_string (value, priv->symbol); |
236 | break; |
237 | case PROP_RESIDENT: |
238 | g_value_set_boolean (value, priv->resident); |
239 | break; |
240 | case PROP_LOCAL_LINKAGE: |
241 | g_value_set_boolean (value, priv->local_linkage); |
242 | break; |
243 | default: |
244 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "../libbean/bean-object-module.c", 244, ("property"), _glib__property_id , _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance *) (_glib__pspec))->g_class))->g_type)))), (g_type_name ((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); |
245 | break; |
246 | } |
247 | } |
248 | |
249 | static void |
250 | bean_object_module_set_property (GObject *object, |
251 | guint prop_id, |
252 | const GValue *value, |
253 | GParamSpec *pspec) |
254 | { |
255 | BeanObjectModule *module = BEAN_OBJECT_MODULE (object)((((BeanObjectModule*) (void *) ((object))))); |
256 | BeanObjectModulePrivate *priv = GET_PRIV (module)(bean_object_module_get_instance_private (module)); |
257 | |
258 | switch (prop_id) |
259 | { |
260 | case PROP_MODULE_NAME: |
261 | priv->module_name = g_value_dup_string (value); |
262 | g_type_module_set_name (G_TYPE_MODULE (object)((((GTypeModule*) (void *) ((object))))), |
263 | priv->module_name); |
264 | break; |
265 | case PROP_PATH: |
266 | priv->path = g_value_dup_string (value); |
267 | break; |
268 | case PROP_SYMBOL: |
269 | priv->symbol = g_value_dup_string (value); |
270 | break; |
271 | case PROP_RESIDENT: |
272 | priv->resident = g_value_get_boolean (value); |
273 | break; |
274 | case PROP_LOCAL_LINKAGE: |
275 | priv->local_linkage = g_value_get_boolean (value); |
276 | break; |
277 | default: |
278 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec *_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id = ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'" , "../libbean/bean-object-module.c", 278, ("property"), _glib__property_id , _glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance *) (_glib__pspec))->g_class))->g_type)))), (g_type_name ((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class ))->g_type)))))); } while (0); |
279 | break; |
280 | } |
281 | } |
282 | |
283 | static void |
284 | bean_object_module_class_init (BeanObjectModuleClass *klass) |
285 | { |
286 | GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) ((klass))))); |
287 | GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (klass)((((GTypeModuleClass*) (void *) ((klass))))); |
288 | |
289 | intern_plugin_info = g_intern_static_string ("plugin-info"); |
290 | |
291 | object_class->set_property = bean_object_module_set_property; |
292 | object_class->get_property = bean_object_module_get_property; |
293 | object_class->finalize = bean_object_module_finalize; |
294 | |
295 | module_class->load = bean_object_module_load; |
296 | module_class->unload = bean_object_module_unload; |
297 | |
298 | properties[PROP_MODULE_NAME] = |
299 | g_param_spec_string ("module-name", |
300 | "Module Name", |
301 | "The module to load for this object", |
302 | NULL((void*)0), |
303 | G_PARAM_READWRITE | |
304 | G_PARAM_CONSTRUCT_ONLY | |
305 | G_PARAM_STATIC_STRINGS(G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB )); |
306 | |
307 | properties[PROP_PATH] = |
308 | g_param_spec_string ("path", |
309 | "Path", |
310 | "The path to use when loading this module", |
311 | NULL((void*)0), |
312 | G_PARAM_READWRITE | |
313 | G_PARAM_CONSTRUCT_ONLY | |
314 | G_PARAM_STATIC_STRINGS(G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB )); |
315 | |
316 | properties[PROP_SYMBOL] = |
317 | g_param_spec_string ("symbol", |
318 | "Symbol", |
319 | "The registration symbol to use for this module", |
320 | "bean_register_types", |
321 | G_PARAM_READWRITE | |
322 | G_PARAM_CONSTRUCT_ONLY | |
323 | G_PARAM_STATIC_STRINGS(G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB )); |
324 | |
325 | properties[PROP_RESIDENT] = |
326 | g_param_spec_boolean ("resident", |
327 | "Resident", |
328 | "Whether the module is resident", |
329 | FALSE(0), |
330 | G_PARAM_READWRITE | |
331 | G_PARAM_CONSTRUCT_ONLY | |
332 | G_PARAM_STATIC_STRINGS(G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB )); |
333 | |
334 | /** |
335 | * BeanObjectModule:local-linkage |
336 | * |
337 | * This property indicates whether the module is loaded with |
338 | * local linkage, i.e. #G_MODULE_BIND_LOCAL. |
339 | * |
340 | * Since 1.14 |
341 | */ |
342 | properties[PROP_LOCAL_LINKAGE] = |
343 | g_param_spec_boolean ("local-linkage", |
344 | "Local linkage", |
345 | "Whether the module loaded with local linkage", |
346 | FALSE(0), |
347 | G_PARAM_READWRITE | |
348 | G_PARAM_CONSTRUCT_ONLY | |
349 | G_PARAM_STATIC_STRINGS(G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB )); |
350 | |
351 | g_object_class_install_properties (object_class, N_PROPERTIES, properties); |
352 | } |
353 | |
354 | /** |
355 | * bean_object_module_new: (skip) |
356 | * @module_name: The module name. |
357 | * @path: The path. |
358 | * @resident: If the module should be resident. |
359 | * |
360 | * Creates a new #BeanObjectModule. |
361 | * |
362 | * Return value: a new #BeanObjectModule. |
363 | */ |
364 | BeanObjectModule * |
365 | bean_object_module_new (const gchar *module_name, |
366 | const gchar *path, |
367 | gboolean resident) |
368 | { |
369 | g_return_val_if_fail (module_name != NULL && *module_name != '\0', NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_40 = 0; if (module_name != ((void*)0) && *module_name != '\0') _g_boolean_var_40 = 1; _g_boolean_var_40; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) ( __func__)), "module_name != NULL && *module_name != '\\0'" ); return (((void*)0)); } } while (0); |
370 | g_return_val_if_fail (path != NULL && *path != '\0', NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_41 = 0; if (path != ((void*)0) && *path != '\0') _g_boolean_var_41 = 1; _g_boolean_var_41; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__)), "path != NULL && *path != '\\0'" ); return (((void*)0)); } } while (0); |
371 | |
372 | return BEAN_OBJECT_MODULE (g_object_new (BEAN_TYPE_OBJECT_MODULE,((((BeanObjectModule*) (void *) ((g_object_new ((bean_object_module_get_type ()), "module-name", module_name, "path", path, "resident", resident , ((void*)0))))))) |
373 | "module-name", module_name,((((BeanObjectModule*) (void *) ((g_object_new ((bean_object_module_get_type ()), "module-name", module_name, "path", path, "resident", resident , ((void*)0))))))) |
374 | "path", path,((((BeanObjectModule*) (void *) ((g_object_new ((bean_object_module_get_type ()), "module-name", module_name, "path", path, "resident", resident , ((void*)0))))))) |
375 | "resident", resident,((((BeanObjectModule*) (void *) ((g_object_new ((bean_object_module_get_type ()), "module-name", module_name, "path", path, "resident", resident , ((void*)0))))))) |
376 | NULL))((((BeanObjectModule*) (void *) ((g_object_new ((bean_object_module_get_type ()), "module-name", module_name, "path", path, "resident", resident , ((void*)0))))))); |
377 | } |
378 | |
379 | /** |
380 | * bean_object_module_new_full: (skip) |
381 | * @module_name: The module name. |
382 | * @path: The path. |
383 | * @resident: If the module should be resident. |
384 | * @local_linkage: Whether to load the module with local linkage. |
385 | * |
386 | * Creates a new #BeanObjectModule. |
387 | * |
388 | * Return value: a new #BeanObjectModule. |
389 | * |
390 | * Since 1.14 |
391 | */ |
392 | BeanObjectModule * |
393 | bean_object_module_new_full (const gchar *module_name, |
394 | const gchar *path, |
395 | gboolean resident, |
396 | gboolean local_linkage) |
397 | { |
398 | g_return_val_if_fail (module_name != NULL && *module_name != '\0', NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_42 = 0; if (module_name != ((void*)0) && *module_name != '\0') _g_boolean_var_42 = 1; _g_boolean_var_42; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) ( __func__)), "module_name != NULL && *module_name != '\\0'" ); return (((void*)0)); } } while (0); |
399 | g_return_val_if_fail (path != NULL && *path != '\0', NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_43 = 0; if (path != ((void*)0) && *path != '\0') _g_boolean_var_43 = 1; _g_boolean_var_43; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__)), "path != NULL && *path != '\\0'" ); return (((void*)0)); } } while (0); |
400 | |
401 | return BEAN_OBJECT_MODULE (g_object_new (BEAN_TYPE_OBJECT_MODULE,((((BeanObjectModule*) (void *) ((g_object_new ((bean_object_module_get_type ()), "module-name", module_name, "path", path, "resident", resident , "local-linkage", local_linkage, ((void*)0))))))) |
402 | "module-name", module_name,((((BeanObjectModule*) (void *) ((g_object_new ((bean_object_module_get_type ()), "module-name", module_name, "path", path, "resident", resident , "local-linkage", local_linkage, ((void*)0))))))) |
403 | "path", path,((((BeanObjectModule*) (void *) ((g_object_new ((bean_object_module_get_type ()), "module-name", module_name, "path", path, "resident", resident , "local-linkage", local_linkage, ((void*)0))))))) |
404 | "resident", resident,((((BeanObjectModule*) (void *) ((g_object_new ((bean_object_module_get_type ()), "module-name", module_name, "path", path, "resident", resident , "local-linkage", local_linkage, ((void*)0))))))) |
405 | "local-linkage", local_linkage,((((BeanObjectModule*) (void *) ((g_object_new ((bean_object_module_get_type ()), "module-name", module_name, "path", path, "resident", resident , "local-linkage", local_linkage, ((void*)0))))))) |
406 | NULL))((((BeanObjectModule*) (void *) ((g_object_new ((bean_object_module_get_type ()), "module-name", module_name, "path", path, "resident", resident , "local-linkage", local_linkage, ((void*)0))))))); |
407 | } |
408 | |
409 | /** |
410 | * bean_object_module_new_embedded: (skip) |
411 | * @module_name: The module name. |
412 | * |
413 | * Creates a new #BeanObjectModule for an embedded plugin. |
414 | * |
415 | * Return value: a new #BeanObjectModule. |
416 | * |
417 | * Since: 1.18 |
418 | */ |
419 | BeanObjectModule * |
420 | bean_object_module_new_embedded (const gchar *module_name, |
421 | const gchar *symbol) |
422 | { |
423 | g_return_val_if_fail (module_name != NULL && *module_name != '\0', NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_44 = 0; if (module_name != ((void*)0) && *module_name != '\0') _g_boolean_var_44 = 1; _g_boolean_var_44; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) ( __func__)), "module_name != NULL && *module_name != '\\0'" ); return (((void*)0)); } } while (0); |
424 | g_return_val_if_fail (symbol != NULL && *symbol != '\0', NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_45 = 0; if (symbol != ((void*)0) && *symbol != '\0') _g_boolean_var_45 = 1; _g_boolean_var_45; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__)), "symbol != NULL && *symbol != '\\0'" ); return (((void*)0)); } } while (0); |
425 | |
426 | return BEAN_OBJECT_MODULE (g_object_new (BEAN_TYPE_OBJECT_MODULE,((((BeanObjectModule*) (void *) ((g_object_new ((bean_object_module_get_type ()), "module-name", module_name, "symbol", symbol, "resident" , (!(0)), "local-linkage", (0), ((void*)0))))))) |
427 | "module-name", module_name,((((BeanObjectModule*) (void *) ((g_object_new ((bean_object_module_get_type ()), "module-name", module_name, "symbol", symbol, "resident" , (!(0)), "local-linkage", (0), ((void*)0))))))) |
428 | "symbol", symbol,((((BeanObjectModule*) (void *) ((g_object_new ((bean_object_module_get_type ()), "module-name", module_name, "symbol", symbol, "resident" , (!(0)), "local-linkage", (0), ((void*)0))))))) |
429 | "resident", TRUE,((((BeanObjectModule*) (void *) ((g_object_new ((bean_object_module_get_type ()), "module-name", module_name, "symbol", symbol, "resident" , (!(0)), "local-linkage", (0), ((void*)0))))))) |
430 | "local-linkage", FALSE,((((BeanObjectModule*) (void *) ((g_object_new ((bean_object_module_get_type ()), "module-name", module_name, "symbol", symbol, "resident" , (!(0)), "local-linkage", (0), ((void*)0))))))) |
431 | NULL))((((BeanObjectModule*) (void *) ((g_object_new ((bean_object_module_get_type ()), "module-name", module_name, "symbol", symbol, "resident" , (!(0)), "local-linkage", (0), ((void*)0))))))); |
432 | } |
433 | |
434 | /** |
435 | * bean_object_module_create_object: (skip) |
436 | * @module: A #BeanObjectModule. |
437 | * @exten_type: The #GType of the extension. |
438 | * @n_parameters: The number of paramteters. |
439 | * @parameters: (array length=n_parameters): The parameters. |
440 | * |
441 | * Creates an object for the @exten_type passing @n_parameters |
442 | * and @parameters to the #BeanFactoryFunc. If @module does |
443 | * not provide a #BeanFactoryFunc for @exten_type then |
444 | * %NULL is returned. |
445 | * |
446 | * Since libbean 1.22, @exten_type can be an Abstract #GType |
447 | * and not just an Interface #GType. |
448 | * |
449 | * Return value: (transfer full): The created object, or %NULL. |
450 | */ |
451 | GObject * |
452 | bean_object_module_create_object (BeanObjectModule *module, |
453 | GType exten_type, |
454 | guint n_parameters, |
455 | GParameter *parameters) |
456 | { |
457 | BeanObjectModulePrivate *priv = GET_PRIV (module)(bean_object_module_get_instance_private (module)); |
458 | guint i; |
459 | ExtensionImplementation *impls; |
460 | |
461 | g_return_val_if_fail (BEAN_IS_OBJECT_MODULE (module), NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_46 = 0; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((module)); GType __t = ((bean_object_module_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } ))))) _g_boolean_var_46 = 1; _g_boolean_var_46; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__ )), "BEAN_IS_OBJECT_MODULE (module)"); return (((void*)0)); } } while (0); |
462 | g_return_val_if_fail (G_TYPE_IS_INTERFACE (exten_type) ||do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_47 = 0; if (((g_type_fundamental (exten_type)) == ((GType) ((2) << (2)))) || (g_type_test_flags ((exten_type), G_TYPE_FLAG_ABSTRACT ))) _g_boolean_var_47 = 1; _g_boolean_var_47; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__ )), "G_TYPE_IS_INTERFACE (exten_type) || G_TYPE_IS_ABSTRACT (exten_type)" ); return (((void*)0)); } } while (0) |
463 | G_TYPE_IS_ABSTRACT (exten_type), NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_47 = 0; if (((g_type_fundamental (exten_type)) == ((GType) ((2) << (2)))) || (g_type_test_flags ((exten_type), G_TYPE_FLAG_ABSTRACT ))) _g_boolean_var_47 = 1; _g_boolean_var_47; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__ )), "G_TYPE_IS_INTERFACE (exten_type) || G_TYPE_IS_ABSTRACT (exten_type)" ); return (((void*)0)); } } while (0); |
464 | |
465 | impls = (ExtensionImplementation *) priv->implementations->data; |
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption | |
466 | for (i = 0; i < priv->implementations->len; ++i) |
467 | { |
468 | if (impls[i].exten_type == exten_type) |
469 | return impls[i].func (n_parameters, parameters, impls[i].user_data); |
470 | } |
471 | |
472 | return NULL((void*)0); |
473 | } |
474 | |
475 | /** |
476 | * bean_object_module_provides_object: (skip) |
477 | * @module: A #BeanObjectModule. |
478 | * @exten_type: The #GType of the extension. |
479 | * |
480 | * Determines if the module provides an extension for @exten_type. |
481 | * |
482 | * Since libbean 1.22, @exten_type can be an Abstract #GType |
483 | * and not just an Interface #GType. |
484 | * |
485 | * Return value: if the module provides an extension for @exten_type. |
486 | */ |
487 | gboolean |
488 | bean_object_module_provides_object (BeanObjectModule *module, |
489 | GType exten_type) |
490 | { |
491 | BeanObjectModulePrivate *priv = GET_PRIV (module)(bean_object_module_get_instance_private (module)); |
492 | guint i; |
493 | ExtensionImplementation *impls; |
494 | |
495 | g_return_val_if_fail (BEAN_IS_OBJECT_MODULE (module), FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_48 = 0; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((module)); GType __t = ((bean_object_module_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } ))))) _g_boolean_var_48 = 1; _g_boolean_var_48; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__ )), "BEAN_IS_OBJECT_MODULE (module)"); return ((0)); } } while (0); |
496 | g_return_val_if_fail (G_TYPE_IS_INTERFACE (exten_type) ||do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_49 = 0; if (((g_type_fundamental (exten_type)) == ((GType) ((2) << (2)))) || (g_type_test_flags ((exten_type), G_TYPE_FLAG_ABSTRACT ))) _g_boolean_var_49 = 1; _g_boolean_var_49; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__ )), "G_TYPE_IS_INTERFACE (exten_type) || G_TYPE_IS_ABSTRACT (exten_type)" ); return ((0)); } } while (0) |
497 | G_TYPE_IS_ABSTRACT (exten_type), FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_49 = 0; if (((g_type_fundamental (exten_type)) == ((GType) ((2) << (2)))) || (g_type_test_flags ((exten_type), G_TYPE_FLAG_ABSTRACT ))) _g_boolean_var_49 = 1; _g_boolean_var_49; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__ )), "G_TYPE_IS_INTERFACE (exten_type) || G_TYPE_IS_ABSTRACT (exten_type)" ); return ((0)); } } while (0); |
498 | |
499 | impls = (ExtensionImplementation *) priv->implementations->data; |
500 | for (i = 0; i < priv->implementations->len; ++i) |
501 | { |
502 | if (impls[i].exten_type == exten_type) |
503 | return TRUE(!(0)); |
504 | } |
505 | |
506 | return FALSE(0); |
507 | } |
508 | |
509 | /** |
510 | * bean_object_module_get_path: (skip) |
511 | * @module: A #BeanObjectModule. |
512 | * |
513 | * Gets the path. |
514 | * |
515 | * Return value: the path. |
516 | */ |
517 | const gchar * |
518 | bean_object_module_get_path (BeanObjectModule *module) |
519 | { |
520 | BeanObjectModulePrivate *priv = GET_PRIV (module)(bean_object_module_get_instance_private (module)); |
521 | |
522 | g_return_val_if_fail (BEAN_IS_OBJECT_MODULE (module), NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_50 = 0; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((module)); GType __t = ((bean_object_module_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } ))))) _g_boolean_var_50 = 1; _g_boolean_var_50; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__ )), "BEAN_IS_OBJECT_MODULE (module)"); return (((void*)0)); } } while (0); |
523 | |
524 | return priv->path; |
525 | } |
526 | |
527 | /** |
528 | * bean_object_module_get_module_name: (skip) |
529 | * @module: A #BeanObjectModule. |
530 | * |
531 | * Gets the module name. |
532 | * |
533 | * Return value: the module name. |
534 | */ |
535 | const gchar * |
536 | bean_object_module_get_module_name (BeanObjectModule *module) |
537 | { |
538 | BeanObjectModulePrivate *priv = GET_PRIV (module)(bean_object_module_get_instance_private (module)); |
539 | |
540 | g_return_val_if_fail (BEAN_IS_OBJECT_MODULE (module), NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_51 = 0; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((module)); GType __t = ((bean_object_module_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } ))))) _g_boolean_var_51 = 1; _g_boolean_var_51; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__ )), "BEAN_IS_OBJECT_MODULE (module)"); return (((void*)0)); } } while (0); |
541 | |
542 | return priv->module_name; |
543 | } |
544 | |
545 | /** |
546 | * bean_object_module_get_symbol: (skip) |
547 | * @module: A #BeanObjectModule. |
548 | * |
549 | * Gets the symbol name used to register extension implementations. |
550 | * |
551 | * Return value: the symbol name. |
552 | * |
553 | * Since: 1.18 |
554 | */ |
555 | const gchar * |
556 | bean_object_module_get_symbol (BeanObjectModule *module) |
557 | { |
558 | BeanObjectModulePrivate *priv = GET_PRIV (module)(bean_object_module_get_instance_private (module)); |
559 | |
560 | g_return_val_if_fail (BEAN_IS_OBJECT_MODULE (module), NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_52 = 0; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((module)); GType __t = ((bean_object_module_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } ))))) _g_boolean_var_52 = 1; _g_boolean_var_52; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__ )), "BEAN_IS_OBJECT_MODULE (module)"); return (((void*)0)); } } while (0); |
561 | |
562 | return priv->symbol; |
563 | } |
564 | |
565 | /** |
566 | * bean_object_module_get_library: (skip) |
567 | * @module: A #BeanObjectModule. |
568 | * |
569 | * Gets the library. |
570 | * |
571 | * Return value: the library. |
572 | */ |
573 | GModule * |
574 | bean_object_module_get_library (BeanObjectModule *module) |
575 | { |
576 | BeanObjectModulePrivate *priv = GET_PRIV (module)(bean_object_module_get_instance_private (module)); |
577 | |
578 | g_return_val_if_fail (BEAN_IS_OBJECT_MODULE (module), NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_53 = 0; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((module)); GType __t = ((bean_object_module_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } ))))) _g_boolean_var_53 = 1; _g_boolean_var_53; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__ )), "BEAN_IS_OBJECT_MODULE (module)"); return (((void*)0)); } } while (0); |
579 | |
580 | return priv->library; |
581 | } |
582 | |
583 | /** |
584 | * bean_object_module_register_extension_factory: |
585 | * @module: Your plugin's #BeanObjectModule. |
586 | * @exten_type: The #GType of the extension you implement. |
587 | * @factory_func: The #BeanFactoryFunc that will create the @exten_type |
588 | * instance when requested. |
589 | * @user_data: Data to pass to @func calls. |
590 | * @destroy_func: A #GDestroyNotify for @user_data. |
591 | * |
592 | * Register an implementation for an extension type through a factory |
593 | * function @factory_func which will instantiate the extension when |
594 | * requested. |
595 | * |
596 | * This method is primarily meant to be used by native bindings (like ctkmm), |
597 | * creating native types which cannot be instantiated correctly using |
598 | * g_object_new(). For other uses, you will usually prefer relying on |
599 | * bean_object_module_register_extension_type(). |
600 | * |
601 | * Since libbean 1.22, @exten_type can be an Abstract #GType |
602 | * and not just an Interface #GType. |
603 | */ |
604 | void |
605 | bean_object_module_register_extension_factory (BeanObjectModule *module, |
606 | GType exten_type, |
607 | BeanFactoryFunc factory_func, |
608 | gpointer user_data, |
609 | GDestroyNotify destroy_func) |
610 | { |
611 | BeanObjectModulePrivate *priv = GET_PRIV (module)(bean_object_module_get_instance_private (module)); |
612 | ExtensionImplementation impl = { exten_type, factory_func, user_data, destroy_func }; |
613 | |
614 | g_return_if_fail (BEAN_IS_OBJECT_MODULE (module))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_54 = 0; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((module)); GType __t = ((bean_object_module_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } ))))) _g_boolean_var_54 = 1; _g_boolean_var_54; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__ )), "BEAN_IS_OBJECT_MODULE (module)"); return; } } while (0); |
615 | g_return_if_fail (G_TYPE_IS_INTERFACE (exten_type) ||do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_55 = 0; if (((g_type_fundamental (exten_type)) == ((GType) ((2) << (2)))) || (g_type_test_flags ((exten_type), G_TYPE_FLAG_ABSTRACT ))) _g_boolean_var_55 = 1; _g_boolean_var_55; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__ )), "G_TYPE_IS_INTERFACE (exten_type) || G_TYPE_IS_ABSTRACT (exten_type)" ); return; } } while (0) |
616 | G_TYPE_IS_ABSTRACT (exten_type))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_55 = 0; if (((g_type_fundamental (exten_type)) == ((GType) ((2) << (2)))) || (g_type_test_flags ((exten_type), G_TYPE_FLAG_ABSTRACT ))) _g_boolean_var_55 = 1; _g_boolean_var_55; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__ )), "G_TYPE_IS_INTERFACE (exten_type) || G_TYPE_IS_ABSTRACT (exten_type)" ); return; } } while (0); |
617 | g_return_if_fail (!bean_object_module_provides_object (module, exten_type))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_56 = 0; if (!bean_object_module_provides_object (module, exten_type )) _g_boolean_var_56 = 1; _g_boolean_var_56; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__ )), "!bean_object_module_provides_object (module, exten_type)" ); return; } } while (0); |
618 | g_return_if_fail (factory_func != NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_57 = 0; if (factory_func != ((void*)0)) _g_boolean_var_57 = 1; _g_boolean_var_57 ; }), 1))) { } else { g_return_if_fail_warning ("libbean", (( const char*) (__func__)), "factory_func != NULL"); return; } } while (0); |
619 | |
620 | g_array_append_val (priv->implementations, impl)g_array_append_vals (priv->implementations, &(impl), 1 ); |
621 | |
622 | g_debug ("Registered extension for type '%s'", g_type_name (exten_type)); |
623 | } |
624 | |
625 | static GObject * |
626 | create_gobject_from_type (guint n_parameters, |
627 | GParameter *parameters, |
628 | gpointer user_data) |
629 | { |
630 | GType impl_type = GPOINTER_TO_SIZE (user_data)((gsize) (user_data)); |
631 | |
632 | /* We should be called with a "plugin-info" property appended |
633 | * to the parameters. Let's get rid of it if the actual type |
634 | * doesn't have such a property as it would cause a warning. |
635 | */ |
636 | if ((impl_type & TYPE_MISSING_PLUGIN_INFO_PROPERTY(((GType) (1 << 0)))) != 0) |
637 | { |
638 | impl_type &= ~TYPE_MISSING_PLUGIN_INFO_PROPERTY(((GType) (1 << 0))); |
639 | |
640 | if (n_parameters > 0) |
641 | { |
642 | GParameter *info_param = ¶meters[n_parameters - 1]; |
643 | |
644 | if (info_param->name == intern_plugin_info && |
645 | G_VALUE_TYPE (&info_param->value)(((GValue*) (&info_param->value))->g_type) == BEAN_TYPE_PLUGIN_INFO(bean_plugin_info_get_type ())) |
646 | { |
647 | n_parameters--; |
648 | } |
649 | } |
650 | } |
651 | |
652 | return G_OBJECT (g_object_newv (impl_type, n_parameters, parameters))((((GObject*) (void *) ((g_object_newv (impl_type, n_parameters , parameters)))))); |
653 | } |
654 | |
655 | /** |
656 | * bean_object_module_register_extension_type: |
657 | * @module: Your plugin's #BeanObjectModule. |
658 | * @exten_type: The #GType of the extension you implement. |
659 | * @impl_type: The #GType of your implementation of @exten_type. |
660 | * |
661 | * Register @impl_type as an extension which implements @extension_type. |
662 | * |
663 | * Since libbean 1.22, @exten_type can be an Abstract #GType |
664 | * and not just an Interface #GType. |
665 | */ |
666 | void |
667 | bean_object_module_register_extension_type (BeanObjectModule *module, |
668 | GType exten_type, |
669 | GType impl_type) |
670 | { |
671 | GObjectClass *cls; |
672 | GParamSpec *pspec; |
673 | |
674 | g_return_if_fail (BEAN_IS_OBJECT_MODULE (module))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_58 = 0; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance *) ((module)); GType __t = ((bean_object_module_get_type ())) ; gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0) ); else __r = g_type_check_instance_is_a (__inst, __t); __r; } ))))) _g_boolean_var_58 = 1; _g_boolean_var_58; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__ )), "BEAN_IS_OBJECT_MODULE (module)"); return; } } while (0); |
675 | g_return_if_fail (G_TYPE_IS_INTERFACE (exten_type) ||do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_59 = 0; if (((g_type_fundamental (exten_type)) == ((GType) ((2) << (2)))) || (g_type_test_flags ((exten_type), G_TYPE_FLAG_ABSTRACT ))) _g_boolean_var_59 = 1; _g_boolean_var_59; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__ )), "G_TYPE_IS_INTERFACE (exten_type) || G_TYPE_IS_ABSTRACT (exten_type)" ); return; } } while (0) |
676 | G_TYPE_IS_ABSTRACT (exten_type))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_59 = 0; if (((g_type_fundamental (exten_type)) == ((GType) ((2) << (2)))) || (g_type_test_flags ((exten_type), G_TYPE_FLAG_ABSTRACT ))) _g_boolean_var_59 = 1; _g_boolean_var_59; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__ )), "G_TYPE_IS_INTERFACE (exten_type) || G_TYPE_IS_ABSTRACT (exten_type)" ); return; } } while (0); |
677 | g_return_if_fail (!bean_object_module_provides_object (module, exten_type))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_60 = 0; if (!bean_object_module_provides_object (module, exten_type )) _g_boolean_var_60 = 1; _g_boolean_var_60; }), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__ )), "!bean_object_module_provides_object (module, exten_type)" ); return; } } while (0); |
678 | g_return_if_fail (g_type_is_a (impl_type, exten_type))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_61 = 0; if (((impl_type) == (exten_type) || (g_type_is_a) ((impl_type ), (exten_type)))) _g_boolean_var_61 = 1; _g_boolean_var_61; } ), 1))) { } else { g_return_if_fail_warning ("libbean", ((const char*) (__func__)), "g_type_is_a (impl_type, exten_type)"); return ; } } while (0); |
679 | |
680 | cls = g_type_class_ref (impl_type); |
681 | pspec = g_object_class_find_property (cls, "plugin-info"); |
682 | |
683 | /* Avoid checking for this each time in the factory function */ |
684 | if (pspec == NULL((void*)0) || pspec->value_type != BEAN_TYPE_PLUGIN_INFO(bean_plugin_info_get_type ())) |
685 | impl_type |= TYPE_MISSING_PLUGIN_INFO_PROPERTY(((GType) (1 << 0))); |
686 | |
687 | bean_object_module_register_extension_factory (module, |
688 | exten_type, |
689 | create_gobject_from_type, |
690 | GSIZE_TO_POINTER (impl_type)((gpointer) (guintptr) (gsize) (impl_type)), |
691 | NULL((void*)0)); |
692 | |
693 | g_type_class_unref (cls); |
694 | } |