X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/4e4e5a6f2694187498445a6ac6f1634ce8141119..14957cd040308e3eeec43d26bae5d76da13fcd85:/wtf/gobject/GRefPtr.cpp diff --git a/wtf/gobject/GRefPtr.cpp b/wtf/gobject/GRefPtr.cpp index e7cf34b..1cd22c5 100644 --- a/wtf/gobject/GRefPtr.cpp +++ b/wtf/gobject/GRefPtr.cpp @@ -19,6 +19,8 @@ #include "config.h" #include "GRefPtr.h" +#if ENABLE(GLIB_SUPPORT) + #include namespace WTF { @@ -35,4 +37,50 @@ template <> void derefGPtr(GHashTable* ptr) g_hash_table_unref(ptr); } +#if GLIB_CHECK_VERSION(2, 24, 0) +template <> GVariant* refGPtr(GVariant* ptr) +{ + if (ptr) + g_variant_ref(ptr); + return ptr; +} + +template <> void derefGPtr(GVariant* ptr) +{ + g_variant_unref(ptr); +} + +#else + +// We do this so that we can avoid including the glib.h header in GRefPtr.h. +typedef struct _GVariant { + bool fake; +} GVariant; + +template <> GVariant* refGPtr(GVariant* ptr) +{ + return ptr; +} + +template <> void derefGPtr(GVariant* ptr) +{ +} + +#endif + +template <> GSource* refGPtr(GSource* ptr) +{ + if (ptr) + g_source_ref(ptr); + return ptr; +} + +template <> void derefGPtr(GSource* ptr) +{ + if (ptr) + g_source_unref(ptr); +} + } // namespace WTF + +#endif // ENABLE(GLIB_SUPPORT)