[gnome-builder] libide: add IdeDiagnostic boxed type



commit a3dcf7218e30cb2c6762bbf74a3b2e9e7f282b3e
Author: Christian Hergert <christian hergert me>
Date:   Wed Feb 11 19:09:27 2015 -0800

    libide: add IdeDiagnostic boxed type

 libide/Makefile.am      |    1 +
 libide/ide-diagnostic.c |   51 +++++++++++++++++++++++++++++++++++++++++++++++
 libide/ide-diagnostic.h |   16 ++++----------
 3 files changed, 57 insertions(+), 11 deletions(-)
---
diff --git a/libide/Makefile.am b/libide/Makefile.am
index 24cd827..10e9997 100644
--- a/libide/Makefile.am
+++ b/libide/Makefile.am
@@ -53,6 +53,7 @@ libide_la_SOURCES = \
        libide/ide-device.h \
        libide/ide-diagnostic-provider.c \
        libide/ide-diagnostic-provider.h \
+       libide/ide-diagnostic.c \
        libide/ide-diagnostic.h \
        libide/ide-diagnostician.c \
        libide/ide-diagnostician.h \
diff --git a/libide/ide-diagnostic.c b/libide/ide-diagnostic.c
new file mode 100644
index 0000000..856c0bd
--- /dev/null
+++ b/libide/ide-diagnostic.c
@@ -0,0 +1,51 @@
+/* ide-diagnostic.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This file 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "ide-diagnostic.h"
+
+G_DEFINE_BOXED_TYPE (IdeDiagnostic, ide_diagnostic,
+                     ide_diagnostic_ref, ide_diagnostic_unref)
+
+struct _IdeDiagnostic
+{
+  volatile gint ref_count;
+};
+
+IdeDiagnostic *
+ide_diagnostic_ref (IdeDiagnostic *self)
+{
+  g_return_val_if_fail (self, NULL);
+  g_return_val_if_fail (self->ref_count > 0, NULL);
+
+  g_atomic_int_inc (&self->ref_count);
+
+  return self;
+}
+
+void
+ide_diagnostic_unref (IdeDiagnostic *self)
+{
+  g_return_if_fail (self);
+  g_return_if_fail (self->ref_count > 0);
+
+  if (g_atomic_int_dec_and_test (&self->ref_count))
+    {
+      g_slice_free (IdeDiagnostic, self);
+    }
+}
+
diff --git a/libide/ide-diagnostic.h b/libide/ide-diagnostic.h
index f077f45..0c934b7 100644
--- a/libide/ide-diagnostic.h
+++ b/libide/ide-diagnostic.h
@@ -19,21 +19,15 @@
 #ifndef IDE_DIAGNOSTIC_H
 #define IDE_DIAGNOSTIC_H
 
-#include <glib-object.h>
+#include "ide-types.h"
 
 G_BEGIN_DECLS
 
-#define IDE_TYPE_DIAGNOSTIC               (ide_diagnostic_get_type ())
-#define IDE_DIAGNOSTIC(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), IDE_TYPE_DIAGNOSTIC, 
IdeDiagnostic))
-#define IDE_IS_DIAGNOSTIC(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IDE_TYPE_DIAGNOSTIC))
-#define IDE_DIAGNOSTIC_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), IDE_TYPE_DIAGNOSTIC, 
IdeDiagnosticInterface))
+#define IDE_TYPE_DIAGNOSTIC (ide_diagnostic_get_type())
 
-struct _IdeDiagnosticInterface
-{
-  GTypeInterface parent;
-};
-
-GType ide_diagnostic_get_type (void);
+GType          ide_diagnostic_get_type (void);
+IdeDiagnostic *ide_diagnostic_ref      (IdeDiagnostic *self);
+void           ide_diagnostic_unref    (IdeDiagnostic *self);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]