[gnome-builder/wip/extensions] symbol-resolver: make IdeSymbolResolver an interface



commit 82eb53bc86b2cb6f38852c65a9f012f4c604db78
Author: Christian Hergert <christian hergert me>
Date:   Sat Jun 27 00:57:50 2015 -0700

    symbol-resolver: make IdeSymbolResolver an interface

 libide/clang/ide-clang-symbol-resolver.c |   29 +++++++++++++++++++----------
 libide/clang/ide-clang-symbol-resolver.h |    3 ++-
 libide/ide-symbol-resolver.c             |   23 ++++++++---------------
 libide/ide-symbol-resolver.h             |    6 +++---
 4 files changed, 32 insertions(+), 29 deletions(-)
---
diff --git a/libide/clang/ide-clang-symbol-resolver.c b/libide/clang/ide-clang-symbol-resolver.c
index 6a983f4..6244904 100644
--- a/libide/clang/ide-clang-symbol-resolver.c
+++ b/libide/clang/ide-clang-symbol-resolver.c
@@ -28,10 +28,16 @@
 
 struct _IdeClangSymbolResolver
 {
-  IdeSymbolResolver parent_instance;
+  IdeObject parent_instance;
 };
 
-G_DEFINE_TYPE (IdeClangSymbolResolver, ide_clang_symbol_resolver, IDE_TYPE_SYMBOL_RESOLVER)
+static void symbol_resolver_init (IdeSymbolResolverInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (IdeClangSymbolResolver,
+                         ide_clang_symbol_resolver,
+                         IDE_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (IDE_TYPE_SYMBOL_RESOLVER,
+                                                symbol_resolver_init))
 
 static void
 ide_clang_symbol_resolver_lookup_symbol_cb (GObject      *object,
@@ -321,16 +327,19 @@ ide_clang_symbol_resolver_get_symbol_tree_finish (IdeSymbolResolver  *resolver,
 }
 
 static void
+symbol_resolver_init (IdeSymbolResolverInterface *iface)
+{
+  iface->lookup_symbol_async = ide_clang_symbol_resolver_lookup_symbol_async;
+  iface->lookup_symbol_finish = ide_clang_symbol_resolver_lookup_symbol_finish;
+  iface->get_symbols_async = ide_clang_symbol_resolver_get_symbols_async;
+  iface->get_symbols_finish = ide_clang_symbol_resolver_get_symbols_finish;
+  iface->get_symbol_tree_async = ide_clang_symbol_resolver_get_symbol_tree_async;
+  iface->get_symbol_tree_finish = ide_clang_symbol_resolver_get_symbol_tree_finish;
+}
+
+static void
 ide_clang_symbol_resolver_class_init (IdeClangSymbolResolverClass *klass)
 {
-  IdeSymbolResolverClass *symbol_resolver_class = IDE_SYMBOL_RESOLVER_CLASS (klass);
-
-  symbol_resolver_class->lookup_symbol_async = ide_clang_symbol_resolver_lookup_symbol_async;
-  symbol_resolver_class->lookup_symbol_finish = ide_clang_symbol_resolver_lookup_symbol_finish;
-  symbol_resolver_class->get_symbols_async = ide_clang_symbol_resolver_get_symbols_async;
-  symbol_resolver_class->get_symbols_finish = ide_clang_symbol_resolver_get_symbols_finish;
-  symbol_resolver_class->get_symbol_tree_async = ide_clang_symbol_resolver_get_symbol_tree_async;
-  symbol_resolver_class->get_symbol_tree_finish = ide_clang_symbol_resolver_get_symbol_tree_finish;
 }
 
 static void
diff --git a/libide/clang/ide-clang-symbol-resolver.h b/libide/clang/ide-clang-symbol-resolver.h
index 4cdc57c..8fef4c5 100644
--- a/libide/clang/ide-clang-symbol-resolver.h
+++ b/libide/clang/ide-clang-symbol-resolver.h
@@ -26,7 +26,8 @@ G_BEGIN_DECLS
 #define IDE_TYPE_CLANG_SYMBOL_RESOLVER (ide_clang_symbol_resolver_get_type())
 
 G_DECLARE_FINAL_TYPE (IdeClangSymbolResolver, ide_clang_symbol_resolver,
-                      IDE, CLANG_SYMBOL_RESOLVER, IdeSymbolResolver)
+                      IDE, CLANG_SYMBOL_RESOLVER,
+                      IdeObject)
 
 G_END_DECLS
 
diff --git a/libide/ide-symbol-resolver.c b/libide/ide-symbol-resolver.c
index 2e9cdda..3bab6ad 100644
--- a/libide/ide-symbol-resolver.c
+++ b/libide/ide-symbol-resolver.c
@@ -19,15 +19,10 @@
 #include "ide-file.h"
 #include "ide-symbol-resolver.h"
 
-G_DEFINE_ABSTRACT_TYPE (IdeSymbolResolver, ide_symbol_resolver, IDE_TYPE_OBJECT)
+G_DEFINE_INTERFACE (IdeSymbolResolver, ide_symbol_resolver, IDE_TYPE_OBJECT)
 
 static void
-ide_symbol_resolver_class_init (IdeSymbolResolverClass *klass)
-{
-}
-
-static void
-ide_symbol_resolver_init (IdeSymbolResolver *self)
+ide_symbol_resolver_default_init (IdeSymbolResolverInterface *iface)
 {
 }
 
@@ -54,8 +49,7 @@ ide_symbol_resolver_lookup_symbol_async  (IdeSymbolResolver   *self,
   g_return_if_fail (location != NULL);
   g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
 
-  IDE_SYMBOL_RESOLVER_GET_CLASS (self)->
-    lookup_symbol_async (self, location, cancellable, callback, user_data);
+  IDE_SYMBOL_RESOLVER_GET_IFACE (self)->lookup_symbol_async (self, location, cancellable, callback, 
user_data);
 }
 
 /**
@@ -77,7 +71,7 @@ ide_symbol_resolver_lookup_symbol_finish (IdeSymbolResolver  *self,
   g_return_val_if_fail (IDE_IS_SYMBOL_RESOLVER (self), NULL);
   g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL);
 
-  return IDE_SYMBOL_RESOLVER_GET_CLASS (self)->lookup_symbol_finish (self, result, error);
+  return IDE_SYMBOL_RESOLVER_GET_IFACE (self)->lookup_symbol_finish (self, result, error);
 }
 
 void
@@ -91,8 +85,7 @@ ide_symbol_resolver_get_symbols_async (IdeSymbolResolver   *self,
   g_return_if_fail (IDE_IS_FILE (file));
   g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
 
-  IDE_SYMBOL_RESOLVER_GET_CLASS (self)->
-    get_symbols_async (self, file, cancellable, callback, user_data);
+  IDE_SYMBOL_RESOLVER_GET_IFACE (self)->get_symbols_async (self, file, cancellable, callback, user_data);
 }
 
 /**
@@ -112,7 +105,7 @@ ide_symbol_resolver_get_symbols_finish (IdeSymbolResolver  *self,
   g_return_val_if_fail (IDE_IS_SYMBOL_RESOLVER (self), NULL);
   g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL);
 
-  return IDE_SYMBOL_RESOLVER_GET_CLASS (self)->get_symbols_finish (self, result, error);
+  return IDE_SYMBOL_RESOLVER_GET_IFACE (self)->get_symbols_finish (self, result, error);
 }
 
 void
@@ -125,7 +118,7 @@ ide_symbol_resolver_get_symbol_tree_async (IdeSymbolResolver   *self,
   g_return_if_fail (IDE_IS_SYMBOL_RESOLVER (self));
   g_return_if_fail (G_IS_FILE (file));
 
-  IDE_SYMBOL_RESOLVER_GET_CLASS (self)->get_symbol_tree_async (self, file, cancellable, callback, user_data);
+  IDE_SYMBOL_RESOLVER_GET_IFACE (self)->get_symbol_tree_async (self, file, cancellable, callback, user_data);
 }
 
 /**
@@ -143,5 +136,5 @@ ide_symbol_resolver_get_symbol_tree_finish (IdeSymbolResolver  *self,
   g_return_val_if_fail (IDE_IS_SYMBOL_RESOLVER (self), NULL);
   g_return_val_if_fail (!result || G_IS_ASYNC_RESULT (result), NULL);
 
-  return IDE_SYMBOL_RESOLVER_GET_CLASS (self)->get_symbol_tree_finish (self, result, error);
+  return IDE_SYMBOL_RESOLVER_GET_IFACE (self)->get_symbol_tree_finish (self, result, error);
 }
diff --git a/libide/ide-symbol-resolver.h b/libide/ide-symbol-resolver.h
index c216cda..9ace3bd 100644
--- a/libide/ide-symbol-resolver.h
+++ b/libide/ide-symbol-resolver.h
@@ -27,11 +27,11 @@ G_BEGIN_DECLS
 
 #define IDE_TYPE_SYMBOL_RESOLVER (ide_symbol_resolver_get_type())
 
-G_DECLARE_DERIVABLE_TYPE (IdeSymbolResolver, ide_symbol_resolver, IDE, SYMBOL_RESOLVER, IdeObject)
+G_DECLARE_INTERFACE (IdeSymbolResolver, ide_symbol_resolver, IDE, SYMBOL_RESOLVER, IdeObject)
 
-struct _IdeSymbolResolverClass
+struct _IdeSymbolResolverInterface
 {
-  IdeObjectClass parent;
+  GTypeInterface parent_iface;
 
   void           (*lookup_symbol_async)    (IdeSymbolResolver    *self,
                                             IdeSourceLocation    *location,


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