[beast/devel: 5/26] PLUGINS: make BseAdder a resident type plugin



commit b0cc36261cb32bf4287afa10d14fe2bebccff500
Author: Tim Janik <timj gnu org>
Date:   Mon Dec 17 20:04:44 2012 +0100

    PLUGINS: make BseAdder a resident type plugin

 plugins/bseadder.cc |   54 +++++++++++++++++++++++++++++++++++++-------------
 plugins/bseadder.h  |    2 +-
 2 files changed, 41 insertions(+), 15 deletions(-)
---
diff --git a/plugins/bseadder.cc b/plugins/bseadder.cc
index aa4a558..4b396be 100644
--- a/plugins/bseadder.cc
+++ b/plugins/bseadder.cc
@@ -17,6 +17,9 @@
 #include "bseadder.h"
 
 #include <bse/bseengine.h>
+#include <bse/bsecategories.h>
+#include <bse/bseplugin.h>
+#include <sfi/sficxx.hh>
 
 #include <string.h>
 
@@ -32,7 +35,6 @@ enum
 /* --- prototypes --- */
 static void	 bse_adder_init			(BseAdder	*self);
 static void	 bse_adder_class_init		(BseAdderClass	*klass);
-static void      bse_adder_class_finalize       (BseAdderClass  *klass);
 static void	 bse_adder_set_property		(GObject        *object,
 						 guint           param_id,
 						 const GValue   *value,
@@ -50,14 +52,45 @@ static void	 bse_adder_update_modules	(BseAdder	*self,
 
 
 /* --- Export to BSE --- */
+static GType
+bse_adder_get_type ()
+{
+  static const GTypeInfo type_info = {
+    sizeof (BseAdderClass),
+    (GBaseInitFunc) NULL,
+    (GBaseFinalizeFunc) NULL,
+    (GClassInitFunc) bse_adder_class_init,
+    (GClassFinalizeFunc) NULL,
+    NULL /* class_data */,
+    sizeof (BseAdder),
+    0 /* n_preallocs */,
+    (GInstanceInitFunc) bse_adder_init,
+  };
 #include "./icons/sum.c"
-BSE_REGISTER_OBJECT (BseAdder, BseSource, "/Modules/Routing/Adder", "deprecated",
-                     "The Adder is a very simplisitic prototype mixer that just sums up "
-                     "incoming signals (it does allow for switching to subtract mode though)",
-                     sum_icon,
-                     bse_adder_class_init, bse_adder_class_finalize, bse_adder_init);
-BSE_DEFINE_EXPORTS ();
+  static GType type_id = 0;
+  if (!type_id)
+    {
+      type_id = bse_type_register_static (BSE_TYPE_SOURCE,
+                                          "BseAdder",
+                                          "The Adder is a very simplisitic prototype mixer that just sums up "
+                                          "incoming signals (it does allow for switching to subtract mode though)",
+                                          __FILE__, __LINE__,
+                                          &type_info);
+      bse_categories_register_stock_module (N_("Routing/Adder"), type_id, sum_icon); // FIXME: deprecated
+    }
+  return type_id;
+}
 
+static void
+init_adder ()
+{
+  // make this plugin resident to allow static type registration
+  bse_plugin_make_resident();
+  // force registration of plugin types
+  volatile GType types = BSE_TYPE_ADDER;
+  (void) types;
+}
+static Sfi::Init onload (init_adder);
 
 /* --- variables --- */
 static gpointer		 parent_class = NULL;
@@ -101,13 +134,6 @@ bse_adder_class_init (BseAdderClass *klass)
 }
 
 static void
-bse_adder_class_finalize (BseAdderClass *klass)
-{
-  bse_icon_free (klass->sub_icon);
-  klass->sub_icon = NULL;
-}
-
-static void
 bse_adder_init (BseAdder *self)
 {
   self->subtract = FALSE;
diff --git a/plugins/bseadder.h b/plugins/bseadder.h
index ff44a4f..2e29af1 100644
--- a/plugins/bseadder.h
+++ b/plugins/bseadder.h
@@ -28,7 +28,7 @@ extern "C" {
 
 
 /* --- object type macros --- */
-#define BSE_TYPE_ADDER              (BSE_EXPORT_TYPE_ID (BseAdder))
+#define BSE_TYPE_ADDER              (bse_adder_get_type())
 #define BSE_ADDER(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), BSE_TYPE_ADDER, BseAdder))
 #define BSE_ADDER_CLASS(class)      (G_TYPE_CHECK_CLASS_CAST ((class), BSE_TYPE_ADDER, BseAdderClass))
 #define BSE_IS_ADDER(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), BSE_TYPE_ADDER))



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