Commit 74576b2abc2e0a7c35de363aafde675adf5ed766
1 parent
4a39f052
Exists in
master
and in
1 other branch
Adding compatibility macros.
Showing
2 changed files
with
34 additions
and
9 deletions
Show diff stats
src/include/internals.h
... | ... | @@ -43,15 +43,7 @@ |
43 | 43 | #include <lib3270/log.h> |
44 | 44 | #include <v3270.h> |
45 | 45 | |
46 | - #if ! GLIB_CHECK_VERSION(2,44,0) | |
47 | - | |
48 | - G_GNUC_INTERNAL void v3270_autoptr_cleanup_generic_gfree(void *p); | |
49 | - | |
50 | - #define g_autofree __attribute__((cleanup(v3270_autoptr_cleanup_generic_gfree))) | |
51 | - | |
52 | - #endif // ! GLIB(2,44,0) | |
53 | - | |
54 | - G_BEGIN_DECLS | |
46 | + G_BEGIN_DECLS | |
55 | 47 | |
56 | 48 | /*--[ Structures ]-----------------------------------------------------------------------------------*/ |
57 | 49 | ... | ... |
src/include/v3270.h
... | ... | @@ -37,6 +37,39 @@ |
37 | 37 | #include <lib3270/popup.h> |
38 | 38 | #include <lib3270/filetransfer.h> |
39 | 39 | |
40 | +#if ! GLIB_CHECK_VERSION(2,44,0) | |
41 | + | |
42 | + LIB3270_EXPORT void v3270_autoptr_cleanup_generic_gfree(void *p); | |
43 | + | |
44 | + #define g_autofree __attribute__((cleanup(v3270_autoptr_cleanup_generic_gfree))) | |
45 | + #define g_autoptr(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_TYPENAME(TypeName) | |
46 | + | |
47 | + static inline void v3270_autoptr_cleanup_GError(GError **error) { | |
48 | + if(*error) { | |
49 | + g_error_free(*error); | |
50 | + *error = NULL; | |
51 | + } | |
52 | + } | |
53 | + | |
54 | + static inline void v3270_autoptr_cleanup_GObject(GObject **object) { | |
55 | + if(*object) { | |
56 | + g_object_unref(*object); | |
57 | + *object = NULL; | |
58 | + } | |
59 | + } | |
60 | + | |
61 | + static inline void v3270_autoptr_cleanup_GVariant(GVariant **variant) { | |
62 | + if(*variant) { | |
63 | + g_variant_unref(*variant) | |
64 | + *variant = NULL; | |
65 | + } | |
66 | + } | |
67 | + | |
68 | + #define V3270_AUTOPTR_FUNC_NAME(TypeName) v3270_autoptr_cleanup_##TypeName | |
69 | + #define v3270_autoptr(TypeName) TypeName * __attribute__ ((__cleanup__(V3270_AUTOPTR_FUNC_NAME(TypeName)))) | |
70 | + | |
71 | +#endif // ! GLIB(2,44,0) | |
72 | + | |
40 | 73 | G_BEGIN_DECLS |
41 | 74 | |
42 | 75 | #define GTK_TYPE_V3270 (v3270_get_type ()) | ... | ... |